aboutsummaryrefslogtreecommitdiff
path: root/common/action.h
diff options
context:
space:
mode:
Diffstat (limited to 'common/action.h')
-rw-r--r--common/action.h200
1 files changed, 105 insertions, 95 deletions
diff --git a/common/action.h b/common/action.h
index bb44049ad..b9a6cb5b4 100644
--- a/common/action.h
+++ b/common/action.h
@@ -21,10 +21,6 @@ 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 */ 24/* Struct to record event and tap count */
29typedef struct { 25typedef struct {
30 keyevent_t event; 26 keyevent_t event;
@@ -33,7 +29,7 @@ typedef struct {
33 29
34/* Action struct. 30/* Action struct.
35 * 31 *
36 * In avr-gcc bit field seems to be assigned from LSB(bit0) to MSB(bit15). 32 * In avr-gcc bit field seems to be assigned from LSB(bit0) to MSB(bit15).
37 * AVR looks like a little endian in avr-gcc. 33 * AVR looks like a little endian in avr-gcc.
38 * 34 *
39 * NOTE: not portable across compiler/endianness? 35 * NOTE: not portable across compiler/endianness?
@@ -79,6 +75,21 @@ typedef union {
79} action_t; 75} action_t;
80 76
81 77
78
79/* layer used currently */
80extern uint8_t current_layer;
81/* layer to return or start with */
82extern uint8_t default_layer;
83
84/* Execute action per keyevent */
85void action_exec(keyevent_t event);
86
87/* action for key */
88action_t action_for_key(uint8_t layer, key_t key);
89
90/* user defined special function */
91void action_function(keyrecord_t *record, uint8_t id, uint8_t opt);
92
82/* 93/*
83 * Utilities for actions. 94 * Utilities for actions.
84 */ 95 */
@@ -96,98 +107,97 @@ bool waiting_buffer_has_anykey_pressed(void);
96 107
97 108
98 109
99
100/* 110/*
101 * Action codes 111 * Action codes
102 * ============ 112 * ============
103 * 16bit code: action_kind(4bit) + action_parameter(12bit) 113 * 16bit code: action_kind(4bit) + action_parameter(12bit)
104 * 114 *
105Keyboard Keys 115 * Keyboard Keys
106------------- 116 * -------------
107ACT_LMODS(0000): 117 * ACT_LMODS(0000):
1080000|0000|000000|00 No action 118 * 0000|0000|000000|00 No action
1090000|0000|000000|01 Transparent 119 * 0000|0000|000000|01 Transparent
1100000|0000| keycode Key 120 * 0000|0000| keycode Key
1110000|mods|000000|00 Left mods 121 * 0000|mods|000000|00 Left mods
1120000|mods| keycode Key & Left mods 122 * 0000|mods| keycode Key & Left mods
113 123 *
114ACT_RMODS(0001): 124 * ACT_RMODS(0001):
1150001|0000|000000|00 No action(not used) 125 * 0001|0000|000000|00 No action(not used)
1160001|0000|000000|01 Transparent(not used) 126 * 0001|0000|000000|01 Transparent(not used)
1170001|0000| keycode Key(no used) 127 * 0001|0000| keycode Key(no used)
1180001|mods|000000|00 Right mods 128 * 0001|mods|000000|00 Right mods
1190001|mods| keycode Key & Right mods 129 * 0001|mods| keycode Key & Right mods
120 130 *
121ACT_LMODS_TAP(0010): 131 * ACT_LMODS_TAP(0010):
1220010|mods|000000|00 Left mods OneShot 132 * 0010|mods|000000|00 Left mods OneShot
1230010|mods|000000|01 (reserved) 133 * 0010|mods|000000|01 (reserved)
1240010|mods|000000|10 (reserved) 134 * 0010|mods|000000|10 (reserved)
1250010|mods|000000|11 (reserved) 135 * 0010|mods|000000|11 (reserved)
1260010|mods| keycode Left mods + tap Key 136 * 0010|mods| keycode Left mods + tap Key
127 137 *
128ACT_RMODS_TAP(0011): 138 * ACT_RMODS_TAP(0011):
1290011|mods|000000|00 Right mods OneShot 139 * 0011|mods|000000|00 Right mods OneShot
1300011|mods|000000|01 (reserved) 140 * 0011|mods|000000|01 (reserved)
1310011|mods|000000|10 (reserved) 141 * 0011|mods|000000|10 (reserved)
1320011|mods|000000|11 (reserved) 142 * 0011|mods|000000|11 (reserved)
1330011|mods| keycode Right mods + tap Key 143 * 0011|mods| keycode Right mods + tap Key
134 144 *
135 145 *
136Other HID Usage 146 * Other HID Usage
137--------------- 147 * ---------------
138This action handles other usages than keyboard. 148 * This action handles other usages than keyboard.
139ACT_USAGE(0100): 149 * ACT_USAGE(0100):
1400100|00| usage(10) System control(0x80) - General Desktop page(0x01) 150 * 0100|00| usage(10) System control(0x80) - General Desktop page(0x01)
1410100|01| usage(10) Consumer control(0x01) - Consumer page(0x0C) 151 * 0100|01| usage(10) Consumer control(0x01) - Consumer page(0x0C)
1420100|10| usage(10) (reserved) 152 * 0100|10| usage(10) (reserved)
1430100|11| usage(10) (reserved) 153 * 0100|11| usage(10) (reserved)
144 154 *
145 155 *
146Mouse Keys 156 * Mouse Keys
147---------- 157 * ----------
148TODO: can be combined with 'Other HID Usage'? to save action kind id. 158 * TODO: can be combined with 'Other HID Usage'? to save action kind id.
149ACT_MOUSEKEY(0110): 159 * ACT_MOUSEKEY(0110):
1500101|XXXX| keycode Mouse key 160 * 0101|XXXX| keycode Mouse key
151 161 *
152 162 *
153Layer Actions 163 * Layer Actions
154------------- 164 * -------------
155ACT_LAYER(1000): Set layer 165 * ACT_LAYER(1000): Set layer
156ACT_LAYER_BIT(1001): Bit-op layer 166 * ACT_LAYER_BIT(1001): Bit-op layer
157 167 *
1581000|LLLL|0000 0000 set L to layer on press and set default on release(momentary) 168 * 1000|LLLL|0000 0000 set L to layer on press and set default on release(momentary)
1591000|LLLL|0000 0001 set L to layer on press 169 * 1000|LLLL|0000 0001 set L to layer on press
1601000|LLLL|0000 0010 set L to layer on release 170 * 1000|LLLL|0000 0010 set L to layer on release
1611000|----|0000 0011 set default to layer on both(return to default layer) 171 * 1000|----|0000 0011 set default to layer on both(return to default layer)
1621000|LLLL| keycode set L to layer while hold and send key on tap 172 * 1000|LLLL| keycode set L to layer while hold and send key on tap
1631000|LLLL|1111 0000 set L to layer while hold and toggle on several taps 173 * 1000|LLLL|1111 0000 set L to layer while hold and toggle on several taps
1641000|LLLL|1111 1111 set L to default and layer(on press) 174 * 1000|LLLL|1111 1111 set L to default and layer(on press)
165 175 *
1661001|BBBB|0000 0000 (not used) 176 * 1001|BBBB|0000 0000 (not used)
1671001|BBBB|0000 0001 bit-xor layer with B on press 177 * 1001|BBBB|0000 0001 bit-xor layer with B on press
1681001|BBBB|0000 0010 bit-xor layer with B on release 178 * 1001|BBBB|0000 0010 bit-xor layer with B on release
1691001|BBBB|0000 0011 bit-xor layer with B on both(momentary) 179 * 1001|BBBB|0000 0011 bit-xor layer with B on both(momentary)
1701001|BBBB| keycode bit-xor layer with B while hold and send key on tap 180 * 1001|BBBB| keycode bit-xor layer with B while hold and send key on tap
1711001|BBBB|1111 0000 bit-xor layer with B while hold and toggle on several taps 181 * 1001|BBBB|1111 0000 bit-xor layer with B while hold and toggle on several taps
1721001|BBBB|1111 1111 bit-xor default with B and set layer(on press) 182 * 1001|BBBB|1111 1111 bit-xor default with B and set layer(on press)
173 183 *
174 184 *
175 185 *
176Extensions(11XX) 186 * Extensions(11XX)
177---------------- 187 * ----------------
178NOTE: NOT FIXED 188 * NOTE: NOT FIXED
179 189 *
180ACT_MACRO(1100): 190 * ACT_MACRO(1100):
1811100|opt | id(8) Macro play? 191 * 1100|opt | id(8) Macro play?
1821100|1111| id(8) Macro record? 192 * 1100|1111| id(8) Macro record?
183 193 *
184ACT_COMMAND(1110): 194 * ACT_COMMAND(1110):
1851110|opt | id(8) Built-in Command exec 195 * 1110|opt | id(8) Built-in Command exec
186 196 *
187ACT_FUNCTION(1111): 197 * ACT_FUNCTION(1111):
1881111| address(12) Function? 198 * 1111| address(12) Function?
1891111|opt | id(8) Function? 199 * 1111|opt | id(8) Function?
190 200 *
191 */ 201 */
192enum action_kind_id { 202enum action_kind_id {
193 ACT_LMODS = 0b0000, 203 ACT_LMODS = 0b0000,
@@ -241,7 +251,7 @@ enum mods_codes {
241#define ACTION_RMOD_ONESHOT(mod) ACTION(ACT_RMODS_TAP, MODS4(MOD_BIT(mod))<<8 | MODS_ONESHOT) 251#define ACTION_RMOD_ONESHOT(mod) ACTION(ACT_RMODS_TAP, MODS4(MOD_BIT(mod))<<8 | MODS_ONESHOT)
242 252
243 253
244/* 254/*
245 * Switch layer 255 * Switch layer
246 */ 256 */
247enum layer_codes { 257enum layer_codes {
@@ -258,7 +268,7 @@ enum layer_vals_default {
258 DEFAULT_ON_BOTH = 3, 268 DEFAULT_ON_BOTH = 3,
259}; 269};
260 270
261/* 271/*
262 * return to default layer 272 * return to default layer
263 */ 273 */
264#define ACTION_LAYER_DEFAULT ACTION_LAYER_DEFAULT_R 274#define ACTION_LAYER_DEFAULT ACTION_LAYER_DEFAULT_R
@@ -288,7 +298,7 @@ enum layer_vals_default {
288/* set default layer on both press and release */ 298/* set default layer on both press and release */
289#define ACTION_LAYER_SET_DEFAULT(layer) ACTION(ACT_LAYER, (layer)<<8 | LAYER_CHANGE_DEFAULT) 299#define ACTION_LAYER_SET_DEFAULT(layer) ACTION(ACT_LAYER, (layer)<<8 | LAYER_CHANGE_DEFAULT)
290 300
291/* 301/*
292 * Bit-op layer 302 * Bit-op layer
293 */ 303 */
294/* bit-xor on both press and release */ 304/* bit-xor on both press and release */