aboutsummaryrefslogtreecommitdiff
path: root/common/action.h
diff options
context:
space:
mode:
authortmk <nobody@nowhere>2013-01-23 23:53:51 +0900
committertmk <nobody@nowhere>2013-01-23 23:53:51 +0900
commit28b5f69ce5c8b35d40725b490e7a2d4bfe922ad4 (patch)
tree1a427f0e0d410fee5f57bfc170e31ef2d7050ac9 /common/action.h
parent1fe820a8654b69576875a8173e22b47b365c2460 (diff)
downloadqmk_firmware-28b5f69ce5c8b35d40725b490e7a2d4bfe922ad4.tar.gz
qmk_firmware-28b5f69ce5c8b35d40725b490e7a2d4bfe922ad4.zip
Add prototype of Action Function.
Diffstat (limited to 'common/action.h')
-rw-r--r--common/action.h38
1 files changed, 36 insertions, 2 deletions
diff --git a/common/action.h b/common/action.h
index 3115c67f4..9aa1d78e9 100644
--- a/common/action.h
+++ b/common/action.h
@@ -3,8 +3,30 @@
3 3
4#include "keyboard.h" 4#include "keyboard.h"
5 5
6extern uint8_t tap_count;
7extern keyevent_t tapping_event;
6 8
7/* Key Action(16bit code) 9
10/*
11 * Utilities for actions.
12 */
13void register_code(uint8_t code);
14void unregister_code(uint8_t code);
15void add_mods(uint8_t mods);
16void del_mods(uint8_t mods);
17void set_mods(uint8_t mods);
18void clear_keyboard(void);
19void clear_keyboard_but_mods(void);
20bool sending_anykey(void);
21void layer_switch(uint8_t new_layer);
22bool is_tap_key(keyevent_t event);
23
24
25
26
27/*
28Action codes
2916bit code: action_kind(4bit) + action_parameter(12bit)
8 30
9Keyboard Keys 31Keyboard Keys
10------------- 32-------------
@@ -94,6 +116,7 @@ ACT_COMMAND(1110):
94 116
95ACT_FUNCTION(1111): 117ACT_FUNCTION(1111):
961111| address(12) Function 1181111| address(12) Function
1191111|opt | id(8) Function
97 Macro record(dynamicly) 120 Macro record(dynamicly)
98 Macro play(dynamicly) 121 Macro play(dynamicly)
99TODO: modifier + [tap key /w mod] 122TODO: modifier + [tap key /w mod]
@@ -160,6 +183,11 @@ typedef union {
160 uint16_t option :4; 183 uint16_t option :4;
161 uint16_t kind :4; 184 uint16_t kind :4;
162 } command; 185 } command;
186 struct action_function {
187 uint8_t id :8;
188 uint8_t opt :4;
189 uint8_t kind :4;
190 } func;
163} action_t; 191} action_t;
164 192
165 193
@@ -169,14 +197,20 @@ enum stroke_cmd {
169 STROKE_ALLUP, /* release all keys in reverse order */ 197 STROKE_ALLUP, /* release all keys in reverse order */
170}; 198};
171 199
200// TODO: not needed?
172typedef struct { 201typedef struct {
173 keyevent_t event; 202 keyevent_t event;
174 action_t action; 203 action_t action;
175 uint8_t mods; 204 uint8_t mods;
176} keyrecord_t; 205} keyrecord_t;
177 206
207/* action function */
208typedef void (*action_func_t)(keyevent_t event, uint8_t opt);
209
178 210
211// TODO: legacy keymap support
179void action_exec(keyevent_t event); 212void action_exec(keyevent_t event);
213void action_call_function(keyevent_t event, uint8_t id);
180 214
181 215
182// TODO: proper names 216// TODO: proper names
@@ -234,7 +268,7 @@ void action_exec(keyevent_t event);
234/* Command */ 268/* Command */
235#define ACTION_COMMAND(opt, id) ACTION(ACT_COMMAND, (opt)<<8 | (addr)) 269#define ACTION_COMMAND(opt, id) ACTION(ACT_COMMAND, (opt)<<8 | (addr))
236/* Function */ 270/* Function */
237#define ACTION_FUNCTION(addr) ACTION(ACT_FUNCTION, addr) 271#define ACTION_FUNCTION(id, opt) ACTION(ACT_FUNCTION, (opt)<<8 | id)
238 272
239 273
240/* helpers for readability */ 274/* helpers for readability */