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