Module: wine Branch: master Commit: a06821765a86b783fb45487a50630b26a9f6a96b URL: http://source.winehq.org/git/wine.git/?a=commit;h=a06821765a86b783fb45487a50...
Author: Vitaliy Margolen wine-patches@kievinfo.com Date: Tue Feb 6 09:47:17 2007 -0700
dinput: Don't reset dead zone and saturation when setting data format.
Additional tests indicate that native doesn't touch previously set properties.
---
dlls/dinput/joystick_linux.c | 32 +++----------------------------- dlls/dinput/joystick_linuxinput.c | 13 ++++++++++++- dlls/dinput/tests/joystick.c | 23 ++++++++++++++++++++++- 3 files changed, 37 insertions(+), 31 deletions(-)
diff --git a/dlls/dinput/joystick_linux.c b/dlls/dinput/joystick_linux.c index 3fa906d..26a62b5 100644 --- a/dlls/dinput/joystick_linux.c +++ b/dlls/dinput/joystick_linux.c @@ -474,7 +474,7 @@ static HRESULT alloc_device(REFGUID rgui 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; @@ -672,32 +672,6 @@ static ULONG WINAPI JoystickAImpl_Releas }
/****************************************************************************** - * 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 */ static HRESULT WINAPI JoystickAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface) @@ -1250,7 +1224,7 @@ static const IDirectInputDevice8AVtbl Jo JoystickAImpl_Unacquire, JoystickAImpl_GetDeviceState, IDirectInputDevice2AImpl_GetDeviceData, - JoystickAImpl_SetDataFormat, + IDirectInputDevice2AImpl_SetDataFormat, IDirectInputDevice2AImpl_SetEventNotification, IDirectInputDevice2AImpl_SetCooperativeLevel, JoystickAImpl_GetObjectInfo, @@ -1292,7 +1266,7 @@ static const IDirectInputDevice8WVtbl Sy 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, diff --git a/dlls/dinput/joystick_linuxinput.c b/dlls/dinput/joystick_linuxinput.c index 12fcf6d..8df801e 100644 --- a/dlls/dinput/joystick_linuxinput.c +++ b/dlls/dinput/joystick_linuxinput.c @@ -923,9 +923,20 @@ static HRESULT WINAPI JoystickAImpl_GetP 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; diff --git a/dlls/dinput/tests/joystick.c b/dlls/dinput/tests/joystick.c index 7ca690a..61d1426 100644 --- a/dlls/dinput/tests/joystick.c +++ b/dlls/dinput/tests/joystick.c @@ -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));