summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/Src/ControllerInterface
diff options
context:
space:
mode:
authorSoren Jorvang <soren.jorvang@gmail.com>2011-01-15 21:16:13 +0000
committerSoren Jorvang <soren.jorvang@gmail.com>2011-01-15 21:16:13 +0000
commit2cb5a1aa565bdc31e50b216d3b7b13e92a16ed98 (patch)
tree4fe257c2222f1621ee7c9942b58a51de282645bb /Source/Core/InputCommon/Src/ControllerInterface
parent2add956cbad2a10ea736cefe21d139822ec94f01 (diff)
HID reports can use negative numbers.
Use UTF-8 for input device names and profile filenames. From8Bit->To8Bit is not transparent. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6857 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/InputCommon/Src/ControllerInterface')
-rw-r--r--Source/Core/InputCommon/Src/ControllerInterface/OSX/OSXJoystick.h1
-rw-r--r--Source/Core/InputCommon/Src/ControllerInterface/OSX/OSXJoystick.mm9
2 files changed, 5 insertions, 5 deletions
diff --git a/Source/Core/InputCommon/Src/ControllerInterface/OSX/OSXJoystick.h b/Source/Core/InputCommon/Src/ControllerInterface/OSX/OSXJoystick.h
index d9270d6994..c9bb7bdfaf 100644
--- a/Source/Core/InputCommon/Src/ControllerInterface/OSX/OSXJoystick.h
+++ b/Source/Core/InputCommon/Src/ControllerInterface/OSX/OSXJoystick.h
@@ -50,6 +50,7 @@ protected:
std::string m_name;
direction m_direction;
float m_neutral;
+ float m_scale;
};
bool UpdateInput();
diff --git a/Source/Core/InputCommon/Src/ControllerInterface/OSX/OSXJoystick.mm b/Source/Core/InputCommon/Src/ControllerInterface/OSX/OSXJoystick.mm
index 9b5f654b32..b3012b6c87 100644
--- a/Source/Core/InputCommon/Src/ControllerInterface/OSX/OSXJoystick.mm
+++ b/Source/Core/InputCommon/Src/ControllerInterface/OSX/OSXJoystick.mm
@@ -173,8 +173,9 @@ Joystick::Axis::Axis(IOHIDElementRef element, direction dir)
m_name = std::string("Axis ") + description;
m_name.append((m_direction == positive) ? "+" : "-");
- m_neutral = (IOHIDElementGetLogicalMax(m_element) -
+ m_neutral = (IOHIDElementGetLogicalMax(m_element) +
IOHIDElementGetLogicalMin(m_element)) / 2.;
+ m_scale = 1 / fabs(IOHIDElementGetLogicalMax(m_element) - m_neutral);
}
ControlState Joystick::Axis::GetState(IOHIDDeviceRef device) const
@@ -185,12 +186,10 @@ ControlState Joystick::Axis::GetState(IOHIDDeviceRef device) const
{
float position = IOHIDValueGetIntegerValue(value);
- //NSLog(@"%s %f %f", m_name.c_str(), m_neutral, position);
-
if (m_direction == positive && position > m_neutral)
- return (position - m_neutral) / m_neutral;
+ return (position - m_neutral) * m_scale;
if (m_direction == negative && position < m_neutral)
- return (m_neutral - position) / m_neutral;
+ return (m_neutral - position) * m_scale;
}
return 0;