2 Copyright 2013 Jun Wako <wakojun@gmail.com>
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #ifndef ACTION_MACRO_H
18 #define ACTION_MACRO_H
24 #define MACRO(...) ({ static const macro_t __m[] PROGMEM = { __VA_ARGS__ }; &__m[0]; })
25 #define MACRO_GET(p) pgm_read_byte(p)
27 typedef uint8_t macro_t;
30 #ifndef NO_ACTION_MACRO
31 void action_macro_play(const macro_t *macro_p);
33 #define action_macro_play(macro)
39 * code(0x04-73) // key down(1byte)
40 * code(0x04-73) | 0x80 // key up(1byte)
41 * { KEY_DOWN, code(0x04-0xff) } // key down(2bytes)
42 * { KEY_UP, code(0x04-0xff) } // key up(2bytes)
43 * WAIT // wait milli-seconds
44 * INTERVAL // set interval between macro commands
45 * END // stop macro execution
47 * Ideas(Not implemented):
56 enum macro_command_id{
62 /* 0x04 - 0x73 (reserved for keycode down) */
71 /* 0x84 - 0xf3 (reserved for keycode up) */
77 /* TODO: keycode:0x04-0x73 can be handled by 1byte command else 2bytes are needed
78 * if keycode between 0x04 and 0x73
79 * keycode / (keycode|0x80)
81 * {KEY_DOWN, keycode} / {KEY_UP, keycode}
83 #define DOWN(key) KEY_DOWN, (key)
84 #define UP(key) KEY_UP, (key)
85 #define TYPE(key) DOWN(key), UP(key)
86 #define WAIT(ms) WAIT, (ms)
87 #define INTERVAL(ms) INTERVAL, (ms)
88 #define STORE() MOD_STORE
89 #define RESTORE() MOD_RESTORE
90 #define CLEAR() MOD_CLEAR
93 #define D(key) DOWN(KC_##key)
95 #define U(key) UP(KC_##key)
97 #define T(key) TYPE(KC_##key)
99 #define W(ms) WAIT(ms)
101 #define I(ms) INTERVAL(ms)
102 /* store modifier(s) */
104 /* restore modifier(s) */
105 #define RM() RESTORE()
106 /* clear modifier(s) */
109 /* for backward comaptibility */
110 #define MD(key) DOWN(KC_##key)
111 #define MU(key) UP(KC_##key)
114 #endif /* ACTION_MACRO_H */