]> git.friedersdorff.com Git - max/tmk_keyboard.git/commitdiff
Add action 'Momentary switching with Modifiers'
authortmk <nobody@nowhere>
Mon, 29 Sep 2014 01:12:58 +0000 (10:12 +0900)
committertmk <nobody@nowhere>
Mon, 29 Sep 2014 01:29:33 +0000 (10:29 +0900)
common/action.c
common/action_code.h
doc/keymap.md

index fddb97c508dbd96865c73ef08bfd68cc1739b1ac..83bc8a6187990b9dc16ce2d9259d43af307acfa5 100644 (file)
@@ -237,6 +237,16 @@ void process_action(keyrecord_t *record)
         case ACT_LAYER_TAP:
         case ACT_LAYER_TAP_EXT:
             switch (action.layer_tap.code) {
+                case 0xe0 ... 0xef:
+                    /* layer On/Off with modifiers(left only) */
+                    if (event.pressed) {
+                        layer_on(action.layer_tap.val);
+                        register_mods(action.layer_tap.code & 0x0f);
+                    } else {
+                        layer_off(action.layer_tap.val);
+                        unregister_mods(action.layer_tap.code & 0x0f);
+                    }
+                    break;
                 case OP_TAP_TOGGLE:
                     /* tap toggle */
                     if (event.pressed) {
index 50112d4d20ebb57e745b021eed335f717abc7abf..bc40e2c6fbfeebf4c82cd832ef0b90e42c88501e 100644 (file)
@@ -71,7 +71,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
  * ACT_LAYER_TAP(101x):
  * 101E|LLLL| keycode    On/Off with tap key
- * 101E|LLLL|1110 xxxx   Reserved(0xE0-EF)
+ * 101E|LLLL|1110 mods   On/Off with modifiers(0xE0-EF)
  * 101E|LLLL|1111 0000   Invert with tap toggle(0xF0)
  * 101E|LLLL|1111 0001   On/Off
  * 101E|LLLL|1111 0010   Off/On
@@ -266,6 +266,7 @@ enum layer_pram_tap_op {
 #define ACTION_LAYER_ON_OFF(layer)                  ACTION_LAYER_TAP((layer), OP_ON_OFF)
 #define ACTION_LAYER_OFF_ON(layer)                  ACTION_LAYER_TAP((layer), OP_OFF_ON)
 #define ACTION_LAYER_SET_CLEAR(layer)               ACTION_LAYER_TAP((layer), OP_SET_CLEAR)
+#define ACTION_LAYER_MODS(layer, mods)              ACTION_LAYER_TAP((layer), 0xe0 | (mods)&0x0f)
 /* With Tapping */
 #define ACTION_LAYER_TAP_KEY(layer, key)            ACTION_LAYER_TAP((layer), (key))
 #define ACTION_LAYER_TAP_TOGGLE(layer)              ACTION_LAYER_TAP((layer), OP_TAP_TOGGLE)
index 11feeac218c37470095fbc48e00c9df9ee2f312d..9d986a8c51d80e0a1588ca03a911ccb32786a294 100644 (file)
@@ -497,6 +497,13 @@ Number of taps can be configured with `TAPPING_TOGGLE` in `config.h`, `5` by def
 
 
 
+### 3.5 Momentary switching with Modifiers
+This registers modifier key(s) simultaneously with layer switching.
+
+    ACTION_LAYER_MODS(2, MOD_LSFT | MOD_LALT)
+
+
+
 ## 4. Tapping
 Tapping is to press and release a key quickly. Tapping speed is determined with setting of `TAPPING_TERM`, which can be defined in `config.h`, 200ms by default.