Author: akhaldi
Date: Mon Feb 29 00:08:18 2016
New Revision: 70812
URL: 
http://svn.reactos.org/svn/reactos?rev=70812&view=rev
Log:
[DINPUT] Sync with Wine Staging 1.9.4. CORE-10912
Modified:
    trunk/reactos/dll/directx/wine/dinput/device.c
    trunk/reactos/dll/directx/wine/dinput/device_private.h
    trunk/reactos/media/doc/README.WINE
Modified: trunk/reactos/dll/directx/wine/dinput/device.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/wine/dinput/de…
==============================================================================
--- trunk/reactos/dll/directx/wine/dinput/device.c      [iso-8859-1] (original)
+++ trunk/reactos/dll/directx/wine/dinput/device.c      [iso-8859-1] Mon Feb 29 00:08:18
2016
@@ -764,11 +764,13 @@
 HRESULT _set_action_map(LPDIRECTINPUTDEVICE8W iface, LPDIACTIONFORMATW lpdiaf, LPCWSTR
lpszUserName, DWORD dwFlags, LPCDIDATAFORMAT df)
 {
+    static const WCHAR emptyW[] = { 0 };
     IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8W(iface);
     DIDATAFORMAT data_format;
     DIOBJECTDATAFORMAT *obj_df = NULL;
     DIPROPDWORD dp;
     DIPROPRANGE dpr;
+    DIPROPSTRING dps;
     WCHAR username[MAX_PATH];
     DWORD username_size = MAX_PATH;
     int i, action = 0, num_actions = 0;
@@ -848,6 +850,13 @@
         GetUserNameW(username, &username_size);
     else
         lstrcpynW(username, lpszUserName, MAX_PATH);
+
+    dps.diph.dwSize = sizeof(dps);
+    dps.diph.dwHeaderSize = sizeof(DIPROPHEADER);
+    dps.diph.dwObj = 0;
+    dps.diph.dwHow = DIPH_DEVICE;
+    lstrcpynW(dps.wsz, (dwFlags & DIDSAM_NOUSER) ? emptyW : username,
sizeof(dps.wsz)/sizeof(WCHAR));
+    IDirectInputDevice8_SetProperty(iface, DIPROP_USERNAME, &dps.diph);
     /* Save the settings to disk */
     save_mapping_settings(iface, lpdiaf, username);
@@ -1014,10 +1023,10 @@
     if (hwnd && GetWindowLongW(hwnd, GWL_STYLE) & WS_CHILD) return E_HANDLE;
-    if (dwflags == (DISCL_NONEXCLUSIVE | DISCL_BACKGROUND))
+    if (!hwnd && dwflags == (DISCL_NONEXCLUSIVE | DISCL_BACKGROUND))
         hwnd = GetDesktopWindow();
-    if (!hwnd) return E_HANDLE;
+    if (!IsWindow(hwnd)) return E_HANDLE;
     /* For security reasons native does not allow exclusive background level
        for mouse and keyboard only */
@@ -1086,6 +1095,9 @@
     /* Free action mapping */
     HeapFree(GetProcessHeap(), 0, This->action_map);
+    /* Free username */
+    HeapFree(GetProcessHeap(), 0, This->username);
+
     EnterCriticalSection( &This->dinput->crit );
     list_remove( &This->entry );
     LeaveCriticalSection( &This->dinput->crit );
@@ -1235,6 +1247,17 @@
             pd->dwData = This->queue_len;
             TRACE("buffersize = %d\n", pd->dwData);
+            break;
+        }
+        case (DWORD_PTR) DIPROP_USERNAME:
+        {
+            LPDIPROPSTRING ps = (LPDIPROPSTRING)pdiph;
+
+            if (pdiph->dwSize != sizeof(DIPROPSTRING)) return DIERR_INVALIDPARAM;
+
+            ps->wsz[0] = 0;
+            if (This->username)
+                lstrcpynW(ps->wsz, This->username,
sizeof(ps->wsz)/sizeof(WCHAR));
             break;
         }
         case (DWORD_PTR) DIPROP_VIDPID:
@@ -1308,6 +1331,22 @@
             This->queue_len  = pd->dwData;
             LeaveCriticalSection(&This->crit);
+            break;
+        }
+        case (DWORD_PTR) DIPROP_USERNAME:
+        {
+            LPCDIPROPSTRING ps = (LPCDIPROPSTRING)pdiph;
+
+            if (pdiph->dwSize != sizeof(DIPROPSTRING)) return DIERR_INVALIDPARAM;
+
+            if (!This->username)
+                This->username = HeapAlloc(GetProcessHeap(), 0, sizeof(ps->wsz));
+            if (!This->username)
+                return DIERR_OUTOFMEMORY;
+
+            This->username[0] = 0;
+            if (ps->wsz)
+                lstrcpynW(This->username, ps->wsz,
sizeof(ps->wsz)/sizeof(WCHAR));
             break;
         }
         default:
Modified: trunk/reactos/dll/directx/wine/dinput/device_private.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/wine/dinput/de…
==============================================================================
--- trunk/reactos/dll/directx/wine/dinput/device_private.h      [iso-8859-1] (original)
+++ trunk/reactos/dll/directx/wine/dinput/device_private.h      [iso-8859-1] Mon Feb 29
00:08:18 2016
@@ -73,6 +73,7 @@
     /* Action mapping */
     int                         num_actions; /* number of actions mapped */
     ActionMap                  *action_map;  /* array of mappings */
+    WCHAR                      *username;    /* set by 'SetActionMap' */
 };
 extern BOOL get_app_key(HKEY*, HKEY*) DECLSPEC_HIDDEN;
Modified: trunk/reactos/media/doc/README.WINE
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/media/doc/README.WINE?rev=…
==============================================================================
--- trunk/reactos/media/doc/README.WINE [iso-8859-1] (original)
+++ trunk/reactos/media/doc/README.WINE [iso-8859-1] Mon Feb 29 00:08:18 2016
@@ -30,7 +30,7 @@
 reactos/dll/directx/wine/d3dxof         # Synced to WineStaging-1.7.55
 reactos/dll/directx/wine/ddraw          # Synced to WineStaging-1.9.4
 reactos/dll/directx/wine/devenum        # Synced to WineStaging-1.7.55
-reactos/dll/directx/wine/dinput         # Synced to WineStaging-1.7.55
+reactos/dll/directx/wine/dinput         # Synced to WineStaging-1.9.4
 reactos/dll/directx/wine/dinput8        # Synced to WineStaging-1.7.55
 reactos/dll/directx/wine/dmusic         # Synced to WineStaging-1.7.55
 reactos/dll/directx/wine/dplay          # Synced to WineStaging-1.7.55