In an application that runs in a frame buffer, I read keys from /dev/tty after having set it to mediumraw mode using
int fd = open("/dev/tty", O_RDWR); ... ioctl(fd, KDSKBMODE, K_MEDIUMRAW);
In order to get at the unicode values of the keys representing chars, I do something along the lines of
struct kbentry entry; entry.kb_table = (some combination of KG_* values or 0); entry.kb_index = code & 0x7f; /* code is the value received by read()ing from /dev/tty */ ioctl(fd, KDSKBMODE, K_UNICODE); ioctl(kbd->fd, KDGKBENT, &entry); ioctl(fd, KDSKBMODE, K_MEDIUMRAW); /* unicode value is now in entry.kb_value */
This works quite well, except for one thing: when my keyboard has dead chars, I get those returned as 0x0400, 0x0401, 0x0402 etc. The 0x04 is KT_DEAD, so this looks about right, but when I read the kernel's diacritical table into a struct kbdiacrsuc, I see that that expects actual character codes instead of 01, 02, ... So, how do I get those character codes from the dead keys?