From: Rémi Bernon rbernon@codeweavers.com
--- dlls/hidclass.sys/device.c | 37 +++++++++++++++---------------- dlls/hidclass.sys/pnp.c | 23 +++++++------------ dlls/win32u/message.c | 45 +++++++------------------------------- include/ntuser.h | 18 ++++++++++++++- server/protocol.def | 9 ++------ server/queue.c | 2 +- 6 files changed, 54 insertions(+), 80 deletions(-)
diff --git a/dlls/hidclass.sys/device.c b/dlls/hidclass.sys/device.c index 1b5233e84b6..e6b34077a77 100644 --- a/dlls/hidclass.sys/device.c +++ b/dlls/hidclass.sys/device.c @@ -225,7 +225,6 @@ static void hid_device_queue_input( DEVICE_OBJECT *device, HID_XFER_PACKET *pack struct hid_report *last_report, *report; struct hid_queue *queue; LIST_ENTRY completed, *entry; - RAWINPUT *rawinput; KIRQL irql; IRP *irp;
@@ -233,28 +232,28 @@ static void hid_device_queue_input( DEVICE_OBJECT *device, HID_XFER_PACKET *pack
if (IsEqualGUID( ext->class_guid, &GUID_DEVINTERFACE_HID )) { - size = offsetof( RAWINPUT, data.hid.bRawData[report_len] ); - if (!(rawinput = malloc( size ))) ERR( "Failed to allocate rawinput data!\n" ); + struct hid_packet *hid; + + size = offsetof( struct hid_packet, data[report_len] ); + if (!(hid = 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 = report_len; - memcpy( rawinput->data.hid.bRawData, packet->reportBuffer, packet->reportBufferLen ); - memset( rawinput->data.hid.bRawData + packet->reportBufferLen, 0, report_len - packet->reportBufferLen ); - - input.type = INPUT_HARDWARE; + INPUT input = {.type = INPUT_HARDWARE}; + input.hi.uMsg = WM_INPUT; - input.hi.wParamH = 0; - input.hi.wParamL = 0; - NtUserSendHardwareInput( 0, 0, &input, (LPARAM)rawinput ); + input.hi.wParamH = HIWORD(RIM_INPUT); + input.hi.wParamL = LOWORD(RIM_INPUT); + + hid->head.device = ext->u.pdo.rawinput_handle; + hid->head.usage = MAKELONG(desc->Usage, desc->UsagePage); + + hid->head.count = 1; + hid->head.length = report_len; + memcpy( hid->data, packet->reportBuffer, packet->reportBufferLen ); + memset( hid->data + packet->reportBufferLen, 0, report_len - packet->reportBufferLen ); + NtUserSendHardwareInput( 0, 0, &input, (LPARAM)hid );
- free( rawinput ); + free( hid ); } }
diff --git a/dlls/hidclass.sys/pnp.c b/dlls/hidclass.sys/pnp.c index afa217c539f..ddccffb91e2 100644 --- a/dlls/hidclass.sys/pnp.c +++ b/dlls/hidclass.sys/pnp.c @@ -114,27 +114,20 @@ C_ASSERT(offsetof(RAWINPUT, data.hid.bRawData[2 * sizeof(USAGE)]) < sizeof(RAWIN static void send_wm_input_device_change(BASE_DEVICE_EXTENSION *ext, LPARAM param) { HIDP_COLLECTION_DESC *desc = ext->u.pdo.device_desc.CollectionDesc; - RAWINPUT rawinput; - INPUT input; + INPUT input = {.type = INPUT_HARDWARE}; + struct hid_packet hid = {0};
TRACE("ext %p, lparam %p\n", ext, (void *)param);
if (!IsEqualGUID( ext->class_guid, &GUID_DEVINTERFACE_HID )) return;
- rawinput.header.dwType = RIM_TYPEHID; - rawinput.header.dwSize = offsetof(RAWINPUT, data.hid.bRawData[2 * sizeof(USAGE)]); - rawinput.header.hDevice = ULongToHandle(ext->u.pdo.rawinput_handle); - rawinput.header.wParam = param; - rawinput.data.hid.dwCount = 0; - rawinput.data.hid.dwSizeHid = 0; - ((USAGE *)rawinput.data.hid.bRawData)[0] = desc->UsagePage; - ((USAGE *)rawinput.data.hid.bRawData)[1] = desc->Usage; - - input.type = INPUT_HARDWARE; input.hi.uMsg = WM_INPUT_DEVICE_CHANGE; - input.hi.wParamH = 0; - input.hi.wParamL = 0; - NtUserSendHardwareInput(0, 0, &input, (LPARAM)&rawinput); + input.hi.wParamH = HIWORD(param); + input.hi.wParamL = LOWORD(param); + + hid.head.device = ext->u.pdo.rawinput_handle; + hid.head.usage = MAKELONG(desc->Usage, desc->UsagePage); + NtUserSendHardwareInput(0, 0, &input, (LPARAM)&hid); }
static NTSTATUS WINAPI driver_add_device(DRIVER_OBJECT *driver, DEVICE_OBJECT *bus_pdo) diff --git a/dlls/win32u/message.c b/dlls/win32u/message.c index e0944ca64d8..79390a7fdc5 100644 --- a/dlls/win32u/message.c +++ b/dlls/win32u/message.c @@ -3486,7 +3486,6 @@ NTSTATUS send_hardware_message( HWND hwnd, UINT flags, const INPUT *input, LPARA { struct send_message_info info; int prev_x, prev_y, new_x, new_y; - USAGE hid_usage_page, hid_usage; NTSTATUS ret; BOOL wait, affects_key_state = FALSE;
@@ -3500,25 +3499,6 @@ NTSTATUS send_hardware_message( HWND hwnd, UINT flags, const INPUT *input, LPARA if (input->type == INPUT_MOUSE && (input->mi.dwFlags & (MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_RIGHTDOWN))) clip_fullscreen_window( hwnd, FALSE );
- if (input->type == INPUT_HARDWARE) - { - if (input->hi.uMsg == WM_INPUT_DEVICE_CHANGE) - { - const RAWINPUT *rawinput = (const RAWINPUT *)lparam; - hid_usage_page = ((USAGE *)rawinput->data.hid.bRawData)[0]; - hid_usage = ((USAGE *)rawinput->data.hid.bRawData)[1]; - } - if (input->hi.uMsg == WM_INPUT) - { - const RAWINPUT *rawinput = (const RAWINPUT *)lparam; - if (!rawinput_device_get_usages( rawinput->header.hDevice, &hid_usage_page, &hid_usage )) - { - WARN( "unable to get HID usages for device %p\n", rawinput->header.hDevice ); - return STATUS_INVALID_HANDLE; - } - } - } - SERVER_START_REQ( send_hardware_message ) { req->win = wine_server_user_handle( hwnd ); @@ -3548,29 +3528,20 @@ NTSTATUS send_hardware_message( HWND hwnd, UINT flags, const INPUT *input, LPARA break; case INPUT_HARDWARE: req->input.hw.msg = input->hi.uMsg; - req->input.hw.lparam = MAKELONG( input->hi.wParamL, input->hi.wParamH ); + req->input.hw.wparam = MAKELONG( input->hi.wParamL, input->hi.wParamH ); switch (input->hi.uMsg) { case WM_INPUT: case WM_INPUT_DEVICE_CHANGE: { - const RAWINPUT *rawinput = (const RAWINPUT *)lparam; - switch (rawinput->header.dwType) - { - case RIM_TYPEHID: - req->input.hw.wparam = rawinput->header.wParam; - req->input.hw.hid.device = HandleToUlong( rawinput->header.hDevice ); - req->input.hw.hid.usage = MAKELONG(hid_usage, hid_usage_page); - req->input.hw.hid.count = rawinput->data.hid.dwCount; - req->input.hw.hid.length = rawinput->data.hid.dwSizeHid; - wine_server_add_data( req, rawinput->data.hid.bRawData, - rawinput->data.hid.dwCount * rawinput->data.hid.dwSizeHid ); - break; - default: - assert( 0 ); - break; - } + struct hid_packet *hid = (struct hid_packet *)lparam; + req->input.hw.hid = hid->head; + wine_server_add_data( req, hid->data, hid->head.count * hid->head.length ); + break; } + default: + req->input.hw.lparam = lparam; + break; } break; } diff --git a/include/ntuser.h b/include/ntuser.h index eb8c95ac8b4..a048aebbb2a 100644 --- a/include/ntuser.h +++ b/include/ntuser.h @@ -1407,11 +1407,27 @@ static inline BOOL NtUserShowOwnedPopups( HWND hwnd, BOOL show ) return NtUserCallHwndParam( hwnd, show, NtUserCallHwndParam_ShowOwnedPopups ); }
+struct hid_input +{ + UINT device; + UINT usage; + UINT count; + UINT length; +}; + +struct hid_packet +{ + struct hid_input head; + BYTE data[]; +}; + +C_ASSERT(sizeof(struct hid_packet) == offsetof(struct hid_packet, data[0])); + struct send_hardware_input_params { UINT flags; const INPUT *input; - LPARAM lparam; /* RAWINPUT pointer for WM_INPUT* messages */ + LPARAM lparam; /* struct hid_packet pointer for WM_INPUT* messages */ };
static inline BOOL NtUserSendHardwareInput( HWND hwnd, UINT flags, const INPUT *input, LPARAM lparam ) diff --git a/server/protocol.def b/server/protocol.def index fa78e0487f8..7b21aa16636 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -30,6 +30,7 @@
#include <windef.h> #include <winbase.h> +#include <ntuser.h>
typedef unsigned int obj_handle_t; typedef unsigned int user_handle_t; @@ -341,13 +342,7 @@ typedef union unsigned int msg; /* message code */ lparam_t wparam; /* parameters */ lparam_t lparam; /* parameters */ - struct - { - unsigned int device; /* rawinput device index */ - unsigned int usage; /* HID device usage */ - unsigned int count; /* HID report count */ - unsigned int length; /* HID report length */ - } hid; + struct hid_input hid; /* defined in ntuser.h */ } hw; } hw_input_t;
diff --git a/server/queue.c b/server/queue.c index 4373bd71254..ef40d30aedf 100644 --- a/server/queue.c +++ b/server/queue.c @@ -2250,7 +2250,7 @@ static void queue_custom_hardware_message( struct desktop *desktop, user_handle_
msg->win = get_user_full_handle( win ); msg->msg = input->hw.msg; - msg->wparam = 0; + msg->wparam = input->hw.wparam; msg->lparam = input->hw.lparam; msg->x = desktop->cursor.x; msg->y = desktop->cursor.y;