summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortmk <nobody@nowhere>2013-03-05 19:18:01 +0900
committertmk <nobody@nowhere>2013-03-05 21:08:16 +0900
commit9e9a85c1426650148d0d83c900e432003ff174fb (patch)
tree8518cbbb2a1c864a076d1d17758d8584ec367cd2
parent38bbe976e00a9a7bf6f8157016717e80503bf6a9 (diff)
downloadqmk_firmware-9e9a85c1426650148d0d83c900e432003ff174fb.tar.gz
qmk_firmware-9e9a85c1426650148d0d83c900e432003ff174fb.zip
Fix ghost block and remove matrix_has_ghost()
-rw-r--r--common/keyboard.c25
-rw-r--r--common/matrix.h2
-rw-r--r--keyboard/hbkb/Makefile.lufa1
-rw-r--r--keyboard/hbkb/matrix.c15
4 files changed, 27 insertions, 16 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){
diff --git a/common/matrix.h b/common/matrix.h
index b3332d5ff9..48203c71dc 100644
--- a/common/matrix.h
+++ b/common/matrix.h
@@ -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 */
diff --git a/keyboard/hbkb/Makefile.lufa b/keyboard/hbkb/Makefile.lufa
index c73a0ca7d1..33366d7208 100644
--- a/keyboard/hbkb/Makefile.lufa
+++ b/keyboard/hbkb/Makefile.lufa
@@ -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
diff --git a/keyboard/hbkb/matrix.c b/keyboard/hbkb/matrix.c
index d7c0663642..f3a0cde5f3 100644
--- a/keyboard/hbkb/matrix.c
+++ b/keyboard/hbkb/matrix.c
@@ -148,18 +148,6 @@ bool matrix_is_modified(void)
}
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)
{
return (matrix[row] & (1<<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;