Commit bb5f0e12 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

win32u: Use a custom struct hid_input for NtUserSendHardwareInput.

parent 66baee8b
...@@ -225,7 +225,6 @@ static void hid_device_queue_input( DEVICE_OBJECT *device, HID_XFER_PACKET *pack ...@@ -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_report *last_report, *report;
struct hid_queue *queue; struct hid_queue *queue;
LIST_ENTRY completed, *entry; LIST_ENTRY completed, *entry;
RAWINPUT *rawinput;
KIRQL irql; KIRQL irql;
IRP *irp; IRP *irp;
...@@ -233,28 +232,28 @@ static void hid_device_queue_input( DEVICE_OBJECT *device, HID_XFER_PACKET *pack ...@@ -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 )) if (IsEqualGUID( ext->class_guid, &GUID_DEVINTERFACE_HID ))
{ {
size = offsetof( RAWINPUT, data.hid.bRawData[report_len] ); struct hid_packet *hid;
if (!(rawinput = malloc( size ))) ERR( "Failed to allocate rawinput data!\n" );
size = offsetof( struct hid_packet, data[report_len] );
if (!(hid = malloc( size ))) ERR( "Failed to allocate rawinput data!\n" );
else else
{ {
INPUT input; INPUT input = {.type = INPUT_HARDWARE};
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.hi.uMsg = WM_INPUT; input.hi.uMsg = WM_INPUT;
input.hi.wParamH = 0; input.hi.wParamH = HIWORD(RIM_INPUT);
input.hi.wParamL = 0; input.hi.wParamL = LOWORD(RIM_INPUT);
NtUserSendHardwareInput( 0, 0, &input, (LPARAM)rawinput );
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 );
} }
} }
......
...@@ -114,27 +114,20 @@ C_ASSERT(offsetof(RAWINPUT, data.hid.bRawData[2 * sizeof(USAGE)]) < sizeof(RAWIN ...@@ -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) static void send_wm_input_device_change(BASE_DEVICE_EXTENSION *ext, LPARAM param)
{ {
HIDP_COLLECTION_DESC *desc = ext->u.pdo.device_desc.CollectionDesc; HIDP_COLLECTION_DESC *desc = ext->u.pdo.device_desc.CollectionDesc;
RAWINPUT rawinput; INPUT input = {.type = INPUT_HARDWARE};
INPUT input; struct hid_packet hid = {0};
TRACE("ext %p, lparam %p\n", ext, (void *)param); TRACE("ext %p, lparam %p\n", ext, (void *)param);
if (!IsEqualGUID( ext->class_guid, &GUID_DEVINTERFACE_HID )) return; 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.uMsg = WM_INPUT_DEVICE_CHANGE;
input.hi.wParamH = 0; input.hi.wParamH = HIWORD(param);
input.hi.wParamL = 0; input.hi.wParamL = LOWORD(param);
NtUserSendHardwareInput(0, 0, &input, (LPARAM)&rawinput);
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) static NTSTATUS WINAPI driver_add_device(DRIVER_OBJECT *driver, DEVICE_OBJECT *bus_pdo)
......
...@@ -3486,7 +3486,6 @@ NTSTATUS send_hardware_message( HWND hwnd, UINT flags, const INPUT *input, LPARA ...@@ -3486,7 +3486,6 @@ NTSTATUS send_hardware_message( HWND hwnd, UINT flags, const INPUT *input, LPARA
{ {
struct send_message_info info; struct send_message_info info;
int prev_x, prev_y, new_x, new_y; int prev_x, prev_y, new_x, new_y;
USAGE hid_usage_page, hid_usage;
NTSTATUS ret; NTSTATUS ret;
BOOL wait, affects_key_state = FALSE; BOOL wait, affects_key_state = FALSE;
...@@ -3500,25 +3499,6 @@ NTSTATUS send_hardware_message( HWND hwnd, UINT flags, const INPUT *input, LPARA ...@@ -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))) if (input->type == INPUT_MOUSE && (input->mi.dwFlags & (MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_RIGHTDOWN)))
clip_fullscreen_window( hwnd, FALSE ); 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 ) SERVER_START_REQ( send_hardware_message )
{ {
req->win = wine_server_user_handle( hwnd ); req->win = wine_server_user_handle( hwnd );
...@@ -3548,30 +3528,21 @@ NTSTATUS send_hardware_message( HWND hwnd, UINT flags, const INPUT *input, LPARA ...@@ -3548,30 +3528,21 @@ NTSTATUS send_hardware_message( HWND hwnd, UINT flags, const INPUT *input, LPARA
break; break;
case INPUT_HARDWARE: case INPUT_HARDWARE:
req->input.hw.msg = input->hi.uMsg; 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) switch (input->hi.uMsg)
{ {
case WM_INPUT: case WM_INPUT:
case WM_INPUT_DEVICE_CHANGE: case WM_INPUT_DEVICE_CHANGE:
{ {
const RAWINPUT *rawinput = (const RAWINPUT *)lparam; struct hid_packet *hid = (struct hid_packet *)lparam;
switch (rawinput->header.dwType) req->input.hw.hid = hid->head;
{ wine_server_add_data( req, hid->data, hid->head.count * hid->head.length );
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; break;
}
default: default:
assert( 0 ); req->input.hw.lparam = lparam;
break; break;
} }
}
}
break; break;
} }
ret = wine_server_call( req ); ret = wine_server_call( req );
......
...@@ -1407,11 +1407,27 @@ static inline BOOL NtUserShowOwnedPopups( HWND hwnd, BOOL show ) ...@@ -1407,11 +1407,27 @@ static inline BOOL NtUserShowOwnedPopups( HWND hwnd, BOOL show )
return NtUserCallHwndParam( hwnd, show, NtUserCallHwndParam_ShowOwnedPopups ); 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 struct send_hardware_input_params
{ {
UINT flags; UINT flags;
const INPUT *input; 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 ) static inline BOOL NtUserSendHardwareInput( HWND hwnd, UINT flags, const INPUT *input, LPARAM lparam )
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include <windef.h> #include <windef.h>
#include <winbase.h> #include <winbase.h>
#include <ntuser.h>
typedef unsigned int obj_handle_t; typedef unsigned int obj_handle_t;
typedef unsigned int user_handle_t; typedef unsigned int user_handle_t;
...@@ -325,13 +326,7 @@ typedef union ...@@ -325,13 +326,7 @@ typedef union
unsigned int msg; unsigned int msg;
lparam_t wparam; lparam_t wparam;
lparam_t lparam; lparam_t lparam;
struct struct hid_input hid;
{
unsigned int device;
unsigned int usage;
unsigned int count;
unsigned int length;
} hid;
} hw; } hw;
} hw_input_t; } hw_input_t;
...@@ -6507,7 +6502,7 @@ union generic_reply ...@@ -6507,7 +6502,7 @@ union generic_reply
/* ### protocol_version begin ### */ /* ### protocol_version begin ### */
#define SERVER_PROTOCOL_VERSION 794 #define SERVER_PROTOCOL_VERSION 795
/* ### protocol_version end ### */ /* ### protocol_version end ### */
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <windef.h> #include <windef.h>
#include <winbase.h> #include <winbase.h>
#include <ntuser.h>
typedef unsigned int obj_handle_t; typedef unsigned int obj_handle_t;
typedef unsigned int user_handle_t; typedef unsigned int user_handle_t;
...@@ -341,13 +342,7 @@ typedef union ...@@ -341,13 +342,7 @@ typedef union
unsigned int msg; /* message code */ unsigned int msg; /* message code */
lparam_t wparam; /* parameters */ lparam_t wparam; /* parameters */
lparam_t lparam; /* parameters */ lparam_t lparam; /* parameters */
struct struct hid_input hid; /* defined in ntuser.h */
{
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;
} hw; } hw;
} hw_input_t; } hw_input_t;
......
...@@ -2250,7 +2250,7 @@ static void queue_custom_hardware_message( struct desktop *desktop, user_handle_ ...@@ -2250,7 +2250,7 @@ static void queue_custom_hardware_message( struct desktop *desktop, user_handle_
msg->win = get_user_full_handle( win ); msg->win = get_user_full_handle( win );
msg->msg = input->hw.msg; msg->msg = input->hw.msg;
msg->wparam = 0; msg->wparam = input->hw.wparam;
msg->lparam = input->hw.lparam; msg->lparam = input->hw.lparam;
msg->x = desktop->cursor.x; msg->x = desktop->cursor.x;
msg->y = desktop->cursor.y; msg->y = desktop->cursor.y;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment