From f1ec77194497348b05adbf01dbe22b3895e4380a Mon Sep 17 00:00:00 2001 From: lynxnb Date: Thu, 3 Nov 2022 01:29:59 +0100 Subject: [PATCH] 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. --- app/src/main/java/emu/skyline/input/InputHandler.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/emu/skyline/input/InputHandler.kt b/app/src/main/java/emu/skyline/input/InputHandler.kt index d759550e..a9e050f1 100644 --- a/app/src/main/java/emu/skyline/input/InputHandler.kt +++ b/app/src/main/java/emu/skyline/input/InputHandler.kt @@ -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) {