diff options
| author | tmk <nobody@nowhere> | 2013-01-23 23:53:51 +0900 |
|---|---|---|
| committer | tmk <nobody@nowhere> | 2013-01-23 23:53:51 +0900 |
| commit | 28b5f69ce5c8b35d40725b490e7a2d4bfe922ad4 (patch) | |
| tree | 1a427f0e0d410fee5f57bfc170e31ef2d7050ac9 /common/action.h | |
| parent | 1fe820a8654b69576875a8173e22b47b365c2460 (diff) | |
| download | qmk_firmware-28b5f69ce5c8b35d40725b490e7a2d4bfe922ad4.tar.gz qmk_firmware-28b5f69ce5c8b35d40725b490e7a2d4bfe922ad4.zip | |
Add prototype of Action Function.
Diffstat (limited to 'common/action.h')
| -rw-r--r-- | common/action.h | 38 |
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 | ||
| 6 | extern uint8_t tap_count; | ||
| 7 | extern keyevent_t tapping_event; | ||
| 6 | 8 | ||
| 7 | /* Key Action(16bit code) | 9 | |
| 10 | /* | ||
| 11 | * Utilities for actions. | ||
| 12 | */ | ||
| 13 | void register_code(uint8_t code); | ||
| 14 | void unregister_code(uint8_t code); | ||
| 15 | void add_mods(uint8_t mods); | ||
| 16 | void del_mods(uint8_t mods); | ||
| 17 | void set_mods(uint8_t mods); | ||
| 18 | void clear_keyboard(void); | ||
| 19 | void clear_keyboard_but_mods(void); | ||
| 20 | bool sending_anykey(void); | ||
| 21 | void layer_switch(uint8_t new_layer); | ||
| 22 | bool is_tap_key(keyevent_t event); | ||
| 23 | |||
| 24 | |||
| 25 | |||
| 26 | |||
| 27 | /* | ||
| 28 | Action codes | ||
| 29 | 16bit code: action_kind(4bit) + action_parameter(12bit) | ||
| 8 | 30 | ||
| 9 | Keyboard Keys | 31 | Keyboard Keys |
| 10 | ------------- | 32 | ------------- |
| @@ -94,6 +116,7 @@ ACT_COMMAND(1110): | |||
| 94 | 116 | ||
| 95 | ACT_FUNCTION(1111): | 117 | ACT_FUNCTION(1111): |
| 96 | 1111| address(12) Function | 118 | 1111| address(12) Function |
| 119 | 1111|opt | id(8) Function | ||
| 97 | Macro record(dynamicly) | 120 | Macro record(dynamicly) |
| 98 | Macro play(dynamicly) | 121 | Macro play(dynamicly) |
| 99 | TODO: modifier + [tap key /w mod] | 122 | TODO: 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? | ||
| 172 | typedef struct { | 201 | typedef 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 */ | ||
| 208 | typedef void (*action_func_t)(keyevent_t event, uint8_t opt); | ||
| 209 | |||
| 178 | 210 | ||
| 211 | // TODO: legacy keymap support | ||
| 179 | void action_exec(keyevent_t event); | 212 | void action_exec(keyevent_t event); |
| 213 | void 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 */ |
