Use physical position of keys for config reset

This commit is contained in:
Tim Crawford 2020-10-01 12:16:14 -06:00 committed by Jeremy Soller
parent 9afec7af27
commit 39e2586c50
9 changed files with 78 additions and 4 deletions

View File

@ -46,4 +46,12 @@
// Keymap // Keymap
extern uint16_t __xdata KEYMAP[KM_LAY][KM_OUT][KM_IN]; extern uint16_t __xdata KEYMAP[KM_LAY][KM_OUT][KM_IN];
// Position of physical Esc key in the matrix
#define MATRIX_ESC_INPUT 7
#define MATRIX_ESC_OUTPUT 7
// Position of physical Fn key in the matrix
#define MATRIX_FN_INPUT 3
#define MATRIX_FN_OUTPUT 17
#endif // _BOARD_KEYMAP_H #endif // _BOARD_KEYMAP_H

View File

@ -48,4 +48,12 @@
// Keymap // Keymap
extern uint16_t __xdata KEYMAP[KM_LAY][KM_OUT][KM_IN]; extern uint16_t __xdata KEYMAP[KM_LAY][KM_OUT][KM_IN];
// Position of physical Esc key in the matrix
#define MATRIX_ESC_INPUT 0
#define MATRIX_ESC_OUTPUT 6
// Position of physical Fn key in the matrix
#define MATRIX_FN_INPUT 0
#define MATRIX_FN_OUTPUT 4
#endif // _BOARD_KEYMAP_H #endif // _BOARD_KEYMAP_H

View File

@ -27,6 +27,14 @@ uint16_t kbscan_repeat_delay = 500;
uint8_t sci_extra = 0; uint8_t sci_extra = 0;
static inline bool matrix_position_is_esc(int row, int col) {
return (row == MATRIX_ESC_OUTPUT) && (col == MATRIX_ESC_INPUT);
}
static inline bool matrix_position_is_fn(int row, int col) {
return (row == MATRIX_FN_OUTPUT) && (col == MATRIX_FN_INPUT);
}
void kbscan_init(void) { void kbscan_init(void) {
KSOCTRL = 0x05; KSOCTRL = 0x05;
KSICTRLR = 0x04; KSICTRLR = 0x04;
@ -185,16 +193,12 @@ bool kbscan_press(uint16_t key, bool pressed, uint8_t * layer) {
case (KT_NORMAL): case (KT_NORMAL):
if (kbscan_enabled) { if (kbscan_enabled) {
kbc_scancode(&KBC, key, pressed); kbc_scancode(&KBC, key, pressed);
if ((key & 0xFF) == K_ESC)
kbscan_esc_held = pressed;
} }
break; break;
case (KT_FN): case (KT_FN):
if (layer != NULL) { if (layer != NULL) {
if (pressed) *layer = 1; if (pressed) *layer = 1;
else *layer = 0; else *layer = 0;
kbscan_fn_held = pressed;
} else { } else {
// In the case no layer can be set, reset bit // In the case no layer can be set, reset bit
return false; return false;
@ -332,6 +336,12 @@ void kbscan_event(void) {
debounce = true; debounce = true;
debounce_time = time_get(); debounce_time = time_get();
// Check keys used for config reset
if (matrix_position_is_esc(i, j))
kbscan_esc_held = new_b;
if (matrix_position_is_fn(i, j))
kbscan_fn_held = new_b;
// Handle key press/release // Handle key press/release
if (new_b) { if (new_b) {
// On a press, cache the layer the key was pressed on // On a press, cache the layer the key was pressed on

View File

@ -46,4 +46,12 @@
// Keymap // Keymap
extern uint16_t __xdata KEYMAP[KM_LAY][KM_OUT][KM_IN]; extern uint16_t __xdata KEYMAP[KM_LAY][KM_OUT][KM_IN];
// Position of physical Esc key in the matrix
#define MATRIX_ESC_INPUT 7
#define MATRIX_ESC_OUTPUT 7
// Position of physical Fn key in the matrix
#define MATRIX_FN_INPUT 3
#define MATRIX_FN_OUTPUT 17
#endif // _BOARD_KEYMAP_H #endif // _BOARD_KEYMAP_H

View File

@ -44,4 +44,12 @@
// Keymap // Keymap
extern uint16_t __xdata KEYMAP[KM_LAY][KM_OUT][KM_IN]; extern uint16_t __xdata KEYMAP[KM_LAY][KM_OUT][KM_IN];
// Position of physical Esc key in the matrix
#define MATRIX_ESC_INPUT 7
#define MATRIX_ESC_OUTPUT 7
// Position of physical Fn key in the matrix
#define MATRIX_FN_INPUT 0
#define MATRIX_FN_OUTPUT 6
#endif // _BOARD_KEYMAP_H #endif // _BOARD_KEYMAP_H

View File

@ -46,4 +46,12 @@
// Keymap // Keymap
extern uint16_t __xdata KEYMAP[KM_LAY][KM_OUT][KM_IN]; extern uint16_t __xdata KEYMAP[KM_LAY][KM_OUT][KM_IN];
// Position of physical Esc key in the matrix
#define MATRIX_ESC_INPUT 7
#define MATRIX_ESC_OUTPUT 7
// Position of physical Fn key in the matrix
#define MATRIX_FN_INPUT 3
#define MATRIX_FN_OUTPUT 17
#endif // _BOARD_KEYMAP_H #endif // _BOARD_KEYMAP_H

View File

@ -45,4 +45,12 @@
// Keymap // Keymap
extern uint16_t __xdata KEYMAP[KM_LAY][KM_OUT][KM_IN]; extern uint16_t __xdata KEYMAP[KM_LAY][KM_OUT][KM_IN];
// Position of physical Esc key in the matrix
#define MATRIX_ESC_INPUT 7
#define MATRIX_ESC_OUTPUT 7
// Position of physical Fn key in the matrix
#define MATRIX_FN_INPUT 0
#define MATRIX_FN_OUTPUT 6
#endif // _BOARD_KEYMAP_H #endif // _BOARD_KEYMAP_H

View File

@ -46,4 +46,12 @@
// Keymap // Keymap
extern uint16_t __xdata KEYMAP[KM_LAY][KM_OUT][KM_IN]; extern uint16_t __xdata KEYMAP[KM_LAY][KM_OUT][KM_IN];
// Position of physical Esc key in the matrix
#define MATRIX_ESC_INPUT 7
#define MATRIX_ESC_OUTPUT 7
// Position of physical Fn key in the matrix
#define MATRIX_FN_INPUT 3
#define MATRIX_FN_OUTPUT 17
#endif // _BOARD_KEYMAP_H #endif // _BOARD_KEYMAP_H

View File

@ -46,4 +46,12 @@
// Keymap // Keymap
extern uint16_t __xdata KEYMAP[KM_LAY][KM_OUT][KM_IN]; extern uint16_t __xdata KEYMAP[KM_LAY][KM_OUT][KM_IN];
// Position of physical Esc key in the matrix
#define MATRIX_ESC_INPUT 7
#define MATRIX_ESC_OUTPUT 7
// Position of physical Fn key in the matrix
#define MATRIX_FN_INPUT 3
#define MATRIX_FN_OUTPUT 17
#endif // _BOARD_KEYMAP_H #endif // _BOARD_KEYMAP_H