summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControllerInterface/OSX
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface/OSX')
-rw-r--r--Source/Core/InputCommon/ControllerInterface/OSX/OSXJoystick.mm14
1 files changed, 12 insertions, 2 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/OSX/OSXJoystick.mm b/Source/Core/InputCommon/ControllerInterface/OSX/OSXJoystick.mm
index 0c8a199d5d..bc503ec398 100644
--- a/Source/Core/InputCommon/ControllerInterface/OSX/OSXJoystick.mm
+++ b/Source/Core/InputCommon/ControllerInterface/OSX/OSXJoystick.mm
@@ -227,11 +227,21 @@ Joystick::Hat::Hat(IOHIDElementRef element, IOHIDDeviceRef device, direction dir
ControlState Joystick::Hat::GetState() const
{
IOHIDValueRef value;
- int position;
if (IOHIDDeviceGetValue(m_device, m_element, &value) == kIOReturnSuccess)
{
- position = IOHIDValueGetIntegerValue(value);
+ int position = IOHIDValueGetIntegerValue(value);
+ int min = IOHIDElementGetLogicalMin(m_element);
+ int max = IOHIDElementGetLogicalMax(m_element);
+
+ // if the position is outside the min or max, don't register it as a valid button press
+ if (position < min || position > max)
+ {
+ return 0;
+ }
+
+ // normalize the position so that its lowest value is 0
+ position -= min;
switch (position)
{