[DINPUT] Sync with Wine Staging 3.3. CORE-14434
authorAmine Khaldi <amine.khaldi@reactos.org>
Thu, 8 Mar 2018 12:33:13 +0000 (13:33 +0100)
committerAmine Khaldi <amine.khaldi@reactos.org>
Thu, 8 Mar 2018 12:33:13 +0000 (13:33 +0100)
18 files changed:
dll/directx/wine/dinput/CMakeLists.txt
dll/directx/wine/dinput/config.c
dll/directx/wine/dinput/data_formats.c
dll/directx/wine/dinput/device.c
dll/directx/wine/dinput/device_private.h
dll/directx/wine/dinput/dinput.rc
dll/directx/wine/dinput/dinput_main.c
dll/directx/wine/dinput/dinput_private.h
dll/directx/wine/dinput/joystick.c
dll/directx/wine/dinput/joystick_linux.c
dll/directx/wine/dinput/joystick_linuxinput.c
dll/directx/wine/dinput/joystick_osx.c
dll/directx/wine/dinput/joystick_private.h
dll/directx/wine/dinput/keyboard.c
dll/directx/wine/dinput/mouse.c
dll/directx/wine/dinput/precomp.h [new file with mode: 0644]
dll/directx/wine/dinput/resource.h
media/doc/README.WINE

index 7292e15..fc215ea 100644 (file)
@@ -14,7 +14,7 @@ list(APPEND SOURCE
     joystick_osx.c
     keyboard.c
     mouse.c
-    dinput_private.h)
+    precomp.h)
 
 add_library(dinput SHARED
     ${SOURCE}
@@ -27,5 +27,5 @@ add_dependencies(dinput_data_formats psdk)
 set_module_type(dinput win32dll)
 target_link_libraries(dinput dxguid uuid wine)
 add_importlibs(dinput comctl32 ole32 user32 advapi32 msvcrt kernel32 ntdll)
-add_pch(dinput dinput_private.h SOURCE)
+add_pch(dinput precomp.h SOURCE)
 add_cd_file(TARGET dinput DESTINATION reactos/system32 FOR all)
index 52a950a..708f406 100644 (file)
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
-#include "dinput_private.h"
-
-#include <winuser.h>
-#include <commctrl.h>
+#define NONAMELESSUNION
 
+#include "wine/unicode.h"
+#include "objbase.h"
+#include "dinput_private.h"
+#include "device_private.h"
 #include "resource.h"
 
 typedef struct {
index e1582c0..5fac7b7 100644 (file)
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
-#define WIN32_NO_STATUS
-#define _INC_WINDOWS
-#define COM_NO_WINDOWS_H
+#if 0
+#pragma makedep implib
+#endif
 
 #include <stdarg.h>
 
-#include <windef.h>
-#include <winbase.h>
-#include <dinput.h>
+#include "windef.h"
+#include "dinput.h"
 
 #define numObjects(x) (sizeof(x) / sizeof(x[0]))
 
index d9f95b9..bb2a641 100644 (file)
 
    It also contains all the helper functions.
 */
-
+#include "config.h"
+
+#include <stdarg.h>
+#include <string.h>
+#include "wine/debug.h"
+#include "wine/unicode.h"
+#include "windef.h"
+#include "winbase.h"
+#include "winreg.h"
+#include "winuser.h"
+#include "winerror.h"
+#include "dinput.h"
+#include "device_private.h"
 #include "dinput_private.h"
 
+WINE_DEFAULT_DEBUG_CHANNEL(dinput);
+
 static inline IDirectInputDeviceImpl *impl_from_IDirectInputDevice8A(IDirectInputDevice8A *iface)
 {
     return CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8A_iface);
@@ -976,9 +990,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 +1018,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 bf227fd..52bbec4 100644 (file)
 #ifndef __WINE_DLLS_DINPUT_DINPUTDEVICE_PRIVATE_H
 #define __WINE_DLLS_DINPUT_DINPUTDEVICE_PRIVATE_H
 
+#include <stdarg.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "dinput.h"
+#include "wine/list.h"
+#include "dinput_private.h"
+
 typedef struct
 {
     int size;
index 0c5dae0..d2641f3 100644 (file)
@@ -16,9 +16,6 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
-#include <winuser.h>
-#include <commctrl.h>
-
 #include "resource.h"
 
 1 WINE_REGISTRY dinput_classes.rgs
@@ -30,7 +27,7 @@
 #define WINE_PRODUCTVERSION 5,1,2600,881
 #define WINE_PRODUCTVERSION_STR "5.1"
 
-#include <wine/wine_common_ver.rc>
+#include "wine/wine_common_ver.rc"
 
 #pragma makedep po
 
index 8b10680..69b9ff0 100644 (file)
  * - Fallout : works great in X and DGA mode
  */
 
+#include "config.h"
+#include <assert.h>
+#include <stdarg.h>
+#include <string.h>
+
+#define COBJMACROS
+#define NONAMELESSUNION
+
+#include "wine/debug.h"
+#include "wine/unicode.h"
+#include "windef.h"
+#include "winbase.h"
+#include "winuser.h"
+#include "winerror.h"
+#include "objbase.h"
+#include "rpcproxy.h"
+#include "initguid.h"
 #include "dinput_private.h"
+#include "device_private.h"
+#include "dinputd.h"
 
-#include <rpcproxy.h>
+WINE_DEFAULT_DEBUG_CHANNEL(dinput);
 
 static const IDirectInput7AVtbl ddi7avt;
 static const IDirectInput7WVtbl ddi7wvt;
@@ -1637,7 +1656,7 @@ static DWORD WINAPI hook_thread_proc(void *param)
 
     /* Force creation of the message queue */
     PeekMessageW( &msg, 0, 0, 0, PM_NOREMOVE );
-    SetEvent(*(LPHANDLE)param);
+    SetEvent(param);
 
     while (GetMessageW( &msg, 0, 0, 0 ))
     {
@@ -1705,6 +1724,7 @@ static DWORD WINAPI hook_thread_proc(void *param)
 }
 
 static DWORD hook_thread_id;
+static HANDLE hook_thread_event;
 
 static CRITICAL_SECTION_DEBUG dinput_critsect_debug =
 {
@@ -1723,24 +1743,21 @@ static BOOL check_hook_thread(void)
     TRACE("IDirectInputs left: %d\n", list_count(&direct_input_list));
     if (!list_empty(&direct_input_list) && !hook_thread)
     {
-        HANDLE event;
-
-        event = CreateEventW(NULL, FALSE, FALSE, NULL);
-        hook_thread = CreateThread(NULL, 0, hook_thread_proc, &event, 0, &hook_thread_id);
-        if (event && hook_thread)
-        {
-            HANDLE handles[2];
-            handles[0] = event;
-            handles[1] = hook_thread;
-            WaitForMultipleObjects(2, handles, FALSE, INFINITE);
-        }
+        hook_thread_event = CreateEventW(NULL, FALSE, FALSE, NULL);
+        hook_thread = CreateThread(NULL, 0, hook_thread_proc, hook_thread_event, 0, &hook_thread_id);
         LeaveCriticalSection(&dinput_hook_crit);
-        CloseHandle(event);
     }
     else if (list_empty(&direct_input_list) && hook_thread)
     {
         DWORD tid = hook_thread_id;
 
+        if (hook_thread_event) /* if thread is not started yet */
+        {
+            WaitForSingleObject(hook_thread_event, INFINITE);
+            CloseHandle(hook_thread_event);
+            hook_thread_event = NULL;
+        }
+
         hook_thread_id = 0;
         PostThreadMessageW(tid, WM_USER+0x10, 0, 0);
         LeaveCriticalSection(&dinput_hook_crit);
@@ -1756,7 +1773,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;
@@ -1766,7 +1783,7 @@ void check_dinput_hooks(LPDIRECTINPUTDEVICE8W iface)
 
     if (dev->dwCoopLevel & DISCL_FOREGROUND)
     {
-        if (dev->acquired)
+        if (acquired)
             foreground_cnt++;
         else
             foreground_cnt--;
@@ -1781,6 +1798,13 @@ void check_dinput_hooks(LPDIRECTINPUTDEVICE8W iface)
         callwndproc_hook = NULL;
     }
 
+    if (hook_thread_event) /* if thread is not started yet */
+    {
+        WaitForSingleObject(hook_thread_event, INFINITE);
+        CloseHandle(hook_thread_event);
+        hook_thread_event = NULL;
+    }
+
     PostThreadMessageW( hook_thread_id, WM_USER+0x10, 1, 0 );
 
     LeaveCriticalSection(&dinput_hook_crit);
index fb8c32e..3ed68f2 100644 (file)
 #ifndef __WINE_DLLS_DINPUT_DINPUT_PRIVATE_H
 #define __WINE_DLLS_DINPUT_DINPUT_PRIVATE_H
 
-#include <wine/config.h>
-
 #include <stdarg.h>
 
-#define WIN32_NO_STATUS
-#define _INC_WINDOWS
-#define COM_NO_WINDOWS_H
-
-#define COBJMACROS
-#define NONAMELESSUNION
-
-#include <windef.h>
-#include <winbase.h>
-#include <winreg.h>
-#include <winuser.h>
-#include <dinput.h>
-#include <dinputd.h>
-
-#include <wine/debug.h>
-#include <wine/list.h>
-#include <wine/unicode.h>
-
-WINE_DEFAULT_DEBUG_CHANNEL(dinput);
+#include "windef.h"
+#include "winbase.h"
+#include "dinput.h"
+#include "dinputd.h"
+#include "wine/list.h"
 
 /* Implementation specification */
 typedef struct IDirectInputImpl IDirectInputImpl;
@@ -85,7 +69,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);
 
@@ -102,6 +86,4 @@ extern WCHAR* get_mapping_path(const WCHAR *device, const WCHAR *username) DECLS
 #define DIMOUSE_MASK       0x82000000
 #define DIGENRE_ANY        0xFF000000
 
-#include "device_private.h"
-
 #endif /* __WINE_DLLS_DINPUT_DINPUT_PRIVATE_H */
index ef21faf..45c3618 100644 (file)
  *     force feedback
  */
 
-#include "dinput_private.h"
-
 #include <stdio.h>
 
 #include "joystick_private.h"
+#include "wine/debug.h"
+#include "winreg.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(dinput);
 
 static inline JoystickGenericImpl *impl_from_IDirectInputDevice8A(IDirectInputDevice8A *iface)
 {
index 673fb1b..963e62f 100644 (file)
  *     force feedback
  */
 
-#include "dinput_private.h"
+#include "config.h"
+#include "wine/port.h"
 
+#include <stdarg.h>
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
 #ifdef HAVE_UNISTD_H
 # include <unistd.h>
 #endif
 #ifdef HAVE_SYS_TIME_H
 # include <sys/time.h>
 #endif
+#include <fcntl.h>
 #ifdef HAVE_SYS_IOCTL_H
 # include <sys/ioctl.h>
 #endif
+#include <errno.h>
 #ifdef HAVE_LINUX_IOCTL_H
 # include <linux/ioctl.h>
 #endif
 # include <sys/poll.h>
 #endif
 
+#include "wine/debug.h"
+#include "wine/unicode.h"
+#include "windef.h"
+#include "winbase.h"
+#include "winerror.h"
+#include "dinput.h"
+
+#include "dinput_private.h"
+#include "device_private.h"
+#include "joystick_private.h"
+
 #ifdef HAVE_LINUX_22_JOYSTICK_API
 
+WINE_DEFAULT_DEBUG_CHANNEL(dinput);
+
 #define JOYDEV_NEW "/dev/input/js"
 #define JOYDEV_OLD "/dev/js"
 #define JOYDEVDRIVER " (js)"
index 2cd01e8..910e755 100644 (file)
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
-#include "dinput_private.h"
-
+#include "config.h"
+#include "wine/port.h"
+
+#include <assert.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
 #ifdef HAVE_UNISTD_H
 # include <unistd.h>
 #endif
 # include <sys/poll.h>
 #endif
 
+#include "wine/debug.h"
+#include "wine/unicode.h"
+#include "wine/list.h"
+#include "windef.h"
+#include "winbase.h"
+#include "winerror.h"
+#include "winreg.h"
+#include "dinput.h"
+
+#include "dinput_private.h"
 #include "device_private.h"
+#include "joystick_private.h"
 
 #ifdef HAS_PROPER_HEADER
 
+WINE_DEFAULT_DEBUG_CHANNEL(dinput);
+
 #define EVDEVPREFIX "/dev/input/event"
 #define EVDEVDRIVER " (event)"
 
index 67b1d63..b0dcdd9 100644 (file)
@@ -20,8 +20,8 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
-#include <config.h>
-//#include "wine/port.h"
+#include "config.h"
+#include "wine/port.h"
 
 #if defined(HAVE_IOKIT_HID_IOHIDLIB_H)
 #define DWORD UInt32
 #undef E_PENDING
 #endif /* HAVE_IOKIT_HID_IOHIDLIB_H */
 
-//#include "wine/debug.h"
-//#include "wine/unicode.h"
-//#include "windef.h"
-//#include "winbase.h"
-//#include "winerror.h"
-//#include "winreg.h"
-//#include "dinput.h"
+#include "wine/debug.h"
+#include "wine/unicode.h"
+#include "windef.h"
+#include "winbase.h"
+#include "winerror.h"
+#include "winreg.h"
+#include "dinput.h"
 
 #include "dinput_private.h"
-//#include "device_private.h"
-//#include "joystick_private.h"
+#include "device_private.h"
+#include "joystick_private.h"
 
 #ifdef HAVE_IOHIDMANAGERCREATE
 
index 3e24dee..e758cac 100644 (file)
 #ifndef __WINE_DLLS_DINPUT_JOYSTICK_PRIVATE_H
 #define __WINE_DLLS_DINPUT_JOYSTICK_PRIVATE_H
 
+#include <stdarg.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "dinput.h"
+#include "wine/list.h"
+#include "wine/unicode.h"
+#include "dinput_private.h"
+#include "device_private.h"
+
 /* Number of objects in the default data format */
 #define MAX_PROPS 164
 struct JoystickGenericImpl;
index ec7a58a..4c3c38e 100644 (file)
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
+#include "config.h"
+#include "wine/port.h"
+
+#include <stdarg.h>
+#include <string.h>
+#include "windef.h"
+#include "winbase.h"
+#include "winuser.h"
+#include "winerror.h"
+#include "dinput.h"
+
 #include "dinput_private.h"
+#include "device_private.h"
+#include "wine/debug.h"
+#include "wine/unicode.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(dinput);
 
 #define WINE_DINPUT_KEYBOARD_MAX_KEYS 256
 
index bcf9e13..eaec6b1 100644 (file)
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
+#include "config.h"
+#include "wine/port.h"
+
+#include <stdarg.h>
+#include <string.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "wingdi.h"
+#include "winuser.h"
+#include "winerror.h"
+#include "winreg.h"
+#include "dinput.h"
+
 #include "dinput_private.h"
+#include "device_private.h"
+#include "wine/debug.h"
+#include "wine/unicode.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(dinput);
 
 /* Wine mouse driver object instances */
 #define WINE_MOUSE_X_AXIS_INSTANCE   0
diff --git a/dll/directx/wine/dinput/precomp.h b/dll/directx/wine/dinput/precomp.h
new file mode 100644 (file)
index 0000000..9504beb
--- /dev/null
@@ -0,0 +1,24 @@
+
+#ifndef __WINE_DINPUT_PRECOMP_H
+#define __WINE_DINPUT_PRECOMP_H
+
+#include <wine/config.h>
+
+#define WIN32_NO_STATUS
+#define _INC_WINDOWS
+#define COM_NO_WINDOWS_H
+
+#define COBJMACROS
+#define NONAMELESSUNION
+
+#include "dinput_private.h"
+
+#include <winreg.h>
+#include <winuser.h>
+
+#include <wine/debug.h>
+#include <wine/unicode.h>
+
+#include "device_private.h"
+
+#endif /* !__WINE_DINPUT_PRECOMP_H */
index fa0376f..1f28fc5 100644 (file)
@@ -18,6 +18,8 @@
 
 #pragma once
 
+#include "shlobj.h"
+
 #define IDD_CONFIGUREDEVICES                    1
 
 #define IDC_DEVICETEXT                          20
index f41e488..ef1c4ac 100644 (file)
@@ -30,7 +30,7 @@ reactos/dll/directx/wine/d3dx9_24 => 43 # Synced to WineStaging-3.3
 reactos/dll/directx/wine/d3dxof         # Synced to WineStaging-3.3
 reactos/dll/directx/wine/ddraw          # Synced to WineStaging-3.3
 reactos/dll/directx/wine/devenum        # Synced to WineStaging-3.3
-reactos/dll/directx/wine/dinput         # Synced to Wine-3.0
+reactos/dll/directx/wine/dinput         # Synced to WineStaging-3.3
 reactos/dll/directx/wine/dinput8        # Synced to WineStaging-2.9
 reactos/dll/directx/wine/dmusic         # Synced to WineStaging-2.9
 reactos/dll/directx/wine/dplay          # Synced to WineStaging-2.9