Rebase against bf454cc39428fc5299e5c26d9c0ddc6a9277c7ae.

This commit is contained in:
Zebediah Figura
2020-06-09 18:27:57 -05:00
parent 9a4c8c5631
commit cb2a6551bc
19 changed files with 362 additions and 347 deletions

View File

@@ -1,4 +1,4 @@
From c2f13f4d65b25a10b2e9dc8a156dbf6adc6e8263 Mon Sep 17 00:00:00 2001
From 7d1d098c5c456e1791bae10dd27996a62c7d993a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?R=C3=A9mi=20Bernon?= <rbernon@codeweavers.com>
Date: Mon, 26 Aug 2019 16:06:59 +0200
Subject: [PATCH] dinput8: Add support for dinput devices that use raw input
@@ -12,16 +12,16 @@ anymore. They will also conflict with any raw input device registered
outside of dinput, as exposed by the unit tests.
---
dlls/dinput/device_private.h | 3 ++
dlls/dinput/dinput_main.c | 84 +++++++++++++++++++++++++++++++++++-
2 files changed, 86 insertions(+), 1 deletion(-)
dlls/dinput/dinput_main.c | 98 ++++++++++++++++++++++++++++++++++--
2 files changed, 97 insertions(+), 4 deletions(-)
diff --git a/dlls/dinput/device_private.h b/dlls/dinput/device_private.h
index 423e8f77792..b0fb181fc6d 100644
index fe5644f21c7..2fac4f0e61e 100644
--- a/dlls/dinput/device_private.h
+++ b/dlls/dinput/device_private.h
@@ -70,6 +70,9 @@ struct IDirectInputDeviceImpl
@@ -69,6 +69,9 @@ struct IDirectInputDeviceImpl
HWND win;
int acquired;
DI_EVENT_PROC event_proc; /* function to receive mouse & keyboard events */
+ BOOL use_raw_input; /* use raw input instead of low-level messages */
+ RAWINPUTDEVICE raw_device; /* raw device to (un)register */
@@ -30,10 +30,10 @@ index 423e8f77792..b0fb181fc6d 100644
int queue_len; /* valid size of the queue */
int queue_head; /* position to write new event into queue */
diff --git a/dlls/dinput/dinput_main.c b/dlls/dinput/dinput_main.c
index ee5af1b8ce3..79b275af89b 100644
index 2e561502406..f7e30606bf4 100644
--- a/dlls/dinput/dinput_main.c
+++ b/dlls/dinput/dinput_main.c
@@ -98,6 +98,10 @@ static const struct dinput_device *dinput_devices[] =
@@ -97,6 +97,10 @@ static const struct dinput_device *dinput_devices[] =
HINSTANCE DINPUT_instance;
@@ -44,12 +44,13 @@ index ee5af1b8ce3..79b275af89b 100644
static BOOL check_hook_thread(void);
static CRITICAL_SECTION dinput_hook_crit;
static struct list direct_input_list = LIST_INIT( direct_input_list );
@@ -626,6 +630,59 @@ static HRESULT WINAPI IDirectInputWImpl_QueryInterface(LPDIRECTINPUT7W iface, RE
@@ -637,6 +641,61 @@ static HRESULT WINAPI IDirectInputWImpl_QueryInterface(LPDIRECTINPUT7W iface, RE
return IDirectInputAImpl_QueryInterface( &This->IDirectInput7A_iface, riid, ppobj );
}
+static LRESULT WINAPI di_em_win_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
+{
+ IDirectInputDeviceImpl *dev;
+ IDirectInputImpl *dinput;
+
+ TRACE( "%p %d %lx %lx\n", hwnd, msg, wparam, lparam );
@@ -57,20 +58,21 @@ index ee5af1b8ce3..79b275af89b 100644
+ if (msg == WM_INPUT)
+ {
+ EnterCriticalSection( &dinput_hook_crit );
+ LIST_FOR_EACH_ENTRY( dinput, &direct_input_list, IDirectInputImpl, entry )
+ LIST_FOR_EACH_ENTRY( dev, &acquired_mouse_list, IDirectInputDeviceImpl, entry )
+ {
+ IDirectInputDeviceImpl *dev;
+
+ EnterCriticalSection( &dinput->crit );
+ LIST_FOR_EACH_ENTRY( dev, &dinput->devices_list, IDirectInputDeviceImpl, entry )
+ if (dev->use_raw_input)
+ {
+ if (dev->acquired && dev->event_proc && dev->use_raw_input)
+ {
+ TRACE("calling %p->%p (%lx %lx)\n", dev, dev->event_proc, wparam, lparam);
+ dev->event_proc( &dev->IDirectInputDevice8A_iface, GET_RAWINPUT_CODE_WPARAM(wparam), lparam );
+ }
+ TRACE("calling dinput_mouse_hook (%p %lx %lx)\n", dev, wparam, lparam);
+ dinput_mouse_hook( &dev->IDirectInputDevice8A_iface, GET_RAWINPUT_CODE_WPARAM(wparam), lparam );
+ }
+ }
+ LIST_FOR_EACH_ENTRY( dev, &acquired_keyboard_list, IDirectInputDeviceImpl, entry )
+ {
+ if (dev->use_raw_input)
+ {
+ TRACE("calling dinput_keyboard_hook (%p %lx %lx)\n", dev, wparam, lparam);
+ dinput_keyboard_hook( &dev->IDirectInputDevice8A_iface, GET_RAWINPUT_CODE_WPARAM(wparam), lparam );
+ }
+ LeaveCriticalSection( &dinput->crit );
+ }
+ LeaveCriticalSection( &dinput_hook_crit );
+ }
@@ -104,16 +106,31 @@ index ee5af1b8ce3..79b275af89b 100644
static HRESULT initialize_directinput_instance(IDirectInputImpl *This, DWORD dwVersion)
{
if (!This->initialized)
@@ -1695,7 +1752,7 @@ static LRESULT CALLBACK LL_hook_proc( int code, WPARAM wparam, LPARAM lparam )
@@ -1668,13 +1727,19 @@ static LRESULT CALLBACK LL_hook_proc( int code, WPARAM wparam, LPARAM lparam )
EnterCriticalSection( &dinput_hook_crit );
LIST_FOR_EACH_ENTRY( dev, &acquired_mouse_list, IDirectInputDeviceImpl, entry )
{
- TRACE("calling dinput_mouse_hook (%p %lx %lx)\n", dev, wparam, lparam);
- skip |= dinput_mouse_hook( &dev->IDirectInputDevice8A_iface, wparam, lparam );
+ if (!dev->use_raw_input)
+ {
+ TRACE("calling dinput_mouse_hook (%p %lx %lx)\n", dev, wparam, lparam);
+ skip |= dinput_mouse_hook( &dev->IDirectInputDevice8A_iface, wparam, lparam );
+ }
}
LIST_FOR_EACH_ENTRY( dev, &acquired_keyboard_list, IDirectInputDeviceImpl, entry )
{
- TRACE("calling dinput_keyboard_hook (%p %lx %lx)\n", dev, wparam, lparam);
- skip |= dinput_keyboard_hook( &dev->IDirectInputDevice8A_iface, wparam, lparam );
+ if (!dev->use_raw_input)
+ {
+ TRACE("calling dinput_keyboard_hook (%p %lx %lx)\n", dev, wparam, lparam);
+ skip |= dinput_keyboard_hook( &dev->IDirectInputDevice8A_iface, wparam, lparam );
+ }
}
LeaveCriticalSection( &dinput_hook_crit );
EnterCriticalSection( &dinput->crit );
LIST_FOR_EACH_ENTRY( dev, &dinput->devices_list, IDirectInputDeviceImpl, entry )
- if (dev->acquired && dev->event_proc)
+ if (dev->acquired && dev->event_proc && !dev->use_raw_input)
{
TRACE("calling %p->%p (%lx %lx)\n", dev, dev->event_proc, wparam, lparam);
skip |= dev->event_proc( &dev->IDirectInputDevice8A_iface, wparam, lparam );
@@ -1748,6 +1805,9 @@ static DWORD WINAPI hook_thread_proc(void *param)
@@ -1728,6 +1793,9 @@ static DWORD WINAPI hook_thread_proc(void *param)
static HHOOK kbd_hook, mouse_hook;
MSG msg;
@@ -123,7 +140,7 @@ index ee5af1b8ce3..79b275af89b 100644
/* Force creation of the message queue */
PeekMessageW( &msg, 0, 0, 0, PM_NOREMOVE );
SetEvent(param);
@@ -1816,6 +1876,9 @@ static DWORD WINAPI hook_thread_proc(void *param)
@@ -1778,6 +1846,9 @@ static DWORD WINAPI hook_thread_proc(void *param)
DispatchMessageW(&msg);
}
@@ -133,7 +150,7 @@ index ee5af1b8ce3..79b275af89b 100644
FreeLibraryAndExitThread(DINPUT_instance, 0);
}
@@ -1898,6 +1961,23 @@ void check_dinput_hooks(LPDIRECTINPUTDEVICE8W iface, BOOL acquired)
@@ -1860,6 +1931,23 @@ void check_dinput_hooks(LPDIRECTINPUTDEVICE8W iface, BOOL acquired)
hook_thread_event = NULL;
}
@@ -157,7 +174,7 @@ index ee5af1b8ce3..79b275af89b 100644
if (acquired)
hook_change_finished_event = CreateEventW( NULL, FALSE, FALSE, NULL );
PostThreadMessageW( hook_thread_id, WM_USER+0x10, 1, (LPARAM)hook_change_finished_event );
@@ -1932,9 +2012,11 @@ BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved)
@@ -1894,9 +1982,11 @@ BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved)
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(inst);
DINPUT_instance = inst;
@@ -170,5 +187,5 @@ index ee5af1b8ce3..79b275af89b 100644
break;
}
--
2.26.1
2.26.2

View File

@@ -1,8 +1,7 @@
From 4994e308b4f1e21c0d84de23df8c655c4bc5bf9f Mon Sep 17 00:00:00 2001
From 75e4a39ac1bad4b2c69e993b7df3f59d9f2a212c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?R=C3=A9mi=20Bernon?= <rbernon@codeweavers.com>
Date: Mon, 26 Aug 2019 14:08:20 +0200
Subject: [PATCH 12/12] dinput8: Use raw input interface for dinput8 mouse
device.
Subject: [PATCH] dinput8: Use raw input interface for dinput8 mouse device.
---
dlls/dinput/mouse.c | 117 +++++++++++++++++++++++++++++++++++-
@@ -10,12 +9,12 @@ Subject: [PATCH 12/12] dinput8: Use raw input interface for dinput8 mouse
2 files changed, 119 insertions(+), 8 deletions(-)
diff --git a/dlls/dinput/mouse.c b/dlls/dinput/mouse.c
index 2e0101facec..b8b88f38c15 100644
index 5e6f34f0eca..265a9e0a16a 100644
--- a/dlls/dinput/mouse.c
+++ b/dlls/dinput/mouse.c
@@ -246,6 +246,13 @@ static SysMouseImpl *alloc_device(REFGUID rguid, IDirectInputImpl *dinput)
list_add_tail(&dinput->devices_list, &newDevice->base.entry);
LeaveCriticalSection(&dinput->crit);
@@ -239,6 +239,13 @@ static SysMouseImpl *alloc_device(REFGUID rguid, IDirectInputImpl *dinput)
newDevice->base.data_format.wine_df = df;
IDirectInput_AddRef(&newDevice->base.dinput->IDirectInput7A_iface);
+ if (dinput->dwVersion >= 0x0800)
+ {
@@ -27,7 +26,7 @@ index 2e0101facec..b8b88f38c15 100644
return newDevice;
failed:
@@ -318,7 +325,115 @@ static int dinput_mouse_hook( LPDIRECTINPUTDEVICE8A iface, WPARAM wparam, LPARAM
@@ -311,7 +318,115 @@ int dinput_mouse_hook( LPDIRECTINPUTDEVICE8A iface, WPARAM wparam, LPARAM lparam
{
MSLLHOOKSTRUCT *hook = (MSLLHOOKSTRUCT *)lparam;
SysMouseImpl* This = impl_from_IDirectInputDevice8A(iface);
@@ -145,10 +144,10 @@ index 2e0101facec..b8b88f38c15 100644
TRACE("msg %lx @ (%d %d)\n", wparam, hook->pt.x, hook->pt.y);
diff --git a/dlls/dinput8/tests/device.c b/dlls/dinput8/tests/device.c
index 45fc2889066..42ba78707c6 100644
index 328174e5796..b0a863f69f5 100644
--- a/dlls/dinput8/tests/device.c
+++ b/dlls/dinput8/tests/device.c
@@ -696,13 +696,9 @@ static void test_mouse_keyboard(void)
@@ -646,13 +646,9 @@ static void test_mouse_keyboard(void)
raw_devices_count = ARRAY_SIZE(raw_devices);
memset(raw_devices, 0, sizeof(raw_devices));
hr = GetRegisteredRawInputDevices(raw_devices, &raw_devices_count, sizeof(RAWINPUTDEVICE));
@@ -162,7 +161,7 @@ index 45fc2889066..42ba78707c6 100644
ok(raw_devices[0].dwFlags == RIDEV_INPUTSINK, "Unexpected raw device flags: %x\n", raw_devices[0].dwFlags);
todo_wine
ok(raw_devices[0].hwndTarget == di_hwnd, "Unexpected raw device target: %p\n", raw_devices[0].hwndTarget);
@@ -712,6 +708,9 @@ static void test_mouse_keyboard(void)
@@ -662,6 +658,9 @@ static void test_mouse_keyboard(void)
GetRegisteredRawInputDevices(NULL, &raw_devices_count, sizeof(RAWINPUTDEVICE));
ok(raw_devices_count == 0, "Unexpected raw devices registered: %d\n", raw_devices_count);
@@ -172,7 +171,7 @@ index 45fc2889066..42ba78707c6 100644
/* expect dinput8 to take over any activated raw input devices */
raw_devices[0].usUsagePage = 0x01;
raw_devices[0].usUsage = 0x05;
@@ -739,9 +738,7 @@ static void test_mouse_keyboard(void)
@@ -689,9 +688,7 @@ static void test_mouse_keyboard(void)
ok(hr == 3, "GetRegisteredRawInputDevices returned %d, raw_devices_count: %d\n", hr, raw_devices_count);
ok(raw_devices[0].usUsagePage == 1, "Unexpected raw device usage page: %x\n", raw_devices[0].usUsagePage);
ok(raw_devices[0].usUsage == 2, "Unexpected raw device usage: %x\n", raw_devices[0].usUsage);
@@ -182,7 +181,7 @@ index 45fc2889066..42ba78707c6 100644
ok(raw_devices[0].hwndTarget == di_hwnd, "Unexpected raw device target: %p\n", raw_devices[0].hwndTarget);
ok(raw_devices[1].usUsagePage == 1, "Unexpected raw device usage page: %x\n", raw_devices[1].usUsagePage);
ok(raw_devices[1].usUsage == 5, "Unexpected raw device usage: %x\n", raw_devices[1].usUsage);
@@ -767,7 +764,6 @@ static void test_mouse_keyboard(void)
@@ -717,7 +714,6 @@ static void test_mouse_keyboard(void)
todo_wine
ok(hr == 1, "GetRegisteredRawInputDevices returned %d, raw_devices_count: %d\n", hr, raw_devices_count);
ok(raw_devices[0].usUsagePage == 1, "Unexpected raw device usage page: %x\n", raw_devices[0].usUsagePage);
@@ -191,5 +190,5 @@ index 45fc2889066..42ba78707c6 100644
ok(raw_devices[0].dwFlags == 0, "Unexpected raw device flags: %x\n", raw_devices[0].dwFlags);
ok(raw_devices[0].hwndTarget == hwnd, "Unexpected raw device target: %p\n", raw_devices[0].hwndTarget);
--
2.24.1
2.26.2