summaryrefslogtreecommitdiff
path: root/common/keyboard.c
diff options
context:
space:
mode:
authortmk <nobody@nowhere>2013-03-05 21:46:35 +0900
committertmk <nobody@nowhere>2013-03-05 21:46:35 +0900
commit5d6b848a157a2e94859949961297d40da6a77527 (patch)
tree685ba0477174789f5d64902a5cd96114346aa9d7 /common/keyboard.c
parent38bbe976e00a9a7bf6f8157016717e80503bf6a9 (diff)
parent81d2753ab07890532ea8c4bd6a68de3e5e08ca33 (diff)
Merge branch 'ghost_fix'
Diffstat (limited to 'common/keyboard.c')
-rw-r--r--common/keyboard.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/common/keyboard.c b/common/keyboard.c
index 432ea89347..91f321d9ca 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/>.
#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){