dinput: Use the ARRAY_SIZE() macro.
Signed-off-by: Michael Stefaniuc <mstefani@winehq.org> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
be25106503
commit
6710a0485d
|
@ -95,7 +95,7 @@ static void init_listview_columns(HWND dialog)
|
|||
GetClientRect(GetDlgItem(dialog, IDC_DEVICEOBJECTSLIST), &viewRect);
|
||||
width = (viewRect.right - viewRect.left)/2;
|
||||
|
||||
LoadStringW(hinstance, IDS_OBJECTCOLUMN, column, sizeof(column)/sizeof(column[0]));
|
||||
LoadStringW(hinstance, IDS_OBJECTCOLUMN, column, ARRAY_SIZE(column));
|
||||
listColumn.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;
|
||||
listColumn.pszText = column;
|
||||
listColumn.cchTextMax = lstrlenW(listColumn.pszText);
|
||||
|
@ -103,7 +103,7 @@ static void init_listview_columns(HWND dialog)
|
|||
|
||||
SendDlgItemMessageW (dialog, IDC_DEVICEOBJECTSLIST, LVM_INSERTCOLUMNW, 0, (LPARAM) &listColumn);
|
||||
|
||||
LoadStringW(hinstance, IDS_ACTIONCOLUMN, column, sizeof(column)/sizeof(column[0]));
|
||||
LoadStringW(hinstance, IDS_ACTIONCOLUMN, column, ARRAY_SIZE(column));
|
||||
listColumn.cx = width;
|
||||
listColumn.pszText = column;
|
||||
listColumn.cchTextMax = lstrlenW(listColumn.pszText);
|
||||
|
|
|
@ -80,7 +80,7 @@ static void _dump_cooperativelevel_DI(DWORD dwFlags) {
|
|||
#undef FE
|
||||
};
|
||||
TRACE(" cooperative level : ");
|
||||
for (i = 0; i < (sizeof(flags) / sizeof(flags[0])); i++)
|
||||
for (i = 0; i < ARRAY_SIZE(flags); i++)
|
||||
if (flags[i].mask & dwFlags)
|
||||
TRACE("%s ",flags[i].name);
|
||||
TRACE("\n");
|
||||
|
@ -106,7 +106,7 @@ static void _dump_ObjectDataFormat_flags(DWORD dwFlags) {
|
|||
TRACE("Flags:");
|
||||
|
||||
/* First the flags */
|
||||
for (i = 0; i < (sizeof(flags) / sizeof(flags[0])); i++) {
|
||||
for (i = 0; i < ARRAY_SIZE(flags); i++) {
|
||||
if (flags[i].mask & dwFlags)
|
||||
TRACE(" %s",flags[i].name);
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ static void _dump_EnumObjects_flags(DWORD dwFlags) {
|
|||
if (type == DIDFT_ALL) {
|
||||
TRACE(" DIDFT_ALL");
|
||||
} else {
|
||||
for (i = 0; i < (sizeof(flags) / sizeof(flags[0])); i++) {
|
||||
for (i = 0; i < ARRAY_SIZE(flags); i++) {
|
||||
if (flags[i].mask & type) {
|
||||
type &= ~flags[i].mask;
|
||||
TRACE(" %s",flags[i].name);
|
||||
|
@ -230,7 +230,7 @@ const char *_dump_dinput_GUID(const GUID *guid) {
|
|||
};
|
||||
if (guid == NULL)
|
||||
return "null GUID";
|
||||
for (i = 0; i < (sizeof(guids) / sizeof(guids[0])); i++) {
|
||||
for (i = 0; i < ARRAY_SIZE(guids); i++) {
|
||||
if (IsEqualGUID(guids[i].guid, guid)) {
|
||||
return guids[i].name;
|
||||
}
|
||||
|
@ -916,7 +916,7 @@ HRESULT _set_action_map(LPDIRECTINPUTDEVICE8W iface, LPDIACTIONFORMATW lpdiaf, L
|
|||
if (dwFlags & DIDSAM_NOUSER)
|
||||
dps.wsz[0] = '\0';
|
||||
else
|
||||
lstrcpynW(dps.wsz, username, sizeof(dps.wsz)/sizeof(WCHAR));
|
||||
lstrcpynW(dps.wsz, username, ARRAY_SIZE(dps.wsz));
|
||||
IDirectInputDevice8_SetProperty(iface, DIPROP_USERNAME, &dps.diph);
|
||||
|
||||
/* Save the settings to disk */
|
||||
|
@ -1323,7 +1323,7 @@ HRESULT WINAPI IDirectInputDevice2WImpl_GetProperty(LPDIRECTINPUTDEVICE8W iface,
|
|||
{
|
||||
if (*device_player->username)
|
||||
{
|
||||
lstrcpynW(ps->wsz, device_player->username, sizeof(ps->wsz)/sizeof(WCHAR));
|
||||
lstrcpynW(ps->wsz, device_player->username, ARRAY_SIZE(ps->wsz));
|
||||
return DI_OK;
|
||||
}
|
||||
else break;
|
||||
|
@ -1428,8 +1428,7 @@ HRESULT WINAPI IDirectInputDevice2WImpl_SetProperty(
|
|||
device_player->instance_guid = This->guid;
|
||||
}
|
||||
if (device_player)
|
||||
lstrcpynW(device_player->username, ps->wsz,
|
||||
sizeof(device_player->username)/sizeof(WCHAR));
|
||||
lstrcpynW(device_player->username, ps->wsz, ARRAY_SIZE(device_player->username));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
|
@ -282,7 +282,7 @@ static void _dump_EnumDevices_dwFlags(DWORD dwFlags)
|
|||
TRACE("DIEDFL_ALLDEVICES\n");
|
||||
return;
|
||||
}
|
||||
for (i = 0; i < (sizeof(flags) / sizeof(flags[0])); i++)
|
||||
for (i = 0; i < ARRAY_SIZE(flags); i++)
|
||||
if (flags[i].mask & dwFlags)
|
||||
TRACE("%s ",flags[i].name);
|
||||
}
|
||||
|
@ -1090,7 +1090,7 @@ static HRESULT WINAPI IDirectInput8AImpl_EnumDevicesBySemantics(
|
|||
/* Add keyboard and mouse to remaining device count */
|
||||
if (!(dwFlags & DIEDBSFL_FORCEFEEDBACK))
|
||||
{
|
||||
for (i = 0; i < sizeof(guids) / sizeof(guids[0]); i++)
|
||||
for (i = 0; i < ARRAY_SIZE(guids); i++)
|
||||
{
|
||||
if (should_enumerate_device(username_w, dwFlags, &This->device_players, guids[i]))
|
||||
remain++;
|
||||
|
@ -1119,7 +1119,7 @@ static HRESULT WINAPI IDirectInput8AImpl_EnumDevicesBySemantics(
|
|||
}
|
||||
|
||||
/* Enumerate keyboard and mouse */
|
||||
for(i=0; i < sizeof(guids)/sizeof(guids[0]); i++)
|
||||
for (i = 0; i < ARRAY_SIZE(guids); i++)
|
||||
{
|
||||
if (should_enumerate_device(username_w, dwFlags, &This->device_players, guids[i]))
|
||||
{
|
||||
|
@ -1191,7 +1191,7 @@ static HRESULT WINAPI IDirectInput8WImpl_EnumDevicesBySemantics(
|
|||
/* Add keyboard and mouse to remaining device count */
|
||||
if (!(dwFlags & DIEDBSFL_FORCEFEEDBACK))
|
||||
{
|
||||
for (i = 0; i < sizeof(guids) / sizeof(guids[0]); i++)
|
||||
for (i = 0; i < ARRAY_SIZE(guids); i++)
|
||||
{
|
||||
if (should_enumerate_device(ptszUserName, dwFlags, &This->device_players, guids[i]))
|
||||
remain++;
|
||||
|
@ -1215,7 +1215,7 @@ static HRESULT WINAPI IDirectInput8WImpl_EnumDevicesBySemantics(
|
|||
if (dwFlags & DIEDBSFL_FORCEFEEDBACK) return DI_OK;
|
||||
|
||||
/* Enumerate keyboard and mouse */
|
||||
for(i=0; i < sizeof(guids)/sizeof(guids[0]); i++)
|
||||
for (i = 0; i < ARRAY_SIZE(guids); i++)
|
||||
{
|
||||
if (should_enumerate_device(ptszUserName, dwFlags, &This->device_players, guids[i]))
|
||||
{
|
||||
|
|
|
@ -92,7 +92,7 @@ static void _dump_DIEFFECT_flags(DWORD dwFlags)
|
|||
FE(DIEFF_SPHERICAL)
|
||||
#undef FE
|
||||
};
|
||||
for (i = 0; i < (sizeof(flags) / sizeof(flags[0])); i++)
|
||||
for (i = 0; i < ARRAY_SIZE(flags); i++)
|
||||
if (flags[i].mask & dwFlags)
|
||||
TRACE("%s ", flags[i].name);
|
||||
TRACE("\n");
|
||||
|
@ -786,7 +786,7 @@ HRESULT WINAPI JoystickWGenericImpl_BuildActionMap(LPDIRECTINPUTDEVICE8W iface,
|
|||
/* Only consider actions of the right genre */
|
||||
if (lpdiaf->dwGenre != genre && genre != DIGENRE_ANY) continue;
|
||||
|
||||
for (j=0; j < sizeof(object_types)/sizeof(object_types[0]); j++)
|
||||
for (j = 0; j < ARRAY_SIZE(object_types); j++)
|
||||
{
|
||||
if (type & object_types[j])
|
||||
{
|
||||
|
@ -979,7 +979,7 @@ HRESULT setup_dinput_options(JoystickGenericImpl *This, const int *default_axis_
|
|||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < sizeof(axis_names) / sizeof(axis_names[0]); i++)
|
||||
for (i = 0; i < ARRAY_SIZE(axis_names); i++)
|
||||
{
|
||||
if (!strcmp(ptr, axis_names[i]))
|
||||
{
|
||||
|
@ -1011,7 +1011,7 @@ HRESULT setup_dinput_options(JoystickGenericImpl *This, const int *default_axis_
|
|||
}
|
||||
}
|
||||
|
||||
if (i == sizeof(axis_names) / sizeof(axis_names[0]))
|
||||
if (i == ARRAY_SIZE(axis_names))
|
||||
{
|
||||
ERR("invalid joystick axis type: \"%s\"\n", ptr);
|
||||
i = -1;
|
||||
|
|
|
@ -279,7 +279,7 @@ static const char* debugstr_cf(CFTypeRef t)
|
|||
if (!ret)
|
||||
{
|
||||
UniChar buf[200];
|
||||
int len = min(CFStringGetLength(s), sizeof(buf)/sizeof(buf[0]));
|
||||
int len = min(CFStringGetLength(s), ARRAY_SIZE(buf));
|
||||
CFStringGetCharacters(s, CFRangeMake(0, len), buf);
|
||||
ret = debugstr_wn(buf, len);
|
||||
}
|
||||
|
|
|
@ -508,7 +508,7 @@ static HRESULT WINAPI SysKeyboardWImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface
|
|||
|
||||
scan = map_dik_to_scan(DIDFT_GETINSTANCE(pdidoi->dwType), This->subtype);
|
||||
if (!GetKeyNameTextW((scan & 0x80) << 17 | (scan & 0x7f) << 16,
|
||||
pdidoi->tszName, sizeof(pdidoi->tszName)/sizeof(pdidoi->tszName[0])))
|
||||
pdidoi->tszName, ARRAY_SIZE(pdidoi->tszName)))
|
||||
return DIERR_OBJECTNOTFOUND;
|
||||
|
||||
_dump_OBJECTINSTANCEW(pdidoi);
|
||||
|
|
Loading…
Reference in New Issue