abouttreesummaryrefslogcommitdiff
path: root/srcs
diff options
context:
space:
mode:
authorJules Aguillon2022-03-17 11:24:33 +0100
committerJules Aguillon2022-03-17 11:24:33 +0100
commitfe35d5fd5a96d995e0ff434718b7b2b8bcac5ba5 (patch)
tree82208f77cc0abfb4397d75f01846043f08bb9389 /srcs
parent2eb615dbf6b8326c99db175bf7eec2eb13168546 (diff)
downloadunexpected-keyboard-fe35d5fd5a96d995e0ff434718b7b2b8bcac5ba5.tar.gz
unexpected-keyboard-fe35d5fd5a96d995e0ff434718b7b2b8bcac5ba5.zip
Avoid ghost touches while holding modulated keys
On some devices, bogus touch events can be sent while holding a key. With modulated keys, it can happens on top of other keys. Ignore every new pointers when a modulated key is pressed.
Diffstat (limited to 'srcs')
-rw-r--r--srcs/juloo.keyboard2/Pointers.java15
1 files changed, 15 insertions, 0 deletions
diff --git a/srcs/juloo.keyboard2/Pointers.java b/srcs/juloo.keyboard2/Pointers.java
index e6db206..1f0e44c 100644
--- a/srcs/juloo.keyboard2/Pointers.java
+++ b/srcs/juloo.keyboard2/Pointers.java
@@ -107,6 +107,11 @@ public final class Pointers implements Handler.Callback
public void onTouchDown(float x, float y, int pointerId, KeyboardData.Key key)
{
+ // Ignore new presses while a modulated key is active. On some devices,
+ // ghost touch events can happen while the pointer travels on top of other
+ // keys.
+ if (isModulatedKeyPressed())
+ return;
KeyValue value = key.key0;
Pointer ptr = new Pointer(pointerId, key, value, x, y);
_ptrs.add(ptr);
@@ -199,6 +204,16 @@ public final class Pointers implements Handler.Callback
}
}
+ private boolean isModulatedKeyPressed()
+ {
+ for (Pointer ptr : _ptrs)
+ {
+ if ((ptr.flags & KeyValue.FLAG_PRECISE_REPEAT) != 0)
+ return true;
+ }
+ return false;
+ }
+
// Key repeat
/** Message from [_keyrepeat_handler]. */