aboutsummaryrefslogtreecommitdiff
path: root/common/action.h
diff options
context:
space:
mode:
authortmk <nobody@nowhere>2013-02-01 14:48:11 +0900
committertmk <nobody@nowhere>2013-02-01 14:48:11 +0900
commit1d7962ba8a20323dc13cc913381608e117afaeb4 (patch)
tree7f345a164f79364a3d7178be8b828d648b3e6c8a /common/action.h
parentd95463f2e0369dc0e28497bb923b3012fb09e900 (diff)
downloadqmk_firmware-1d7962ba8a20323dc13cc913381608e117afaeb4.tar.gz
qmk_firmware-1d7962ba8a20323dc13cc913381608e117afaeb4.zip
Add user defined function to action.
Diffstat (limited to 'common/action.h')
-rw-r--r--common/action.h47
1 files changed, 24 insertions, 23 deletions
diff --git a/common/action.h b/common/action.h
index d6530df42..b657aa540 100644
--- a/common/action.h
+++ b/common/action.h
@@ -21,6 +21,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
21#include "keycode.h" 21#include "keycode.h"
22 22
23 23
24/* Execute action per keyevent */
25void action_exec(keyevent_t event);
26
27
28/* Struct to record event and tap count */
29typedef struct {
30 keyevent_t event;
31 uint8_t tap_count;
32} keyrecord_t;
33
24/* Action struct. 34/* Action struct.
25 * 35 *
26 * In avr-gcc bit field seems to be assigned from LSB(bit0) to MSB(bit15). 36 * In avr-gcc bit field seems to be assigned from LSB(bit0) to MSB(bit15).
@@ -48,7 +58,7 @@ typedef union {
48 } key; 58 } key;
49 struct action_layer { 59 struct action_layer {
50 uint16_t code :8; 60 uint16_t code :8;
51 uint16_t opt :4; 61 uint16_t val :4;
52 uint16_t kind :4; 62 uint16_t kind :4;
53 } layer; 63 } layer;
54 struct action_usage { 64 struct action_usage {
@@ -58,7 +68,7 @@ typedef union {
58 } usage; 68 } usage;
59 struct action_command { 69 struct action_command {
60 uint16_t id :8; 70 uint16_t id :8;
61 uint16_t option :4; 71 uint16_t opt :4;
62 uint16_t kind :4; 72 uint16_t kind :4;
63 } command; 73 } command;
64 struct action_function { 74 struct action_function {
@@ -68,18 +78,6 @@ typedef union {
68 } func; 78 } func;
69} action_t; 79} action_t;
70 80
71/* Struct to record action and tap count */
72typedef struct {
73 keyevent_t event;
74 uint8_t tap_count;
75} keyrecord_t;
76
77
78/* execute action per keyevent */
79void action_exec(keyevent_t event);
80typedef void (*action_func_t)(keyevent_t event, uint8_t opt); // TODO:no need?
81void action_call_function(keyevent_t event, uint8_t id); // TODO: action function
82
83 81
84/* 82/*
85 * Utilities for actions. 83 * Utilities for actions.
@@ -94,6 +92,7 @@ void clear_keyboard_but_mods(void);
94bool sending_anykey(void); 92bool sending_anykey(void);
95void layer_switch(uint8_t new_layer); 93void layer_switch(uint8_t new_layer);
96bool is_tap_key(key_t key); 94bool is_tap_key(key_t key);
95bool waiting_buffer_has_anykey_pressed(void);
97 96
98 97
99 98
@@ -203,9 +202,6 @@ ACT_FUNCTION(1111):
2031111| address(12) Function? 2021111| address(12) Function?
2041111|opt | id(8) Function? 2031111|opt | id(8) Function?
205 204
206TODO: modifier + function by tap?
207 for example: LShift + '('[Shift+9] and RShift + ')'[Shift+0]
208 http://deskthority.net/workshop-f7/tmk-keyboard-firmware-collection-t4478.html#p90052
209 */ 205 */
210enum action_kind_id { 206enum action_kind_id {
211 ACT_LMODS = 0b0000, 207 ACT_LMODS = 0b0000,
@@ -226,8 +222,12 @@ enum action_kind_id {
226 ACT_FUNCTION = 0b1111 222 ACT_FUNCTION = 0b1111
227}; 223};
228 224
229enum acion_param { 225enum params {
230 ONE_SHOT = 0x00, 226 P_ONESHOT = 0x00,
227};
228
229enum options {
230 O_TAP = 0x8,
231}; 231};
232 232
233 233
@@ -251,14 +251,14 @@ enum acion_param {
251 251
252/* Mods + Tap key */ 252/* Mods + Tap key */
253#define ACTION_LMODS_TAP_KEY(mods, key) ACTION(ACT_LMODS_TAP, MODS4(mods)<<8 | (key)) 253#define ACTION_LMODS_TAP_KEY(mods, key) ACTION(ACT_LMODS_TAP, MODS4(mods)<<8 | (key))
254#define ACTION_LMODS_ONESHOT(mods) ACTION(ACT_LMODS_TAP, MODS4(mods)<<8 | ONE_SHOT) 254#define ACTION_LMODS_ONESHOT(mods) ACTION(ACT_LMODS_TAP, MODS4(mods)<<8 | P_ONESHOT)
255#define ACTION_RMODS_TAP_KEY(mods, key) ACTION(ACT_RMODS_TAP, MODS4(mods)<<8 | (key)) 255#define ACTION_RMODS_TAP_KEY(mods, key) ACTION(ACT_RMODS_TAP, MODS4(mods)<<8 | (key))
256#define ACTION_RMODS_ONESHOT(mods) ACTION(ACT_RMODS_TAP, MODS4(mods)<<8 | ONE_SHOT) 256#define ACTION_RMODS_ONESHOT(mods) ACTION(ACT_RMODS_TAP, MODS4(mods)<<8 | P_ONESHOT)
257/* Mod + Tap key */ 257/* Mod + Tap key */
258#define ACTION_LMOD_TAP_KEY(mod, key) ACTION(ACT_LMODS_TAP, MODS4(MOD_BIT(mod))<<8 | (key)) 258#define ACTION_LMOD_TAP_KEY(mod, key) ACTION(ACT_LMODS_TAP, MODS4(MOD_BIT(mod))<<8 | (key))
259#define ACTION_LMOD_ONESHOT(mod) ACTION(ACT_LMODS_TAP, MODS4(MOD_BIT(mod))<<8 | ONE_SHOT) 259#define ACTION_LMOD_ONESHOT(mod) ACTION(ACT_LMODS_TAP, MODS4(MOD_BIT(mod))<<8 | P_ONESHOT)
260#define ACTION_RMOD_TAP_KEY(mod, key) ACTION(ACT_RMODS_TAP, MODS4(MOD_BIT(mod))<<8 | (key)) 260#define ACTION_RMOD_TAP_KEY(mod, key) ACTION(ACT_RMODS_TAP, MODS4(MOD_BIT(mod))<<8 | (key))
261#define ACTION_RMOD_ONESHOT(mod) ACTION(ACT_RMODS_TAP, MODS4(MOD_BIT(mod))<<8 | ONE_SHOT) 261#define ACTION_RMOD_ONESHOT(mod) ACTION(ACT_RMODS_TAP, MODS4(MOD_BIT(mod))<<8 | P_ONESHOT)
262 262
263// TODO: contemplate about layer action 263// TODO: contemplate about layer action
264/* Switch current layer */ 264/* Switch current layer */
@@ -304,5 +304,6 @@ enum acion_param {
304 304
305/* Function */ 305/* Function */
306#define ACTION_FUNCTION(id, opt) ACTION(ACT_FUNCTION, (opt)<<8 | id) 306#define ACTION_FUNCTION(id, opt) ACTION(ACT_FUNCTION, (opt)<<8 | id)
307#define ACTION_FUNCTION_TAP(id) ACTION(ACT_FUNCTION, O_TAP<<8 | id)
307 308
308#endif /* ACTION_H */ 309#endif /* ACTION_H */