Ivo Ivanov : dinput: Introduce a new set_parameter_value_angle helper.
Alexandre Julliard
julliard at winehq.org
Fri Nov 19 15:45:31 CST 2021
Module: wine
Branch: master
Commit: b8931fdce2eff4df4b6ccb85cf3ca2b80d063236
URL: https://source.winehq.org/git/wine.git/?a=commit;h=b8931fdce2eff4df4b6ccb85cf3ca2b80d063236
Author: Ivo Ivanov <logos128 at gmail.com>
Date: Fri Nov 19 09:39:40 2021 +0100
dinput: Introduce a new set_parameter_value_angle helper.
To correctly scale angle values and warn about unexpected units.
Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/dinput/joystick_hid.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c
index 11ba9867623..fb83d173bda 100644
--- a/dlls/dinput/joystick_hid.c
+++ b/dlls/dinput/joystick_hid.c
@@ -2596,6 +2596,18 @@ static void set_parameter_value( struct hid_joystick_effect *impl, char *report_
return set_report_value( impl->joystick, report_buf, caps, value );
}
+static void set_parameter_value_angle( struct hid_joystick_effect *impl, char *report_buf,
+ struct hid_value_caps *caps, LONG value )
+{
+ LONG exp;
+ if (!caps) return;
+ exp = caps->units_exp;
+ if (caps->units != 0x14) WARN( "unknown angle unit caps %x\n", caps->units );
+ else if (exp < -2) while (exp++ < -2) value *= 10;
+ else if (exp > -2) while (exp-- > -2) value /= 10;
+ set_parameter_value( impl, report_buf, caps, value );
+}
+
static void set_parameter_value_us( struct hid_joystick_effect *impl, char *report_buf,
struct hid_value_caps *caps, LONG value )
{
@@ -2766,7 +2778,7 @@ static HRESULT WINAPI hid_joystick_effect_Download( IDirectInputEffect *iface )
{
tmp = directions[i] + (i == 0 ? 9000 : 0);
caps = effect_update->direction_caps[effect_update->direction_count - i - 1];
- set_parameter_value( impl, impl->effect_update_buf, caps, tmp % 36000 );
+ set_parameter_value_angle( impl, impl->effect_update_buf, caps, tmp % 36000 );
}
status = HidP_SetUsageValue( HidP_Output, HID_USAGE_PAGE_PID, 0, PID_USAGE_TRIGGER_BUTTON,
More information about the wine-cvs
mailing list