refactor(splits): Use index for event source.

* Track peripherals by indexes slot, with all appropiate peripheral
  state stored in the slot.
* Event sources tracked by peripheral slot index.
This commit is contained in:
Peter Johanson
2022-01-02 04:55:30 +00:00
committed by Pete Johanson
parent e8540f17fc
commit 9297c5f2b4
8 changed files with 252 additions and 103 deletions

View File

@@ -9,6 +9,17 @@
#include <zmk/keys.h>
#include <zmk/ble/profile.h>
#define ZMK_BLE_IS_CENTRAL \
(IS_ENABLED(CONFIG_ZMK_SPLIT) && IS_ENABLED(CONFIG_ZMK_BLE) && \
IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL))
#if ZMK_BLE_IS_CENTRAL
#define ZMK_BLE_PROFILE_COUNT (CONFIG_BT_MAX_PAIRED - 1)
#define ZMK_BLE_SPLIT_PERIPHERAL_COUNT 1
#else
#define ZMK_BLE_PROFILE_COUNT CONFIG_BT_MAX_PAIRED
#endif
int zmk_ble_clear_bonds();
int zmk_ble_prof_next();
int zmk_ble_prof_prev();

View File

@@ -8,16 +8,9 @@
#include <zephyr.h>
#include <zmk/event_manager.h>
#include <bluetooth/addr.h>
#if IS_ENABLED(CONFIG_ZMK_BLE)
typedef const bt_addr_le_t *zmk_position_state_changed_source_t;
#else
typedef void *zmk_position_state_changed_source_t;
#endif
struct zmk_position_state_changed {
zmk_position_state_changed_source_t source;
uint8_t source;
uint32_t position;
bool state;
int64_t timestamp;

View File

@@ -20,8 +20,8 @@ int zmk_keymap_layer_toggle(uint8_t layer);
int zmk_keymap_layer_to(uint8_t layer);
const char *zmk_keymap_layer_label(uint8_t layer);
int zmk_keymap_position_state_changed(zmk_position_state_changed_source_t source, uint32_t position,
bool pressed, int64_t timestamp);
int zmk_keymap_position_state_changed(uint8_t source, uint32_t position, bool pressed,
int64_t timestamp);
#define ZMK_KEYMAP_EXTRACT_BINDING(idx, drv_inst) \
{ \

View File

@@ -4,5 +4,5 @@
#include <bluetooth/addr.h>
#include <zmk/behavior.h>
int zmk_split_bt_invoke_behavior(const bt_addr_le_t *source, struct zmk_behavior_binding *binding,
int zmk_split_bt_invoke_behavior(uint8_t source, struct zmk_behavior_binding *binding,
struct zmk_behavior_binding_event event, bool state);