diff options
Diffstat (limited to 'm0110_usb/matrix.c')
| -rw-r--r-- | m0110_usb/matrix.c | 49 |
1 files changed, 2 insertions, 47 deletions
diff --git a/m0110_usb/matrix.c b/m0110_usb/matrix.c index b28045b9c..1ca6894c4 100644 --- a/m0110_usb/matrix.c +++ b/m0110_usb/matrix.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | Copyright 2011 Jun Wako <wakojun@gmail.com> | 2 | Copyright 2011,2012 Jun Wako <wakojun@gmail.com> |
| 3 | 3 | ||
| 4 | This program is free software: you can redistribute it and/or modify | 4 | This program is free software: you can redistribute it and/or modify |
| 5 | it under the terms of the GNU General Public License as published by | 5 | it under the terms of the GNU General Public License as published by |
| @@ -36,11 +36,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 36 | #define ROW(key) ((key)>>3&0x0F) | 36 | #define ROW(key) ((key)>>3&0x0F) |
| 37 | #define COL(key) ((key)&0x07) | 37 | #define COL(key) ((key)&0x07) |
| 38 | 38 | ||
| 39 | #define ARROW_UP_BREAK (0x4D | 0x80) | ||
| 40 | #define ARROW_DOWN_BREAK (0x48 | 0x80) | ||
| 41 | #define ARROW_LEFT_BREAK (0x46 | 0x80) | ||
| 42 | #define ARROW_RIGHT_BREAK (0x42 | 0x80) | ||
| 43 | |||
| 44 | 39 | ||
| 45 | static bool is_modified = false; | 40 | static bool is_modified = false; |
| 46 | 41 | ||
| @@ -48,9 +43,6 @@ static bool is_modified = false; | |||
| 48 | static uint8_t *matrix; | 43 | static uint8_t *matrix; |
| 49 | static uint8_t _matrix0[MATRIX_ROWS]; | 44 | static uint8_t _matrix0[MATRIX_ROWS]; |
| 50 | 45 | ||
| 51 | #ifdef MATRIX_HAS_GHOST | ||
| 52 | static bool matrix_has_ghost_in_row(uint8_t row); | ||
| 53 | #endif | ||
| 54 | static void register_key(uint8_t key); | 46 | static void register_key(uint8_t key); |
| 55 | 47 | ||
| 56 | 48 | ||
| @@ -100,20 +92,6 @@ uint8_t matrix_scan(void) | |||
| 100 | return 0; | 92 | return 0; |
| 101 | } else if (key == M0110_ERROR) { | 93 | } else if (key == M0110_ERROR) { |
| 102 | return 0; | 94 | return 0; |
| 103 | } else if (key == ARROW_UP_BREAK || | ||
| 104 | key == ARROW_DOWN_BREAK || | ||
| 105 | key == ARROW_LEFT_BREAK || | ||
| 106 | key == ARROW_RIGHT_BREAK) { | ||
| 107 | // WORK AROUND: exceptional handling for M0110A | ||
| 108 | // Unregister both Arrow key and coressponding Calc key when receive Arrow key break. | ||
| 109 | // | ||
| 110 | // Shift + Calc keys(=/*+): | ||
| 111 | // Send no Shift break(0xF1) when release Calc keys. Can't be desinguished from Arrow keys. | ||
| 112 | // (press: 0x71, 0x79, 0xXX release: 0x79, 0xXX) | ||
| 113 | // See m0110.c for key events and scan codes. | ||
| 114 | is_modified = true; | ||
| 115 | register_key(key); | ||
| 116 | register_key(key|M0110_CALC_OFFSET); | ||
| 117 | } else { | 95 | } else { |
| 118 | #ifdef MATRIX_HAS_LOCKING_CAPS | 96 | #ifdef MATRIX_HAS_LOCKING_CAPS |
| 119 | if (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) { | 97 | if (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) { |
| @@ -133,7 +111,7 @@ uint8_t matrix_scan(void) | |||
| 133 | } | 111 | } |
| 134 | 112 | ||
| 135 | if (debug_enable) { | 113 | if (debug_enable) { |
| 136 | print("key: "); phex(key); print("\n"); | 114 | print("["); phex(key); print("]\n"); |
| 137 | } | 115 | } |
| 138 | return 1; | 116 | return 1; |
| 139 | } | 117 | } |
| @@ -146,12 +124,6 @@ bool matrix_is_modified(void) | |||
| 146 | inline | 124 | inline |
| 147 | bool matrix_has_ghost(void) | 125 | bool matrix_has_ghost(void) |
| 148 | { | 126 | { |
| 149 | #ifdef MATRIX_HAS_GHOST | ||
| 150 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
| 151 | if (matrix_has_ghost_in_row(i)) | ||
| 152 | return true; | ||
| 153 | } | ||
| 154 | #endif | ||
| 155 | return false; | 127 | return false; |
| 156 | } | 128 | } |
| 157 | 129 | ||
| @@ -186,23 +158,6 @@ uint8_t matrix_key_count(void) | |||
| 186 | return count; | 158 | return count; |
| 187 | } | 159 | } |
| 188 | 160 | ||
| 189 | #ifdef MATRIX_HAS_GHOST | ||
| 190 | inline | ||
| 191 | static bool matrix_has_ghost_in_row(uint8_t row) | ||
| 192 | { | ||
| 193 | // no ghost exists in case less than 2 keys on | ||
| 194 | if (((matrix[row] - 1) & matrix[row]) == 0) | ||
| 195 | return false; | ||
| 196 | |||
| 197 | // ghost exists in case same state as other row | ||
| 198 | for (uint8_t i=0; i < MATRIX_ROWS; i++) { | ||
| 199 | if (i != row && (matrix[i] & matrix[row]) == matrix[row]) | ||
| 200 | return true; | ||
| 201 | } | ||
| 202 | return false; | ||
| 203 | } | ||
| 204 | #endif | ||
| 205 | |||
| 206 | inline | 161 | inline |
| 207 | static void register_key(uint8_t key) | 162 | static void register_key(uint8_t key) |
| 208 | { | 163 | { |
