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