Skip to content

Commit c3f2d2d

Browse files
author
Robin Müller
committed
Use also finger_count as global var
1 parent 0a37f24 commit c3f2d2d

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/gesture_detection.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ typedef struct gesture_start {
5050

5151
mt_slots_t mt_slots;
5252
gesture_start_t gesture_start;
53+
uint8_t finger_count;
5354

5455
static int test_grab(int fd) {
5556
int rc;
@@ -60,7 +61,7 @@ static int test_grab(int fd) {
6061
return rc;
6162
}
6263

63-
static void init_gesture(uint8_t finger_count) {
64+
static void init_gesture() {
6465
int32_t x_distance, y_distance;
6566
gesture_start.point.x = mt_slots.points[0].x;
6667
gesture_start.point.y = mt_slots.points[0].y;
@@ -130,10 +131,9 @@ static void set_key_event(struct input_event *key_event, int code, int value) {
130131

131132
static input_event_array_t *process_syn_event(struct input_event event,
132133
configuration_t config,
133-
point_t thresholds,
134-
uint8_t *finger_count) {
134+
point_t thresholds) {
135135
input_event_array_t *result = NULL;
136-
if (*finger_count > 0 && event.code == SYN_REPORT) {
136+
if (finger_count > 0 && event.code == SYN_REPORT) {
137137
direction_t direction = NONE;
138138

139139
int32_t x_distance, y_distance;
@@ -155,7 +155,7 @@ static input_event_array_t *process_syn_event(struct input_event event,
155155
if (direction != NONE) {
156156
uint8_t i;
157157
for (i = MAX_KEYS_PER_GESTURE; i > 0; i--) {
158-
int key = config.swipe_keys[FINGER_TO_INDEX(*finger_count)][direction].keys[i - 1];
158+
int key = config.swipe_keys[FINGER_TO_INDEX(finger_count)][direction].keys[i - 1];
159159
if (key > 0) {
160160
if (!result) {
161161
// i is the number of keys to press
@@ -170,7 +170,7 @@ static input_event_array_t *process_syn_event(struct input_event event,
170170
set_key_event(&result->data[result->length / 2 + i - 1], key, 0);
171171
}
172172
}
173-
*finger_count = 0;
173+
finger_count = 0;
174174
}
175175
}
176176
return result ? result : new_input_event_array(0);
@@ -187,7 +187,6 @@ static int32_t get_axix_threshold(int fd, int axis, uint8_t percentage) {
187187
void process_events(int fd, configuration_t config, void (*callback)(input_event_array_t*)) {
188188
struct input_event ev[64];
189189
int i, rd;
190-
uint8_t finger_count;
191190

192191
point_t thresholds;
193192
thresholds.x = get_axix_threshold(fd, ABS_X, config.horz_threshold_percentage);
@@ -214,14 +213,14 @@ void process_events(int fd, configuration_t config, void (*callback)(input_event
214213
case EV_KEY:
215214
finger_count = process_key_event(ev[i]);
216215
if (finger_count > 0) {
217-
init_gesture(finger_count);
216+
init_gesture();
218217
}
219218
break;
220219
case EV_ABS:
221220
process_abs_event(ev[i]);
222221
break;
223222
case EV_SYN: {
224-
input_event_array_t *input_events = process_syn_event(ev[i], config, thresholds, &finger_count);
223+
input_event_array_t *input_events = process_syn_event(ev[i], config, thresholds);
225224
callback(input_events);
226225
free(input_events);
227226
}

0 commit comments

Comments
 (0)