File tree Expand file tree Collapse file tree 4 files changed +18
-3
lines changed
Expand file tree Collapse file tree 4 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -139,7 +139,8 @@ unsigned char read_data_reply() {
139139int keyboard_buffer [KEYBOARD_BUFFER_SIZE + 3 ];
140140
141141void keyboard_scanner_handler_init ();
142- int keyboard_scanner_handle_buffer (int keyboard_buffer_queue []);
142+ void keyboard_scanner_ascii_clear ();
143+ int keyboard_scanner_handle_buffer ();
143144
144145void keyboard_scanner_init () {
145146 ASSERT ( queue_init (keyboard_buffer , KEYBOARD_BUFFER_SIZE ) );
@@ -160,11 +161,12 @@ int keyboard_scanner_step() {
160161 queue_push (keyboard_buffer , out );
161162 qs ++ ;
162163 }
163- keyboard_scanner_handle_buffer (keyboard_buffer );
164+ keyboard_scanner_handle_buffer ();
164165 return state_change ;
165166}
166167
167168char keyboard_get_key_pressed_blocking () {
169+ keyboard_scanner_ascii_clear ();
168170 while (!keyboard_scanner_ascii_is_available ()) {
169171 keyboard_scanner_step ();
170172 }
Original file line number Diff line number Diff line change @@ -172,10 +172,15 @@ static const unsigned char KEYBOARD_ASCII_MAPH_OTHERS[] = {
172172};
173173
174174static unsigned char KEYBOARD_ASCII_MAPPING [256 ];
175+ extern int keyboard_buffer [];
175176static char last_ascii ;
176177static int last_ascii_available = 0 ;
177178static char tmp_juggad_is_f0 = 0 ;
178179
180+ void keyboard_scanner_ascii_clear () {
181+ queue_clear (keyboard_buffer );
182+ }
183+
179184int keyboard_scanner_ascii_is_available () {
180185 return last_ascii_available ;
181186}
@@ -207,7 +212,7 @@ void keyboard_scanner_handler_init() {
207212 }
208213}
209214
210- int keyboard_scanner_handle_buffer (int keyboard_buffer [] ) {
215+ int keyboard_scanner_handle_buffer () {
211216 // For now just taking care of some of the key press and disgarding others.
212217 int len = queue_size (keyboard_buffer );
213218 if (len == 0 ) return 0 ;
Original file line number Diff line number Diff line change @@ -9,6 +9,12 @@ int queue_init(int container[], int size) {
99 return 1 ;
1010}
1111
12+ void queue_clear (int container []) {
13+ int * back = & container [0 ];
14+ int * front = & container [1 ];
15+ * back = * front = -1 ;
16+ }
17+
1218int queue_push (int container [], int data ) {
1319 int * back = & container [0 ];
1420 int * front = & container [1 ];
Original file line number Diff line number Diff line change 44
55// Returns if the queue init is successful.
66int queue_init (int container [], int effective_size );
7+ // Clears the queue.
8+ void queue_clear (int container []);
79// Returns if the push is successful.
810int queue_push (int container [], int data );
911// Returns if the push is successful.
You can’t perform that action at this time.
0 commit comments