From c07fb95821ddf45c17b09819d0b738955a9dd0b3 Mon Sep 17 00:00:00 2001 From: Soren Jorvang Date: Sun, 27 Feb 2011 00:15:26 +0000 Subject: [PATCH] PS3 controllers have some input elements with very large value fields that cause IOHIDValueGetIntegerValue() to smash the stack when trying to convert them. In practice, all relevant axes seem to also be available as either 8 or 16-bit values, so just ignore anything that doesn't look like that (or a button). Fixes issue 3931. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7255 8ced0084-cf51-0410-be5f-012b33b47a6e --- .../InputCommon/Src/ControllerInterface/OSX/OSXJoystick.mm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Source/Core/InputCommon/Src/ControllerInterface/OSX/OSXJoystick.mm b/Source/Core/InputCommon/Src/ControllerInterface/OSX/OSXJoystick.mm index 418e4f4ef0..56ca3e55a6 100644 --- a/Source/Core/InputCommon/Src/ControllerInterface/OSX/OSXJoystick.mm +++ b/Source/Core/InputCommon/Src/ControllerInterface/OSX/OSXJoystick.mm @@ -75,8 +75,6 @@ Joystick::Joystick(IOHIDDeviceRef device, std::string name, int index) ControlState Joystick::GetInputState( const ControllerInterface::Device::Input* const input) const { - if (input == NULL) // XXX - return 0; return ((Input*)input)->GetState(m_device); } @@ -182,6 +180,11 @@ ControlState Joystick::Axis::GetState(IOHIDDeviceRef device) const if (IOHIDDeviceGetValue(device, m_element, &value) == kIOReturnSuccess) { + // IOHIDValueGetIntegerValue() crashes when trying + // to convert unusually large element values. + if (IOHIDValueGetLength(value) > 2) + return 0; + float position = IOHIDValueGetIntegerValue(value); if (m_direction == positive && position > m_neutral)