diff options
| author | Jules Aguillon | 2022-05-08 16:53:33 +0200 |
|---|---|---|
| committer | Jules Aguillon | 2022-05-08 16:55:03 +0200 |
| commit | 82d3290c6a12caa1cc4f3a5929e5466074c4e3ba (patch) | |
| tree | baf7e09fa8e992bf6dca883b186757f82ca5b349 /srcs | |
| parent | b15ca662c2329fd638cbf74b097988c1be477cc8 (diff) | |
| download | unexpected-keyboard-82d3290c6a12caa1cc4f3a5929e5466074c4e3ba.tar.gz unexpected-keyboard-82d3290c6a12caa1cc4f3a5929e5466074c4e3ba.zip | |
Fix vibration when pointer move slightly
Fix the bug introduced in the parent commit.
Diffstat (limited to 'srcs')
| -rw-r--r-- | srcs/juloo.keyboard2/Keyboard2View.java | 19 | ||||
| -rw-r--r-- | srcs/juloo.keyboard2/Pointers.java | 22 |
2 files changed, 17 insertions, 24 deletions
diff --git a/srcs/juloo.keyboard2/Keyboard2View.java b/srcs/juloo.keyboard2/Keyboard2View.java index 3ae0fdf..c0743bc 100644 --- a/srcs/juloo.keyboard2/Keyboard2View.java +++ b/srcs/juloo.keyboard2/Keyboard2View.java @@ -96,24 +96,15 @@ public class Keyboard2View extends View invalidate(); } - public KeyValue onPointerDown(KeyValue k, int flags) + public KeyValue modifyKey(KeyValue k, int flags) { - k = KeyModifier.handleFlags(k, flags); - invalidate(); - if (k != null) - vibrate(); - return k; + return KeyModifier.handleFlags(k, flags); } - public KeyValue onPointerSwipe(KeyValue k, int flags) + public void onPointerDown(boolean isSwipe) { - k = KeyModifier.handleFlags(k, flags); - if (k != null) - { - invalidate(); - vibrate(); - } - return k; + invalidate(); + vibrate(); } public void onPointerUp(KeyValue k, int flags) diff --git a/srcs/juloo.keyboard2/Pointers.java b/srcs/juloo.keyboard2/Pointers.java index b4c1a6f..866c36a 100644 --- a/srcs/juloo.keyboard2/Pointers.java +++ b/srcs/juloo.keyboard2/Pointers.java @@ -134,11 +134,12 @@ public final class Pointers implements Handler.Callback if (isModulatedKeyPressed()) return; int mflags = getFlags(isOtherPointerDown()); - KeyValue value = _handler.onPointerDown(key.key0, mflags); + KeyValue value = _handler.modifyKey(key.key0, mflags); Pointer ptr = new Pointer(pointerId, key, value, x, y, mflags); _ptrs.add(ptr); if (value != null && (value.flags & KeyValue.FLAG_SPECIAL) == 0) startKeyRepeat(ptr); + _handler.onPointerDown(false); } /* @@ -152,14 +153,14 @@ public final class Pointers implements Handler.Callback private KeyValue getKeyAtDirection(Pointer ptr, int direction) { if (direction == 0) - return _handler.onPointerSwipe(ptr.key.key0, ptr.modifier_flags); + return _handler.modifyKey(ptr.key.key0, ptr.modifier_flags); KeyValue k; for (int i = 0; i > -2; i = (~i>>31) - i) { int d = Math.floorMod(direction + i - 1, 8) + 1; // Don't make the difference between a key that doesn't exist and a key // that is removed by [_handler]. Triggers side effects. - k = _handler.onPointerSwipe(ptr.key.getAtDirection(d), ptr.modifier_flags); + k = _handler.modifyKey(ptr.key.getAtDirection(d), ptr.modifier_flags); if (k != null) return k; } @@ -216,6 +217,7 @@ public final class Pointers implements Handler.Callback if ((newValue.flags & KeyValue.FLAG_SPECIAL) == 0) startKeyRepeat(ptr); } + _handler.onPointerDown(true); } } } @@ -372,15 +374,15 @@ public final class Pointers implements Handler.Callback public interface IPointerEventHandler { - /** A key is pressed. Key can be modified or removed by returning [null]. - [getFlags()] is not uptodate. */ - public KeyValue onPointerDown(KeyValue k, int flags); + /** Key can be modified or removed by returning [null]. */ + public KeyValue modifyKey(KeyValue k, int flags); - /** Pointer swipes into a corner. Key can be modified or removed. */ - public KeyValue onPointerSwipe(KeyValue k, int flags); + /** A key is pressed. [getFlags()] is uptodate. Might be called after a + press or a swipe to a different value. */ + public void onPointerDown(boolean isSwipe); - /** Key is released. [k] is the key that was returned by [onPointerDown] or - [onPointerSwipe]. */ + /** Key is released. [k] is the key that was returned by + [modifySelectedKey] or [modifySelectedKey]. */ public void onPointerUp(KeyValue k, int flags); /** Flags changed because latched or locked keys or cancelled pointers. */ |
