Use physical position of keys for config reset
This commit is contained in:
parent
9afec7af27
commit
39e2586c50
@ -46,4 +46,12 @@
|
||||
// Keymap
|
||||
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
|
||||
|
@ -48,4 +48,12 @@
|
||||
// Keymap
|
||||
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
|
||||
|
@ -27,6 +27,14 @@ uint16_t kbscan_repeat_delay = 500;
|
||||
|
||||
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) {
|
||||
KSOCTRL = 0x05;
|
||||
KSICTRLR = 0x04;
|
||||
@ -185,16 +193,12 @@ bool kbscan_press(uint16_t key, bool pressed, uint8_t * layer) {
|
||||
case (KT_NORMAL):
|
||||
if (kbscan_enabled) {
|
||||
kbc_scancode(&KBC, key, pressed);
|
||||
if ((key & 0xFF) == K_ESC)
|
||||
kbscan_esc_held = pressed;
|
||||
}
|
||||
break;
|
||||
case (KT_FN):
|
||||
if (layer != NULL) {
|
||||
if (pressed) *layer = 1;
|
||||
else *layer = 0;
|
||||
|
||||
kbscan_fn_held = pressed;
|
||||
} else {
|
||||
// In the case no layer can be set, reset bit
|
||||
return false;
|
||||
@ -332,6 +336,12 @@ void kbscan_event(void) {
|
||||
debounce = true;
|
||||
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
|
||||
if (new_b) {
|
||||
// On a press, cache the layer the key was pressed on
|
||||
|
@ -46,4 +46,12 @@
|
||||
// Keymap
|
||||
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
|
||||
|
@ -44,4 +44,12 @@
|
||||
// Keymap
|
||||
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
|
||||
|
@ -46,4 +46,12 @@
|
||||
// Keymap
|
||||
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
|
||||
|
@ -45,4 +45,12 @@
|
||||
// Keymap
|
||||
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
|
||||
|
@ -46,4 +46,12 @@
|
||||
// Keymap
|
||||
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
|
||||
|
@ -46,4 +46,12 @@
|
||||
// Keymap
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user