Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document syncing layer change callback across halves #23298

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions docs/feature_layers.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,44 @@ Use the `IS_LAYER_ON_STATE(state, layer)` and `IS_LAYER_OFF_STATE(state, layer)`

Outside of `layer_state_set_*` functions, you can use the `IS_LAYER_ON(layer)` and `IS_LAYER_OFF(layer)` macros to check global layer state.

### Running on slave half as well as master (for split keyboards)

By default `layer_state_set_*` functions only run on master. A workaround for this is to use split custom communication to call the slave half.

In `keymap.c`:

```c
#include "transactions.h"

void update_layer_state_set(uint8_t state, const void* unused, uint8_t unused2, void* unused3) {
layer_state_set_user(state);
}

void keyboard_post_init_user(void) {
// Register callback to update layer LEDs on layer change.
transaction_register_rpc(SYNC_LAYER_CHANGE, update_layer_state_set);
}

layer_state_t layer_state_set_user(layer_state_t state) {
/* Other config code
...
*/
if (is_keyboard_master()){
transaction_rpc_exec(SYNC_LAYER_CHANGE, state, NULL, 0, NULL);
}
return state;
```

In `config.h`:

```c
// Transaction ID for inter-half coms.
#define SPLIT_TRANSACTION_IDS_USER SYNC_LAYER_CHANGE

#define SPLIT_LAYER_STATE_ENABLE
```


### `layer_state_set_*` Function Documentation

* Keyboard/Revision: `layer_state_t layer_state_set_kb(layer_state_t state)`
Expand Down
Loading