diff options
author | Pete Johanson <peter@peterjohanson.com> | 2021-01-18 00:35:56 -0500 |
---|---|---|
committer | Pete Johanson <peter@peterjohanson.com> | 2021-01-20 07:06:11 -0500 |
commit | 3fe2acc2d191006fa6309191ee99b2e4e249ed08 (patch) | |
tree | 4994508fdc58daee4629c671e07e689b6332bd32 /app/src/split | |
parent | 003db892adadb7b760f43411d7154fe60bf3556d (diff) |
refactor(core): Extra event payloads to own types, refactor API.
* Make it easier to use *just* event payloads by defining the data,
and then having event manager macros generate "wrapper structs"
* Improve is_*/cast_* APIs to hide details of full event struct.
* Create `zmk_event_t` typedef to pass to event handlers.
* Bring event names inline w/ consistent `zmk_` prefix.
Diffstat (limited to 'app/src/split')
-rw-r--r-- | app/src/split/bluetooth/central.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/app/src/split/bluetooth/central.c b/app/src/split/bluetooth/central.c index 6772869..a56b0b8 100644 --- a/app/src/split/bluetooth/central.c +++ b/app/src/split/bluetooth/central.c @@ -33,17 +33,14 @@ static struct bt_uuid_128 uuid = BT_UUID_INIT_128(ZMK_SPLIT_BT_SERVICE_UUID); static struct bt_gatt_discover_params discover_params; static struct bt_gatt_subscribe_params subscribe_params; -K_MSGQ_DEFINE(peripheral_event_msgq, sizeof(struct zmk_position_state_changed_data), +K_MSGQ_DEFINE(peripheral_event_msgq, sizeof(struct zmk_position_state_changed), CONFIG_ZMK_SPLIT_BLE_CENTRAL_POSITION_QUEUE_SIZE, 4); void peripheral_event_work_callback(struct k_work *work) { - struct zmk_position_state_changed_data ev; + struct zmk_position_state_changed ev; while (k_msgq_get(&peripheral_event_msgq, &ev, K_NO_WAIT) == 0) { - struct position_state_changed *pos_ev = new_position_state_changed(); - pos_ev->data = ev; - LOG_DBG("Trigger key position state change for %d", ev.position); - ZMK_EVENT_RAISE(pos_ev); + ZMK_EVENT_RAISE(new_zmk_position_state_changed(ev)); } } @@ -74,7 +71,7 @@ static uint8_t split_central_notify_func(struct bt_conn *conn, if (changed_positions[i] & BIT(j)) { uint32_t position = (i * 8) + j; bool pressed = position_state[i] & BIT(j); - struct zmk_position_state_changed_data ev = { + struct zmk_position_state_changed ev = { .position = position, .state = pressed, .timestamp = k_uptime_get()}; k_msgq_put(&peripheral_event_msgq, &ev, K_NO_WAIT); |