Compare commits
No commits in common. "634c8a1727bf6ab13bfb01400aa7be64e2db4023" and "13275a969bef8787a0c6a0e385673ce88a30c161" have entirely different histories.
634c8a1727
...
13275a969b
27
tikker.c
27
tikker.c
@ -1,15 +1,16 @@
|
|||||||
#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 <sys/ioctl.h>
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <linux/input.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include "sormc.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};
|
||||||
|
|
||||||
@ -22,11 +23,8 @@ int is_keyboard(int fd) {
|
|||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
|
||||||
db = sormc("tikker.db");
|
|
||||||
|
|
||||||
ulonglong times_repeated = 0;
|
db = sormc("tikker.db");
|
||||||
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)");
|
sormq(db,"CREATE TABLE IF NOT EXISTS kevent (id INTEGER PRIMARY KEY AUTOINCREMENT, code,event,name,timestamp)");
|
||||||
|
|
||||||
@ -89,20 +87,17 @@ int main() {
|
|||||||
char * event_name = NULL;
|
char * event_name = NULL;
|
||||||
if(ev.value == 1){
|
if(ev.value == 1){
|
||||||
event_name = "PRESSED";
|
event_name = "PRESSED";
|
||||||
times_pressed++;
|
|
||||||
}else if(ev.value == 0){
|
}else if(ev.value == 0){
|
||||||
event_name = "RELEASED";
|
event_name = "RELEASED";
|
||||||
times_released++;
|
|
||||||
}else {
|
}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,
|
sormq(db, "INSERT INTO kevent (code, event, name,timestamp) VALUES (%d, %s, %s, DATETIME('now'))",ev.code,event_name,key_name);
|
||||||
event_name, key_name);
|
printf("Event: %s, ",
|
||||||
printf("Event: %s, ", ev.value == 1 ? "PRESSED" : ev.value == 0 ? "RELEASED" : "REPEATED");
|
ev.value == 1 ? "PRESSED" :
|
||||||
printf("Key Code: %d ", ev.code);
|
ev.value == 0 ? "RELEASED" : "REPEATED");
|
||||||
printf("Pr: %lld Rel: %lld Rep: %lld\n", times_pressed, times_released, times_repeated);
|
printf("Key Code: %d\n", ev.code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user