dinput: Move SetProperty implementation to the generic device.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
801bc147f0
commit
3834eaf9bd
|
@ -1143,8 +1143,35 @@ static BOOL CALLBACK set_object_property( const DIDEVICEOBJECTINSTANCEW *instanc
|
|||
{
|
||||
struct set_object_property_params *params = context;
|
||||
struct dinput_device *impl = impl_from_IDirectInputDevice8W( params->iface );
|
||||
impl->vtbl->set_property( params->iface, params->property, params->header, instance );
|
||||
return DIENUM_CONTINUE;
|
||||
struct object_properties *properties = NULL;
|
||||
|
||||
if (!impl->object_properties) return DIENUM_STOP;
|
||||
properties = impl->object_properties + instance->dwOfs / sizeof(LONG);
|
||||
|
||||
switch (params->property)
|
||||
{
|
||||
case (DWORD_PTR)DIPROP_RANGE:
|
||||
{
|
||||
const DIPROPRANGE *value = (const DIPROPRANGE *)params->header;
|
||||
properties->range_min = value->lMin;
|
||||
properties->range_max = value->lMax;
|
||||
return DIENUM_CONTINUE;
|
||||
}
|
||||
case (DWORD_PTR)DIPROP_DEADZONE:
|
||||
{
|
||||
const DIPROPDWORD *value = (const DIPROPDWORD *)params->header;
|
||||
properties->deadzone = value->dwData;
|
||||
return DIENUM_CONTINUE;
|
||||
}
|
||||
case (DWORD_PTR)DIPROP_SATURATION:
|
||||
{
|
||||
const DIPROPDWORD *value = (const DIPROPDWORD *)params->header;
|
||||
properties->saturation = value->dwData;
|
||||
return DIENUM_CONTINUE;
|
||||
}
|
||||
}
|
||||
|
||||
return DIENUM_STOP;
|
||||
}
|
||||
|
||||
static BOOL CALLBACK reset_object_value( const DIDEVICEOBJECTINSTANCEW *instance, void *context )
|
||||
|
|
|
@ -45,8 +45,6 @@ struct dinput_device_vtbl
|
|||
LPDIENUMDEVICEOBJECTSCALLBACKW callback, void *context );
|
||||
HRESULT (*get_property)( IDirectInputDevice8W *iface, DWORD property, DIPROPHEADER *header,
|
||||
DIDEVICEOBJECTINSTANCEW *instance );
|
||||
HRESULT (*set_property)( IDirectInputDevice8W *iface, DWORD property, const DIPROPHEADER *header,
|
||||
const DIDEVICEOBJECTINSTANCEW *instance );
|
||||
HRESULT (*get_effect_info)( IDirectInputDevice8W *iface, DIEFFECTINFOW *info, const GUID *guid );
|
||||
HRESULT (*create_effect)( IDirectInputDevice8W *iface, IDirectInputEffect **out );
|
||||
HRESULT (*send_force_feedback_command)( IDirectInputDevice8W *iface, DWORD command, BOOL unacquire );
|
||||
|
|
|
@ -780,22 +780,6 @@ static HRESULT hid_joystick_get_property( IDirectInputDevice8W *iface, DWORD pro
|
|||
return DIERR_UNSUPPORTED;
|
||||
}
|
||||
|
||||
static void set_extra_caps_range( struct hid_joystick *impl, const DIDEVICEOBJECTINSTANCEW *instance,
|
||||
LONG min, LONG max )
|
||||
{
|
||||
struct object_properties *properties = impl->base.object_properties + instance->dwOfs / sizeof(LONG);
|
||||
LONG tmp;
|
||||
|
||||
properties->range_min = min;
|
||||
properties->range_max = max;
|
||||
|
||||
if (instance->dwType & DIDFT_POV)
|
||||
{
|
||||
tmp = properties->logical_max - properties->logical_min;
|
||||
if (tmp > 0) properties->range_max -= max / (tmp + 1);
|
||||
}
|
||||
}
|
||||
|
||||
static HRESULT hid_joystick_send_device_gain( IDirectInputDevice8W *iface, LONG device_gain )
|
||||
{
|
||||
struct hid_joystick *impl = impl_from_IDirectInputDevice8W( iface );
|
||||
|
@ -817,39 +801,6 @@ static HRESULT hid_joystick_send_device_gain( IDirectInputDevice8W *iface, LONG
|
|||
return DI_OK;
|
||||
}
|
||||
|
||||
static HRESULT hid_joystick_set_property( IDirectInputDevice8W *iface, DWORD property,
|
||||
const DIPROPHEADER *header, const DIDEVICEOBJECTINSTANCEW *instance )
|
||||
{
|
||||
struct hid_joystick *impl = impl_from_IDirectInputDevice8W( iface );
|
||||
struct object_properties *properties = NULL;
|
||||
|
||||
if (instance) properties = impl->base.object_properties + instance->dwOfs / sizeof(LONG);
|
||||
|
||||
switch (property)
|
||||
{
|
||||
case (DWORD_PTR)DIPROP_RANGE:
|
||||
{
|
||||
const DIPROPRANGE *value = (const DIPROPRANGE *)header;
|
||||
set_extra_caps_range( impl, instance, value->lMin, value->lMax );
|
||||
return DI_OK;
|
||||
}
|
||||
case (DWORD_PTR)DIPROP_DEADZONE:
|
||||
{
|
||||
const DIPROPDWORD *value = (const DIPROPDWORD *)header;
|
||||
properties->deadzone = value->dwData;
|
||||
return DI_OK;
|
||||
}
|
||||
case (DWORD_PTR)DIPROP_SATURATION:
|
||||
{
|
||||
const DIPROPDWORD *value = (const DIPROPDWORD *)header;
|
||||
properties->saturation = value->dwData;
|
||||
return DI_OK;
|
||||
}
|
||||
}
|
||||
|
||||
return DIERR_UNSUPPORTED;
|
||||
}
|
||||
|
||||
static HRESULT hid_joystick_acquire( IDirectInputDevice8W *iface )
|
||||
{
|
||||
struct hid_joystick *impl = impl_from_IDirectInputDevice8W( iface );
|
||||
|
@ -1301,7 +1252,6 @@ static const struct dinput_device_vtbl hid_joystick_vtbl =
|
|||
hid_joystick_unacquire,
|
||||
hid_joystick_enum_objects,
|
||||
hid_joystick_get_property,
|
||||
hid_joystick_set_property,
|
||||
hid_joystick_get_effect_info,
|
||||
hid_joystick_create_effect,
|
||||
hid_joystick_send_force_feedback_command,
|
||||
|
@ -1561,11 +1511,20 @@ static BOOL init_object_properties( struct hid_joystick *impl, struct hid_value_
|
|||
DIDEVICEOBJECTINSTANCEW *instance, void *data )
|
||||
{
|
||||
struct object_properties *properties = impl->base.object_properties + instance->dwOfs / sizeof(LONG);
|
||||
LONG range_max = (instance->dwType & DIDFT_AXIS) ? 65535 : 36000;
|
||||
LONG tmp;
|
||||
|
||||
properties->bit_size = caps->bit_size;
|
||||
properties->logical_min = caps->logical_min;
|
||||
properties->logical_max = caps->logical_max;
|
||||
set_extra_caps_range( impl, instance, 0, range_max );
|
||||
|
||||
if (instance->dwType & DIDFT_AXIS) properties->range_max = 65535;
|
||||
else
|
||||
{
|
||||
properties->range_max = 36000;
|
||||
tmp = caps->logical_max - caps->logical_min;
|
||||
if (tmp > 0) properties->range_max -= 36000 / (tmp + 1);
|
||||
}
|
||||
|
||||
properties->saturation = 10000;
|
||||
return DIENUM_CONTINUE;
|
||||
}
|
||||
|
|
|
@ -274,12 +274,6 @@ static HRESULT keyboard_get_property( IDirectInputDevice8W *iface, DWORD propert
|
|||
return DIERR_UNSUPPORTED;
|
||||
}
|
||||
|
||||
static HRESULT keyboard_set_property( IDirectInputDevice8W *iface, DWORD property,
|
||||
const DIPROPHEADER *header, const DIDEVICEOBJECTINSTANCEW *instance )
|
||||
{
|
||||
return DIERR_UNSUPPORTED;
|
||||
}
|
||||
|
||||
static const struct dinput_device_vtbl keyboard_vtbl =
|
||||
{
|
||||
NULL,
|
||||
|
@ -289,7 +283,6 @@ static const struct dinput_device_vtbl keyboard_vtbl =
|
|||
keyboard_unacquire,
|
||||
keyboard_enum_objects,
|
||||
keyboard_get_property,
|
||||
keyboard_set_property,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
|
|
|
@ -576,12 +576,6 @@ static HRESULT mouse_get_property( IDirectInputDevice8W *iface, DWORD property,
|
|||
return DIERR_UNSUPPORTED;
|
||||
}
|
||||
|
||||
static HRESULT mouse_set_property( IDirectInputDevice8W *iface, DWORD property,
|
||||
const DIPROPHEADER *header, const DIDEVICEOBJECTINSTANCEW *instance )
|
||||
{
|
||||
return DIERR_UNSUPPORTED;
|
||||
}
|
||||
|
||||
static const struct dinput_device_vtbl mouse_vtbl =
|
||||
{
|
||||
NULL,
|
||||
|
@ -591,7 +585,6 @@ static const struct dinput_device_vtbl mouse_vtbl =
|
|||
mouse_unacquire,
|
||||
mouse_enum_objects,
|
||||
mouse_get_property,
|
||||
mouse_set_property,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
|
|
Loading…
Reference in New Issue