]> git.gir.st - tmk_keyboard.git/blob - common/action_macro.h
Merge branch 'bob_fix'
[tmk_keyboard.git] / common / action_macro.h
1 /*
2 Copyright 2013 Jun Wako <wakojun@gmail.com>
3
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.
8
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.
13
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/>.
16 */
17 #ifndef ACTION_MACRO_H
18 #define ACTION_MACRO_H
19 #include <stdint.h>
20 #include <avr/pgmspace.h>
21
22
23 #define MACRO_NONE 0
24 #define MACRO(...) ({ static const macro_t __m[] PROGMEM = { __VA_ARGS__ }; &__m[0]; })
25
26
27 typedef uint8_t macro_t;
28
29
30 #ifndef NO_ACTION_MACRO
31 void action_macro_play(const macro_t *macro_p);
32 #else
33 #define action_macro_play(macro)
34 #endif
35
36
37
38 /* TODO: NOT FINISHED
39 normal mode command:
40 key(down): 0x04-7f/73(F24)
41 key(up): 0x84-ff
42 command: 0x00-03, 0x80-83(0x74-7f, 0xf4-ff)
43 mods down 0x00
44 mods up 0x01
45 wait 0x02
46 interval 0x03
47 extkey down 0x80
48 extkey up 0x81
49 ext commad 0x82
50 ext mode 0x83
51 end 0xff
52
53 extension mode command: NOT IMPLEMENTED
54 key down 0x00
55 key up 0x01
56 key down + wait
57 key up + wait
58 mods push
59 mods pop
60 wait
61 interval
62 if
63 loop
64 push
65 pop
66 all up
67 end
68 */
69 enum macro_command_id{
70 /* 0x00 - 0x03 */
71 END = 0x00,
72 MODS_DOWN = 0x01,
73 MODS_UP = 0x02,
74 MODS_SET,
75 MODS_PUSH,
76 MODS_POP,
77
78 WAIT = 0x74,
79 INTERVAL,
80 /* 0x74 - 0x7f */
81 /* 0x80 - 0x84 */
82
83 EXT_DOWN,
84 EXT_UP,
85 EXT_WAIT,
86 EXT_INTERVAL,
87 COMPRESSION_MODE,
88
89 EXTENSION_MODE = 0xff,
90 };
91
92
93 /* normal mode */
94 #define DOWN(key) (key)
95 #define UP(key) ((key) | 0x80)
96 #define TYPE(key) (key), (key | 0x80)
97 #define MODS_DOWN(mods) MODS_DOWN, (mods)
98 #define MODS_UP(mods) MODS_UP, (mods)
99 #define WAIT(ms) WAIT, (ms)
100 #define INTERVAL(ms) INTERVAL, (ms)
101
102 #define D(key) DOWN(KC_##key)
103 #define U(key) UP(KC_##key)
104 #define T(key) TYPE(KC_##key)
105 #define MD(key) MODS_DOWN(MOD_BIT(KC_##key))
106 #define MU(key) MODS_UP(MOD_BIT(KC_##key))
107 #define W(ms) WAIT(ms)
108 #define I(ms) INTERVAL(ms)
109
110
111 /* extension mode */
112
113
114 #endif /* ACTION_MACRO_H */
Imprint / Impressum