diff --git a/app/src/main/java/emu/skyline/input/InputHandler.kt b/app/src/main/java/emu/skyline/input/InputHandler.kt index a25462ea..a2ca4695 100644 --- a/app/src/main/java/emu/skyline/input/InputHandler.kt +++ b/app/src/main/java/emu/skyline/input/InputHandler.kt @@ -117,7 +117,7 @@ class InputHandler(private val inputManager : InputManager, private val preferen /** * The last value of the axes so the stagnant axes can be eliminated to not wastefully look them up */ - private val axesHistory = arrayOfNulls(MotionHostEvent.axes.size) + private val axesHistory = FloatArray(MotionHostEvent.axes.size) /** * Handles translating any [MotionHostEvent]s to a [GuestEvent] that is passed into libskyline @@ -128,8 +128,8 @@ class InputHandler(private val inputManager : InputManager, private val preferen val axis = axisItem.value 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 || (value == 0f && axesHistory[axisItem.index]?.let { it >= 0 } == true) + if ((event.historySize != 0 && value != event.getHistoricalAxisValue(axis, 0)) || axesHistory[axisItem.index] != value) { + var polarity = value > 0 || (value == 0f && axesHistory[axisItem.index] >= 0) val guestEvent = MotionHostEvent(event.device.descriptor, axis, polarity).let { hostEvent -> inputManager.eventMap[hostEvent] ?: if (value == 0f) { diff --git a/app/src/main/java/emu/skyline/input/dialog/ButtonDialog.kt b/app/src/main/java/emu/skyline/input/dialog/ButtonDialog.kt index bd5ca4d4..ca83682b 100644 --- a/app/src/main/java/emu/skyline/input/dialog/ButtonDialog.kt +++ b/app/src/main/java/emu/skyline/input/dialog/ButtonDialog.kt @@ -152,7 +152,7 @@ class ButtonDialog @JvmOverloads constructor(private val item : ControllerButton } val axes = MotionHostEvent.axes - val axesHistory = arrayOfNulls(axes.size) // The last recorded value of an axis, this is used to eliminate any stagnant axes + val axesHistory = FloatArray(axes.size) // The last recorded value of an axis, this is used to eliminate any stagnant axes view.setOnGenericMotionListener { _, event -> // We want all input events from Joysticks and Buttons that are [MotionEvent.ACTION_MOVE] and not from the D-pad @@ -163,7 +163,7 @@ class ButtonDialog @JvmOverloads constructor(private val item : ControllerButton val value = event.getAxisValue(axis) // This checks the history of the axis so we can ignore any stagnant axis - if ((event.historySize == 0 || value == event.getHistoricalAxisValue(axis, 0)) && (axesHistory[axisItem.index]?.let { it == value } != false)) { + if ((event.historySize == 0 || value == event.getHistoricalAxisValue(axis, 0)) && axesHistory[axisItem.index] == value) { axesHistory[axisItem.index] = value continue }