dinput: Guard (Get|Set)Property logic within the device CS.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
c918234f71
commit
99783e8c8b
|
@ -911,7 +911,7 @@ static BOOL CALLBACK find_object( const DIDEVICEOBJECTINSTANCEW *instance, void
|
||||||
return DIENUM_STOP;
|
return DIENUM_STOP;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI dinput_device_GetProperty( IDirectInputDevice8W *iface, const GUID *guid, DIPROPHEADER *header )
|
static HRESULT dinput_device_get_property( IDirectInputDevice8W *iface, const GUID *guid, DIPROPHEADER *header )
|
||||||
{
|
{
|
||||||
struct dinput_device *impl = impl_from_IDirectInputDevice8W( iface );
|
struct dinput_device *impl = impl_from_IDirectInputDevice8W( iface );
|
||||||
DWORD object_mask = DIDFT_AXIS | DIDFT_BUTTON | DIDFT_POV;
|
DWORD object_mask = DIDFT_AXIS | DIDFT_BUTTON | DIDFT_POV;
|
||||||
|
@ -919,12 +919,6 @@ static HRESULT WINAPI dinput_device_GetProperty( IDirectInputDevice8W *iface, co
|
||||||
DIPROPHEADER filter;
|
DIPROPHEADER filter;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
TRACE( "iface %p, guid %s, header %p\n", iface, debugstr_guid( guid ), header );
|
|
||||||
|
|
||||||
if (!header) return DIERR_INVALIDPARAM;
|
|
||||||
if (header->dwHeaderSize != sizeof(DIPROPHEADER)) return DIERR_INVALIDPARAM;
|
|
||||||
if (!IS_DIPROP( guid )) return DI_OK;
|
|
||||||
|
|
||||||
filter = *header;
|
filter = *header;
|
||||||
if (FAILED(hr = enum_object_filter_init( impl, &filter ))) return hr;
|
if (FAILED(hr = enum_object_filter_init( impl, &filter ))) return hr;
|
||||||
|
|
||||||
|
@ -1023,6 +1017,24 @@ static HRESULT WINAPI dinput_device_GetProperty( IDirectInputDevice8W *iface, co
|
||||||
return DI_OK;
|
return DI_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static HRESULT WINAPI dinput_device_GetProperty( IDirectInputDevice8W *iface, const GUID *guid, DIPROPHEADER *header )
|
||||||
|
{
|
||||||
|
struct dinput_device *impl = impl_from_IDirectInputDevice8W( iface );
|
||||||
|
HRESULT hr;
|
||||||
|
|
||||||
|
TRACE( "iface %p, guid %s, header %p\n", iface, debugstr_guid( guid ), header );
|
||||||
|
|
||||||
|
if (!header) return DIERR_INVALIDPARAM;
|
||||||
|
if (header->dwHeaderSize != sizeof(DIPROPHEADER)) return DIERR_INVALIDPARAM;
|
||||||
|
if (!IS_DIPROP( guid )) return DI_OK;
|
||||||
|
|
||||||
|
EnterCriticalSection( &impl->crit );
|
||||||
|
hr = dinput_device_get_property( iface, guid, header );
|
||||||
|
LeaveCriticalSection( &impl->crit );
|
||||||
|
|
||||||
|
return hr;
|
||||||
|
}
|
||||||
|
|
||||||
struct set_object_property_params
|
struct set_object_property_params
|
||||||
{
|
{
|
||||||
IDirectInputDevice8W *iface;
|
IDirectInputDevice8W *iface;
|
||||||
|
@ -1071,7 +1083,7 @@ static void reset_device_state( IDirectInputDevice8W *iface )
|
||||||
impl->vtbl->enum_objects( iface, &filter, DIDFT_AXIS | DIDFT_POV, reset_object_value, impl );
|
impl->vtbl->enum_objects( iface, &filter, DIDFT_AXIS | DIDFT_POV, reset_object_value, impl );
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI dinput_device_SetProperty( IDirectInputDevice8W *iface, const GUID *guid,
|
static HRESULT WINAPI dinput_device_set_property( IDirectInputDevice8W *iface, const GUID *guid,
|
||||||
const DIPROPHEADER *header )
|
const DIPROPHEADER *header )
|
||||||
{
|
{
|
||||||
struct set_object_property_params params = {.iface = iface, .header = header, .property = LOWORD( guid )};
|
struct set_object_property_params params = {.iface = iface, .header = header, .property = LOWORD( guid )};
|
||||||
|
@ -1081,12 +1093,6 @@ static HRESULT WINAPI dinput_device_SetProperty( IDirectInputDevice8W *iface, co
|
||||||
DIPROPHEADER filter;
|
DIPROPHEADER filter;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
TRACE( "iface %p, guid %s, header %p\n", iface, debugstr_guid( guid ), header );
|
|
||||||
|
|
||||||
if (!header) return DIERR_INVALIDPARAM;
|
|
||||||
if (header->dwHeaderSize != sizeof(DIPROPHEADER)) return DIERR_INVALIDPARAM;
|
|
||||||
if (!IS_DIPROP( guid )) return DI_OK;
|
|
||||||
|
|
||||||
filter = *header;
|
filter = *header;
|
||||||
if (FAILED(hr = enum_object_filter_init( impl, &filter ))) return hr;
|
if (FAILED(hr = enum_object_filter_init( impl, &filter ))) return hr;
|
||||||
|
|
||||||
|
@ -1118,18 +1124,13 @@ static HRESULT WINAPI dinput_device_SetProperty( IDirectInputDevice8W *iface, co
|
||||||
const DIPROPDWORD *value = (const DIPROPDWORD *)header;
|
const DIPROPDWORD *value = (const DIPROPDWORD *)header;
|
||||||
if (header->dwSize != sizeof(DIPROPDWORD)) return DIERR_INVALIDPARAM;
|
if (header->dwSize != sizeof(DIPROPDWORD)) return DIERR_INVALIDPARAM;
|
||||||
if (header->dwHow != DIPH_DEVICE) return DIERR_UNSUPPORTED;
|
if (header->dwHow != DIPH_DEVICE) return DIERR_UNSUPPORTED;
|
||||||
EnterCriticalSection( &impl->crit );
|
if (impl->acquired) return DIERR_ACQUIRED;
|
||||||
if (impl->acquired) hr = DIERR_ACQUIRED;
|
if (value->dwData > DIPROPAUTOCENTER_ON) return DIERR_INVALIDPARAM;
|
||||||
else if (value->dwData > DIPROPAUTOCENTER_ON) hr = DIERR_INVALIDPARAM;
|
if (!(impl->caps.dwFlags & DIDC_FORCEFEEDBACK)) return DIERR_UNSUPPORTED;
|
||||||
else if (!(impl->caps.dwFlags & DIDC_FORCEFEEDBACK)) hr = DIERR_UNSUPPORTED;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
FIXME( "DIPROP_AUTOCENTER stub!\n" );
|
FIXME( "DIPROP_AUTOCENTER stub!\n" );
|
||||||
impl->autocenter = value->dwData;
|
impl->autocenter = value->dwData;
|
||||||
hr = DI_OK;
|
return DI_OK;
|
||||||
}
|
|
||||||
LeaveCriticalSection( &impl->crit );
|
|
||||||
return hr;
|
|
||||||
}
|
}
|
||||||
case (DWORD_PTR)DIPROP_FFGAIN:
|
case (DWORD_PTR)DIPROP_FFGAIN:
|
||||||
{
|
{
|
||||||
|
@ -1138,12 +1139,9 @@ static HRESULT WINAPI dinput_device_SetProperty( IDirectInputDevice8W *iface, co
|
||||||
if (!impl->vtbl->send_device_gain) return DIERR_UNSUPPORTED;
|
if (!impl->vtbl->send_device_gain) return DIERR_UNSUPPORTED;
|
||||||
if (header->dwHow != DIPH_DEVICE) return DIERR_UNSUPPORTED;
|
if (header->dwHow != DIPH_DEVICE) return DIERR_UNSUPPORTED;
|
||||||
if (value->dwData > 10000) return DIERR_INVALIDPARAM;
|
if (value->dwData > 10000) return DIERR_INVALIDPARAM;
|
||||||
EnterCriticalSection( &impl->crit );
|
|
||||||
impl->device_gain = value->dwData;
|
impl->device_gain = value->dwData;
|
||||||
if (!impl->acquired || !(impl->dwCoopLevel & DISCL_EXCLUSIVE)) hr = DI_OK;
|
if (!impl->acquired || !(impl->dwCoopLevel & DISCL_EXCLUSIVE)) return DI_OK;
|
||||||
else hr = impl->vtbl->send_device_gain( iface, impl->device_gain );
|
return impl->vtbl->send_device_gain( iface, impl->device_gain );
|
||||||
LeaveCriticalSection( &impl->crit );
|
|
||||||
return hr;
|
|
||||||
}
|
}
|
||||||
case (DWORD_PTR)DIPROP_FFLOAD:
|
case (DWORD_PTR)DIPROP_FFLOAD:
|
||||||
case (DWORD_PTR)DIPROP_GRANULARITY:
|
case (DWORD_PTR)DIPROP_GRANULARITY:
|
||||||
|
@ -1163,41 +1161,31 @@ static HRESULT WINAPI dinput_device_SetProperty( IDirectInputDevice8W *iface, co
|
||||||
if (header->dwSize != sizeof(DIPROPDWORD)) return DIERR_INVALIDPARAM;
|
if (header->dwSize != sizeof(DIPROPDWORD)) return DIERR_INVALIDPARAM;
|
||||||
if (header->dwHow != DIPH_DEVICE) return DIERR_UNSUPPORTED;
|
if (header->dwHow != DIPH_DEVICE) return DIERR_UNSUPPORTED;
|
||||||
if (header->dwHow == DIPH_DEVICE && header->dwObj) return DIERR_INVALIDPARAM;
|
if (header->dwHow == DIPH_DEVICE && header->dwObj) return DIERR_INVALIDPARAM;
|
||||||
|
if (impl->acquired) return DIERR_ACQUIRED;
|
||||||
|
|
||||||
TRACE( "Axis mode: %s\n", value->dwData == DIPROPAXISMODE_ABS ? "absolute" : "relative" );
|
TRACE( "Axis mode: %s\n", value->dwData == DIPROPAXISMODE_ABS ? "absolute" : "relative" );
|
||||||
EnterCriticalSection( &impl->crit );
|
if (impl->user_format)
|
||||||
if (impl->acquired) hr = DIERR_ACQUIRED;
|
|
||||||
else if (!impl->user_format) hr = DI_OK;
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
impl->user_format->dwFlags &= ~DIDFT_AXIS;
|
impl->user_format->dwFlags &= ~DIDFT_AXIS;
|
||||||
impl->user_format->dwFlags |= value->dwData == DIPROPAXISMODE_ABS ? DIDF_ABSAXIS : DIDF_RELAXIS;
|
impl->user_format->dwFlags |= value->dwData == DIPROPAXISMODE_ABS ? DIDF_ABSAXIS : DIDF_RELAXIS;
|
||||||
hr = DI_OK;
|
|
||||||
}
|
}
|
||||||
LeaveCriticalSection( &impl->crit );
|
return DI_OK;
|
||||||
return hr;
|
|
||||||
}
|
}
|
||||||
case (DWORD_PTR)DIPROP_BUFFERSIZE:
|
case (DWORD_PTR)DIPROP_BUFFERSIZE:
|
||||||
{
|
{
|
||||||
const DIPROPDWORD *value = (const DIPROPDWORD *)header;
|
const DIPROPDWORD *value = (const DIPROPDWORD *)header;
|
||||||
if (header->dwSize != sizeof(DIPROPDWORD)) return DIERR_INVALIDPARAM;
|
if (header->dwSize != sizeof(DIPROPDWORD)) return DIERR_INVALIDPARAM;
|
||||||
|
if (impl->acquired) return DIERR_ACQUIRED;
|
||||||
|
|
||||||
TRACE( "buffersize = %d\n", value->dwData );
|
TRACE( "buffersize = %d\n", value->dwData );
|
||||||
|
|
||||||
EnterCriticalSection( &impl->crit );
|
|
||||||
if (impl->acquired) hr = DIERR_ACQUIRED;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
impl->buffersize = value->dwData;
|
impl->buffersize = value->dwData;
|
||||||
impl->queue_len = min( impl->buffersize, 1024 );
|
impl->queue_len = min( impl->buffersize, 1024 );
|
||||||
free( impl->data_queue );
|
free( impl->data_queue );
|
||||||
|
|
||||||
impl->data_queue = impl->queue_len ? malloc( impl->queue_len * sizeof(DIDEVICEOBJECTDATA) ) : NULL;
|
impl->data_queue = impl->queue_len ? malloc( impl->queue_len * sizeof(DIDEVICEOBJECTDATA) ) : NULL;
|
||||||
impl->queue_head = impl->queue_tail = impl->overflow = 0;
|
impl->queue_head = impl->queue_tail = impl->overflow = 0;
|
||||||
hr = DI_OK;
|
return DI_OK;
|
||||||
}
|
|
||||||
LeaveCriticalSection( &impl->crit );
|
|
||||||
return hr;
|
|
||||||
}
|
}
|
||||||
case (DWORD_PTR)DIPROP_APPDATA:
|
case (DWORD_PTR)DIPROP_APPDATA:
|
||||||
{
|
{
|
||||||
|
@ -1220,6 +1208,25 @@ static HRESULT WINAPI dinput_device_SetProperty( IDirectInputDevice8W *iface, co
|
||||||
return DI_OK;
|
return DI_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static HRESULT WINAPI dinput_device_SetProperty( IDirectInputDevice8W *iface, const GUID *guid,
|
||||||
|
const DIPROPHEADER *header )
|
||||||
|
{
|
||||||
|
struct dinput_device *impl = impl_from_IDirectInputDevice8W( iface );
|
||||||
|
HRESULT hr;
|
||||||
|
|
||||||
|
TRACE( "iface %p, guid %s, header %p\n", iface, debugstr_guid( guid ), header );
|
||||||
|
|
||||||
|
if (!header) return DIERR_INVALIDPARAM;
|
||||||
|
if (header->dwHeaderSize != sizeof(DIPROPHEADER)) return DIERR_INVALIDPARAM;
|
||||||
|
if (!IS_DIPROP( guid )) return DI_OK;
|
||||||
|
|
||||||
|
EnterCriticalSection( &impl->crit );
|
||||||
|
hr = dinput_device_set_property( iface, guid, header );
|
||||||
|
LeaveCriticalSection( &impl->crit );
|
||||||
|
|
||||||
|
return hr;
|
||||||
|
}
|
||||||
|
|
||||||
static void dinput_device_set_username( struct dinput_device *impl, const DIPROPSTRING *value )
|
static void dinput_device_set_username( struct dinput_device *impl, const DIPROPSTRING *value )
|
||||||
{
|
{
|
||||||
struct DevicePlayer *device_player;
|
struct DevicePlayer *device_player;
|
||||||
|
|
Loading…
Reference in New Issue