mirror of
git://source.winehq.org/git/wine.git
synced 2024-11-01 09:50:52 +00:00
dinput: Don't reset dead zone and saturation when setting data format.
Additional tests indicate that native doesn't touch previously set properties.
This commit is contained in:
parent
aa4f89c84d
commit
a06821765a
3 changed files with 37 additions and 31 deletions
|
@ -474,7 +474,7 @@ static HRESULT alloc_device(REFGUID rguid, const void *jvt, IDirectInputImpl *di
|
|||
newDevice->base.crit.DebugInfo->Spare[0] = (DWORD_PTR)"DINPUT_joystick";
|
||||
|
||||
/* setup_dinput_options may change these */
|
||||
newDevice->deadzone = 5000;
|
||||
newDevice->deadzone = 0;
|
||||
newDevice->devcaps.dwButtons = newDevice->buttons;
|
||||
newDevice->devcaps.dwAxes = newDevice->axes;
|
||||
newDevice->devcaps.dwPOVs = 0;
|
||||
|
@ -671,32 +671,6 @@ static ULONG WINAPI JoystickAImpl_Release(LPDIRECTINPUTDEVICE8A iface)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* SetDataFormat : the application can choose the format of the data
|
||||
* the device driver sends back with GetDeviceState.
|
||||
*/
|
||||
static HRESULT WINAPI JoystickAImpl_SetDataFormat(
|
||||
LPDIRECTINPUTDEVICE8A iface,
|
||||
LPCDIDATAFORMAT df)
|
||||
{
|
||||
JoystickImpl *This = (JoystickImpl *)iface;
|
||||
unsigned int i;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("(%p,%p)\n",This,df);
|
||||
|
||||
hr = IDirectInputDevice2AImpl_SetDataFormat(iface, df);
|
||||
if (FAILED(hr)) return hr;
|
||||
|
||||
for (i = 0; i < This->base.data_format.wine_df->dwNumObjs; i++)
|
||||
{
|
||||
This->props[i].lDeadZone = 1000;
|
||||
This->props[i].lSaturation = 0;
|
||||
}
|
||||
|
||||
return DI_OK;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Acquire : gets exclusive control of the joystick
|
||||
*/
|
||||
|
@ -1250,7 +1224,7 @@ static const IDirectInputDevice8AVtbl JoystickAvt =
|
|||
JoystickAImpl_Unacquire,
|
||||
JoystickAImpl_GetDeviceState,
|
||||
IDirectInputDevice2AImpl_GetDeviceData,
|
||||
JoystickAImpl_SetDataFormat,
|
||||
IDirectInputDevice2AImpl_SetDataFormat,
|
||||
IDirectInputDevice2AImpl_SetEventNotification,
|
||||
IDirectInputDevice2AImpl_SetCooperativeLevel,
|
||||
JoystickAImpl_GetObjectInfo,
|
||||
|
@ -1292,7 +1266,7 @@ static const IDirectInputDevice8WVtbl SysJoystickWvt =
|
|||
XCAST(Unacquire)JoystickAImpl_Unacquire,
|
||||
XCAST(GetDeviceState)JoystickAImpl_GetDeviceState,
|
||||
XCAST(GetDeviceData)IDirectInputDevice2AImpl_GetDeviceData,
|
||||
XCAST(SetDataFormat)JoystickAImpl_SetDataFormat,
|
||||
XCAST(SetDataFormat)IDirectInputDevice2AImpl_SetDataFormat,
|
||||
XCAST(SetEventNotification)IDirectInputDevice2AImpl_SetEventNotification,
|
||||
XCAST(SetCooperativeLevel)IDirectInputDevice2AImpl_SetCooperativeLevel,
|
||||
IDirectInputDevice2WImpl_GetObjectInfo,
|
||||
|
|
|
@ -923,9 +923,20 @@ static HRESULT WINAPI JoystickAImpl_GetProperty(LPDIRECTINPUTDEVICE8A iface,
|
|||
TRACE("range(%d, %d) obj=%d\n", pr->lMin, pr->lMax, obj);
|
||||
break;
|
||||
}
|
||||
case (DWORD) DIPROP_DEADZONE:
|
||||
{
|
||||
LPDIPROPDWORD pd = (LPDIPROPDWORD)pdiph;
|
||||
int obj = find_property(&This->base.data_format, pdiph);
|
||||
|
||||
if (obj < 0) return DIERR_OBJECTNOTFOUND;
|
||||
|
||||
pd->dwData = This->props[obj].deadzone;
|
||||
TRACE("deadzone(%d) obj=%d\n", pd->dwData, obj);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
return IDirectInputDevice2AImpl_GetProperty(iface, rguid, pdiph);
|
||||
return IDirectInputDevice2AImpl_GetProperty(iface, rguid, pdiph);
|
||||
}
|
||||
|
||||
return DI_OK;
|
||||
|
|
|
@ -82,6 +82,7 @@ typedef struct tagJoystickInfo
|
|||
DWORD pov;
|
||||
DWORD button;
|
||||
LONG lMin, lMax;
|
||||
DWORD dZone;
|
||||
} JoystickInfo;
|
||||
|
||||
static BOOL CALLBACK EnumAxes(
|
||||
|
@ -97,13 +98,21 @@ static BOOL CALLBACK EnumAxes(
|
|||
IsEqualIID(&pdidoi->guidType, &GUID_RxAxis) ||
|
||||
IsEqualIID(&pdidoi->guidType, &GUID_RyAxis) ||
|
||||
IsEqualIID(&pdidoi->guidType, &GUID_RzAxis) ||
|
||||
IsEqualIID(&pdidoi->guidType, &GUID_Slider)) {
|
||||
IsEqualIID(&pdidoi->guidType, &GUID_Slider))
|
||||
{
|
||||
DIPROPRANGE diprg;
|
||||
DIPROPDWORD dipdw;
|
||||
|
||||
diprg.diph.dwSize = sizeof(DIPROPRANGE);
|
||||
diprg.diph.dwHeaderSize = sizeof(DIPROPHEADER);
|
||||
diprg.diph.dwHow = DIPH_BYID;
|
||||
diprg.diph.dwObj = pdidoi->dwType;
|
||||
|
||||
dipdw.diph.dwSize = sizeof(dipdw);
|
||||
dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER);
|
||||
dipdw.diph.dwHow = DIPH_BYID;
|
||||
dipdw.diph.dwObj = pdidoi->dwType;
|
||||
|
||||
hr = IDirectInputDevice_GetProperty(info->pJoystick, DIPROP_RANGE, &diprg.diph);
|
||||
ok(SUCCEEDED(hr), "IDirectInputDevice_GetProperty() failed: %s\n", DXGetErrorString8(hr));
|
||||
ok(info->lMin == diprg.lMin && info->lMax == diprg.lMax, "Min/Max range invalid: "
|
||||
|
@ -119,6 +128,17 @@ static BOOL CALLBACK EnumAxes(
|
|||
hr = IDirectInputDevice_SetProperty(info->pJoystick, DIPROP_RANGE, &diprg.diph);
|
||||
ok(hr==DI_OK,"IDirectInputDevice_SetProperty() failed: %s\n", DXGetErrorString8(hr));
|
||||
|
||||
/* dead zone */
|
||||
hr = IDirectInputDevice_GetProperty(info->pJoystick, DIPROP_DEADZONE, &dipdw.diph);
|
||||
ok(SUCCEEDED(hr), "IDirectInputDevice_GetProperty() failed: %s\n", DXGetErrorString8(hr));
|
||||
ok(info->dZone == dipdw.dwData, "deadzone invalid: expected %d got %d\n",
|
||||
info->dZone, dipdw.dwData);
|
||||
|
||||
dipdw.dwData = 123;
|
||||
|
||||
hr = IDirectInputDevice_SetProperty(info->pJoystick, DIPROP_DEADZONE, &dipdw.diph);
|
||||
ok(hr==DI_OK,"IDirectInputDevice_SetProperty() failed: %s\n", DXGetErrorString8(hr));
|
||||
|
||||
info->axis++;
|
||||
} else if (IsEqualIID(&pdidoi->guidType, &GUID_POV))
|
||||
info->pov++;
|
||||
|
@ -263,6 +283,7 @@ static BOOL CALLBACK EnumJoysticks(
|
|||
ok(hr==DI_OK,"IDirectInputDevice_SetDataFormat() failed: %s\n", DXGetErrorString8(hr));
|
||||
info.lMin = -2000;
|
||||
info.lMax = +2000;
|
||||
info.dZone= 123;
|
||||
hr = IDirectInputDevice_EnumObjects(pJoystick, EnumAxes, (VOID*)&info, DIDFT_ALL);
|
||||
ok(hr==DI_OK,"IDirectInputDevice_EnumObjects() failed: %s\n", DXGetErrorString8(hr));
|
||||
|
||||
|
|
Loading…
Reference in a new issue