Module: wine Branch: master Commit: 42c8860b23a024a1e0bbb6ad6445d7182698603e URL: https://source.winehq.org/git/wine.git/?a=commit;h=42c8860b23a024a1e0bbb6ad6...
Author: Rémi Bernon rbernon@codeweavers.com Date: Thu Mar 3 12:02:04 2022 +0100
dinput: Check collection nodes to find HID simulation device usages.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/dinput/joystick_hid.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c index 1a39dfd6cab..4f1c8444e43 100644 --- a/dlls/dinput/joystick_hid.c +++ b/dlls/dinput/joystick_hid.c @@ -1418,10 +1418,12 @@ static BOOL hid_joystick_device_try_open( UINT32 handle, const WCHAR *path, HAND { BOOL has_accelerator, has_brake, has_clutch, has_z, has_pov; PHIDP_PREPARSED_DATA preparsed_data = NULL; + HIDP_LINK_COLLECTION_NODE nodes[256]; DWORD type, button_count = 0; HIDP_BUTTON_CAPS buttons[10]; HIDP_VALUE_CAPS value; HANDLE device_file; + ULONG node_count; NTSTATUS status; USHORT count;
@@ -1453,6 +1455,16 @@ static BOOL hid_joystick_device_try_open( UINT32 handle, const WCHAR *path, HAND instance->wUsagePage = caps->UsagePage; instance->wUsage = caps->Usage;
+ node_count = ARRAY_SIZE(nodes); + status = HidP_GetLinkCollectionNodes( nodes, &node_count, preparsed_data ); + if (status != HIDP_STATUS_SUCCESS) node_count = 0; + while (node_count--) + { + if (nodes[node_count].LinkUsagePage != HID_USAGE_PAGE_SIMULATION) continue; + if (nodes[node_count].LinkUsage == HID_USAGE_SIMULATION_AUTOMOBILE_SIMULATION_DEVICE) type = DI8DEVTYPE_DRIVING; + if (nodes[node_count].LinkUsage == HID_USAGE_SIMULATION_FLIGHT_SIMULATION_DEVICE) type = DI8DEVTYPE_FLIGHT; + } + count = ARRAY_SIZE(buttons); status = HidP_GetSpecificButtonCaps( HidP_Output, HID_USAGE_PAGE_PID, 0, PID_USAGE_DC_DEVICE_RESET, buttons, &count, preparsed_data ); @@ -1533,6 +1545,9 @@ static BOOL hid_joystick_device_try_open( UINT32 handle, const WCHAR *path, HAND else type |= (DI8DEVTYPEDRIVING_LIMITED << 8); break; + case DI8DEVTYPE_FLIGHT: + type |= (DI8DEVTYPEFLIGHT_STICK << 8); + break; }
instance->dwDevType = device_type_for_version( type, version ) | DIDEVTYPE_HID;