Aric Stewart : dinput: Handle case where IOHIDDeviceGetValue fails.
Alexandre Julliard
julliard at winehq.org
Tue Jun 4 16:28:13 CDT 2019
Module: wine
Branch: master
Commit: c5283300e10b289293203a02f765cf757e3e910e
URL: https://source.winehq.org/git/wine.git/?a=commit;h=c5283300e10b289293203a02f765cf757e3e910e
Author: Aric Stewart <aric at codeweavers.com>
Date: Tue Jun 4 07:47:35 2019 -0500
dinput: Handle case where IOHIDDeviceGetValue fails.
This prevents crashes if a controller disconnects from OS/X.
Signed-off-by: Aric Stewart <aric at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/dinput/joystick_osx.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/dlls/dinput/joystick_osx.c b/dlls/dinput/joystick_osx.c
index 540d16b..ba3d56d 100644
--- a/dlls/dinput/joystick_osx.c
+++ b/dlls/dinput/joystick_osx.c
@@ -801,7 +801,11 @@ static void poll_osx_device_state(LPDIRECTINPUTDEVICE8A iface)
TRACE("kIOHIDElementTypeInput_Button\n");
if(button_idx < 128)
{
- IOHIDDeviceGetValue(hid_device, element, &valueRef);
+ valueRef = NULL;
+ if (IOHIDDeviceGetValue(hid_device, element, &valueRef) != kIOReturnSuccess)
+ return;
+ if (valueRef == NULL)
+ return;
val = IOHIDValueGetIntegerValue(valueRef);
newVal = val ? 0x80 : 0x0;
oldVal = device->generic.js.rgbButtons[button_idx];
@@ -823,7 +827,11 @@ static void poll_osx_device_state(LPDIRECTINPUTDEVICE8A iface)
case kHIDUsage_GD_Hatswitch:
{
TRACE("kIOHIDElementTypeInput_Misc / kHIDUsage_GD_Hatswitch\n");
- IOHIDDeviceGetValue(hid_device, element, &valueRef);
+ valueRef = NULL;
+ if (IOHIDDeviceGetValue(hid_device, element, &valueRef) != kIOReturnSuccess)
+ return;
+ if (valueRef == NULL)
+ return;
val = IOHIDValueGetIntegerValue(valueRef);
oldVal = device->generic.js.rgdwPOV[pov_idx];
if (val >= 8)
@@ -850,7 +858,11 @@ static void poll_osx_device_state(LPDIRECTINPUTDEVICE8A iface)
{
int wine_obj = -1;
- IOHIDDeviceGetValue(hid_device, element, &valueRef);
+ valueRef = NULL;
+ if (IOHIDDeviceGetValue(hid_device, element, &valueRef) != kIOReturnSuccess)
+ return;
+ if (valueRef == NULL)
+ return;
val = IOHIDValueGetIntegerValue(valueRef);
newVal = joystick_map_axis(&device->generic.props[idx], val);
switch (usage)
More information about the wine-cvs
mailing list