abouttreesummaryrefslogcommitdiff
path: root/srcs/juloo.keyboard2
diff options
context:
space:
mode:
authordzaima2026-02-27 01:41:48 +0200
committerGitHub2026-02-27 00:41:48 +0100
commit27fdcb6bfcc43d80840b777974bb5a085b4529de (patch)
tree793b995e9b21c9b06e76981635380e4083ed4cf8 /srcs/juloo.keyboard2
parent6a19f7ccd34be0a1e26e64c081de755287460347 (diff)
downloadunexpected-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')
-rw-r--r--srcs/juloo.keyboard2/KeyValue.java20
-rw-r--r--srcs/juloo.keyboard2/Pointers.java15
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<KeyValue>
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;