From 324756535e139aacfb9d828a5bc9a2a6fef634ea Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Sun, 24 Jul 2022 20:02:48 +0200 Subject: 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. --- srcs/juloo.keyboard2/Pointers.java | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'srcs/juloo.keyboard2/Pointers.java') 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) -- cgit v1.2.3