diff options
Diffstat (limited to 'common/action.h')
| -rw-r--r-- | common/action.h | 148 |
1 files changed, 77 insertions, 71 deletions
diff --git a/common/action.h b/common/action.h index a6cb45384..2c4f306a4 100644 --- a/common/action.h +++ b/common/action.h | |||
| @@ -65,8 +65,8 @@ typedef union { | |||
| 65 | } key; | 65 | } key; |
| 66 | struct action_layer { | 66 | struct action_layer { |
| 67 | uint8_t code :8; | 67 | uint8_t code :8; |
| 68 | uint8_t val :4; | 68 | uint8_t val :5; |
| 69 | uint8_t kind :4; | 69 | uint8_t kind :3; |
| 70 | } layer; | 70 | } layer; |
| 71 | struct action_usage { | 71 | struct action_usage { |
| 72 | uint16_t code :10; | 72 | uint16_t code :10; |
| @@ -170,35 +170,42 @@ void debug_action(action_t action); | |||
| 170 | * | 170 | * |
| 171 | * Layer Actions(10XX) | 171 | * Layer Actions(10XX) |
| 172 | * ------------------- | 172 | * ------------------- |
| 173 | * ACT_KEYMAP: | 173 | * ACT_LAYER: |
| 174 | * 1000|--xx|0000 0000 Clear keyamp and overlay | 174 | * 1000|--xx|0000 0000 Clear keyamp |
| 175 | * 1000|LLLL|0000 00xx Reset default layer and clear keymap and overlay | 175 | * 100X|LLLL|0000 00xx Reset default layer and clear keymap |
| 176 | * 1000|LLLL| keycode Invert with tap key | 176 | * 100X|LLLL| keycode Invert with tap key |
| 177 | * 1000|LLLL|1111 0000 Invert with tap toggle | 177 | * 100X|LLLL|1111 0000 Invert with tap toggle |
| 178 | * 1000|LLLL|1111 00xx Invert[^= 1<<L] | 178 | * 100X|LLLL|1111 00xx Invert[^= 1<<L] |
| 179 | * 1000|LLLL|1111 0100 On/Off | 179 | * 100X|LLLL|1111 0100 On/Off |
| 180 | * 1000|LLLL|1111 01xx On[|= 1<<L] | 180 | * 100X|LLLL|1111 01xx On[|= 1<<L] |
| 181 | * 1000|LLLL|1111 1000 Off/On | 181 | * 100X|LLLL|1111 1000 Off/On |
| 182 | * 1000|LLLL|1111 10xx Off[&= ~(1<<L)] | 182 | * 100X|LLLL|1111 10xx Off[&= ~(1<<L)] |
| 183 | * 1000|LLLL|1111 1100 Set/Clear | 183 | * 100X|LLLL|1111 1100 Set/Clear |
| 184 | * 1000|LLLL|1111 11xx Set[= 1<<L] | 184 | * 100X|LLLL|1111 11xx Set[= 1<<L] |
| 185 | * default layer: 0-15(4bit) | 185 | * XLLLL: Layer 0-31 |
| 186 | * xx: On {00:for special use, 01:press, 10:release, 11:both} | 186 | * xx: On {00:for special use, 01:press, 10:release, 11:both} |
| 187 | * | 187 | * |
| 188 | * ACT_OVERLAY: | 188 | * ACT_LAYER_BITOP: |
| 189 | * 1011|0000|0000 0000 Clear overlay | 189 | * 101B|Booo|xxxx xxxx bit operation |
| 190 | * 1011|LLLL|0000 00ss Invert 4-bit chunk [^= L<<(4*ss)] | 190 | * BB: operand. which part of layer state bits |
| 191 | * 1011|LLLL| keycode Invert with tap key | 191 | * 00: 0-7th bit |
| 192 | * 1011|LLLL|1111 0000 Invert with tap toggle | 192 | * 01: 8-15th bit |
| 193 | * 1011|LLLL|1111 00xx Invert[^= 1<<L] | 193 | * 10: 16-23th bit |
| 194 | * 1011|LLLL|1111 0100 On/Off(momentary) | 194 | * 11: 24-31th bit |
| 195 | * 1011|LLLL|1111 01xx On[|= 1<<L] | 195 | * ooo: operation. |
| 196 | * 1011|LLLL|1111 1000 Off/On | 196 | * 000: AND |
| 197 | * 1011|LLLL|1111 10xx Off[&= ~(1<<L)] | 197 | * 001: OR |
| 198 | * 1011|LLLL|1111 1100 Set/Clear | 198 | * 010: XOR |
| 199 | * 1011|LLLL|1111 11xx Set[= 1<<L] | 199 | * 011: |
| 200 | * overlays: 16-layer on/off status(16bit) | 200 | * 100: LSHIFT |
| 201 | * xx: On {00:for special use, 01:press, 10:release, 11:both} | 201 | * 101: RSHIFT |
| 202 | * 110: | ||
| 203 | * 111: | ||
| 204 | * bbbb bbbb: bits | ||
| 205 | * layer_state |= (((layer_state>>(0bBB*8)) & 0xff) BITOP 0bxxxxxxxx)<<(0bBB*8) | ||
| 206 | * layer_state: 32-bit layer switch state | ||
| 207 | * | ||
| 208 | * | ||
| 202 | * | 209 | * |
| 203 | * | 210 | * |
| 204 | * Extensions(11XX) | 211 | * Extensions(11XX) |
| @@ -216,16 +223,20 @@ void debug_action(action_t action); | |||
| 216 | * | 223 | * |
| 217 | */ | 224 | */ |
| 218 | enum action_kind_id { | 225 | enum action_kind_id { |
| 226 | ACT_MODS = 0b0000, | ||
| 219 | ACT_LMODS = 0b0000, | 227 | ACT_LMODS = 0b0000, |
| 220 | ACT_RMODS = 0b0001, | 228 | ACT_RMODS = 0b0001, |
| 229 | ACT_MODS_TAP = 0b0010, | ||
| 221 | ACT_LMODS_TAP = 0b0010, | 230 | ACT_LMODS_TAP = 0b0010, |
| 222 | ACT_RMODS_TAP = 0b0011, | 231 | ACT_RMODS_TAP = 0b0011, |
| 223 | 232 | ||
| 224 | ACT_USAGE = 0b0100, | 233 | ACT_USAGE = 0b0100, |
| 225 | ACT_MOUSEKEY = 0b0101, | 234 | ACT_MOUSEKEY = 0b0101, |
| 226 | 235 | ||
| 227 | ACT_KEYMAP = 0b1000, | 236 | ACT_LAYER = 0b1000, |
| 228 | ACT_OVERLAY = 0b1001, | 237 | ACT_LAYER1 = 0b1001, |
| 238 | ACT_LAYER_BITOP = 0b1010, | ||
| 239 | ACT_LAYER1_BITOP = 0b1011, | ||
| 229 | 240 | ||
| 230 | ACT_MACRO = 0b1100, | 241 | ACT_MACRO = 0b1100, |
| 231 | ACT_COMMAND = 0b1110, | 242 | ACT_COMMAND = 0b1110, |
| @@ -285,12 +296,14 @@ enum usage_pages { | |||
| 285 | * Set layer = (1<<layer) | 296 | * Set layer = (1<<layer) |
| 286 | * Clear layer = 0 | 297 | * Clear layer = 0 |
| 287 | */ | 298 | */ |
| 288 | enum layer_params { | 299 | enum layer_param_on { |
| 289 | ON_PRESS = 1, | 300 | ON_PRESS = 1, |
| 290 | ON_RELEASE = 2, | 301 | ON_RELEASE = 2, |
| 291 | ON_BOTH = 3, | 302 | ON_BOTH = 3, |
| 303 | }; | ||
| 292 | 304 | ||
| 293 | OP_RESET = 0x00, | 305 | enum layer_pram_op { |
| 306 | OP_RESET = 0x00, | ||
| 294 | OP_INV4 = 0x00, | 307 | OP_INV4 = 0x00, |
| 295 | OP_INV = 0xF0, | 308 | OP_INV = 0xF0, |
| 296 | OP_ON = 0xF4, | 309 | OP_ON = 0xF4, |
| @@ -298,56 +311,49 @@ enum layer_params { | |||
| 298 | OP_SET = 0xFC, | 311 | OP_SET = 0xFC, |
| 299 | }; | 312 | }; |
| 300 | 313 | ||
| 314 | enum layer_pram_bitop { | ||
| 315 | BITOP_AND, | ||
| 316 | BITOP_OR, | ||
| 317 | BITOP_XOR, | ||
| 318 | BITOP_LSHIFT, | ||
| 319 | BITOP_RSHIFT, | ||
| 320 | }; | ||
| 321 | |||
| 301 | /* | 322 | /* |
| 302 | * Default Layer | 323 | * Default Layer |
| 303 | */ | 324 | */ |
| 304 | #define ACTION_DEFAULT_LAYER ACTION(ACT_KEYMAP, ON_RELEASE<<8 | OP_RESET | 0) | 325 | #define ACTION_DEFAULT_LAYER ACTION(ACT_LAYER, ON_RELEASE<<8 | OP_RESET | 0) |
| 305 | #define ACTION_DEFAULT_LAYER_SET(layer) ACTION_DEFAULT_LAYER_TO(layer, ON_RELEASE) | 326 | #define ACTION_DEFAULT_LAYER_SET(layer) ACTION_DEFAULT_LAYER_TO(layer, ON_RELEASE) |
| 306 | #define ACTION_DEFAULT_LAYER_TO(layer, on) ACTION(ACT_KEYMAP, (layer)<<8 | OP_RESET | (on)) | 327 | #define ACTION_DEFAULT_LAYER_TO(layer, on) ACTION(ACT_LAYER, (layer)<<8 | OP_RESET | (on)) |
| 328 | |||
| 307 | /* | 329 | /* |
| 308 | * Keymap Layer | 330 | * Keymap Layer |
| 309 | */ | 331 | */ |
| 310 | #define ACTION_KEYMAP_MOMENTARY(layer) ACTION_KEYMAP_ON_OFF(layer) | 332 | #define ACTION_LAYER_MOMENTARY(layer) ACTION_LAYER_ON_OFF(layer) |
| 311 | #define ACTION_KEYMAP_TOGGLE(layer) ACTION_KEYMAP_INV(layer, ON_RELEASE) | 333 | #define ACTION_LAYER_TOGGLE(layer) ACTION_LAYER_INV(layer, ON_RELEASE) |
| 312 | /* Keymap Invert */ | 334 | /* Keymap Invert */ |
| 313 | #define ACTION_KEYMAP_INV(layer, on) ACTION(ACT_KEYMAP, (layer)<<8 | OP_INV | (on)) | 335 | #define ACTION_LAYER_INV(layer, on) ACTION(ACT_LAYER, (layer)<<8 | OP_INV | (on)) |
| 314 | #define ACTION_KEYMAP_TAP_TOGGLE(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_INV | 0) | 336 | #define ACTION_LAYER_TAP_TOGGLE(layer) ACTION(ACT_LAYER, (layer)<<8 | OP_INV | 0) |
| 315 | /* Keymap On */ | 337 | /* Keymap On */ |
| 316 | #define ACTION_KEYMAP_ON(layer, on) ACTION(ACT_KEYMAP, (layer)<<8 | OP_ON | (on)) | 338 | #define ACTION_LAYER_ON(layer, on) ACTION(ACT_LAYER, (layer)<<8 | OP_ON | (on)) |
| 317 | #define ACTION_KEYMAP_ON_OFF(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_ON | 0) | 339 | #define ACTION_LAYER_ON_OFF(layer) ACTION(ACT_LAYER, (layer)<<8 | OP_ON | 0) |
| 318 | /* Keymap Off */ | 340 | /* Keymap Off */ |
| 319 | #define ACTION_KEYMAP_OFF(layer, on) ACTION(ACT_KEYMAP, (layer)<<8 | OP_OFF | (on)) | 341 | #define ACTION_LAYER_OFF(layer, on) ACTION(ACT_LAYER, (layer)<<8 | OP_OFF | (on)) |
| 320 | #define ACTION_KEYMAP_OFF_ON(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_OFF | 0) | 342 | #define ACTION_LAYER_OFF_ON(layer) ACTION(ACT_LAYER, (layer)<<8 | OP_OFF | 0) |
| 321 | /* Keymap Set */ | 343 | /* Keymap Set */ |
| 322 | #define ACTION_KEYMAP_SET(layer, on) ACTION(ACT_KEYMAP, (layer)<<8 | OP_SET | (on)) | 344 | #define ACTION_LAYER_SET(layer, on) ACTION(ACT_LAYER, (layer)<<8 | OP_SET | (on)) |
| 323 | #define ACTION_KEYMAP_SET_CLEAR(layer) ACTION(ACT_KEYMAP, (layer)<<8 | OP_SET | 0) | 345 | #define ACTION_LAYER_SET_CLEAR(layer) ACTION(ACT_LAYER, (layer)<<8 | OP_SET | 0) |
| 324 | /* Keymap Invert with tap key */ | 346 | /* Keymap Invert with tap key */ |
| 325 | #define ACTION_KEYMAP_TAP_KEY(layer, key) ACTION(ACT_KEYMAP, (layer)<<8 | (key)) | 347 | #define ACTION_LAYER_TAP_KEY(layer, key) ACTION(ACT_LAYER, (layer)<<8 | (key)) |
| 326 | 348 | ||
| 327 | /* | 349 | /* Layer BitOp: 101|BB|ooo|xxxxxxxx */ |
| 328 | * Overlay Layer | 350 | #define ACTION_LAYER_BITOP(op, part, bits) (ACT_LAYER_BITOP<<12 | (part&0x3)<<11 | (op&0x7)<<8 | bits) |
| 329 | */ | 351 | #define ACTION_LAYER_AND(part, bits) ACTION_LAYER_BITOP(BITOP_AND, part, bits) |
| 330 | #define ACTION_OVERLAY_MOMENTARY(layer) ACTION_OVERLAY_ON_OFF(layer) | 352 | #define ACTION_LAYER_OR(part, bits) ACTION_LAYER_BITOP(BITOP_OR, part, bits) |
| 331 | #define ACTION_OVERLAY_TOGGLE(layer) ACTION_OVERLAY_INV(layer, ON_RELEASE) | 353 | #define ACTION_LAYER_XOR(part, bits) ACTION_LAYER_BITOP(BITOP_XOR, part, bits) |
| 332 | /* Overlay Clear */ | 354 | #define ACTION_LAYER_LSHIFT(part, bits) ACTION_LAYER_BITOP(BITOP_LSHIFT, part, bits) |
| 333 | #define ACTION_OVERLAY_CLEAR(on) ACTION(ACT_OVERLAY, 0<<8 | OP_INV4 | (on)) | 355 | #define ACTION_LAYER_RSHIFT(part, bits) ACTION_LAYER_BITOP(BITOP_RSHIFT, part, bits) |
| 334 | /* Overlay Invert 4-bit chunk */ | 356 | |
| 335 | #define ACTION_OVERLAY_INV4(bits, shift) ACTION(ACT_OVERLAY, (bits)<<8 | OP_INV4 | shift) | ||
| 336 | /* Overlay Invert */ | ||
| 337 | #define ACTION_OVERLAY_INV(layer, on) ACTION(ACT_OVERLAY, (layer)<<8 | OP_INV | (on)) | ||
| 338 | #define ACTION_OVERLAY_TAP_TOGGLE(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_INV | 0) | ||
| 339 | /* Overlay On */ | ||
| 340 | #define ACTION_OVERLAY_ON(layer, on) ACTION(ACT_OVERLAY, (layer)<<8 | OP_ON | (on)) | ||
| 341 | #define ACTION_OVERLAY_ON_OFF(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_ON | 0) | ||
| 342 | /* Overlay Off */ | ||
| 343 | #define ACTION_OVERLAY_OFF(layer, on) ACTION(ACT_OVERLAY, (layer)<<8 | OP_OFF | (on)) | ||
| 344 | #define ACTION_OVERLAY_OFF_ON(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_OFF | 0) | ||
| 345 | /* Overlay Set */ | ||
| 346 | #define ACTION_OVERLAY_SET(layer, on) ACTION(ACT_OVERLAY, (layer)<<8 | OP_SET | (on)) | ||
| 347 | #define ACTION_OVERLAY_SET_CLEAR(layer) ACTION(ACT_OVERLAY, (layer)<<8 | OP_SET | 0) | ||
| 348 | /* Overlay Invert with tap key */ | ||
| 349 | #define ACTION_OVERLAY_TAP_KEY(layer, key) ACTION(ACT_OVERLAY, (layer)<<8 | (key)) | ||
| 350 | |||
| 351 | 357 | ||
| 352 | /* | 358 | /* |
| 353 | * Extensions | 359 | * Extensions |
