Skip to content

Commit

Permalink
refactor: Fixes for review feedback.
Browse files Browse the repository at this point in the history
  • Loading branch information
petejohanson committed Jan 26, 2024
1 parent ecac94d commit 935e94d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 20 deletions.
18 changes: 9 additions & 9 deletions app/Kconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Copyright (c) 2020 The ZMK Contributors
# SPDX-License-Identifier: MIT
#Copyright(c) 2020 The ZMK Contributors
#SPDX - License - Identifier : MIT

mainmenu "ZMK Firmware"

Expand Down Expand Up @@ -180,7 +180,7 @@ endchoice
config BT_CTLR_PHY_2M
default n if ZMK_BLE_EXPERIMENTAL_CONN

# BT_TINYCRYPT_ECC is required for BT_SMP_SC_PAIR_ONLY when using HCI
#BT_TINYCRYPT_ECC is required for BT_SMP_SC_PAIR_ONLY when using HCI
config BT_TINYCRYPT_ECC
default y if BT_HCI && !BT_CTLR

Expand Down Expand Up @@ -212,7 +212,7 @@ config ZMK_BLE_CLEAR_BONDS_ON_START
bool "Configuration that clears all bond information from the keyboard on startup."
default n

# HID GATT notifications sent this way are *not* picked up by Linux, and possibly others.
#HID GATT notifications sent this way are * not *picked up by Linux, and possibly others.
config BT_GATT_NOTIFY_MULTIPLE
default n

Expand Down Expand Up @@ -240,7 +240,7 @@ endif
#Output Types
endmenu

# HID
#HID
endmenu

rsource "src/split/Kconfig"
Expand All @@ -259,7 +259,7 @@ menuconfig ZMK_RGB_UNDERGLOW

if ZMK_RGB_UNDERGLOW

# This default value cuts down on tons of excess .conf files, if you're using GPIO, manually disable this
#This default value cuts down on tons of excess.conf files, if you're using GPIO, manually disable this
config SPI
default y

Expand Down Expand Up @@ -360,7 +360,7 @@ config ZMK_BACKLIGHT_AUTO_OFF_USB
#ZMK_BACKLIGHT
endif

#Display/LED Options
#Display / LED Options
endmenu

menu "Mouse Options"
Expand Down Expand Up @@ -504,7 +504,7 @@ if ZMK_KSCAN_SIDEBAND_BEHAVIORS

config ZMK_KSCAN_SIDEBAND_BEHAVIORS_INIT_PRIORITY
int "Keyboard scan sideband behaviors driver init priority"
# The default kscan init priority is 90, so be sure we are lower.
#The default kscan init priority is 90, so be sure we are initialezed after.
default 95

endif # ZMK_KSCAN_SIDEBAND_BEHAVIORS
Expand Down Expand Up @@ -545,7 +545,7 @@ choice USB_DRIVER_LOG_LEVEL_CHOICE
default USB_DRIVER_LOG_LEVEL_OFF
endchoice

# We do this to avoid log loop where logging to USB generates more log messages.
#We do this to avoid log loop where logging to USB generates more log messages.

config USB_CDC_ACM_RINGBUF_SIZE
default 1024
Expand Down
19 changes: 8 additions & 11 deletions app/src/kscan_sideband_behaviors.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,44 +41,41 @@ struct ksbb_data {
// KSBBs to check when a kscan callback from the "wrapped" inner kscan fires.
static const struct device *ksbbs[] = {DT_INST_FOREACH_STATUS_OKAY(GET_KSBB_DEV)};

int find_ksbb_for_inner(const struct device *inner_dev, const struct device **ksbb_dev) {
const struct device *find_ksbb_for_inner(const struct device *inner_dev) {
for (int i = 0; i < ARRAY_SIZE(ksbbs); i++) {
const struct device *ksbb = ksbbs[i];
const struct ksbb_config *cfg = ksbb->config;

if (cfg->kscan == inner_dev) {
*ksbb_dev = ksbb;
return 0;
return ksbb;
}
}

return -ENODEV;
return NULL;
}

int find_sideband_behavior(const struct device *dev, uint32_t row, uint32_t column,
struct ksbb_entry **entry) {
struct ksbb_entry *find_sideband_behavior(const struct device *dev, uint32_t row, uint32_t column) {
const struct ksbb_config *cfg = dev->config;

for (int e = 0; e < cfg->entries_len; e++) {
struct ksbb_entry *candidate = &cfg->entries[e];

if (candidate->row == row && candidate->column == column) {
*entry = candidate;
return 0;
return candidate;
}
}

return -ENODEV;
return NULL;
}

void ksbb_inner_kscan_callback(const struct device *dev, uint32_t row, uint32_t column,
bool pressed) {
struct ksbb_entry *entry = NULL;
const struct device *ksbb = NULL;

if (find_ksbb_for_inner(dev, &ksbb) >= 0) {
if ((ksbb = find_ksbb_for_inner(dev)) != NULL) {
struct ksbb_data *data = ksbb->data;
if (find_sideband_behavior(ksbb, row, column, &entry) >= 0) {
if ((entry = find_sideband_behavior(ksbb, row, column)) != NULL) {
struct zmk_behavior_binding_event event = {.position = INT32_MAX,
.timestamp = k_uptime_get()};

Expand Down

0 comments on commit 935e94d

Please sign in to comment.