diff --git a/src/main/java/de/bwravencl/controllerbuddy/input/action/ButtonToCycleAction.java b/src/main/java/de/bwravencl/controllerbuddy/input/action/ButtonToCycleAction.java index 4dacf1af..9eabc5b2 100644 --- a/src/main/java/de/bwravencl/controllerbuddy/input/action/ButtonToCycleAction.java +++ b/src/main/java/de/bwravencl/controllerbuddy/input/action/ButtonToCycleAction.java @@ -31,7 +31,7 @@ @Action(label = "BUTTON_TO_CYCLE_ACTION", category = ActionCategory.BUTTON, order = 140) public final class ButtonToCycleAction extends DescribableAction - implements IButtonToAction, IResetableAction, IActivatableAction { + implements IActivatableAction, IButtonToAction, IResetableAction { private transient Activatable activatable = Activatable.YES; diff --git a/src/main/java/de/bwravencl/controllerbuddy/input/action/ButtonToModeAction.java b/src/main/java/de/bwravencl/controllerbuddy/input/action/ButtonToModeAction.java index adeec404..7bf07007 100644 --- a/src/main/java/de/bwravencl/controllerbuddy/input/action/ButtonToModeAction.java +++ b/src/main/java/de/bwravencl/controllerbuddy/input/action/ButtonToModeAction.java @@ -33,7 +33,7 @@ import org.lwjgl.glfw.GLFW; @Action(label = "BUTTON_TO_MODE_ACTION", category = ActionCategory.BUTTON, order = 145) -public final class ButtonToModeAction implements IButtonToAction, IResetableAction { +public final class ButtonToModeAction implements IButtonToAction, IResetableAction { private static final LinkedList buttonToModeActionStack = new LinkedList<>(); diff --git a/src/main/java/de/bwravencl/controllerbuddy/input/action/ButtonToSelectOnScreenKeyboardKeyAction.java b/src/main/java/de/bwravencl/controllerbuddy/input/action/ButtonToSelectOnScreenKeyboardKeyAction.java index ffadc70a..5a966ef5 100644 --- a/src/main/java/de/bwravencl/controllerbuddy/input/action/ButtonToSelectOnScreenKeyboardKeyAction.java +++ b/src/main/java/de/bwravencl/controllerbuddy/input/action/ButtonToSelectOnScreenKeyboardKeyAction.java @@ -30,7 +30,7 @@ label = "BUTTON_TO_SELECT_ON_SCREEN_KEYBOARD_KEY_ACTION", category = ActionCategory.ON_SCREEN_KEYBOARD_MODE, order = 510) -public final class ButtonToSelectOnScreenKeyboardKeyAction implements IButtonToAction, IResetableAction { +public final class ButtonToSelectOnScreenKeyboardKeyAction implements IButtonToAction, IResetableAction { private static final long INITIAL_MIN_ELAPSE_TIME = 250L; private static final long PEAK_MIN_ELAPSE_TIME = 90L; diff --git a/src/main/java/de/bwravencl/controllerbuddy/input/action/IResetableAction.java b/src/main/java/de/bwravencl/controllerbuddy/input/action/IResetableAction.java index e8bede34..bc139306 100644 --- a/src/main/java/de/bwravencl/controllerbuddy/input/action/IResetableAction.java +++ b/src/main/java/de/bwravencl/controllerbuddy/input/action/IResetableAction.java @@ -18,7 +18,7 @@ import de.bwravencl.controllerbuddy.input.Input; -public interface IResetableAction extends IAction { +public interface IResetableAction extends IAction { void reset(final Input input); } diff --git a/src/main/java/de/bwravencl/controllerbuddy/input/action/ToKeyAction.java b/src/main/java/de/bwravencl/controllerbuddy/input/action/ToKeyAction.java index 64530520..ca114b47 100644 --- a/src/main/java/de/bwravencl/controllerbuddy/input/action/ToKeyAction.java +++ b/src/main/java/de/bwravencl/controllerbuddy/input/action/ToKeyAction.java @@ -26,7 +26,7 @@ import java.text.MessageFormat; public abstract class ToKeyAction extends DescribableAction - implements IActivatableAction, ILongPressAction { + implements IActivatableAction, ILongPressAction, IResetableAction { @ActionProperty(label = "ACTIVATION", editorBuilder = ActivationEditorBuilder.class, order = 11) private Activation activation = Activation.REPEAT; @@ -39,6 +39,8 @@ public abstract class ToKeyAction extends DescribableAction private transient Activatable activatable; + private transient boolean wasDown; + @Override public Object clone() throws CloneNotSupportedException { final var toKeyAction = (ToKeyAction) super.clone(); @@ -77,8 +79,15 @@ void handleAction(final boolean hot, final Input input) { switch (activation) { case REPEAT -> { final var downKeyStrokes = input.getDownKeyStrokes(); - if (!hot) downKeyStrokes.remove(keystroke); - else downKeyStrokes.add(keystroke); + if (!hot) { + if (wasDown) { + downKeyStrokes.remove(keystroke); + wasDown = false; + } + } else { + downKeyStrokes.add(keystroke); + wasDown = true; + } } case SINGLE_IMMEDIATELY -> { if (!hot) activatable = Activatable.YES; @@ -104,6 +113,11 @@ public boolean isLongPress() { return longPress; } + @Override + public void reset(final Input input) { + wasDown = false; + } + @Override public void setActivatable(final Activatable activatable) { this.activatable = activatable;