123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- #ifndef ACTION_MACRO_H
- #define ACTION_MACRO_H
- #include <stdint.h>
- #include "progmem.h"
- 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)
- #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) ) )
- #define MACRO_TAP_HOLD_MOD(record, macro, mod) MACRO_TAP_HOLD(record, (MACRO(D(mod), END)), MACRO(U(mod), END), macro)
- #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)
- #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; }) ) )
- #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
- void action_macro_play(const macro_t *macro_p);
- #else
- #define action_macro_play(macro)
- #endif
- enum macro_command_id{
-
- END = 0x00,
- KEY_DOWN,
- KEY_UP,
-
-
- WAIT = 0x74,
- INTERVAL,
-
-
- };
- #define DOWN(key) KEY_DOWN, (key)
- #define UP(key) KEY_UP, (key)
- #define TYPE(key) DOWN(key), UP(key)
- #define WAIT(ms) WAIT, (ms)
- #define INTERVAL(ms) INTERVAL, (ms)
- #define D(key) DOWN(KC_##key)
- #define U(key) UP(KC_##key)
- #define T(key) TYPE(KC_##key)
- #define W(ms) WAIT(ms)
- #define I(ms) INTERVAL(ms)
- #define MD(key) DOWN(KC_##key)
- #define MU(key) UP(KC_##key)
- #endif
|