diff options
Diffstat (limited to 'tmk_core/common/action.c')
| -rw-r--r-- | tmk_core/common/action.c | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/tmk_core/common/action.c b/tmk_core/common/action.c index 2ccc0e0b9..f9e6c17dc 100644 --- a/tmk_core/common/action.c +++ b/tmk_core/common/action.c | |||
| @@ -53,6 +53,22 @@ void action_exec(keyevent_t event) | |||
| 53 | #endif | 53 | #endif |
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | #if !defined(NO_ACTION_LAYER) && defined(PREVENT_STUCK_MODIFIERS) | ||
| 57 | bool disable_action_cache = false; | ||
| 58 | |||
| 59 | void process_action_nocache(keyrecord_t *record) | ||
| 60 | { | ||
| 61 | disable_action_cache = true; | ||
| 62 | process_action(record); | ||
| 63 | disable_action_cache = false; | ||
| 64 | } | ||
| 65 | #else | ||
| 66 | void process_action_nocache(keyrecord_t *record) | ||
| 67 | { | ||
| 68 | process_action(record); | ||
| 69 | } | ||
| 70 | #endif | ||
| 71 | |||
| 56 | __attribute__ ((weak)) | 72 | __attribute__ ((weak)) |
| 57 | void process_action_kb(keyrecord_t *record) {} | 73 | void process_action_kb(keyrecord_t *record) {} |
| 58 | 74 | ||
| @@ -67,7 +83,7 @@ void process_action(keyrecord_t *record) | |||
| 67 | 83 | ||
| 68 | process_action_kb(record); | 84 | process_action_kb(record); |
| 69 | 85 | ||
| 70 | action_t action = layer_switch_get_action(event.key); | 86 | action_t action = store_or_get_action(event.pressed, event.key); |
| 71 | dprint("ACTION: "); debug_action(action); | 87 | dprint("ACTION: "); debug_action(action); |
| 72 | #ifndef NO_ACTION_LAYER | 88 | #ifndef NO_ACTION_LAYER |
| 73 | dprint(" layer_state: "); layer_debug(); | 89 | dprint(" layer_state: "); layer_debug(); |
| @@ -88,14 +104,24 @@ void process_action(keyrecord_t *record) | |||
| 88 | action.key.mods<<4; | 104 | action.key.mods<<4; |
| 89 | if (event.pressed) { | 105 | if (event.pressed) { |
| 90 | if (mods) { | 106 | if (mods) { |
| 91 | add_weak_mods(mods); | 107 | if (IS_MOD(action.key.code)) { |
| 108 | // e.g. LSFT(KC_LGUI): we don't want the LSFT to be weak as it would make it useless. | ||
| 109 | // this also makes LSFT(KC_LGUI) behave exactly the same as LGUI(KC_LSFT) | ||
| 110 | add_mods(mods); | ||
| 111 | } else { | ||
| 112 | add_weak_mods(mods); | ||
| 113 | } | ||
| 92 | send_keyboard_report(); | 114 | send_keyboard_report(); |
| 93 | } | 115 | } |
| 94 | register_code(action.key.code); | 116 | register_code(action.key.code); |
| 95 | } else { | 117 | } else { |
| 96 | unregister_code(action.key.code); | 118 | unregister_code(action.key.code); |
| 97 | if (mods) { | 119 | if (mods) { |
| 98 | del_weak_mods(mods); | 120 | if (IS_MOD(action.key.code)) { |
| 121 | del_mods(mods); | ||
| 122 | } else { | ||
| 123 | del_weak_mods(mods); | ||
| 124 | } | ||
| 99 | send_keyboard_report(); | 125 | send_keyboard_report(); |
| 100 | } | 126 | } |
| 101 | } | 127 | } |
