blob: 8c04c00c8bebc96fb7845616f1eaf646c25a474c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#include QMK_KEYBOARD_H
#include "transactions.h"
#include "star_key.h"
typedef struct _master_to_slave_t {
int is_star;
} master_to_slave_t;
bool is_star = 0;
static bool is_synced = 1;
// Handler for the slave, receive the star information
void user_sync_a_slave_handler(uint8_t in_buflen, const void* in_data, uint8_t out_buflen, void* out_data) {
const master_to_slave_t *m2s = (const master_to_slave_t*)in_data;
is_star = m2s->is_star;
}
void star_key_init(void) {
if (!is_keyboard_master()) {
transaction_register_rpc(SET_STAR_KEY, user_sync_a_slave_handler);
}
}
void set_star_key(bool status) {
is_star = status;
is_synced = 0;
}
void sync_star_key(void) {
if (!is_synced) {
// Send the state to the other side of the keyboard
master_to_slave_t m2s = { is_star };
transaction_rpc_send(SET_STAR_KEY, sizeof(m2s), &m2s);
is_synced = 1;
}
}
|