From 48e74aa0827a667010ee88bbaa2fb8868ad54eeb Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Sat, 16 Sep 2017 20:44:43 +0000 Subject: [PATCH] [DINPUT] Sync with Wine Staging 2.16. CORE-13762 5214b47 dinput: Do not wait for hook thread startup in IDirectInput8::Initialize. 83a3887 dinput: Avoid possible deadlock when CS are acquired in different order. 49fdde1 dinput: Use proper size for combobox controls. b50d1fa dinput: Limit axes while remaping broken devices. svn path=/trunk/; revision=75855 --- reactos/dll/directx/wine/dinput/device.c | 8 ++++---- reactos/dll/directx/wine/dinput/dinput.rc | 4 ++-- reactos/dll/directx/wine/dinput/dinput_main.c | 4 ++-- reactos/dll/directx/wine/dinput/dinput_private.h | 2 +- reactos/dll/directx/wine/dinput/joystick_linux.c | 8 ++++++-- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/reactos/dll/directx/wine/dinput/device.c b/reactos/dll/directx/wine/dinput/device.c index d9f95b913b9..a67e24403c0 100644 --- a/reactos/dll/directx/wine/dinput/device.c +++ b/reactos/dll/directx/wine/dinput/device.c @@ -976,9 +976,9 @@ HRESULT WINAPI IDirectInputDevice2WImpl_Acquire(LPDIRECTINPUTDEVICE8W iface) EnterCriticalSection(&This->crit); res = This->acquired ? S_FALSE : DI_OK; This->acquired = 1; - if (res == DI_OK) - check_dinput_hooks(iface); LeaveCriticalSection(&This->crit); + if (res == DI_OK) + check_dinput_hooks(iface, TRUE); return res; } @@ -1004,9 +1004,9 @@ HRESULT WINAPI IDirectInputDevice2WImpl_Unacquire(LPDIRECTINPUTDEVICE8W iface) EnterCriticalSection(&This->crit); res = !This->acquired ? DI_NOEFFECT : DI_OK; This->acquired = 0; - if (res == DI_OK) - check_dinput_hooks(iface); LeaveCriticalSection(&This->crit); + if (res == DI_OK) + check_dinput_hooks(iface, FALSE); return res; } diff --git a/reactos/dll/directx/wine/dinput/dinput.rc b/reactos/dll/directx/wine/dinput/dinput.rc index e677561c5df..0c5dae01104 100644 --- a/reactos/dll/directx/wine/dinput/dinput.rc +++ b/reactos/dll/directx/wine/dinput/dinput.rc @@ -50,8 +50,8 @@ FONT 8, "MS Shell Dlg" DEFPUSHBUTTON "OK", IDOK, 10, 236, 50, 14 PUSHBUTTON "Cancel", IDCANCEL, 65, 236, 50, 14 PUSHBUTTON "Reset", IDC_RESET, 210, 236, 50, 14 - COMBOBOX IDC_PLAYERCOMBO, 10, 50, 90, 30, CBS_DROPDOWNLIST | CBS_HASSTRINGS - COMBOBOX IDC_CONTROLLERCOMBO, 10, 20, 90, 30, CBS_DROPDOWNLIST | CBS_HASSTRINGS + COMBOBOX IDC_PLAYERCOMBO, 10, 50, 90, 60, CBS_DROPDOWNLIST | CBS_HASSTRINGS + COMBOBOX IDC_CONTROLLERCOMBO, 10, 20, 90, 60, CBS_DROPDOWNLIST | CBS_HASSTRINGS LTEXT "Player", IDC_PLAYERTEXT, 10, 40, 90, 8, SS_LEFT LTEXT "Device", IDC_DEVICETEXT, 10, 10, 90, 8, SS_LEFT LTEXT "Actions", IDC_ACTIONTEXT, 10, 70, 90, 8, SS_LEFT diff --git a/reactos/dll/directx/wine/dinput/dinput_main.c b/reactos/dll/directx/wine/dinput/dinput_main.c index fc6d979c1de..e480af77ea0 100644 --- a/reactos/dll/directx/wine/dinput/dinput_main.c +++ b/reactos/dll/directx/wine/dinput/dinput_main.c @@ -1754,7 +1754,7 @@ static BOOL check_hook_thread(void) return hook_thread_id != 0; } -void check_dinput_hooks(LPDIRECTINPUTDEVICE8W iface) +void check_dinput_hooks(LPDIRECTINPUTDEVICE8W iface, BOOL acquired) { static HHOOK callwndproc_hook; static ULONG foreground_cnt; @@ -1764,7 +1764,7 @@ void check_dinput_hooks(LPDIRECTINPUTDEVICE8W iface) if (dev->dwCoopLevel & DISCL_FOREGROUND) { - if (dev->acquired) + if (acquired) foreground_cnt++; else foreground_cnt--; diff --git a/reactos/dll/directx/wine/dinput/dinput_private.h b/reactos/dll/directx/wine/dinput/dinput_private.h index fb8c32ef17e..7a35be2c115 100644 --- a/reactos/dll/directx/wine/dinput/dinput_private.h +++ b/reactos/dll/directx/wine/dinput/dinput_private.h @@ -85,7 +85,7 @@ extern const struct dinput_device joystick_linux_device DECLSPEC_HIDDEN; extern const struct dinput_device joystick_linuxinput_device DECLSPEC_HIDDEN; extern const struct dinput_device joystick_osx_device DECLSPEC_HIDDEN; -extern void check_dinput_hooks(LPDIRECTINPUTDEVICE8W) DECLSPEC_HIDDEN; +extern void check_dinput_hooks(LPDIRECTINPUTDEVICE8W, BOOL) DECLSPEC_HIDDEN; extern void check_dinput_events(void) DECLSPEC_HIDDEN; typedef int (*DI_EVENT_PROC)(LPDIRECTINPUTDEVICE8A, WPARAM, LPARAM); diff --git a/reactos/dll/directx/wine/dinput/joystick_linux.c b/reactos/dll/directx/wine/dinput/joystick_linux.c index 054e088d87b..673fb1b19ed 100644 --- a/reactos/dll/directx/wine/dinput/joystick_linux.c +++ b/reactos/dll/directx/wine/dinput/joystick_linux.c @@ -233,10 +233,14 @@ static INT find_joystick_devices(void) /* If no axes were configured but there are axes assume a 1-to-1 (wii controller) */ if (joydev.axis_count && !found_axes) { + int axes_limit = min(joydev.axis_count, 8); /* generic driver limit */ + ERR("Incoherent joystick data, advertised %d axes, detected 0. Assuming 1-to-1.\n", - joydev.axis_count); - for (j = 0; j < joydev.axis_count; j++) + joydev.axis_count); + for (j = 0; j < axes_limit; j++) joydev.dev_axes_map[j] = j; + + joydev.axis_count = axes_limit; } }