[PATCH] hidclass.sys: Only send WM_INPUT messages for HID devices.
Rémi Bernon
rbernon at codeweavers.com
Wed Sep 22 05:27:26 CDT 2021
And not for the internal WINEXINPUT devices.
Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
---
This should fix a high CPU usage introduced by the winexinput devices,
especially for controller which send a lot of reports.
Sending the messages makes __wine_send_input try finding a device with
the provided rawinput handle, and as it only lists HID, mouse and
keyboard device class interfaces, it never finds it. This makes it
re-enumerate the device list every time, looking for a possible new
device, in vain.
We don't use WM_INPUT messages in xinput, so they aren't needed and we
can just save a few wineserver requests. The &IG_00 device will send its
own WM_INPUT messages anyway.
dlls/hidclass.sys/device.c | 43 ++++++++++++++++++++------------------
1 file changed, 23 insertions(+), 20 deletions(-)
diff --git a/dlls/hidclass.sys/device.c b/dlls/hidclass.sys/device.c
index 8e998bd71be..848f8da906a 100644
--- a/dlls/hidclass.sys/device.c
+++ b/dlls/hidclass.sys/device.c
@@ -190,27 +190,30 @@ static void hid_device_queue_input( DEVICE_OBJECT *device, HID_XFER_PACKET *pack
KIRQL irql;
IRP *irp;
- size = offsetof( RAWINPUT, data.hid.bRawData[packet->reportBufferLen] );
- if (!(rawinput = malloc( size ))) ERR( "Failed to allocate rawinput data!\n" );
- else
+ if (IsEqualGUID( ext->class_guid, &GUID_DEVINTERFACE_HID ))
{
- INPUT input;
-
- rawinput->header.dwType = RIM_TYPEHID;
- rawinput->header.dwSize = size;
- rawinput->header.hDevice = ULongToHandle( ext->u.pdo.rawinput_handle );
- rawinput->header.wParam = RIM_INPUT;
- rawinput->data.hid.dwCount = 1;
- rawinput->data.hid.dwSizeHid = packet->reportBufferLen;
- memcpy( rawinput->data.hid.bRawData, packet->reportBuffer, packet->reportBufferLen );
-
- input.type = INPUT_HARDWARE;
- input.hi.uMsg = WM_INPUT;
- input.hi.wParamH = 0;
- input.hi.wParamL = 0;
- __wine_send_input( 0, &input, rawinput );
-
- free( rawinput );
+ size = offsetof( RAWINPUT, data.hid.bRawData[packet->reportBufferLen] );
+ if (!(rawinput = malloc( size ))) ERR( "Failed to allocate rawinput data!\n" );
+ else
+ {
+ INPUT input;
+
+ rawinput->header.dwType = RIM_TYPEHID;
+ rawinput->header.dwSize = size;
+ rawinput->header.hDevice = ULongToHandle( ext->u.pdo.rawinput_handle );
+ rawinput->header.wParam = RIM_INPUT;
+ rawinput->data.hid.dwCount = 1;
+ rawinput->data.hid.dwSizeHid = packet->reportBufferLen;
+ memcpy( rawinput->data.hid.bRawData, packet->reportBuffer, packet->reportBufferLen );
+
+ input.type = INPUT_HARDWARE;
+ input.hi.uMsg = WM_INPUT;
+ input.hi.wParamH = 0;
+ input.hi.wParamL = 0;
+ __wine_send_input( 0, &input, rawinput );
+
+ free( rawinput );
+ }
}
if (!(last_report = hid_report_create( packet )))
--
2.33.0
More information about the wine-devel
mailing list