Skip to content

Commit beccf72

Browse files
author
Robin Müller
committed
Added possibility to invert the scroll direction by using negative values for the deltas
1 parent d8f34cb commit beccf72

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

src/configuraion.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ configuration_t read_config(const char *filename) {
8080
}
8181
result.scroll.vert = iniparser_getboolean(ini, "scroll:vertical", false);
8282
result.scroll.horz = iniparser_getboolean(ini, "scroll:horizontal", false);
83-
result.scroll.vert_delta = (uint8_t) iniparser_getint(ini, "scroll:verticaldelta", 79);
84-
result.scroll.horz_delta = (uint8_t) iniparser_getint(ini, "scroll:horizontaldelta", 30);
83+
result.scroll.vert_delta = (int8_t) iniparser_getint(ini, "scroll:verticaldelta", 79);
84+
result.scroll.horz_delta = (int8_t) iniparser_getint(ini, "scroll:horizontaldelta", 30);
8585
result.vert_threshold_percentage = iniparser_getint(ini, "thresholds:vertical", 15);
8686
result.horz_threshold_percentage = iniparser_getint(ini, "thresholds:horizontal", 15);
8787
result.zoom.enabled = iniparser_getboolean(ini, "zoom:enabled", false);

src/configuraion.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ typedef struct configuration {
4444
struct scroll_options {
4545
bool vert;
4646
bool horz;
47-
uint8_t vert_delta;
48-
uint8_t horz_delta;
47+
int8_t vert_delta;
48+
int8_t horz_delta;
4949
} scroll;
5050
struct zoom_options {
5151
bool enabled;

src/gesture_detection.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ static input_event_array_t *do_scroll(double distance, int32_t delta, int rel_co
206206
scroll.width += distance;
207207
// a scroll width of delta means scroll one "scroll-unit" therefore a scroll event
208208
// can be first triggered if the absolute value of scroll.width exeeded delta
209-
if (fabs(scroll.width) > delta) {
209+
if (fabs(scroll.width) > fabs(delta)) {
210210
result = new_input_event_array(2);
211211
int width = (int)(scroll.width / delta);
212212
set_rel_event(&result->data[0], rel_code, width);

0 commit comments

Comments
 (0)