You've already forked wine-staging
mirror of
https://gitlab.winehq.org/wine/wine-staging.git
synced 2025-04-13 14:42:51 -07:00
user32-rawinput-*: Rebase and re-enable.
Thanks to Rémi Bernon for the rebased patch sets.
This commit is contained in:
@@ -1,82 +0,0 @@
|
||||
From 3f8031f89ca79ef5c4dd46666cda2304aa647083 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?R=C3=A9mi=20Bernon?= <rbernon@codeweavers.com>
|
||||
Date: Mon, 4 Nov 2019 23:33:09 +0100
|
||||
Subject: [PATCH 1/4] dinput: Add DIERR_INPUTLOST error code support for
|
||||
DISCL_FOREGROUND cooperative level.
|
||||
|
||||
---
|
||||
dlls/dinput/device.c | 2 ++
|
||||
dlls/dinput/device_private.h | 1 +
|
||||
dlls/dinput/keyboard.c | 6 ++++++
|
||||
dlls/dinput/mouse.c | 6 ++++++
|
||||
4 files changed, 15 insertions(+)
|
||||
|
||||
diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c
|
||||
index df7a22a303b..51a536f0892 100644
|
||||
--- a/dlls/dinput/device.c
|
||||
+++ b/dlls/dinput/device.c
|
||||
@@ -1087,6 +1087,7 @@ HRESULT WINAPI IDirectInputDevice2WImpl_Acquire(LPDIRECTINPUTDEVICE8W iface)
|
||||
EnterCriticalSection(&This->crit);
|
||||
res = This->acquired ? S_FALSE : DI_OK;
|
||||
This->acquired = 1;
|
||||
+ This->inputlost = 0;
|
||||
LeaveCriticalSection(&This->crit);
|
||||
if (res == DI_OK)
|
||||
check_dinput_hooks(iface, TRUE);
|
||||
@@ -1115,6 +1116,7 @@ HRESULT WINAPI IDirectInputDevice2WImpl_Unacquire(LPDIRECTINPUTDEVICE8W iface)
|
||||
EnterCriticalSection(&This->crit);
|
||||
res = !This->acquired ? DI_NOEFFECT : DI_OK;
|
||||
This->acquired = 0;
|
||||
+ This->inputlost = 0;
|
||||
LeaveCriticalSection(&This->crit);
|
||||
if (res == DI_OK)
|
||||
check_dinput_hooks(iface, FALSE);
|
||||
diff --git a/dlls/dinput/device_private.h b/dlls/dinput/device_private.h
|
||||
index 9116aaeab66..70b4ae1ef69 100644
|
||||
--- a/dlls/dinput/device_private.h
|
||||
+++ b/dlls/dinput/device_private.h
|
||||
@@ -68,6 +68,7 @@ struct IDirectInputDeviceImpl
|
||||
DWORD dwCoopLevel;
|
||||
HWND win;
|
||||
int acquired;
|
||||
+ int inputlost;
|
||||
DI_EVENT_PROC event_proc; /* function to receive mouse & keyboard events */
|
||||
|
||||
BOOL use_raw_input; /* use raw input instead of low-level messages */
|
||||
diff --git a/dlls/dinput/keyboard.c b/dlls/dinput/keyboard.c
|
||||
index 1ec8003897a..2c62d3eab09 100644
|
||||
--- a/dlls/dinput/keyboard.c
|
||||
+++ b/dlls/dinput/keyboard.c
|
||||
@@ -371,6 +371,12 @@ static HRESULT WINAPI SysKeyboardWImpl_GetDeviceState(LPDIRECTINPUTDEVICE8W ifac
|
||||
|
||||
check_dinput_events();
|
||||
|
||||
+ if ((This->base.dwCoopLevel & DISCL_FOREGROUND) && This->base.win != GetForegroundWindow())
|
||||
+ {
|
||||
+ This->base.acquired = 0;
|
||||
+ return DIERR_INPUTLOST;
|
||||
+ }
|
||||
+
|
||||
EnterCriticalSection(&This->base.crit);
|
||||
|
||||
if (TRACE_ON(dinput)) {
|
||||
diff --git a/dlls/dinput/mouse.c b/dlls/dinput/mouse.c
|
||||
index b8b88f38c15..06cf78de13a 100644
|
||||
--- a/dlls/dinput/mouse.c
|
||||
+++ b/dlls/dinput/mouse.c
|
||||
@@ -672,6 +672,12 @@ static HRESULT WINAPI SysMouseWImpl_GetDeviceState(LPDIRECTINPUTDEVICE8W iface,
|
||||
|
||||
check_dinput_events();
|
||||
|
||||
+ if ((This->base.dwCoopLevel & DISCL_FOREGROUND) && This->base.win != GetForegroundWindow())
|
||||
+ {
|
||||
+ This->base.acquired = 0;
|
||||
+ return DIERR_INPUTLOST;
|
||||
+ }
|
||||
+
|
||||
EnterCriticalSection(&This->base.crit);
|
||||
_dump_mouse_state(&This->m_state);
|
||||
|
||||
--
|
||||
2.24.1
|
||||
|
@@ -0,0 +1,98 @@
|
||||
From f59841a0e07a536adda717cbe0bcd2686ab11507 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?R=C3=A9mi=20Bernon?= <rbernon@codeweavers.com>
|
||||
Date: Sat, 6 Jun 2020 17:51:05 +0200
|
||||
Subject: [PATCH] dinput: Introduce dinput_keyboard_handle_key_event helper.
|
||||
|
||||
This factor the key event logic, so we can then use it in rawinput
|
||||
message handler as well.
|
||||
---
|
||||
dlls/dinput/keyboard.c | 52 +++++++++++++++++++++++++++---------------
|
||||
1 file changed, 33 insertions(+), 19 deletions(-)
|
||||
|
||||
diff --git a/dlls/dinput/keyboard.c b/dlls/dinput/keyboard.c
|
||||
index 9981372d957..aa5bf30a378 100644
|
||||
--- a/dlls/dinput/keyboard.c
|
||||
+++ b/dlls/dinput/keyboard.c
|
||||
@@ -103,21 +103,16 @@ static BYTE map_dik_code(DWORD scanCode, DWORD vkCode, DWORD subType, DWORD vers
|
||||
return scanCode;
|
||||
}
|
||||
|
||||
-int dinput_keyboard_hook( LPDIRECTINPUTDEVICE8A iface, WPARAM wparam, LPARAM lparam )
|
||||
+static void dinput_keyboard_handle_key_event( LPDIRECTINPUTDEVICE8A iface, DWORD vkey_code,
|
||||
+ DWORD scan_code, BOOL is_key_ext, BOOL is_key_up )
|
||||
{
|
||||
SysKeyboardImpl *This = impl_from_IDirectInputDevice8A(iface);
|
||||
- int dik_code, ret = This->base.dwCoopLevel & DISCL_EXCLUSIVE;
|
||||
- KBDLLHOOKSTRUCT *hook = (KBDLLHOOKSTRUCT *)lparam;
|
||||
- BYTE new_diks;
|
||||
+ int dik_code;
|
||||
+ BYTE dik_state;
|
||||
|
||||
- if (wparam != WM_KEYDOWN && wparam != WM_KEYUP &&
|
||||
- wparam != WM_SYSKEYDOWN && wparam != WM_SYSKEYUP)
|
||||
- return 0;
|
||||
+ TRACE("(%p) vk %02x, scan %02x\n", iface, vkey_code, scan_code);
|
||||
|
||||
- TRACE("(%p) wp %08lx, lp %08lx, vk %02x, scan %02x\n",
|
||||
- iface, wparam, lparam, hook->vkCode, hook->scanCode);
|
||||
-
|
||||
- switch (hook->vkCode)
|
||||
+ switch (vkey_code)
|
||||
{
|
||||
/* R-Shift is special - it is an extended key with separate scan code */
|
||||
case VK_RSHIFT : dik_code = DIK_RSHIFT; break;
|
||||
@@ -125,24 +120,43 @@ int dinput_keyboard_hook( LPDIRECTINPUTDEVICE8A iface, WPARAM wparam, LPARAM lpa
|
||||
case VK_NUMLOCK : dik_code = DIK_NUMLOCK; break;
|
||||
case VK_SUBTRACT: dik_code = DIK_SUBTRACT; break;
|
||||
default:
|
||||
- dik_code = map_dik_code(hook->scanCode & 0xff, hook->vkCode, This->subtype, This->base.dinput->dwVersion);
|
||||
- if (hook->flags & LLKHF_EXTENDED) dik_code |= 0x80;
|
||||
+ dik_code = map_dik_code(scan_code & 0xff, vkey_code, This->subtype, This->base.dinput->dwVersion);
|
||||
+ if (is_key_ext) dik_code |= 0x80;
|
||||
}
|
||||
- new_diks = hook->flags & LLKHF_UP ? 0 : 0x80;
|
||||
+ dik_state = (is_key_up ? 0 : 0x80);
|
||||
|
||||
/* returns now if key event already known */
|
||||
- if (new_diks == This->DInputKeyState[dik_code])
|
||||
- return ret;
|
||||
+ if (dik_state == This->DInputKeyState[dik_code])
|
||||
+ return;
|
||||
|
||||
- This->DInputKeyState[dik_code] = new_diks;
|
||||
+ This->DInputKeyState[dik_code] = dik_state;
|
||||
TRACE(" setting %02X to %02X\n", dik_code, This->DInputKeyState[dik_code]);
|
||||
|
||||
EnterCriticalSection(&This->base.crit);
|
||||
queue_event(iface, DIDFT_MAKEINSTANCE(dik_code) | DIDFT_PSHBUTTON,
|
||||
- new_diks, GetCurrentTime(), This->base.dinput->evsequence++);
|
||||
+ dik_state, GetCurrentTime(), This->base.dinput->evsequence++);
|
||||
LeaveCriticalSection(&This->base.crit);
|
||||
+}
|
||||
+
|
||||
+int dinput_keyboard_hook( LPDIRECTINPUTDEVICE8A iface, WPARAM wparam, LPARAM lparam )
|
||||
+{
|
||||
+ SysKeyboardImpl *This = impl_from_IDirectInputDevice8A(iface);
|
||||
+ KBDLLHOOKSTRUCT *hook = (KBDLLHOOKSTRUCT *)lparam;
|
||||
+ DWORD vkey_code, scan_code;
|
||||
+ BOOL is_key_ext, is_key_up;
|
||||
+
|
||||
+ if (wparam != WM_KEYDOWN && wparam != WM_KEYUP &&
|
||||
+ wparam != WM_SYSKEYDOWN && wparam != WM_SYSKEYUP)
|
||||
+ return 0;
|
||||
+
|
||||
+ vkey_code = hook->vkCode;
|
||||
+ scan_code = hook->scanCode;
|
||||
+ is_key_ext = (hook->flags & LLKHF_EXTENDED);
|
||||
+ is_key_up = (hook->flags & LLKHF_UP);
|
||||
+
|
||||
+ dinput_keyboard_handle_key_event(iface, vkey_code, scan_code, is_key_ext, is_key_up);
|
||||
|
||||
- return ret;
|
||||
+ return (This->base.dwCoopLevel & DISCL_EXCLUSIVE);
|
||||
}
|
||||
|
||||
static DWORD get_keyboard_subtype(void)
|
||||
--
|
||||
2.27.0
|
||||
|
@@ -1,146 +0,0 @@
|
||||
From 87087e7d92d5cbbaf8e63cdfadead60701d0b360 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?R=C3=A9mi=20Bernon?= <rbernon@codeweavers.com>
|
||||
Date: Mon, 26 Aug 2019 15:32:07 +0200
|
||||
Subject: [PATCH 2/4] dinput8: Use raw input interface for dinput8 keyboard
|
||||
device.
|
||||
|
||||
---
|
||||
dlls/dinput/keyboard.c | 69 +++++++++++++++++++++++++++++++++----
|
||||
dlls/dinput8/tests/device.c | 7 ----
|
||||
2 files changed, 62 insertions(+), 14 deletions(-)
|
||||
|
||||
diff --git a/dlls/dinput/keyboard.c b/dlls/dinput/keyboard.c
|
||||
index 2c62d3eab09..fb0f273bdbe 100644
|
||||
--- a/dlls/dinput/keyboard.c
|
||||
+++ b/dlls/dinput/keyboard.c
|
||||
@@ -107,17 +107,65 @@ static int KeyboardCallback( LPDIRECTINPUTDEVICE8A iface, WPARAM wparam, LPARAM
|
||||
{
|
||||
SysKeyboardImpl *This = impl_from_IDirectInputDevice8A(iface);
|
||||
int dik_code, ret = This->base.dwCoopLevel & DISCL_EXCLUSIVE;
|
||||
- KBDLLHOOKSTRUCT *hook = (KBDLLHOOKSTRUCT *)lparam;
|
||||
BYTE new_diks;
|
||||
+ DWORD vkey_code, scan_code;
|
||||
+ BOOL is_key_ext, is_key_up;
|
||||
|
||||
if (wparam != WM_KEYDOWN && wparam != WM_KEYUP &&
|
||||
- wparam != WM_SYSKEYDOWN && wparam != WM_SYSKEYUP)
|
||||
+ wparam != WM_SYSKEYDOWN && wparam != WM_SYSKEYUP &&
|
||||
+ wparam != RIM_INPUT && wparam != RIM_INPUTSINK)
|
||||
return 0;
|
||||
|
||||
+ if (wparam == RIM_INPUT || wparam == RIM_INPUTSINK)
|
||||
+ {
|
||||
+ RAWINPUTHEADER raw_header;
|
||||
+ RAWINPUT raw_input;
|
||||
+ UINT size;
|
||||
+
|
||||
+ TRACE("(%p) wp %08lx, lp %08lx\n", iface, wparam, lparam);
|
||||
+
|
||||
+ size = sizeof(raw_header);
|
||||
+ if (GetRawInputData( (HRAWINPUT)lparam, RID_HEADER, &raw_header, &size, sizeof(RAWINPUTHEADER) ) != sizeof(raw_header))
|
||||
+ {
|
||||
+ WARN( "Unable to read raw input data header\n" );
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ if (raw_header.dwType != RIM_TYPEKEYBOARD)
|
||||
+ return 0;
|
||||
+
|
||||
+ if (raw_header.dwSize > sizeof(raw_input))
|
||||
+ {
|
||||
+ WARN( "Unexpected size for keyboard raw input data\n" );
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ size = raw_header.dwSize;
|
||||
+ if (GetRawInputData( (HRAWINPUT)lparam, RID_INPUT, &raw_input, &size, sizeof(RAWINPUTHEADER) ) != raw_header.dwSize )
|
||||
+ {
|
||||
+ WARN( "Unable to read raw input data\n" );
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ vkey_code = raw_input.data.keyboard.VKey;
|
||||
+ scan_code = raw_input.data.keyboard.MakeCode;
|
||||
+ is_key_ext = (raw_input.data.keyboard.Flags & RI_KEY_E0);
|
||||
+ is_key_up = (raw_input.data.keyboard.Flags & RI_KEY_BREAK);
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ KBDLLHOOKSTRUCT *hook = (KBDLLHOOKSTRUCT *)lparam;
|
||||
+
|
||||
+ vkey_code = hook->vkCode;
|
||||
+ scan_code = hook->scanCode;
|
||||
+ is_key_ext = (hook->flags & LLKHF_EXTENDED);
|
||||
+ is_key_up = (hook->flags & LLKHF_UP);
|
||||
+ }
|
||||
+
|
||||
TRACE("(%p) wp %08lx, lp %08lx, vk %02x, scan %02x\n",
|
||||
- iface, wparam, lparam, hook->vkCode, hook->scanCode);
|
||||
+ iface, wparam, lparam, vkey_code, scan_code);
|
||||
|
||||
- switch (hook->vkCode)
|
||||
+ switch (vkey_code)
|
||||
{
|
||||
/* R-Shift is special - it is an extended key with separate scan code */
|
||||
case VK_RSHIFT : dik_code = DIK_RSHIFT; break;
|
||||
@@ -125,10 +173,10 @@ static int KeyboardCallback( LPDIRECTINPUTDEVICE8A iface, WPARAM wparam, LPARAM
|
||||
case VK_NUMLOCK : dik_code = DIK_NUMLOCK; break;
|
||||
case VK_SUBTRACT: dik_code = DIK_SUBTRACT; break;
|
||||
default:
|
||||
- dik_code = map_dik_code(hook->scanCode & 0xff, hook->vkCode, This->subtype);
|
||||
- if (hook->flags & LLKHF_EXTENDED) dik_code |= 0x80;
|
||||
+ dik_code = map_dik_code(scan_code & 0xff, vkey_code, This->subtype);
|
||||
+ if (is_key_ext) dik_code |= 0x80;
|
||||
}
|
||||
- new_diks = hook->flags & LLKHF_UP ? 0 : 0x80;
|
||||
+ new_diks = is_key_up ? 0 : 0x80;
|
||||
|
||||
/* returns now if key event already known */
|
||||
if (new_diks == This->DInputKeyState[dik_code])
|
||||
@@ -295,6 +343,13 @@ static SysKeyboardImpl *alloc_device(REFGUID rguid, IDirectInputImpl *dinput)
|
||||
list_add_tail(&dinput->devices_list, &newDevice->base.entry);
|
||||
LeaveCriticalSection(&dinput->crit);
|
||||
|
||||
+ if (dinput->dwVersion >= 0x800)
|
||||
+ {
|
||||
+ newDevice->base.use_raw_input = TRUE;
|
||||
+ newDevice->base.raw_device.usUsagePage = 1; /* HID generic device page */
|
||||
+ newDevice->base.raw_device.usUsage = 6; /* HID generic keyboard */
|
||||
+ }
|
||||
+
|
||||
return newDevice;
|
||||
|
||||
failed:
|
||||
diff --git a/dlls/dinput8/tests/device.c b/dlls/dinput8/tests/device.c
|
||||
index 31220db220a..8a6d1997b67 100644
|
||||
--- a/dlls/dinput8/tests/device.c
|
||||
+++ b/dlls/dinput8/tests/device.c
|
||||
@@ -659,15 +659,10 @@ 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));
|
||||
- todo_wine
|
||||
ok(hr == 1, "GetRegisteredRawInputDevices returned %d, raw_devices_count: %d\n", hr, raw_devices_count);
|
||||
- todo_wine
|
||||
ok(raw_devices[0].usUsagePage == 1, "Unexpected raw device usage page: %x\n", raw_devices[0].usUsagePage);
|
||||
- todo_wine
|
||||
ok(raw_devices[0].usUsage == 6, "Unexpected raw device usage: %x\n", raw_devices[0].usUsage);
|
||||
- todo_wine
|
||||
ok(raw_devices[0].dwFlags == RIDEV_INPUTSINK, "Unexpected raw device flags: %x\n", raw_devices[0].dwFlags);
|
||||
- todo_wine
|
||||
ok(raw_devices[0].hwndTarget != NULL, "Unexpected raw device target: %p\n", raw_devices[0].hwndTarget);
|
||||
hr = IDirectInputDevice8_Unacquire(di_keyboard);
|
||||
ok(SUCCEEDED(hr), "IDirectInputDevice8_Acquire failed: %08x\n", hr);
|
||||
@@ -746,9 +741,7 @@ static void test_mouse_keyboard(void)
|
||||
ok(raw_devices[1].hwndTarget == hwnd, "Unexpected raw device target: %p\n", raw_devices[1].hwndTarget);
|
||||
ok(raw_devices[2].usUsagePage == 1, "Unexpected raw device usage page: %x\n", raw_devices[1].usUsagePage);
|
||||
ok(raw_devices[2].usUsage == 6, "Unexpected raw device usage: %x\n", raw_devices[1].usUsage);
|
||||
- todo_wine
|
||||
ok(raw_devices[2].dwFlags == RIDEV_INPUTSINK, "Unexpected raw device flags: %x\n", raw_devices[1].dwFlags);
|
||||
- todo_wine
|
||||
ok(raw_devices[2].hwndTarget == di_hwnd, "Unexpected raw device target: %p\n", raw_devices[1].hwndTarget);
|
||||
hr = IDirectInputDevice8_Unacquire(di_keyboard);
|
||||
ok(SUCCEEDED(hr), "IDirectInputDevice8_Acquire failed: %08x\n", hr);
|
||||
--
|
||||
2.24.1
|
||||
|
@@ -0,0 +1,87 @@
|
||||
From 5449030617b7c85792128554b99b971ce2579e4d Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?R=C3=A9mi=20Bernon?= <rbernon@codeweavers.com>
|
||||
Date: Sat, 6 Jun 2020 17:52:26 +0200
|
||||
Subject: [PATCH] dinput8: Use rawinput interface for keyboard device.
|
||||
|
||||
---
|
||||
dlls/dinput/dinput_main.c | 10 ++++++++++
|
||||
dlls/dinput/dinput_private.h | 1 +
|
||||
dlls/dinput/keyboard.c | 22 ++++++++++++++++++++++
|
||||
3 files changed, 33 insertions(+)
|
||||
|
||||
diff --git a/dlls/dinput/dinput_main.c b/dlls/dinput/dinput_main.c
|
||||
index 5e03964f901..0e45d821897 100644
|
||||
--- a/dlls/dinput/dinput_main.c
|
||||
+++ b/dlls/dinput/dinput_main.c
|
||||
@@ -662,6 +662,16 @@ static LRESULT WINAPI di_em_win_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPAR
|
||||
dinput_mouse_rawinput_hook( &dev->IDirectInputDevice8A_iface, wparam, lparam, &ri );
|
||||
LeaveCriticalSection( &dinput_hook_crit );
|
||||
}
|
||||
+ else if (ri.header.dwType == RIM_TYPEKEYBOARD)
|
||||
+ {
|
||||
+ EnterCriticalSection( &dinput_hook_crit );
|
||||
+ LIST_FOR_EACH_ENTRY( dev, &acquired_keyboard_list, IDirectInputDeviceImpl, entry )
|
||||
+ {
|
||||
+ if (!dev->use_raw_input) continue;
|
||||
+ dinput_keyboard_rawinput_hook( &dev->IDirectInputDevice8A_iface, wparam, lparam, &ri );
|
||||
+ }
|
||||
+ LeaveCriticalSection( &dinput_hook_crit );
|
||||
+ }
|
||||
}
|
||||
|
||||
return DefWindowProcW(hwnd, msg, wparam, lparam);
|
||||
diff --git a/dlls/dinput/dinput_private.h b/dlls/dinput/dinput_private.h
|
||||
index c0c88da9674..690e4947f0b 100644
|
||||
--- a/dlls/dinput/dinput_private.h
|
||||
+++ b/dlls/dinput/dinput_private.h
|
||||
@@ -74,6 +74,7 @@ extern void dinput_hooks_unacquire_device(LPDIRECTINPUTDEVICE8W iface);
|
||||
extern int dinput_mouse_hook(LPDIRECTINPUTDEVICE8A iface, WPARAM wparam, LPARAM lparam);
|
||||
extern int dinput_keyboard_hook(LPDIRECTINPUTDEVICE8A iface, WPARAM wparam, LPARAM lparam);
|
||||
extern void dinput_mouse_rawinput_hook( LPDIRECTINPUTDEVICE8A iface, WPARAM wparam, LPARAM lparam, RAWINPUT *raw );
|
||||
+extern void dinput_keyboard_rawinput_hook( LPDIRECTINPUTDEVICE8A iface, WPARAM wparam, LPARAM lparam, RAWINPUT *raw );
|
||||
|
||||
extern void check_dinput_hooks(LPDIRECTINPUTDEVICE8W, BOOL) DECLSPEC_HIDDEN;
|
||||
extern void check_dinput_events(void) DECLSPEC_HIDDEN;
|
||||
diff --git a/dlls/dinput/keyboard.c b/dlls/dinput/keyboard.c
|
||||
index aa5bf30a378..fc59006018c 100644
|
||||
--- a/dlls/dinput/keyboard.c
|
||||
+++ b/dlls/dinput/keyboard.c
|
||||
@@ -138,6 +138,21 @@ static void dinput_keyboard_handle_key_event( LPDIRECTINPUTDEVICE8A iface, DWORD
|
||||
LeaveCriticalSection(&This->base.crit);
|
||||
}
|
||||
|
||||
+void dinput_keyboard_rawinput_hook( LPDIRECTINPUTDEVICE8A iface, WPARAM wparam, LPARAM lparam, RAWINPUT *ri )
|
||||
+{
|
||||
+ DWORD vkey_code, scan_code;
|
||||
+ BOOL is_key_ext, is_key_up;
|
||||
+
|
||||
+ TRACE("(%p) wp %08lx, lp %08lx\n", iface, wparam, lparam);
|
||||
+
|
||||
+ vkey_code = ri->data.keyboard.VKey;
|
||||
+ scan_code = ri->data.keyboard.MakeCode;
|
||||
+ is_key_ext = (ri->data.keyboard.Flags & RI_KEY_E0);
|
||||
+ is_key_up = (ri->data.keyboard.Flags & RI_KEY_BREAK);
|
||||
+
|
||||
+ dinput_keyboard_handle_key_event(iface, vkey_code, scan_code, is_key_ext, is_key_up);
|
||||
+}
|
||||
+
|
||||
int dinput_keyboard_hook( LPDIRECTINPUTDEVICE8A iface, WPARAM wparam, LPARAM lparam )
|
||||
{
|
||||
SysKeyboardImpl *This = impl_from_IDirectInputDevice8A(iface);
|
||||
@@ -304,6 +319,13 @@ static SysKeyboardImpl *alloc_device(REFGUID rguid, IDirectInputImpl *dinput)
|
||||
newDevice->base.data_format.wine_df = df;
|
||||
IDirectInput_AddRef(&newDevice->base.dinput->IDirectInput7A_iface);
|
||||
|
||||
+ if (dinput->dwVersion >= 0x800)
|
||||
+ {
|
||||
+ newDevice->base.use_raw_input = TRUE;
|
||||
+ newDevice->base.raw_device.usUsagePage = 1; /* HID generic device page */
|
||||
+ newDevice->base.raw_device.usUsage = 6; /* HID generic keyboard */
|
||||
+ }
|
||||
+
|
||||
return newDevice;
|
||||
|
||||
failed:
|
||||
--
|
||||
2.27.0
|
||||
|
@@ -0,0 +1,69 @@
|
||||
From fcf11610ea23ecb5a4b86e67c7c838457e2d8dcf Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?R=C3=A9mi=20Bernon?= <rbernon@codeweavers.com>
|
||||
Date: Wed, 24 Jun 2020 12:13:02 +0200
|
||||
Subject: [PATCH] dinput8: Stop using LL hooks for keyboard devices.
|
||||
|
||||
---
|
||||
dlls/dinput/dinput_main.c | 17 +++++++++++------
|
||||
1 file changed, 11 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/dlls/dinput/dinput_main.c b/dlls/dinput/dinput_main.c
|
||||
index 0e45d821897..9b6c4d4c434 100644
|
||||
--- a/dlls/dinput/dinput_main.c
|
||||
+++ b/dlls/dinput/dinput_main.c
|
||||
@@ -107,6 +107,7 @@ static struct list direct_input_list = LIST_INIT( direct_input_list );
|
||||
static struct list acquired_mouse_list = LIST_INIT( acquired_mouse_list );
|
||||
static struct list acquired_rawmouse_list = LIST_INIT( acquired_rawmouse_list );
|
||||
static struct list acquired_keyboard_list = LIST_INIT( acquired_keyboard_list );
|
||||
+static struct list acquired_rawkeyboard_list = LIST_INIT( acquired_rawkeyboard_list );
|
||||
static struct list acquired_device_list = LIST_INIT( acquired_device_list );
|
||||
|
||||
static HRESULT initialize_directinput_instance(IDirectInputImpl *This, DWORD dwVersion);
|
||||
@@ -120,7 +121,7 @@ void dinput_hooks_acquire_device(LPDIRECTINPUTDEVICE8W iface)
|
||||
if (IsEqualGUID( &dev->guid, &GUID_SysMouse ))
|
||||
list_add_tail( dev->use_raw_input ? &acquired_rawmouse_list : &acquired_mouse_list, &dev->entry );
|
||||
else if (IsEqualGUID( &dev->guid, &GUID_SysKeyboard ))
|
||||
- list_add_tail( &acquired_keyboard_list, &dev->entry );
|
||||
+ list_add_tail( dev->use_raw_input ? &acquired_rawkeyboard_list : &acquired_keyboard_list, &dev->entry );
|
||||
else
|
||||
list_add_tail( &acquired_device_list, &dev->entry );
|
||||
LeaveCriticalSection( &dinput_hook_crit );
|
||||
@@ -665,11 +666,8 @@ static LRESULT WINAPI di_em_win_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPAR
|
||||
else if (ri.header.dwType == RIM_TYPEKEYBOARD)
|
||||
{
|
||||
EnterCriticalSection( &dinput_hook_crit );
|
||||
- LIST_FOR_EACH_ENTRY( dev, &acquired_keyboard_list, IDirectInputDeviceImpl, entry )
|
||||
- {
|
||||
- if (!dev->use_raw_input) continue;
|
||||
+ LIST_FOR_EACH_ENTRY( dev, &acquired_rawkeyboard_list, IDirectInputDeviceImpl, entry )
|
||||
dinput_keyboard_rawinput_hook( &dev->IDirectInputDevice8A_iface, wparam, lparam, &ri );
|
||||
- }
|
||||
LeaveCriticalSection( &dinput_hook_crit );
|
||||
}
|
||||
}
|
||||
@@ -1736,7 +1734,6 @@ static LRESULT CALLBACK LL_hook_proc( int code, WPARAM wparam, LPARAM lparam )
|
||||
}
|
||||
LIST_FOR_EACH_ENTRY( dev, &acquired_keyboard_list, IDirectInputDeviceImpl, entry )
|
||||
{
|
||||
- if (dev->use_raw_input) continue;
|
||||
TRACE("calling dinput_keyboard_hook (%p %lx %lx)\n", dev, wparam, lparam);
|
||||
skip |= dinput_keyboard_hook( &dev->IDirectInputDevice8A_iface, wparam, lparam );
|
||||
}
|
||||
@@ -1790,6 +1787,14 @@ static LRESULT CALLBACK callwndproc_proc( int code, WPARAM wparam, LPARAM lparam
|
||||
IDirectInputDevice_Unacquire( &dev->IDirectInputDevice8A_iface );
|
||||
}
|
||||
}
|
||||
+ LIST_FOR_EACH_ENTRY_SAFE( dev, next, &acquired_rawkeyboard_list, IDirectInputDeviceImpl, entry )
|
||||
+ {
|
||||
+ if (msg->hwnd == dev->win && msg->hwnd != foreground)
|
||||
+ {
|
||||
+ TRACE( "%p window is not foreground - unacquiring %p\n", dev->win, dev );
|
||||
+ IDirectInputDevice_Unacquire( &dev->IDirectInputDevice8A_iface );
|
||||
+ }
|
||||
+ }
|
||||
LeaveCriticalSection( &dinput_hook_crit );
|
||||
|
||||
return CallNextHookEx( 0, code, wparam, lparam );
|
||||
--
|
||||
2.27.0
|
||||
|
@@ -1,95 +0,0 @@
|
||||
From 31d4d9619c14a37522b99917deae40273f6e3654 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?R=C3=A9mi=20Bernon?= <rbernon@codeweavers.com>
|
||||
Date: Sat, 7 Sep 2019 09:41:59 +0200
|
||||
Subject: [PATCH 3/4] user32: Add support for RIDEV_INPUTSINK flag in
|
||||
RegisterRawInputDevices.
|
||||
|
||||
This flag allows applications to receive rawinput messages while in
|
||||
background. They have to specify a target hwnd in which queue to receive
|
||||
them and the messages will carry a RIM_INPUTSINK wparam in this case.
|
||||
---
|
||||
dlls/user32/rawinput.c | 9 ++++++++-
|
||||
dlls/user32/tests/input.c | 2 --
|
||||
server/queue.c | 9 ++++++---
|
||||
3 files changed, 14 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/dlls/user32/rawinput.c b/dlls/user32/rawinput.c
|
||||
index 72ae91cfcb5..5a238928b24 100644
|
||||
--- a/dlls/user32/rawinput.c
|
||||
+++ b/dlls/user32/rawinput.c
|
||||
@@ -304,6 +304,13 @@ BOOL WINAPI DECLSPEC_HOTPATCH RegisterRawInputDevices(RAWINPUTDEVICE *devices, U
|
||||
|
||||
for (i = 0; i < device_count; ++i)
|
||||
{
|
||||
+ if ((devices[i].dwFlags & RIDEV_INPUTSINK) &&
|
||||
+ (devices[i].hwndTarget == NULL))
|
||||
+ {
|
||||
+ SetLastError(ERROR_INVALID_PARAMETER);
|
||||
+ return FALSE;
|
||||
+ }
|
||||
+
|
||||
if ((devices[i].dwFlags & RIDEV_REMOVE) &&
|
||||
(devices[i].hwndTarget != NULL))
|
||||
{
|
||||
@@ -319,7 +326,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH RegisterRawInputDevices(RAWINPUTDEVICE *devices, U
|
||||
TRACE("device %u: page %#x, usage %#x, flags %#x, target %p.\n",
|
||||
i, devices[i].usUsagePage, devices[i].usUsage,
|
||||
devices[i].dwFlags, devices[i].hwndTarget);
|
||||
- if (devices[i].dwFlags & ~(RIDEV_REMOVE|RIDEV_NOLEGACY))
|
||||
+ if (devices[i].dwFlags & ~(RIDEV_REMOVE|RIDEV_NOLEGACY|RIDEV_INPUTSINK))
|
||||
FIXME("Unhandled flags %#x for device %u.\n", devices[i].dwFlags, i);
|
||||
|
||||
d[i].usage_page = devices[i].usUsagePage;
|
||||
diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c
|
||||
index a1f983f1960..68d6731551a 100644
|
||||
--- a/dlls/user32/tests/input.c
|
||||
+++ b/dlls/user32/tests/input.c
|
||||
@@ -1812,9 +1812,7 @@ static void test_RegisterRawInputDevices(void)
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
res = RegisterRawInputDevices(raw_devices, ARRAY_SIZE(raw_devices), sizeof(RAWINPUTDEVICE));
|
||||
- todo_wine
|
||||
ok(res == FALSE, "RegisterRawInputDevices failed\n");
|
||||
- todo_wine
|
||||
ok(GetLastError() == ERROR_INVALID_PARAMETER, "RegisterRawInputDevices returned %08x\n", GetLastError());
|
||||
|
||||
raw_devices[0].hwndTarget = hwnd;
|
||||
diff --git a/server/queue.c b/server/queue.c
|
||||
index 85aa896c7bd..145b9c110b1 100644
|
||||
--- a/server/queue.c
|
||||
+++ b/server/queue.c
|
||||
@@ -1758,6 +1758,7 @@ static int queue_rawinput_message( struct process* process, void* user )
|
||||
struct thread *thread = NULL, *foreground = 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;
|
||||
@@ -1777,10 +1778,12 @@ static int queue_rawinput_message( struct process* process, void* user )
|
||||
process != thread->process)
|
||||
goto done;
|
||||
|
||||
- /* FIXME: Implement RIDEV_INPUTSINK */
|
||||
if (!(foreground = get_window_thread( desktop->foreground_input->active )) ||
|
||||
thread->process != foreground->process)
|
||||
- goto done;
|
||||
+ {
|
||||
+ if (!(device->flags & RIDEV_INPUTSINK)) goto done;
|
||||
+ wparam = RIM_INPUTSINK;
|
||||
+ }
|
||||
|
||||
if (!(msg = alloc_hardware_message( raw_msg->data.info, raw_msg->source, raw_msg->time, raw_msg->extra_len )))
|
||||
goto done;
|
||||
@@ -1788,7 +1791,7 @@ static int queue_rawinput_message( struct process* process, void* user )
|
||||
|
||||
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(*msg_data) );
|
||||
--
|
||||
2.24.1
|
||||
|
@@ -1,4 +1,4 @@
|
||||
From 18e2112beb69c8499cdd90b133348ec52502dc6d Mon Sep 17 00:00:00 2001
|
||||
From 58b859f29d69de9f86990170d637fb3a89c548bb Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?R=C3=A9mi=20Bernon?= <rbernon@codeweavers.com>
|
||||
Date: Wed, 21 Aug 2019 16:37:57 +0200
|
||||
Subject: [PATCH] winex11.drv: Listen to RawKey* events in the desktop thread.
|
||||
@@ -79,10 +79,10 @@ index 37c96c926f4..4d113d8c184 100644
|
||||
* X11DRV_KEYBOARD_DetectLayout
|
||||
*
|
||||
diff --git a/dlls/winex11.drv/mouse.c b/dlls/winex11.drv/mouse.c
|
||||
index bc23b9cbba1..2e9b39fcff7 100644
|
||||
index e3c5f8d122e..95ece0710e5 100644
|
||||
--- a/dlls/winex11.drv/mouse.c
|
||||
+++ b/dlls/winex11.drv/mouse.c
|
||||
@@ -406,6 +406,8 @@ void X11DRV_XInput2_Enable(void)
|
||||
@@ -415,6 +415,8 @@ void X11DRV_XInput2_Enable(void)
|
||||
{
|
||||
XISetMask( mask_bits, XI_RawButtonPress );
|
||||
XISetMask( mask_bits, XI_RawButtonRelease );
|
||||
@@ -91,7 +91,7 @@ index bc23b9cbba1..2e9b39fcff7 100644
|
||||
data->xi2_rawinput_only = TRUE;
|
||||
}
|
||||
else
|
||||
@@ -2038,6 +2040,10 @@ BOOL X11DRV_GenericEvent( HWND hwnd, XEvent *xev )
|
||||
@@ -2123,6 +2125,10 @@ BOOL X11DRV_GenericEvent( HWND hwnd, XEvent *xev )
|
||||
case XI_RawButtonRelease:
|
||||
ret = X11DRV_RawButtonEvent( event );
|
||||
break;
|
||||
@@ -103,10 +103,10 @@ index bc23b9cbba1..2e9b39fcff7 100644
|
||||
default:
|
||||
TRACE( "Unhandled event %#x\n", event->evtype );
|
||||
diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h
|
||||
index c843cd74ace..f89538a1755 100644
|
||||
index 396056464a7..eb6d6530c1e 100644
|
||||
--- a/dlls/winex11.drv/x11drv.h
|
||||
+++ b/dlls/winex11.drv/x11drv.h
|
||||
@@ -518,6 +518,7 @@ extern BOOL X11DRV_ButtonRelease( HWND hwnd, XEvent *event ) DECLSPEC_HIDDEN;
|
||||
@@ -517,6 +517,7 @@ extern BOOL X11DRV_ButtonRelease( HWND hwnd, XEvent *event ) DECLSPEC_HIDDEN;
|
||||
extern BOOL X11DRV_MotionNotify( HWND hwnd, XEvent *event ) DECLSPEC_HIDDEN;
|
||||
extern BOOL X11DRV_EnterNotify( HWND hwnd, XEvent *event ) DECLSPEC_HIDDEN;
|
||||
extern BOOL X11DRV_KeyEvent( HWND hwnd, XEvent *event ) DECLSPEC_HIDDEN;
|
||||
@@ -115,5 +115,5 @@ index c843cd74ace..f89538a1755 100644
|
||||
extern BOOL X11DRV_DestroyNotify( HWND hwnd, XEvent *event ) DECLSPEC_HIDDEN;
|
||||
extern BOOL X11DRV_SelectionRequest( HWND hWnd, XEvent *event ) DECLSPEC_HIDDEN;
|
||||
--
|
||||
2.24.0
|
||||
2.27.0
|
||||
|
||||
|
@@ -1,3 +1,3 @@
|
||||
Fixes: [35128] Air Conflicts (Pacific Carriers/Secret Wars) hangs at the loading screen (needs support for raw input in DInput8 keyboard)
|
||||
Depends: user32-rawinput-hid
|
||||
Disabled: True
|
||||
Disabled: true
|
||||
|
Reference in New Issue
Block a user