refactor(splits): Ability to override split role.
* Move central/peripheral setting to Kconfig.defconfig files to allow left/right .conf files to override central/peripheral role for splits.
This commit is contained in:
parent
842aa5a842
commit
4db5b169bf
36 changed files with 92 additions and 79 deletions
|
@ -39,7 +39,7 @@ target_sources(app PRIVATE src/events/sensor_event.c)
|
|||
target_sources_ifdef(CONFIG_ZMK_BLE app PRIVATE src/events/ble_active_profile_changed.c)
|
||||
target_sources_ifdef(CONFIG_ZMK_BLE app PRIVATE src/events/battery_state_changed.c)
|
||||
target_sources_ifdef(CONFIG_USB app PRIVATE src/events/usb_conn_state_changed.c)
|
||||
if (NOT CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL)
|
||||
if ((NOT CONFIG_ZMK_SPLIT) OR CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL)
|
||||
target_sources(app PRIVATE src/behaviors/behavior_key_press.c)
|
||||
target_sources(app PRIVATE src/behaviors/behavior_reset.c)
|
||||
target_sources(app PRIVATE src/behaviors/behavior_hold_tap.c)
|
||||
|
@ -57,9 +57,13 @@ target_sources_ifdef(CONFIG_ZMK_RGB_UNDERGLOW app PRIVATE src/behaviors/behavior
|
|||
target_sources_ifdef(CONFIG_ZMK_BLE app PRIVATE src/behaviors/behavior_bt.c)
|
||||
target_sources_ifdef(CONFIG_ZMK_BLE app PRIVATE src/ble.c)
|
||||
target_sources_ifdef(CONFIG_ZMK_BLE app PRIVATE src/battery.c)
|
||||
target_sources_ifdef(CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL app PRIVATE src/split_listener.c)
|
||||
target_sources_ifdef(CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL app PRIVATE src/split/bluetooth/service.c)
|
||||
target_sources_ifdef(CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL app PRIVATE src/split/bluetooth/central.c)
|
||||
if (CONFIG_ZMK_SPLIT_BLE AND (NOT CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL))
|
||||
target_sources(app PRIVATE src/split_listener.c)
|
||||
target_sources(app PRIVATE src/split/bluetooth/service.c)
|
||||
endif()
|
||||
if (CONFIG_ZMK_SPLIT_BLE AND CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL)
|
||||
target_sources(app PRIVATE src/split/bluetooth/central.c)
|
||||
endif()
|
||||
target_sources_ifdef(CONFIG_USB app PRIVATE src/usb.c)
|
||||
target_sources_ifdef(CONFIG_ZMK_BLE app PRIVATE src/hog.c)
|
||||
target_sources_ifdef(CONFIG_ZMK_RGB_UNDERGLOW app PRIVATE src/rgb_underglow.c)
|
||||
|
|
15
app/Kconfig
15
app/Kconfig
|
@ -83,7 +83,6 @@ menu "Split Support"
|
|||
|
||||
config ZMK_SPLIT
|
||||
bool "Split keyboard support"
|
||||
default n
|
||||
|
||||
if ZMK_SPLIT
|
||||
|
||||
|
@ -95,19 +94,12 @@ config ZMK_SPLIT_BLE
|
|||
|
||||
if ZMK_SPLIT_BLE
|
||||
|
||||
choice ZMK_SPLIT_BLE_ROLE
|
||||
bool "BLE Role For Split Communication"
|
||||
default ZMK_SPLIT_BLE_ROLE_CENTRAL
|
||||
|
||||
config ZMK_SPLIT_BLE_ROLE_CENTRAL
|
||||
bool "Central"
|
||||
select BT_CENTRAL
|
||||
select BT_GATT_CLIENT
|
||||
|
||||
config ZMK_SPLIT_BLE_ROLE_PERIPHERAL
|
||||
bool "Peripheral"
|
||||
|
||||
if ZMK_SPLIT_BLE_ROLE_PERIPHERAL
|
||||
if !ZMK_SPLIT_BLE_ROLE_CENTRAL
|
||||
|
||||
config ZMK_USB
|
||||
default n
|
||||
|
@ -121,12 +113,9 @@ config BT_MAX_CONN
|
|||
config BT_GAP_AUTO_UPDATE_CONN_PARAMS
|
||||
default n
|
||||
|
||||
#ZMK_SPLIT_BLE_ROLE_PERIPHERAL
|
||||
#!ZMK_SPLIT_BLE_ROLE_CENTRAL
|
||||
endif
|
||||
|
||||
#ZMK_SPLIT_BLE_ROLE
|
||||
endchoice
|
||||
|
||||
#ZMK_SPLIT_BLE
|
||||
endif
|
||||
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
|
||||
if SHIELD_CORNE_LEFT
|
||||
|
||||
config ZMK_KEYBOARD_NAME
|
||||
default "Corne Left"
|
||||
default "Corne"
|
||||
|
||||
config ZMK_SPLIT_BLE_ROLE_CENTRAL
|
||||
default y
|
||||
|
||||
endif
|
||||
|
||||
|
||||
if SHIELD_CORNE_RIGHT
|
||||
|
||||
config ZMK_KEYBOARD_NAME
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
CONFIG_ZMK_SPLIT=y
|
||||
CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y
|
|
@ -1,2 +0,0 @@
|
|||
CONFIG_ZMK_SPLIT=y
|
||||
CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y
|
|
@ -6,6 +6,9 @@ if SHIELD_CRADIO_LEFT
|
|||
config ZMK_KEYBOARD_NAME
|
||||
default "cradio left"
|
||||
|
||||
config ZMK_SPLIT_BLE_ROLE_CENTRAL
|
||||
default y
|
||||
|
||||
endif
|
||||
|
||||
if SHIELD_CRADIO_RIGHT
|
||||
|
@ -14,3 +17,10 @@ config ZMK_KEYBOARD_NAME
|
|||
default "cradio right"
|
||||
|
||||
endif
|
||||
|
||||
if SHIELD_CRADIO_LEFT || SHIELD_CRADIO_RIGHT
|
||||
|
||||
config ZMK_SPLIT
|
||||
default y
|
||||
|
||||
endif
|
|
@ -1,5 +1,2 @@
|
|||
# Copyright (c) 2020 The ZMK Contributors
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
CONFIG_ZMK_SPLIT=y
|
||||
CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
# Copyright (c) 2020 The ZMK Contributors
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
CONFIG_ZMK_SPLIT=y
|
||||
CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y
|
||||
|
|
|
@ -6,6 +6,9 @@ if SHIELD_IRIS_LEFT
|
|||
config ZMK_KEYBOARD_NAME
|
||||
default "Iris Left"
|
||||
|
||||
config ZMK_SPLIT_BLE_ROLE_CENTRAL
|
||||
default y
|
||||
|
||||
endif
|
||||
|
||||
if SHIELD_IRIS_RIGHT
|
||||
|
@ -14,3 +17,10 @@ config ZMK_KEYBOARD_NAME
|
|||
default "Iris Right"
|
||||
|
||||
endif
|
||||
|
||||
if SHIELD_IRIS_LEFT || SHIELD_IRIS_RIGHT
|
||||
|
||||
config ZMK_SPLIT
|
||||
default y
|
||||
|
||||
endif
|
|
@ -1,2 +0,0 @@
|
|||
CONFIG_ZMK_SPLIT=y
|
||||
CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y
|
|
@ -1,2 +0,0 @@
|
|||
CONFIG_ZMK_SPLIT=y
|
||||
CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y
|
|
@ -4,6 +4,9 @@ if SHIELD_JIAN_LEFT
|
|||
config ZMK_KEYBOARD_NAME
|
||||
default "Jian Left"
|
||||
|
||||
config ZMK_SPLIT_BLE_ROLE_CENTRAL
|
||||
default y
|
||||
|
||||
endif
|
||||
|
||||
|
||||
|
@ -18,6 +21,5 @@ if SHIELD_JIAN_LEFT || SHIELD_JIAN_RIGHT
|
|||
|
||||
config ZMK_SPLIT
|
||||
default y
|
||||
|
||||
|
||||
endif
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
CONFIG_ZMK_SPLIT=y
|
||||
CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y
|
|
@ -1,2 +0,0 @@
|
|||
CONFIG_ZMK_SPLIT=y
|
||||
CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y
|
|
@ -4,6 +4,9 @@ if SHIELD_JORNE_LEFT
|
|||
config ZMK_KEYBOARD_NAME
|
||||
default "Jorne Left"
|
||||
|
||||
config ZMK_SPLIT_BLE_ROLE_CENTRAL
|
||||
default y
|
||||
|
||||
endif
|
||||
|
||||
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
CONFIG_ZMK_SPLIT=y
|
||||
CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y
|
|
@ -1,2 +0,0 @@
|
|||
CONFIG_ZMK_SPLIT=y
|
||||
CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y
|
|
@ -4,6 +4,9 @@ if SHIELD_KYRIA_LEFT
|
|||
config ZMK_KEYBOARD_NAME
|
||||
default "Kyria Left"
|
||||
|
||||
config ZMK_SPLIT_BLE_ROLE_CENTRAL
|
||||
default y
|
||||
|
||||
endif
|
||||
|
||||
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
CONFIG_ZMK_SPLIT=y
|
||||
CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y
|
|
@ -1,2 +0,0 @@
|
|||
CONFIG_ZMK_SPLIT=y
|
||||
CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y
|
|
@ -4,6 +4,9 @@ if SHIELD_LILY58_LEFT
|
|||
config ZMK_KEYBOARD_NAME
|
||||
default "Lily58 Left"
|
||||
|
||||
config ZMK_SPLIT_BLE_ROLE_CENTRAL
|
||||
default y
|
||||
|
||||
endif
|
||||
|
||||
if SHIELD_LILY58_RIGHT
|
||||
|
@ -15,6 +18,9 @@ endif
|
|||
|
||||
if SHIELD_LILY58_LEFT || SHIELD_LILY58_RIGHT
|
||||
|
||||
config ZMK_SPLIT
|
||||
default y
|
||||
|
||||
if ZMK_DISPLAY
|
||||
|
||||
config I2C
|
||||
|
@ -52,3 +58,4 @@ endchoice
|
|||
endif # LVGL
|
||||
|
||||
endif
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# Uncomment to enable encoder
|
||||
# CONFIG_EC11=y
|
||||
# CONFIG_EC11_TRIGGER_GLOBAL_THREAD=y
|
||||
|
||||
CONFIG_ZMK_SPLIT=y
|
||||
CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y
|
|
@ -1,2 +1 @@
|
|||
CONFIG_ZMK_SPLIT=y
|
||||
CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y
|
||||
|
||||
|
|
|
@ -6,6 +6,9 @@ if SHIELD_MICRODOX_LEFT
|
|||
config ZMK_KEYBOARD_NAME
|
||||
default "Microdox Left"
|
||||
|
||||
config ZMK_SPLIT_BLE_ROLE_CENTRAL
|
||||
default y
|
||||
|
||||
endif
|
||||
|
||||
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
CONFIG_ZMK_SPLIT=y
|
||||
CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y
|
|
@ -1,2 +0,0 @@
|
|||
CONFIG_ZMK_SPLIT=y
|
||||
CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y
|
|
@ -7,6 +7,9 @@ if SHIELD_QUEFRENCY_LEFT
|
|||
config ZMK_KEYBOARD_NAME
|
||||
default "Quefrency Left"
|
||||
|
||||
config ZMK_SPLIT_BLE_ROLE_CENTRAL
|
||||
default y
|
||||
|
||||
endif
|
||||
|
||||
if SHIELD_QUEFRENCY_RIGHT
|
||||
|
@ -15,3 +18,10 @@ config ZMK_KEYBOARD_NAME
|
|||
default "Quefrency Right"
|
||||
|
||||
endif
|
||||
|
||||
if SHIELD_QUEFRENCY_LEFT || SHIELD_QUEFRENCY_RIGHT
|
||||
|
||||
config ZMK_SPLIT
|
||||
default y
|
||||
|
||||
endif
|
|
@ -1,2 +0,0 @@
|
|||
CONFIG_ZMK_SPLIT=y
|
||||
CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y
|
|
@ -1,2 +0,0 @@
|
|||
CONFIG_ZMK_SPLIT=y
|
||||
CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y
|
|
@ -5,6 +5,10 @@ if SHIELD_SOFLE_LEFT
|
|||
|
||||
config ZMK_KEYBOARD_NAME
|
||||
default "Sofle Left"
|
||||
|
||||
config ZMK_SPLIT_BLE_ROLE_CENTRAL
|
||||
default y
|
||||
|
||||
endif
|
||||
|
||||
if SHIELD_SOFLE_RIGHT
|
||||
|
@ -15,6 +19,9 @@ endif
|
|||
|
||||
if SHIELD_SOFLE_LEFT || SHIELD_SOFLE_RIGHT
|
||||
|
||||
config ZMK_SPLIT
|
||||
default y
|
||||
|
||||
if ZMK_DISPLAY
|
||||
|
||||
config I2C
|
||||
|
|
|
@ -1,5 +1,2 @@
|
|||
# Copyright (c) 2020 Ryan Cross
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
CONFIG_ZMK_SPLIT=y
|
||||
CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y
|
||||
|
|
|
@ -1,5 +1,2 @@
|
|||
# Copyright (c) 2020 Ryan Cross
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
CONFIG_ZMK_SPLIT=y
|
||||
CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y
|
||||
|
|
|
@ -8,6 +8,9 @@ if SHIELD_SPLITREUS62_LEFT
|
|||
config ZMK_KEYBOARD_NAME
|
||||
default "Splitreus62 Left"
|
||||
|
||||
config ZMK_SPLIT_BLE_ROLE_CENTRAL
|
||||
default y
|
||||
|
||||
endif
|
||||
|
||||
if SHIELD_SPLITREUS62_RIGHT
|
||||
|
@ -19,4 +22,7 @@ endif
|
|||
|
||||
if SHIELD_SPLITREUS62_LEFT || SHIELD_SPLITREUS62_RIGHT
|
||||
|
||||
config ZMK_SPLIT
|
||||
default y
|
||||
|
||||
endif
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
CONFIG_ZMK_SPLIT=y
|
||||
CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y
|
|
@ -1,2 +0,0 @@
|
|||
CONFIG_ZMK_SPLIT=y
|
||||
CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y
|
|
@ -63,19 +63,24 @@ static uint8_t active_profile;
|
|||
#define DEVICE_NAME CONFIG_BT_DEVICE_NAME
|
||||
#define DEVICE_NAME_LEN (sizeof(DEVICE_NAME) - 1)
|
||||
|
||||
#define IS_HOST_PERIPHERAL \
|
||||
(!IS_ENABLED(CONFIG_ZMK_SPLIT) || IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL))
|
||||
#define IS_SPLIT_PERIPHERAL \
|
||||
(IS_ENABLED(CONFIG_ZMK_SPLIT) && !IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL))
|
||||
|
||||
static const struct bt_data zmk_ble_ad[] = {
|
||||
#if !IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL)
|
||||
#if IS_HOST_PERIPHERAL
|
||||
BT_DATA(BT_DATA_NAME_COMPLETE, DEVICE_NAME, DEVICE_NAME_LEN),
|
||||
BT_DATA_BYTES(BT_DATA_GAP_APPEARANCE, 0xC1, 0x03),
|
||||
#endif
|
||||
BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)),
|
||||
BT_DATA_BYTES(BT_DATA_UUID16_SOME,
|
||||
#if !IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL)
|
||||
#if IS_HOST_PERIPHERAL
|
||||
0x12, 0x18, /* HID Service */
|
||||
#endif
|
||||
0x0f, 0x18 /* Battery Service */
|
||||
),
|
||||
#if IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL)
|
||||
#if IS_SPLIT_PERIPHERAL
|
||||
BT_DATA_BYTES(BT_DATA_UUID128_ALL, ZMK_SPLIT_BT_SERVICE_UUID)
|
||||
#endif
|
||||
};
|
||||
|
@ -373,7 +378,7 @@ static void connected(struct bt_conn *conn, uint8_t err) {
|
|||
|
||||
bt_conn_le_param_update(conn, BT_LE_CONN_PARAM(0x0006, 0x000c, 30, 400));
|
||||
|
||||
#if IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL)
|
||||
#if IS_SPLIT_PERIPHERAL
|
||||
bt_conn_le_phy_update(conn, BT_CONN_LE_PHY_PARAM_2M);
|
||||
#endif
|
||||
|
||||
|
@ -462,7 +467,7 @@ static void auth_cancel(struct bt_conn *conn) {
|
|||
LOG_DBG("Pairing cancelled: %s", log_strdup(addr));
|
||||
}
|
||||
|
||||
#if !IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL)
|
||||
#if IS_HOST_PERIPHERAL
|
||||
static enum bt_security_err auth_pairing_accept(struct bt_conn *conn,
|
||||
const struct bt_conn_pairing_feat *const feat) {
|
||||
struct bt_conn_info info;
|
||||
|
@ -476,7 +481,7 @@ static enum bt_security_err auth_pairing_accept(struct bt_conn *conn,
|
|||
|
||||
return BT_SECURITY_ERR_SUCCESS;
|
||||
};
|
||||
#endif /* !IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL) */
|
||||
#endif /* IS_HOST_PERIPHERAL */
|
||||
|
||||
static void auth_pairing_complete(struct bt_conn *conn, bool bonded) {
|
||||
struct bt_conn_info info;
|
||||
|
@ -491,22 +496,22 @@ static void auth_pairing_complete(struct bt_conn *conn, bool bonded) {
|
|||
return;
|
||||
}
|
||||
|
||||
#if !IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL)
|
||||
#if IS_HOST_PERIPHERAL
|
||||
if (!zmk_ble_active_profile_is_open()) {
|
||||
LOG_ERR("Pairing completed but current profile is not open: %s", log_strdup(addr));
|
||||
bt_unpair(BT_ID_DEFAULT, dst);
|
||||
return;
|
||||
}
|
||||
#endif /* !IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL) */
|
||||
#endif /* IS_HOST_PERIPHERAL */
|
||||
|
||||
set_profile_address(active_profile, dst);
|
||||
update_advertising();
|
||||
};
|
||||
|
||||
static struct bt_conn_auth_cb zmk_ble_auth_cb_display = {
|
||||
#if !IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL)
|
||||
#if IS_HOST_PERIPHERAL
|
||||
.pairing_accept = auth_pairing_accept,
|
||||
#endif /* !IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL) */
|
||||
#endif /* IS_HOST_PERIPHERAL */
|
||||
.pairing_complete = auth_pairing_complete,
|
||||
// .passkey_display = auth_passkey_display,
|
||||
|
||||
|
|
Loading…
Reference in a new issue