Skip to content

Commit

Permalink
Merge pull request #1101 from priyadi/layer_state_set_kb
Browse files Browse the repository at this point in the history
Add weak layer_state_set_kb hook
  • Loading branch information
jackhumbert authored Feb 15, 2017
2 parents fd2925e + bd8d717 commit 7bef285
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tmk_core/common/action_layer.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,14 @@
*/
uint32_t default_layer_state = 0;

__attribute__((weak))
uint32_t default_layer_state_set_kb(uint32_t state) {
return state;
}

static void default_layer_state_set(uint32_t state)
{
state = default_layer_state_set_kb(state);
debug("default_layer_state: ");
default_layer_debug(); debug(" to ");
default_layer_state = state;
Expand Down Expand Up @@ -57,8 +63,14 @@ void default_layer_xor(uint32_t state)
*/
uint32_t layer_state = 0;

__attribute__((weak))
uint32_t layer_state_set_kb(uint32_t state) {
return state;
}

static void layer_state_set(uint32_t state)
{
state = layer_state_set_kb(state);
dprint("layer_state: ");
layer_debug(); dprint(" to ");
layer_state = state;
Expand Down
5 changes: 5 additions & 0 deletions tmk_core/common/action_layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ extern uint32_t default_layer_state;
void default_layer_debug(void);
void default_layer_set(uint32_t state);

__attribute__((weak))
uint32_t default_layer_state_set_kb(uint32_t state);

#ifndef NO_ACTION_LAYER
/* bitwise operation */
void default_layer_or(uint32_t state);
Expand Down Expand Up @@ -69,6 +72,8 @@ void layer_xor(uint32_t state);
#define layer_xor(state)
#define layer_debug()

__attribute__((weak))
uint32_t layer_state_set_kb(uint32_t state);
#endif

/* pressed actions cache */
Expand Down

0 comments on commit 7bef285

Please sign in to comment.