diff options
| author | Jules Aguillon | 2022-07-24 20:02:48 +0200 |
|---|---|---|
| committer | Jules Aguillon | 2022-07-24 20:02:48 +0200 |
| commit | 324756535e139aacfb9d828a5bc9a2a6fef634ea (patch) | |
| tree | 717553aab3e9bd5a0536aa8b2e2a3a69d5e335ca /srcs/juloo.keyboard2/Pointers.java | |
| parent | 2d8ed2d85849c95c7d39e0dfe11405bf70eeb395 (diff) | |
| download | unexpected-keyboard-324756535e139aacfb9d828a5bc9a2a6fef634ea.tar.gz unexpected-keyboard-324756535e139aacfb9d828a5bc9a2a6fef634ea.zip | |
Automatic capitalisation at beginning of sentences
Keep track of end-of-sentence characters while typing and automatically
enable shift when appropriate.
The last few characters just before the cursor need to be queried in
some cases: Begin of input, cursor has moved or text is deleted.
This might have a performance cost.
This normally only enable shift but it also needs to disable shift when
the cursor moves.
Diffstat (limited to 'srcs/juloo.keyboard2/Pointers.java')
| -rw-r--r-- | srcs/juloo.keyboard2/Pointers.java | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/srcs/juloo.keyboard2/Pointers.java b/srcs/juloo.keyboard2/Pointers.java index 9b8ee97..84323ae 100644 --- a/srcs/juloo.keyboard2/Pointers.java +++ b/srcs/juloo.keyboard2/Pointers.java @@ -74,6 +74,24 @@ public final class Pointers implements Handler.Callback return -1; } + /** Fake pointers are latched and not lockable. */ + public void add_fake_pointer(KeyValue kv, KeyboardData.Key key) + { + // Avoid adding a fake pointer to a key that is already down. + if (isKeyDown(key)) + return; + Pointer ptr = new Pointer(-1, key, kv, 0.f, 0.f, Modifiers.EMPTY); + ptr.flags = ptr.flags & ~(KeyValue.FLAG_LATCH | KeyValue.FLAG_LOCK); + _ptrs.add(ptr); + } + + public void remove_fake_pointer(KeyValue kv, KeyboardData.Key key) + { + Pointer ptr = getLatched(key, kv); + if (ptr != null) + removePtr(ptr); + } + // Receiving events public void onTouchUp(int pointerId) @@ -252,8 +270,11 @@ public final class Pointers implements Handler.Callback private Pointer getLatched(Pointer target) { - KeyboardData.Key k = target.key; - KeyValue v = target.value; + return getLatched(target.key, target.value); + } + + private Pointer getLatched(KeyboardData.Key k, KeyValue v) + { if (v == null) return null; for (Pointer p : _ptrs) |
