From 0f11a884185b832496fa5374ff03cfe61b91f9fb Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Thu, 2 May 2024 19:31:48 +0200 Subject: More precise and faster spacebar slider (#593) * Make slider speed independent from swipe distance Swipe distances other than the default resulted in a slider that were not easy to control. * refactor: Add class Pointers.Sliding It holds the states and the code needed to make the slider work. 'Pointer.sliding' is set to [null] when sliding is not in progress. The implementation is changed not to depend on [downX] and [dx] but instead use the pointer's [x] coordinate directly. * Move the cursor further for faster slides In sliding mode, compute the speed of the pointer and use it to increase at which the cursor moves. * refactor: Separate kind for cursor movement keys This allows to define a key that moves the cursor more than one position at a time. This will be used to avoid lag during fast slider movements. * Reduce lag when sliding quickly on the spacebar Avoid sending key events in a loop while sliding quickly in a cursor movement key. Key of kind Cursor_move are "multiplied", meaning a single key event represents a movement of more than one position, reducing the number of key events sent. This is only for cursor move keys. --- srcs/juloo.keyboard2/KeyEventHandler.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'srcs/juloo.keyboard2/KeyEventHandler.java') diff --git a/srcs/juloo.keyboard2/KeyEventHandler.java b/srcs/juloo.keyboard2/KeyEventHandler.java index 01c4300..b6225f1 100644 --- a/srcs/juloo.keyboard2/KeyEventHandler.java +++ b/srcs/juloo.keyboard2/KeyEventHandler.java @@ -94,6 +94,7 @@ public final class KeyEventHandler implements Config.IKeyEventHandler case Compose_pending: _recv.set_compose_pending(true); break; + case Cursor_move: move_cursor(key.getCursorMove()); break; } update_meta_state(old_mods); } @@ -222,8 +223,6 @@ public final class KeyEventHandler implements Config.IKeyEventHandler case REPLACE: send_context_menu_action(android.R.id.replaceText); break; case ASSIST: send_context_menu_action(android.R.id.textAssist); break; case AUTOFILL: send_context_menu_action(android.R.id.autofill); break; - case CURSOR_LEFT: move_cursor(-1); break; - case CURSOR_RIGHT: move_cursor(1); break; } } -- cgit v1.2.3