Skip to content

Commit

Permalink
refactor(splits): Ability to override split role.
Browse files Browse the repository at this point in the history
* Move central/peripheral setting to Kconfig.defconfig
  files to allow left/right .conf files to override
  central/peripheral role for splits.
  • Loading branch information
petejohanson committed Dec 28, 2020
1 parent 842aa5a commit 4db5b16
Show file tree
Hide file tree
Showing 36 changed files with 92 additions and 79 deletions.
12 changes: 8 additions & 4 deletions app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
15 changes: 2 additions & 13 deletions app/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ menu "Split Support"

config ZMK_SPLIT
bool "Split keyboard support"
default n

if ZMK_SPLIT

Expand All @@ -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
Expand All @@ -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

Expand Down
7 changes: 4 additions & 3 deletions app/boards/shields/corne/Kconfig.defconfig
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@

if SHIELD_CORNE_LEFT

config ZMK_KEYBOARD_NAME
default "Corne Left"
default "Corne"

endif
config ZMK_SPLIT_BLE_ROLE_CENTRAL
default y

endif

if SHIELD_CORNE_RIGHT

Expand Down
2 changes: 0 additions & 2 deletions app/boards/shields/corne/corne_left.conf
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
CONFIG_ZMK_SPLIT=y
CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y
2 changes: 0 additions & 2 deletions app/boards/shields/corne/corne_right.conf
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
CONFIG_ZMK_SPLIT=y
CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y
10 changes: 10 additions & 0 deletions app/boards/shields/cradio/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
3 changes: 0 additions & 3 deletions app/boards/shields/cradio/cradio_left.conf
Original file line number Diff line number Diff line change
@@ -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
2 changes: 0 additions & 2 deletions app/boards/shields/cradio/cradio_right.conf
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions app/boards/shields/iris/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
2 changes: 0 additions & 2 deletions app/boards/shields/iris/iris_left.conf
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
CONFIG_ZMK_SPLIT=y
CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y
2 changes: 0 additions & 2 deletions app/boards/shields/iris/iris_right.conf
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
CONFIG_ZMK_SPLIT=y
CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y
4 changes: 3 additions & 1 deletion app/boards/shields/jian/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ if SHIELD_JIAN_LEFT
config ZMK_KEYBOARD_NAME
default "Jian Left"

config ZMK_SPLIT_BLE_ROLE_CENTRAL
default y

endif


Expand All @@ -18,6 +21,5 @@ if SHIELD_JIAN_LEFT || SHIELD_JIAN_RIGHT

config ZMK_SPLIT
default y


endif
2 changes: 0 additions & 2 deletions app/boards/shields/jian/jian_left.conf
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
CONFIG_ZMK_SPLIT=y
CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y
2 changes: 0 additions & 2 deletions app/boards/shields/jian/jian_right.conf
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
CONFIG_ZMK_SPLIT=y
CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y
3 changes: 3 additions & 0 deletions app/boards/shields/jorne/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ if SHIELD_JORNE_LEFT
config ZMK_KEYBOARD_NAME
default "Jorne Left"

config ZMK_SPLIT_BLE_ROLE_CENTRAL
default y

endif


Expand Down
2 changes: 0 additions & 2 deletions app/boards/shields/jorne/jorne_left.conf
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
CONFIG_ZMK_SPLIT=y
CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y
2 changes: 0 additions & 2 deletions app/boards/shields/jorne/jorne_right.conf
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
CONFIG_ZMK_SPLIT=y
CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y
3 changes: 3 additions & 0 deletions app/boards/shields/kyria/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ if SHIELD_KYRIA_LEFT
config ZMK_KEYBOARD_NAME
default "Kyria Left"

config ZMK_SPLIT_BLE_ROLE_CENTRAL
default y

endif


Expand Down
2 changes: 0 additions & 2 deletions app/boards/shields/kyria/kyria_left.conf
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
CONFIG_ZMK_SPLIT=y
CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y
2 changes: 0 additions & 2 deletions app/boards/shields/kyria/kyria_right.conf
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
CONFIG_ZMK_SPLIT=y
CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y
7 changes: 7 additions & 0 deletions app/boards/shields/lily58/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -15,6 +18,9 @@ endif

if SHIELD_LILY58_LEFT || SHIELD_LILY58_RIGHT

config ZMK_SPLIT
default y

if ZMK_DISPLAY

config I2C
Expand Down Expand Up @@ -52,3 +58,4 @@ endchoice
endif # LVGL

endif

3 changes: 0 additions & 3 deletions app/boards/shields/lily58/lily58_left.conf
Original file line number Diff line number Diff line change
@@ -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
3 changes: 1 addition & 2 deletions app/boards/shields/lily58/lily58_right.conf
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
CONFIG_ZMK_SPLIT=y
CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y

3 changes: 3 additions & 0 deletions app/boards/shields/microdox/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ if SHIELD_MICRODOX_LEFT
config ZMK_KEYBOARD_NAME
default "Microdox Left"

config ZMK_SPLIT_BLE_ROLE_CENTRAL
default y

endif


Expand Down
2 changes: 0 additions & 2 deletions app/boards/shields/microdox/microdox_left.conf
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
CONFIG_ZMK_SPLIT=y
CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y
2 changes: 0 additions & 2 deletions app/boards/shields/microdox/microdox_right.conf
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
CONFIG_ZMK_SPLIT=y
CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y
10 changes: 10 additions & 0 deletions app/boards/shields/quefrency/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
2 changes: 0 additions & 2 deletions app/boards/shields/quefrency/quefrency_left.conf
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
CONFIG_ZMK_SPLIT=y
CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y
2 changes: 0 additions & 2 deletions app/boards/shields/quefrency/quefrency_right.conf
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
CONFIG_ZMK_SPLIT=y
CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y
7 changes: 7 additions & 0 deletions app/boards/shields/sofle/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -15,6 +19,9 @@ endif

if SHIELD_SOFLE_LEFT || SHIELD_SOFLE_RIGHT

config ZMK_SPLIT
default y

if ZMK_DISPLAY

config I2C
Expand Down
3 changes: 0 additions & 3 deletions app/boards/shields/sofle/sofle_left.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
# Copyright (c) 2020 Ryan Cross
# SPDX-License-Identifier: MIT

CONFIG_ZMK_SPLIT=y
CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y
3 changes: 0 additions & 3 deletions app/boards/shields/sofle/sofle_right.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
# Copyright (c) 2020 Ryan Cross
# SPDX-License-Identifier: MIT

CONFIG_ZMK_SPLIT=y
CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y
6 changes: 6 additions & 0 deletions app/boards/shields/splitreus62/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -19,4 +22,7 @@ endif

if SHIELD_SPLITREUS62_LEFT || SHIELD_SPLITREUS62_RIGHT

config ZMK_SPLIT
default y

endif
2 changes: 0 additions & 2 deletions app/boards/shields/splitreus62/splitreus62_left.conf
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
CONFIG_ZMK_SPLIT=y
CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y
2 changes: 0 additions & 2 deletions app/boards/shields/splitreus62/splitreus62_right.conf
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
CONFIG_ZMK_SPLIT=y
CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y
Loading

0 comments on commit 4db5b16

Please sign in to comment.