wine-staging/patches/dinput-scancode/0003-dinput-Enumerate-lower-keyboard-scancodes-values-fir.patch

65 lines
2.8 KiB
Diff
Raw Normal View History

2024-08-23 18:52:24 -07:00
From c133a17f33a7cce87df6a56c7e265b1553726134 Mon Sep 17 00:00:00 2001
2023-07-07 22:20:31 -07:00
From: =?UTF-8?q?R=C3=A9mi=20Bernon?= <rbernon@codeweavers.com>
2024-08-23 18:52:24 -07:00
Date: Fri, 23 Aug 2024 08:52:34 +0200
2023-07-07 22:20:31 -07:00
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
2024-08-23 18:52:24 -07:00
index d9c73cd7367..407634967de 100644
2023-07-07 22:20:31 -07:00
--- a/dlls/dinput/keyboard.c
+++ b/dlls/dinput/keyboard.c
2024-08-23 18:52:24 -07:00
@@ -208,6 +208,7 @@ static BOOL enum_object( struct keyboard *impl, const DIPROPHEADER *filter, DWOR
static HRESULT enum_objects( struct keyboard *impl, const DIPROPHEADER *filter,
DWORD flags, enum_object_callback callback, void *data )
2023-07-07 22:20:31 -07:00
{
+ static const UINT vsc_base[] = {0, 0x100, 0x80, 0x180};
BYTE subtype = GET_DIDEVICE_SUBTYPE( impl->base.instance.dwDevType );
DIDEVICEOBJECTINSTANCEW instance =
2024-08-23 18:52:24 -07:00
{
@@ -217,18 +218,21 @@ static HRESULT enum_objects( struct keyboard *impl, const DIPROPHEADER *filter,
2023-07-07 22:20:31 -07:00
.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 );
2024-08-23 18:52:24 -07:00
- ret = enum_object( impl, filter, flags, callback, index++, &instance, data );
2023-07-07 22:20:31 -07:00
- 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 );
2024-08-23 18:52:24 -07:00
+ ret = enum_object( impl, filter, flags, callback, index++, &instance, data );
2023-07-07 22:20:31 -07:00
+ if (ret != DIENUM_CONTINUE) return DIENUM_STOP;
+ }
}
return DIENUM_CONTINUE;
--
2024-08-23 18:52:24 -07:00
2.43.0
2023-07-07 22:20:31 -07:00