void EvdevDevice::update(float delta) { struct input_event ev[128]; // FIXME: turn this into a while loop so all events get processed int rd = read(fd, ev, sizeof(struct input_event) * 128); //std::cout << rd / sizeof(struct input_event) << std::endl; if (rd >= (int) sizeof(struct input_event)) { for (int i = 0; i < rd / (int)sizeof(struct input_event); ++i) { //std::cout << ev[i].type << " " << ev[i].code << " " << ev[i].value << std::endl; switch (ev[i].type) { case EV_ABS: process_absolute(ev[i]); break; case EV_REL: process_relative(ev[i]); break; case EV_KEY: process_key(ev[i]); break; default: #if 0 if (ev[i].type == EV_SYN) { printf("Event: time %ld.%06ld, -------------- %s ------------\n", ev[i].time.tv_sec, ev[i].time.tv_usec, ev[i].code ? "Config Sync" : "Report Sync" ); } else if (ev[i].type == EV_MSC && (ev[i].code == MSC_RAW || ev[i].code == MSC_SCAN)) { printf("Event: time %ld.%06ld, type %d (%s), code %d (%s), value %02x\n", ev[i].time.tv_sec, ev[i].time.tv_usec, ev[i].type, events[ev[i].type] ? events[ev[i].type] : "?", ev[i].code, names[ev[i].type] ? (names[ev[i].type][ev[i].code] ? names[ev[i].type][ev[i].code] : "?") : "?", ev[i].value); } else { printf("Event: time %ld.%06ld, type %d (%s), code %d (%s), value %d\n", ev[i].time.tv_sec, ev[i].time.tv_usec, ev[i].type, events[ev[i].type] ? events[ev[i].type] : "?", ev[i].code, names[ev[i].type] ? (names[ev[i].type][ev[i].code] ? names[ev[i].type][ev[i].code] : "?") : "?", ev[i].value); } #endif break; } } } }
static void touchpad_process(struct evdev_dispatch *dispatch, struct evdev_device *device, struct input_event *e, uint32_t time) { struct touchpad_dispatch *touchpad = (struct touchpad_dispatch *) dispatch; switch (e->type) { case EV_SYN: if (e->code == SYN_REPORT) touchpad->event_mask |= TOUCHPAD_EVENT_REPORT; break; case EV_ABS: process_absolute(touchpad, device, e); break; case EV_KEY: process_key(touchpad, device, e, time); break; } touchpad_update_state(touchpad, time); }