mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-31 13:18:50 +00:00
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
This commit is contained in:
parent
2add956cba
commit
2cb5a1aa56
4 changed files with 10 additions and 11 deletions
|
@ -50,6 +50,7 @@ protected:
|
|||
std::string m_name;
|
||||
direction m_direction;
|
||||
float m_neutral;
|
||||
float m_scale;
|
||||
};
|
||||
|
||||
bool UpdateInput();
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue