From a6448966cfed4cd9ad0eceffc2b4c51ea60356ad Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Sat, 8 Jul 2023 15:20:31 +1000 Subject: [PATCH] Added dinput-scancode patchset --- ...plicated-objects-in-keyboard-devices.patch | 34 ++++++++++ ...-lower-keyboard-scancodes-values-fir.patch | 64 +++++++++++++++++++ patches/dinput-scancode/definition | 2 + 3 files changed, 100 insertions(+) create mode 100644 patches/dinput-scancode/0001-dinput-Avoid-duplicated-objects-in-keyboard-devices.patch create mode 100644 patches/dinput-scancode/0002-dinput-Enumerate-lower-keyboard-scancodes-values-fir.patch create mode 100644 patches/dinput-scancode/definition diff --git a/patches/dinput-scancode/0001-dinput-Avoid-duplicated-objects-in-keyboard-devices.patch b/patches/dinput-scancode/0001-dinput-Avoid-duplicated-objects-in-keyboard-devices.patch new file mode 100644 index 00000000..801cdd71 --- /dev/null +++ b/patches/dinput-scancode/0001-dinput-Avoid-duplicated-objects-in-keyboard-devices.patch @@ -0,0 +1,34 @@ +From b2764b3d21a64c3c194b29b9cb71379456e03b06 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?R=C3=A9mi=20Bernon?= +Date: Fri, 7 Jul 2023 12:44:26 +0200 +Subject: [PATCH] dinput: Avoid duplicated objects in keyboard devices. + +Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55205 +--- + dlls/dinput/keyboard.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/dlls/dinput/keyboard.c b/dlls/dinput/keyboard.c +index cbcbf94f0f6..3fd75bb10e6 100644 +--- a/dlls/dinput/keyboard.c ++++ b/dlls/dinput/keyboard.c +@@ -265,13 +265,15 @@ static HRESULT keyboard_enum_objects( IDirectInputDevice8W *iface, const DIPROPH + .dwOfs = DIK_ESCAPE, + .dwType = DIDFT_PSHBUTTON | DIDFT_MAKEINSTANCE( DIK_ESCAPE ), + }; ++ BOOL ret, mapped[0x100] = {0}; + DWORD index, i, dik; +- BOOL ret; + + for (i = 0, index = 0; i < 512; ++i) + { + if (!GetKeyNameTextW( i << 16, instance.tszName, ARRAY_SIZE(instance.tszName) )) continue; + if (!(dik = map_dik_code( i, 0, subtype, impl->base.dinput->dwVersion ))) continue; ++ if (mapped[dik]) continue; ++ mapped[dik] = TRUE; + instance.dwOfs = dik; + instance.dwType = DIDFT_PSHBUTTON | DIDFT_MAKEINSTANCE( dik ); + ret = try_enum_object( &impl->base, filter, flags, callback, index++, &instance, context ); +-- +2.40.1 + diff --git a/patches/dinput-scancode/0002-dinput-Enumerate-lower-keyboard-scancodes-values-fir.patch b/patches/dinput-scancode/0002-dinput-Enumerate-lower-keyboard-scancodes-values-fir.patch new file mode 100644 index 00000000..b5ca4cd8 --- /dev/null +++ b/patches/dinput-scancode/0002-dinput-Enumerate-lower-keyboard-scancodes-values-fir.patch @@ -0,0 +1,64 @@ +From bdf952bf0711a7cf22fee840197234bd413ae611 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?R=C3=A9mi=20Bernon?= +Date: Fri, 7 Jul 2023 12:45:04 +0200 +Subject: [PATCH] dinput: Enumerate lower keyboard scancodes values first. + +Windows usually doesn't have scancodes higher than 0x7f, or extended +scancodes higher than 0x17f, but X11 does for several XF86 keys. + +We want to enumerate the basic keys first including in the extended +scancode range, so they appear before the XF86 keys in the dinput +device object list. + +Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55205 +--- + dlls/dinput/keyboard.c | 24 ++++++++++++++---------- + 1 file changed, 14 insertions(+), 10 deletions(-) + +diff --git a/dlls/dinput/keyboard.c b/dlls/dinput/keyboard.c +index 3fd75bb10e6..1f1db883b80 100644 +--- a/dlls/dinput/keyboard.c ++++ b/dlls/dinput/keyboard.c +@@ -256,6 +256,7 @@ static BOOL try_enum_object( struct dinput_device *impl, const DIPROPHEADER *fil + static HRESULT keyboard_enum_objects( IDirectInputDevice8W *iface, const DIPROPHEADER *filter, + DWORD flags, enum_object_callback callback, void *context ) + { ++ static const UINT vsc_base[] = {0, 0x100, 0x80, 0x180}; + struct keyboard *impl = impl_from_IDirectInputDevice8W( iface ); + BYTE subtype = GET_DIDEVICE_SUBTYPE( impl->base.instance.dwDevType ); + DIDEVICEOBJECTINSTANCEW instance = +@@ -266,18 +267,21 @@ static HRESULT keyboard_enum_objects( IDirectInputDevice8W *iface, const DIPROPH + .dwType = DIDFT_PSHBUTTON | DIDFT_MAKEINSTANCE( DIK_ESCAPE ), + }; + BOOL ret, mapped[0x100] = {0}; +- DWORD index, i, dik; ++ DWORD index, i, dik, vsc; + +- for (i = 0, index = 0; i < 512; ++i) ++ for (i = 0, index = 0; i < ARRAY_SIZE(vsc_base); ++i) + { +- if (!GetKeyNameTextW( i << 16, instance.tszName, ARRAY_SIZE(instance.tszName) )) continue; +- if (!(dik = map_dik_code( i, 0, subtype, impl->base.dinput->dwVersion ))) continue; +- if (mapped[dik]) continue; +- mapped[dik] = TRUE; +- instance.dwOfs = dik; +- instance.dwType = DIDFT_PSHBUTTON | DIDFT_MAKEINSTANCE( dik ); +- ret = try_enum_object( &impl->base, filter, flags, callback, index++, &instance, context ); +- if (ret != DIENUM_CONTINUE) return DIENUM_STOP; ++ for (vsc = vsc_base[i]; vsc < vsc_base[i] + 0x80; vsc++) ++ { ++ if (!GetKeyNameTextW( vsc << 16, instance.tszName, ARRAY_SIZE(instance.tszName) )) continue; ++ if (!(dik = map_dik_code( vsc, 0, subtype, impl->base.dinput->dwVersion ))) continue; ++ if (mapped[dik]) continue; ++ mapped[dik] = TRUE; ++ instance.dwOfs = dik; ++ instance.dwType = DIDFT_PSHBUTTON | DIDFT_MAKEINSTANCE( dik ); ++ ret = try_enum_object( &impl->base, filter, flags, callback, index++, &instance, context ); ++ if (ret != DIENUM_CONTINUE) return DIENUM_STOP; ++ } + } + + return DIENUM_CONTINUE; +-- +2.40.1 + diff --git a/patches/dinput-scancode/definition b/patches/dinput-scancode/definition new file mode 100644 index 00000000..67de6c89 --- /dev/null +++ b/patches/dinput-scancode/definition @@ -0,0 +1,2 @@ +Fixes: [55205] dinput: Improve keyboard devices scancode support. +# PR 3264