summaryrefslogtreecommitdiff
path: root/quantum/action_layer.c
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/action_layer.c')
-rw-r--r--quantum/action_layer.c88
1 files changed, 64 insertions, 24 deletions
diff --git a/quantum/action_layer.c b/quantum/action_layer.c
index ed1a4bd20d..e20eedee40 100644
--- a/quantum/action_layer.c
+++ b/quantum/action_layer.c
@@ -18,13 +18,17 @@ layer_state_t default_layer_state = 0;
*
* Run user code on default layer state change
*/
-__attribute__((weak)) layer_state_t default_layer_state_set_user(layer_state_t state) { return state; }
+__attribute__((weak)) layer_state_t default_layer_state_set_user(layer_state_t state) {
+ return state;
+}
/** \brief Default Layer State Set At Keyboard Level
*
* Run keyboard code on default layer state change
*/
-__attribute__((weak)) layer_state_t default_layer_state_set_kb(layer_state_t state) { return default_layer_state_set_user(state); }
+__attribute__((weak)) layer_state_t default_layer_state_set_kb(layer_state_t state) {
+ return default_layer_state_set_user(state);
+}
/** \brief Default Layer State Set
*
@@ -39,9 +43,9 @@ static void default_layer_state_set(layer_state_t state) {
default_layer_debug();
debug("\n");
#ifdef STRICT_LAYER_RELEASE
- clear_keyboard_but_mods(); // To avoid stuck keys
+ clear_keyboard_but_mods(); // To avoid stuck keys
#else
- clear_keyboard_but_mods_and_keys(); // Don't reset held keys
+ clear_keyboard_but_mods_and_keys(); // Don't reset held keys
#endif
}
@@ -49,30 +53,40 @@ static void default_layer_state_set(layer_state_t state) {
*
* Print out the hex value of the 32-bit default layer state, as well as the value of the highest bit.
*/
-void default_layer_debug(void) { dprintf("%08lX(%u)", default_layer_state, get_highest_layer(default_layer_state)); }
+void default_layer_debug(void) {
+ dprintf("%08lX(%u)", default_layer_state, get_highest_layer(default_layer_state));
+}
/** \brief Default Layer Set
*
* Sets the default layer state.
*/
-void default_layer_set(layer_state_t state) { default_layer_state_set(state); }
+void default_layer_set(layer_state_t state) {
+ default_layer_state_set(state);
+}
#ifndef NO_ACTION_LAYER
/** \brief Default Layer Or
*
* Turns on the default layer based on matching bits between specifed layer and existing layer state
*/
-void default_layer_or(layer_state_t state) { default_layer_state_set(default_layer_state | state); }
+void default_layer_or(layer_state_t state) {
+ default_layer_state_set(default_layer_state | state);
+}
/** \brief Default Layer And
*
* Turns on default layer based on matching enabled bits between specifed layer and existing layer state
*/
-void default_layer_and(layer_state_t state) { default_layer_state_set(default_layer_state & state); }
+void default_layer_and(layer_state_t state) {
+ default_layer_state_set(default_layer_state & state);
+}
/** \brief Default Layer Xor
*
* Turns on default layer based on non-matching bits between specifed layer and existing layer state
*/
-void default_layer_xor(layer_state_t state) { default_layer_state_set(default_layer_state ^ state); }
+void default_layer_xor(layer_state_t state) {
+ default_layer_state_set(default_layer_state ^ state);
+}
#endif
#ifndef NO_ACTION_LAYER
@@ -84,13 +98,17 @@ layer_state_t layer_state = 0;
*
* Runs user code on layer state change
*/
-__attribute__((weak)) layer_state_t layer_state_set_user(layer_state_t state) { return state; }
+__attribute__((weak)) layer_state_t layer_state_set_user(layer_state_t state) {
+ return state;
+}
/** \brief Layer state set keyboard
*
* Runs keyboard code on layer state change
*/
-__attribute__((weak)) layer_state_t layer_state_set_kb(layer_state_t state) { return layer_state_set_user(state); }
+__attribute__((weak)) layer_state_t layer_state_set_kb(layer_state_t state) {
+ return layer_state_set_user(state);
+}
/** \brief Layer state set
*
@@ -105,9 +123,9 @@ void layer_state_set(layer_state_t state) {
layer_debug();
dprintln();
# ifdef STRICT_LAYER_RELEASE
- clear_keyboard_but_mods(); // To avoid stuck keys
+ clear_keyboard_but_mods(); // To avoid stuck keys
# else
- clear_keyboard_but_mods_and_keys(); // Don't reset held keys
+ clear_keyboard_but_mods_and_keys(); // Don't reset held keys
# endif
}
@@ -115,13 +133,17 @@ void layer_state_set(layer_state_t state) {
*
* Turn off all layers
*/
-void layer_clear(void) { layer_state_set(0); }
+void layer_clear(void) {
+ layer_state_set(0);
+}
/** \brief Layer state is
*
* Return whether the given state is on (it might still be shadowed by a higher state, though)
*/
-bool layer_state_is(uint8_t layer) { return layer_state_cmp(layer_state, layer); }
+bool layer_state_is(uint8_t layer) {
+ return layer_state_cmp(layer_state, layer);
+}
/** \brief Layer state compare
*
@@ -138,47 +160,63 @@ bool layer_state_cmp(layer_state_t cmp_layer_state, uint8_t layer) {
*
* Turns on the given layer and turn off all other layers
*/
-void layer_move(uint8_t layer) { layer_state_set((layer_state_t)1 << layer); }
+void layer_move(uint8_t layer) {
+ layer_state_set((layer_state_t)1 << layer);
+}
/** \brief Layer on
*
* Turns on given layer
*/
-void layer_on(uint8_t layer) { layer_state_set(layer_state | ((layer_state_t)1 << layer)); }
+void layer_on(uint8_t layer) {
+ layer_state_set(layer_state | ((layer_state_t)1 << layer));
+}
/** \brief Layer off
*
* Turns off given layer
*/
-void layer_off(uint8_t layer) { layer_state_set(layer_state & ~((layer_state_t)1 << layer)); }
+void layer_off(uint8_t layer) {
+ layer_state_set(layer_state & ~((layer_state_t)1 << layer));
+}
/** \brief Layer invert
*
* Toggle the given layer (set it if it's unset, or unset it if it's set)
*/
-void layer_invert(uint8_t layer) { layer_state_set(layer_state ^ ((layer_state_t)1 << layer)); }
+void layer_invert(uint8_t layer) {
+ layer_state_set(layer_state ^ ((layer_state_t)1 << layer));
+}
/** \brief Layer or
*
* Turns on layers based on matching bits between specifed layer and existing layer state
*/
-void layer_or(layer_state_t state) { layer_state_set(layer_state | state); }
+void layer_or(layer_state_t state) {
+ layer_state_set(layer_state | state);
+}
/** \brief Layer and
*
* Turns on layers based on matching enabled bits between specifed layer and existing layer state
*/
-void layer_and(layer_state_t state) { layer_state_set(layer_state & state); }
+void layer_and(layer_state_t state) {
+ layer_state_set(layer_state & state);
+}
/** \brief Layer xor
*
* Turns on layers based on non-matching bits between specifed layer and existing layer state
*/
-void layer_xor(layer_state_t state) { layer_state_set(layer_state ^ state); }
+void layer_xor(layer_state_t state) {
+ layer_state_set(layer_state ^ state);
+}
/** \brief Layer debug printing
*
* Print out the hex value of the 32-bit layer state, as well as the value of the highest bit.
*/
-void layer_debug(void) { dprintf("%08lX(%u)", layer_state, get_highest_layer(layer_state)); }
+void layer_debug(void) {
+ dprintf("%08lX(%u)", layer_state, get_highest_layer(layer_state));
+}
#endif
#if !defined(NO_ACTION_LAYER) && !defined(STRICT_LAYER_RELEASE)
@@ -276,4 +314,6 @@ uint8_t layer_switch_get_layer(keypos_t key) {
*
* Gets action code based on key position
*/
-action_t layer_switch_get_action(keypos_t key) { return action_for_key(layer_switch_get_layer(key), key); }
+action_t layer_switch_get_action(keypos_t key) {
+ return action_for_key(layer_switch_get_layer(key), key);
+}