diff options
| author | Jules Aguillon | 2022-04-30 23:36:17 +0200 |
|---|---|---|
| committer | Jules Aguillon | 2022-04-30 23:47:09 +0200 |
| commit | b72635b8875e25dd6da7f42d05aac77468db85a2 (patch) | |
| tree | 259ac0c6ed963da40697892a40fd97ddd2d37088 /srcs/juloo.keyboard2/Pointers.java | |
| parent | 84af72c2229025a451c861ac128ea585cbb72954 (diff) | |
| download | unexpected-keyboard-b72635b8875e25dd6da7f42d05aac77468db85a2.tar.gz unexpected-keyboard-b72635b8875e25dd6da7f42d05aac77468db85a2.zip | |
Fix modifiers not cleared when presses overlap
When typing fast, a second key might be pressed before the first is
released.
Clearing modifiers earlier would prevent this but would break modifiers
placed in corners (especially the accent keys). Instead, don't take
latched modifiers into account when registering the second press.
A new flag is needed to not interfere with holding modifers, which is
merged with the norepeat flag.
Diffstat (limited to 'srcs/juloo.keyboard2/Pointers.java')
| -rw-r--r-- | srcs/juloo.keyboard2/Pointers.java | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/srcs/juloo.keyboard2/Pointers.java b/srcs/juloo.keyboard2/Pointers.java index 6368918..0d0e0fc 100644 --- a/srcs/juloo.keyboard2/Pointers.java +++ b/srcs/juloo.keyboard2/Pointers.java @@ -24,9 +24,18 @@ public final class Pointers implements Handler.Callback public int getFlags() { + return getFlags(false); + } + + /* When [skip_latched] is true, don't take flags of latched keys into account. */ + private int getFlags(boolean skip_latched) + { int flags = 0; for (Pointer p : _ptrs) - flags |= p.flags; + { + if (!(skip_latched && p.pointerId == -1 && (p.flags & KeyValue.FLAG_LOCKED) == 0)) + flags |= p.flags; + } return flags; } @@ -107,6 +116,15 @@ public final class Pointers implements Handler.Callback _handler.onPointerFlagsChanged(); } + /* Whether an other pointer is down on a non-special key. */ + private boolean isOtherPointerDown() + { + for (Pointer p : _ptrs) + if (p.pointerId != -1 && (p.flags & KeyValue.FLAG_SPECIAL) == 0) + return true; + return false; + } + public void onTouchDown(float x, float y, int pointerId, KeyboardData.Key key) { // Ignore new presses while a modulated key is active. On some devices, @@ -114,11 +132,11 @@ public final class Pointers implements Handler.Callback // keys. if (isModulatedKeyPressed()) return; - int mflags = getFlags(); + int mflags = getFlags(isOtherPointerDown()); KeyValue value = _handler.onPointerDown(key.key0, mflags); Pointer ptr = new Pointer(pointerId, key, 0, value, x, y, mflags); _ptrs.add(ptr); - if (value != null && (value.flags & KeyValue.FLAG_NOREPEAT) == 0) + if (value != null && (value.flags & KeyValue.FLAG_SPECIAL) == 0) startKeyRepeat(ptr); } @@ -164,7 +182,7 @@ public final class Pointers implements Handler.Callback if ((old_flags & newValue.flags & KeyValue.FLAG_PRECISE_REPEAT) == 0) { stopKeyRepeat(ptr); - if ((newValue.flags & KeyValue.FLAG_NOREPEAT) == 0) + if ((newValue.flags & KeyValue.FLAG_SPECIAL) == 0) startKeyRepeat(ptr); } } |
