Compare commits

..

2 Commits

Author SHA1 Message Date
634c8a1727 Formatted. 2024-12-08 19:33:45 +01:00
f17d732df6 Implemented real time statistics. 2024-12-08 19:33:01 +01:00
3 changed files with 30 additions and 27 deletions

View File

@ -9049,5 +9049,3 @@ void sormfmtd(char *csv) {
} }
#endif #endif

BIN
tikker

Binary file not shown.

View File

@ -1,16 +1,15 @@
#include "sormc.h"
#include <fcntl.h>
#include <linux/input.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <linux/input.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include "sormc.h" #include <unistd.h>
#define MAX_DEVICES 32 #define MAX_DEVICES 32
#define DEVICE_PATH "/dev/input/event" #define DEVICE_PATH "/dev/input/event"
int is_keyboard(int fd) { int is_keyboard(int fd) {
char device_name[256] = {0}; char device_name[256] = {0};
@ -23,10 +22,13 @@ int is_keyboard(int fd) {
int main() { int main() {
db = sormc("tikker.db"); db = sormc("tikker.db");
sormq(db,"CREATE TABLE IF NOT EXISTS kevent (id INTEGER PRIMARY KEY AUTOINCREMENT, code,event,name,timestamp)"); ulonglong times_repeated = 0;
ulonglong times_pressed = 0;
ulonglong times_released = 0;
sormq(db, "CREATE TABLE IF NOT EXISTS kevent (id INTEGER PRIMARY KEY AUTOINCREMENT, code,event,name,timestamp)");
int keyboard_fds[MAX_DEVICES]; int keyboard_fds[MAX_DEVICES];
int num_keyboards = 0; int num_keyboards = 0;
@ -84,20 +86,23 @@ int main() {
ioctl(keyboard_fds[i], EVIOCGNAME(sizeof(key_name)), key_name); ioctl(keyboard_fds[i], EVIOCGNAME(sizeof(key_name)), key_name);
printf("Keyboard: %s, ", key_name); printf("Keyboard: %s, ", key_name);
char * event_name = NULL; char *event_name = NULL;
if(ev.value == 1){ if (ev.value == 1) {
event_name = "PRESSED"; event_name = "PRESSED";
}else if(ev.value == 0){ times_pressed++;
} else if (ev.value == 0) {
event_name = "RELEASED"; event_name = "RELEASED";
}else { times_released++;
} else {
event_name = "REPEATED"; event_name = "REPEATED";
times_repeated++;
} }
sormq(db, "INSERT INTO kevent (code, event, name,timestamp) VALUES (%d, %s, %s, DATETIME('now'))",ev.code,event_name,key_name); sormq(db, "INSERT INTO kevent (code, event, name,timestamp) VALUES (%d, %s, %s, DATETIME('now'))", ev.code,
printf("Event: %s, ", event_name, key_name);
ev.value == 1 ? "PRESSED" : printf("Event: %s, ", ev.value == 1 ? "PRESSED" : ev.value == 0 ? "RELEASED" : "REPEATED");
ev.value == 0 ? "RELEASED" : "REPEATED"); printf("Key Code: %d ", ev.code);
printf("Key Code: %d\n", ev.code); printf("Pr: %lld Rel: %lld Rep: %lld\n", times_pressed, times_released, times_repeated);
} }
} }
} }