]> git.donarmstrong.com Git - tmk_firmware.git/commitdiff
Fix ghost block and remove matrix_has_ghost()
authortmk <nobody@nowhere>
Tue, 5 Mar 2013 10:18:01 +0000 (19:18 +0900)
committertmk <nobody@nowhere>
Tue, 5 Mar 2013 12:08:16 +0000 (21:08 +0900)
common/keyboard.c
common/matrix.h
keyboard/hbkb/Makefile.lufa
keyboard/hbkb/matrix.c

index 432ea89347622bdbd7e93f09ce9ea947554a7bc5..91f321d9ca24b02838b38cc89bc6005544c8cebc 100644 (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){
index b3332d5ff91ca3132cc5524a4b6485df568d5b0c..48203c71dcd26771e0489d39993754f47d1dd02c 100644 (file)
@@ -45,8 +45,6 @@ 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 */
index c73a0ca7d1e0de946c6ee57308d200231ebced1e..33366d720889c889db972bc5c509d9c59e590f83 100644 (file)
@@ -99,6 +99,7 @@ F_USB = $(F_CPU)
 #
 MOUSEKEY_ENABLE = yes  # Mouse keys
 EXTRAKEY_ENABLE = yes  # Audio control and System control
+CONSOLE_ENABLE = yes   # Console for debug
 #NKRO_ENABLE = yes     # USB Nkey Rollover
 #PS2_MOUSE_ENABLE = yes        # PS/2 mouse(TrackPoint) support
 
index d7c06636420532ebe84bb229ac08a48b22964a3e..f3a0cde5f3f6117805f3210a8afe0e9242ec9bf1 100644 (file)
@@ -147,18 +147,6 @@ bool matrix_is_modified(void)
     return false;
 }
 
-inline
-bool matrix_has_ghost(void)
-{
-#ifdef MATRIX_HAS_GHOST
-    for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
-        if (matrix_has_ghost_in_row(i))
-            return true;
-    }
-#endif
-    return false;
-}
-
 inline
 bool matrix_is_on(uint8_t row, uint8_t col)
 {
@@ -217,7 +205,8 @@ static bool matrix_has_ghost_in_row(uint8_t row)
 
     // ghost exists in case same state as other row
     for (uint8_t i=0; i < MATRIX_ROWS; i++) {
-        if (i != row && (matrix[i] & matrix[row]) == matrix[row])
+        //if (i != row && (matrix[i] & matrix[row]) == matrix[row])
+        if (i != row && (matrix[i] & matrix[row]))
             return true;
     }
     return false;