From 1ad31539a6e27d55af374cc8ad55194227db35dd Mon Sep 17 00:00:00 2001 From: tmk Date: Sat, 8 Oct 2016 10:59:49 +0900 Subject: [PATCH 1/1] Fix matrix.c to use new default impl. --- converter/adb_usb/matrix.c | 114 +------------------------------- converter/ibm4704_usb/matrix.c | 28 -------- converter/m0110_usb/matrix.c | 48 -------------- converter/news_usb/matrix.c | 54 --------------- converter/next_usb/matrix.c | 32 --------- converter/pc98_usb/matrix.c | 54 --------------- converter/sun_usb/matrix.c | 56 +--------------- converter/terminal_usb/matrix.c | 86 ------------------------ converter/x68k_usb/matrix.c | 48 -------------- converter/xt_usb/matrix.c | 86 ------------------------ keyboard/alps64/matrix.c | 28 -------- keyboard/gh60/matrix.c | 43 ------------ keyboard/hbkb/matrix.c | 59 ----------------- keyboard/hhkb/matrix.c | 41 ------------ keyboard/onekey/matrix.c | 43 ------------ 15 files changed, 4 insertions(+), 816 deletions(-) diff --git a/converter/adb_usb/matrix.c b/converter/adb_usb/matrix.c index 6190c71a..8f6a0dc9 100644 --- a/converter/adb_usb/matrix.c +++ b/converter/adb_usb/matrix.c @@ -31,44 +31,18 @@ along with this program. If not, see . #include "host.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 static bool has_media_keys = false; static bool is_iso_layout = false; -static bool is_modified = false; static report_mouse_t mouse_report = {}; // matrix state buffer(1:on, 0:off) -#if (MATRIX_COLS <= 8) -static uint8_t matrix[MATRIX_ROWS]; -#else -static uint16_t matrix[MATRIX_ROWS]; -#endif +static matrix_row_t matrix[MATRIX_ROWS]; -#ifdef MATRIX_HAS_GHOST -static bool matrix_has_ghost_in_row(uint8_t row); -#endif static void register_key(uint8_t key); -inline -uint8_t matrix_rows(void) -{ - return MATRIX_ROWS; -} - -inline -uint8_t matrix_cols(void) -{ - return MATRIX_COLS; -} - void matrix_init(void) { // LED on @@ -208,8 +182,6 @@ uint8_t matrix_scan(void) uint16_t codes; uint8_t key0, key1; - is_modified = false; - codes = extra_key; extra_key = 0xFFFF; @@ -328,93 +300,12 @@ uint8_t matrix_scan(void) return 1; } -bool matrix_is_modified(void) -{ - return is_modified; -} - -inline -bool matrix_has_ghost(void) -{ -#ifdef MATRIX_HAS_GHOST - for (uint8_t i = 0; i < MATRIX_ROWS; i++) { - if (matrix_has_ghost_in_row(i)) - return true; - } -#endif - return false; -} - -inline -bool matrix_is_on(uint8_t row, uint8_t col) -{ - return (matrix[row] & (1<>3)&0xF) #define COL(code) (code&0x07) -static bool is_modified = false; - - -inline -uint8_t matrix_rows(void) -{ - return MATRIX_ROWS; -} - -inline -uint8_t matrix_cols(void) -{ - return MATRIX_COLS; -} void matrix_init(void) { @@ -74,8 +60,6 @@ void matrix_init(void) uint8_t matrix_scan(void) { - is_modified = false; - uint8_t code; code = news_recv(); if (code == 0) { @@ -87,56 +71,18 @@ uint8_t matrix_scan(void) // break code if (matrix_is_on(ROW(code), COL(code))) { matrix[ROW(code)] &= ~(1<>3)&0xF) #define COL(code) (code&0x07) -static bool is_modified = false; - - -inline -uint8_t matrix_rows(void) -{ - return MATRIX_ROWS; -} - -inline -uint8_t matrix_cols(void) -{ - return MATRIX_COLS; -} static void pc98_inhibit_repeat(void) { @@ -128,8 +114,6 @@ void matrix_init(void) uint8_t matrix_scan(void) { - is_modified = false; - uint16_t code; PC98_RDY_PORT |= (1<. #include "matrix.h" #include "debug.h" #include "protocol/serial.h" +#include "led.h" +#include "host.h" /* @@ -46,20 +48,6 @@ static uint8_t matrix[MATRIX_ROWS]; #define ROW(code) ((code>>3)&0xF) #define COL(code) (code&0x07) -static bool is_modified = false; - - -inline -uint8_t matrix_rows(void) -{ - return MATRIX_ROWS; -} - -inline -uint8_t matrix_cols(void) -{ - return MATRIX_COLS; -} void matrix_init(void) { @@ -92,8 +80,6 @@ void matrix_init(void) uint8_t matrix_scan(void) { - is_modified = false; - uint8_t code; code = serial_recv(); if (!code) return 0; @@ -131,56 +117,18 @@ uint8_t matrix_scan(void) // break code if (matrix_is_on(ROW(code), COL(code))) { matrix[ROW(code)] &= ~(1<. static void matrix_make(uint8_t code); static void matrix_break(uint8_t code); -#ifdef MATRIX_HAS_GHOST -static bool matrix_has_ghost_in_row(uint8_t row); -#endif /* @@ -49,20 +46,6 @@ static uint8_t matrix[MATRIX_ROWS]; #define ROW(code) (code>>3) #define COL(code) (code&0x07) -static bool is_modified = false; - - -inline -uint8_t matrix_rows(void) -{ - return MATRIX_ROWS; -} - -inline -uint8_t matrix_cols(void) -{ - return MATRIX_COLS; -} void matrix_init(void) { @@ -93,8 +76,6 @@ uint8_t matrix_scan(void) F0, } state = RESET; - is_modified = false; - uint8_t code; if ((code = ps2_host_recv())) { debug("r"); debug_hex(code); debug(" "); @@ -172,83 +153,17 @@ uint8_t matrix_scan(void) return 1; } -bool matrix_is_modified(void) -{ - return is_modified; -} - -inline -bool matrix_has_ghost(void) -{ -#ifdef MATRIX_HAS_GHOST - for (uint8_t i = 0; i < MATRIX_ROWS; i++) { - if (matrix_has_ghost_in_row(i)) - return true; - } -#endif - return false; -} - -inline -bool matrix_is_on(uint8_t row, uint8_t col) -{ - return (matrix[row] & (1<. static void matrix_make(uint8_t code); static void matrix_break(uint8_t code); -#ifdef MATRIX_HAS_GHOST -static bool matrix_has_ghost_in_row(uint8_t row); -#endif static uint8_t matrix[MATRIX_ROWS]; #define ROW(code) (code>>3) @@ -40,20 +37,6 @@ static uint8_t matrix[MATRIX_ROWS]; #define PRINT_SCREEN (0x7C) #define PAUSE (0x7D) -static bool is_modified = false; - - -inline -uint8_t matrix_rows(void) -{ - return MATRIX_ROWS; -} - -inline -uint8_t matrix_cols(void) -{ - return MATRIX_COLS; -} void matrix_init(void) { @@ -131,8 +114,6 @@ uint8_t matrix_scan(void) } state = INIT; - is_modified = false; - // 'pseudo break code' hack if (matrix_is_on(ROW(PAUSE), COL(PAUSE))) { matrix_break(PAUSE); @@ -236,83 +217,17 @@ uint8_t matrix_scan(void) return 1; } -bool matrix_is_modified(void) -{ - return is_modified; -} - -inline -bool matrix_has_ghost(void) -{ -#ifdef MATRIX_HAS_GHOST - for (uint8_t i = 0; i < MATRIX_ROWS; i++) { - if (matrix_has_ghost_in_row(i)) - return true; - } -#endif - return false; -} - -inline -bool matrix_is_on(uint8_t row, uint8_t col) -{ - return (matrix[row] & (1<