diff options
author | tmk <nobody@nowhere> | 2010-10-24 03:27:43 +0900 |
---|---|---|
committer | tmk <nobody@nowhere> | 2010-10-24 03:33:08 +0900 |
commit | 4acc38751e9c8e90921773e6e5f5a100b0729d98 (patch) | |
tree | e8e650c6c0557871f55c39b6449a0cc2479fbf58 /hhkb/matrix.c | |
parent | bf92bdd7fa9938c162c29e565d245e5609e4a912 (diff) |
switch debug on/off by pressing 4 keys on booting time
Diffstat (limited to 'hhkb/matrix.c')
-rw-r--r-- | hhkb/matrix.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/hhkb/matrix.c b/hhkb/matrix.c index a1917793e7..a425439cca 100644 --- a/hhkb/matrix.c +++ b/hhkb/matrix.c @@ -32,6 +32,7 @@ static uint8_t _matrix1[MATRIX_ROWS]; static bool matrix_has_ghost_in_row(int row); +static int bit_pop(uint8_t bits); inline @@ -88,7 +89,7 @@ int matrix_scan(void) } bool matrix_is_modified(void) { - for (int i=0; i <MATRIX_ROWS; i++) { + for (int i = 0; i < MATRIX_ROWS; i++) { if (matrix[i] != matrix_prev[i]) return true; } @@ -117,7 +118,22 @@ void matrix_print(void) { } } +int matrix_key_count(void) { + int count = 0; + for (int i = 0; i < MATRIX_ROWS; i++) { + count += bit_pop(~matrix[i]); + } + return count; +} + inline static bool matrix_has_ghost_in_row(int row) { return false; } + +static int bit_pop(uint8_t bits) { + int c; + for (c = 0; bits; c++) + bits &= bits -1; + return c; +} |