]> git.donarmstrong.com Git - qmk_firmware.git/commitdiff
Merge pull request #182 from Vifon/modifier-release-fix
authorErez Zukerman <bulk@ezuk.org>
Wed, 6 Apr 2016 19:47:31 +0000 (22:47 +0300)
committerErez Zukerman <bulk@ezuk.org>
Wed, 6 Apr 2016 19:47:31 +0000 (22:47 +0300)
Fix the layer-dependent modifiers handling

1  2 
tmk_core/common/action.c

diff --combined tmk_core/common/action.c
index 901089634368561003b95b5a5e325ddda0e08228,6aa6dc26019998c526c96cd40801c308ba84288f..f9e6c17dc3bd9c37044f322424107ca15ec65563
@@@ -53,6 -53,22 +53,22 @@@ void action_exec(keyevent_t event
  #endif
  }
  
+ #if !defined(NO_ACTION_LAYER) && defined(PREVENT_STUCK_MODIFIERS)
+ bool disable_action_cache = false;
+ void process_action_nocache(keyrecord_t *record)
+ {
+     disable_action_cache = true;
+     process_action(record);
+     disable_action_cache = false;
+ }
+ #else
+ void process_action_nocache(keyrecord_t *record)
+ {
+     process_action(record);
+ }
+ #endif
  __attribute__ ((weak))
  void process_action_kb(keyrecord_t *record) {}
  
@@@ -67,7 -83,7 +83,7 @@@ void process_action(keyrecord_t *record
  
      process_action_kb(record);
  
-     action_t action = layer_switch_get_action(event.key);
+     action_t action = store_or_get_action(event.pressed, event.key);
      dprint("ACTION: "); debug_action(action);
  #ifndef NO_ACTION_LAYER
      dprint(" layer_state: "); layer_debug();
                                                                  action.key.mods<<4;
                  if (event.pressed) {
                      if (mods) {
 -                        add_weak_mods(mods);
 +                        if (IS_MOD(action.key.code)) {
 +                            // e.g. LSFT(KC_LGUI): we don't want the LSFT to be weak as it would make it useless.
 +                            // this also makes LSFT(KC_LGUI) behave exactly the same as LGUI(KC_LSFT)
 +                            add_mods(mods);
 +                        } else {
 +                            add_weak_mods(mods);
 +                        }
                          send_keyboard_report();
                      }
                      register_code(action.key.code);
                  } else {
                      unregister_code(action.key.code);
                      if (mods) {
 -                        del_weak_mods(mods);
 +                        if (IS_MOD(action.key.code)) {
 +                            del_mods(mods);
 +                        } else {
 +                            del_weak_mods(mods);
 +                        }
                          send_keyboard_report();
                      }
                  }