int main(const int argc, const char *argv[]) { Geis geis; GeisSubscription subscription; GeisFilter filter; GeisStatus status; int fd; parse_args(argc, argv); setup(); geis = geis_new(GEIS_INIT_TRACK_DEVICES, NULL); subscription = geis_subscription_new(geis, "mtsd", GEIS_SUBSCRIPTION_CONT); filter = geis_filter_new(geis, "mtsd_filter"); status = geis_subscription_add_filter(subscription, filter); status = geis_subscription_activate(subscription); geis_get_configuration(geis, GEIS_CONFIGURATION_FD, &fd); while (running) { running = run(&fd, &geis, &status); } geis_subscription_delete(subscription); geis_delete(geis); return 0; }
int main(int argc, char* argv[]) { GeisStatus status; Geis geis; GeisSubscription subscription; GeisFilter filter; int fd; geis = geis_new(GEIS_INIT_TRACK_DEVICES, NULL); subscription = geis_subscription_new(geis, "example", GEIS_SUBSCRIPTION_CONT); filter = geis_filter_new(geis, "filter"); geis_filter_add_term(filter, GEIS_FILTER_CLASS, GEIS_GESTURE_ATTRIBUTE_TOUCHES, GEIS_FILTER_OP_EQ, 2, NULL); status = geis_subscription_add_filter(subscription, filter); status = geis_subscription_activate(subscription); geis_get_configuration(geis, GEIS_CONFIGURATION_FD, &fd); while(1) { fd_set read_fds; FD_ZERO(&read_fds); FD_SET(0, &read_fds); FD_SET(fd, &read_fds); int sstat = select(fd+1, &read_fds, NULL, NULL, NULL); if (sstat < 0) { fprintf(stderr, "error %d in select(): %s\n", errno, strerror(errno)); break; } if (FD_ISSET(fd, &read_fds)) { GeisEvent event; status = geis_dispatch_events(geis); status = geis_next_event(geis, &event); while (status == GEIS_STATUS_CONTINUE || status == GEIS_STATUS_SUCCESS) { switch (geis_event_type(event)) { case GEIS_EVENT_DEVICE_AVAILABLE: case GEIS_EVENT_DEVICE_UNAVAILABLE: dump_device_event(event); break; case GEIS_EVENT_GESTURE_BEGIN: case GEIS_EVENT_GESTURE_UPDATE: case GEIS_EVENT_GESTURE_END: dump_gesture_event(event); break; } geis_event_delete(event); status = geis_next_event(geis, &event); } } if (FD_ISSET(0, &read_fds)) { break; } } geis_subscription_delete(subscription); geis_delete(geis); }