Skip to content

Commit 02364a9

Browse files
author
Robin Müller
committed
Use the scroll invert flags also for the scroll slowdown
1 parent 24e386e commit 02364a9

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/gesture_detection.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ static double calcualte_velocity(struct input_event event1, struct input_event e
172172
return distance / time_delta;
173173
}
174174

175-
static void process_abs_event(struct input_event event, point_t offsets) {
175+
static void process_abs_event(struct input_event event, point_t offsets, bool invert_horz_scroll, bool invert_vert_scroll) {
176176
if (event.code == ABS_MT_SLOT) {
177177
// store the current mt_slot
178178
mt_slots.active = event.value;
@@ -186,7 +186,7 @@ static void process_abs_event(struct input_event event, point_t offsets) {
186186
if (scroll.last_x_abs_event.type == EV_ABS && scroll.last_x_abs_event.code == ABS_MT_POSITION_X) {
187187
// invert the velocity to scroll to the correct direction as a positive x direction
188188
// on the touchpad mean scroll left (negative scroll direction)
189-
scroll.x_velocity = -calcualte_velocity(scroll.last_x_abs_event, event);
189+
scroll.x_velocity = calcualte_velocity(scroll.last_x_abs_event, event) * (invert_horz_scroll ? 1 : -1);
190190
}
191191
scroll.last_x_abs_event = event;
192192
}
@@ -200,7 +200,7 @@ static void process_abs_event(struct input_event event, point_t offsets) {
200200
if (mt_slots.active == 0 && finger_count == SCROLL_FINGER_COUNT) {
201201
// check wether a correct input event was set to scroll.last_y_abs_event
202202
if (scroll.last_y_abs_event.type == EV_ABS && scroll.last_y_abs_event.code == ABS_MT_POSITION_Y) {
203-
scroll.y_velocity = calcualte_velocity(scroll.last_y_abs_event, event);
203+
scroll.y_velocity = calcualte_velocity(scroll.last_y_abs_event, event) * (invert_vert_scroll ? -1 : 1);
204204
}
205205
scroll.last_y_abs_event = event;
206206
}
@@ -518,7 +518,7 @@ void process_events(int fd, configuration_t config, void (*callback)(input_event
518518
}
519519
break;
520520
case EV_ABS:
521-
process_abs_event(ev[i], offsets);
521+
process_abs_event(ev[i], offsets, config.scroll.invert_horz, config.scroll.invert_vert);
522522
break;
523523
case EV_SYN: {
524524
input_event_array_t *input_events = process_syn_event(ev[i], config, thresholds);

0 commit comments

Comments
 (0)