doskeyb
diff keyb.c @ 2:da4c014bb055
implemented kb_isdown(KB_ANY) correctly
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Mon, 23 Sep 2013 04:07:09 +0300 |
parents | c2b210a70ce9 |
children |
line diff
1.1 --- a/keyb.c Mon Sep 23 03:45:39 2013 +0300 1.2 +++ b/keyb.c Mon Sep 23 04:07:09 2013 +0300 1.3 @@ -42,6 +42,7 @@ 1.4 static int buffer_size, buf_ridx, buf_widx; 1.5 static int last_key; 1.6 1.7 +static unsigned int num_pressed; 1.8 static unsigned char keystate[256]; 1.9 1.10 #define ADVANCE(x) ((x) = ((x) + 1) % buffer_size) 1.11 @@ -62,6 +63,7 @@ 1.12 last_key = -1; 1.13 1.14 memset(keystate, 0, sizeof keystate); 1.15 + num_pressed = 0; 1.16 1.17 /* set our interrupt handler */ 1.18 _disable(); 1.19 @@ -88,6 +90,9 @@ 1.20 1.21 int kb_isdown(int key) 1.22 { 1.23 + if(key == KB_ANY) { 1.24 + return num_pressed; 1.25 + } 1.26 return (int)keystate[key]; 1.27 } 1.28 1.29 @@ -155,8 +160,14 @@ 1.30 if(code >= 128) { 1.31 press = 0; 1.32 code -= 128; 1.33 + 1.34 + if(num_pressed > 0) { 1.35 + num_pressed--; 1.36 + } 1.37 } else { 1.38 press = 1; 1.39 + 1.40 + num_pressed++; 1.41 } 1.42 1.43 key = scantbl[code];