diff options
Diffstat (limited to 'common/action.h')
-rw-r--r-- | common/action.h | 74 |
1 files changed, 34 insertions, 40 deletions
diff --git a/common/action.h b/common/action.h index 96b8ba2ed7..46ae809cb7 100644 --- a/common/action.h +++ b/common/action.h @@ -76,11 +76,6 @@ typedef union { -/* layer used currently */ -extern uint8_t current_layer; -/* layer to return or start with */ -extern uint8_t default_layer; - /* Execute action per keyevent */ void action_exec(keyevent_t event); @@ -155,17 +150,14 @@ bool waiting_buffer_has_anykey_pressed(void); * * Mouse Keys * ---------- - * TODO: can be combined with 'Other HID Usage'? to save action kind id. + * NOTE: can be combined with 'Other HID Usage'? to save action kind id. * ACT_MOUSEKEY(0110): * 0101|XXXX| keycode Mouse key * * * Layer Actions * ------------- - * ACT_LAYER(1000): Set layer - * ACT_LAYER_BIT(1001): Bit-op layer - * ACT_LAYER_STACK: Layer stack - * + * ACT_LAYER_SET(1000): Set layer * 1000|LLLL|0000 0000 set current layer on press and return to default on release(momentary) * 1000|LLLL|0000 0001 set current layer on press * 1000|LLLL|0000 0010 set current layer on release @@ -175,6 +167,7 @@ bool waiting_buffer_has_anykey_pressed(void); * 1000|DDDD|1111 1111 set default layer on press * L: 0 means default layer * + * ACT_LAYER_BIT(1001): Bit-op layer * 1001|BBBB|0000 0000 bit-on current layer on press and bit-off on release(momentary) * 1001|BBBB|0000 0001 bit-xor current layer on press * 1001|BBBB|0000 0010 bit-xor current layer on release @@ -183,12 +176,13 @@ bool waiting_buffer_has_anykey_pressed(void); * 1001|BBBB|1111 0000 bit-xor current layer on hold and toggle on several taps * 1001|BBBB|1111 1111 bit-xor default layer on both * - * 1011|LLLL|0000 0000 push on press and remove on release(momentary) - * 1011|LLLL|0000 0001 push or remove on press - * 1011|LLLL|0000 0010 push or remove on release - * 1011|LLLL|0000 0011 push or remove on both - * 1011|LLLL| keycode push or remove on hold and send key on tap - * 1011|LLLL|1111 0000 push or remove on hold and toggle on several taps + * ACT_LAYER_SWITCH: Switch + * 1011|LLLL|0000 0000 On on press and Off on release(momentary) + * 1011|LLLL|0000 0001 Invert on press + * 1011|LLLL|0000 0010 Invert on release + * 1011|LLLL|0000 0011 Invert on both + * 1011|LLLL| keycode Invert on hold and send key on tap + * 1011|LLLL|1111 0000 Invert on hold and toggle on several taps * 1011|LLLL|1111 1111 (not used) * * @@ -217,9 +211,9 @@ enum action_kind_id { ACT_USAGE = 0b0100, ACT_MOUSEKEY = 0b0101, - ACT_LAYER = 0b1000, + ACT_LAYER_SET = 0b1000, ACT_LAYER_BIT = 0b1001, - ACT_LAYER_STACK = 0b1011, + ACT_LAYER_SWITCH = 0b1011, ACT_MACRO = 0b1100, ACT_COMMAND = 0b1110, @@ -233,7 +227,7 @@ enum action_kind_id { #define ACTION(kind, param) ((kind)<<12 | (param)) #define MODS4(mods) (((mods)>>4 | (mods)) & 0x0F) -/* +/* * Key */ #define ACTION_KEY(key) ACTION(ACT_LMODS, key) @@ -278,14 +272,14 @@ enum layer_codes { */ /* set default layer */ #define ACTION_LAYER_SET_DEFAULT(layer) ACTION_LAYER_SET_DEFAULT_R(layer) -#define ACTION_LAYER_SET_DEFAULT_P(layer) ACTION(ACT_LAYER, (layer)<<8 | LAYER_SET_DEFAULT_ON_PRESS) -#define ACTION_LAYER_SET_DEFAULT_R(layer) ACTION(ACT_LAYER, (layer)<<8 | LAYER_SET_DEFAULT_ON_RELEASE) -#define ACTION_LAYER_SET_DEFAULT_B(layer) ACTION(ACT_LAYER, (layer)<<8 | LAYER_SET_DEFAULT_ON_BOTH) +#define ACTION_LAYER_SET_DEFAULT_P(layer) ACTION(ACT_LAYER_SET, (layer)<<8 | LAYER_SET_DEFAULT_ON_PRESS) +#define ACTION_LAYER_SET_DEFAULT_R(layer) ACTION(ACT_LAYER_SET, (layer)<<8 | LAYER_SET_DEFAULT_ON_RELEASE) +#define ACTION_LAYER_SET_DEFAULT_B(layer) ACTION(ACT_LAYER_SET, (layer)<<8 | LAYER_SET_DEFAULT_ON_BOTH) /* bit-xor default layer */ #define ACTION_LAYER_BIT_DEFAULT(bits) ACTION_LAYER_BIT_DEFAULT_R(bits) -#define ACTION_LAYER_BIT_DEFAULT_P(bits) ACTION(ACT_LAYER, (bits)<<8 | LAYER_SET_DEFAULT_ON_PRESS) -#define ACTION_LAYER_BIT_DEFAULT_R(bits) ACTION(ACT_LAYER, (bits)<<8 | LAYER_SET_DEFAULT_ON_RELEASE) -#define ACTION_LAYER_BIT_DEFAULT_B(bits) ACTION(ACT_LAYER, (bits)<<8 | LAYER_SET_DEFAULT_ON_BOTH) +#define ACTION_LAYER_BIT_DEFAULT_P(bits) ACTION(ACT_LAYER_BIT, (bits)<<8 | LAYER_SET_DEFAULT_ON_PRESS) +#define ACTION_LAYER_BIT_DEFAULT_R(bits) ACTION(ACT_LAYER_BIT, (bits)<<8 | LAYER_SET_DEFAULT_ON_RELEASE) +#define ACTION_LAYER_BIT_DEFAULT_B(bits) ACTION(ACT_LAYER_BIT, (bits)<<8 | LAYER_SET_DEFAULT_ON_BOTH) /* * Current layer: Return to default layer */ @@ -297,13 +291,13 @@ enum layer_codes { * Current layer: Set */ #define ACTION_LAYER_SET(layer) ACTION_LAYER_SET_P(layer) -#define ACTION_LAYER_SET_MOMENTARY(layer) ACTION(ACT_LAYER, (layer)<<8 | LAYER_MOMENTARY) +#define ACTION_LAYER_SET_MOMENTARY(layer) ACTION(ACT_LAYER_SET, (layer)<<8 | LAYER_MOMENTARY) #define ACTION_LAYER_SET_TOGGLE(layer) ACTION_LAYER_SET_R(layer) -#define ACTION_LAYER_SET_P(layer) ACTION(ACT_LAYER, (layer)<<8 | LAYER_ON_PRESS) -#define ACTION_LAYER_SET_R(layer) ACTION(ACT_LAYER, (layer)<<8 | LAYER_ON_RELEASE) -#define ACTION_LAYER_SET_B(layer) ACTION(ACT_LAYER, (layer)<<8 | LAYER_ON_BOTH) -#define ACTION_LAYER_SET_TAP_TOGGLE(layer) ACTION(ACT_LAYER, (layer)<<8 | LAYER_TAP_TOGGLE) -#define ACTION_LAYER_SET_TAP_KEY(layer, key) ACTION(ACT_LAYER, (layer)<<8 | (key)) +#define ACTION_LAYER_SET_P(layer) ACTION(ACT_LAYER_SET, (layer)<<8 | LAYER_ON_PRESS) +#define ACTION_LAYER_SET_R(layer) ACTION(ACT_LAYER_SET, (layer)<<8 | LAYER_ON_RELEASE) +#define ACTION_LAYER_SET_B(layer) ACTION(ACT_LAYER_SET, (layer)<<8 | LAYER_ON_BOTH) +#define ACTION_LAYER_SET_TAP_TOGGLE(layer) ACTION(ACT_LAYER_SET, (layer)<<8 | LAYER_TAP_TOGGLE) +#define ACTION_LAYER_SET_TAP_KEY(layer, key) ACTION(ACT_LAYER_SET, (layer)<<8 | (key)) /* * Current layer: Bit-op */ @@ -316,17 +310,17 @@ enum layer_codes { #define ACTION_LAYER_BIT_TAP_TOGGLE(bits) ACTION(ACT_LAYER_BIT, (bits)<<8 | LAYER_TAP_TOGGLE) #define ACTION_LAYER_BIT_TAP_KEY(bits, key) ACTION(ACT_LAYER_BIT, (bits)<<8 | (key)) /* - * Layer Stack + * Layer SWITCH */ /* momentary */ -#define ACTION_LAYER_STACK(layer) ACTION_LAYER_STACK_MOMENTARY(layer) -#define ACTION_LAYER_STACK_MOMENTARY(layer) ACTION(ACT_LAYER_STACK, (layer)<<8 | LAYER_MOMENTARY) -#define ACTION_LAYER_STACK_TOGGLE(layer) ACTION_LAYER_STACK_R(layer) -#define ACTION_LAYER_STACK_P(layer) ACTION(ACT_LAYER_STACK, (layer)<<8 | LAYER_ON_PRESS) -#define ACTION_LAYER_STACK_R(layer) ACTION(ACT_LAYER_STACK, (layer)<<8 | LAYER_ON_RELEASE) -#define ACTION_LAYER_STACK_B(layer) ACTION(ACT_LAYER_STACK, (layer)<<8 | LAYER_ON_BOTH) -#define ACTION_LAYER_STACK_TAP_TOGGLE(layer) ACTION(ACT_LAYER_STACK, (layer)<<8 | LAYER_TAP_TOGGLE) -#define ACTION_LAYER_STACK_TAP_KEY(layer, key) ACTION(ACT_LAYER_STACK, (layer)<<8 | (key)) +#define ACTION_LAYER_SWITCH(layer) ACTION_LAYER_SWITCH_MOMENTARY(layer) +#define ACTION_LAYER_SWITCH_MOMENTARY(layer) ACTION(ACT_LAYER_SWITCH, (layer)<<8 | LAYER_MOMENTARY) +#define ACTION_LAYER_SWITCH_TOGGLE(layer) ACTION_LAYER_SWITCH_R(layer) +#define ACTION_LAYER_SWITCH_P(layer) ACTION(ACT_LAYER_SWITCH, (layer)<<8 | LAYER_ON_PRESS) +#define ACTION_LAYER_SWITCH_R(layer) ACTION(ACT_LAYER_SWITCH, (layer)<<8 | LAYER_ON_RELEASE) +#define ACTION_LAYER_SWITCH_B(layer) ACTION(ACT_LAYER_SWITCH, (layer)<<8 | LAYER_ON_BOTH) +#define ACTION_LAYER_SWITCH_TAP_TOGGLE(layer) ACTION(ACT_LAYER_SWITCH, (layer)<<8 | LAYER_TAP_TOGGLE) +#define ACTION_LAYER_SWITCH_TAP_KEY(layer, key) ACTION(ACT_LAYER_SWITCH, (layer)<<8 | (key)) /* |