Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/device.c | 1 + dlls/dinput8/tests/hid.c | 1 - 2 files changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c index 17eaff69d50..2a3ed391919 100644 --- a/dlls/dinput/device.c +++ b/dlls/dinput/device.c @@ -1094,6 +1094,7 @@ HRESULT WINAPI IDirectInputDevice2WImpl_SetDataFormat(LPDIRECTINPUTDEVICE8W ifac _dump_DIDATAFORMAT(df);
if (df->dwSize != sizeof(DIDATAFORMAT)) return DIERR_INVALIDPARAM; + if (df->dwObjSize != sizeof(DIOBJECTDATAFORMAT)) return DIERR_INVALIDPARAM; if (This->acquired) return DIERR_ACQUIRED;
EnterCriticalSection(&This->crit); diff --git a/dlls/dinput8/tests/hid.c b/dlls/dinput8/tests/hid.c index 371edc99251..e017e048a30 100644 --- a/dlls/dinput8/tests/hid.c +++ b/dlls/dinput8/tests/hid.c @@ -4015,7 +4015,6 @@ static void test_simple_joystick(void) ok( hr == DIERR_INVALIDPARAM, "IDirectInputDevice8_SetDataFormat returned: %#x\n", hr ); dataformat.dwSize = sizeof(DIDATAFORMAT); hr = IDirectInputDevice8_SetDataFormat( device, &dataformat ); - todo_wine ok( hr == DIERR_INVALIDPARAM, "IDirectInputDevice8_SetDataFormat returned: %#x\n", hr ); dataformat.dwObjSize = sizeof(DIOBJECTDATAFORMAT); hr = IDirectInputDevice8_SetDataFormat( device, &dataformat );
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/device.c | 12 +++++++++--- dlls/dinput8/tests/hid.c | 1 - 2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c index 2a3ed391919..11496640049 100644 --- a/dlls/dinput/device.c +++ b/dlls/dinput/device.c @@ -1118,6 +1118,7 @@ HRESULT WINAPI IDirectInputDevice2WImpl_SetDataFormat(LPDIRECTINPUTDEVICE8W ifac HRESULT WINAPI IDirectInputDevice2WImpl_SetCooperativeLevel(LPDIRECTINPUTDEVICE8W iface, HWND hwnd, DWORD dwflags) { IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8W(iface); + HRESULT hr;
TRACE("(%p) %p,0x%08x\n", This, hwnd, dwflags); _dump_cooperativelevel_DI(dwflags); @@ -1144,11 +1145,16 @@ HRESULT WINAPI IDirectInputDevice2WImpl_SetCooperativeLevel(LPDIRECTINPUTDEVICE8
/* Store the window which asks for the mouse */ EnterCriticalSection(&This->crit); - This->win = hwnd; - This->dwCoopLevel = dwflags; + if (This->acquired) hr = DIERR_ACQUIRED; + else + { + This->win = hwnd; + This->dwCoopLevel = dwflags; + hr = DI_OK; + } LeaveCriticalSection(&This->crit);
- return DI_OK; + return hr; }
/****************************************************************************** diff --git a/dlls/dinput8/tests/hid.c b/dlls/dinput8/tests/hid.c index e017e048a30..c0f1b78160c 100644 --- a/dlls/dinput8/tests/hid.c +++ b/dlls/dinput8/tests/hid.c @@ -4082,7 +4082,6 @@ static void test_simple_joystick(void) hr = IDirectInputDevice8_Acquire( device ); ok( hr == DI_OK, "IDirectInputDevice8_Acquire returned: %#x\n", hr ); hr = IDirectInputDevice8_SetCooperativeLevel( device, hwnd, DISCL_FOREGROUND | DISCL_EXCLUSIVE ); - todo_wine ok( hr == DIERR_ACQUIRED, "IDirectInputDevice8_SetCooperativeLevel returned: %#x\n", hr ); hr = IDirectInputDevice8_Unacquire( device ); ok( hr == DI_OK, "IDirectInputDevice8_Unacquire returned: %#x\n", hr );
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/joystick_hid.c | 4 ++++ dlls/dinput8/tests/hid.c | 13 +++++-------- 2 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c index f7107733d26..acd21001bdf 100644 --- a/dlls/dinput/joystick_hid.c +++ b/dlls/dinput/joystick_hid.c @@ -248,6 +248,7 @@ static BOOL enum_value_objects( struct hid_joystick *impl, const DIPROPHEADER *f instance.wUsage = caps.value->NotRange.Usage; instance.guidType = *object_usage_to_guid( instance.wUsagePage, instance.wUsage ); instance.wReportId = caps.value->ReportID; + instance.wCollectionNumber = caps.value->LinkCollection;
switch (instance.wUsage) { @@ -348,6 +349,7 @@ static BOOL enum_button_objects( struct hid_joystick *impl, const DIPROPHEADER * instance.wUsage = j; instance.guidType = *object_usage_to_guid( instance.wUsagePage, instance.wUsage ); instance.wReportId = caps.button->ReportID; + instance.wCollectionNumber = caps.button->LinkCollection; ret = enum_object( impl, filter, flags, callback, &caps, &instance, data ); if (ret != DIENUM_CONTINUE) return ret; } @@ -363,6 +365,7 @@ static BOOL enum_button_objects( struct hid_joystick *impl, const DIPROPHEADER * instance.wUsage = caps.button->NotRange.Usage; instance.guidType = *object_usage_to_guid( instance.wUsagePage, instance.wUsage ); instance.wReportId = caps.button->ReportID; + instance.wCollectionNumber = caps.button->LinkCollection; ret = enum_object( impl, filter, flags, callback, &caps, &instance, data ); if (ret != DIENUM_CONTINUE) return ret; } @@ -396,6 +399,7 @@ static BOOL enum_collections_objects( struct hid_joystick *impl, const DIPROPHEA instance.wUsage = caps.node->LinkUsage; instance.guidType = *object_usage_to_guid( instance.wUsagePage, instance.wUsage ); instance.wReportId = 0; + instance.wCollectionNumber = caps.node->Parent; ret = enum_object( impl, filter, flags, callback, &caps, &instance, data ); if (ret != DIENUM_CONTINUE) return ret; } diff --git a/dlls/dinput8/tests/hid.c b/dlls/dinput8/tests/hid.c index c0f1b78160c..23dc3f6d5f8 100644 --- a/dlls/dinput8/tests/hid.c +++ b/dlls/dinput8/tests/hid.c @@ -3567,11 +3567,11 @@ static void test_simple_joystick(void) }; const struct check_objects_todos objects_todos[ARRAY_SIZE(expect_objects)] = { - {.ofs = TRUE, .type = TRUE, .collection_number = TRUE}, - {.ofs = TRUE, .type = TRUE, .collection_number = TRUE}, - {.ofs = TRUE, .collection_number = TRUE}, - {.ofs = TRUE, .collection_number = TRUE}, - {.ofs = TRUE, .collection_number = TRUE}, + {.ofs = TRUE, .type = TRUE}, + {.ofs = TRUE, .type = TRUE}, + {.ofs = TRUE}, + {.ofs = TRUE}, + {.ofs = TRUE}, {}, {.type = TRUE}, }; @@ -3968,7 +3968,6 @@ static void test_simple_joystick(void) if (!localized) todo_wine check_member_wstr( objinst, expect_objects[1], tszName ); check_member( objinst, expect_objects[1], "%u", dwFFMaxForce ); check_member( objinst, expect_objects[1], "%u", dwFFForceResolution ); - todo_wine check_member( objinst, expect_objects[1], "%u", wCollectionNumber ); check_member( objinst, expect_objects[1], "%u", wDesignatorIndex ); check_member( objinst, expect_objects[1], "%#04x", wUsagePage ); @@ -4000,7 +3999,6 @@ static void test_simple_joystick(void) if (!localized) todo_wine check_member_wstr( objinst, expect_objects[4], tszName ); check_member( objinst, expect_objects[4], "%u", dwFFMaxForce ); check_member( objinst, expect_objects[4], "%u", dwFFForceResolution ); - todo_wine check_member( objinst, expect_objects[4], "%u", wCollectionNumber ); check_member( objinst, expect_objects[4], "%u", wDesignatorIndex ); check_member( objinst, expect_objects[4], "%#04x", wUsagePage ); @@ -4035,7 +4033,6 @@ static void test_simple_joystick(void) if (!localized) todo_wine check_member_wstr( objinst, expect_objects[0], tszName ); check_member( objinst, expect_objects[0], "%u", dwFFMaxForce ); check_member( objinst, expect_objects[0], "%u", dwFFForceResolution ); - todo_wine check_member( objinst, expect_objects[0], "%u", wCollectionNumber ); check_member( objinst, expect_objects[0], "%u", wDesignatorIndex ); check_member( objinst, expect_objects[0], "%#04x", wUsagePage );
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/joystick_hid.c | 4 ++-- dlls/dinput8/tests/hid.c | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c index acd21001bdf..4d7bbe82a23 100644 --- a/dlls/dinput/joystick_hid.c +++ b/dlls/dinput/joystick_hid.c @@ -379,8 +379,8 @@ static BOOL enum_collections_objects( struct hid_joystick *impl, const DIPROPHEA { DIDEVICEOBJECTINSTANCEW instance = {.dwSize = sizeof(DIDEVICEOBJECTINSTANCEW)}; struct hid_caps caps = {.type = LINK_COLLECTION_NODE}; + DWORD collection = 0, i; BOOL ret; - DWORD i;
for (i = 0; i < impl->caps.NumberLinkCollectionNodes; ++i) { @@ -393,7 +393,7 @@ static BOOL enum_collections_objects( struct hid_joystick *impl, const DIPROPHEA else { instance.dwOfs = 0; - instance.dwType = DIDFT_COLLECTION | DIDFT_NODATA; + instance.dwType = DIDFT_COLLECTION | DIDFT_MAKEINSTANCE( collection++ ) | DIDFT_NODATA; instance.dwFlags = 0; instance.wUsagePage = caps.node->LinkUsagePage; instance.wUsage = caps.node->LinkUsage; diff --git a/dlls/dinput8/tests/hid.c b/dlls/dinput8/tests/hid.c index 23dc3f6d5f8..54d85cae14b 100644 --- a/dlls/dinput8/tests/hid.c +++ b/dlls/dinput8/tests/hid.c @@ -3572,8 +3572,6 @@ static void test_simple_joystick(void) {.ofs = TRUE}, {.ofs = TRUE}, {.ofs = TRUE}, - {}, - {.type = TRUE}, };
struct check_objects_params check_objects_params =
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/joystick_hid.c | 23 +++++++++++++++-------- dlls/dinput8/tests/hid.c | 6 ++---- 2 files changed, 17 insertions(+), 12 deletions(-)
diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c index 4d7bbe82a23..11c23cfd58f 100644 --- a/dlls/dinput/joystick_hid.c +++ b/dlls/dinput/joystick_hid.c @@ -220,13 +220,20 @@ static BOOL enum_object( struct hid_joystick *impl, const DIPROPHEADER *filter, return DIENUM_CONTINUE; }
+static void set_axis_type( DIDEVICEOBJECTINSTANCEW *instance, BOOL *seen, DWORD i, DWORD *count ) +{ + if (!seen[i]) instance->dwType = DIDFT_ABSAXIS | DIDFT_MAKEINSTANCE( i ); + else instance->dwType = DIDFT_ABSAXIS | DIDFT_MAKEINSTANCE( 6 + *count++ ); + seen[i] = TRUE; +} + static BOOL enum_value_objects( struct hid_joystick *impl, const DIPROPHEADER *filter, DWORD flags, enum_object_callback callback, void *data ) { DIDEVICEOBJECTINSTANCEW instance = {.dwSize = sizeof(DIDEVICEOBJECTINSTANCEW)}; struct hid_caps caps = {.type = VALUE_CAPS}; + BOOL ret, seen_axis[6] = {0}; DWORD axis = 0, pov = 0, i; - BOOL ret;
for (i = 0; i < impl->caps.NumberInputValueCaps; ++i) { @@ -254,49 +261,49 @@ static BOOL enum_value_objects( struct hid_joystick *impl, const DIPROPHEADER *f { case HID_USAGE_GENERIC_X: instance.dwOfs = DIJOFS_X; - instance.dwType = DIDFT_ABSAXIS | DIDFT_MAKEINSTANCE( axis++ ); + set_axis_type( &instance, seen_axis, 0, &axis ); instance.dwFlags = DIDOI_ASPECTPOSITION; ret = enum_object( impl, filter, flags, callback, &caps, &instance, data ); if (ret != DIENUM_CONTINUE) return ret; break; case HID_USAGE_GENERIC_Y: instance.dwOfs = DIJOFS_Y; - instance.dwType = DIDFT_ABSAXIS | DIDFT_MAKEINSTANCE( axis++ ); + set_axis_type( &instance, seen_axis, 1, &axis ); instance.dwFlags = DIDOI_ASPECTPOSITION; ret = enum_object( impl, filter, flags, callback, &caps, &instance, data ); if (ret != DIENUM_CONTINUE) return ret; break; case HID_USAGE_GENERIC_Z: instance.dwOfs = DIJOFS_Z; - instance.dwType = DIDFT_ABSAXIS | DIDFT_MAKEINSTANCE( axis++ ); + set_axis_type( &instance, seen_axis, 2, &axis ); instance.dwFlags = DIDOI_ASPECTPOSITION; ret = enum_object( impl, filter, flags, callback, &caps, &instance, data ); if (ret != DIENUM_CONTINUE) return ret; break; case HID_USAGE_GENERIC_RX: instance.dwOfs = DIJOFS_RX; - instance.dwType = DIDFT_ABSAXIS | DIDFT_MAKEINSTANCE( axis++ ); + set_axis_type( &instance, seen_axis, 3, &axis ); instance.dwFlags = DIDOI_ASPECTPOSITION; ret = enum_object( impl, filter, flags, callback, &caps, &instance, data ); if (ret != DIENUM_CONTINUE) return ret; break; case HID_USAGE_GENERIC_RY: instance.dwOfs = DIJOFS_RY; - instance.dwType = DIDFT_ABSAXIS | DIDFT_MAKEINSTANCE( axis++ ); + set_axis_type( &instance, seen_axis, 4, &axis ); instance.dwFlags = DIDOI_ASPECTPOSITION; ret = enum_object( impl, filter, flags, callback, &caps, &instance, data ); if (ret != DIENUM_CONTINUE) return ret; break; case HID_USAGE_GENERIC_RZ: instance.dwOfs = DIJOFS_RZ; - instance.dwType = DIDFT_ABSAXIS | DIDFT_MAKEINSTANCE( axis++ ); + set_axis_type( &instance, seen_axis, 5, &axis ); instance.dwFlags = DIDOI_ASPECTPOSITION; ret = enum_object( impl, filter, flags, callback, &caps, &instance, data ); if (ret != DIENUM_CONTINUE) return ret; break; case HID_USAGE_GENERIC_SLIDER: instance.dwOfs = DIJOFS_SLIDER( 0 ); - instance.dwType = DIDFT_ABSAXIS | DIDFT_MAKEINSTANCE( axis++ ); + instance.dwType = DIDFT_ABSAXIS | DIDFT_MAKEINSTANCE( 6 + axis++ ); instance.dwFlags = DIDOI_ASPECTPOSITION; ret = enum_object( impl, filter, flags, callback, &caps, &instance, data ); if (ret != DIENUM_CONTINUE) return ret; diff --git a/dlls/dinput8/tests/hid.c b/dlls/dinput8/tests/hid.c index 54d85cae14b..75c9e7cd92a 100644 --- a/dlls/dinput8/tests/hid.c +++ b/dlls/dinput8/tests/hid.c @@ -3567,8 +3567,8 @@ static void test_simple_joystick(void) }; const struct check_objects_todos objects_todos[ARRAY_SIZE(expect_objects)] = { - {.ofs = TRUE, .type = TRUE}, - {.ofs = TRUE, .type = TRUE}, + {.ofs = TRUE}, + {.ofs = TRUE}, {.ofs = TRUE}, {.ofs = TRUE}, {.ofs = TRUE}, @@ -3960,7 +3960,6 @@ static void test_simple_joystick(void) check_member_guid( objinst, expect_objects[1], guidType ); todo_wine check_member( objinst, expect_objects[1], "%#x", dwOfs ); - todo_wine check_member( objinst, expect_objects[1], "%#x", dwType ); check_member( objinst, expect_objects[1], "%#x", dwFlags ); if (!localized) todo_wine check_member_wstr( objinst, expect_objects[1], tszName ); @@ -4025,7 +4024,6 @@ static void test_simple_joystick(void) check_member_guid( objinst, expect_objects[0], guidType ); todo_wine check_member( objinst, expect_objects[0], "%#x", dwOfs ); - todo_wine check_member( objinst, expect_objects[0], "%#x", dwType ); check_member( objinst, expect_objects[0], "%#x", dwFlags ); if (!localized) todo_wine check_member_wstr( objinst, expect_objects[0], tszName );
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/joystick_hid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c index 11c23cfd58f..051ad743cde 100644 --- a/dlls/dinput/joystick_hid.c +++ b/dlls/dinput/joystick_hid.c @@ -1199,7 +1199,7 @@ static BOOL init_objects( struct hid_joystick *impl, struct hid_caps *caps, DIDATAFORMAT *format = impl->base.data_format.wine_df;
format->dwNumObjs++; - if (instance->dwType & DIDFT_PSHBUTTON) impl->dev_caps.dwButtons++; + if (instance->dwType & DIDFT_BUTTON) impl->dev_caps.dwButtons++; if (instance->dwType & DIDFT_AXIS) impl->dev_caps.dwAxes++; if (instance->dwType & DIDFT_POV) impl->dev_caps.dwPOVs++;
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput8/tests/hid.c | 136 ++++++++++++++++++++++++++------------- 1 file changed, 90 insertions(+), 46 deletions(-)
diff --git a/dlls/dinput8/tests/hid.c b/dlls/dinput8/tests/hid.c index 75c9e7cd92a..bd513760794 100644 --- a/dlls/dinput8/tests/hid.c +++ b/dlls/dinput8/tests/hid.c @@ -3286,9 +3286,14 @@ static BOOL CALLBACK find_test_device( const DIDEVICEINSTANCEW *devinst, void *c
struct check_objects_todos { + BOOL guid; BOOL ofs; BOOL type; + BOOL flags; BOOL collection_number; + BOOL usage; + BOOL usage_page; + BOOL report_id; };
struct check_objects_params @@ -3312,11 +3317,13 @@ static BOOL CALLBACK check_objects( const DIDEVICEOBJECTINSTANCEW *obj, void *ar if (params->index >= params->expect_count) exp = &unexpected_obj;
check_member( *obj, *exp, "%u", dwSize ); + todo_wine_if( todo->guid ) check_member_guid( *obj, *exp, guidType ); todo_wine_if( todo->ofs ) check_member( *obj, *exp, "%#x", dwOfs ); todo_wine_if( todo->type ) check_member( *obj, *exp, "%#x", dwType ); + todo_wine_if( todo->flags ) check_member( *obj, *exp, "%#x", dwFlags ); if (!localized) todo_wine check_member_wstr( *obj, *exp, tszName ); check_member( *obj, *exp, "%u", dwFFMaxForce ); @@ -3324,10 +3331,13 @@ static BOOL CALLBACK check_objects( const DIDEVICEOBJECTINSTANCEW *obj, void *ar todo_wine_if( todo->collection_number ) check_member( *obj, *exp, "%u", wCollectionNumber ); check_member( *obj, *exp, "%u", wDesignatorIndex ); + todo_wine_if( todo->usage_page ) check_member( *obj, *exp, "%#04x", wUsagePage ); + todo_wine_if( todo->usage ) check_member( *obj, *exp, "%#04x", wUsage ); check_member( *obj, *exp, "%#04x", dwDimension ); check_member( *obj, *exp, "%#04x", wExponent ); + todo_wine_if( todo->report_id ) check_member( *obj, *exp, "%u", wReportId );
winetest_pop_context(); @@ -3355,6 +3365,8 @@ static void test_simple_joystick(void) COLLECTION(1, Report), REPORT_ID(1, 1),
+ USAGE(1, HID_USAGE_GENERIC_WHEEL), + USAGE(4, (0xff01u<<16)|(0x1234)), USAGE(1, HID_USAGE_GENERIC_X), USAGE(1, HID_USAGE_GENERIC_Y), LOGICAL_MINIMUM(1, 0xe7), @@ -3362,7 +3374,7 @@ static void test_simple_joystick(void) PHYSICAL_MINIMUM(1, 0xe7), PHYSICAL_MAXIMUM(1, 0x38), REPORT_SIZE(1, 8), - REPORT_COUNT(1, 2), + REPORT_COUNT(1, 4), INPUT(1, Data|Var|Abs),
USAGE(1, HID_USAGE_GENERIC_HATSWITCH), @@ -3392,14 +3404,14 @@ static void test_simple_joystick(void)
static const HIDP_CAPS hid_caps = { - .InputReportByteLength = 4, + .InputReportByteLength = 6, }; static const DIDEVCAPS expect_caps = { .dwSize = sizeof(DIDEVCAPS), .dwFlags = DIDC_ATTACHED | DIDC_EMULATED, .dwDevType = DIDEVTYPE_HID | (DI8DEVTYPEJOYSTICK_LIMITED << 8) | DI8DEVTYPE_JOYSTICK, - .dwAxes = 2, + .dwAxes = 3, .dwPOVs = 1, .dwButtons = 2, }; @@ -3407,53 +3419,53 @@ static void test_simple_joystick(void) { { .code = IOCTL_HID_READ_REPORT, - .report_buf = {1,0x10,0x10,0}, + .report_buf = {1,0x10,0x10,0x10,0x10,0}, }, { .code = IOCTL_HID_READ_REPORT, - .report_buf = {1,0x38,0x38,0xf8}, + .report_buf = {1,0x10,0x10,0x38,0x38,0xf8}, }, { .code = IOCTL_HID_READ_REPORT, - .report_buf = {1,0x01,0x01,0x00}, + .report_buf = {1,0x10,0x10,0x01,0x01,0x00}, }, { .code = IOCTL_HID_READ_REPORT, - .report_buf = {1,0x01,0x01,0x00}, + .report_buf = {1,0x10,0x10,0x01,0x01,0x00}, }, { .code = IOCTL_HID_READ_REPORT, - .report_buf = {1,0x80,0x80,0xff}, + .report_buf = {1,0x10,0x10,0x80,0x80,0xff}, }, { .code = IOCTL_HID_READ_REPORT, - .report_buf = {1,0x10,0xee,0x54}, + .report_buf = {1,0x10,0x10,0x10,0xee,0x54}, }, }; static const struct DIJOYSTATE2 expect_state[] = { - {.lX = 32767, .lY = 32767, .rgdwPOV = {-1, -1, -1, -1}, .rgbButtons = {0, 0}}, - {.lX = 32767, .lY = 32767, .rgdwPOV = {-1, -1, -1, -1}, .rgbButtons = {0, 0}}, - {.lX = 65535, .lY = 65535, .rgdwPOV = {31500, -1, -1, -1}, .rgbButtons = {0x80, 0x80}}, - {.lX = 20779, .lY = 20779, .rgdwPOV = {-1, -1, -1, -1}, .rgbButtons = {0, 0}}, - {.lX = 20779, .lY = 20779, .rgdwPOV = {-1, -1, -1, -1}, .rgbButtons = {0, 0}}, - {.lX = 0, .lY = 0, .rgdwPOV = {-1, -1, -1, -1}, .rgbButtons = {0x80, 0x80}}, - {.lX = 32767, .lY = 5594, .rgdwPOV = {13500, -1, -1, -1}, .rgbButtons = {0x80}}, + {.lX = 32767, .lY = 32767, .lZ = 32767, .rgdwPOV = {-1, -1, -1, -1}, .rgbButtons = {0, 0}}, + {.lX = 32767, .lY = 32767, .lZ = 32767, .rgdwPOV = {-1, -1, -1, -1}, .rgbButtons = {0, 0}}, + {.lX = 65535, .lY = 65535, .lZ = 32767, .rgdwPOV = {31500, -1, -1, -1}, .rgbButtons = {0x80, 0x80}}, + {.lX = 20779, .lY = 20779, .lZ = 32767, .rgdwPOV = {-1, -1, -1, -1}, .rgbButtons = {0, 0}}, + {.lX = 20779, .lY = 20779, .lZ = 32767, .rgdwPOV = {-1, -1, -1, -1}, .rgbButtons = {0, 0}}, + {.lX = 0, .lY = 0, .lZ = 32767, .rgdwPOV = {-1, -1, -1, -1}, .rgbButtons = {0x80, 0x80}}, + {.lX = 32767, .lY = 5594, .lZ = 32767, .rgdwPOV = {13500, -1, -1, -1}, .rgbButtons = {0x80}}, }; static const struct DIJOYSTATE2 expect_state_abs[] = { - {.lX = -9000, .lY = 26000, .rgdwPOV = {-1, -1, -1, -1}, .rgbButtons = {0, 0}}, - {.lX = -9000, .lY = 26000, .rgdwPOV = {-1, -1, -1, -1}, .rgbButtons = {0, 0}}, - {.lX = -4000, .lY = 51000, .rgdwPOV = {31500, -1, -1, -1}, .rgbButtons = {0x80, 0x80}}, - {.lX = -10667, .lY = 12905, .rgdwPOV = {-1, -1, -1, -1}, .rgbButtons = {0, 0}}, - {.lX = -10667, .lY = 12905, .rgdwPOV = {-1, -1, -1, -1}, .rgbButtons = {0, 0}}, - {.lX = -14000, .lY = 1000, .rgdwPOV = {-1, -1, -1, -1}, .rgbButtons = {0x80, 0x80}}, - {.lX = -9000, .lY = 1000, .rgdwPOV = {13500, -1, -1, -1}, .rgbButtons = {0x80}}, + {.lX = -9000, .lY = 26000, .lZ = 26000, .rgdwPOV = {-1, -1, -1, -1}, .rgbButtons = {0, 0}}, + {.lX = -9000, .lY = 26000, .lZ = 26000, .rgdwPOV = {-1, -1, -1, -1}, .rgbButtons = {0, 0}}, + {.lX = -4000, .lY = 51000, .lZ = 26000, .rgdwPOV = {31500, -1, -1, -1}, .rgbButtons = {0x80, 0x80}}, + {.lX = -10667, .lY = 12905, .lZ = 26000, .rgdwPOV = {-1, -1, -1, -1}, .rgbButtons = {0, 0}}, + {.lX = -10667, .lY = 12905, .lZ = 26000, .rgdwPOV = {-1, -1, -1, -1}, .rgbButtons = {0, 0}}, + {.lX = -14000, .lY = 1000, .lZ = 26000, .rgdwPOV = {-1, -1, -1, -1}, .rgbButtons = {0x80, 0x80}}, + {.lX = -9000, .lY = 1000, .lZ = 26000, .rgdwPOV = {13500, -1, -1, -1}, .rgbButtons = {0x80}}, }; static const struct DIJOYSTATE2 expect_state_rel[] = { {.lX = 0, .lY = 0, .rgdwPOV = {13500, -1, -1, -1}, .rgbButtons = {0x80, 0}}, - {.lX = 9016, .lY = -984, .rgdwPOV = {-1, -1, -1, -1}, .rgbButtons = {0, 0}}, + {.lX = 9016, .lY = -984, .lZ = -25984, .rgdwPOV = {-1, -1, -1, -1}, .rgbButtons = {0, 0}}, {.lX = 40, .lY = 40, .rgdwPOV = {31500, -1, -1, -1}, .rgbButtons = {0x80, 0x80}}, {.lX = -55, .lY = -55, .rgdwPOV = {-1, -1, -1, -1}, .rgbButtons = {0, 0}}, {.lX = 0, .lY = 0, .rgdwPOV = {-1, -1, -1, -1}, .rgbButtons = {0, 0}}, @@ -3515,10 +3527,22 @@ static void test_simple_joystick(void) .wUsage = HID_USAGE_GENERIC_X, .wReportId = 1, }, + { + .dwSize = sizeof(DIDEVICEOBJECTINSTANCEW), + .guidType = GUID_ZAxis, + .dwOfs = 0xc, + .dwType = DIDFT_ABSAXIS|DIDFT_MAKEINSTANCE(2), + .dwFlags = DIDOI_ASPECTPOSITION, + .tszName = L"Wheel", + .wCollectionNumber = 1, + .wUsagePage = HID_USAGE_PAGE_GENERIC, + .wUsage = HID_USAGE_GENERIC_WHEEL, + .wReportId = 1, + }, { .dwSize = sizeof(DIDEVICEOBJECTINSTANCEW), .guidType = GUID_POV, - .dwOfs = 0x8, + .dwOfs = 0x10, .dwType = DIDFT_POV|DIDFT_MAKEINSTANCE(0), .tszName = L"Hat Switch", .wCollectionNumber = 1, @@ -3529,7 +3553,7 @@ static void test_simple_joystick(void) { .dwSize = sizeof(DIDEVICEOBJECTINSTANCEW), .guidType = GUID_Button, - .dwOfs = 0xc, + .dwOfs = 0x14, .dwType = DIDFT_PSHBUTTON|DIDFT_MAKEINSTANCE(0), .tszName = L"Button 0", .wCollectionNumber = 1, @@ -3540,7 +3564,7 @@ static void test_simple_joystick(void) { .dwSize = sizeof(DIDEVICEOBJECTINSTANCEW), .guidType = GUID_Button, - .dwOfs = 0xd, + .dwOfs = 0x15, .dwType = DIDFT_PSHBUTTON|DIDFT_MAKEINSTANCE(1), .tszName = L"Button 1", .wCollectionNumber = 1, @@ -3569,9 +3593,11 @@ static void test_simple_joystick(void) { {.ofs = TRUE}, {.ofs = TRUE}, - {.ofs = TRUE}, - {.ofs = TRUE}, - {.ofs = TRUE}, + {.guid = TRUE, .ofs = TRUE, .type = TRUE, .flags = TRUE, .usage = TRUE}, + {.guid = TRUE, .ofs = TRUE, .type = TRUE, .usage = TRUE, .usage_page = TRUE}, + {.ofs = TRUE, .type = TRUE, .usage = TRUE}, + {.guid = TRUE, .ofs = TRUE, .type = TRUE, .collection_number = TRUE, .report_id = TRUE, .usage = TRUE, .usage_page = TRUE}, + {.type = TRUE}, };
struct check_objects_params check_objects_params = @@ -3768,6 +3794,7 @@ static void test_simple_joystick(void) check_member( caps, expect_caps, "%d", dwSize ); check_member( caps, expect_caps, "%#x", dwFlags ); check_member( caps, expect_caps, "%#x", dwDevType ); + todo_wine check_member( caps, expect_caps, "%d", dwAxes ); check_member( caps, expect_caps, "%d", dwButtons ); check_member( caps, expect_caps, "%d", dwPOVs ); @@ -3933,9 +3960,11 @@ static void test_simple_joystick(void) res = 0; hr = IDirectInputDevice8_EnumObjects( device, check_object_count, &res, DIDFT_AXIS | DIDFT_PSHBUTTON ); ok( hr == DI_OK, "IDirectInputDevice8_EnumObjects returned %#x\n", hr ); - ok( res == 4, "got %u expected %u\n", res, 4 ); + todo_wine + ok( res == 5, "got %u expected %u\n", res, 5 ); hr = IDirectInputDevice8_EnumObjects( device, check_objects, &check_objects_params, DIDFT_ALL ); ok( hr == DI_OK, "IDirectInputDevice8_EnumObjects returned %#x\n", hr ); + todo_wine ok( check_objects_params.index >= check_objects_params.expect_count, "missing %u objects\n", check_objects_params.expect_count - check_objects_params.index );
@@ -3987,22 +4016,22 @@ static void test_simple_joystick(void) hr = IDirectInputDevice8_GetObjectInfo( device, &objinst, res, DIPH_BYID ); ok( hr == DI_OK, "IDirectInputDevice8_GetObjectInfo returned: %#x\n", hr );
- check_member( objinst, expect_objects[4], "%u", dwSize ); - check_member_guid( objinst, expect_objects[4], guidType ); + check_member( objinst, expect_objects[5], "%u", dwSize ); + check_member_guid( objinst, expect_objects[5], guidType ); todo_wine - check_member( objinst, expect_objects[4], "%#x", dwOfs ); - check_member( objinst, expect_objects[4], "%#x", dwType ); - check_member( objinst, expect_objects[4], "%#x", dwFlags ); - if (!localized) todo_wine check_member_wstr( objinst, expect_objects[4], tszName ); - check_member( objinst, expect_objects[4], "%u", dwFFMaxForce ); - check_member( objinst, expect_objects[4], "%u", dwFFForceResolution ); - check_member( objinst, expect_objects[4], "%u", wCollectionNumber ); - check_member( objinst, expect_objects[4], "%u", wDesignatorIndex ); - check_member( objinst, expect_objects[4], "%#04x", wUsagePage ); - check_member( objinst, expect_objects[4], "%#04x", wUsage ); - check_member( objinst, expect_objects[4], "%#04x", dwDimension ); - check_member( objinst, expect_objects[4], "%#04x", wExponent ); - check_member( objinst, expect_objects[4], "%u", wReportId ); + check_member( objinst, expect_objects[5], "%#x", dwOfs ); + check_member( objinst, expect_objects[5], "%#x", dwType ); + check_member( objinst, expect_objects[5], "%#x", dwFlags ); + if (!localized) todo_wine check_member_wstr( objinst, expect_objects[5], tszName ); + check_member( objinst, expect_objects[5], "%u", dwFFMaxForce ); + check_member( objinst, expect_objects[5], "%u", dwFFForceResolution ); + check_member( objinst, expect_objects[5], "%u", wCollectionNumber ); + check_member( objinst, expect_objects[5], "%u", wDesignatorIndex ); + check_member( objinst, expect_objects[5], "%#04x", wUsagePage ); + check_member( objinst, expect_objects[5], "%#04x", wUsage ); + check_member( objinst, expect_objects[5], "%#04x", dwDimension ); + check_member( objinst, expect_objects[5], "%#04x", wExponent ); + check_member( objinst, expect_objects[5], "%u", wReportId );
hr = IDirectInputDevice8_SetDataFormat( device, NULL ); ok( hr == E_POINTER, "IDirectInputDevice8_SetDataFormat returned: %#x\n", hr ); @@ -4108,7 +4137,9 @@ static void test_simple_joystick(void) check_member( state, expect_state[i], "%d", lX ); todo_wine_if( i != 2 ) check_member( state, expect_state[i], "%d", lY ); + todo_wine check_member( state, expect_state[i], "%d", lZ ); + check_member( state, expect_state[i], "%d", lRx ); todo_wine_if( i == 0 ) check_member( state, expect_state[i], "%#x", rgdwPOV[0] ); check_member( state, expect_state[i], "%#x", rgdwPOV[1] ); @@ -4132,7 +4163,9 @@ static void test_simple_joystick(void) check_member( state, expect_state[i], "%d", lX ); todo_wine check_member( state, expect_state[i], "%d", lY ); + todo_wine check_member( state, expect_state[i], "%d", lZ ); + check_member( state, expect_state[i], "%d", lRx ); check_member( state, expect_state[i], "%#x", rgdwPOV[0] ); check_member( state, expect_state[i], "%#x", rgdwPOV[1] ); check_member( state, expect_state[i], "%#x", rgbButtons[0] ); @@ -4257,7 +4290,9 @@ static void test_simple_joystick(void) check_member( state, expect_state[3], "%d", lX ); todo_wine check_member( state, expect_state[3], "%d", lY ); + todo_wine check_member( state, expect_state[3], "%d", lZ ); + check_member( state, expect_state[3], "%d", lRx ); check_member( state, expect_state[3], "%d", rgdwPOV[0] ); check_member( state, expect_state[3], "%d", rgdwPOV[1] ); check_member( state, expect_state[3], "%#x", rgbButtons[0] ); @@ -4312,7 +4347,9 @@ static void test_simple_joystick(void) check_member( state, expect_state_abs[1], "%d", lX ); todo_wine check_member( state, expect_state_abs[1], "%d", lY ); + todo_wine check_member( state, expect_state_abs[1], "%d", lZ ); + check_member( state, expect_state_abs[1], "%d", lRx ); check_member( state, expect_state_abs[1], "%d", rgdwPOV[0] ); check_member( state, expect_state_abs[1], "%d", rgdwPOV[1] ); check_member( state, expect_state_abs[1], "%#x", rgbButtons[0] ); @@ -4457,7 +4494,9 @@ static void test_simple_joystick(void) todo_wine_if( i != 2 ) check_member( state, expect_state_abs[i], "%d", lY ); } + todo_wine check_member( state, expect_state_abs[i], "%d", lZ ); + check_member( state, expect_state_abs[i], "%d", lRx ); check_member( state, expect_state_abs[i], "%d", rgdwPOV[0] ); check_member( state, expect_state_abs[i], "%d", rgdwPOV[1] ); check_member( state, expect_state_abs[i], "%#x", rgbButtons[0] ); @@ -4480,7 +4519,9 @@ static void test_simple_joystick(void) check_member( state, expect_state_abs[i], "%d", lX ); todo_wine check_member( state, expect_state_abs[i], "%d", lY ); + todo_wine check_member( state, expect_state_abs[i], "%d", lZ ); + check_member( state, expect_state_abs[i], "%d", lRx ); check_member( state, expect_state_abs[i], "%d", rgdwPOV[0] ); check_member( state, expect_state_abs[i], "%d", rgdwPOV[1] ); check_member( state, expect_state_abs[i], "%#x", rgbButtons[0] ); @@ -4575,7 +4616,9 @@ static void test_simple_joystick(void) check_member( state, expect_state_rel[i], "%d", lX ); todo_wine check_member( state, expect_state_rel[i], "%d", lY ); + todo_wine_if( i == 1 ) check_member( state, expect_state_rel[i], "%d", lZ ); + check_member( state, expect_state_rel[i], "%d", lRx ); check_member( state, expect_state_rel[i], "%d", rgdwPOV[0] ); check_member( state, expect_state_rel[i], "%d", rgdwPOV[1] ); check_member( state, expect_state_rel[i], "%#x", rgbButtons[0] ); @@ -4599,6 +4642,7 @@ static void test_simple_joystick(void) todo_wine check_member( state, expect_state_rel[i], "%d", lY ); check_member( state, expect_state_rel[i], "%d", lZ ); + check_member( state, expect_state_rel[i], "%d", lRx ); check_member( state, expect_state_rel[i], "%d", rgdwPOV[0] ); check_member( state, expect_state_rel[i], "%d", rgdwPOV[1] ); check_member( state, expect_state_rel[i], "%#x", rgbButtons[0] );
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/joystick_hid.c | 3 +++ dlls/dinput8/tests/hid.c | 25 ++++++------------------- 2 files changed, 9 insertions(+), 19 deletions(-)
diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c index 051ad743cde..81fa3eefe7a 100644 --- a/dlls/dinput/joystick_hid.c +++ b/dlls/dinput/joystick_hid.c @@ -178,6 +178,7 @@ static const GUID *object_usage_to_guid( USAGE usage_page, USAGE usage ) case HID_USAGE_GENERIC_X: return &GUID_XAxis; case HID_USAGE_GENERIC_Y: return &GUID_YAxis; case HID_USAGE_GENERIC_Z: return &GUID_ZAxis; + case HID_USAGE_GENERIC_WHEEL: return &GUID_ZAxis; case HID_USAGE_GENERIC_RX: return &GUID_RxAxis; case HID_USAGE_GENERIC_RY: return &GUID_RyAxis; case HID_USAGE_GENERIC_RZ: return &GUID_RzAxis; @@ -274,6 +275,7 @@ static BOOL enum_value_objects( struct hid_joystick *impl, const DIPROPHEADER *f if (ret != DIENUM_CONTINUE) return ret; break; case HID_USAGE_GENERIC_Z: + case HID_USAGE_GENERIC_WHEEL: instance.dwOfs = DIJOFS_Z; set_axis_type( &instance, seen_axis, 2, &axis ); instance.dwFlags = DIDOI_ASPECTPOSITION; @@ -301,6 +303,7 @@ static BOOL enum_value_objects( struct hid_joystick *impl, const DIPROPHEADER *f ret = enum_object( impl, filter, flags, callback, &caps, &instance, data ); if (ret != DIENUM_CONTINUE) return ret; break; + case HID_USAGE_GENERIC_DIAL: case HID_USAGE_GENERIC_SLIDER: instance.dwOfs = DIJOFS_SLIDER( 0 ); instance.dwType = DIDFT_ABSAXIS | DIDFT_MAKEINSTANCE( 6 + axis++ ); diff --git a/dlls/dinput8/tests/hid.c b/dlls/dinput8/tests/hid.c index bd513760794..14198f2d876 100644 --- a/dlls/dinput8/tests/hid.c +++ b/dlls/dinput8/tests/hid.c @@ -3286,14 +3286,9 @@ static BOOL CALLBACK find_test_device( const DIDEVICEINSTANCEW *devinst, void *c
struct check_objects_todos { - BOOL guid; BOOL ofs; BOOL type; - BOOL flags; BOOL collection_number; - BOOL usage; - BOOL usage_page; - BOOL report_id; };
struct check_objects_params @@ -3317,13 +3312,11 @@ static BOOL CALLBACK check_objects( const DIDEVICEOBJECTINSTANCEW *obj, void *ar if (params->index >= params->expect_count) exp = &unexpected_obj;
check_member( *obj, *exp, "%u", dwSize ); - todo_wine_if( todo->guid ) check_member_guid( *obj, *exp, guidType ); todo_wine_if( todo->ofs ) check_member( *obj, *exp, "%#x", dwOfs ); todo_wine_if( todo->type ) check_member( *obj, *exp, "%#x", dwType ); - todo_wine_if( todo->flags ) check_member( *obj, *exp, "%#x", dwFlags ); if (!localized) todo_wine check_member_wstr( *obj, *exp, tszName ); check_member( *obj, *exp, "%u", dwFFMaxForce ); @@ -3331,13 +3324,10 @@ static BOOL CALLBACK check_objects( const DIDEVICEOBJECTINSTANCEW *obj, void *ar todo_wine_if( todo->collection_number ) check_member( *obj, *exp, "%u", wCollectionNumber ); check_member( *obj, *exp, "%u", wDesignatorIndex ); - todo_wine_if( todo->usage_page ) check_member( *obj, *exp, "%#04x", wUsagePage ); - todo_wine_if( todo->usage ) check_member( *obj, *exp, "%#04x", wUsage ); check_member( *obj, *exp, "%#04x", dwDimension ); check_member( *obj, *exp, "%#04x", wExponent ); - todo_wine_if( todo->report_id ) check_member( *obj, *exp, "%u", wReportId );
winetest_pop_context(); @@ -3593,11 +3583,10 @@ static void test_simple_joystick(void) { {.ofs = TRUE}, {.ofs = TRUE}, - {.guid = TRUE, .ofs = TRUE, .type = TRUE, .flags = TRUE, .usage = TRUE}, - {.guid = TRUE, .ofs = TRUE, .type = TRUE, .usage = TRUE, .usage_page = TRUE}, - {.ofs = TRUE, .type = TRUE, .usage = TRUE}, - {.guid = TRUE, .ofs = TRUE, .type = TRUE, .collection_number = TRUE, .report_id = TRUE, .usage = TRUE, .usage_page = TRUE}, - {.type = TRUE}, + {.ofs = TRUE}, + {.ofs = TRUE}, + {.ofs = TRUE}, + {.ofs = TRUE}, };
struct check_objects_params check_objects_params = @@ -3794,7 +3783,6 @@ static void test_simple_joystick(void) check_member( caps, expect_caps, "%d", dwSize ); check_member( caps, expect_caps, "%#x", dwFlags ); check_member( caps, expect_caps, "%#x", dwDevType ); - todo_wine check_member( caps, expect_caps, "%d", dwAxes ); check_member( caps, expect_caps, "%d", dwButtons ); check_member( caps, expect_caps, "%d", dwPOVs ); @@ -3960,11 +3948,9 @@ static void test_simple_joystick(void) res = 0; hr = IDirectInputDevice8_EnumObjects( device, check_object_count, &res, DIDFT_AXIS | DIDFT_PSHBUTTON ); ok( hr == DI_OK, "IDirectInputDevice8_EnumObjects returned %#x\n", hr ); - todo_wine ok( res == 5, "got %u expected %u\n", res, 5 ); hr = IDirectInputDevice8_EnumObjects( device, check_objects, &check_objects_params, DIDFT_ALL ); ok( hr == DI_OK, "IDirectInputDevice8_EnumObjects returned %#x\n", hr ); - todo_wine ok( check_objects_params.index >= check_objects_params.expect_count, "missing %u objects\n", check_objects_params.expect_count - check_objects_params.index );
@@ -4616,7 +4602,7 @@ static void test_simple_joystick(void) check_member( state, expect_state_rel[i], "%d", lX ); todo_wine check_member( state, expect_state_rel[i], "%d", lY ); - todo_wine_if( i == 1 ) + todo_wine check_member( state, expect_state_rel[i], "%d", lZ ); check_member( state, expect_state_rel[i], "%d", lRx ); check_member( state, expect_state_rel[i], "%d", rgdwPOV[0] ); @@ -4641,6 +4627,7 @@ static void test_simple_joystick(void) check_member( state, expect_state_rel[i], "%d", lX ); todo_wine check_member( state, expect_state_rel[i], "%d", lY ); + todo_wine check_member( state, expect_state_rel[i], "%d", lZ ); check_member( state, expect_state_rel[i], "%d", lRx ); check_member( state, expect_state_rel[i], "%d", rgdwPOV[0] );