aboutsummaryrefslogtreecommitdiffstats
path: root/kbdtest.c
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2019-01-18 10:23:41 +0100
committerGerd Hoffmann <kraxel@redhat.com>2019-01-18 11:03:55 +0100
commit1e49f9371f39475be7d2a3a9be2994ce5d27870b (patch)
treeb84ba5b35e846beddca3c78b6f01d12a6d5116a7 /kbdtest.c
parent03c8b71a085afb2a856fcf9a6e53c0b83cd9795c (diff)
downloadfbida-1e49f9371f39475be7d2a3a9be2994ce5d27870b.tar.gz
abstract away some kbd details
Diffstat (limited to 'kbdtest.c')
-rw-r--r--kbdtest.c21
1 files changed, 6 insertions, 15 deletions
diff --git a/kbdtest.c b/kbdtest.c
index 849e5e2..866b6df 100644
--- a/kbdtest.c
+++ b/kbdtest.c
@@ -19,31 +19,21 @@ static const char *keyname[KEY_CNT] = {
int main(int argc, char *argv[])
{
- struct timeval limit;
uint32_t code, mod;
char key[32];
- fd_set set;
int rc,i;
- tty_raw();
+ kbd_init();
for (;;) {
- FD_ZERO(&set);
- FD_SET(0, &set);
- limit.tv_sec = 10;
- limit.tv_usec = 0;
- rc = select(1, &set, NULL, NULL, &limit);
- if (0 == rc || !FD_ISSET(0,&set))
- break;
+ kbd_wait(10);
- memset(key, 0, sizeof(key));
- rc = read(0, key, sizeof(key)-1);
- if (rc < 1) {
+ rc = kbd_read(key, sizeof(key), &code, &mod);
+ if (rc < 0) {
/* EOF */
break;
}
- code = kbd_parse(key, &mod);
fprintf(stderr, "key: \"");
for (i = 0; key[i] != 0; i++) {
fprintf(stderr, "%c", isprint(key[i]) ? key[i] : '.');
@@ -55,6 +45,7 @@ int main(int argc, char *argv[])
fprintf(stderr, " +ctrl");
fprintf(stderr, "\n");
}
- tty_restore();
+
+ kbd_fini();
return 0;
}