Fix inverted axis polarity

In the case of axis value being zero, polarity would favor one side of the stick resulting in invalid values. Fix that by taking into account axis history when calculating polarity.
This commit is contained in:
lynxnb 2022-11-03 01:29:59 +01:00 committed by Niccolò Betto
parent 675e8dbb2e
commit f1ec771944

View File

@ -138,7 +138,7 @@ class InputHandler(private val inputManager : InputManager, private val preferen
var value = event.getAxisValue(axis)
if ((event.historySize != 0 && value != event.getHistoricalAxisValue(axis, 0)) || (axesHistory[axisItem.index]?.let { it == value } == false)) {
var polarity = value >= 0
var polarity = value > 0 || (value == 0f && axesHistory[axisItem.index]?.let { it >= 0 } == true)
val guestEvent = MotionHostEvent(event.device.descriptor, axis, polarity).let { hostEvent ->
inputManager.eventMap[hostEvent] ?: if (value == 0f) {