aboutsummaryrefslogtreecommitdiff
path: root/converter/ps2_usb/matrix.c
diff options
context:
space:
mode:
authortmk <nobody@nowhere>2013-11-28 15:50:17 +0900
committertmk <nobody@nowhere>2013-11-28 15:50:55 +0900
commit10b2b1ae431b31b2ae29228dcaccb5ea292bbf9a (patch)
tree8ce43042c9988a35051667aede10e8afc7dcf204 /converter/ps2_usb/matrix.c
parent8b4fa599cf485f5d06314938a228a88dabb0b7f5 (diff)
downloadqmk_firmware-10b2b1ae431b31b2ae29228dcaccb5ea292bbf9a.tar.gz
qmk_firmware-10b2b1ae431b31b2ae29228dcaccb5ea292bbf9a.zip
Fix key stack and PS/2 Overrun
Diffstat (limited to 'converter/ps2_usb/matrix.c')
-rw-r--r--converter/ps2_usb/matrix.c33
1 files changed, 27 insertions, 6 deletions
diff --git a/converter/ps2_usb/matrix.c b/converter/ps2_usb/matrix.c
index aa0c38c68..45344c0f7 100644
--- a/converter/ps2_usb/matrix.c
+++ b/converter/ps2_usb/matrix.c
@@ -29,6 +29,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
29 29
30static void matrix_make(uint8_t code); 30static void matrix_make(uint8_t code);
31static void matrix_break(uint8_t code); 31static void matrix_break(uint8_t code);
32static void matrix_clear(void);
32#ifdef MATRIX_HAS_GHOST 33#ifdef MATRIX_HAS_GHOST
33static bool matrix_has_ghost_in_row(uint8_t row); 34static bool matrix_has_ghost_in_row(uint8_t row);
34#endif 35#endif
@@ -84,6 +85,7 @@ uint8_t matrix_cols(void)
84 85
85void matrix_init(void) 86void matrix_init(void)
86{ 87{
88 debug_enable = true;
87 ps2_host_init(); 89 ps2_host_init();
88 90
89 // initialize matrix state: all keys off 91 // initialize matrix state: all keys off
@@ -209,16 +211,18 @@ uint8_t matrix_scan(void)
209 state = INIT; 211 state = INIT;
210 break; 212 break;
211 case 0x00: // Overrun [3]p.25 213 case 0x00: // Overrun [3]p.25
212 print("Overrun\n"); 214 matrix_clear();
213 clear_keyboard(); 215 clear_keyboard();
216 print("Overrun\n");
214 state = INIT; 217 state = INIT;
215 break; 218 break;
216 default: // normal key make 219 default: // normal key make
217 if (code < 0x80) { 220 if (code < 0x80) {
218 matrix_make(code); 221 matrix_make(code);
219 } else { 222 } else {
220 xprintf("unexpected scan code at INIT: %02X\n", code); 223 matrix_clear();
221 clear_keyboard(); 224 clear_keyboard();
225 xprintf("unexpected scan code at INIT: %02X\n", code);
222 } 226 }
223 state = INIT; 227 state = INIT;
224 } 228 }
@@ -239,8 +243,9 @@ uint8_t matrix_scan(void)
239 if (code < 0x80) { 243 if (code < 0x80) {
240 matrix_make(code|0x80); 244 matrix_make(code|0x80);
241 } else { 245 } else {
242 xprintf("unexpected scan code at E0: %02X\n", code); 246 matrix_clear();
243 clear_keyboard(); 247 clear_keyboard();
248 xprintf("unexpected scan code at E0: %02X\n", code);
244 } 249 }
245 state = INIT; 250 state = INIT;
246 } 251 }
@@ -255,12 +260,18 @@ uint8_t matrix_scan(void)
255 matrix_break(PRINT_SCREEN); 260 matrix_break(PRINT_SCREEN);
256 state = INIT; 261 state = INIT;
257 break; 262 break;
263 case 0xF0:
264 matrix_clear();
265 clear_keyboard();
266 xprintf("unexpected scan code at F0: F0(clear and cont.)\n");
267 break;
258 default: 268 default:
259 if (code < 0x80) { 269 if (code < 0x80) {
260 matrix_break(code); 270 matrix_break(code);
261 } else { 271 } else {
262 xprintf("unexpected scan code at F0: %02X\n", code); 272 matrix_clear();
263 clear_keyboard(); 273 clear_keyboard();
274 xprintf("unexpected scan code at F0: %02X\n", code);
264 } 275 }
265 state = INIT; 276 state = INIT;
266 } 277 }
@@ -275,8 +286,9 @@ uint8_t matrix_scan(void)
275 if (code < 0x80) { 286 if (code < 0x80) {
276 matrix_break(code|0x80); 287 matrix_break(code|0x80);
277 } else { 288 } else {
278 xprintf("unexpected scan code at E0_F0: %02X\n", code); 289 matrix_clear();
279 clear_keyboard(); 290 clear_keyboard();
291 xprintf("unexpected scan code at E0_F0: %02X\n", code);
280 } 292 }
281 state = INIT; 293 state = INIT;
282 } 294 }
@@ -369,10 +381,13 @@ uint8_t matrix_scan(void)
369 } 381 }
370 } 382 }
371 383
372 if (ps2_error > PS2_ERR_STARTBIT3) { 384 // TODO: request RESEND when error occurs?
385/*
386 if (PS2_IS_FAILED(ps2_error)) {
373 uint8_t ret = ps2_host_send(PS2_RESEND); 387 uint8_t ret = ps2_host_send(PS2_RESEND);
374 xprintf("Resend: %02X\n", ret); 388 xprintf("Resend: %02X\n", ret);
375 } 389 }
390*/
376 return 1; 391 return 1;
377} 392}
378 393
@@ -464,3 +479,9 @@ static void matrix_break(uint8_t code)
464 is_modified = true; 479 is_modified = true;
465 } 480 }
466} 481}
482
483inline
484static void matrix_clear(void)
485{
486 for (uint8_t i=0; i < MATRIX_ROWS; i++) matrix[i] = 0x00;
487}