Zebediah Figura : xinput: Use HidP_GetScaledUsageValue().
Alexandre Julliard
julliard at winehq.org
Fri Feb 15 14:37:02 CST 2019
Module: wine
Branch: master
Commit: 681414400eda0bd085217a7d0019d9eac9a5e1f5
URL: https://source.winehq.org/git/wine.git/?a=commit;h=681414400eda0bd085217a7d0019d9eac9a5e1f5
Author: Zebediah Figura <z.figura12 at gmail.com>
Date: Tue Feb 12 00:06:05 2019 -0600
xinput: Use HidP_GetScaledUsageValue().
Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Aric Stewart <aric at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/xinput1_3/hid.c | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/dlls/xinput1_3/hid.c b/dlls/xinput1_3/hid.c
index d7e2248..f276fe3 100644
--- a/dlls/xinput1_3/hid.c
+++ b/dlls/xinput1_3/hid.c
@@ -338,9 +338,8 @@ void HID_destroy_gamepads(xinput_controller *devices)
LeaveCriticalSection(&hid_xinput_crit);
}
-#define SIGN(v,b) ((b==8)?(BYTE)v:(b==16)?(SHORT)v:(INT)v)
-#define SCALE_SHORT(v,r) (SHORT)((((0xffff)*(SIGN(v,r[1]) - r[0]))/r[2])-32767)
-#define SCALE_BYTE(v,r) (BYTE)((((0xff)*(SIGN(v,r[1]) - r[0]))/r[2]))
+#define SCALE_SHORT(v,r) (SHORT)((((0xffff)*(v - r[0]))/r[2])-32767)
+#define SCALE_BYTE(v,r) (BYTE)((((0xff)*(v - r[0]))/r[2]))
void HID_update_state(xinput_controller* device)
{
@@ -351,7 +350,7 @@ void HID_update_state(xinput_controller* device)
USAGE buttons[15];
ULONG button_length;
- ULONG value;
+ LONG value;
if (!private->enabled)
return;
@@ -402,22 +401,22 @@ void HID_update_state(xinput_controller* device)
}
}
- HidP_GetUsageValue(HidP_Input, HID_USAGE_PAGE_GENERIC, 0, HID_USAGE_GENERIC_X, &value, private->ppd, target_report, private->report_length);
+ HidP_GetScaledUsageValue(HidP_Input, HID_USAGE_PAGE_GENERIC, 0, HID_USAGE_GENERIC_X, &value, private->ppd, target_report, private->report_length);
device->state.Gamepad.sThumbLX = SCALE_SHORT(value, private->ThumbLXRange);
- HidP_GetUsageValue(HidP_Input, HID_USAGE_PAGE_GENERIC, 0, HID_USAGE_GENERIC_Y, &value, private->ppd, target_report, private->report_length);
+ HidP_GetScaledUsageValue(HidP_Input, HID_USAGE_PAGE_GENERIC, 0, HID_USAGE_GENERIC_Y, &value, private->ppd, target_report, private->report_length);
device->state.Gamepad.sThumbLY = -SCALE_SHORT(value, private->ThumbLYRange);
- HidP_GetUsageValue(HidP_Input, HID_USAGE_PAGE_GENERIC, 0, HID_USAGE_GENERIC_RX, &value, private->ppd, target_report, private->report_length);
+ HidP_GetScaledUsageValue(HidP_Input, HID_USAGE_PAGE_GENERIC, 0, HID_USAGE_GENERIC_RX, &value, private->ppd, target_report, private->report_length);
device->state.Gamepad.sThumbRX = SCALE_SHORT(value, private->ThumbRXRange);
- HidP_GetUsageValue(HidP_Input, HID_USAGE_PAGE_GENERIC, 0, HID_USAGE_GENERIC_RY, &value, private->ppd, target_report, private->report_length);
+ HidP_GetScaledUsageValue(HidP_Input, HID_USAGE_PAGE_GENERIC, 0, HID_USAGE_GENERIC_RY, &value, private->ppd, target_report, private->report_length);
device->state.Gamepad.sThumbRY = -SCALE_SHORT(value, private->ThumbRYRange);
- HidP_GetUsageValue(HidP_Input, HID_USAGE_PAGE_GENERIC, 0, HID_USAGE_GENERIC_RZ, &value, private->ppd, target_report, private->report_length);
+ HidP_GetScaledUsageValue(HidP_Input, HID_USAGE_PAGE_GENERIC, 0, HID_USAGE_GENERIC_RZ, &value, private->ppd, target_report, private->report_length);
device->state.Gamepad.bRightTrigger = SCALE_BYTE(value, private->RightTriggerRange);
- HidP_GetUsageValue(HidP_Input, HID_USAGE_PAGE_GENERIC, 0, HID_USAGE_GENERIC_Z, &value, private->ppd, target_report, private->report_length);
+ HidP_GetScaledUsageValue(HidP_Input, HID_USAGE_PAGE_GENERIC, 0, HID_USAGE_GENERIC_Z, &value, private->ppd, target_report, private->report_length);
device->state.Gamepad.bLeftTrigger = SCALE_BYTE(value, private->LeftTriggerRange);
LeaveCriticalSection(&private->crit);
}
More information about the wine-cvs
mailing list