diff options
Diffstat (limited to 'src/main.c')
| -rw-r--r-- | src/main.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..3542f36 --- /dev/null +++ b/src/main.c @@ -0,0 +1,45 @@ +#include <linux/input.h> +#include <sys/time.h> +#include <stdio.h> + +#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; +} |
