[DINPUT] Sync with Wine Staging 1.9.11. CORE-11368

svn path=/trunk/; revision=71759
This commit is contained in:
Amine Khaldi 2016-07-02 15:38:59 +00:00
parent b30f3bad0f
commit b0105c5dc3
6 changed files with 25 additions and 26 deletions

View file

@ -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:

View file

@ -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;

View file

@ -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);

View file

@ -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

View file

@ -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;

View file

@ -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