diff options
Diffstat (limited to 'common/action.h')
| -rw-r--r-- | common/action.h | 251 |
1 files changed, 137 insertions, 114 deletions
diff --git a/common/action.h b/common/action.h index b9a6cb5b4..ead917983 100644 --- a/common/action.h +++ b/common/action.h | |||
| @@ -19,12 +19,23 @@ 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 */ |
| 26 | typedef union { | ||
| 27 | struct { | ||
| 28 | bool interrupted :1; | ||
| 29 | bool reserved2 :1; | ||
| 30 | bool reserved1 :1; | ||
| 31 | bool reserved0 :1; | ||
| 32 | uint8_t count :4; | ||
| 33 | }; | ||
| 34 | } tap_t; | ||
| 35 | |||
| 25 | typedef struct { | 36 | typedef struct { |
| 26 | keyevent_t event; | 37 | keyevent_t event; |
| 27 | uint8_t tap_count; | 38 | tap_t tap; |
| 28 | } keyrecord_t; | 39 | } keyrecord_t; |
| 29 | 40 | ||
| 30 | /* Action struct. | 41 | /* Action struct. |
| @@ -76,17 +87,15 @@ typedef union { | |||
| 76 | 87 | ||
| 77 | 88 | ||
| 78 | 89 | ||
| 79 | /* layer used currently */ | ||
| 80 | extern uint8_t current_layer; | ||
| 81 | /* layer to return or start with */ | ||
| 82 | extern uint8_t default_layer; | ||
| 83 | |||
| 84 | /* Execute action per keyevent */ | 90 | /* Execute action per keyevent */ |
| 85 | void action_exec(keyevent_t event); | 91 | void action_exec(keyevent_t event); |
| 86 | 92 | ||
| 87 | /* action for key */ | 93 | /* action for key */ |
| 88 | action_t action_for_key(uint8_t layer, key_t key); | 94 | action_t action_for_key(uint8_t layer, key_t key); |
| 89 | 95 | ||
| 96 | /* macro */ | ||
| 97 | const prog_macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt); | ||
| 98 | |||
| 90 | /* user defined special function */ | 99 | /* user defined special function */ |
| 91 | void action_function(keyrecord_t *record, uint8_t id, uint8_t opt); | 100 | void action_function(keyrecord_t *record, uint8_t id, uint8_t opt); |
| 92 | 101 | ||
| @@ -112,8 +121,8 @@ bool waiting_buffer_has_anykey_pressed(void); | |||
| 112 | * ============ | 121 | * ============ |
| 113 | * 16bit code: action_kind(4bit) + action_parameter(12bit) | 122 | * 16bit code: action_kind(4bit) + action_parameter(12bit) |
| 114 | * | 123 | * |
| 115 | * Keyboard Keys | 124 | * Keyboard Keys(00XX) |
| 116 | * ------------- | 125 | * ------------------- |
| 117 | * ACT_LMODS(0000): | 126 | * ACT_LMODS(0000): |
| 118 | * 0000|0000|000000|00 No action | 127 | * 0000|0000|000000|00 No action |
| 119 | * 0000|0000|000000|01 Transparent | 128 | * 0000|0000|000000|01 Transparent |
| @@ -143,8 +152,8 @@ bool waiting_buffer_has_anykey_pressed(void); | |||
| 143 | * 0011|mods| keycode Right mods + tap Key | 152 | * 0011|mods| keycode Right mods + tap Key |
| 144 | * | 153 | * |
| 145 | * | 154 | * |
| 146 | * Other HID Usage | 155 | * Other keys(01XX) |
| 147 | * --------------- | 156 | * -------------------- |
| 148 | * This action handles other usages than keyboard. | 157 | * This action handles other usages than keyboard. |
| 149 | * ACT_USAGE(0100): | 158 | * ACT_USAGE(0100): |
| 150 | * 0100|00| usage(10) System control(0x80) - General Desktop page(0x01) | 159 | * 0100|00| usage(10) System control(0x80) - General Desktop page(0x01) |
| @@ -152,41 +161,45 @@ bool waiting_buffer_has_anykey_pressed(void); | |||
| 152 | * 0100|10| usage(10) (reserved) | 161 | * 0100|10| usage(10) (reserved) |
| 153 | * 0100|11| usage(10) (reserved) | 162 | * 0100|11| usage(10) (reserved) |
| 154 | * | 163 | * |
| 155 | * | ||
| 156 | * Mouse Keys | ||
| 157 | * ---------- | ||
| 158 | * TODO: can be combined with 'Other HID Usage'? to save action kind id. | ||
| 159 | * ACT_MOUSEKEY(0110): | 164 | * ACT_MOUSEKEY(0110): |
| 160 | * 0101|XXXX| keycode Mouse key | 165 | * 0101|XXXX| keycode Mouse key |
| 161 | * | 166 | * |
| 162 | * | 167 | * |
| 163 | * Layer Actions | 168 | * Layer Actions(10XX) |
| 164 | * ------------- | 169 | * ------------------- |
| 165 | * ACT_LAYER(1000): Set layer | 170 | * ACT_KEYMAP: |
| 166 | * ACT_LAYER_BIT(1001): Bit-op layer | 171 | * 1000|--xx|0000 0000 Clear keyamp and overlay |
| 167 | * | 172 | * 1000|LLLL|0000 00xx Reset default layer and clear keymap and overlay |
| 168 | * 1000|LLLL|0000 0000 set L to layer on press and set default on release(momentary) | 173 | * 1000|LLLL| keycode Invert with tap key |
| 169 | * 1000|LLLL|0000 0001 set L to layer on press | 174 | * 1000|LLLL|1111 0000 Invert with tap toggle |
| 170 | * 1000|LLLL|0000 0010 set L to layer on release | 175 | * 1000|LLLL|1111 00xx Invert[^= 1<<L] |
| 171 | * 1000|----|0000 0011 set default to layer on both(return to default layer) | 176 | * 1000|LLLL|1111 0100 On/Off |
| 172 | * 1000|LLLL| keycode set L to layer while hold and send key on tap | 177 | * 1000|LLLL|1111 01xx On[|= 1<<L] |
| 173 | * 1000|LLLL|1111 0000 set L to layer while hold and toggle on several taps | 178 | * 1000|LLLL|1111 1000 Off/On |
| 174 | * 1000|LLLL|1111 1111 set L to default and layer(on press) | 179 | * 1000|LLLL|1111 10xx Off[&= ~(1<<L)] |
| 175 | * | 180 | * 1000|LLLL|1111 1100 Set/Clear |
| 176 | * 1001|BBBB|0000 0000 (not used) | 181 | * 1000|LLLL|1111 11xx Set[= 1<<L] |
| 177 | * 1001|BBBB|0000 0001 bit-xor layer with B on press | 182 | * default layer: 0-15(4bit) |
| 178 | * 1001|BBBB|0000 0010 bit-xor layer with B on release | 183 | * xx: On {00:for special use, 01:press, 10:release, 11:both} |
| 179 | * 1001|BBBB|0000 0011 bit-xor layer with B on both(momentary) | ||
| 180 | * 1001|BBBB| keycode bit-xor layer with B while hold and send key on tap | ||
| 181 | * 1001|BBBB|1111 0000 bit-xor layer with B while hold and toggle on several taps | ||
| 182 | * 1001|BBBB|1111 1111 bit-xor default with B and set layer(on press) | ||
| 183 | * | 184 | * |
| 185 | * ACT_OVERLAY: | ||
| 186 | * 1011|0000|0000 0000 Clear overlay | ||
| 187 | * 1011|LLLL|0000 00ss Invert 4-bit chunk [^= L<<(4*ss)] | ||
| 188 | * 1011|LLLL| keycode Invert with tap key | ||
| 189 | * 1011|LLLL|1111 0000 Invert with tap toggle | ||
| 190 | * 1011|LLLL|1111 00xx Invert[^= 1<<L] | ||
| 191 | * 1011|LLLL|1111 0100 On/Off(momentary) | ||
| 192 | * 1011|LLLL|1111 01xx On[|= 1<<L] | ||
| 193 | * 1011|LLLL|1111 1000 Off/On | ||
| 194 | * 1011|LLLL|1111 10xx Off[&= ~(1<<L)] | ||
| 195 | * 1011|LLLL|1111 1100 Set/Clear | ||
| 196 | * 1011|LLLL|1111 11xx Set[= 1<<L] | ||
| 197 | * overlays: 16-layer on/off status(16bit) | ||
| 198 | * xx: On {00:for special use, 01:press, 10:release, 11:both} | ||
| 184 | * | 199 | * |
| 185 | * | 200 | * |
| 186 | * Extensions(11XX) | 201 | * Extensions(11XX) |
| 187 | * ---------------- | 202 | * ---------------- |
| 188 | * NOTE: NOT FIXED | ||
| 189 | * | ||
| 190 | * ACT_MACRO(1100): | 203 | * ACT_MACRO(1100): |
| 191 | * 1100|opt | id(8) Macro play? | 204 | * 1100|opt | id(8) Macro play? |
| 192 | * 1100|1111| id(8) Macro record? | 205 | * 1100|1111| id(8) Macro record? |
| @@ -208,8 +221,8 @@ enum action_kind_id { | |||
| 208 | ACT_USAGE = 0b0100, | 221 | ACT_USAGE = 0b0100, |
| 209 | ACT_MOUSEKEY = 0b0101, | 222 | ACT_MOUSEKEY = 0b0101, |
| 210 | 223 | ||
| 211 | ACT_LAYER = 0b1000, | 224 | ACT_KEYMAP = 0b1000, |
| 212 | ACT_LAYER_BIT = 0b1001, | 225 | ACT_OVERLAY = 0b1001, |
| 213 | 226 | ||
| 214 | ACT_MACRO = 0b1100, | 227 | ACT_MACRO = 0b1100, |
| 215 | ACT_COMMAND = 0b1110, | 228 | ACT_COMMAND = 0b1110, |
| @@ -223,20 +236,20 @@ enum action_kind_id { | |||
| 223 | #define ACTION(kind, param) ((kind)<<12 | (param)) | 236 | #define ACTION(kind, param) ((kind)<<12 | (param)) |
| 224 | #define MODS4(mods) (((mods)>>4 | (mods)) & 0x0F) | 237 | #define MODS4(mods) (((mods)>>4 | (mods)) & 0x0F) |
| 225 | 238 | ||
| 226 | /* Key */ | 239 | /* |
| 240 | * Key | ||
| 241 | */ | ||
| 227 | #define ACTION_KEY(key) ACTION(ACT_LMODS, key) | 242 | #define ACTION_KEY(key) ACTION(ACT_LMODS, key) |
| 228 | /* Mods & key */ | 243 | /* Mods & key */ |
| 229 | #define ACTION_LMODS(mods) ACTION(ACT_LMODS, MODS4(mods)<<8 | 0x00) | 244 | #define ACTION_LMODS(mods) ACTION(ACT_LMODS, MODS4(mods)<<8 | 0x00) |
| 230 | #define ACTION_LMODS_KEY(mods, key) ACTION(ACT_LMODS, MODS4(mods)<<8 | (key)) | 245 | #define ACTION_LMODS_KEY(mods, key) ACTION(ACT_LMODS, MODS4(mods)<<8 | (key)) |
| 231 | #define ACTION_RMODS(mods) ACTION(ACT_RMODS, MODS4(mods)<<8 | 0x00) | 246 | #define ACTION_RMODS(mods) ACTION(ACT_RMODS, MODS4(mods)<<8 | 0x00) |
| 232 | #define ACTION_RMODS_KEY(mods, key) ACTION(ACT_RMODS, MODS4(mods)<<8 | (key)) | 247 | #define ACTION_RMODS_KEY(mods, key) ACTION(ACT_RMODS, MODS4(mods)<<8 | (key)) |
| 233 | /* Mod & key */ | ||
| 234 | #define ACTION_LMOD(mod) ACTION(ACT_LMODS, MODS4(MOD_BIT(mod))<<8 | 0x00) | 248 | #define ACTION_LMOD(mod) ACTION(ACT_LMODS, MODS4(MOD_BIT(mod))<<8 | 0x00) |
| 235 | #define ACTION_LMOD_KEY(mod, key) ACTION(ACT_LMODS, MODS4(MOD_BIT(mod))<<8 | (key)) | 249 | #define ACTION_LMOD_KEY(mod, key) ACTION(ACT_LMODS, MODS4(MOD_BIT(mod))<<8 | (key)) |
| 236 | #define ACTION_RMOD(mod) ACTION(ACT_RMODS, MODS4(MOD_BIT(mod))<<8 | 0x00) | 250 | #define ACTION_RMOD(mod) ACTION(ACT_RMODS, MODS4(MOD_BIT(mod))<<8 | 0x00) |
| 237 | #define ACTION_RMOD_KEY(mod, key) ACTION(ACT_RMODS, MODS4(MOD_BIT(mod))<<8 | (key)) | 251 | #define ACTION_RMOD_KEY(mod, key) ACTION(ACT_RMODS, MODS4(MOD_BIT(mod))<<8 | (key)) |
| 238 | 252 | /* Tap key */ | |
| 239 | /* Mods + Tap key */ | ||
| 240 | enum mods_codes { | 253 | enum mods_codes { |
| 241 | MODS_ONESHOT = 0x00, | 254 | MODS_ONESHOT = 0x00, |
| 242 | }; | 255 | }; |
| @@ -244,102 +257,112 @@ enum mods_codes { | |||
| 244 | #define ACTION_LMODS_ONESHOT(mods) ACTION(ACT_LMODS_TAP, MODS4(mods)<<8 | MODS_ONESHOT) | 257 | #define ACTION_LMODS_ONESHOT(mods) ACTION(ACT_LMODS_TAP, MODS4(mods)<<8 | MODS_ONESHOT) |
| 245 | #define ACTION_RMODS_TAP_KEY(mods, key) ACTION(ACT_RMODS_TAP, MODS4(mods)<<8 | (key)) | 258 | #define ACTION_RMODS_TAP_KEY(mods, key) ACTION(ACT_RMODS_TAP, MODS4(mods)<<8 | (key)) |
| 246 | #define ACTION_RMODS_ONESHOT(mods) ACTION(ACT_RMODS_TAP, MODS4(mods)<<8 | MODS_ONESHOT) | 259 | #define ACTION_RMODS_ONESHOT(mods) ACTION(ACT_RMODS_TAP, MODS4(mods)<<8 | MODS_ONESHOT) |
| 247 | /* Mod + Tap key */ | ||
| 248 | #define ACTION_LMOD_TAP_KEY(mod, key) ACTION(ACT_LMODS_TAP, MODS4(MOD_BIT(mod))<<8 | (key)) | 260 | #define ACTION_LMOD_TAP_KEY(mod, key) ACTION(ACT_LMODS_TAP, MODS4(MOD_BIT(mod))<<8 | (key)) |
| 249 | #define ACTION_LMOD_ONESHOT(mod) ACTION(ACT_LMODS_TAP, MODS4(MOD_BIT(mod))<<8 | MODS_ONESHOT) | 261 | #define ACTION_LMOD_ONESHOT(mod) ACTION(ACT_LMODS_TAP, MODS4(MOD_BIT(mod))<<8 | MODS_ONESHOT) |
| 250 | #define ACTION_RMOD_TAP_KEY(mod, key) ACTION(ACT_RMODS_TAP, MODS4(MOD_BIT(mod))<<8 | (key)) | 262 | #define ACTION_RMOD_TAP_KEY(mod, key) ACTION(ACT_RMODS_TAP, MODS4(MOD_BIT(mod))<<8 | (key)) |
| 251 | #define ACTION_RMOD_ONESHOT(mod) ACTION(ACT_RMODS_TAP, MODS4(MOD_BIT(mod))<<8 | MODS_ONESHOT) | 263 | #define ACTION_RMOD_ONESHOT(mod) ACTION(ACT_RMODS_TAP, MODS4(MOD_BIT(mod))<<8 | MODS_ONESHOT) |
| 252 | 264 | ||
| 265 | /* HID Usage */ | ||
| 266 | enum usage_pages { | ||
| 267 | PAGE_SYSTEM, | ||
| 268 | PAGE_CONSUMER | ||
| 269 | }; | ||
| 270 | #define ACTION_USAGE_SYSTEM(id) ACTION(ACT_USAGE, PAGE_SYSTEM<<10 | (id)) | ||
| 271 | #define ACTION_USAGE_CONSUMER(id) ACTION(ACT_USAGE, PAGE_CONSUMER<<10 | (id)) | ||
| 253 | 272 | ||
| 254 | /* | 273 | /* Mousekey */ |
| 255 | * Switch layer | 274 | #define ACTION_MOUSEKEY(key) ACTION(ACT_MOUSEKEY, key) |
| 275 | |||
| 276 | |||
| 277 | |||
| 278 | /* Layer Actions: | ||
| 279 | * Invert layer ^= (1<<layer) | ||
| 280 | * On layer |= (1<<layer) | ||
| 281 | * Off layer &= ~(1<<layer) | ||
| 282 | * Set layer = (1<<layer) | ||
| 283 | * Clear layer = 0 | ||
| 256 | */ | 284 | */ |
| 257 | enum layer_codes { | 285 | enum layer_params { |
| 258 | LAYER_MOMENTARY = 0, | 286 | ON_PRESS = 1, |
| 259 | LAYER_ON_PRESS = 1, | 287 | ON_RELEASE = 2, |
| 260 | LAYER_ON_RELEASE = 2, | 288 | ON_BOTH = 3, |
| 261 | LAYER_DEFAULT =3, | 289 | |
| 262 | LAYER_TAP_TOGGLE = 0xF0, | 290 | OP_RESET = 0x00, |
| 263 | LAYER_CHANGE_DEFAULT = 0xFF | 291 | OP_INV4 = 0x00, |
| 264 | }; | 292 | OP_INV = 0xF0, |
| 265 | enum layer_vals_default { | 293 | OP_ON = 0xF4, |
| 266 | DEFAULT_ON_PRESS = 1, | 294 | OP_OFF = 0xF8, |
| 267 | DEFAULT_ON_RELEASE = 2, | 295 | OP_SET = 0xFC, |
| 268 | DEFAULT_ON_BOTH = 3, | ||
| 269 | }; | 296 | }; |
| 270 | 297 | ||
| 271 | /* | 298 | /* |
| 272 | * return to default layer | 299 | * Default Layer |
| 273 | */ | 300 | */ |
| 274 | #define ACTION_LAYER_DEFAULT ACTION_LAYER_DEFAULT_R | 301 | #define ACTION_DEFAULT_LAYER ACTION(ACT_KEYMAP, ON_RELEASE<<8 | OP_RESET | 0) |
| 275 | /* set default layer on press */ | 302 | #define ACTION_DEFAULT_LAYER_SET(layer) ACTION_DEFAULT_LAYER_TO(layer, ON_RELEASE) |
| 276 | #define ACTION_LAYER_DEFAULT_P ACTION(ACT_LAYER, DEFAULT_ON_PRESS<<8 | LAYER_DEFAULT) | 303 | #define ACTION_DEFAULT_LAYER_TO(layer, on) ACTION(ACT_KEYMAP, (layer)<<8 | OP_RESET | (on)) |
| 277 | /* set default layer on release */ | ||
| 278 | #define ACTION_LAYER_DEFAULT_R ACTION(ACT_LAYER, DEFAULT_ON_RELEASE<<8 | LAYER_DEFAULT) | ||
| 279 | /* change default layer and set layer */ | ||
| 280 | |||
| 281 | /* | 304 | /* |
| 282 | * Set layer | 305 | * Keymap Layer |
| 283 | */ | 306 | */ |
| 284 | /* set layer on press and none on release */ | 307 | #define ACTION_KEYMAP_MOMENTARY(layer) ACTION_KEYMAP_ON_OFF(layer) |
| 285 | #define ACTION_LAYER_SET(layer) ACTION_LAYER_SET_P(layer) | 308 | #define ACTION_KEYMAP_TOGGLE(layer) ACTION_KEYMAP_INV(layer, ON_RELEASE) |
| 286 | /* set layer on press and set default on release (This is needed by legacy keymap support.) */ | 309 | /* Keymap Invert */ |
| 287 | #define ACTION_LAYER_SET_MOMENTARY(layer) ACTION(ACT_LAYER, (layer)<<8 | LAYER_MOMENTARY) | 310 | #define ACTION_KEYMAP_INV(layer, on) ACTION(ACT_KEYMAP, (layer)<<8 | OP_INV | (on)) |
| 288 | /* set layer on press and none on release */ | 311 | #define ACTION_KEYMAP_TAP_TOGGLE(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_INV | 0) |
| 289 | #define ACTION_LAYER_SET_TOGGLE(layer) ACTION_LAYER_SET_R(layer) | 312 | /* Keymap On */ |
| 290 | /* set layer while hold and send key on tap */ | 313 | #define ACTION_KEYMAP_ON(layer, on) ACTION(ACT_KEYMAP, (layer)<<8 | OP_ON | (on)) |
| 291 | #define ACTION_LAYER_SET_TAP_KEY(layer, key) ACTION(ACT_LAYER, (layer)<<8 | (key)) | 314 | #define ACTION_KEYMAP_ON_OFF(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_ON | 0) |
| 292 | /* set layer on press */ | 315 | /* Keymap Off */ |
| 293 | #define ACTION_LAYER_SET_P(layer) ACTION(ACT_LAYER, (layer)<<8 | LAYER_ON_PRESS) | 316 | #define ACTION_KEYMAP_OFF(layer, on) ACTION(ACT_KEYMAP, (layer)<<8 | OP_OFF | (on)) |
| 294 | /* set layer on release */ | 317 | #define ACTION_KEYMAP_OFF_ON(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_OFF | 0) |
| 295 | #define ACTION_LAYER_SET_R(layer) ACTION(ACT_LAYER, (layer)<<8 | LAYER_ON_RELEASE) | 318 | /* Keymap Set */ |
| 296 | /* set layer on hold and toggle on several taps */ | 319 | #define ACTION_KEYMAP_SET(layer, on) ACTION(ACT_KEYMAP, (layer)<<8 | OP_SET | (on)) |
| 297 | #define ACTION_LAYER_SET_TAP_TOGGLE(layer) ACTION(ACT_LAYER, (layer)<<8 | LAYER_TAP_TOGGLE) | 320 | #define ACTION_KEYMAP_SET_CLEAR(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_SET | 0) |
| 298 | /* set default layer on both press and release */ | 321 | /* Keymap Invert with tap key */ |
| 299 | #define ACTION_LAYER_SET_DEFAULT(layer) ACTION(ACT_LAYER, (layer)<<8 | LAYER_CHANGE_DEFAULT) | 322 | #define ACTION_KEYMAP_TAP_KEY(layer, key) ACTION(ACT_KEYMAP, (layer)<<8 | (key)) |
| 300 | 323 | ||
| 301 | /* | 324 | /* |
| 302 | * Bit-op layer | 325 | * Overlay Layer |
| 303 | */ | 326 | */ |
| 304 | /* bit-xor on both press and release */ | 327 | #define ACTION_OVERLAY_MOMENTARY(layer) ACTION_OVERLAY_ON_OFF(layer) |
| 305 | #define ACTION_LAYER_BIT(bits) ACTION_LAYER_BIT_MOMENTARY(bits) | 328 | #define ACTION_OVERLAY_TOGGLE(layer) ACTION_OVERLAY_INV(layer, ON_RELEASE) |
| 306 | #define ACTION_LAYER_BIT_MOMENTARY(bits) ACTION(ACT_LAYER_BIT, (bits)<<8 | LAYER_MOMENTARY) | 329 | /* Overlay Clear */ |
| 307 | /* bit-xor on press */ | 330 | #define ACTION_OVERLAY_CLEAR(on) ACTION(ACT_OVERLAY, 0<<8 | OP_INV4 | (on)) |
| 308 | #define ACTION_LAYER_BIT_TOGGLE(bits) ACTION_LAYER_BIT_R(bits) | 331 | /* Overlay Invert 4-bit chunk */ |
| 309 | /* bit-xor while hold and send key on tap */ | 332 | #define ACTION_OVERLAY_INV4(bits, shift) ACTION(ACT_OVERLAY, (bits)<<8 | OP_INV4 | shift) |
| 310 | #define ACTION_LAYER_BIT_TAP_KEY(bits, key) ACTION(ACT_LAYER_BIT, (bits)<<8 | (key)) | 333 | /* Overlay Invert */ |
| 311 | /* bit-xor on press */ | 334 | #define ACTION_OVERLAY_INV(layer, on) ACTION(ACT_OVERLAY, (layer)<<8 | OP_INV | (on)) |
| 312 | #define ACTION_LAYER_BIT_P(bits) ACTION(ACT_LAYER_BIT, (bits)<<8 | LAYER_ON_PRESS) | 335 | #define ACTION_OVERLAY_TAP_TOGGLE(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_INV | 0) |
| 313 | /* bit-xor on release */ | 336 | /* Overlay On */ |
| 314 | #define ACTION_LAYER_BIT_R(bits) ACTION(ACT_LAYER_BIT, (bits)<<8 | LAYER_ON_RELEASE) | 337 | #define ACTION_OVERLAY_ON(layer, on) ACTION(ACT_OVERLAY, (layer)<<8 | OP_ON | (on)) |
| 315 | /* bit-xor while hold and toggle on several taps */ | 338 | #define ACTION_OVERLAY_ON_OFF(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_ON | 0) |
| 316 | #define ACTION_LAYER_BIT_TAP_TOGGLE(bits) ACTION(ACT_LAYER_BIT, (bits)<<8 | LAYER_TAP_TOGGLE) | 339 | /* Overlay Off */ |
| 317 | /* bit-xor default layer and set layer */ | 340 | #define ACTION_OVERLAY_OFF(layer, on) ACTION(ACT_OVERLAY, (layer)<<8 | OP_OFF | (on)) |
| 318 | #define ACTION_LAYER_BIT_DEFAULT(bits) ACTION(ACT_LAYER, (bits)<<8 | LAYER_CHANGE_DEFAULT) | 341 | #define ACTION_OVERLAY_OFF_ON(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_OFF | 0) |
| 319 | 342 | /* Overlay Set */ | |
| 320 | 343 | #define ACTION_OVERLAY_SET(layer, on) ACTION(ACT_OVERLAY, (layer)<<8 | OP_SET | (on)) | |
| 321 | /* HID Usage */ | 344 | #define ACTION_OVERLAY_SET_CLEAR(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_SET | 0) |
| 322 | enum usage_pages { | 345 | /* Overlay Invert with tap key */ |
| 323 | PAGE_SYSTEM, | 346 | #define ACTION_OVERLAY_TAP_KEY(layer, key) ACTION(ACT_OVERLAY, (layer)<<8 | (key)) |
| 324 | PAGE_CONSUMER | ||
| 325 | }; | ||
| 326 | #define ACTION_USAGE_SYSTEM(id) ACTION(ACT_USAGE, PAGE_SYSTEM<<10 | (id)) | ||
| 327 | #define ACTION_USAGE_CONSUMER(id) ACTION(ACT_USAGE, PAGE_CONSUMER<<10 | (id)) | ||
| 328 | 347 | ||
| 329 | /* Mousekey */ | ||
| 330 | #define ACTION_MOUSEKEY(key) ACTION(ACT_MOUSEKEY, key) | ||
| 331 | 348 | ||
| 349 | /* | ||
| 350 | * Extensions | ||
| 351 | */ | ||
| 332 | /* Macro */ | 352 | /* Macro */ |
| 333 | #define ACTION_MACRO(opt, id) ACTION(ACT_FUNCTION, (opt)<<8 | (addr)) | 353 | #define ACTION_MACRO(id) ACTION(ACT_MACRO, (id)) |
| 354 | #define ACTION_MACRO_TAP(id) ACTION(ACT_MACRO, FUNC_TAP<<8 | (id)) | ||
| 355 | #define ACTION_MACRO_OPT(id, opt) ACTION(ACT_MACRO, (opt)<<8 | (id)) | ||
| 334 | 356 | ||
| 335 | /* Command */ | 357 | /* Command */ |
| 336 | #define ACTION_COMMAND(opt, id) ACTION(ACT_COMMAND, (opt)<<8 | (addr)) | 358 | #define ACTION_COMMAND(id, opt) ACTION(ACT_COMMAND, (opt)<<8 | (addr)) |
| 337 | 359 | ||
| 338 | /* Function */ | 360 | /* Function */ |
| 339 | enum function_opts { | 361 | enum function_opts { |
| 340 | FUNC_TAP = 0x8, /* indciates function is tappable */ | 362 | FUNC_TAP = 0x8, /* indciates function is tappable */ |
| 341 | }; | 363 | }; |
| 342 | #define ACTION_FUNCTION(id, opt) ACTION(ACT_FUNCTION, (opt)<<8 | id) | 364 | #define ACTION_FUNCTION(id) ACTION(ACT_FUNCTION, (id)) |
| 343 | #define ACTION_FUNCTION_TAP(id) ACTION(ACT_FUNCTION, FUNC_TAP<<8 | id) | 365 | #define ACTION_FUNCTION_TAP(id) ACTION(ACT_FUNCTION, FUNC_TAP<<8 | (id)) |
| 366 | #define ACTION_FUNCTION_OPT(id, opt) ACTION(ACT_FUNCTION, (opt)<<8 | (id)) | ||
| 344 | 367 | ||
| 345 | #endif /* ACTION_H */ | 368 | #endif /* ACTION_H */ |
