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
Show file tree
Hide file tree
Changes from all commits
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
24 changes: 24 additions & 0 deletions docs/feature_layers.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,30 @@ 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 is to manually update it in housekeeping.

In `keymap.c`:

```c
static uint32_t last_layer_state = 0;

void update_layer_state_set(void){
if (!is_keyboard_master()) {
if (last_layer_state != layer_state) {
last_layer_state = layer_state;
layer_state_set_user(layer_state);
}
}
}

void housekeeping_task_user(void) {
update_layer_state_set();
}
```


### `layer_state_set_*` Function Documentation

* Keyboard/Revision: `layer_state_t layer_state_set_kb(layer_state_t state)`
Expand Down
22 changes: 22 additions & 0 deletions docs/feature_split_keyboard.md
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ QMK's split transport allows for arbitrary data transactions at both the keyboar
To leverage this, a keyboard or user/keymap can define a comma-separated list of _transaction IDs_:

```c
// *_SYNC_* names can be called whatever you want, so long as they are passed to transaction_register_rpc with the function they apply to
// for keyboard-level data sync:
#define SPLIT_TRANSACTION_IDS_KB KEYBOARD_SYNC_A, KEYBOARD_SYNC_B
// or, for user:
Expand Down Expand Up @@ -381,6 +382,27 @@ By default, the inbound and outbound data is limited to a maximum of 32 bytes ea
#define RPC_S2M_BUFFER_SIZE 48
```

If you only need to transfer a small integer one way, or just run a function on the slave, this can be simplified to:

```c
#include "transactions.h"

void func_to_call(uint8_t data, const void* unused, uint8_t unused2, void* unused3) {
do_something_with(data);
}
void keyboard_post_init_user(void) {
transaction_register_rpc(USER_SYNC_A, func_to_call);
}

void housekeeping_task_user(void) {
if (is_keyboard_master()){
// 24 is arbitrary int8
transaction_rpc_exec(USER_SYNC_A, 24, NULL, 0, NULL);
}
}

```

### Hardware Configuration Options

There are some settings that you may need to configure, based on how the hardware is set up.
Expand Down
Loading