[DINPUT] Sync with Wine Staging 2.16. CORE-13762
authorAmine Khaldi <amine.khaldi@reactos.org>
Sat, 16 Sep 2017 20:44:43 +0000 (20:44 +0000)
committerAmine Khaldi <amine.khaldi@reactos.org>
Sat, 16 Sep 2017 20:44:43 +0000 (20:44 +0000)
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
reactos/dll/directx/wine/dinput/dinput.rc
reactos/dll/directx/wine/dinput/dinput_main.c
reactos/dll/directx/wine/dinput/dinput_private.h
reactos/dll/directx/wine/dinput/joystick_linux.c

index d9f95b9..a67e244 100644 (file)
@@ -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;
 }
index e677561..0c5dae0 100644 (file)
@@ -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
index fc6d979..e480af7 100644 (file)
@@ -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--;
index fb8c32e..7a35be2 100644 (file)
@@ -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);
 
index 054e088..673fb1b 100644 (file)
@@ -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;
                 }
             }