summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authortmk <nobody@nowhere>2014-09-29 03:12:58 +0200
committertmk <nobody@nowhere>2014-09-29 03:29:33 +0200
commit821c719e98f310938e2bb3f2ad3e6a726bd8b03e (patch)
tree0af03831bbed9d6a4155e46923406b4a3bd6b67e /common
parent8cec0bc9d66cb7da4770e6502e97a426908eb532 (diff)
downloadqmk_firmware-821c719e98f310938e2bb3f2ad3e6a726bd8b03e.tar.gz
qmk_firmware-821c719e98f310938e2bb3f2ad3e6a726bd8b03e.tar.xz
Add action 'Momentary switching with Modifiers'
Diffstat (limited to 'common')
-rw-r--r--common/action.c10
-rw-r--r--common/action_code.h3
2 files changed, 12 insertions, 1 deletions
diff --git a/common/action.c b/common/action.c
index fddb97c50..83bc8a618 100644
--- a/common/action.c
+++ b/common/action.c
@@ -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) {
diff --git a/common/action_code.h b/common/action_code.h
index 50112d4d2..bc40e2c6f 100644
--- a/common/action_code.h
+++ b/common/action_code.h
@@ -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)