diff options
| author | tmk <nobody@nowhere> | 2013-03-05 19:18:01 +0900 |
|---|---|---|
| committer | tmk <nobody@nowhere> | 2013-03-05 21:08:16 +0900 |
| commit | 9e9a85c1426650148d0d83c900e432003ff174fb (patch) | |
| tree | 8518cbbb2a1c864a076d1d17758d8584ec367cd2 /common/keyboard.c | |
| parent | 38bbe976e00a9a7bf6f8157016717e80503bf6a9 (diff) | |
| download | qmk_firmware-9e9a85c1426650148d0d83c900e432003ff174fb.tar.gz qmk_firmware-9e9a85c1426650148d0d83c900e432003ff174fb.zip | |
Fix ghost block and remove matrix_has_ghost()
Diffstat (limited to 'common/keyboard.c')
| -rw-r--r-- | common/keyboard.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/common/keyboard.c b/common/keyboard.c index 432ea8934..91f321d9c 100644 --- a/common/keyboard.c +++ b/common/keyboard.c | |||
| @@ -34,6 +34,24 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 34 | #endif | 34 | #endif |
| 35 | 35 | ||
| 36 | 36 | ||
| 37 | #ifdef MATRIX_HAS_GHOST | ||
| 38 | static bool has_ghost_in_row(uint8_t row) | ||
| 39 | { | ||
| 40 | matrix_row_t matrix_row = matrix_get_row(row); | ||
| 41 | // No ghost exists when less than 2 keys are down on the row | ||
| 42 | if (((matrix_row - 1) & matrix_row) == 0) | ||
| 43 | return false; | ||
| 44 | |||
| 45 | // Ghost occurs when the row shares column line with other row | ||
| 46 | for (uint8_t i=0; i < MATRIX_ROWS; i++) { | ||
| 47 | if (i != row && (matrix_get_row(i) & matrix_row)) | ||
| 48 | return true; | ||
| 49 | } | ||
| 50 | return false; | ||
| 51 | } | ||
| 52 | #endif | ||
| 53 | |||
| 54 | |||
| 37 | void keyboard_init(void) | 55 | void keyboard_init(void) |
| 38 | { | 56 | { |
| 39 | // TODO: configuration of sendchar impl | 57 | // TODO: configuration of sendchar impl |
| @@ -81,7 +99,12 @@ void keyboard_task(void) | |||
| 81 | matrix_change = matrix_row ^ matrix_prev[r]; | 99 | matrix_change = matrix_row ^ matrix_prev[r]; |
| 82 | if (matrix_change) { | 100 | if (matrix_change) { |
| 83 | if (debug_matrix) matrix_print(); | 101 | if (debug_matrix) matrix_print(); |
| 84 | 102 | #ifdef MATRIX_HAS_GHOST | |
| 103 | if (has_ghost_in_row(r)) { | ||
| 104 | matrix_prev[r] = matrix_row; | ||
| 105 | continue; | ||
| 106 | } | ||
| 107 | #endif | ||
| 85 | for (uint8_t c = 0; c < MATRIX_COLS; c++) { | 108 | for (uint8_t c = 0; c < MATRIX_COLS; c++) { |
| 86 | if (matrix_change & ((matrix_row_t)1<<c)) { | 109 | if (matrix_change & ((matrix_row_t)1<<c)) { |
| 87 | action_exec((keyevent_t){ | 110 | action_exec((keyevent_t){ |
