diff options
| author | Jules Aguillon | 2024-01-26 00:17:51 +0100 |
|---|---|---|
| committer | Jules Aguillon | 2024-01-26 00:17:51 +0100 |
| commit | c5f2c0b727c0ef70a76e897402e0247f148553fc (patch) | |
| tree | 80cbfd0435cbf29270485dee02fbebc85ec862e0 /srcs/juloo.keyboard2/Keyboard2View.java | |
| parent | fb27f8d36f09e51e1988fb335e3fd9f34acb434e (diff) | |
| download | unexpected-keyboard-c5f2c0b727c0ef70a76e897402e0247f148553fc.tar.gz unexpected-keyboard-c5f2c0b727c0ef70a76e897402e0247f148553fc.zip | |
Send down event for modifiers on time
This allows to use modifiers in combination with other inputs like a
mouse click, for example under termux-x11.
The key down event and notification about modifiers changing are sent
down to KeyEventHandler. A mutable state remember for which modifier
down events have been sent.
When pressing down a modifier with one finger and typing with the
other, it might appear that the modifier is released after the first
time an other key is pressed and then pressed and released for the
following keys.
This prevents unintentionally type two modified keys instead of one
when the second key is pressed while the other is not yet released.
Diffstat (limited to 'srcs/juloo.keyboard2/Keyboard2View.java')
| -rw-r--r-- | srcs/juloo.keyboard2/Keyboard2View.java | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/srcs/juloo.keyboard2/Keyboard2View.java b/srcs/juloo.keyboard2/Keyboard2View.java index f9712e1..a4cfeb0 100644 --- a/srcs/juloo.keyboard2/Keyboard2View.java +++ b/srcs/juloo.keyboard2/Keyboard2View.java @@ -125,7 +125,6 @@ public class Keyboard2View extends View return; // Don't remove locked pointers _pointers.remove_fake_pointer(_shift_kv, _shift_key); } - invalidate(); } public KeyValue modifyKey(KeyValue k, Pointers.Modifiers mods) @@ -144,6 +143,7 @@ public class Keyboard2View extends View public void onPointerDown(KeyValue k, boolean isSwipe) { + updateFlags(); _config.handler.key_down(k, isSwipe); invalidate(); vibrate(); @@ -151,17 +151,22 @@ public class Keyboard2View extends View public void onPointerUp(KeyValue k, Pointers.Modifiers mods) { + // [key_up] must be called before [updateFlags]. The latter might disable + // flags. _config.handler.key_up(k, mods); + updateFlags(); invalidate(); } public void onPointerHold(KeyValue k, Pointers.Modifiers mods) { _config.handler.key_up(k, mods); + updateFlags(); } public void onPointerFlagsChanged(boolean shouldVibrate) { + updateFlags(); invalidate(); if (shouldVibrate) vibrate(); @@ -170,6 +175,7 @@ public class Keyboard2View extends View private void updateFlags() { _mods = _pointers.getModifiers(); + _config.handler.mods_changed(_mods); } @Override @@ -287,7 +293,6 @@ public class Keyboard2View extends View @Override protected void onDraw(Canvas canvas) { - updateFlags(); // Set keyboard background opacity getBackground().setAlpha(_config.keyboardOpacity); // Set keys opacity |
