diff options
| author | dzaima | 2026-02-27 01:41:48 +0200 |
|---|---|---|
| committer | GitHub | 2026-02-27 00:41:48 +0100 |
| commit | 27fdcb6bfcc43d80840b777974bb5a085b4529de (patch) | |
| tree | 793b995e9b21c9b06e76981635380e4083ed4cf8 /srcs/juloo.keyboard2/Pointers.java | |
| parent | 6a19f7ccd34be0a1e26e64c081de755287460347 (diff) | |
| download | unexpected-keyboard-27fdcb6bfcc43d80840b777974bb5a085b4529de.tar.gz unexpected-keyboard-27fdcb6bfcc43d80840b777974bb5a085b4529de.zip | |
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
Diffstat (limited to 'srcs/juloo.keyboard2/Pointers.java')
| -rw-r--r-- | srcs/juloo.keyboard2/Pointers.java | 15 |
1 files changed, 12 insertions, 3 deletions
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; |
