mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-11-10 19:05:08 +01:00
Account for stick flat area when retrieving axes value from a MotionEvent
This commit is contained in:
parent
c966220bab
commit
b209ae8e90
@ -126,7 +126,17 @@ class InputHandler(private val inputManager : InputManager, private val preferen
|
||||
if ((event.isFromSource(InputDevice.SOURCE_CLASS_JOYSTICK) || event.isFromSource(InputDevice.SOURCE_CLASS_BUTTON)) && event.action == MotionEvent.ACTION_MOVE) {
|
||||
for (axisItem in MotionHostEvent.axes.withIndex()) {
|
||||
val axis = axisItem.value
|
||||
val range : InputDevice.MotionRange? = event.device.getMotionRange(axis, event.source)
|
||||
var value = event.getAxisValue(axis)
|
||||
range?.let {
|
||||
value = if (abs(value) > it.flat)
|
||||
if (value > 0)
|
||||
(value - it.flat) / (it.max - it.flat)
|
||||
else
|
||||
-((abs(value) - it.flat) / (abs(it.min) - it.flat))
|
||||
else
|
||||
0f
|
||||
}
|
||||
|
||||
if ((event.historySize != 0 && value != event.getHistoricalAxisValue(axis, 0)) || axesHistory[axisItem.index] != value) {
|
||||
var polarity = value > 0 || (value == 0f && axesHistory[axisItem.index] >= 0)
|
||||
|
Loading…
Reference in New Issue
Block a user