doskeyb
diff 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 diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/test.c Mon Sep 23 03:42:39 2013 +0300 1.3 @@ -0,0 +1,32 @@ 1.4 +#include <stdio.h> 1.5 +#include <ctype.h> 1.6 +#include <assert.h> 1.7 +#include "keyb.h" 1.8 + 1.9 +int main(void) 1.10 +{ 1.11 + int key; 1.12 + 1.13 + /* The argument to kb_init specifies how many keypresses to buffer up. 1.14 + * If you don't need any keypress buffering, pass 0 to disable it. 1.15 + */ 1.16 + kb_init(16); 1.17 + 1.18 + for(;;) { 1.19 + kb_wait(); /* wait for any keypress */ 1.20 + key = kb_getkey(); /* get the pressed key */ 1.21 + assert(key != -1); /* this should never happen since kb_wait returned */ 1.22 + 1.23 + if(key == 27) break; /* quit on esc */ 1.24 + 1.25 + /* if it's a printable character print it along with the key value */ 1.26 + if(isprint(key)) { 1.27 + printf("key: %d '%c'\n", key, (char)key); 1.28 + } else { 1.29 + printf("key: %d\n", key); 1.30 + } 1.31 + } 1.32 + 1.33 + kb_shutdown(); 1.34 + return 0; 1.35 +}