summaryrefslogtreecommitdiff
path: root/keyboard/hhkb
diff options
context:
space:
mode:
authortmk <nobody@nowhere>2012-10-06 02:23:12 +0900
committertmk <nobody@nowhere>2012-10-17 15:55:37 +0900
commit4ae979f6ef8dbf9e1d1f35be15322ad6d02e2958 (patch)
tree9f5132005c27ef04ae793b77d4699cb285479466 /keyboard/hhkb
parent93e33fb8f694c9685accd72ed0458a2cf3d3f04a (diff)
Initial version of new code for layer switch is added.
Diffstat (limited to 'keyboard/hhkb')
-rw-r--r--keyboard/hhkb/config.h2
-rw-r--r--keyboard/hhkb/keymap.c8
-rw-r--r--keyboard/hhkb/matrix.c50
3 files changed, 10 insertions, 50 deletions
diff --git a/keyboard/hhkb/config.h b/keyboard/hhkb/config.h
index bf946ac01e..17a4494065 100644
--- a/keyboard/hhkb/config.h
+++ b/keyboard/hhkb/config.h
@@ -35,8 +35,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* matrix size */
#define MATRIX_ROWS 8
#define MATRIX_COLS 8
-/* define if matrix has ghost */
-//#define MATRIX_HAS_GHOST
/* key combination for command */
diff --git a/keyboard/hhkb/keymap.c b/keyboard/hhkb/keymap.c
index f05962aed6..43f777c564 100644
--- a/keyboard/hhkb/keymap.c
+++ b/keyboard/hhkb/keymap.c
@@ -210,12 +210,12 @@ uint8_t keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t col)
return KEYCODE(layer, row, col);
}
-uint8_t keymap_fn_layer(uint8_t fn_bits)
+uint8_t keymap_fn_layer(uint8_t index)
{
- return pgm_read_byte(&fn_layer[biton(fn_bits)]);
+ return pgm_read_byte(&fn_layer[index]);
}
-uint8_t keymap_fn_keycode(uint8_t fn_bits)
+uint8_t keymap_fn_keycode(uint8_t index)
{
- return pgm_read_byte(&fn_keycode[(biton(fn_bits))]);
+ return pgm_read_byte(&fn_keycode[index]);
}
diff --git a/keyboard/hhkb/matrix.c b/keyboard/hhkb/matrix.c
index 79d2d98731..3bd6e73b35 100644
--- a/keyboard/hhkb/matrix.c
+++ b/keyboard/hhkb/matrix.c
@@ -43,22 +43,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// matrix state buffer(1:on, 0:off)
-#if (MATRIX_COLS <= 8)
-static uint8_t *matrix;
-static uint8_t *matrix_prev;
-static uint8_t _matrix0[MATRIX_ROWS];
-static uint8_t _matrix1[MATRIX_ROWS];
-#else
-static uint16_t *matrix;
-static uint16_t *matrix_prev;
-static uint16_t _matrix0[MATRIX_ROWS];
-static uint16_t _matrix1[MATRIX_ROWS];
-#endif
-
-// HHKB has no ghost and no bounce.
-#ifdef MATRIX_HAS_GHOST
-static bool matrix_has_ghost_in_row(uint8_t row);
-#endif
+static matrix_row_t *matrix;
+static matrix_row_t *matrix_prev;
+static matrix_row_t _matrix0[MATRIX_ROWS];
+static matrix_row_t _matrix1[MATRIX_ROWS];
// Matrix I/O ports
@@ -192,6 +180,8 @@ uint8_t matrix_scan(void)
}
// Ignore if this code region execution time elapses more than 20us.
+ // MEMO: 20[us] * (TIMER_RAW_FREQ / 1000000)[count per us]
+ // MEMO: then change above using this rule: a/(b/c) = a*1/(b/c) = a*(c/b)
if (TIMER_DIFF_RAW(TIMER_RAW, last) > 20/(1000000/TIMER_RAW_FREQ)) {
matrix[row] = matrix_prev[row];
}
@@ -219,12 +209,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;
}
@@ -258,11 +242,6 @@ void matrix_print(void)
#else
pbin_reverse16(matrix_get_row(row));
#endif
-#ifdef MATRIX_HAS_GHOST
- if (matrix_has_ghost_in_row(row)) {
- print(" <ghost");
- }
-#endif
print("\n");
}
}
@@ -279,20 +258,3 @@ uint8_t matrix_key_count(void)
}
return count;
}
-
-#ifdef MATRIX_HAS_GHOST
-inline
-static bool matrix_has_ghost_in_row(uint8_t row)
-{
- // no ghost exists in case less than 2 keys on
- if (((matrix[row] - 1) & matrix[row]) == 0)
- return false;
-
- // 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])
- return true;
- }
- return false;
-}
-#endif