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