Alistair Leslie-Hughes : xinput: Check that we actually received a value before assignment.
Alexandre Julliard
julliard at winehq.org
Wed Apr 24 16:33:29 CDT 2019
Module: wine
Branch: master
Commit: 72e62952db9104b03d136d9fa0ebdb1e8aa6ae52
URL: https://source.winehq.org/git/wine.git/?a=commit;h=72e62952db9104b03d136d9fa0ebdb1e8aa6ae52
Author: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Date: Wed Apr 24 00:58:15 2019 +0000
xinput: Check that we actually received a value before assignment.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=46999
Signed-off-by: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/xinput1_3/hid.c | 30 ++++++++++++++++++------------
1 file changed, 18 insertions(+), 12 deletions(-)
diff --git a/dlls/xinput1_3/hid.c b/dlls/xinput1_3/hid.c
index c0c405f..1ccecb1 100644
--- a/dlls/xinput1_3/hid.c
+++ b/dlls/xinput1_3/hid.c
@@ -388,23 +388,29 @@ void HID_update_state(xinput_controller* device)
}
}
- 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->lx);
+ if(HidP_GetScaledUsageValue(HidP_Input, HID_USAGE_PAGE_GENERIC, 0, HID_USAGE_GENERIC_X, &value,
+ private->ppd, target_report, private->report_length) == HIDP_STATUS_SUCCESS)
+ device->state.Gamepad.sThumbLX = scale_short(value, &private->lx);
- 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->ly) - 1;
+ if(HidP_GetScaledUsageValue(HidP_Input, HID_USAGE_PAGE_GENERIC, 0, HID_USAGE_GENERIC_Y, &value,
+ private->ppd, target_report, private->report_length) == HIDP_STATUS_SUCCESS)
+ device->state.Gamepad.sThumbLY = -scale_short(value, &private->ly) - 1;
- 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->rx);
+ if(HidP_GetScaledUsageValue(HidP_Input, HID_USAGE_PAGE_GENERIC, 0, HID_USAGE_GENERIC_RX, &value,
+ private->ppd, target_report, private->report_length) == HIDP_STATUS_SUCCESS)
+ device->state.Gamepad.sThumbRX = scale_short(value, &private->rx);
- 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->ry) - 1;
+ if(HidP_GetScaledUsageValue(HidP_Input, HID_USAGE_PAGE_GENERIC, 0, HID_USAGE_GENERIC_RY, &value,
+ private->ppd, target_report, private->report_length) == HIDP_STATUS_SUCCESS)
+ device->state.Gamepad.sThumbRY = -scale_short(value, &private->ry) - 1;
- 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->rtrigger);
+ if(HidP_GetScaledUsageValue(HidP_Input, HID_USAGE_PAGE_GENERIC, 0, HID_USAGE_GENERIC_RZ, &value,
+ private->ppd, target_report, private->report_length) == HIDP_STATUS_SUCCESS)
+ device->state.Gamepad.bRightTrigger = scale_byte(value, &private->rtrigger);
- 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->ltrigger);
+ if(HidP_GetScaledUsageValue(HidP_Input, HID_USAGE_PAGE_GENERIC, 0, HID_USAGE_GENERIC_Z, &value,
+ private->ppd, target_report, private->report_length) == HIDP_STATUS_SUCCESS)
+ device->state.Gamepad.bLeftTrigger = scale_byte(value, &private->ltrigger);
LeaveCriticalSection(&private->crit);
}
More information about the wine-cvs
mailing list