Commit c5283300 authored by Aric Stewart's avatar Aric Stewart Committed by Alexandre Julliard

dinput: Handle case where IOHIDDeviceGetValue fails.

This prevents crashes if a controller disconnects from OS/X. Signed-off-by: 's avatarAric Stewart <aric@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 620da60f
...@@ -801,7 +801,11 @@ static void poll_osx_device_state(LPDIRECTINPUTDEVICE8A iface) ...@@ -801,7 +801,11 @@ static void poll_osx_device_state(LPDIRECTINPUTDEVICE8A iface)
TRACE("kIOHIDElementTypeInput_Button\n"); TRACE("kIOHIDElementTypeInput_Button\n");
if(button_idx < 128) 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); val = IOHIDValueGetIntegerValue(valueRef);
newVal = val ? 0x80 : 0x0; newVal = val ? 0x80 : 0x0;
oldVal = device->generic.js.rgbButtons[button_idx]; oldVal = device->generic.js.rgbButtons[button_idx];
...@@ -823,7 +827,11 @@ static void poll_osx_device_state(LPDIRECTINPUTDEVICE8A iface) ...@@ -823,7 +827,11 @@ static void poll_osx_device_state(LPDIRECTINPUTDEVICE8A iface)
case kHIDUsage_GD_Hatswitch: case kHIDUsage_GD_Hatswitch:
{ {
TRACE("kIOHIDElementTypeInput_Misc / kHIDUsage_GD_Hatswitch\n"); 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); val = IOHIDValueGetIntegerValue(valueRef);
oldVal = device->generic.js.rgdwPOV[pov_idx]; oldVal = device->generic.js.rgdwPOV[pov_idx];
if (val >= 8) if (val >= 8)
...@@ -850,7 +858,11 @@ static void poll_osx_device_state(LPDIRECTINPUTDEVICE8A iface) ...@@ -850,7 +858,11 @@ static void poll_osx_device_state(LPDIRECTINPUTDEVICE8A iface)
{ {
int wine_obj = -1; 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); val = IOHIDValueGetIntegerValue(valueRef);
newVal = joystick_map_axis(&device->generic.props[idx], val); newVal = joystick_map_axis(&device->generic.props[idx], val);
switch (usage) switch (usage)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment