Modify keys after a long press

This commit is contained in:
Jules Aguillon 2023-02-12 23:14:57 +01:00
parent 5fac3459aa
commit c46e3b6c61
2 changed files with 20 additions and 3 deletions

View File

@ -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())

View File

@ -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;
}