Browse Source

Merge branch 'ghost_fix'

core
tmk 11 years ago
parent
commit
96160e1409
2 changed files with 24 additions and 5 deletions
  1. 24
    1
      common/keyboard.c
  2. 0
    4
      common/matrix.h

+ 24
- 1
common/keyboard.c View File

@@ -34,6 +34,24 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#endif


#ifdef MATRIX_HAS_GHOST
static bool has_ghost_in_row(uint8_t row)
{
matrix_row_t matrix_row = matrix_get_row(row);
// No ghost exists when less than 2 keys are down on the row
if (((matrix_row - 1) & matrix_row) == 0)
return false;

// Ghost occurs when the row shares column line with other row
for (uint8_t i=0; i < MATRIX_ROWS; i++) {
if (i != row && (matrix_get_row(i) & matrix_row))
return true;
}
return false;
}
#endif


void keyboard_init(void)
{
// TODO: configuration of sendchar impl
@@ -81,7 +99,12 @@ void keyboard_task(void)
matrix_change = matrix_row ^ matrix_prev[r];
if (matrix_change) {
if (debug_matrix) matrix_print();

#ifdef MATRIX_HAS_GHOST
if (has_ghost_in_row(r)) {
matrix_prev[r] = matrix_row;
continue;
}
#endif
for (uint8_t c = 0; c < MATRIX_COLS; c++) {
if (matrix_change & ((matrix_row_t)1<<c)) {
action_exec((keyevent_t){

+ 0
- 4
common/matrix.h View File

@@ -45,14 +45,10 @@ void matrix_init(void);
uint8_t matrix_scan(void);
/* whether modified from previous scan. used after matrix_scan. */
bool matrix_is_modified(void);
/* whether ghosting occur on matrix. */
bool matrix_has_ghost(void);
/* whether a swtich is on */
bool matrix_is_on(uint8_t row, uint8_t col);
/* matrix state on row */
matrix_row_t matrix_get_row(uint8_t row);
/* count keys pressed */
uint8_t matrix_key_count(void);
/* print matrix for debug */
void matrix_print(void);