You've already forked wine-staging
mirror of
https://gitlab.winehq.org/wine/wine-staging.git
synced 2025-09-12 18:50:20 -07:00
user32-rawinput-*: Rebase and re-enable.
Thanks to Rémi Bernon for the rebased patch sets.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
From 694ff514bfce59c2590668e3e812d501b713acdb Mon Sep 17 00:00:00 2001
|
||||
From 1851c55f41d14e03c927b0e5220f9c00b1d05f6e Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?R=C3=A9mi=20Bernon?= <rbernon@codeweavers.com>
|
||||
Date: Thu, 12 Sep 2019 14:14:08 +0200
|
||||
Subject: [PATCH 1/5] server: Add process argument to find_rawinput_device.
|
||||
Subject: [PATCH] server: Add process argument to find_rawinput_device.
|
||||
|
||||
We need to be able to iterate all registered rawinput devices for
|
||||
foreign processes, not only the current one.
|
||||
@@ -10,10 +10,10 @@ foreign processes, not only the current one.
|
||||
1 file changed, 5 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/server/queue.c b/server/queue.c
|
||||
index f5dc06100d1..3ed7e82a906 100644
|
||||
index 46ace52f004..810612c5167 100644
|
||||
--- a/server/queue.c
|
||||
+++ b/server/queue.c
|
||||
@@ -1576,11 +1576,11 @@ static user_handle_t find_hardware_message_window( struct desktop *desktop, stru
|
||||
@@ -1490,11 +1490,11 @@ static user_handle_t find_hardware_message_window( struct desktop *desktop, stru
|
||||
return win;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ index f5dc06100d1..3ed7e82a906 100644
|
||||
{
|
||||
if (e->device.usage_page != usage_page || e->device.usage != usage) continue;
|
||||
return e;
|
||||
@@ -1593,7 +1593,7 @@ static void update_rawinput_device(const struct rawinput_device *device)
|
||||
@@ -1507,7 +1507,7 @@ static void update_rawinput_device(const struct rawinput_device *device)
|
||||
{
|
||||
struct rawinput_device_entry *e;
|
||||
|
||||
@@ -36,7 +36,7 @@ index f5dc06100d1..3ed7e82a906 100644
|
||||
{
|
||||
if (!(e = mem_alloc( sizeof(*e) ))) return;
|
||||
list_add_tail( ¤t->process->rawinput_devices, &e->entry );
|
||||
@@ -3375,9 +3375,9 @@ DECL_HANDLER(update_rawinput_devices)
|
||||
@@ -3286,9 +3286,9 @@ DECL_HANDLER(update_rawinput_devices)
|
||||
update_rawinput_device(&devices[i]);
|
||||
}
|
||||
|
||||
@@ -49,5 +49,5 @@ index f5dc06100d1..3ed7e82a906 100644
|
||||
}
|
||||
|
||||
--
|
||||
2.24.1
|
||||
2.27.0
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
From 9aca9116db8ca84eea5be6a67b748ff6fdde9a31 Mon Sep 17 00:00:00 2001
|
||||
From ea854d200d2fb243dc898a1ef4e2a1a6f127a329 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?R=C3=A9mi=20Bernon?= <rbernon@codeweavers.com>
|
||||
Date: Thu, 19 Sep 2019 09:20:44 +0200
|
||||
Subject: [PATCH] server: Allow extra data for hardware_msg_data message.
|
||||
@@ -6,14 +6,14 @@ Subject: [PATCH] server: Allow extra data for hardware_msg_data message.
|
||||
The RIM_TYPEHID messages will have to carry the variable length HID
|
||||
report.
|
||||
---
|
||||
server/queue.c | 43 +++++++++++++++++++++++++++----------------
|
||||
1 file changed, 27 insertions(+), 16 deletions(-)
|
||||
server/queue.c | 31 +++++++++++++++++++++----------
|
||||
1 file changed, 21 insertions(+), 10 deletions(-)
|
||||
|
||||
diff --git a/server/queue.c b/server/queue.c
|
||||
index 9dca519cad2..364c8e43485 100644
|
||||
index 810612c5167..f5d19031485 100644
|
||||
--- a/server/queue.c
|
||||
+++ b/server/queue.c
|
||||
@@ -398,13 +398,13 @@ static int assign_thread_input( struct thread *thread, struct thread_input *new_
|
||||
@@ -343,13 +343,13 @@ static int assign_thread_input( struct thread *thread, struct thread_input *new_
|
||||
|
||||
/* allocate a hardware message and its data */
|
||||
static struct message *alloc_hardware_message( lparam_t info, struct hw_msg_source source,
|
||||
@@ -29,7 +29,7 @@ index 9dca519cad2..364c8e43485 100644
|
||||
{
|
||||
free( msg );
|
||||
return NULL;
|
||||
@@ -413,9 +413,9 @@ static struct message *alloc_hardware_message( lparam_t info, struct hw_msg_sour
|
||||
@@ -358,9 +358,9 @@ static struct message *alloc_hardware_message( lparam_t info, struct hw_msg_sour
|
||||
msg->type = MSG_HARDWARE;
|
||||
msg->time = time;
|
||||
msg->data = msg_data;
|
||||
@@ -41,7 +41,7 @@ index 9dca519cad2..364c8e43485 100644
|
||||
msg_data->info = info;
|
||||
msg_data->source = source;
|
||||
return msg;
|
||||
@@ -448,7 +448,7 @@ static void set_cursor_pos( struct desktop *desktop, int x, int y )
|
||||
@@ -393,7 +393,7 @@ static void set_cursor_pos( struct desktop *desktop, int x, int y )
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -50,26 +50,26 @@ index 9dca519cad2..364c8e43485 100644
|
||||
|
||||
msg->msg = WM_MOUSEMOVE;
|
||||
msg->x = x;
|
||||
@@ -1756,6 +1756,8 @@ struct rawinput_message
|
||||
struct hw_msg_source source;
|
||||
unsigned int time;
|
||||
struct hardware_msg_data data;
|
||||
+ const void *extra;
|
||||
+ data_size_t extra_len;
|
||||
@@ -1649,6 +1649,8 @@ struct rawinput_message
|
||||
struct hw_msg_source source;
|
||||
unsigned int time;
|
||||
struct hardware_msg_data data;
|
||||
+ const void *extra;
|
||||
+ data_size_t extra_len;
|
||||
};
|
||||
|
||||
static int queue_rawinput_message( struct process* process, void* user )
|
||||
@@ -1765,6 +1767,7 @@ static int queue_rawinput_message( struct process* process, void* user )
|
||||
struct desktop *desktop = NULL;
|
||||
struct thread *thread = NULL, *foreground = NULL;
|
||||
/* check if process is supposed to receive a WM_INPUT message and eventually queue it */
|
||||
@@ -1659,6 +1661,7 @@ static int queue_rawinput_message( struct process* process, void *arg )
|
||||
struct desktop *target_desktop = NULL;
|
||||
struct thread *target_thread = NULL;
|
||||
struct message *msg;
|
||||
+ struct hardware_msg_data *msg_data;
|
||||
int wparam = RIM_INPUT;
|
||||
|
||||
if (raw_msg->data.rawinput.type == RIM_TYPEMOUSE)
|
||||
device = process->rawinput_mouse;
|
||||
@@ -1787,14 +1790,18 @@ static int queue_rawinput_message( struct process* process, void* user )
|
||||
thread->process != foreground->process)
|
||||
goto done;
|
||||
@@ -1676,14 +1679,18 @@ static int queue_rawinput_message( struct process* process, void *arg )
|
||||
wparam = RIM_INPUTSINK;
|
||||
}
|
||||
|
||||
- if (!(msg = alloc_hardware_message( raw_msg->data.info, raw_msg->source, raw_msg->time )))
|
||||
+ if (!(msg = alloc_hardware_message( raw_msg->data.info, raw_msg->source, raw_msg->time, raw_msg->extra_len )))
|
||||
@@ -78,7 +78,7 @@ index 9dca519cad2..364c8e43485 100644
|
||||
|
||||
msg->win = device->target;
|
||||
msg->msg = WM_INPUT;
|
||||
msg->wparam = RIM_INPUT;
|
||||
msg->wparam = wparam;
|
||||
msg->lparam = 0;
|
||||
- memcpy( msg->data, &raw_msg->data, sizeof(raw_msg->data) );
|
||||
+
|
||||
@@ -86,24 +86,18 @@ index 9dca519cad2..364c8e43485 100644
|
||||
+ if (raw_msg->extra_len && raw_msg->extra)
|
||||
+ memcpy( msg_data + 1, raw_msg->extra, raw_msg->extra_len );
|
||||
|
||||
queue_hardware_message( desktop, msg, 0 );
|
||||
queue_hardware_message( raw_msg->desktop, msg, 1 );
|
||||
|
||||
@@ -1863,9 +1870,11 @@ static int queue_mouse_message( struct desktop *desktop, user_handle_t win, cons
|
||||
|
||||
if (req_flags & SEND_HWMSG_RAWINPUT)
|
||||
{
|
||||
- raw_msg.desktop = desktop;
|
||||
- raw_msg.source = source;
|
||||
- raw_msg.time = time;
|
||||
+ raw_msg.desktop = desktop;
|
||||
+ raw_msg.source = source;
|
||||
+ raw_msg.time = time;
|
||||
+ raw_msg.extra = NULL;
|
||||
+ raw_msg.extra_len = 0;
|
||||
@@ -1756,6 +1763,8 @@ static int queue_mouse_message( struct desktop *desktop, user_handle_t win, cons
|
||||
raw_msg.desktop = desktop;
|
||||
raw_msg.source = source;
|
||||
raw_msg.time = time;
|
||||
+ raw_msg.extra = NULL;
|
||||
+ raw_msg.extra_len = 0;
|
||||
|
||||
msg_data = &raw_msg.data;
|
||||
msg_data->info = input->mouse.info;
|
||||
@@ -1895,7 +1904,7 @@ static int queue_mouse_message( struct desktop *desktop, user_handle_t win, cons
|
||||
@@ -1785,7 +1794,7 @@ static int queue_mouse_message( struct desktop *desktop, user_handle_t win, cons
|
||||
if (!(flags & (1 << i))) continue;
|
||||
flags &= ~(1 << i);
|
||||
|
||||
@@ -112,23 +106,17 @@ index 9dca519cad2..364c8e43485 100644
|
||||
msg_data = msg->data;
|
||||
|
||||
msg->win = get_user_full_handle( win );
|
||||
@@ -1999,9 +2008,11 @@ static int queue_keyboard_message( struct desktop *desktop, user_handle_t win, c
|
||||
|
||||
if (req_flags & SEND_HWMSG_RAWINPUT)
|
||||
{
|
||||
- raw_msg.desktop = desktop;
|
||||
- raw_msg.source = source;
|
||||
- raw_msg.time = time;
|
||||
+ raw_msg.desktop = desktop;
|
||||
+ raw_msg.source = source;
|
||||
+ raw_msg.time = time;
|
||||
+ raw_msg.extra = NULL;
|
||||
+ raw_msg.extra_len = 0;
|
||||
@@ -1894,6 +1903,8 @@ static int queue_keyboard_message( struct desktop *desktop, user_handle_t win, c
|
||||
raw_msg.desktop = desktop;
|
||||
raw_msg.source = source;
|
||||
raw_msg.time = time;
|
||||
+ raw_msg.extra = NULL;
|
||||
+ raw_msg.extra_len = 0;
|
||||
|
||||
msg_data = &raw_msg.data;
|
||||
msg_data->info = input->kbd.info;
|
||||
@@ -2022,7 +2033,7 @@ static int queue_keyboard_message( struct desktop *desktop, user_handle_t win, c
|
||||
if ((device = current->process->rawinput_kbd) && (device->flags & RIDEV_NOLEGACY))
|
||||
@@ -1917,7 +1928,7 @@ static int queue_keyboard_message( struct desktop *desktop, user_handle_t win, c
|
||||
if (!(req_flags & SEND_HWMSG_WINDOW))
|
||||
return 0;
|
||||
|
||||
- if (!(msg = alloc_hardware_message( input->kbd.info, source, time ))) return 0;
|
||||
@@ -136,7 +124,7 @@ index 9dca519cad2..364c8e43485 100644
|
||||
msg_data = msg->data;
|
||||
|
||||
msg->win = get_user_full_handle( win );
|
||||
@@ -2060,7 +2071,7 @@ static void queue_custom_hardware_message( struct desktop *desktop, user_handle_
|
||||
@@ -1955,7 +1966,7 @@ static void queue_custom_hardware_message( struct desktop *desktop, user_handle_
|
||||
struct hw_msg_source source = { IMDT_UNAVAILABLE, origin };
|
||||
struct message *msg;
|
||||
|
||||
@@ -146,5 +134,5 @@ index 9dca519cad2..364c8e43485 100644
|
||||
msg->win = get_user_full_handle( win );
|
||||
msg->msg = input->hw.msg;
|
||||
--
|
||||
2.17.1
|
||||
2.27.0
|
||||
|
||||
|
@@ -0,0 +1,64 @@
|
||||
From eee5ecbed5c813be03d4b540675f1c4792101567 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?R=C3=A9mi=20Bernon?= <rbernon@codeweavers.com>
|
||||
Date: Mon, 11 Nov 2019 18:35:18 +0100
|
||||
Subject: [PATCH] server: Make it possible to queue rawinput message on all
|
||||
desktops.
|
||||
|
||||
---
|
||||
server/queue.c | 18 +++++++++++++-----
|
||||
1 file changed, 13 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/server/queue.c b/server/queue.c
|
||||
index f5d19031485..59c6cbb6921 100644
|
||||
--- a/server/queue.c
|
||||
+++ b/server/queue.c
|
||||
@@ -1658,8 +1658,8 @@ static int queue_rawinput_message( struct process* process, void *arg )
|
||||
{
|
||||
const struct rawinput_message* raw_msg = arg;
|
||||
const struct rawinput_device *device = NULL;
|
||||
- struct desktop *target_desktop = NULL;
|
||||
- struct thread *target_thread = NULL;
|
||||
+ struct desktop *target_desktop = NULL, *desktop = NULL;
|
||||
+ struct thread *target_thread = NULL, *foreground = NULL;
|
||||
struct message *msg;
|
||||
struct hardware_msg_data *msg_data;
|
||||
int wparam = RIM_INPUT;
|
||||
@@ -1670,12 +1670,18 @@ static int queue_rawinput_message( struct process* process, void *arg )
|
||||
device = process->rawinput_kbd;
|
||||
if (!device) return 0;
|
||||
|
||||
- if (process != raw_msg->foreground->process)
|
||||
+ if (raw_msg->desktop) desktop = (struct desktop *)grab_object( raw_msg->desktop );
|
||||
+ else if (!(desktop = get_desktop_obj( process, process->desktop, 0 ))) goto done;
|
||||
+
|
||||
+ if (raw_msg->foreground) foreground = (struct thread *)grab_object( raw_msg->foreground );
|
||||
+ else if (!(foreground = get_foreground_thread( desktop, 0 ))) goto done;
|
||||
+
|
||||
+ if (process != foreground->process)
|
||||
{
|
||||
if (!(device->flags & RIDEV_INPUTSINK)) goto done;
|
||||
if (!(target_thread = get_window_thread( device->target ))) goto done;
|
||||
if (!(target_desktop = get_thread_desktop( target_thread, 0 ))) goto done;
|
||||
- if (target_desktop != raw_msg->desktop) goto done;
|
||||
+ if (target_desktop != desktop) goto done;
|
||||
wparam = RIM_INPUTSINK;
|
||||
}
|
||||
|
||||
@@ -1692,11 +1698,13 @@ static int queue_rawinput_message( struct process* process, void *arg )
|
||||
if (raw_msg->extra_len && raw_msg->extra)
|
||||
memcpy( msg_data + 1, raw_msg->extra, raw_msg->extra_len );
|
||||
|
||||
- queue_hardware_message( raw_msg->desktop, msg, 1 );
|
||||
+ queue_hardware_message( desktop, msg, 1 );
|
||||
|
||||
done:
|
||||
if (target_thread) release_object( target_thread );
|
||||
if (target_desktop) release_object( target_desktop );
|
||||
+ if (foreground) release_object( foreground );
|
||||
+ if (desktop) release_object( desktop );
|
||||
return 0;
|
||||
}
|
||||
|
||||
--
|
||||
2.27.0
|
||||
|
@@ -1,21 +1,23 @@
|
||||
From d0347613c7149144d4339109b641901537c4c326 Mon Sep 17 00:00:00 2001
|
||||
From 2c92d595325accce44db85552efda8070f526569 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?R=C3=A9mi=20Bernon?= <rbernon@codeweavers.com>
|
||||
Date: Mon, 11 Nov 2019 18:35:18 +0100
|
||||
Subject: [PATCH 3/5] server: Add HID input message type to
|
||||
send_hardware_message request.
|
||||
Subject: [PATCH] server: Add HID input message type to send_hardware_message
|
||||
request.
|
||||
|
||||
---
|
||||
dlls/user32/message.c | 4 +++-
|
||||
server/protocol.def | 26 +++++++++++++++++++---
|
||||
server/queue.c | 50 ++++++++++++++++++++++++++++++++++++++-----
|
||||
server/trace.c | 10 ++++++---
|
||||
4 files changed, 78 insertions(+), 12 deletions(-)
|
||||
dlls/user32/message.c | 4 ++-
|
||||
dlls/user32/rawinput.c | 60 ++++++++++++++++++++++++++++++++++++--
|
||||
dlls/user32/user_private.h | 2 ++
|
||||
server/protocol.def | 26 +++++++++++++++--
|
||||
server/queue.c | 58 +++++++++++++++++++++++++++++++-----
|
||||
server/trace.c | 10 +++++--
|
||||
6 files changed, 143 insertions(+), 17 deletions(-)
|
||||
|
||||
diff --git a/dlls/user32/message.c b/dlls/user32/message.c
|
||||
index cc25d2f6c2f..55bbe409c9e 100644
|
||||
index c5c7db667cf..bb7c79b9b2c 100644
|
||||
--- a/dlls/user32/message.c
|
||||
+++ b/dlls/user32/message.c
|
||||
@@ -3354,10 +3354,10 @@ NTSTATUS send_hardware_message( HWND hwnd, const INPUT *input, UINT flags )
|
||||
@@ -3244,10 +3244,10 @@ NTSTATUS send_hardware_message( HWND hwnd, const INPUT *input, UINT flags )
|
||||
{
|
||||
req->win = wine_server_user_handle( hwnd );
|
||||
req->flags = flags;
|
||||
@@ -27,7 +29,7 @@ index cc25d2f6c2f..55bbe409c9e 100644
|
||||
req->input.mouse.x = input->u.mi.dx;
|
||||
req->input.mouse.y = input->u.mi.dy;
|
||||
req->input.mouse.data = input->u.mi.mouseData;
|
||||
@@ -3366,6 +3366,7 @@ NTSTATUS send_hardware_message( HWND hwnd, const INPUT *input, UINT flags )
|
||||
@@ -3256,6 +3256,7 @@ NTSTATUS send_hardware_message( HWND hwnd, const INPUT *input, UINT flags )
|
||||
req->input.mouse.info = input->u.mi.dwExtraInfo;
|
||||
break;
|
||||
case INPUT_KEYBOARD:
|
||||
@@ -35,7 +37,7 @@ index cc25d2f6c2f..55bbe409c9e 100644
|
||||
req->input.kbd.vkey = input->u.ki.wVk;
|
||||
req->input.kbd.scan = input->u.ki.wScan;
|
||||
req->input.kbd.flags = input->u.ki.dwFlags;
|
||||
@@ -3373,6 +3374,7 @@ NTSTATUS send_hardware_message( HWND hwnd, const INPUT *input, UINT flags )
|
||||
@@ -3263,6 +3264,7 @@ NTSTATUS send_hardware_message( HWND hwnd, const INPUT *input, UINT flags )
|
||||
req->input.kbd.info = input->u.ki.dwExtraInfo;
|
||||
break;
|
||||
case INPUT_HARDWARE:
|
||||
@@ -43,11 +45,139 @@ index cc25d2f6c2f..55bbe409c9e 100644
|
||||
req->input.hw.msg = input->u.hi.uMsg;
|
||||
req->input.hw.lparam = MAKELONG( input->u.hi.wParamL, input->u.hi.wParamH );
|
||||
break;
|
||||
diff --git a/dlls/user32/rawinput.c b/dlls/user32/rawinput.c
|
||||
index 43da5248faf..90dc911397d 100644
|
||||
--- a/dlls/user32/rawinput.c
|
||||
+++ b/dlls/user32/rawinput.c
|
||||
@@ -47,6 +47,7 @@ struct device
|
||||
{
|
||||
WCHAR *path;
|
||||
HANDLE file;
|
||||
+ HANDLE handle;
|
||||
RID_DEVICE_INFO info;
|
||||
PHIDP_PREPARSED_DATA data;
|
||||
};
|
||||
@@ -63,6 +64,8 @@ static CRITICAL_SECTION_DEBUG rawinput_devices_cs_debug =
|
||||
};
|
||||
static CRITICAL_SECTION rawinput_devices_cs = { &rawinput_devices_cs_debug, -1, 0, 0, 0, 0 };
|
||||
|
||||
+extern DWORD WINAPI GetFinalPathNameByHandleW(HANDLE file, LPWSTR path, DWORD charcount, DWORD flags);
|
||||
+
|
||||
static BOOL array_reserve(void **elements, unsigned int *capacity, unsigned int count, unsigned int size)
|
||||
{
|
||||
unsigned int new_capacity, max_capacity;
|
||||
@@ -144,10 +147,43 @@ static struct device *add_device(HDEVINFO set, SP_DEVICE_INTERFACE_DATA *iface)
|
||||
device->path = path;
|
||||
device->file = file;
|
||||
device->info.cbSize = sizeof(RID_DEVICE_INFO);
|
||||
+ device->handle = INVALID_HANDLE_VALUE;
|
||||
|
||||
return device;
|
||||
}
|
||||
|
||||
+HANDLE rawinput_handle_from_device_handle(HANDLE device)
|
||||
+{
|
||||
+ WCHAR buffer[sizeof(OBJECT_NAME_INFORMATION) + MAX_PATH + 1];
|
||||
+ OBJECT_NAME_INFORMATION *info = (OBJECT_NAME_INFORMATION*)&buffer;
|
||||
+ ULONG dummy;
|
||||
+ unsigned int i;
|
||||
+
|
||||
+ for (i = 0; i < rawinput_devices_count; ++i)
|
||||
+ {
|
||||
+ if (rawinput_devices[i].handle == device)
|
||||
+ return &rawinput_devices[i];
|
||||
+ }
|
||||
+
|
||||
+ if (NtQueryObject( device, ObjectNameInformation, &buffer, sizeof(buffer) - sizeof(WCHAR), &dummy ) || !info->Name.Buffer)
|
||||
+ return NULL;
|
||||
+
|
||||
+ /* replace \??\ with \\?\ to match rawinput_devices paths */
|
||||
+ if (info->Name.Length > 1 && info->Name.Buffer[0] == '\\' && info->Name.Buffer[1] == '?')
|
||||
+ info->Name.Buffer[1] = '\\';
|
||||
+
|
||||
+ for (i = 0; i < rawinput_devices_count; ++i)
|
||||
+ {
|
||||
+ if (strcmpW(rawinput_devices[i].path, info->Name.Buffer) == 0)
|
||||
+ {
|
||||
+ rawinput_devices[i].handle = device;
|
||||
+ return &rawinput_devices[i];
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
static void find_devices(void)
|
||||
{
|
||||
static ULONGLONG last_check;
|
||||
@@ -325,6 +361,22 @@ BOOL rawinput_from_hardware_message(RAWINPUT *rawinput, const struct hardware_ms
|
||||
rawinput->data.keyboard.Message = msg_data->rawinput.kbd.message;
|
||||
rawinput->data.keyboard.ExtraInformation = msg_data->info;
|
||||
}
|
||||
+ else if (msg_data->rawinput.type == RIM_TYPEHID)
|
||||
+ {
|
||||
+ if (sizeof(*rawinput) + msg_data->rawinput.hid.length > RAWINPUT_BUFFER_SIZE)
|
||||
+ {
|
||||
+ ERR("unexpectedly large hardware message dropped\n");
|
||||
+ return FALSE;
|
||||
+ }
|
||||
+
|
||||
+ rawinput->header.dwSize = FIELD_OFFSET(RAWINPUT, data.hid.bRawData) + msg_data->rawinput.hid.length;
|
||||
+ rawinput->header.hDevice = rawinput_handle_from_device_handle(wine_server_ptr_handle(msg_data->rawinput.hid.device));
|
||||
+ rawinput->header.wParam = 0;
|
||||
+
|
||||
+ rawinput->data.hid.dwSizeHid = msg_data->rawinput.hid.length;
|
||||
+ rawinput->data.hid.dwCount = 1;
|
||||
+ memcpy(rawinput->data.hid.bRawData, msg_data + 1, msg_data->rawinput.hid.length);
|
||||
+ }
|
||||
else
|
||||
{
|
||||
FIXME("Unhandled rawinput type %#x.\n", msg_data->rawinput.type);
|
||||
@@ -514,7 +566,7 @@ UINT WINAPI DECLSPEC_HOTPATCH GetRawInputBuffer(RAWINPUT *data, UINT *data_size,
|
||||
{
|
||||
struct hardware_msg_data *msg_data;
|
||||
RAWINPUT *rawinput;
|
||||
- UINT count = 0, rawinput_size, next_size, overhead;
|
||||
+ UINT count = 0, rawinput_size, msg_size, next_size, overhead;
|
||||
BOOL is_wow64;
|
||||
int i;
|
||||
|
||||
@@ -572,7 +624,10 @@ UINT WINAPI DECLSPEC_HOTPATCH GetRawInputBuffer(RAWINPUT *data, UINT *data_size,
|
||||
data->header.dwSize - sizeof(RAWINPUTHEADER));
|
||||
data->header.dwSize += overhead;
|
||||
data = NEXTRAWINPUTBLOCK(data);
|
||||
- msg_data++;
|
||||
+ msg_size = sizeof(*msg_data);
|
||||
+ if (msg_data->rawinput.type == RIM_TYPEHID)
|
||||
+ msg_size += msg_data->rawinput.hid.length;
|
||||
+ msg_data = (struct hardware_msg_data *)((char *)msg_data + msg_size);
|
||||
}
|
||||
|
||||
if (count == 0 && next_size == 0) *data_size = 0;
|
||||
@@ -647,6 +702,7 @@ UINT WINAPI GetRawInputDeviceInfoW(HANDLE handle, UINT command, void *data, UINT
|
||||
handle, command, data, data_size);
|
||||
|
||||
if (!data_size) return ~0U;
|
||||
+ if (!device) return ~0U;
|
||||
|
||||
/* each case below must set:
|
||||
* *data_size: length (meaning defined by command) of data we want to copy
|
||||
diff --git a/dlls/user32/user_private.h b/dlls/user32/user_private.h
|
||||
index eb828203597..6592927cfae 100644
|
||||
--- a/dlls/user32/user_private.h
|
||||
+++ b/dlls/user32/user_private.h
|
||||
@@ -380,4 +380,6 @@ static inline WCHAR *heap_strdupW(const WCHAR *src)
|
||||
return dst;
|
||||
}
|
||||
|
||||
+extern HANDLE rawinput_handle_from_device_handle(HANDLE device);
|
||||
+
|
||||
#endif /* __WINE_USER_PRIVATE_H */
|
||||
diff --git a/server/protocol.def b/server/protocol.def
|
||||
index d37dceba40c..85cc2ac6937 100644
|
||||
index 21de849e5d8..d49c33f63f9 100644
|
||||
--- a/server/protocol.def
|
||||
+++ b/server/protocol.def
|
||||
@@ -321,6 +321,13 @@ struct hardware_msg_data
|
||||
@@ -312,6 +312,13 @@ struct hardware_msg_data
|
||||
int y; /* y coordinate */
|
||||
unsigned int data; /* mouse data */
|
||||
} mouse;
|
||||
@@ -61,7 +191,7 @@ index d37dceba40c..85cc2ac6937 100644
|
||||
} rawinput;
|
||||
};
|
||||
|
||||
@@ -344,7 +351,7 @@ typedef union
|
||||
@@ -335,7 +342,7 @@ typedef union
|
||||
int type;
|
||||
struct
|
||||
{
|
||||
@@ -70,7 +200,7 @@ index d37dceba40c..85cc2ac6937 100644
|
||||
unsigned short vkey; /* virtual key code */
|
||||
unsigned short scan; /* scan code */
|
||||
unsigned int flags; /* event flags */
|
||||
@@ -353,7 +360,7 @@ typedef union
|
||||
@@ -344,7 +351,7 @@ typedef union
|
||||
} kbd;
|
||||
struct
|
||||
{
|
||||
@@ -79,7 +209,7 @@ index d37dceba40c..85cc2ac6937 100644
|
||||
int x; /* coordinates */
|
||||
int y;
|
||||
unsigned int data; /* mouse data */
|
||||
@@ -363,11 +370,23 @@ typedef union
|
||||
@@ -354,11 +361,23 @@ typedef union
|
||||
} mouse;
|
||||
struct
|
||||
{
|
||||
@@ -104,7 +234,7 @@ index d37dceba40c..85cc2ac6937 100644
|
||||
|
||||
typedef union
|
||||
{
|
||||
@@ -2361,6 +2380,7 @@ enum message_type
|
||||
@@ -2330,6 +2349,7 @@ enum message_type
|
||||
user_handle_t win; /* window handle */
|
||||
hw_input_t input; /* input data */
|
||||
unsigned int flags; /* flags (see below) */
|
||||
@@ -113,10 +243,10 @@ index d37dceba40c..85cc2ac6937 100644
|
||||
int wait; /* do we need to wait for a reply? */
|
||||
int prev_x; /* previous cursor position */
|
||||
diff --git a/server/queue.c b/server/queue.c
|
||||
index feff00e2b9f..85aa896c7bd 100644
|
||||
index 59c6cbb6921..fbed47d6951 100644
|
||||
--- a/server/queue.c
|
||||
+++ b/server/queue.c
|
||||
@@ -1698,7 +1698,7 @@ static int send_hook_ll_message( struct desktop *desktop, struct message *hardwa
|
||||
@@ -1594,7 +1594,7 @@ static int send_hook_ll_message( struct desktop *desktop, struct message *hardwa
|
||||
struct msg_queue *queue;
|
||||
struct message *msg;
|
||||
timeout_t timeout = 2000 * -10000; /* FIXME: load from registry */
|
||||
@@ -125,7 +255,7 @@ index feff00e2b9f..85aa896c7bd 100644
|
||||
|
||||
if (!(hook_thread = get_first_global_hook( id ))) return 0;
|
||||
if (!(queue = hook_thread->queue)) return 0;
|
||||
@@ -1716,7 +1716,7 @@ static int send_hook_ll_message( struct desktop *desktop, struct message *hardwa
|
||||
@@ -1612,7 +1612,7 @@ static int send_hook_ll_message( struct desktop *desktop, struct message *hardwa
|
||||
msg->data_size = hardware_msg->data_size;
|
||||
msg->result = NULL;
|
||||
|
||||
@@ -134,33 +264,33 @@ index feff00e2b9f..85aa896c7bd 100644
|
||||
{
|
||||
unsigned short vkey = input->kbd.vkey;
|
||||
if (input->kbd.flags & KEYEVENTF_UNICODE) vkey = VK_PACKET;
|
||||
@@ -1742,6 +1742,8 @@ struct rawinput_message
|
||||
struct desktop *desktop;
|
||||
struct hw_msg_source source;
|
||||
unsigned int time;
|
||||
+ unsigned char usage_page;
|
||||
+ unsigned char usage;
|
||||
struct hardware_msg_data data;
|
||||
const void *extra;
|
||||
data_size_t extra_len;
|
||||
@@ -1750,6 +1752,7 @@ struct rawinput_message
|
||||
static int queue_rawinput_message( struct process* process, void* user )
|
||||
@@ -1648,6 +1648,8 @@ struct rawinput_message
|
||||
struct desktop *desktop;
|
||||
struct hw_msg_source source;
|
||||
unsigned int time;
|
||||
+ unsigned char usage_page;
|
||||
+ unsigned char usage;
|
||||
struct hardware_msg_data data;
|
||||
const void *extra;
|
||||
data_size_t extra_len;
|
||||
@@ -1657,6 +1659,7 @@ struct rawinput_message
|
||||
static int queue_rawinput_message( struct process* process, void *arg )
|
||||
{
|
||||
const struct rawinput_message* raw_msg = user;
|
||||
const struct rawinput_message* raw_msg = arg;
|
||||
+ const struct rawinput_device_entry *entry;
|
||||
const struct rawinput_device *device = NULL;
|
||||
struct desktop *desktop = NULL;
|
||||
struct thread *thread = NULL, *foreground = NULL;
|
||||
@@ -1760,6 +1763,8 @@ static int queue_rawinput_message( struct process* process, void* user )
|
||||
struct desktop *target_desktop = NULL, *desktop = NULL;
|
||||
struct thread *target_thread = NULL, *foreground = NULL;
|
||||
@@ -1668,6 +1671,8 @@ static int queue_rawinput_message( struct process* process, void *arg )
|
||||
device = process->rawinput_mouse;
|
||||
else if (raw_msg->data.rawinput.type == RIM_TYPEKEYBOARD)
|
||||
device = process->rawinput_kbd;
|
||||
+ else if ((entry = find_rawinput_device( process, raw_msg->usage_page, raw_msg->usage )))
|
||||
+ device = &entry->device;
|
||||
if (!device) return 0;
|
||||
|
||||
if (!device)
|
||||
goto done;
|
||||
@@ -2067,6 +2072,38 @@ static void queue_custom_hardware_message( struct desktop *desktop, user_handle_
|
||||
if (raw_msg->desktop) desktop = (struct desktop *)grab_object( raw_msg->desktop );
|
||||
@@ -1986,6 +1991,37 @@ static void queue_custom_hardware_message( struct desktop *desktop, user_handle_
|
||||
queue_hardware_message( desktop, msg, 1 );
|
||||
}
|
||||
|
||||
@@ -176,7 +306,9 @@ index feff00e2b9f..85aa896c7bd 100644
|
||||
+ if (!(req_flags & SEND_HWMSG_RAWINPUT))
|
||||
+ return;
|
||||
+
|
||||
+ raw_msg.desktop = NULL; /* send to all desktops */
|
||||
+ /* send to all desktops */
|
||||
+ raw_msg.foreground = NULL;
|
||||
+ raw_msg.desktop = NULL;
|
||||
+ raw_msg.source = source;
|
||||
+ raw_msg.time = get_tick_count();
|
||||
+ raw_msg.usage_page = input->hid.usage_page;
|
||||
@@ -190,16 +322,13 @@ index feff00e2b9f..85aa896c7bd 100644
|
||||
+ msg_data->rawinput.hid.device = input->hid.device;
|
||||
+ msg_data->rawinput.hid.length = report_len;
|
||||
+
|
||||
+ if (req_flags == SEND_HWMSG_RAWINPUT)
|
||||
+ enum_processes( queue_rawinput_message, &raw_msg );
|
||||
+ else
|
||||
+ queue_rawinput_message( current->process, &raw_msg );
|
||||
+ enum_processes( queue_rawinput_message, &raw_msg );
|
||||
+}
|
||||
+
|
||||
/* check message filter for a hardware message */
|
||||
static int check_hw_message_filter( user_handle_t win, unsigned int msg_code,
|
||||
user_handle_t filter_win, unsigned int first, unsigned int last )
|
||||
@@ -2577,15 +2614,18 @@ DECL_HANDLER(send_hardware_message)
|
||||
@@ -2491,15 +2527,18 @@ DECL_HANDLER(send_hardware_message)
|
||||
|
||||
switch (req->input.type)
|
||||
{
|
||||
@@ -221,11 +350,38 @@ index feff00e2b9f..85aa896c7bd 100644
|
||||
default:
|
||||
set_error( STATUS_INVALID_PARAMETER );
|
||||
}
|
||||
@@ -3271,20 +3310,23 @@ DECL_HANDLER(get_rawinput_buffer)
|
||||
{
|
||||
struct message *msg = LIST_ENTRY( ptr, struct message, entry );
|
||||
struct hardware_msg_data *data = msg->data;
|
||||
+ data_size_t msg_size = sizeof(*data);
|
||||
+ if (data->rawinput.type == RIM_TYPEHID)
|
||||
+ msg_size += data->rawinput.hid.length;
|
||||
|
||||
ptr = list_next( &input->msg_list, ptr );
|
||||
if (msg->msg != WM_INPUT) continue;
|
||||
|
||||
next_size = req->rawinput_size;
|
||||
if (size + next_size > req->buffer_size) break;
|
||||
- if (cur + sizeof(*data) > buf + get_reply_max_size()) break;
|
||||
+ if (cur + msg_size > buf + get_reply_max_size()) break;
|
||||
|
||||
- memcpy(cur, data, sizeof(*data));
|
||||
+ memcpy(cur, data, msg_size);
|
||||
list_remove( &msg->entry );
|
||||
free_message( msg );
|
||||
|
||||
size += next_size;
|
||||
- cur += sizeof(*data);
|
||||
+ cur += msg_size;
|
||||
count++;
|
||||
}
|
||||
|
||||
diff --git a/server/trace.c b/server/trace.c
|
||||
index 18b56c729e4..c39c56087c1 100644
|
||||
index 2fb5afd5ef1..bbf129ca4f1 100644
|
||||
--- a/server/trace.c
|
||||
+++ b/server/trace.c
|
||||
@@ -381,24 +381,28 @@ static void dump_hw_input( const char *prefix, const hw_input_t *input )
|
||||
@@ -386,24 +386,28 @@ static void dump_hw_input( const char *prefix, const hw_input_t *input )
|
||||
{
|
||||
switch (input->type)
|
||||
{
|
||||
@@ -258,5 +414,5 @@ index 18b56c729e4..c39c56087c1 100644
|
||||
fprintf( stderr, "%s{type=%04x}", prefix, input->type );
|
||||
break;
|
||||
--
|
||||
2.24.1
|
||||
2.27.0
|
||||
|
@@ -1,138 +0,0 @@
|
||||
From a6c66494095012c8a867bf4ee6f44fbebf7bd69a Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?R=C3=A9mi=20Bernon?= <rbernon@codeweavers.com>
|
||||
Date: Thu, 12 Sep 2019 14:48:23 +0200
|
||||
Subject: [PATCH] user32: Implement WM_INPUT/RIM_TYPEHID message handling.
|
||||
|
||||
---
|
||||
dlls/user32/message.c | 19 ++++++++++++++++++-
|
||||
dlls/user32/rawinput.c | 37 +++++++++++++++++++++++++++++++++++++
|
||||
dlls/user32/user_private.h | 2 ++
|
||||
3 files changed, 57 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/dlls/user32/message.c b/dlls/user32/message.c
|
||||
index 8c915629613..5e8ae1e5fb5 100644
|
||||
--- a/dlls/user32/message.c
|
||||
+++ b/dlls/user32/message.c
|
||||
@@ -2285,10 +2285,17 @@ static BOOL process_rawinput_message( MSG *msg, const struct hardware_msg_data *
|
||||
{
|
||||
struct user_thread_info *thread_info = get_user_thread_info();
|
||||
RAWINPUT *rawinput = thread_info->rawinput;
|
||||
+ SIZE_T data_len = 0;
|
||||
+
|
||||
+ if (msg_data->rawinput.type == RIM_TYPEHID)
|
||||
+ {
|
||||
+ data_len = msg_data->rawinput.hid.length;
|
||||
+ rawinput = thread_info->rawinput = HeapReAlloc( GetProcessHeap(), 0, rawinput, sizeof(*rawinput) + data_len );
|
||||
+ }
|
||||
|
||||
if (!rawinput)
|
||||
{
|
||||
- thread_info->rawinput = HeapAlloc( GetProcessHeap(), 0, sizeof(*rawinput) );
|
||||
+ thread_info->rawinput = HeapAlloc( GetProcessHeap(), 0, sizeof(*rawinput) + data_len );
|
||||
if (!(rawinput = thread_info->rawinput)) return FALSE;
|
||||
}
|
||||
|
||||
@@ -2383,6 +2390,16 @@ static BOOL process_rawinput_message( MSG *msg, const struct hardware_msg_data *
|
||||
rawinput->data.keyboard.Message = msg_data->rawinput.kbd.message;
|
||||
rawinput->data.keyboard.ExtraInformation = msg_data->info;
|
||||
}
|
||||
+ else if (msg_data->rawinput.type == RIM_TYPEHID)
|
||||
+ {
|
||||
+ rawinput->header.dwSize = FIELD_OFFSET(RAWINPUT, data.hid.bRawData) + data_len;
|
||||
+ rawinput->header.hDevice = rawinput_handle_from_device_handle(wine_server_ptr_handle(msg_data->rawinput.hid.device));
|
||||
+ rawinput->header.wParam = 0;
|
||||
+
|
||||
+ rawinput->data.hid.dwSizeHid = data_len;
|
||||
+ rawinput->data.hid.dwCount = 1;
|
||||
+ memcpy(rawinput->data.hid.bRawData, msg_data + 1, data_len);
|
||||
+ }
|
||||
else
|
||||
{
|
||||
FIXME("Unhandled rawinput type %#x.\n", msg_data->rawinput.type);
|
||||
diff --git a/dlls/user32/rawinput.c b/dlls/user32/rawinput.c
|
||||
index 0c72b3343ae..5211999e836 100644
|
||||
--- a/dlls/user32/rawinput.c
|
||||
+++ b/dlls/user32/rawinput.c
|
||||
@@ -46,6 +46,7 @@ struct device
|
||||
{
|
||||
WCHAR *path;
|
||||
HANDLE file;
|
||||
+ HANDLE handle;
|
||||
RID_DEVICE_INFO info;
|
||||
PHIDP_PREPARSED_DATA data;
|
||||
};
|
||||
@@ -62,6 +63,8 @@ static CRITICAL_SECTION_DEBUG rawinput_devices_cs_debug =
|
||||
};
|
||||
static CRITICAL_SECTION rawinput_devices_cs = { &rawinput_devices_cs_debug, -1, 0, 0, 0, 0 };
|
||||
|
||||
+extern DWORD WINAPI GetFinalPathNameByHandleW(HANDLE file, LPWSTR path, DWORD charcount, DWORD flags);
|
||||
+
|
||||
static BOOL array_reserve(void **elements, unsigned int *capacity, unsigned int count, unsigned int size)
|
||||
{
|
||||
unsigned int new_capacity, max_capacity;
|
||||
@@ -143,10 +146,43 @@ static struct device *add_device(HDEVINFO set, SP_DEVICE_INTERFACE_DATA *iface)
|
||||
device->path = path;
|
||||
device->file = file;
|
||||
device->info.cbSize = sizeof(RID_DEVICE_INFO);
|
||||
+ device->handle = INVALID_HANDLE_VALUE;
|
||||
|
||||
return device;
|
||||
}
|
||||
|
||||
+HANDLE rawinput_handle_from_device_handle(HANDLE device)
|
||||
+{
|
||||
+ WCHAR buffer[sizeof(OBJECT_NAME_INFORMATION) + MAX_PATH + 1];
|
||||
+ OBJECT_NAME_INFORMATION *info = (OBJECT_NAME_INFORMATION*)&buffer;
|
||||
+ ULONG dummy;
|
||||
+ unsigned int i;
|
||||
+
|
||||
+ for (i = 0; i < rawinput_devices_count; ++i)
|
||||
+ {
|
||||
+ if (rawinput_devices[i].handle == device)
|
||||
+ return &rawinput_devices[i];
|
||||
+ }
|
||||
+
|
||||
+ if (NtQueryObject( device, ObjectNameInformation, &buffer, sizeof(buffer) - sizeof(WCHAR), &dummy ) || !info->Name.Buffer)
|
||||
+ return NULL;
|
||||
+
|
||||
+ /* replace \??\ with \\?\ to match hid_devices paths */
|
||||
+ if (info->Name.Length > 1 && info->Name.Buffer[0] == '\\' && info->Name.Buffer[1] == '?')
|
||||
+ info->Name.Buffer[1] = '\\';
|
||||
+
|
||||
+ for (i = 0; i < rawinput_devices_count; ++i)
|
||||
+ {
|
||||
+ if (strcmpW(rawinput_devices[i].path, info->Name.Buffer) == 0)
|
||||
+ {
|
||||
+ rawinput_devices[i].handle = device;
|
||||
+ return &rawinput_devices[i];
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
static void find_devices(void)
|
||||
{
|
||||
static ULONGLONG last_check;
|
||||
@@ -438,6 +474,7 @@ UINT WINAPI GetRawInputDeviceInfoW(HANDLE handle, UINT command, void *data, UINT
|
||||
handle, command, data, data_size);
|
||||
|
||||
if (!data_size) return ~0U;
|
||||
+ if (!device) return ~0U;
|
||||
|
||||
/* each case below must set:
|
||||
* *data_size: length (meaning defined by command) of data we want to copy
|
||||
diff --git a/dlls/user32/user_private.h b/dlls/user32/user_private.h
|
||||
index 5172423280b..4c478db5449 100644
|
||||
--- a/dlls/user32/user_private.h
|
||||
+++ b/dlls/user32/user_private.h
|
||||
@@ -375,4 +375,6 @@ static inline WCHAR *heap_strdupW(const WCHAR *src)
|
||||
return dst;
|
||||
}
|
||||
|
||||
+extern HANDLE rawinput_handle_from_device_handle(HANDLE device);
|
||||
+
|
||||
#endif /* __WINE_USER_PRIVATE_H */
|
||||
--
|
||||
2.25.1
|
||||
|
@@ -1,8 +1,8 @@
|
||||
From 249548cff4ae17da6731e28a5fafe277a7b3d6ea Mon Sep 17 00:00:00 2001
|
||||
From 8f7a0c92c370cb4bf1ee6e6d7c51a3d90fe4cd48 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?R=C3=A9mi=20Bernon?= <rbernon@codeweavers.com>
|
||||
Date: Wed, 18 Sep 2019 21:04:25 +0200
|
||||
Subject: [PATCH 5/5] hidclass.sys: Send input message to server when HID
|
||||
report is received.
|
||||
Subject: [PATCH] hidclass.sys: Send input message to server when HID report is
|
||||
received.
|
||||
|
||||
---
|
||||
dlls/hidclass.sys/device.c | 30 ++++++++++++++++++++++++++++++
|
||||
@@ -135,5 +135,5 @@ index 1c130e8dd80..b84a358dba4 100644
|
||||
}
|
||||
case IRP_MN_REMOVE_DEVICE:
|
||||
--
|
||||
2.24.1
|
||||
2.27.0
|
||||
|
||||
|
@@ -1,2 +1 @@
|
||||
Depends: user32-rawinput-nolegacy
|
||||
Disabled: true
|
||||
Depends: user32-rawinput-mouse
|
||||
|
Reference in New Issue
Block a user