From bbeae9a0f3f03fcd415165ee4056f04909908321 Mon Sep 17 00:00:00 2001 From: Valter Costa Date: Wed, 12 Oct 2022 22:47:05 +0100 Subject: [PATCH] Fix hold repeat key (#22) --- .../main/java/com/valterc/ki2/input/InputManager.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/valterc/ki2/input/InputManager.java b/app/src/main/java/com/valterc/ki2/input/InputManager.java index f90cc7ea..95d2d762 100644 --- a/app/src/main/java/com/valterc/ki2/input/InputManager.java +++ b/app/src/main/java/com/valterc/ki2/input/InputManager.java @@ -72,6 +72,7 @@ private SwitchKeyEvent convertSwitchToSwitchKey(SwitchEvent switchEvent) { if (karooCommand.first == null) { Pair newKarooCommand = getKarooCommand(switchEvent.getType(), karooCommand.second); + if (newKarooCommand == null) { Timber.w("Unable to retranslate command, original: {switch=%s, command=%s}, target: {switch=%s, command=%s}", switchEvent.getType(), @@ -81,6 +82,11 @@ private SwitchKeyEvent convertSwitchToSwitchKey(SwitchEvent switchEvent) { return null; } + if (switchEvent.getCommand() == SwitchCommand.LONG_PRESS_UP && newKarooCommand.second != SwitchCommandType.HOLD){ + // Avoid repeating key press on LONG_PRESS_UP + return null; + } + karooCommand = newKarooCommand; } @@ -113,9 +119,8 @@ private SwitchKeyEvent getSwitchKeyEvent(SwitchEvent switchEvent, Pair