Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions srcs/juloo.keyboard2/KeyValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -847,18 +847,24 @@ public static interface Describe

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
Expand Down
15 changes: 12 additions & 3 deletions srcs/juloo.keyboard2/Pointers.java
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,9 @@ public Sliding(float x, float y, int dirx, int diry, KeyValue.Slider s)
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)
{
Expand All @@ -625,9 +628,15 @@ public void onTouchMove(Pointer ptr, float x, float y)
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;
Expand Down