diff options
Diffstat (limited to 'tmk_core/common/action.c')
| -rw-r--r-- | tmk_core/common/action.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/tmk_core/common/action.c b/tmk_core/common/action.c index 77ea39e94..be06e12aa 100644 --- a/tmk_core/common/action.c +++ b/tmk_core/common/action.c | |||
| @@ -53,6 +53,26 @@ void action_exec(keyevent_t event) | |||
| 53 | #endif | 53 | #endif |
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | /* | ||
| 57 | * Make sure the action triggered when the key is released is the same | ||
| 58 | * one as the one triggered on press. It's important for the mod keys | ||
| 59 | * when the layer is switched after the down event but before the up | ||
| 60 | * event as they may get stuck otherwise. | ||
| 61 | */ | ||
| 62 | action_t store_or_get_action(bool pressed, keypos_t key) | ||
| 63 | { | ||
| 64 | #ifndef NO_ACTION_LAYER | ||
| 65 | static action_t pressed_actions[MATRIX_ROWS][MATRIX_COLS]; | ||
| 66 | |||
| 67 | if (pressed) { | ||
| 68 | pressed_actions[key.row][key.col] = layer_switch_get_action(key); | ||
| 69 | } | ||
| 70 | return pressed_actions[key.row][key.col]; | ||
| 71 | #else | ||
| 72 | return layer_switch_get_action(key); | ||
| 73 | #endif | ||
| 74 | } | ||
| 75 | |||
| 56 | void process_action(keyrecord_t *record) | 76 | void process_action(keyrecord_t *record) |
| 57 | { | 77 | { |
| 58 | keyevent_t event = record->event; | 78 | keyevent_t event = record->event; |
| @@ -62,7 +82,7 @@ void process_action(keyrecord_t *record) | |||
| 62 | 82 | ||
| 63 | if (IS_NOEVENT(event)) { return; } | 83 | if (IS_NOEVENT(event)) { return; } |
| 64 | 84 | ||
| 65 | action_t action = layer_switch_get_action(event.key); | 85 | action_t action = store_or_get_action(event.pressed, event.key); |
| 66 | dprint("ACTION: "); debug_action(action); | 86 | dprint("ACTION: "); debug_action(action); |
| 67 | #ifndef NO_ACTION_LAYER | 87 | #ifndef NO_ACTION_LAYER |
| 68 | dprint(" layer_state: "); layer_debug(); | 88 | dprint(" layer_state: "); layer_debug(); |
