mirror of
https://github.com/Julow/Unexpected-Keyboard.git
synced 2025-02-22 20:41:10 +01:00
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.
This commit is contained in:
parent
2eb615dbf6
commit
fe35d5fd5a
@ -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]. */
|
||||
|
Loading…
Reference in New Issue
Block a user