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:
Soren Jorvang 2011-02-27 00:15:26 +00:00
parent 47efe0fc82
commit c07fb95821
1 changed files with 5 additions and 2 deletions

View File

@ -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)