diff options
| author | Scott Pleb <scottpleb@comfy.love> | 2017-11-11 00:58:07 -0500 |
|---|---|---|
| committer | Scott Pleb <scottpleb@comfy.love> | 2017-11-11 02:07:04 -0500 |
| commit | 0bede93daa932c053715fc6ad69674ae6b6f8a8d (patch) | |
| tree | 728cbfb95a36caf654471295b09a2e2b8eb75813 /Source/Core/InputCommon/ControllerInterface | |
| parent | 6161bda1dd668c6feee1ce4cbc6d158f598dd073 (diff) | |
evdev: Correctly calculate axis range for min values greater than 0.
Axis range was previously calculated as max + abs(min), which relies on the assumption that
min will not exceed 0. For (min, max) values like (0, 255) or (-128, 127), which I assume to
be the most common cases, the range is correctly calculated as 255. However, given (20,
235), the range is erroneously calculated as 255, leading to axis values being normalized
incorrectly.
SDL already handles this case correctly. After changing the range calculation to max - min,
the axis values received from the evdev backend are practically identical to the values
received from the SDL backend.
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface')
| -rw-r--r-- | Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp index 6d9b7c1091..c7c97ebd0e 100644 --- a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp +++ b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp @@ -313,7 +313,7 @@ evdevDevice::Axis::Axis(u8 index, u16 code, bool upper, libevdev* dev) : m_code(code), m_index(index), m_upper(upper), m_dev(dev) { m_min = libevdev_get_abs_minimum(m_dev, m_code); - m_range = libevdev_get_abs_maximum(m_dev, m_code) + abs(m_min); + m_range = libevdev_get_abs_maximum(m_dev, m_code) - m_min; } std::string evdevDevice::Axis::GetName() const |
