From: Zebediah Figura zfigura@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com Signed-off-by: Rémi Bernon rbernon@codeweavers.com ---
v2: Fix some style nitpicks, move the ioctl to wine/hid.h and name it with a wine prefix, similarly to IOCTL_HID_GET_MS_GENRE_DESCRIPTOR.
dlls/hidclass.sys/device.c | 12 ++++++++++++ include/wine/hid.h | 2 ++ 2 files changed, 14 insertions(+)
diff --git a/dlls/hidclass.sys/device.c b/dlls/hidclass.sys/device.c index 9d917bbc674..7c0dbdcbc10 100644 --- a/dlls/hidclass.sys/device.c +++ b/dlls/hidclass.sys/device.c @@ -655,6 +655,18 @@ NTSTATUS WINAPI pdo_ioctl(DEVICE_OBJECT *device, IRP *irp) case IOCTL_HID_SET_OUTPUT_REPORT: status = hid_device_xfer_report( ext, code, irp ); break; + + case IOCTL_HID_GET_WINE_RAWINPUT_HANDLE: + if (irpsp->Parameters.DeviceIoControl.OutputBufferLength < sizeof(ULONG)) + status = STATUS_BUFFER_OVERFLOW; + else + { + *(ULONG *)irp->AssociatedIrp.SystemBuffer = ext->u.pdo.rawinput_handle; + irp->IoStatus.Information = sizeof(ULONG); + status = STATUS_SUCCESS; + } + break; + default: { ULONG code = irpsp->Parameters.DeviceIoControl.IoControlCode; diff --git a/include/wine/hid.h b/include/wine/hid.h index 236888cbdc7..6a92317551f 100644 --- a/include/wine/hid.h +++ b/include/wine/hid.h @@ -227,4 +227,6 @@ struct hid_preparsed_data #define PID_USAGE_CREATE_NEW_EFFECT_REPORT ((USAGE) 0xab) #define PID_USAGE_RAM_POOL_AVAILABLE ((USAGE) 0xac)
+#define IOCTL_HID_GET_WINE_RAWINPUT_HANDLE HID_BUFFER_CTL_CODE(300) + #endif /* __WINE_PARSE_H */
From: Zebediah Figura zfigura@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/joystick_hid.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-)
diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c index 1f4b300be74..3dc7b70aac4 100644 --- a/dlls/dinput/joystick_hid.c +++ b/dlls/dinput/joystick_hid.c @@ -30,7 +30,9 @@ #include "winuser.h" #include "winerror.h" #include "winreg.h" +#include "winioctl.h"
+#include "ddk/hidclass.h" #include "ddk/hidsdi.h" #include "setupapi.h" #include "devguid.h" @@ -41,7 +43,6 @@ #include "device_private.h"
#include "initguid.h" -#include "devpkey.h"
#include "wine/debug.h" #include "wine/hid.h" @@ -51,7 +52,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(dinput); DEFINE_GUID( GUID_DEVINTERFACE_WINEXINPUT,0x6c53d5fd,0x6480,0x440f,0xb6,0x18,0x47,0x67,0x50,0xc5,0xe1,0xa6 ); DEFINE_GUID( hid_joystick_guid, 0x9e573edb, 0x7734, 0x11d2, 0x8d, 0x4a, 0x23, 0x90, 0x3f, 0xb6, 0xbd, 0xf7 ); DEFINE_GUID( device_path_guid, 0x00000000, 0x0000, 0x0000, 0x8d, 0x4a, 0x23, 0x90, 0x3f, 0xb6, 0xbd, 0xf8 ); -DEFINE_DEVPROPKEY( DEVPROPKEY_HID_HANDLE, 0xbc62e415, 0xf4fe, 0x405c, 0x8e, 0xda, 0x63, 0x6f, 0xb5, 0x9f, 0x08, 0x98, 2 );
struct pid_control_report { @@ -1413,19 +1413,20 @@ static DWORD device_type_for_version( DWORD type, DWORD version ) } }
-static HRESULT hid_joystick_device_try_open( UINT32 handle, const WCHAR *path, HANDLE *device, - PHIDP_PREPARSED_DATA *preparsed, HIDD_ATTRIBUTES *attrs, - HIDP_CAPS *caps, DIDEVICEINSTANCEW *instance, DWORD version ) +static HRESULT hid_joystick_device_try_open( const WCHAR *path, HANDLE *device, PHIDP_PREPARSED_DATA *preparsed, + HIDD_ATTRIBUTES *attrs, HIDP_CAPS *caps, DIDEVICEINSTANCEW *instance, + DWORD version ) { 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; + DWORD type, size, button_count = 0; HIDP_BUTTON_CAPS buttons[10]; HIDP_VALUE_CAPS value; HANDLE device_file; ULONG node_count; NTSTATUS status; + UINT32 handle; USHORT count;
device_file = CreateFileW( path, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, @@ -1448,6 +1449,12 @@ static HRESULT hid_joystick_device_try_open( UINT32 handle, const WCHAR *path, H if (!HidD_GetProductString( device_file, instance->tszInstanceName, MAX_PATH * sizeof(WCHAR) )) goto failed; if (!HidD_GetProductString( device_file, instance->tszProductName, MAX_PATH * sizeof(WCHAR) )) goto failed;
+ if (!DeviceIoControl( device_file, IOCTL_HID_GET_WINE_RAWINPUT_HANDLE, NULL, 0, &handle, sizeof(handle), &size, NULL )) + { + ERR( "failed to get raw input handle, error %lu\n", GetLastError() ); + goto failed; + } + instance->guidInstance = hid_joystick_guid; instance->guidInstance.Data1 ^= handle; instance->guidProduct = dinput_pidvid_guid; @@ -1574,9 +1581,8 @@ static HRESULT hid_joystick_device_open( int index, const GUID *guid, DIDEVICEIN SP_DEVINFO_DATA devinfo = {.cbSize = sizeof(devinfo)}; WCHAR device_id[MAX_PATH], *tmp; HDEVINFO set, xi_set; - UINT32 i = 0, handle; BOOL override; - DWORD type; + UINT32 i = 0; GUID hid;
TRACE( "index %d, guid %s\n", index, debugstr_guid( guid ) ); @@ -1594,11 +1600,7 @@ static HRESULT hid_joystick_device_open( int index, const GUID *guid, DIDEVICEIN detail->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_W); if (!SetupDiGetDeviceInterfaceDetailW( set, &iface, detail, sizeof(buffer), NULL, &devinfo )) continue; - if (!SetupDiGetDevicePropertyW( set, &devinfo, &DEVPROPKEY_HID_HANDLE, &type, - (BYTE *)&handle, sizeof(handle), NULL, 0 ) || - type != DEVPROP_TYPE_UINT32) - continue; - if (FAILED(hid_joystick_device_try_open( handle, detail->DevicePath, device, preparsed, + if (FAILED(hid_joystick_device_try_open( detail->DevicePath, device, preparsed, attrs, caps, instance, version ))) continue;
@@ -1618,7 +1620,7 @@ static HRESULT hid_joystick_device_open( int index, const GUID *guid, DIDEVICEIN
CloseHandle( *device ); HidD_FreePreparsedData( *preparsed ); - if (FAILED(hid_joystick_device_try_open( handle, detail->DevicePath, device, preparsed, + if (FAILED(hid_joystick_device_try_open( detail->DevicePath, device, preparsed, attrs, caps, instance, version ))) continue; } @@ -2040,7 +2042,7 @@ HRESULT hid_joystick_create_device( struct dinput *dinput, const GUID *guid, IDi else { wcscpy( impl->device_path, *(const WCHAR **)guid ); - hr = hid_joystick_device_try_open( 0, impl->device_path, &impl->device, &impl->preparsed, &attrs, + hr = hid_joystick_device_try_open( impl->device_path, &impl->device, &impl->preparsed, &attrs, &impl->caps, &impl->base.instance, dinput->dwVersion ); } if (hr != DI_OK) goto failed;
From: Zebediah Figura zfigura@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/hidclass.sys/pnp.c | 11 ----------- 1 file changed, 11 deletions(-)
diff --git a/dlls/hidclass.sys/pnp.c b/dlls/hidclass.sys/pnp.c index cc4e3b96c82..873c55c4a67 100644 --- a/dlls/hidclass.sys/pnp.c +++ b/dlls/hidclass.sys/pnp.c @@ -24,7 +24,6 @@ #include "initguid.h" #include "hid.h" #include "devguid.h" -#include "devpkey.h" #include "ntddmou.h" #include "ntddkbd.h" #include "ddk/hidtypes.h" @@ -37,7 +36,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(hid);
-DEFINE_DEVPROPKEY(DEVPROPKEY_HID_HANDLE, 0xbc62e415, 0xf4fe, 0x405c, 0x8e, 0xda, 0x63, 0x6f, 0xb5, 0x9f, 0x08, 0x98, 2); DEFINE_GUID(GUID_DEVINTERFACE_WINEXINPUT, 0x6c53d5fd, 0x6480, 0x440f, 0xb6, 0x18, 0x47, 0x67, 0x50, 0xc5, 0xe1, 0xa6);
#ifdef __ASM_USE_FASTCALL_WRAPPER @@ -286,15 +284,6 @@ static void create_child(minidriver *minidriver, DEVICE_OBJECT *fdo)
IoInvalidateDeviceRelations(fdo_ext->u.fdo.hid_ext.PhysicalDeviceObject, BusRelations);
- if ((status = IoSetDevicePropertyData(child_pdo, &DEVPROPKEY_HID_HANDLE, LOCALE_NEUTRAL, - PLUGPLAY_PROPERTY_PERSISTENT, DEVPROP_TYPE_UINT32, - sizeof(pdo_ext->u.pdo.rawinput_handle), &pdo_ext->u.pdo.rawinput_handle))) - { - ERR( "Failed to set device handle property, status %#lx\n", status ); - IoDeleteDevice(child_pdo); - return; - } - pdo_ext->u.pdo.poll_interval = DEFAULT_POLL_INTERVAL;
HID_StartDeviceThread(child_pdo);
From: Zebediah Figura zfigura@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/user32/rawinput.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/dlls/user32/rawinput.c b/dlls/user32/rawinput.c index 4dc240b58b3..e7ff854e3b5 100644 --- a/dlls/user32/rawinput.c +++ b/dlls/user32/rawinput.c @@ -39,14 +39,11 @@
#include "initguid.h" #include "ddk/hidclass.h" -#include "devpkey.h" #include "ntddmou.h" #include "ntddkbd.h"
WINE_DEFAULT_DEBUG_CHANNEL(rawinput);
-DEFINE_DEVPROPKEY(DEVPROPKEY_HID_HANDLE, 0xbc62e415, 0xf4fe, 0x405c, 0x8e, 0xda, 0x63, 0x6f, 0xb5, 0x9f, 0x08, 0x98, 2); - struct device { SP_DEVICE_INTERFACE_DETAIL_DATA_W *detail; @@ -119,13 +116,6 @@ static struct device *add_device( HDEVINFO set, SP_DEVICE_INTERFACE_DATA *iface, return FALSE; }
- if (!SetupDiGetDevicePropertyW(set, &device_data, &DEVPROPKEY_HID_HANDLE, &type, (BYTE *)&handle, sizeof(handle), NULL, 0) || - type != DEVPROP_TYPE_UINT32) - { - ERR("Failed to get device handle, error %#lx.\n", GetLastError()); - return NULL; - } - if (!(detail = malloc(size))) { ERR("Failed to allocate memory.\n"); @@ -146,6 +136,15 @@ static struct device *add_device( HDEVINFO set, SP_DEVICE_INTERFACE_DATA *iface, return NULL; }
+ status = NtDeviceIoControlFile( file, NULL, NULL, NULL, &io, + IOCTL_HID_GET_WINE_RAWINPUT_HANDLE, + NULL, 0, &handle, sizeof(handle) ); + if (status) + { + ERR( "Failed to get raw input handle, status %#lx.\n", status ); + goto fail; + } + memset( &info, 0, sizeof(info) ); info.cbSize = sizeof(info); info.dwType = type;
The original ordering seems to have been lost here; this will cause a temporary regression if ordered after 3/4.
On 6/9/22 20:16, Zebediah Figura wrote:
The original ordering seems to have been lost here; this will cause a temporary regression if ordered after 3/4.
Indeed sorry, I applied the patches with WineHQ patch numbers, I'll resend.