[PATCH 2/7] dinput: Implement HID wheel type detection.
Rémi Bernon
rbernon at codeweavers.com
Thu Jan 20 02:28:40 CST 2022
From: Arkadiusz Hiler <ahiler at codeweavers.com>
Signed-off-by: Arkadiusz Hiler <ahiler at codeweavers.com>
Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
---
dlls/dinput/joystick_hid.c | 31 +++++++++++++++++++++++++++++++
dlls/dinput/tests/joystick8.c | 4 ++--
2 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c
index 29d1de8b98e..ccf205e275b 100644
--- a/dlls/dinput/joystick_hid.c
+++ b/dlls/dinput/joystick_hid.c
@@ -1400,6 +1400,7 @@ static BOOL hid_joystick_device_try_open( UINT32 handle, const WCHAR *path, HAND
PHIDP_PREPARSED_DATA *preparsed, HIDD_ATTRIBUTES *attrs,
HIDP_CAPS *caps, DIDEVICEINSTANCEW *instance, DWORD version )
{
+ BOOL has_accelerator, has_brake, has_clutch;
PHIDP_PREPARSED_DATA preparsed_data = NULL;
DWORD type = 0, button_count = 0;
HIDP_BUTTON_CAPS buttons[10];
@@ -1486,6 +1487,36 @@ static BOOL hid_joystick_device_try_open( UINT32 handle, const WCHAR *path, HAND
if (status != HIDP_STATUS_SUCCESS || !count)
type = DI8DEVTYPE_SUPPLEMENTAL | (DI8DEVTYPESUPPLEMENTAL_UNKNOWN << 8) | DIDEVTYPE_HID;
+ count = 1;
+ status = HidP_GetSpecificValueCaps( HidP_Input, HID_USAGE_PAGE_SIMULATION, 0, HID_USAGE_SIMULATION_STEERING,
+ &value, &count, preparsed_data );
+ if (status == HIDP_STATUS_SUCCESS && count)
+ {
+ type = DI8DEVTYPE_DRIVING | DIDEVTYPE_HID;
+
+ count = 1;
+ status = HidP_GetSpecificValueCaps( HidP_Input, HID_USAGE_PAGE_SIMULATION, 0, HID_USAGE_SIMULATION_ACCELERATOR,
+ &value, &count, preparsed_data );
+ has_accelerator = (status == HIDP_STATUS_SUCCESS && count);
+
+ count = 1;
+ status = HidP_GetSpecificValueCaps( HidP_Input, HID_USAGE_PAGE_SIMULATION, 0, HID_USAGE_SIMULATION_BRAKE,
+ &value, &count, preparsed_data );
+ has_brake = (status == HIDP_STATUS_SUCCESS && count);
+
+ count = 1;
+ status = HidP_GetSpecificValueCaps( HidP_Input, HID_USAGE_PAGE_SIMULATION, 0, HID_USAGE_SIMULATION_CLUTCH,
+ &value, &count, preparsed_data );
+ has_clutch = (status == HIDP_STATUS_SUCCESS && count);
+
+ if (has_accelerator && has_brake && has_clutch)
+ type |= (DI8DEVTYPEDRIVING_THREEPEDALS << 8);
+ else if (has_accelerator && has_brake)
+ type |= (DI8DEVTYPEDRIVING_DUALPEDALS << 8);
+ else
+ type |= (DI8DEVTYPEDRIVING_LIMITED << 8);
+ }
+
instance->dwDevType = device_type_for_version( type, version );
*device = device_file;
diff --git a/dlls/dinput/tests/joystick8.c b/dlls/dinput/tests/joystick8.c
index 7de4ab80d6d..42fbcf808d5 100644
--- a/dlls/dinput/tests/joystick8.c
+++ b/dlls/dinput/tests/joystick8.c
@@ -2557,7 +2557,7 @@ static BOOL test_device_types( DWORD version )
ok( hr == DI_OK, "GetDeviceInfo returned %#x\n", hr );
check_member( devinst, expect_devinst[i], "%d", dwSize );
check_member_guid( devinst, expect_devinst[i], guidProduct );
- todo_wine_if( (version <= 0x700 && i == 3) || i > 3 )
+ todo_wine_if( version <= 0x700 && i == 3 )
check_member( devinst, expect_devinst[i], "%#x", dwDevType );
check_member_guid( devinst, expect_devinst[i], guidFFDriver );
check_member( devinst, expect_devinst[i], "%04x", wUsagePage );
@@ -2567,7 +2567,7 @@ static BOOL test_device_types( DWORD version )
ok( hr == DI_OK, "GetCapabilities returned %#x\n", hr );
check_member( caps, expect_caps[i], "%d", dwSize );
check_member( caps, expect_caps[i], "%#x", dwFlags );
- todo_wine_if( (version <= 0x700 && i == 3) || i > 3 )
+ todo_wine_if( version <= 0x700 && i == 3 )
check_member( caps, expect_caps[i], "%#x", dwDevType );
check_member( caps, expect_caps[i], "%d", dwAxes );
check_member( caps, expect_caps[i], "%d", dwButtons );
--
2.34.1
More information about the wine-devel
mailing list