diff options
| author | Wojciech Siewierski <wojciech.siewierski@onet.pl> | 2016-03-05 14:42:17 +0100 |
|---|---|---|
| committer | Wojciech Siewierski <wojciech.siewierski@onet.pl> | 2016-03-05 14:42:17 +0100 |
| commit | c2480884aa1321ec4a0364f773476f0e7f7d3069 (patch) | |
| tree | fbda4c0b773e48c78378485ab746bf84e2b74739 /tmk_core/common/action.c | |
| parent | 4e4250063ed3f9fcaa3448715d28f7a815f7cc7e (diff) | |
| download | qmk_firmware-c2480884aa1321ec4a0364f773476f0e7f7d3069.tar.gz qmk_firmware-c2480884aa1321ec4a0364f773476f0e7f7d3069.zip | |
Fix the layer-dependent modifiers handling
Closes #181.
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(); |
