#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; } }