doskeyb

view test.c @ 0:c2b210a70ce9

initial DOS keyboard driver commit
author John Tsiombikas <nuclear@member.fsf.org>
date Mon, 23 Sep 2013 03:42:39 +0300
parents
children da4c014bb055
line source
1 #include <stdio.h>
2 #include <ctype.h>
3 #include <assert.h>
4 #include "keyb.h"
6 int main(void)
7 {
8 int key;
10 /* The argument to kb_init specifies how many keypresses to buffer up.
11 * If you don't need any keypress buffering, pass 0 to disable it.
12 */
13 kb_init(16);
15 for(;;) {
16 kb_wait(); /* wait for any keypress */
17 key = kb_getkey(); /* get the pressed key */
18 assert(key != -1); /* this should never happen since kb_wait returned */
20 if(key == 27) break; /* quit on esc */
22 /* if it's a printable character print it along with the key value */
23 if(isprint(key)) {
24 printf("key: %d '%c'\n", key, (char)key);
25 } else {
26 printf("key: %d\n", key);
27 }
28 }
30 kb_shutdown();
31 return 0;
32 }