From c46e3b6c619b6af5825161d4960ea4829a44d429 Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Sun, 12 Feb 2023 23:14:57 +0100 Subject: [PATCH] Modify keys after a long press --- srcs/juloo.keyboard2/KeyModifier.java | 6 ++++++ srcs/juloo.keyboard2/Pointers.java | 17 ++++++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/srcs/juloo.keyboard2/KeyModifier.java b/srcs/juloo.keyboard2/KeyModifier.java index d0beddf..1529835 100644 --- a/srcs/juloo.keyboard2/KeyModifier.java +++ b/srcs/juloo.keyboard2/KeyModifier.java @@ -67,6 +67,12 @@ class KeyModifier } } + /** Modify a key after a long press. */ + public static KeyValue modify_long_press(KeyValue k) + { + return k; + } + private static KeyValue apply_map_char(KeyValue k, Map_char map) { switch (k.getKind()) diff --git a/srcs/juloo.keyboard2/Pointers.java b/srcs/juloo.keyboard2/Pointers.java index ebb6221..acad456 100644 --- a/srcs/juloo.keyboard2/Pointers.java +++ b/srcs/juloo.keyboard2/Pointers.java @@ -369,10 +369,21 @@ public final class Pointers implements Handler.Callback lockPointer(ptr, true); return false; } - // Stop repeating: Latched key, special keys - if (ptr.pointerId == -1 || (ptr.flags & KeyValue.FLAG_SPECIAL) != 0) + // Stop repeating: Latched key, no key + if (ptr.pointerId == -1 || ptr.value == null) return false; - _handler.onPointerHold(ptr.value, ptr.modifiers); + KeyValue kv = KeyModifier.modify_long_press(ptr.value); + if (!kv.equals(ptr.value)) + { + ptr.value = kv; + ptr.flags = kv.getFlags(); + _handler.onPointerDown(true); + return true; + } + // Stop repeating: Special keys + if (kv.hasFlags(KeyValue.FLAG_SPECIAL)) + return false; + _handler.onPointerHold(kv, ptr.modifiers); return true; }