aboutsummaryrefslogtreecommitdiffstats
path: root/tmk_core/common/action_code.h
diff options
context:
space:
mode:
authorGravatar skullY <skullydazed@gmail.com>2019-08-30 11:19:03 -0700
committerGravatar skullydazed <skullydazed@users.noreply.github.com>2019-08-30 15:01:52 -0700
commitb624f32f944acdc59dcb130674c09090c5c404cb (patch)
treebc13adbba137d122d9a2c2fb2fafcbb08ac10e25 /tmk_core/common/action_code.h
parent61af76a10d00aba185b8338604171de490a13e3b (diff)
downloadqmk_firmware-b624f32f944acdc59dcb130674c09090c5c404cb.tar.gz
clang-format changes
Diffstat (limited to 'tmk_core/common/action_code.h')
-rw-r--r--tmk_core/common/action_code.h239
1 files changed, 114 insertions, 125 deletions
diff --git a/tmk_core/common/action_code.h b/tmk_core/common/action_code.h
index 5b5d0e566..03fcb3382 100644
--- a/tmk_core/common/action_code.h
+++ b/tmk_core/common/action_code.h
@@ -98,30 +98,29 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
enum action_kind_id {
/* Key Actions */
- ACT_MODS = 0b0000,
- ACT_LMODS = 0b0000,
- ACT_RMODS = 0b0001,
- ACT_MODS_TAP = 0b0010,
- ACT_LMODS_TAP = 0b0010,
- ACT_RMODS_TAP = 0b0011,
+ ACT_MODS = 0b0000,
+ ACT_LMODS = 0b0000,
+ ACT_RMODS = 0b0001,
+ ACT_MODS_TAP = 0b0010,
+ ACT_LMODS_TAP = 0b0010,
+ ACT_RMODS_TAP = 0b0011,
/* Other Keys */
- ACT_USAGE = 0b0100,
- ACT_MOUSEKEY = 0b0101,
+ ACT_USAGE = 0b0100,
+ ACT_MOUSEKEY = 0b0101,
/* One-hand Support */
- ACT_SWAP_HANDS = 0b0110,
+ ACT_SWAP_HANDS = 0b0110,
/* Layer Actions */
- ACT_LAYER = 0b1000,
- ACT_LAYER_MODS = 0b1001,
- ACT_LAYER_TAP = 0b1010, /* Layer 0-15 */
- ACT_LAYER_TAP_EXT = 0b1011, /* Layer 16-31 */
+ ACT_LAYER = 0b1000,
+ ACT_LAYER_MODS = 0b1001,
+ ACT_LAYER_TAP = 0b1010, /* Layer 0-15 */
+ ACT_LAYER_TAP_EXT = 0b1011, /* Layer 16-31 */
/* Extensions */
- ACT_MACRO = 0b1100,
- ACT_BACKLIGHT = 0b1101,
- ACT_COMMAND = 0b1110,
- ACT_FUNCTION = 0b1111
+ ACT_MACRO = 0b1100,
+ ACT_BACKLIGHT = 0b1101,
+ ACT_COMMAND = 0b1110,
+ ACT_FUNCTION = 0b1111
};
-
/** \brief Action Code Struct
*
* NOTE:
@@ -139,66 +138,63 @@ enum action_kind_id {
typedef union {
uint16_t code;
struct action_kind {
- uint16_t param :12;
- uint8_t id :4;
+ uint16_t param : 12;
+ uint8_t id : 4;
} kind;
struct action_key {
- uint8_t code :8;
- uint8_t mods :4;
- uint8_t kind :4;
+ uint8_t code : 8;
+ uint8_t mods : 4;
+ uint8_t kind : 4;
} key;
struct action_layer_bitop {
- uint8_t bits :4;
- uint8_t xbit :1;
- uint8_t part :3;
- uint8_t on :2;
- uint8_t op :2;
- uint8_t kind :4;
+ uint8_t bits : 4;
+ uint8_t xbit : 1;
+ uint8_t part : 3;
+ uint8_t on : 2;
+ uint8_t op : 2;
+ uint8_t kind : 4;
} layer_bitop;
- struct action_layer_mods
- {
- uint8_t mods :8;
- uint8_t layer :4;
- uint8_t kind :4;
+ struct action_layer_mods {
+ uint8_t mods : 8;
+ uint8_t layer : 4;
+ uint8_t kind : 4;
} layer_mods;
struct action_layer_tap {
- uint8_t code :8;
- uint8_t val :5;
- uint8_t kind :3;
+ uint8_t code : 8;
+ uint8_t val : 5;
+ uint8_t kind : 3;
} layer_tap;
struct action_usage {
- uint16_t code :10;
- uint8_t page :2;
- uint8_t kind :4;
+ uint16_t code : 10;
+ uint8_t page : 2;
+ uint8_t kind : 4;
} usage;
struct action_backlight {
- uint8_t level :8;
- uint8_t opt :4;
- uint8_t kind :4;
+ uint8_t level : 8;
+ uint8_t opt : 4;
+ uint8_t kind : 4;
} backlight;
struct action_command {
- uint8_t id :8;
- uint8_t opt :4;
- uint8_t kind :4;
+ uint8_t id : 8;
+ uint8_t opt : 4;
+ uint8_t kind : 4;
} command;
struct action_function {
- uint8_t id :8;
- uint8_t opt :4;
- uint8_t kind :4;
+ uint8_t id : 8;
+ uint8_t opt : 4;
+ uint8_t kind : 4;
} func;
struct action_swap {
- uint8_t code :8;
- uint8_t opt :4;
- uint8_t kind :4;
+ uint8_t code : 8;
+ uint8_t opt : 4;
+ uint8_t kind : 4;
} swap;
} action_t;
-
/* action utility */
-#define ACTION_NO 0
-#define ACTION_TRANSPARENT 1
-#define ACTION(kind, param) ((kind)<<12 | (param))
-
+#define ACTION_NO 0
+#define ACTION_TRANSPARENT 1
+#define ACTION(kind, param) ((kind) << 12 | (param))
/** \brief Key Actions
*
@@ -220,35 +216,29 @@ enum mods_bit {
MOD_RGUI = 0x18,
};
enum mods_codes {
- MODS_ONESHOT = 0x00,
+ MODS_ONESHOT = 0x00,
MODS_TAP_TOGGLE = 0x01,
};
-#define ACTION_KEY(key) ACTION(ACT_MODS, (key))
-#define ACTION_MODS(mods) ACTION(ACT_MODS, ((mods)&0x1f)<<8 | 0)
-#define ACTION_MODS_KEY(mods, key) ACTION(ACT_MODS, ((mods)&0x1f)<<8 | (key))
-#define ACTION_MODS_TAP_KEY(mods, key) ACTION(ACT_MODS_TAP, ((mods)&0x1f)<<8 | (key))
-#define ACTION_MODS_ONESHOT(mods) ACTION(ACT_MODS_TAP, ((mods)&0x1f)<<8 | MODS_ONESHOT)
-#define ACTION_MODS_TAP_TOGGLE(mods) ACTION(ACT_MODS_TAP, ((mods)&0x1f)<<8 | MODS_TAP_TOGGLE)
-
+#define ACTION_KEY(key) ACTION(ACT_MODS, (key))
+#define ACTION_MODS(mods) ACTION(ACT_MODS, ((mods)&0x1f) << 8 | 0)
+#define ACTION_MODS_KEY(mods, key) ACTION(ACT_MODS, ((mods)&0x1f) << 8 | (key))
+#define ACTION_MODS_TAP_KEY(mods, key) ACTION(ACT_MODS_TAP, ((mods)&0x1f) << 8 | (key))
+#define ACTION_MODS_ONESHOT(mods) ACTION(ACT_MODS_TAP, ((mods)&0x1f) << 8 | MODS_ONESHOT)
+#define ACTION_MODS_TAP_TOGGLE(mods) ACTION(ACT_MODS_TAP, ((mods)&0x1f) << 8 | MODS_TAP_TOGGLE)
/** \brief Other Keys
*/
-enum usage_pages {
- PAGE_SYSTEM,
- PAGE_CONSUMER
-};
-#define ACTION_USAGE_SYSTEM(id) ACTION(ACT_USAGE, PAGE_SYSTEM<<10 | (id))
-#define ACTION_USAGE_CONSUMER(id) ACTION(ACT_USAGE, PAGE_CONSUMER<<10 | (id))
-#define ACTION_MOUSEKEY(key) ACTION(ACT_MOUSEKEY, key)
-
-
+enum usage_pages { PAGE_SYSTEM, PAGE_CONSUMER };
+#define ACTION_USAGE_SYSTEM(id) ACTION(ACT_USAGE, PAGE_SYSTEM << 10 | (id))
+#define ACTION_USAGE_CONSUMER(id) ACTION(ACT_USAGE, PAGE_CONSUMER << 10 | (id))
+#define ACTION_MOUSEKEY(key) ACTION(ACT_MOUSEKEY, key)
/** \brief Layer Actions
*/
enum layer_param_on {
- ON_PRESS = 1,
- ON_RELEASE = 2,
- ON_BOTH = 3,
+ ON_PRESS = 1,
+ ON_RELEASE = 2,
+ ON_BOTH = 3,
};
/** \brief Layer Actions
@@ -269,37 +259,36 @@ enum layer_param_tap_op {
OP_SET_CLEAR,
OP_ONESHOT,
};
-#define ACTION_LAYER_BITOP(op, part, bits, on) ACTION(ACT_LAYER, (op)<<10 | (on)<<8 | (part)<<5 | ((bits)&0x1f))
-#define ACTION_LAYER_TAP(layer, key) ACTION(ACT_LAYER_TAP, (layer)<<8 | (key))
+#define ACTION_LAYER_BITOP(op, part, bits, on) ACTION(ACT_LAYER, (op) << 10 | (on) << 8 | (part) << 5 | ((bits)&0x1f))
+#define ACTION_LAYER_TAP(layer, key) ACTION(ACT_LAYER_TAP, (layer) << 8 | (key))
/* Default Layer */
-#define ACTION_DEFAULT_LAYER_SET(layer) ACTION_DEFAULT_LAYER_BIT_SET((layer)/4, 1<<((layer)%4))
+#define ACTION_DEFAULT_LAYER_SET(layer) ACTION_DEFAULT_LAYER_BIT_SET((layer) / 4, 1 << ((layer) % 4))
/* Layer Operation */
-#define ACTION_LAYER_CLEAR(on) ACTION_LAYER_BIT_AND(0, 0, (on))
-#define ACTION_LAYER_MOMENTARY(layer) ACTION_LAYER_ON_OFF(layer)
-#define ACTION_LAYER_TOGGLE(layer) ACTION_LAYER_INVERT(layer, ON_RELEASE)
-#define ACTION_LAYER_INVERT(layer, on) ACTION_LAYER_BIT_XOR((layer)/4, 1<<((layer)%4), (on))
-#define ACTION_LAYER_ON(layer, on) ACTION_LAYER_BIT_OR( (layer)/4, 1<<((layer)%4), (on))
-#define ACTION_LAYER_OFF(layer, on) ACTION_LAYER_BIT_AND((layer)/4, ~(1<<((layer)%4)), (on))
-#define ACTION_LAYER_SET(layer, on) ACTION_LAYER_BIT_SET((layer)/4, 1<<((layer)%4), (on))
-#define ACTION_LAYER_ON_OFF(layer) ACTION_LAYER_TAP((layer), OP_ON_OFF)
-#define ACTION_LAYER_OFF_ON(layer) ACTION_LAYER_TAP((layer), OP_OFF_ON)
-#define ACTION_LAYER_SET_CLEAR(layer) ACTION_LAYER_TAP((layer), OP_SET_CLEAR)
-#define ACTION_LAYER_ONESHOT(layer) ACTION_LAYER_TAP((layer), OP_ONESHOT)
-#define ACTION_LAYER_MODS(layer, mods) ACTION(ACT_LAYER_MODS, (layer) << 8 | (mods))
+#define ACTION_LAYER_CLEAR(on) ACTION_LAYER_BIT_AND(0, 0, (on))
+#define ACTION_LAYER_MOMENTARY(layer) ACTION_LAYER_ON_OFF(layer)
+#define ACTION_LAYER_TOGGLE(layer) ACTION_LAYER_INVERT(layer, ON_RELEASE)
+#define ACTION_LAYER_INVERT(layer, on) ACTION_LAYER_BIT_XOR((layer) / 4, 1 << ((layer) % 4), (on))
+#define ACTION_LAYER_ON(layer, on) ACTION_LAYER_BIT_OR((layer) / 4, 1 << ((layer) % 4), (on))
+#define ACTION_LAYER_OFF(layer, on) ACTION_LAYER_BIT_AND((layer) / 4, ~(1 << ((layer) % 4)), (on))
+#define ACTION_LAYER_SET(layer, on) ACTION_LAYER_BIT_SET((layer) / 4, 1 << ((layer) % 4), (on))
+#define ACTION_LAYER_ON_OFF(layer) ACTION_LAYER_TAP((layer), OP_ON_OFF)
+#define ACTION_LAYER_OFF_ON(layer) ACTION_LAYER_TAP((layer), OP_OFF_ON)
+#define ACTION_LAYER_SET_CLEAR(layer) ACTION_LAYER_TAP((layer), OP_SET_CLEAR)
+#define ACTION_LAYER_ONESHOT(layer) ACTION_LAYER_TAP((layer), OP_ONESHOT)
+#define ACTION_LAYER_MODS(layer, mods) ACTION(ACT_LAYER_MODS, (layer) << 8 | (mods))
/* With Tapping */
-#define ACTION_LAYER_TAP_KEY(layer, key) ACTION_LAYER_TAP((layer), (key))
-#define ACTION_LAYER_TAP_TOGGLE(layer) ACTION_LAYER_TAP((layer), OP_TAP_TOGGLE)
+#define ACTION_LAYER_TAP_KEY(layer, key) ACTION_LAYER_TAP((layer), (key))
+#define ACTION_LAYER_TAP_TOGGLE(layer) ACTION_LAYER_TAP((layer), OP_TAP_TOGGLE)
/* Bitwise Operation */
-#define ACTION_LAYER_BIT_AND(part, bits, on) ACTION_LAYER_BITOP(OP_BIT_AND, (part), (bits), (on))
-#define ACTION_LAYER_BIT_OR( part, bits, on) ACTION_LAYER_BITOP(OP_BIT_OR, (part), (bits), (on))
-#define ACTION_LAYER_BIT_XOR(part, bits, on) ACTION_LAYER_BITOP(OP_BIT_XOR, (part), (bits), (on))
-#define ACTION_LAYER_BIT_SET(part, bits, on) ACTION_LAYER_BITOP(OP_BIT_SET, (part), (bits), (on))
+#define ACTION_LAYER_BIT_AND(part, bits, on) ACTION_LAYER_BITOP(OP_BIT_AND, (part), (bits), (on))
+#define ACTION_LAYER_BIT_OR(part, bits, on) ACTION_LAYER_BITOP(OP_BIT_OR, (part), (bits), (on))
+#define ACTION_LAYER_BIT_XOR(part, bits, on) ACTION_LAYER_BITOP(OP_BIT_XOR, (part), (bits), (on))
+#define ACTION_LAYER_BIT_SET(part, bits, on) ACTION_LAYER_BITOP(OP_BIT_SET, (part), (bits), (on))
/* Default Layer Bitwise Operation */
-#define ACTION_DEFAULT_LAYER_BIT_AND(part, bits) ACTION_LAYER_BITOP(OP_BIT_AND, (part), (bits), 0)
-#define ACTION_DEFAULT_LAYER_BIT_OR( part, bits) ACTION_LAYER_BITOP(OP_BIT_OR, (part), (bits), 0)
-#define ACTION_DEFAULT_LAYER_BIT_XOR(part, bits) ACTION_LAYER_BITOP(OP_BIT_XOR, (part), (bits), 0)
-#define ACTION_DEFAULT_LAYER_BIT_SET(part, bits) ACTION_LAYER_BITOP(OP_BIT_SET, (part), (bits), 0)
-
+#define ACTION_DEFAULT_LAYER_BIT_AND(part, bits) ACTION_LAYER_BITOP(OP_BIT_AND, (part), (bits), 0)
+#define ACTION_DEFAULT_LAYER_BIT_OR(part, bits) ACTION_LAYER_BITOP(OP_BIT_OR, (part), (bits), 0)
+#define ACTION_DEFAULT_LAYER_BIT_XOR(part, bits) ACTION_LAYER_BITOP(OP_BIT_XOR, (part), (bits), 0)
+#define ACTION_DEFAULT_LAYER_BIT_SET(part, bits) ACTION_LAYER_BITOP(OP_BIT_SET, (part), (bits), 0)
/** \brief Extensions
*/
@@ -313,25 +302,25 @@ enum backlight_opt {
};
/* Macro */
-#define ACTION_MACRO(id) ACTION(ACT_MACRO, (id))
-#define ACTION_MACRO_TAP(id) ACTION(ACT_MACRO, FUNC_TAP<<8 | (id))
-#define ACTION_MACRO_OPT(id, opt) ACTION(ACT_MACRO, (opt)<<8 | (id))
+#define ACTION_MACRO(id) ACTION(ACT_MACRO, (id))
+#define ACTION_MACRO_TAP(id) ACTION(ACT_MACRO, FUNC_TAP << 8 | (id))
+#define ACTION_MACRO_OPT(id, opt) ACTION(ACT_MACRO, (opt) << 8 | (id))
/* Backlight */
-#define ACTION_BACKLIGHT_INCREASE() ACTION(ACT_BACKLIGHT, BACKLIGHT_INCREASE << 8)
-#define ACTION_BACKLIGHT_DECREASE() ACTION(ACT_BACKLIGHT, BACKLIGHT_DECREASE << 8)
-#define ACTION_BACKLIGHT_TOGGLE() ACTION(ACT_BACKLIGHT, BACKLIGHT_TOGGLE << 8)
-#define ACTION_BACKLIGHT_STEP() ACTION(ACT_BACKLIGHT, BACKLIGHT_STEP << 8)
-#define ACTION_BACKLIGHT_ON() ACTION(ACT_BACKLIGHT, BACKLIGHT_ON << 8)
-#define ACTION_BACKLIGHT_OFF() ACTION(ACT_BACKLIGHT, BACKLIGHT_OFF << 8)
+#define ACTION_BACKLIGHT_INCREASE() ACTION(ACT_BACKLIGHT, BACKLIGHT_INCREASE << 8)
+#define ACTION_BACKLIGHT_DECREASE() ACTION(ACT_BACKLIGHT, BACKLIGHT_DECREASE << 8)
+#define ACTION_BACKLIGHT_TOGGLE() ACTION(ACT_BACKLIGHT, BACKLIGHT_TOGGLE << 8)
+#define ACTION_BACKLIGHT_STEP() ACTION(ACT_BACKLIGHT, BACKLIGHT_STEP << 8)
+#define ACTION_BACKLIGHT_ON() ACTION(ACT_BACKLIGHT, BACKLIGHT_ON << 8)
+#define ACTION_BACKLIGHT_OFF() ACTION(ACT_BACKLIGHT, BACKLIGHT_OFF << 8)
/* Command */
-#define ACTION_COMMAND(id, opt) ACTION(ACT_COMMAND, (opt)<<8 | (id))
+#define ACTION_COMMAND(id, opt) ACTION(ACT_COMMAND, (opt) << 8 | (id))
/* Function */
enum function_opts {
- FUNC_TAP = 0x8, /* indciates function is tappable */
+ FUNC_TAP = 0x8, /* indciates function is tappable */
};
-#define ACTION_FUNCTION(id) ACTION(ACT_FUNCTION, (id))
-#define ACTION_FUNCTION_TAP(id) ACTION(ACT_FUNCTION, FUNC_TAP<<8 | (id))
-#define ACTION_FUNCTION_OPT(id, opt) ACTION(ACT_FUNCTION, (opt)<<8 | (id))
+#define ACTION_FUNCTION(id) ACTION(ACT_FUNCTION, (id))
+#define ACTION_FUNCTION_TAP(id) ACTION(ACT_FUNCTION, FUNC_TAP << 8 | (id))
+#define ACTION_FUNCTION_OPT(id, opt) ACTION(ACT_FUNCTION, (opt) << 8 | (id))
/* OneHand Support */
enum swap_hands_param_tap_op {
OP_SH_TOGGLE = 0xF0,
@@ -342,13 +331,13 @@ enum swap_hands_param_tap_op {
OP_SH_ON,
};
-#define ACTION_SWAP_HANDS() ACTION_SWAP_HANDS_ON_OFF()
-#define ACTION_SWAP_HANDS_TOGGLE() ACTION(ACT_SWAP_HANDS, OP_SH_TOGGLE)
-#define ACTION_SWAP_HANDS_TAP_TOGGLE() ACTION(ACT_SWAP_HANDS, OP_SH_TAP_TOGGLE)
-#define ACTION_SWAP_HANDS_TAP_KEY(key) ACTION(ACT_SWAP_HANDS, key)
-#define ACTION_SWAP_HANDS_ON_OFF() ACTION(ACT_SWAP_HANDS, OP_SH_ON_OFF)
-#define ACTION_SWAP_HANDS_OFF_ON() ACTION(ACT_SWAP_HANDS, OP_SH_OFF_ON)
-#define ACTION_SWAP_HANDS_ON() ACTION(ACT_SWAP_HANDS, OP_SH_ON)
-#define ACTION_SWAP_HANDS_OFF() ACTION(ACT_SWAP_HANDS, OP_SH_OFF)
+#define ACTION_SWAP_HANDS() ACTION_SWAP_HANDS_ON_OFF()
+#define ACTION_SWAP_HANDS_TOGGLE() ACTION(ACT_SWAP_HANDS, OP_SH_TOGGLE)
+#define ACTION_SWAP_HANDS_TAP_TOGGLE() ACTION(ACT_SWAP_HANDS, OP_SH_TAP_TOGGLE)
+#define ACTION_SWAP_HANDS_TAP_KEY(key) ACTION(ACT_SWAP_HANDS, key)
+#define ACTION_SWAP_HANDS_ON_OFF() ACTION(ACT_SWAP_HANDS, OP_SH_ON_OFF)
+#define ACTION_SWAP_HANDS_OFF_ON() ACTION(ACT_SWAP_HANDS, OP_SH_OFF_ON)
+#define ACTION_SWAP_HANDS_ON() ACTION(ACT_SWAP_HANDS, OP_SH_ON)
+#define ACTION_SWAP_HANDS_OFF() ACTION(ACT_SWAP_HANDS, OP_SH_OFF)
#endif /* ACTION_CODE_H */