From 6a531b1d1aff120253446b97a5044d7f6f5e2fe3 Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Mon, 29 Feb 2016 00:08:18 +0000 Subject: [PATCH] [DINPUT] Sync with Wine Staging 1.9.4. CORE-10912 svn path=/trunk/; revision=70812 --- reactos/dll/directx/wine/dinput/device.c | 43 ++++++++++++++++++- .../dll/directx/wine/dinput/device_private.h | 1 + reactos/media/doc/README.WINE | 2 +- 3 files changed, 43 insertions(+), 3 deletions(-) diff --git a/reactos/dll/directx/wine/dinput/device.c b/reactos/dll/directx/wine/dinput/device.c index b33286ae777..86cd2cdd6a6 100644 --- a/reactos/dll/directx/wine/dinput/device.c +++ b/reactos/dll/directx/wine/dinput/device.c @@ -764,11 +764,13 @@ HRESULT _build_action_map(LPDIRECTINPUTDEVICE8W iface, LPDIACTIONFORMATW lpdiaf, 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; @@ -849,6 +851,13 @@ HRESULT _set_action_map(LPDIRECTINPUTDEVICE8W iface, LPDIACTIONFORMATW lpdiaf, L 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 @@ HRESULT WINAPI IDirectInputDevice2WImpl_SetCooperativeLevel(LPDIRECTINPUTDEVICE8 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 @@ ULONG WINAPI IDirectInputDevice2WImpl_Release(LPDIRECTINPUTDEVICE8W iface) /* 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 ); @@ -1237,6 +1249,17 @@ HRESULT WINAPI IDirectInputDevice2WImpl_GetProperty(LPDIRECTINPUTDEVICE8W iface, 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: FIXME("DIPROP_VIDPID not implemented\n"); return DIERR_UNSUPPORTED; @@ -1310,6 +1333,22 @@ HRESULT WINAPI IDirectInputDevice2WImpl_SetProperty( 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: WARN("Unknown property %s\n", debugstr_guid(rguid)); return DIERR_UNSUPPORTED; diff --git a/reactos/dll/directx/wine/dinput/device_private.h b/reactos/dll/directx/wine/dinput/device_private.h index bf227fd7f26..6abee8104a3 100644 --- a/reactos/dll/directx/wine/dinput/device_private.h +++ b/reactos/dll/directx/wine/dinput/device_private.h @@ -73,6 +73,7 @@ struct IDirectInputDeviceImpl /* 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; diff --git a/reactos/media/doc/README.WINE b/reactos/media/doc/README.WINE index ebbefd8f217..5564daf98ab 100644 --- a/reactos/media/doc/README.WINE +++ b/reactos/media/doc/README.WINE @@ -30,7 +30,7 @@ reactos/dll/directx/wine/d3dx9_24 => 43 # Synced to WineStaging-1.7.55 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 -- 2.17.1