diff options
Diffstat (limited to 'ps2_usb/matrix.c')
| -rw-r--r-- | ps2_usb/matrix.c | 50 |
1 files changed, 1 insertions, 49 deletions
diff --git a/ps2_usb/matrix.c b/ps2_usb/matrix.c index aaf89719e..52479d975 100644 --- a/ps2_usb/matrix.c +++ b/ps2_usb/matrix.c | |||
| @@ -9,8 +9,7 @@ | |||
| 9 | #include "util.h" | 9 | #include "util.h" |
| 10 | #include "debug.h" | 10 | #include "debug.h" |
| 11 | #include "ps2.h" | 11 | #include "ps2.h" |
| 12 | #include "usb_keyboard.h" | 12 | #include "matrix.h" |
| 13 | #include "matrix_skel.h" | ||
| 14 | 13 | ||
| 15 | 14 | ||
| 16 | #if (MATRIX_COLS > 16) | 15 | #if (MATRIX_COLS > 16) |
| @@ -60,8 +59,6 @@ static bool matrix_has_ghost_in_row(uint8_t row); | |||
| 60 | #endif | 59 | #endif |
| 61 | static void matrix_make(uint8_t code); | 60 | static void matrix_make(uint8_t code); |
| 62 | static void matrix_break(uint8_t code); | 61 | static void matrix_break(uint8_t code); |
| 63 | static void ps2_reset(void); | ||
| 64 | static void ps2_set_leds(uint8_t leds); | ||
| 65 | 62 | ||
| 66 | 63 | ||
| 67 | inline | 64 | inline |
| @@ -78,20 +75,8 @@ uint8_t matrix_cols(void) | |||
| 78 | 75 | ||
| 79 | void matrix_init(void) | 76 | void matrix_init(void) |
| 80 | { | 77 | { |
| 81 | print_enable = true; | ||
| 82 | ps2_host_init(); | 78 | ps2_host_init(); |
| 83 | 79 | ||
| 84 | ps2_reset(); | ||
| 85 | |||
| 86 | // flush LEDs | ||
| 87 | ps2_set_leds(1<<PS2_LED_NUM_LOCK); | ||
| 88 | _delay_ms(100); | ||
| 89 | ps2_set_leds(1<<PS2_LED_NUM_LOCK|1<<PS2_LED_CAPS_LOCK); | ||
| 90 | _delay_ms(100); | ||
| 91 | ps2_set_leds(1<<PS2_LED_NUM_LOCK|1<<PS2_LED_CAPS_LOCK|1<<PS2_LED_SCROLL_LOCK); | ||
| 92 | _delay_ms(300); | ||
| 93 | ps2_set_leds(0x00); | ||
| 94 | |||
| 95 | // initialize matrix state: all keys off | 80 | // initialize matrix state: all keys off |
| 96 | for (uint8_t i=0; i < MATRIX_ROWS; i++) matrix[i] = 0x00; | 81 | for (uint8_t i=0; i < MATRIX_ROWS; i++) matrix[i] = 0x00; |
| 97 | 82 | ||
| @@ -191,7 +176,6 @@ uint8_t matrix_scan(void) | |||
| 191 | 176 | ||
| 192 | uint8_t code; | 177 | uint8_t code; |
| 193 | while ((code = ps2_host_recv())) { | 178 | while ((code = ps2_host_recv())) { |
| 194 | debug_hex(code); debug(" "); | ||
| 195 | switch (state) { | 179 | switch (state) { |
| 196 | case INIT: | 180 | case INIT: |
| 197 | switch (code) { | 181 | switch (code) { |
| @@ -349,22 +333,6 @@ debug_hex(code); debug(" "); | |||
| 349 | state = INIT; | 333 | state = INIT; |
| 350 | } | 334 | } |
| 351 | } | 335 | } |
| 352 | |||
| 353 | // handle LED indicators | ||
| 354 | static uint8_t prev_leds = 0; | ||
| 355 | if (prev_leds != usb_keyboard_leds) { | ||
| 356 | uint8_t leds = 0; | ||
| 357 | if (usb_keyboard_leds&(1<<USB_LED_SCROLL_LOCK)) | ||
| 358 | leds |= (1<<PS2_LED_SCROLL_LOCK); | ||
| 359 | if (usb_keyboard_leds&(1<<USB_LED_NUM_LOCK)) | ||
| 360 | leds |= (1<<PS2_LED_NUM_LOCK); | ||
| 361 | if (usb_keyboard_leds&(1<<USB_LED_CAPS_LOCK)) | ||
| 362 | leds |= (1<<PS2_LED_CAPS_LOCK); | ||
| 363 | |||
| 364 | ps2_set_leds(leds); | ||
| 365 | prev_leds = usb_keyboard_leds; | ||
| 366 | } | ||
| 367 | |||
| 368 | return 1; | 336 | return 1; |
| 369 | } | 337 | } |
| 370 | 338 | ||
| @@ -472,19 +440,3 @@ static void matrix_break(uint8_t code) | |||
| 472 | is_modified = true; | 440 | is_modified = true; |
| 473 | } | 441 | } |
| 474 | } | 442 | } |
| 475 | |||
| 476 | static void ps2_reset(void) | ||
| 477 | { | ||
| 478 | ps2_host_send(0xFF); | ||
| 479 | ps2_host_recv(); // 0xFA | ||
| 480 | ps2_host_recv(); // 0xAA | ||
| 481 | _delay_ms(1000); | ||
| 482 | } | ||
| 483 | |||
| 484 | static void ps2_set_leds(uint8_t leds) | ||
| 485 | { | ||
| 486 | ps2_host_send(0xED); | ||
| 487 | ps2_host_recv(); // 0xFA | ||
| 488 | ps2_host_send(leds); | ||
| 489 | ps2_host_recv(); // 0xFA | ||
| 490 | } | ||
