- got_x = got_y = got_z = 0;
-
- while (1) {
- int i;
-
- r = read(fd, ev, sizeof(struct input_event) * 64);
-
- if (r < (int) sizeof(struct input_event)) {
- close(fd);
- return;
- }
-
- for (i = 0; i < r / (int) sizeof(struct input_event); i++) {
- if (got_syn == 1) {
- if (ev[i].type == EV_ABS) {
- SET_AXIS(x, ABS_X);
- SET_AXIS(y, ABS_Y);
- SET_AXIS(z, ABS_Z);
- }
- }
- if (ev[i].type == EV_SYN && ev[i].code == SYN_REPORT) {
- got_syn = 1;
- }
- if (got_x && got_y && got_z)
- goto read_dev;
- }
- }
-
-read_dev:
- close(fd);
-
- if (!got_x || !got_y || !got_z)
- return;