Rémi Bernon : dinput: Move SetProperty implementation to the generic device.
Alexandre Julliard
julliard at winehq.org
Thu Nov 18 16:19:38 CST 2021
Module: wine
Branch: master
Commit: 3834eaf9bd44fb692d844041f90b85ec342dadd0
URL: https://source.winehq.org/git/wine.git/?a=commit;h=3834eaf9bd44fb692d844041f90b85ec342dadd0
Author: Rémi Bernon <rbernon at codeweavers.com>
Date: Thu Nov 18 09:53:16 2021 +0100
dinput: Move SetProperty implementation to the generic device.
Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/dinput/device.c | 31 ++++++++++++++++++++--
dlls/dinput/device_private.h | 2 --
dlls/dinput/joystick_hid.c | 63 ++++++++------------------------------------
dlls/dinput/keyboard.c | 7 -----
dlls/dinput/mouse.c | 7 -----
5 files changed, 40 insertions(+), 70 deletions(-)
diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c
index ee47ff60e4f..2367023175c 100644
--- a/dlls/dinput/device.c
+++ b/dlls/dinput/device.c
@@ -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 )
diff --git a/dlls/dinput/device_private.h b/dlls/dinput/device_private.h
index 3e2942f71ef..6d24e66bb54 100644
--- a/dlls/dinput/device_private.h
+++ b/dlls/dinput/device_private.h
@@ -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 );
diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c
index b252b9a13c9..56e4c38c31a 100644
--- a/dlls/dinput/joystick_hid.c
+++ b/dlls/dinput/joystick_hid.c
@@ -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;
}
diff --git a/dlls/dinput/keyboard.c b/dlls/dinput/keyboard.c
index 916a1d43233..2afb744d520 100644
--- a/dlls/dinput/keyboard.c
+++ b/dlls/dinput/keyboard.c
@@ -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,
diff --git a/dlls/dinput/mouse.c b/dlls/dinput/mouse.c
index 313ac070c86..94cca61a0d0 100644
--- a/dlls/dinput/mouse.c
+++ b/dlls/dinput/mouse.c
@@ -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,
More information about the wine-cvs
mailing list