#include #include #include #include "logger.h" #include "config.h" int main(int argc, char* argv[]) { FILE* evdev_fp = fopen(KEYBOARD_EVDEV, "r"); FILE* report_fp = NULL; char* report_path = NULL; struct input_event pressed_key; int perkey_pressed[PERKEY_LEN + 1]; int keys_pressed = 0; struct timeval start_time; struct timeval press_time; gettimeofday(&start_time, NULL); asprintf(&report_path, REPORT_PATH, start_time.tv_sec); report_fp = fopen(report_path, "w"); do { fread(&pressed_key, sizeof(pressed_key), 1, evdev_fp); gettimeofday(&press_time, NULL); if (pressed_key.value == 1) { perkey_pressed[pressed_key.code < PERKEY_LEN ? pressed_key.code : PERKEY_LEN]; keys_pressed++; LOG(LOG_DEBUG, "%d:", keys_pressed, pressed_key.type, pressed_key.code, pressed_key.value); rewind(report_fp); fprintf(report_fp, "%d\n", keys_pressed); fflush(report_fp); } } while (1); return 0; }