aboutsummaryrefslogtreecommitdiff
path: root/common/action.h
diff options
context:
space:
mode:
authortmk <nobody@nowhere>2013-02-25 15:30:37 +0900
committertmk <nobody@nowhere>2013-02-25 15:30:37 +0900
commit23c32d304bcc5146a575e547bba80ee8d86a2856 (patch)
treed7826faa7e6d3648cffa21ae163fe1e369caf384 /common/action.h
parent000f3c4c543e0c4490787ccc3a8920d4ee0692ec (diff)
downloadqmk_firmware-23c32d304bcc5146a575e547bba80ee8d86a2856.tar.gz
qmk_firmware-23c32d304bcc5146a575e547bba80ee8d86a2856.zip
Add MACRO action
Diffstat (limited to 'common/action.h')
-rw-r--r--common/action.h52
1 files changed, 27 insertions, 25 deletions
diff --git a/common/action.h b/common/action.h
index 4892cc7fd..9dea4b0aa 100644
--- a/common/action.h
+++ b/common/action.h
@@ -19,6 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
19 19
20#include "keyboard.h" 20#include "keyboard.h"
21#include "keycode.h" 21#include "keycode.h"
22#include "action_macro.h"
22 23
23 24
24/* Struct to record event and tap count */ 25/* Struct to record event and tap count */
@@ -82,6 +83,9 @@ void action_exec(keyevent_t event);
82/* action for key */ 83/* action for key */
83action_t action_for_key(uint8_t layer, key_t key); 84action_t action_for_key(uint8_t layer, key_t key);
84 85
86/* macro */
87const prog_macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt);
88
85/* user defined special function */ 89/* user defined special function */
86void action_function(keyrecord_t *record, uint8_t id, uint8_t opt); 90void action_function(keyrecord_t *record, uint8_t id, uint8_t opt);
87 91
@@ -107,8 +111,8 @@ bool waiting_buffer_has_anykey_pressed(void);
107 * ============ 111 * ============
108 * 16bit code: action_kind(4bit) + action_parameter(12bit) 112 * 16bit code: action_kind(4bit) + action_parameter(12bit)
109 * 113 *
110 * Keyboard Keys 114 * Keyboard Keys(00XX)
111 * ------------- 115 * -------------------
112 * ACT_LMODS(0000): 116 * ACT_LMODS(0000):
113 * 0000|0000|000000|00 No action 117 * 0000|0000|000000|00 No action
114 * 0000|0000|000000|01 Transparent 118 * 0000|0000|000000|01 Transparent
@@ -138,8 +142,8 @@ bool waiting_buffer_has_anykey_pressed(void);
138 * 0011|mods| keycode Right mods + tap Key 142 * 0011|mods| keycode Right mods + tap Key
139 * 143 *
140 * 144 *
141 * Other HID Usage 145 * Other keys(01XX)
142 * --------------- 146 * --------------------
143 * This action handles other usages than keyboard. 147 * This action handles other usages than keyboard.
144 * ACT_USAGE(0100): 148 * ACT_USAGE(0100):
145 * 0100|00| usage(10) System control(0x80) - General Desktop page(0x01) 149 * 0100|00| usage(10) System control(0x80) - General Desktop page(0x01)
@@ -147,15 +151,12 @@ bool waiting_buffer_has_anykey_pressed(void);
147 * 0100|10| usage(10) (reserved) 151 * 0100|10| usage(10) (reserved)
148 * 0100|11| usage(10) (reserved) 152 * 0100|11| usage(10) (reserved)
149 * 153 *
150 *
151 * Mouse Keys
152 * ----------
153 * ACT_MOUSEKEY(0110): 154 * ACT_MOUSEKEY(0110):
154 * 0101|XXXX| keycode Mouse key 155 * 0101|XXXX| keycode Mouse key
155 * 156 *
156 * 157 *
157 * Layer Actions 158 * Layer Actions(10XX)
158 * ------------- 159 * -------------------
159 * ACT_KEYMAP: 160 * ACT_KEYMAP:
160 * 1000|--xx|0000 0000 Clear keyamp and overlay 161 * 1000|--xx|0000 0000 Clear keyamp and overlay
161 * 1000|LLLL|0000 00xx Reset default layer and clear keymap and overlay 162 * 1000|LLLL|0000 00xx Reset default layer and clear keymap and overlay
@@ -189,8 +190,6 @@ bool waiting_buffer_has_anykey_pressed(void);
189 * 190 *
190 * Extensions(11XX) 191 * Extensions(11XX)
191 * ---------------- 192 * ----------------
192 * NOTE: NOT FIXED
193 *
194 * ACT_MACRO(1100): 193 * ACT_MACRO(1100):
195 * 1100|opt | id(8) Macro play? 194 * 1100|opt | id(8) Macro play?
196 * 1100|1111| id(8) Macro record? 195 * 1100|1111| id(8) Macro record?
@@ -253,8 +252,20 @@ enum mods_codes {
253#define ACTION_RMOD_TAP_KEY(mod, key) ACTION(ACT_RMODS_TAP, MODS4(MOD_BIT(mod))<<8 | (key)) 252#define ACTION_RMOD_TAP_KEY(mod, key) ACTION(ACT_RMODS_TAP, MODS4(MOD_BIT(mod))<<8 | (key))
254#define ACTION_RMOD_ONESHOT(mod) ACTION(ACT_RMODS_TAP, MODS4(MOD_BIT(mod))<<8 | MODS_ONESHOT) 253#define ACTION_RMOD_ONESHOT(mod) ACTION(ACT_RMODS_TAP, MODS4(MOD_BIT(mod))<<8 | MODS_ONESHOT)
255 254
255/* HID Usage */
256enum usage_pages {
257 PAGE_SYSTEM,
258 PAGE_CONSUMER
259};
260#define ACTION_USAGE_SYSTEM(id) ACTION(ACT_USAGE, PAGE_SYSTEM<<10 | (id))
261#define ACTION_USAGE_CONSUMER(id) ACTION(ACT_USAGE, PAGE_CONSUMER<<10 | (id))
262
263/* Mousekey */
264#define ACTION_MOUSEKEY(key) ACTION(ACT_MOUSEKEY, key)
265
266
256 267
257/* Layer Operation: 268/* Layer Actions:
258 * Invert layer ^= (1<<layer) 269 * Invert layer ^= (1<<layer)
259 * On layer |= (1<<layer) 270 * On layer |= (1<<layer)
260 * Off layer &= ~(1<<layer) 271 * Off layer &= ~(1<<layer)
@@ -362,23 +373,14 @@ enum layer_params {
362 373
363 374
364/* 375/*
365 * HID Usage 376 * Extensions
366 */ 377 */
367enum usage_pages {
368 PAGE_SYSTEM,
369 PAGE_CONSUMER
370};
371#define ACTION_USAGE_SYSTEM(id) ACTION(ACT_USAGE, PAGE_SYSTEM<<10 | (id))
372#define ACTION_USAGE_CONSUMER(id) ACTION(ACT_USAGE, PAGE_CONSUMER<<10 | (id))
373
374/* Mousekey */
375#define ACTION_MOUSEKEY(key) ACTION(ACT_MOUSEKEY, key)
376
377/* Macro */ 378/* Macro */
378#define ACTION_MACRO(opt, id) ACTION(ACT_FUNCTION, (opt)<<8 | (addr)) 379#define ACTION_MACRO(id) ACTION(ACT_MACRO, (id))
380#define ACTION_MACRO_OPT(id, opt) ACTION(ACT_MACRO, (opt)<<8 | (id))
379 381
380/* Command */ 382/* Command */
381#define ACTION_COMMAND(opt, id) ACTION(ACT_COMMAND, (opt)<<8 | (addr)) 383#define ACTION_COMMAND(id, opt) ACTION(ACT_COMMAND, (opt)<<8 | (addr))
382 384
383/* Function */ 385/* Function */
384enum function_opts { 386enum function_opts {