From 27fdcb6bfcc43d80840b777974bb5a085b4529de Mon Sep 17 00:00:00 2001 From: dzaima Date: Fri, 27 Feb 2026 01:41:48 +0200 Subject: Some slider changes (#1195) * Helper for whether a slider is vertical * Only accumulate delta for the current slider's direction * Slow down horizontal cursor movement while ctrl is held--- srcs/juloo.keyboard2/KeyValue.java | 20 +++++++++++++------- srcs/juloo.keyboard2/Pointers.java | 15 ++++++++++++--- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/srcs/juloo.keyboard2/KeyValue.java b/srcs/juloo.keyboard2/KeyValue.java index 7805443..04f6950 100644 --- a/srcs/juloo.keyboard2/KeyValue.java +++ b/srcs/juloo.keyboard2/KeyValue.java @@ -847,18 +847,24 @@ public final class KeyValue implements Comparable public static enum Slider implements Describe { - Cursor_left(0xE008), - Cursor_right(0xE006), - Cursor_up(0xE005), - Cursor_down(0xE007), - Selection_cursor_left(0xE008), - Selection_cursor_right(0xE006); + Cursor_left(0xE008, false), + Cursor_right(0xE006, false), + Cursor_up(0xE005, true), + Cursor_down(0xE007, true), + Selection_cursor_left(0xE008, false), + Selection_cursor_right(0xE006, false); final String symbol; + final boolean vertical; - Slider(int symbol_) + Slider(int symbol_, boolean vertical) { symbol = String.valueOf((char)symbol_); + this.vertical = vertical; + } + + public boolean isVertical() { + return vertical; } @Override diff --git a/srcs/juloo.keyboard2/Pointers.java b/srcs/juloo.keyboard2/Pointers.java index 62fdbb8..c7feedc 100644 --- a/srcs/juloo.keyboard2/Pointers.java +++ b/srcs/juloo.keyboard2/Pointers.java @@ -612,6 +612,9 @@ public final class Pointers implements Handler.Callback slider slower, as we have less visibility and do smaller movements in that direction. */ static final float SPEED_VERTICAL_MULT = 0.5f; + /** Make horizontal sliders slower while ctrl is held (which typically + means movement happens by whole words instead of characters) */ + static final float SPEED_WORD_MULT = 0.25f; public void onTouchMove(Pointer ptr, float x, float y) { @@ -625,9 +628,15 @@ public final class Pointers implements Handler.Callback return; last_move_ms = System.currentTimeMillis(); } - d += ((x - last_x) * speed * direction_x - + (y - last_y) * speed * SPEED_VERTICAL_MULT * direction_y) - / _config.slide_step_px; + float current_speed = speed / _config.slide_step_px; + if (slider.isVertical()) { + d += (y - last_y) * current_speed * direction_y * SPEED_VERTICAL_MULT; + } else { + if (ptr.modifiers.has(KeyValue.Modifier.CTRL)) + current_speed *= SPEED_WORD_MULT; + d += (x - last_x) * current_speed * direction_x; + } + update_speed(travelled, x, y); // Send an event when [abs(d)] exceeds [1]. int d_ = (int)d; -- cgit v1.2.3