@@ -46,6 +46,8 @@ struct gesture_start_t {
46
46
uint32_t distance ;
47
47
};
48
48
49
+ enum direction_t { NONE , UP , DOWN , LEFT , RIGHT };
50
+
49
51
static int test_grab (int fd ) {
50
52
int rc ;
51
53
rc = ioctl (fd , EVIOCGRAB , (void * )1 );
@@ -119,26 +121,28 @@ static void process_syn_event(struct input_event event,
119
121
struct point_t thresholds ,
120
122
uint8_t * finger_count ) {
121
123
if (* finger_count > 0 && event .code == SYN_REPORT ) {
124
+ enum direction_t direction = NONE ;
125
+
122
126
int32_t x_distance , y_distance ;
123
127
x_distance = gesture_start .point .x - slot_points [0 ].x ;
124
128
y_distance = gesture_start .point .y - slot_points [0 ].y ;
125
129
if (fabs (x_distance ) > fabs (y_distance )) {
126
130
if (x_distance > thresholds .x ) {
127
- printf ("%d fingers left\n" , * finger_count );
128
- * finger_count = 0 ;
131
+ direction = LEFT ;
129
132
} else if (x_distance < - thresholds .x ) {
130
- printf ("%d fingers right\n" , * finger_count );
131
- * finger_count = 0 ;
133
+ direction = RIGHT ;
132
134
}
133
135
} else {
134
136
if (y_distance > thresholds .y ) {
135
- printf ("%d fingers up\n" , * finger_count );
136
- * finger_count = 0 ;
137
+ direction = UP ;
137
138
} else if (y_distance < - thresholds .y ) {
138
- printf ("%d fingers down\n" , * finger_count );
139
- * finger_count = 0 ;
139
+ direction = DOWN ;
140
140
}
141
141
}
142
+ if (direction != NONE ) {
143
+ printf ("fingers: %d, direction: %d\n" , * finger_count , direction );
144
+ * finger_count = 0 ;
145
+ }
142
146
}
143
147
}
144
148
0 commit comments