Right now I'm reading directly from /dev/input/eventX. Is there some library or api that would convert the byte stream for me? Below is the code I'm running, sample input and output.
int main (void)
{
struct input_event ev;
int fd, rd;
//Open Device
if ((fd = open ("/dev/input/event0", O_RDONLY)) == -1){
printf ("not a vaild device.\n");
return -1;
}
while (1){
memset((void*)&ev, 0, sizeof(ev));
rd = read (fd, (void*)&ev, sizeof(ev));
if (rd > 0 && ev.type==1){
printf("value: %d, code: %d\n", ev.value, ev.code);
}
}
If I type
XAL4
I get:
value: 1, code: 42
value: 1, code: 45
value: 0, code: 42
value: 0, code: 45
value: 1, code: 42
value: 1, code: 30
value: 0, code: 42
value: 0, code: 30
value: 1, code: 42
value: 1, code: 38
value: 0, code: 42
value: 0, code: 38
value: 1, code: 5
value: 0, code: 5
Using the header, https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/input-event-codes.h
I know that the key sequence is:
KEY_DOWN: SHIFT
KEY_DOWN: X
KEY_UP: SHIFT
KEY_UP: X
KEY_DOWN: SHIFT
KEY_DOWN: A
KEY_UP: SHIFT
KEY_UP: A
KEY_DOWN: SHIFT
KEY_DOWN: L
KEY_UP: SHIFT
KEY_UP: L
KEY_DOWN: 4
KEY_UP: 4
Is there a library or api that would convert this to raw ascii for me?