blob: b66fad9ec99e1dfad56937ee157013dced6735fd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
#include <stdio.h>
#include <unistd.h>
int main(void)
{
double time;
int left_trigger, right_trigger;
int right_pressed = 0, left_pressed = 0;
while(1) {
if (scanf("%lf, %d, %d,", &time, &left_trigger, &right_trigger) != 3) {
printf("scanf failed\n");
}
if (right_trigger > 1000 && right_pressed == 0) {
right_pressed = 1;
printf("Right trigger pressed at: %lf\n", time);
} else if (right_trigger < 100) {
right_pressed = 0;
}
if (left_trigger > 1000 && left_pressed == 0) {
left_pressed = 1;
printf("Left trigger pressed at: %lf\n", time);
} else if (left_trigger < 100) {
left_pressed = 0;
}
}
return 0;
}
|