From cb7bb2284c37d0dbd58bfe72594fabb7ab398e05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Bernon?= Date: Fri, 19 May 2023 21:38:14 +0200 Subject: [PATCH] dinput: Avoid remapping already mapped objects in BuildActionMap. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=54917 --- dlls/dinput/device.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c index b761b3e9d6d..427d3895700 100644 --- a/dlls/dinput/device.c +++ b/dlls/dinput/device.c @@ -1866,6 +1866,23 @@ static HRESULT WINAPI dinput_device_BuildActionMap( IDirectInputDevice8W *iface, if (!(mapped = calloc( impl->device_format.dwNumObjs, sizeof(*mapped) ))) return DIERR_OUTOFMEMORY; + /* check already mapped objects */ + action_end = format->rgoAction + format->dwNumActions; + for (action = format->rgoAction; action < action_end; action++) + { + if (!action->dwHow || !action->dwObjID) continue; + if (!IsEqualGUID(&action->guidInstance, &impl->guid)) continue; + + object_end = impl->device_format.rgodf + impl->device_format.dwNumObjs; + for (object = impl->device_format.rgodf; object < object_end; object++) + { + if (action->dwObjID != object->dwType) continue; + mapped[object - impl->device_format.rgodf] = TRUE; + break; + } + } + + /* map any unmapped priority 1 objects */ action_end = format->rgoAction + format->dwNumActions; for (action = format->rgoAction; action < action_end; action++) { @@ -1886,6 +1903,7 @@ static HRESULT WINAPI dinput_device_BuildActionMap( IDirectInputDevice8W *iface, } } + /* map any unmapped priority 2 objects */ for (action = format->rgoAction; action < action_end; action++) { if (action->dwHow || (action->dwFlags & DIA_APPNOMAP)) continue; /* already mapped */