dinput: Introduce new is_exclusively_acquired helper.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
c232fce6ea
commit
fd46a5aac3
|
@ -82,6 +82,11 @@ static inline const char *debugstr_diobjectdataformat( const DIOBJECTDATAFORMAT
|
||||||
debugstr_guid( data->pguid ), data->dwOfs, data->dwType, data->dwFlags );
|
debugstr_guid( data->pguid ), data->dwOfs, data->dwType, data->dwFlags );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline BOOL is_exclusively_acquired( struct dinput_device *device )
|
||||||
|
{
|
||||||
|
return device->acquired && (device->dwCoopLevel & DISCL_EXCLUSIVE);
|
||||||
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Various debugging tools
|
* Various debugging tools
|
||||||
*/
|
*/
|
||||||
|
@ -1073,7 +1078,7 @@ static HRESULT check_property( struct dinput_device *impl, const GUID *guid, con
|
||||||
|
|
||||||
case (DWORD_PTR)DIPROP_FFLOAD:
|
case (DWORD_PTR)DIPROP_FFLOAD:
|
||||||
if (!(impl->caps.dwFlags & DIDC_FORCEFEEDBACK)) return DIERR_UNSUPPORTED;
|
if (!(impl->caps.dwFlags & DIDC_FORCEFEEDBACK)) return DIERR_UNSUPPORTED;
|
||||||
if (!impl->acquired || !(impl->dwCoopLevel & DISCL_EXCLUSIVE)) return DIERR_NOTEXCLUSIVEACQUIRED;
|
if (!is_exclusively_acquired( impl )) return DIERR_NOTEXCLUSIVEACQUIRED;
|
||||||
/* fallthrough */
|
/* fallthrough */
|
||||||
case (DWORD_PTR)DIPROP_PRODUCTNAME:
|
case (DWORD_PTR)DIPROP_PRODUCTNAME:
|
||||||
case (DWORD_PTR)DIPROP_INSTANCENAME:
|
case (DWORD_PTR)DIPROP_INSTANCENAME:
|
||||||
|
@ -1399,7 +1404,7 @@ static HRESULT WINAPI dinput_device_set_property( IDirectInputDevice8W *iface, c
|
||||||
const DIPROPDWORD *value = (const DIPROPDWORD *)header;
|
const DIPROPDWORD *value = (const DIPROPDWORD *)header;
|
||||||
if (!impl->vtbl->send_device_gain) return DIERR_UNSUPPORTED;
|
if (!impl->vtbl->send_device_gain) return DIERR_UNSUPPORTED;
|
||||||
impl->device_gain = value->dwData;
|
impl->device_gain = value->dwData;
|
||||||
if (!impl->acquired || !(impl->dwCoopLevel & DISCL_EXCLUSIVE)) return DI_OK;
|
if (!is_exclusively_acquired( impl )) return DI_OK;
|
||||||
return impl->vtbl->send_device_gain( iface, impl->device_gain );
|
return impl->vtbl->send_device_gain( iface, impl->device_gain );
|
||||||
}
|
}
|
||||||
case (DWORD_PTR)DIPROP_AXISMODE:
|
case (DWORD_PTR)DIPROP_AXISMODE:
|
||||||
|
@ -1679,7 +1684,7 @@ static HRESULT WINAPI dinput_device_CreateEffect( IDirectInputDevice8W *iface, c
|
||||||
if (!params) return DI_OK;
|
if (!params) return DI_OK;
|
||||||
|
|
||||||
flags = params->dwSize == sizeof(DIEFFECT_DX6) ? DIEP_ALLPARAMS : DIEP_ALLPARAMS_DX5;
|
flags = params->dwSize == sizeof(DIEFFECT_DX6) ? DIEP_ALLPARAMS : DIEP_ALLPARAMS_DX5;
|
||||||
if (!impl->acquired || !(impl->dwCoopLevel & DISCL_EXCLUSIVE)) flags |= DIEP_NODOWNLOAD;
|
if (!is_exclusively_acquired( impl )) flags |= DIEP_NODOWNLOAD;
|
||||||
hr = IDirectInputEffect_SetParameters( *out, params, flags );
|
hr = IDirectInputEffect_SetParameters( *out, params, flags );
|
||||||
if (FAILED(hr)) goto failed;
|
if (FAILED(hr)) goto failed;
|
||||||
return DI_OK;
|
return DI_OK;
|
||||||
|
@ -1788,10 +1793,8 @@ static HRESULT WINAPI dinput_device_GetForceFeedbackState( IDirectInputDevice8W
|
||||||
if (!(impl->caps.dwFlags & DIDC_FORCEFEEDBACK)) return DIERR_UNSUPPORTED;
|
if (!(impl->caps.dwFlags & DIDC_FORCEFEEDBACK)) return DIERR_UNSUPPORTED;
|
||||||
|
|
||||||
EnterCriticalSection( &impl->crit );
|
EnterCriticalSection( &impl->crit );
|
||||||
if (!impl->acquired || !(impl->dwCoopLevel & DISCL_EXCLUSIVE))
|
if (!is_exclusively_acquired( impl )) hr = DIERR_NOTEXCLUSIVEACQUIRED;
|
||||||
hr = DIERR_NOTEXCLUSIVEACQUIRED;
|
else *out = impl->force_feedback_state;
|
||||||
else
|
|
||||||
*out = impl->force_feedback_state;
|
|
||||||
LeaveCriticalSection( &impl->crit );
|
LeaveCriticalSection( &impl->crit );
|
||||||
|
|
||||||
return hr;
|
return hr;
|
||||||
|
@ -1819,7 +1822,7 @@ static HRESULT WINAPI dinput_device_SendForceFeedbackCommand( IDirectInputDevice
|
||||||
if (!impl->vtbl->send_force_feedback_command) return DIERR_UNSUPPORTED;
|
if (!impl->vtbl->send_force_feedback_command) return DIERR_UNSUPPORTED;
|
||||||
|
|
||||||
EnterCriticalSection( &impl->crit );
|
EnterCriticalSection( &impl->crit );
|
||||||
if (!impl->acquired || !(impl->dwCoopLevel & DISCL_EXCLUSIVE)) hr = DIERR_NOTEXCLUSIVEACQUIRED;
|
if (!is_exclusively_acquired( impl )) hr = DIERR_NOTEXCLUSIVEACQUIRED;
|
||||||
else hr = impl->vtbl->send_force_feedback_command( iface, command, FALSE );
|
else hr = impl->vtbl->send_force_feedback_command( iface, command, FALSE );
|
||||||
LeaveCriticalSection( &impl->crit );
|
LeaveCriticalSection( &impl->crit );
|
||||||
|
|
||||||
|
|
|
@ -241,6 +241,11 @@ static inline struct hid_joystick_effect *impl_from_IDirectInputEffect( IDirectI
|
||||||
return CONTAINING_RECORD( iface, struct hid_joystick_effect, IDirectInputEffect_iface );
|
return CONTAINING_RECORD( iface, struct hid_joystick_effect, IDirectInputEffect_iface );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline BOOL is_exclusively_acquired( struct hid_joystick *joystick )
|
||||||
|
{
|
||||||
|
return joystick->base.acquired && (joystick->base.dwCoopLevel & DISCL_EXCLUSIVE);
|
||||||
|
}
|
||||||
|
|
||||||
static const GUID *object_usage_to_guid( USAGE usage_page, USAGE usage )
|
static const GUID *object_usage_to_guid( USAGE usage_page, USAGE usage )
|
||||||
{
|
{
|
||||||
switch (usage_page)
|
switch (usage_page)
|
||||||
|
@ -827,7 +832,7 @@ static HRESULT hid_joystick_get_property( IDirectInputDevice8W *iface, DWORD pro
|
||||||
{
|
{
|
||||||
DIPROPDWORD *value = (DIPROPDWORD *)header;
|
DIPROPDWORD *value = (DIPROPDWORD *)header;
|
||||||
if (!(impl->base.caps.dwFlags & DIDC_FORCEFEEDBACK)) return DIERR_UNSUPPORTED;
|
if (!(impl->base.caps.dwFlags & DIDC_FORCEFEEDBACK)) return DIERR_UNSUPPORTED;
|
||||||
if (!impl->base.acquired || !(impl->base.dwCoopLevel & DISCL_EXCLUSIVE)) return DIERR_NOTEXCLUSIVEACQUIRED;
|
if (!is_exclusively_acquired( impl )) return DIERR_NOTEXCLUSIVEACQUIRED;
|
||||||
value->dwData = 0;
|
value->dwData = 0;
|
||||||
return DI_OK;
|
return DI_OK;
|
||||||
}
|
}
|
||||||
|
@ -898,7 +903,7 @@ static HRESULT hid_joystick_unacquire( IDirectInputDevice8W *iface )
|
||||||
else WaitForSingleObject( impl->base.read_event, INFINITE );
|
else WaitForSingleObject( impl->base.read_event, INFINITE );
|
||||||
|
|
||||||
if (!(impl->base.caps.dwFlags & DIDC_FORCEFEEDBACK)) return DI_OK;
|
if (!(impl->base.caps.dwFlags & DIDC_FORCEFEEDBACK)) return DI_OK;
|
||||||
if (!impl->base.acquired || !(impl->base.dwCoopLevel & DISCL_EXCLUSIVE)) return DI_OK;
|
if (!is_exclusively_acquired( impl )) return DI_OK;
|
||||||
hid_joystick_send_force_feedback_command( iface, DISFFC_RESET, TRUE );
|
hid_joystick_send_force_feedback_command( iface, DISFFC_RESET, TRUE );
|
||||||
return DI_OK;
|
return DI_OK;
|
||||||
}
|
}
|
||||||
|
@ -2682,7 +2687,7 @@ static HRESULT WINAPI hid_joystick_effect_Start( IDirectInputEffect *iface, DWOR
|
||||||
else control = PID_USAGE_OP_EFFECT_START;
|
else control = PID_USAGE_OP_EFFECT_START;
|
||||||
|
|
||||||
EnterCriticalSection( &impl->joystick->base.crit );
|
EnterCriticalSection( &impl->joystick->base.crit );
|
||||||
if (!impl->joystick->base.acquired || !(impl->joystick->base.dwCoopLevel & DISCL_EXCLUSIVE))
|
if (!is_exclusively_acquired( impl->joystick ))
|
||||||
hr = DIERR_NOTEXCLUSIVEACQUIRED;
|
hr = DIERR_NOTEXCLUSIVEACQUIRED;
|
||||||
else if ((flags & DIES_NODOWNLOAD) && !impl->index)
|
else if ((flags & DIES_NODOWNLOAD) && !impl->index)
|
||||||
hr = DIERR_NOTDOWNLOADED;
|
hr = DIERR_NOTDOWNLOADED;
|
||||||
|
@ -2730,7 +2735,7 @@ static HRESULT WINAPI hid_joystick_effect_Stop( IDirectInputEffect *iface )
|
||||||
TRACE( "iface %p.\n", iface );
|
TRACE( "iface %p.\n", iface );
|
||||||
|
|
||||||
EnterCriticalSection( &impl->joystick->base.crit );
|
EnterCriticalSection( &impl->joystick->base.crit );
|
||||||
if (!impl->joystick->base.acquired || !(impl->joystick->base.dwCoopLevel & DISCL_EXCLUSIVE))
|
if (!is_exclusively_acquired( impl->joystick ))
|
||||||
hr = DIERR_NOTEXCLUSIVEACQUIRED;
|
hr = DIERR_NOTEXCLUSIVEACQUIRED;
|
||||||
else if (!impl->index)
|
else if (!impl->index)
|
||||||
hr = DIERR_NOTDOWNLOADED;
|
hr = DIERR_NOTDOWNLOADED;
|
||||||
|
@ -2775,7 +2780,7 @@ static HRESULT WINAPI hid_joystick_effect_GetEffectStatus( IDirectInputEffect *i
|
||||||
*status = 0;
|
*status = 0;
|
||||||
|
|
||||||
EnterCriticalSection( &impl->joystick->base.crit );
|
EnterCriticalSection( &impl->joystick->base.crit );
|
||||||
if (!impl->joystick->base.acquired || !(impl->joystick->base.dwCoopLevel & DISCL_EXCLUSIVE))
|
if (!is_exclusively_acquired( impl->joystick ))
|
||||||
hr = DIERR_NOTEXCLUSIVEACQUIRED;
|
hr = DIERR_NOTEXCLUSIVEACQUIRED;
|
||||||
else if (!impl->index)
|
else if (!impl->index)
|
||||||
hr = DIERR_NOTDOWNLOADED;
|
hr = DIERR_NOTDOWNLOADED;
|
||||||
|
@ -2850,7 +2855,7 @@ static HRESULT WINAPI hid_joystick_effect_Download( IDirectInputEffect *iface )
|
||||||
if (impl->modified) hr = DI_OK;
|
if (impl->modified) hr = DI_OK;
|
||||||
else hr = DI_NOEFFECT;
|
else hr = DI_NOEFFECT;
|
||||||
|
|
||||||
if (!impl->joystick->base.acquired || !(impl->joystick->base.dwCoopLevel & DISCL_EXCLUSIVE))
|
if (!is_exclusively_acquired( impl->joystick ))
|
||||||
hr = DIERR_NOTEXCLUSIVEACQUIRED;
|
hr = DIERR_NOTEXCLUSIVEACQUIRED;
|
||||||
else if ((impl->flags & complete_mask) != complete_mask)
|
else if ((impl->flags & complete_mask) != complete_mask)
|
||||||
hr = DIERR_INCOMPLETEEFFECT;
|
hr = DIERR_INCOMPLETEEFFECT;
|
||||||
|
|
Loading…
Reference in New Issue