This commit is contained in:
Bryan Forbes 2024-06-21 18:10:32 -05:00 committed by GitHub
commit 825b6a9147
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
28 changed files with 179 additions and 53 deletions

View file

@ -472,14 +472,6 @@ config ZMK_BEHAVIORS_QUEUE_SIZE
rsource "Kconfig.behaviors"
config ZMK_MACRO_DEFAULT_WAIT_MS
int "Default time to wait (in milliseconds) before triggering the next behavior in macros"
default 15
config ZMK_MACRO_DEFAULT_TAP_MS
int "Default time to wait (in milliseconds) between the press and release events of a tapped behavior in macros"
default 30
endmenu
menu "Advanced"
@ -547,8 +539,9 @@ config ZMK_LOGGING_MINIMAL
if !ZMK_LOGGING_MINIMAL
config ZMK_LOG_LEVEL
default 4
choice ZMK_LOG_LEVEL_CHOICE
default ZMK_LOG_LEVEL_DBG
endchoice
endif

View file

@ -35,4 +35,131 @@ config ZMK_BEHAVIOR_SENSOR_ROTATE_VAR
config ZMK_BEHAVIOR_MACRO
bool
default y
depends on DT_HAS_ZMK_BEHAVIOR_MACRO_ENABLED || DT_HAS_ZMK_BEHAVIOR_MACRO_ONE_PARAM_ENABLED || DT_HAS_ZMK_BEHAVIOR_MACRO_TWO_PARAM_ENABLED
depends on DT_HAS_ZMK_BEHAVIOR_MACRO_ENABLED || DT_HAS_ZMK_BEHAVIOR_MACRO_ONE_PARAM_ENABLED || DT_HAS_ZMK_BEHAVIOR_MACRO_TWO_PARAM_ENABLED
config ZMK_MACRO_DEFAULT_WAIT_MS
int "Default time to wait (in milliseconds) before triggering the next behavior in macros"
default 15
config ZMK_MACRO_DEFAULT_TAP_MS
int "Default time to wait (in milliseconds) between the press and release events of a tapped behavior in macros"
default 30
menu "Logging"
module = ZMK_BEHAVIORS
module-str = "ZMK Behaviors"
parent-module = ZMK
source "subsys/logging/Kconfig.template.log_config_inherit"
module = ZMK_BEHAVIOR_BACKLIGHT
module-str = "ZMK Backlight Behavior"
parent-module = ZMK_BEHAVIORS
source "subsys/logging/Kconfig.template.log_config_inherit"
module = ZMK_BEHAVIOR_BLUETOOTH
module-str = "ZMK Bluetooth Behavior"
parent-module = ZMK_BEHAVIORS
source "subsys/logging/Kconfig.template.log_config_inherit"
module = ZMK_BEHAVIOR_CAPS_WORD
module-str = "ZMK Caps Word Behavior"
parent-module = ZMK_BEHAVIORS
source "subsys/logging/Kconfig.template.log_config_inherit"
module = ZMK_BEHAVIOR_EXT_POWER
module-str = "ZMK Ext Power Behavior"
parent-module = ZMK_BEHAVIORS
source "subsys/logging/Kconfig.template.log_config_inherit"
module = ZMK_BEHAVIOR_HOLD_TAP
module-str = "ZMK Hold Tap Behavior"
parent-module = ZMK_BEHAVIORS
source "subsys/logging/Kconfig.template.log_config_inherit"
module = ZMK_BEHAVIOR_KEY_PRESS
module-str = "ZMK Key Press Behavior"
parent-module = ZMK_BEHAVIORS
source "subsys/logging/Kconfig.template.log_config_inherit"
module = ZMK_BEHAVIOR_KEY_REPEAT
module-str = "ZMK Key Repeat Behavior"
parent-module = ZMK_BEHAVIORS
source "subsys/logging/Kconfig.template.log_config_inherit"
module = ZMK_BEHAVIOR_KEY_TOGGLE
module-str = "ZMK Key Toggle Behavior"
parent-module = ZMK_BEHAVIORS
source "subsys/logging/Kconfig.template.log_config_inherit"
module = ZMK_BEHAVIOR_MACRO
module-str = "ZMK Macro Behavior"
parent-module = ZMK_BEHAVIORS
source "subsys/logging/Kconfig.template.log_config_inherit"
module = ZMK_BEHAVIOR_MOD_MORPH
module-str = "ZMK Mod Morph Behavior"
parent-module = ZMK_BEHAVIORS
source "subsys/logging/Kconfig.template.log_config_inherit"
module = ZMK_BEHAVIOR_MOMENTARY_LAYER
module-str = "ZMK Momentary Layer Behavior"
parent-module = ZMK_BEHAVIORS
source "subsys/logging/Kconfig.template.log_config_inherit"
module = ZMK_BEHAVIOR_MOUSE_KEY_PRESS
module-str = "ZMK Mouse Key Press Behavior"
parent-module = ZMK_BEHAVIORS
source "subsys/logging/Kconfig.template.log_config_inherit"
module = ZMK_BEHAVIOR_NONE
module-str = "ZMK None Behavior"
parent-module = ZMK_BEHAVIORS
source "subsys/logging/Kconfig.template.log_config_inherit"
module = ZMK_BEHAVIOR_OUTPUTS
module-str = "ZMK Outputs Behavior"
parent-module = ZMK_BEHAVIORS
source "subsys/logging/Kconfig.template.log_config_inherit"
module = ZMK_BEHAVIOR_RESET
module-str = "ZMK Reset Behavior"
parent-module = ZMK_BEHAVIORS
source "subsys/logging/Kconfig.template.log_config_inherit"
module = ZMK_BEHAVIOR_RGB_UNDERGLOW
module-str = "ZMK RGB Underglow Behavior"
parent-module = ZMK_BEHAVIORS
source "subsys/logging/Kconfig.template.log_config_inherit"
module = ZMK_BEHAVIOR_SENSOR_ROTATE_COMMON
module-str = "ZMK Common Sensor Rotate Behavior"
parent-module = ZMK_BEHAVIORS
source "subsys/logging/Kconfig.template.log_config_inherit"
module = ZMK_BEHAVIOR_STICKY_KEY
module-str = "ZMK Sticky Key Behavior"
parent-module = ZMK_BEHAVIORS
source "subsys/logging/Kconfig.template.log_config_inherit"
module = ZMK_BEHAVIOR_TAP_DANCE
module-str = "ZMK Tap Dance Behavior"
parent-module = ZMK_BEHAVIORS
source "subsys/logging/Kconfig.template.log_config_inherit"
module = ZMK_BEHAVIOR_TO_LAYER
module-str = "ZMK To Layer Behavior"
parent-module = ZMK_BEHAVIORS
source "subsys/logging/Kconfig.template.log_config_inherit"
module = ZMK_BEHAVIOR_TOGGLE_LAYER
module-str = "ZMK Toggle Layer Behavior"
parent-module = ZMK_BEHAVIORS
source "subsys/logging/Kconfig.template.log_config_inherit"
module = ZMK_BEHAVIOR_TRANSPARENT
module-str = "ZMK Transparent Behavior"
parent-module = ZMK_BEHAVIORS
source "subsys/logging/Kconfig.template.log_config_inherit"
endmenu

View file

@ -48,6 +48,7 @@ testcases=$(find $path -name nrf52_bsim.keymap -exec dirname \{\} \;)
num_cases=$(echo "$testcases" | wc -l)
if [ $num_cases -gt 1 ] || [ "$testcases" != "${path%%/}" ]; then
echo "$testcases"
mkdir -p ./build/tests
echo "" > ./build/tests/pass-fail.log
echo "$testcases" | BLE_TESTS_QUIET_OUTPUT=y BLE_TESTS_NO_CENTRAL_BUILD=y xargs -L 1 -P ${J:-4} ./run-ble-test.sh
err=$?

View file

@ -16,6 +16,7 @@ fi
testcases=$(find $path -name native_posix_64.keymap -exec dirname \{\} \;)
num_cases=$(echo "$testcases" | wc -l)
if [ $num_cases -gt 1 ] || [ "$testcases" != "$path" ]; then
mkdir -p ./build/tests
echo "" > ./build/tests/pass-fail.log
echo "$testcases" | xargs -L 1 -P ${J:-4} ./run-test.sh
err=$?

View file

@ -13,7 +13,6 @@
#include <zmk/behavior.h>
#include <zephyr/logging/log.h>
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
const struct device *zmk_behavior_get_binding(const char *name) {
return behavior_get_binding(name);
@ -40,6 +39,8 @@ const struct device *z_impl_behavior_get_binding(const char *name) {
}
#if IS_ENABLED(CONFIG_LOG)
LOG_MODULE_REGISTER(zmk_behavior, CONFIG_ZMK_BEHAVIORS_LOG_LEVEL);
static int check_behavior_names(void) {
// Behavior names must be unique, but we don't have a good way to enforce this
// at compile time, so log an error at runtime if they aren't unique.

View file

@ -10,7 +10,7 @@
#include <zephyr/logging/log.h>
#include <drivers/behavior.h>
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
LOG_MODULE_REGISTER(zmk_behavior_queue, CONFIG_ZMK_BEHAVIORS_LOG_LEVEL);
struct q_item {
uint32_t position;

View file

@ -14,10 +14,10 @@
#include <zmk/backlight.h>
#include <zmk/keymap.h>
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
#if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT)
LOG_MODULE_REGISTER(DT_DRV_COMPAT, CONFIG_ZMK_BEHAVIOR_BACKLIGHT_LOG_LEVEL);
static int behavior_backlight_init(const struct device *dev) { return 0; }
static int

View file

@ -8,9 +8,7 @@
#include <zephyr/device.h>
#include <zephyr/bluetooth/conn.h>
#include <zephyr/logging/log.h>
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
#include <drivers/behavior.h>
#include <dt-bindings/zmk/bt.h>
@ -20,6 +18,8 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
#if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT)
LOG_MODULE_REGISTER(DT_DRV_COMPAT, CONFIG_ZMK_BEHAVIOR_BLUETOOTH_LOG_LEVEL);
static int on_keymap_binding_pressed(struct zmk_behavior_binding *binding,
struct zmk_behavior_binding_event event) {
switch (binding->param1) {

View file

@ -20,10 +20,10 @@
#include <zmk/hid.h>
#include <zmk/keymap.h>
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
#if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT)
LOG_MODULE_REGISTER(DT_DRV_COMPAT, CONFIG_ZMK_BEHAVIOR_CAPS_WORD_LOG_LEVEL);
struct caps_word_continue_item {
uint16_t page;
uint32_t id;

View file

@ -14,10 +14,11 @@
#include <dt-bindings/zmk/ext_power.h>
#include <zephyr/logging/log.h>
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
#if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT)
LOG_MODULE_REGISTER(DT_DRV_COMPAT, CONFIG_ZMK_BEHAVIOR_EXT_POWER_LOG_LEVEL);
static int
on_keymap_binding_convert_central_state_dependent_params(struct zmk_behavior_binding *binding,
struct zmk_behavior_binding_event event) {

View file

@ -20,10 +20,10 @@
#include <zmk/behavior.h>
#include <zmk/keymap.h>
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
#if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT)
LOG_MODULE_REGISTER(DT_DRV_COMPAT, CONFIG_ZMK_BEHAVIOR_HOLD_TAP_LOG_LEVEL);
#define ZMK_BHV_HOLD_TAP_MAX_HELD 10
#define ZMK_BHV_HOLD_TAP_MAX_CAPTURED_EVENTS 40

View file

@ -14,7 +14,7 @@
#include <zmk/events/keycode_state_changed.h>
#include <zmk/behavior.h>
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
LOG_MODULE_REGISTER(DT_DRV_COMPAT, CONFIG_ZMK_BEHAVIOR_KEY_PRESS_LOG_LEVEL);
static int behavior_key_press_init(const struct device *dev) { return 0; };

View file

@ -15,10 +15,10 @@
#include <zmk/event_manager.h>
#include <zmk/events/keycode_state_changed.h>
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
#if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT)
LOG_MODULE_REGISTER(DT_DRV_COMPAT, CONFIG_ZMK_BEHAVIOR_KEY_REPEAT_LOG_LEVEL);
struct behavior_key_repeat_config {
uint8_t index;
uint8_t usage_pages_count;

View file

@ -15,7 +15,7 @@
#include <zmk/events/keycode_state_changed.h>
#include <zmk/behavior.h>
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
LOG_MODULE_REGISTER(DT_DRV_COMPAT, CONFIG_ZMK_BEHAVIOR_KEY_TOGGLE_LOG_LEVEL);
static int behavior_key_toggle_init(const struct device *dev) { return 0; }

View file

@ -11,7 +11,7 @@
#include <zmk/behavior_queue.h>
#include <zmk/keymap.h>
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
LOG_MODULE_REGISTER(zmk_behavior_macro, CONFIG_ZMK_BEHAVIOR_MACRO_LOG_LEVEL);
enum behavior_macro_mode {
MACRO_MODE_TAP,

View file

@ -19,10 +19,10 @@
#include <zmk/events/modifiers_state_changed.h>
#include <zmk/hid.h>
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
#if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT)
LOG_MODULE_REGISTER(DT_DRV_COMPAT, CONFIG_ZMK_BEHAVIOR_MOD_MORPH_LOG_LEVEL);
struct behavior_mod_morph_config {
struct zmk_behavior_binding normal_binding;
struct zmk_behavior_binding morph_binding;

View file

@ -13,7 +13,7 @@
#include <zmk/keymap.h>
#include <zmk/behavior.h>
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
LOG_MODULE_REGISTER(DT_DRV_COMPAT, CONFIG_ZMK_BEHAVIOR_MOMENTARY_LAYER_LOG_LEVEL);
struct behavior_mo_config {};
struct behavior_mo_data {};

View file

@ -14,10 +14,10 @@
#include <zmk/event_manager.h>
#include <zmk/events/mouse_button_state_changed.h>
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
#if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT)
LOG_MODULE_REGISTER(DT_DRV_COMPAT, CONFIG_ZMK_BEHAVIOR_MOUSE_KEY_PRESS_LOG_LEVEL);
static int behavior_mouse_key_press_init(const struct device *dev) { return 0; };
static int on_keymap_binding_pressed(struct zmk_behavior_binding *binding,

View file

@ -12,10 +12,10 @@
#include <zmk/behavior.h>
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
#if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT)
LOG_MODULE_REGISTER(DT_DRV_COMPAT, CONFIG_ZMK_BEHAVIOR_NONE_LOG_LEVEL);
static int behavior_none_init(const struct device *dev) { return 0; };
static int on_keymap_binding_pressed(struct zmk_behavior_binding *binding,

View file

@ -8,6 +8,7 @@
#include <zephyr/device.h>
#include <zephyr/devicetree.h>
#include <zephyr/logging/log.h>
#include <drivers/behavior.h>
#include <dt-bindings/zmk/outputs.h>
@ -15,11 +16,10 @@
#include <zmk/behavior.h>
#include <zmk/endpoints.h>
#include <zephyr/logging/log.h>
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
#if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT)
LOG_MODULE_REGISTER(DT_DRV_COMPAT, CONFIG_ZMK_BEHAVIOR_OUTPUTS_LOG_LEVEL);
static int on_keymap_binding_pressed(struct zmk_behavior_binding *binding,
struct zmk_behavior_binding_event event) {
switch (binding->param1) {

View file

@ -14,9 +14,10 @@
#include <zmk/behavior.h>
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
#if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT)
LOG_MODULE_REGISTER(DT_DRV_COMPAT, CONFIG_ZMK_BEHAVIOR_RESET_LOG_LEVEL);
struct behavior_reset_config {
int type;
};

View file

@ -14,10 +14,10 @@
#include <zmk/rgb_underglow.h>
#include <zmk/keymap.h>
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
#if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT)
LOG_MODULE_REGISTER(DT_DRV_COMPAT, CONFIG_ZMK_BEHAVIOR_RGB_UNDERGLOW_LOG_LEVEL);
static int behavior_rgb_underglow_init(const struct device *dev) { return 0; }
static int

View file

@ -9,7 +9,8 @@
#include "behavior_sensor_rotate_common.h"
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
LOG_MODULE_REGISTER(zmk_behavior_sensor_rotate_common,
CONFIG_ZMK_BEHAVIOR_SENSOR_ROTATE_COMMON_LOG_LEVEL);
int zmk_behavior_sensor_rotate_common_accept_data(
struct zmk_behavior_binding *binding, struct zmk_behavior_binding_event event,

View file

@ -20,10 +20,10 @@
#include <zmk/hid.h>
#include <zmk/keymap.h>
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
#if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT)
LOG_MODULE_REGISTER(DT_DRV_COMPAT, CONFIG_ZMK_BEHAVIOR_STICKY_KEY_LOG_LEVEL);
#define KEY_PRESS DEVICE_DT_NAME(DT_INST(0, zmk_behavior_key_press))
#define ZMK_BHV_STICKY_KEY_MAX_HELD 10

View file

@ -17,10 +17,10 @@
#include <zmk/events/keycode_state_changed.h>
#include <zmk/hid.h>
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
#if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT)
LOG_MODULE_REGISTER(DT_DRV_COMPAT, CONFIG_ZMK_BEHAVIOR_TAP_DANCE_LOG_LEVEL);
#define ZMK_BHV_TAP_DANCE_MAX_HELD 10
#define ZMK_BHV_TAP_DANCE_POSITION_FREE UINT32_MAX
@ -258,4 +258,4 @@ static int behavior_tap_dance_init(const struct device *dev) {
DT_INST_FOREACH_STATUS_OKAY(KP_INST)
#endif
#endif

View file

@ -13,10 +13,10 @@
#include <zmk/keymap.h>
#include <zmk/behavior.h>
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
#if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT)
LOG_MODULE_REGISTER(DT_DRV_COMPAT, CONFIG_ZMK_BEHAVIOR_TO_LAYER_LOG_LEVEL);
static int behavior_to_init(const struct device *dev) { return 0; };
static int to_keymap_binding_pressed(struct zmk_behavior_binding *binding,

View file

@ -13,10 +13,10 @@
#include <zmk/keymap.h>
#include <zmk/behavior.h>
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
#if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT)
LOG_MODULE_REGISTER(DT_DRV_COMPAT, CONFIG_ZMK_BEHAVIOR_TOGGLE_LAYER_LOG_LEVEL);
struct behavior_tog_config {};
struct behavior_tog_data {};

View file

@ -12,10 +12,10 @@
#include <zmk/behavior.h>
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
#if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT)
LOG_MODULE_REGISTER(DT_DRV_COMPAT, CONFIG_ZMK_BEHAVIOR_TRANSPARENT_LOG_LEVEL);
static int behavior_transparent_init(const struct device *dev) { return 0; };
static int on_keymap_binding_pressed(struct zmk_behavior_binding *binding,