diff options
author | Alex Ong <the.onga@gmail.com> | 2019-05-18 06:47:50 +1000 |
---|---|---|
committer | Florian Didron <fdidron@users.noreply.github.com> | 2019-07-27 11:25:58 +0900 |
commit | 8253427f12bea961443bb0cb1c22171a4ccd8db0 (patch) | |
tree | c99a59f1691b86e6aa8622f6e9dc57236c7e750a /tmk_core/common/action_layer.h | |
parent | aa482e2e4ffbb9747a18b0d5e6e6b2e610619484 (diff) |
Typedef'ed layer_state_t to uint32_t (#3637)
* Typedef'ed layer_state_t to uint32_t.
This enables future work with layer_state_t to uint8_t for optimization purposes.
* Removed accidental xeal60 commit
* Revert to egyptian brackets, added sizeof(layer_state_t) so when layer_state_t is redefined it will automagically work.
* Add additional typedefs
* Add checks for setting layer state
* Update tmk_core/common/action_layer.h
Co-Authored-By: alex-ong <the.onga@gmail.com>
* Revert commit.
Diffstat (limited to 'tmk_core/common/action_layer.h')
-rw-r--r-- | tmk_core/common/action_layer.h | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/tmk_core/common/action_layer.h b/tmk_core/common/action_layer.h index 6e2f35d90d..7fa30c86d6 100644 --- a/tmk_core/common/action_layer.h +++ b/tmk_core/common/action_layer.h @@ -21,24 +21,32 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include "keyboard.h" #include "action.h" +#if defined(LAYER_STATE_8BIT) || ( defined(DYNAMIC_KEYMAP_ENABLE) && DYNAMIC_KEYMAP_LAYER_COUNT >= 8 ) +typedef uint8_t layer_state_t; +#elif defined(LAYER_STATE_16BIT) +typedef uint16_t layer_state_t; +#else +typedef uint32_t layer_state_t; +#endif + /* * Default Layer */ -extern uint32_t default_layer_state; +extern layer_state_t default_layer_state; void default_layer_debug(void); -void default_layer_set(uint32_t state); +void default_layer_set(layer_state_t state); __attribute__((weak)) -uint32_t default_layer_state_set_kb(uint32_t state); +layer_state_t default_layer_state_set_kb(layer_state_t state); __attribute__((weak)) -uint32_t default_layer_state_set_user(uint32_t state); +layer_state_t default_layer_state_set_user(layer_state_t state); #ifndef NO_ACTION_LAYER /* bitwise operation */ -void default_layer_or(uint32_t state); -void default_layer_and(uint32_t state); -void default_layer_xor(uint32_t state); +void default_layer_or(layer_state_t state); +void default_layer_and(layer_state_t state); +void default_layer_xor(layer_state_t state); #else #define default_layer_or(state) #define default_layer_and(state) @@ -50,11 +58,11 @@ void default_layer_xor(uint32_t state); * Keymap Layer */ #ifndef NO_ACTION_LAYER -extern uint32_t layer_state; +extern layer_state_t layer_state; -void layer_state_set(uint32_t state); +void layer_state_set(layer_state_t state); bool layer_state_is(uint8_t layer); -bool layer_state_cmp(uint32_t layer1, uint8_t layer2); +bool layer_state_cmp(layer_state_t layer1, uint8_t layer2); void layer_debug(void); void layer_clear(void); @@ -63,9 +71,9 @@ void layer_on(uint8_t layer); void layer_off(uint8_t layer); void layer_invert(uint8_t layer); /* bitwise operation */ -void layer_or(uint32_t state); -void layer_and(uint32_t state); -void layer_xor(uint32_t state); +void layer_or(layer_state_t state); +void layer_and(layer_state_t state); +void layer_xor(layer_state_t state); #else #define layer_state 0 @@ -84,8 +92,8 @@ void layer_xor(uint32_t state); #define layer_xor(state) #endif -uint32_t layer_state_set_user(uint32_t state); -uint32_t layer_state_set_kb(uint32_t state); +layer_state_t layer_state_set_user(layer_state_t state); +layer_state_t layer_state_set_kb(layer_state_t state); /* pressed actions cache */ #if !defined(NO_ACTION_LAYER) && !defined(STRICT_LAYER_RELEASE) |