/* * scan matrix */ #include #include #include #include #include "print.h" #include "util.h" #include "debug.h" #include "ps2.h" #include "usb_keyboard.h" #include "matrix_skel.h" #if (MATRIX_COLS > 16) # error "MATRIX_COLS must not exceed 16" #endif #if (MATRIX_ROWS > 255) # error "MATRIX_ROWS must not exceed 255" #endif /* * Matrix usage: * "PS/2 Scan Codes Set 2" is assigned to 256(32x8)cells matrix. * Hmm, It is very sparse and not efficient :( * * 8bit * --------- * 0| | * :| XX | 00-7F for normal codes * f|_________| * 10| | * :| E0 XX | 80-FF for E0-prefix codes(use (XX|0x80) as code) * 1f| | * --------- * exceptions: * 0x83: F8(normal code placed beyond 0x7F) * 0xFE: PrintScreen * 0xFF: Puause/Break */ #define _PRINT_SCREEN (0xFE) #define _PAUSE_BREAK (0xFF) #define _ROW(code) (code>>3) #define _COL(code) (code&0x07) static bool _matrix_is_modified = false; // matrix state buffer(1:on, 0:off) #if (MATRIX_COLS <= 8) static uint8_t *matrix; static uint8_t _matrix0[MATRIX_ROWS]; #else static uint16_t *matrix; static uint16_t _matrix0[MATRIX_ROWS]; #endif #ifdef MATRIX_HAS_GHOST static bool matrix_has_ghost_in_row(uint8_t row); #endif static void _matrix_make(uint8_t code); static void _matrix_break(uint8_t code); static void _ps2_reset(void); static void _ps2_set_leds(uint8_t leds); inline uint8_t matrix_rows(void) { return MATRIX_ROWS; } inline uint8_t matrix_cols(void) { return MATRIX_COLS; } void matrix_init(void) { print_enable = true; ps2_host_init(); _ps2_reset(); // flush LEDs _ps2_set_leds(1<