From b0105c5dc309f9f8077f3f5d668f694a8957e1ab Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Sat, 2 Jul 2016 15:38:59 +0000 Subject: [PATCH] [DINPUT] Sync with Wine Staging 1.9.11. CORE-11368 svn path=/trunk/; revision=71759 --- reactos/dll/directx/wine/dinput/device.c | 22 +++++-------------- .../dll/directx/wine/dinput/device_private.h | 2 +- .../directx/wine/dinput/effect_linuxinput.c | 19 +++++++++++----- .../dll/directx/wine/dinput/joystick_linux.c | 4 ++-- .../dll/directx/wine/dinput/joystick_osx.c | 2 +- reactos/media/doc/README.WINE | 2 +- 6 files changed, 25 insertions(+), 26 deletions(-) diff --git a/reactos/dll/directx/wine/dinput/device.c b/reactos/dll/directx/wine/dinput/device.c index 86cd2cdd6a6..9c7bf2cb367 100644 --- a/reactos/dll/directx/wine/dinput/device.c +++ b/reactos/dll/directx/wine/dinput/device.c @@ -764,7 +764,6 @@ 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; @@ -855,7 +854,10 @@ HRESULT _set_action_map(LPDIRECTINPUTDEVICE8W iface, LPDIACTIONFORMATW lpdiaf, L 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)); + if (dwFlags & DIDSAM_NOUSER) + dps.wsz[0] = '\0'; + else + lstrcpynW(dps.wsz, username, sizeof(dps.wsz)/sizeof(WCHAR)); IDirectInputDevice8_SetProperty(iface, DIPROP_USERNAME, &dps.diph); /* Save the settings to disk */ @@ -1095,9 +1097,6 @@ 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 ); @@ -1255,9 +1254,7 @@ HRESULT WINAPI IDirectInputDevice2WImpl_GetProperty(LPDIRECTINPUTDEVICE8W iface, 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)); + lstrcpynW(ps->wsz, This->username, sizeof(ps->wsz)/sizeof(WCHAR)); break; } case (DWORD_PTR) DIPROP_VIDPID: @@ -1339,14 +1336,7 @@ HRESULT WINAPI IDirectInputDevice2WImpl_SetProperty( 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)); + lstrcpynW(This->username, ps->wsz, sizeof(This->username)/sizeof(WCHAR)); break; } default: diff --git a/reactos/dll/directx/wine/dinput/device_private.h b/reactos/dll/directx/wine/dinput/device_private.h index 6abee8104a3..3d89f60facc 100644 --- a/reactos/dll/directx/wine/dinput/device_private.h +++ b/reactos/dll/directx/wine/dinput/device_private.h @@ -73,7 +73,7 @@ struct IDirectInputDeviceImpl /* Action mapping */ int num_actions; /* number of actions mapped */ ActionMap *action_map; /* array of mappings */ - WCHAR *username; /* set by 'SetActionMap' */ + WCHAR username[MAX_PATH]; }; extern BOOL get_app_key(HKEY*, HKEY*) DECLSPEC_HIDDEN; diff --git a/reactos/dll/directx/wine/dinput/effect_linuxinput.c b/reactos/dll/directx/wine/dinput/effect_linuxinput.c index 3f172172494..ad7d3ad9f3a 100644 --- a/reactos/dll/directx/wine/dinput/effect_linuxinput.c +++ b/reactos/dll/directx/wine/dinput/effect_linuxinput.c @@ -67,6 +67,11 @@ static inline LinuxInputEffectImpl *impl_from_IDirectInputEffect(IDirectInputEff return CONTAINING_RECORD(iface, LinuxInputEffectImpl, IDirectInputEffect_iface); } +static double ff_effect_direction_to_rad(unsigned int dir) +{ + return (dir & 0xffff) * M_PI / 0x8000; +} + /****************************************************************************** * LinuxInputEffectImpl */ @@ -172,8 +177,10 @@ static HRESULT WINAPI LinuxInputEffectImpl_GetParameters( return diErr; else { if (peff->dwFlags & DIEFF_CARTESIAN) { - peff->rglDirection[0] = sin(M_PI * 3 * This->effect.direction / 0x7FFF) * 1000; - peff->rglDirection[1] = cos(M_PI * 3 * This->effect.direction / 0x7FFF) * 1000; + /* rotate so 0 points right */ + double angle = ff_effect_direction_to_rad(This->effect.direction + 0xc000); + peff->rglDirection[0] = sin(angle) * 1000; + peff->rglDirection[1] = -cos(angle) * 1000; } else { /* Polar and spherical coordinates are the same for two or less * axes. @@ -505,9 +512,11 @@ static HRESULT WINAPI LinuxInputEffectImpl_SetParameters( /* One condition block. This needs to be rotated to direction, * and expanded to separate x and y conditions. */ int i; - double factor[2]; - factor[0] = asin((This->effect.direction * 3.0 * M_PI) / 0x7FFF); - factor[1] = acos((This->effect.direction * 3.0 * M_PI) / 0x7FFF); + double factor[2], angle; + /* rotate so 0 points right */ + angle = ff_effect_direction_to_rad(This->effect.direction + 0xc000); + factor[0] = sin(angle); + factor[1] = -cos(angle); for (i = 0; i < 2; ++i) { This->effect.u.condition[i].center = (int)(factor[i] * (tsp->lOffset / 10) * 32); This->effect.u.condition[i].right_coeff = (int)(factor[i] * (tsp->lPositiveCoefficient / 10) * 32); diff --git a/reactos/dll/directx/wine/dinput/joystick_linux.c b/reactos/dll/directx/wine/dinput/joystick_linux.c index 85a56e91151..3fc6f1a7f62 100644 --- a/reactos/dll/directx/wine/dinput/joystick_linux.c +++ b/reactos/dll/directx/wine/dinput/joystick_linux.c @@ -143,7 +143,7 @@ static INT find_joystick_devices(void) #ifdef JSIOCGAXES if (ioctl(fd, JSIOCGAXES, &joydev.axis_count) < 0) { - WARN("ioctl(%s,JSIOCGAXES) failed: %s, defauting to 2\n", joydev.device, strerror(errno)); + WARN("ioctl(%s,JSIOCGAXES) failed: %s, defaulting to 2\n", joydev.device, strerror(errno)); joydev.axis_count = 2; } #else @@ -153,7 +153,7 @@ static INT find_joystick_devices(void) #ifdef JSIOCGBUTTONS if (ioctl(fd, JSIOCGBUTTONS, &joydev.button_count) < 0) { - WARN("ioctl(%s,JSIOCGBUTTONS) failed: %s, defauting to 2\n", joydev.device, strerror(errno)); + WARN("ioctl(%s,JSIOCGBUTTONS) failed: %s, defaulting to 2\n", joydev.device, strerror(errno)); joydev.button_count = 2; } #else diff --git a/reactos/dll/directx/wine/dinput/joystick_osx.c b/reactos/dll/directx/wine/dinput/joystick_osx.c index d5f54c23b3d..3edc7c97313 100644 --- a/reactos/dll/directx/wine/dinput/joystick_osx.c +++ b/reactos/dll/directx/wine/dinput/joystick_osx.c @@ -1474,7 +1474,7 @@ static HRESULT WINAPI effect_QueryInterface(IDirectInputEffect *iface, TRACE("%p %s %p\n", This, debugstr_guid(guid), out); - if(IsEqualIID(guid, &IID_IDirectInputEffect)){ + if(IsEqualIID(guid, &IID_IUnknown) || IsEqualIID(guid, &IID_IDirectInputEffect)){ *out = iface; IDirectInputEffect_AddRef(iface); return S_OK; diff --git a/reactos/media/doc/README.WINE b/reactos/media/doc/README.WINE index c4c4b1529ab..1e313c4d172 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.9.4 reactos/dll/directx/wine/d3dxof # Synced to WineStaging-1.9.4 reactos/dll/directx/wine/ddraw # Synced to WineStaging-1.9.4 reactos/dll/directx/wine/devenum # Synced to WineStaging-1.9.11 -reactos/dll/directx/wine/dinput # Synced to WineStaging-1.9.4 +reactos/dll/directx/wine/dinput # Synced to WineStaging-1.9.11 reactos/dll/directx/wine/dinput8 # Synced to WineStaging-1.9.4 reactos/dll/directx/wine/dmusic # Synced to WineStaging-1.9.4 reactos/dll/directx/wine/dplay # Synced to WineStaging-1.9.4