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
This commit is contained in:
parent
47efe0fc82
commit
c07fb95821
|
@ -75,8 +75,6 @@ Joystick::Joystick(IOHIDDeviceRef device, std::string name, int index)
|
||||||
ControlState Joystick::GetInputState(
|
ControlState Joystick::GetInputState(
|
||||||
const ControllerInterface::Device::Input* const input) const
|
const ControllerInterface::Device::Input* const input) const
|
||||||
{
|
{
|
||||||
if (input == NULL) // XXX
|
|
||||||
return 0;
|
|
||||||
return ((Input*)input)->GetState(m_device);
|
return ((Input*)input)->GetState(m_device);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,6 +180,11 @@ ControlState Joystick::Axis::GetState(IOHIDDeviceRef device) const
|
||||||
|
|
||||||
if (IOHIDDeviceGetValue(device, m_element, &value) == kIOReturnSuccess)
|
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);
|
float position = IOHIDValueGetIntegerValue(value);
|
||||||
|
|
||||||
if (m_direction == positive && position > m_neutral)
|
if (m_direction == positive && position > m_neutral)
|
||||||
|
|
Loading…
Reference in New Issue