summaryrefslogtreecommitdiffstats
path: root/tmk_core/common/action_macro.h
diff options
context:
space:
mode:
authormilestogo <milestogo@users.noreply.github.com>2017-02-10 08:28:39 +0100
committermilestogo <milestogo@users.noreply.github.com>2017-02-10 08:28:39 +0100
commitb0537f75df73ca5a55355c7546d45577cb2c6a38 (patch)
tree0da100dc4fcbe21629a10879b53e13d02c25c170 /tmk_core/common/action_macro.h
parent5ac0e6e6aee64c9b8fade79aaf22bc839e2c6b47 (diff)
parent41c93575a838e9b201ca113165085f47198e109d (diff)
downloadqmk_firmware-b0537f75df73ca5a55355c7546d45577cb2c6a38.tar.gz
qmk_firmware-b0537f75df73ca5a55355c7546d45577cb2c6a38.tar.xz
Merge branch 'master' into sculpt2
Diffstat (limited to 'tmk_core/common/action_macro.h')
-rw-r--r--tmk_core/common/action_macro.h26
1 files changed, 24 insertions, 2 deletions
diff --git a/tmk_core/common/action_macro.h b/tmk_core/common/action_macro.h
index aedc32ec6..f373f5068 100644
--- a/tmk_core/common/action_macro.h
+++ b/tmk_core/common/action_macro.h
@@ -20,11 +20,33 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "progmem.h"
-#define MACRO_NONE 0
+
+typedef uint8_t macro_t;
+
+#define MACRO_NONE (macro_t*)0
#define MACRO(...) ({ static const macro_t __m[] PROGMEM = { __VA_ARGS__ }; &__m[0]; })
#define MACRO_GET(p) pgm_read_byte(p)
-typedef uint8_t macro_t;
+// Sends press when the macro key is pressed, release when release, or tap_macro when the key has been tapped
+#define MACRO_TAP_HOLD(record, press, release, tap_macro) ( ((record)->event.pressed) ? \
+ ( ((record)->tap.count <= 0 || (record)->tap.interrupted) ? (press) : MACRO_NONE ) : \
+ ( ((record)->tap.count > 0 && !((record)->tap.interrupted)) ? (tap_macro) : (release) ) )
+
+// Holds down the modifier mod when the macro key is held, or sends macro instead when tapped
+#define MACRO_TAP_HOLD_MOD(record, macro, mod) MACRO_TAP_HOLD(record, (MACRO(D(mod), END)), MACRO(U(mod), END), macro)
+
+// Holds down the modifier mod when the macro key is held, or pressed a shifted key when tapped (eg: shift+3 for #)
+#define MACRO_TAP_SHFT_KEY_HOLD_MOD(record, key, mod) MACRO_TAP_HOLD_MOD(record, (MACRO(I(10), D(LSFT), T(key), U(LSFT), END)), mod)
+
+
+// Momentary switch layer when held, sends macro if tapped
+#define MACRO_TAP_HOLD_LAYER(record, macro, layer) ( ((record)->event.pressed) ? \
+ ( ((record)->tap.count <= 0 || (record)->tap.interrupted) ? ({layer_on((layer)); MACRO_NONE; }) : MACRO_NONE ) : \
+ ( ((record)->tap.count > 0 && !((record)->tap.interrupted)) ? (macro) : ({layer_off((layer)); MACRO_NONE; }) ) )
+
+// Momentary switch layer when held, presses a shifted key when tapped (eg: shift+3 for #)
+#define MACRO_TAP_SHFT_KEY_HOLD_LAYER(record, key, layer) MACRO_TAP_HOLD_LAYER(record, MACRO(I(10), D(LSFT), T(key), U(LSFT), END), layer)
+
#ifndef NO_ACTION_MACRO