From bc282a0a4f1af4f6f78a0dd63e5b022eb76a603c Mon Sep 17 00:00:00 2001 From: Nick Date: Sun, 2 Aug 2020 10:29:07 -0500 Subject: WIP DZ60RGB board definition --- app/boards/arm/dz60rgb/CMakeLists.txt | 9 +++ app/boards/arm/dz60rgb/Kconfig.board | 6 ++ app/boards/arm/dz60rgb/Kconfig.defconfig | 14 +++++ app/boards/arm/dz60rgb/board.cmake | 6 ++ app/boards/arm/dz60rgb/dz60rgb_rev1.dts | 87 +++++++++++++++++++++++++++ app/boards/arm/dz60rgb/dz60rgb_rev1.yaml | 19 ++++++ app/boards/arm/dz60rgb/dz60rgb_rev1_defconfig | 30 +++++++++ app/boards/arm/dz60rgb/keymap/keymap.overlay | 37 ++++++++++++ app/boards/arm/dz60rgb/pinmux.c | 69 +++++++++++++++++++++ 9 files changed, 277 insertions(+) create mode 100644 app/boards/arm/dz60rgb/CMakeLists.txt create mode 100644 app/boards/arm/dz60rgb/Kconfig.board create mode 100644 app/boards/arm/dz60rgb/Kconfig.defconfig create mode 100644 app/boards/arm/dz60rgb/board.cmake create mode 100644 app/boards/arm/dz60rgb/dz60rgb_rev1.dts create mode 100644 app/boards/arm/dz60rgb/dz60rgb_rev1.yaml create mode 100644 app/boards/arm/dz60rgb/dz60rgb_rev1_defconfig create mode 100644 app/boards/arm/dz60rgb/keymap/keymap.overlay create mode 100644 app/boards/arm/dz60rgb/pinmux.c diff --git a/app/boards/arm/dz60rgb/CMakeLists.txt b/app/boards/arm/dz60rgb/CMakeLists.txt new file mode 100644 index 0000000..6a0ec73 --- /dev/null +++ b/app/boards/arm/dz60rgb/CMakeLists.txt @@ -0,0 +1,9 @@ +# SPDX-License-Identifier: MIT + +list(APPEND EXTRA_DTC_FLAGS "-qq") + +if(CONFIG_PINMUX) +zephyr_library() +zephyr_library_sources(pinmux.c) +zephyr_library_include_directories(${ZEPHYR_BASE}/drivers) +endif() diff --git a/app/boards/arm/dz60rgb/Kconfig.board b/app/boards/arm/dz60rgb/Kconfig.board new file mode 100644 index 0000000..a96271f --- /dev/null +++ b/app/boards/arm/dz60rgb/Kconfig.board @@ -0,0 +1,6 @@ +# Copyright (c) 2020 Nick Winans +# SPDX-License-Identifier: MIT + +config BOARD_DZ60RGB_REV1 + bool "DZ60RGB Keyboard" + depends on SOC_STM32F303XC diff --git a/app/boards/arm/dz60rgb/Kconfig.defconfig b/app/boards/arm/dz60rgb/Kconfig.defconfig new file mode 100644 index 0000000..cfa71d3 --- /dev/null +++ b/app/boards/arm/dz60rgb/Kconfig.defconfig @@ -0,0 +1,14 @@ +# Planck keyboard configuration + +# Copyright (c) 2020 Nick Winans +# SPDX-License-Identifier: MIT + +if BOARD_DZ60RGB_REV1 + +config ZMK_KEYBOARD_NAME + default "DZ60RGB Rev 1" + +config ZMK_USB + default y + +endif # BOARD_DZ60RGB_REV1 diff --git a/app/boards/arm/dz60rgb/board.cmake b/app/boards/arm/dz60rgb/board.cmake new file mode 100644 index 0000000..4843c41 --- /dev/null +++ b/app/boards/arm/dz60rgb/board.cmake @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: MIT + +board_runner_args(jlink "--device=STM32F303VC" "--speed=4000") + +include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake) +include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake) diff --git a/app/boards/arm/dz60rgb/dz60rgb_rev1.dts b/app/boards/arm/dz60rgb/dz60rgb_rev1.dts new file mode 100644 index 0000000..8066b5a --- /dev/null +++ b/app/boards/arm/dz60rgb/dz60rgb_rev1.dts @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2020 Nick Winans + * + * SPDX-License-Identifier: MIT + */ + +/dts-v1/; +#include + +#include + +/ { + model = "DZ60RGB, Rev 1"; + compatible = "dz60rgb,rev1", "st,stm32f303"; + + chosen { + zephyr,sram = &sram0; + zephyr,flash = &flash0; + zmk,kscan = &kscan0; + }; + + default_transform: keymap_transform_0 { + compatible = "zmk,matrix-transform"; + columns = <14>; + rows = <5>; + map = < +RC(0,0) RC(0,1) RC(0,2) RC(0,3) RC(0,4) RC(0,5) RC(0,6) RC(0,7) RC(0,8) RC(0,9) RC(0,10) RC(0,11) RC(0,12) RC(0,13) +RC(1,0) RC(1,1) RC(1,2) RC(1,3) RC(1,4) RC(1,5) RC(1,6) RC(1,7) RC(1,8) RC(1,9) RC(1,10) RC(1,11) RC(1,12) RC(1,13) +RC(2,0) RC(2,1) RC(2,2) RC(2,3) RC(2,4) RC(2,5) RC(2,6) RC(2,7) RC(2,8) RC(2,9) RC(2,10) RC(2,11) RC(2,13) +RC(3,0) RC(3,1) RC(3,2) RC(3,3) RC(3,4) RC(3,5) RC(3,6) RC(3,7) RC(3,8) RC(3,9) RC(3,10) RC(3,11) RC(3,13) +RC(4,0) RC(4,1) RC(4,2) RC(4,5) RC(4,9) RC(4,10) RC(4,11) RC(4,12) RC(4,13) + >; + }; + + kscan0: kscan { + compatible = "zmk,kscan-gpio-matrix"; + label = "KSCAN"; + + diode-direction = "col2row"; + row-gpios + = <&gpioa 9 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&gpiob 10 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&gpiob 11 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&gpiob 14 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&gpiob 12 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + ; + col-gpios + = <&gpioa 6 GPIO_ACTIVE_HIGH> + , <&gpioa 7 GPIO_ACTIVE_HIGH> + , <&gpiob 0 GPIO_ACTIVE_HIGH> + , <&gpiob 13 GPIO_ACTIVE_HIGH> + , <&gpiob 15 GPIO_ACTIVE_HIGH> + , <&gpioa 8 GPIO_ACTIVE_HIGH> + , <&gpioa 15 GPIO_ACTIVE_HIGH> + , <&gpiob 3 GPIO_ACTIVE_HIGH> + , <&gpiob 4 GPIO_ACTIVE_HIGH> + , <&gpiob 5 GPIO_ACTIVE_HIGH> + , <&gpiob 6 GPIO_ACTIVE_HIGH> + , <&gpiob 9 GPIO_ACTIVE_HIGH> + , <&gpioc 13 GPIO_ACTIVE_HIGH> + , <&gpioc 14 GPIO_ACTIVE_HIGH> + ; + }; + +}; + +&usb { + status = "okay"; +}; + +&flash0 { + /* + * For more information, see: + * http://docs.zephyrproject.org/latest/guides/dts/index.html#flash-partitions + */ + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + /* Set 6Kb of storage at the end of the 256Kb of flash */ + storage_partition: partition@3e800 { + label = "storage"; + reg = <0x0003e800 0x00001800>; + }; + }; +}; diff --git a/app/boards/arm/dz60rgb/dz60rgb_rev1.yaml b/app/boards/arm/dz60rgb/dz60rgb_rev1.yaml new file mode 100644 index 0000000..d283621 --- /dev/null +++ b/app/boards/arm/dz60rgb/dz60rgb_rev1.yaml @@ -0,0 +1,19 @@ +identifier: DZ60RGB_rev1 +name: DZ60RGBREV1 +type: keyboard +arch: arm +toolchain: + - zephyr + - gnuarmemb + - xtools +ram: 40 +supported: + - gpio + - i2c + - counter + - spi + - usb_device + - lsm303dlhc + - nvs + - can + - kscan diff --git a/app/boards/arm/dz60rgb/dz60rgb_rev1_defconfig b/app/boards/arm/dz60rgb/dz60rgb_rev1_defconfig new file mode 100644 index 0000000..5a4c099 --- /dev/null +++ b/app/boards/arm/dz60rgb/dz60rgb_rev1_defconfig @@ -0,0 +1,30 @@ +# SPDX-License-Identifier: MIT + +CONFIG_SOC_SERIES_STM32F3X=y +CONFIG_SOC_STM32F303XC=y +# 72MHz system clock +CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=72000000 + +# enable pinmux +CONFIG_PINMUX=y + +# enable GPIO +CONFIG_GPIO=y + +# clock configuration +CONFIG_CLOCK_CONTROL=y + +# Clock configuration for Cube Clock control driver +CONFIG_CLOCK_STM32_HSE_CLOCK=8000000 +CONFIG_CLOCK_STM32_SYSCLK_SRC_PLL=y +# use HSE as PLL input +CONFIG_CLOCK_STM32_PLL_SRC_HSE=y +# however, the board does not have an external oscillator, so just use +# the 8MHz clock signal coming from integrated STLink +CONFIG_CLOCK_STM32_HSE_BYPASS=y +# produce 72MHz clock at PLL output +CONFIG_CLOCK_STM32_PLL_PREDIV=1 +CONFIG_CLOCK_STM32_PLL_MULTIPLIER=9 +CONFIG_CLOCK_STM32_AHB_PRESCALER=1 +CONFIG_CLOCK_STM32_APB1_PRESCALER=2 +CONFIG_CLOCK_STM32_APB2_PRESCALER=1 diff --git a/app/boards/arm/dz60rgb/keymap/keymap.overlay b/app/boards/arm/dz60rgb/keymap/keymap.overlay new file mode 100644 index 0000000..9d83adc --- /dev/null +++ b/app/boards/arm/dz60rgb/keymap/keymap.overlay @@ -0,0 +1,37 @@ +#include +#include +#include + +/ { + chosen { + zmk,keymap = &keymap0; + }; + + keymap0: keymap { + compatible = "zmk,keymap"; + label ="Default DZ60RGB Keymap"; + layers = <&default>; + }; + + layers { + compatible = "zmk,layers"; + + default: layer_0 { + label = "DEFAULT"; +// ------------------------------------------------------------------------------------------ +// | ESC | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | BKSP | +// | TAB | Q | W | E | R | T | Y | U | I | O | P | [ | ] | "|" | +// | CAPS | A | S | D | F | G | H | J | K | L | ; | ' | ENTER | +// | SHIFT | Z | X | C | V | B | N | M | , | . | SHIFT(/) | ^ | DEL | +// | CTL | WIN | ALT | SPACE | ALT | MO(1) | <- | v | -> | +// ------------------------------------------------------------------------------------------ + bindings = < + &kp ESC &kp NUM_1 &kp NUM_2 &kp NUM_3 &kp NUM_4 &kp NUM_5 &kp NUM_6 &kp NUM_7 &kp NUM_8 &kp NUM_9 &kp NUM_0 &kp MINUS &kp EQL &kp BKSP + &kp TAB &kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P &kp LBKT &kp RBKT &kp BSLH + &kp CLCK &kp A &kp S &kp D &kp F &kp G &kp H &kp J &kp K &kp L &kp SCLN &kp QUOT &kp RET + &kp LSFT &kp Z &kp X &kp C &kp V &kp B &kp N &kp M &kp CMMA &kp DOT &mt MOD_RSFT FSLH &kp UARW &kp DEL + &kp LCTL &kp LGUI &kp LALT &kp SPC &kp RALT &mo 1 &kp LARW &kp DARW &kp RARW + >; + }; + }; +}; diff --git a/app/boards/arm/dz60rgb/pinmux.c b/app/boards/arm/dz60rgb/pinmux.c new file mode 100644 index 0000000..5df5c90 --- /dev/null +++ b/app/boards/arm/dz60rgb/pinmux.c @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2017 I-SENSE group of ICCS + * + * SPDX-License-Identifier: MIT + */ + +#include +#include +#include +#include +#include + +#include + +/* pin assignments for STM32F3DISCOVERY board */ +static const struct pin_config pinconf[] = { +#ifdef CONFIG_UART_1 + {STM32_PIN_PC4, STM32F3_PINMUX_FUNC_PC4_USART1_TX}, + {STM32_PIN_PC5, STM32F3_PINMUX_FUNC_PC5_USART1_RX}, +#endif /* CONFIG_UART_1 */ +#ifdef CONFIG_UART_2 + {STM32_PIN_PA2, STM32F3_PINMUX_FUNC_PA2_USART2_TX}, + {STM32_PIN_PA3, STM32F3_PINMUX_FUNC_PA3_USART2_RX}, +#endif /* CONFIG_UART_2 */ +#ifdef CONFIG_I2C_1 + {STM32_PIN_PB6, STM32F3_PINMUX_FUNC_PB6_I2C1_SCL}, + {STM32_PIN_PB7, STM32F3_PINMUX_FUNC_PB7_I2C1_SDA}, +#endif /* CONFIG_I2C_1 */ +#ifdef CONFIG_I2C_2 + {STM32_PIN_PA9, STM32F3_PINMUX_FUNC_PA9_I2C2_SCL}, + {STM32_PIN_PA10, STM32F3_PINMUX_FUNC_PA10_I2C2_SDA}, +#endif /* CONFIG_I2C_2 */ +#ifdef CONFIG_SPI_1 +#ifdef CONFIG_SPI_STM32_USE_HW_SS + {STM32_PIN_PA4, STM32F3_PINMUX_FUNC_PA4_SPI1_NSS}, +#endif /* CONFIG_SPI_STM32_USE_HW_SS */ + {STM32_PIN_PA5, STM32F3_PINMUX_FUNC_PA5_SPI1_SCK}, + {STM32_PIN_PA6, STM32F3_PINMUX_FUNC_PA6_SPI1_MISO}, + {STM32_PIN_PA7, STM32F3_PINMUX_FUNC_PA7_SPI1_MOSI}, +#endif /* CONFIG_SPI_1 */ +#ifdef CONFIG_SPI_2 +#ifdef CONFIG_SPI_STM32_USE_HW_SS + {STM32_PIN_PB12, STM32F3_PINMUX_FUNC_PB12_SPI2_NSS}, +#endif /* CONFIG_SPI_STM32_USE_HW_SS */ + {STM32_PIN_PB13, STM32F3_PINMUX_FUNC_PB13_SPI2_SCK}, + {STM32_PIN_PB14, STM32F3_PINMUX_FUNC_PB14_SPI2_MISO}, + {STM32_PIN_PB15, STM32F3_PINMUX_FUNC_PB15_SPI2_MOSI}, +#endif /* CONFIG_SPI_2 */ +#ifdef CONFIG_USB_DC_STM32 + {STM32_PIN_PA11, STM32F3_PINMUX_FUNC_PA11_USB_DM}, + {STM32_PIN_PA12, STM32F3_PINMUX_FUNC_PA12_USB_DP}, +#endif /* CONFIG_USB_DC_STM32 */ +#ifdef CONFIG_CAN_1 + {STM32_PIN_PD0, STM32F3_PINMUX_FUNC_PD0_CAN1_RX}, + {STM32_PIN_PD1, STM32F3_PINMUX_FUNC_PD1_CAN1_TX}, +#endif /* CONFIG_CAN_1 */ +}; + +static int pinmux_stm32_init(struct device *port) +{ + ARG_UNUSED(port); + + stm32_setup_pins(pinconf, ARRAY_SIZE(pinconf)); + + return 0; +} + +SYS_INIT(pinmux_stm32_init, PRE_KERNEL_1, + CONFIG_PINMUX_STM32_DEVICE_INITIALIZATION_PRIORITY); -- cgit v1.2.3 From 45ddd4c2ae6aadfad990a688d1d7e82406f075d8 Mon Sep 17 00:00:00 2001 From: CrossR Date: Tue, 11 Aug 2020 18:07:08 +0100 Subject: Add very basic, untested, Sofle configuration. --- app/boards/shields/sofle/Kconfig.defconfig | 54 ++++++++++++++++++++++ app/boards/shields/sofle/Kconfig.shield | 8 ++++ app/boards/shields/sofle/sofle.conf | 2 + app/boards/shields/sofle/sofle.dtsi | 67 ++++++++++++++++++++++++++++ app/boards/shields/sofle/sofle.keymap | 64 ++++++++++++++++++++++++++ app/boards/shields/sofle/sofle_left.conf | 2 + app/boards/shields/sofle/sofle_left.overlay | 23 ++++++++++ app/boards/shields/sofle/sofle_right.conf | 2 + app/boards/shields/sofle/sofle_right.overlay | 26 +++++++++++ 9 files changed, 248 insertions(+) create mode 100644 app/boards/shields/sofle/Kconfig.defconfig create mode 100644 app/boards/shields/sofle/Kconfig.shield create mode 100644 app/boards/shields/sofle/sofle.conf create mode 100644 app/boards/shields/sofle/sofle.dtsi create mode 100644 app/boards/shields/sofle/sofle.keymap create mode 100644 app/boards/shields/sofle/sofle_left.conf create mode 100644 app/boards/shields/sofle/sofle_left.overlay create mode 100644 app/boards/shields/sofle/sofle_right.conf create mode 100644 app/boards/shields/sofle/sofle_right.overlay diff --git a/app/boards/shields/sofle/Kconfig.defconfig b/app/boards/shields/sofle/Kconfig.defconfig new file mode 100644 index 0000000..4437868 --- /dev/null +++ b/app/boards/shields/sofle/Kconfig.defconfig @@ -0,0 +1,54 @@ + +if SHIELD_SOFLE_LEFT + +config ZMK_KEYBOARD_NAME + default "Sofle Left" + +endif + +if SHIELD_SOFLE_RIGHT + +config ZMK_KEYBOARD_NAME + default "Sofle Right" + +endif + +if SHIELD_SOFLE_LEFT || SHIELD_SOFLE_RIGHT + +if ZMK_DISPLAY + +config I2C + default y + +config SSD1306 + default y + +config SSD1306_REVERSE_MODE + default y + +endif # ZMK_DISPLAY + +if LVGL + +config LVGL_HOR_RES + default 128 + +config LVGL_VER_RES + default 32 + +config LVGL_VDB_SIZE + default 64 + +config LVGL_DPI + default 148 + +config LVGL_BITS_PER_PIXEL + default 1 + +choice LVGL_COLOR_DEPTH + default LVGL_COLOR_DEPTH_1 +endchoice + +endif # LVGL + +endif diff --git a/app/boards/shields/sofle/Kconfig.shield b/app/boards/shields/sofle/Kconfig.shield new file mode 100644 index 0000000..d8d5d75 --- /dev/null +++ b/app/boards/shields/sofle/Kconfig.shield @@ -0,0 +1,8 @@ +# Copyright (c) 2020 Pete Johanson +# SPDX-License-Identifier: MIT + +config SHIELD_SOFLE_LEFT + def_bool $(shields_list_contains,sofle_left) + +config SHIELD_SOFLE_RIGHT + def_bool $(shields_list_contains,sofle_right) diff --git a/app/boards/shields/sofle/sofle.conf b/app/boards/shields/sofle/sofle.conf new file mode 100644 index 0000000..60c20dc --- /dev/null +++ b/app/boards/shields/sofle/sofle.conf @@ -0,0 +1,2 @@ +# Uncomment the following line to enable the Sofle OLED Display +# CONFIG_ZMK_DISPLAY=y diff --git a/app/boards/shields/sofle/sofle.dtsi b/app/boards/shields/sofle/sofle.dtsi new file mode 100644 index 0000000..dfa001c --- /dev/null +++ b/app/boards/shields/sofle/sofle.dtsi @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2020 Pete Johanson + * + * SPDX-License-Identifier: MIT + */ + +#include + +/ { + chosen { + zmk,kscan = &kscan0; + zmk,matrix_transform = &default_transform; + }; + + default_transform: keymap_transform_0 { + compatible = "zmk,matrix-transform"; + columns = <16>; + rows = <4>; +// | SW6 | SW5 | SW4 | SW3 | SW2 | SW1 | | SW1 | SW2 | SW3 | SW4 | SW5 | SW6 | +// | SW12 | SW11 | SW10 | SW9 | SW8 | SW7 | | SW7 | SW8 | SW9 | SW10 | SW11 | SW12 | +// | SW18 | SW17 | SW16 | SW15 | SW14 | SW13 | | SW13 | SW14 | SW15 | SW16 | SW17 | SW18 | +// | SW24 | SW23 | SW22 | SW21 | SW20 | SW19 | | SW19 | SW20 | SW21 | SW22 | SW23 | SW24 | +// | SW29 | SW28 | SW27 | SW26 | SW25 | | SW25 | SW26 | SW27 | SW28 | SW29 | + map = < +RC(0,0) RC(0,1) RC(0,2) RC(0,3) RC(0,4) RC(0,5) RC(0,6) RC(0,7) RC(0,8) RC(0,9) RC(0,10) RC(0,11) +RC(1,0) RC(1,1) RC(1,2) RC(1,3) RC(1,4) RC(1,5) RC(1,6) RC(1,7) RC(1,8) RC(1,9) RC(1,10) RC(1,11) +RC(2,0) RC(2,1) RC(2,2) RC(2,3) RC(2,4) RC(2,5) RC(2,6) RC(2,7) RC(2,8) RC(2,9) RC(2,10) RC(2,11) +RC(3,0) RC(3,1) RC(3,2) RC(3,3) RC(3,4) RC(3,5) RC(3,6) RC(3,7) RC(3,8) RC(3,9) RC(3,10) RC(3,11) + RC(4,1) RC(4,2) RC(4,3) RC(4,4) RC(4,5) RC(4,9) RC(4,10) RC(4,11) RC(4,12) RC(4,13) + >; + }; + + kscan0: kscan { + compatible = "zmk,kscan-gpio-matrix"; + label = "KSCAN"; + + diode-direction = "col2row"; + row-gpios + = <&pro_micro_d 5 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 6 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 7 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 8 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 9 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + ; + + }; +}; + +&pro_micro_i2c { + status = "okay"; + + ssd1306@3c { + compatible = "solomon,ssd1306fb"; + reg = <0x3c>; + label = "DISPLAY"; + width = <128>; + height = <32>; + segment-offset = <0>; + page-offset = <0>; + display-offset = <0>; + multiplex-ratio = <31>; + segment-remap; + com-invdir; + com-sequential; + prechargep = <0x22>; + }; +}; diff --git a/app/boards/shields/sofle/sofle.keymap b/app/boards/shields/sofle/sofle.keymap new file mode 100644 index 0000000..45c20cb --- /dev/null +++ b/app/boards/shields/sofle/sofle.keymap @@ -0,0 +1,64 @@ +#include +#include + +//TODO: Is the encoder stuff needed on every single layer? + +/ { + keymap { + compatible = "zmk,keymap"; + + default_layer { +// ------------------------------------------------------------------------------------------------------------ +// | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | ` | +// | ESC | Q | W | E | R | T | | Y | U | I | O | P | Bkspc | +// | CTRL | A | S | D | F | G | | H | J | K | L | ; | ' | +// | SHIFT | Z | X | C | V | B | | N | M | , | . | / | SHIFT | +// | GUI | ALT | CTRL | LOWER| ENTER | | SPACE | RAISE| CTRL | ALT | GUI | + bindings = < +&kp GRAV &kp NUM_1 &kp NUM_2 &kp NUM_3 &kp NUM_4 &kp NUM_5 &kp NUM_6 &kp NUM_7 &kp NUM_8 &kp NUM_9 &kp NUM_0 &kp GRAV +&kp ESC &kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P &kp BKSP +&kp LCTL &kp A &kp S &kp D &kp F &kp G &kp H &kp J &kp K &kp L &kp SCLN &kp QUOT +&kp LSFT &kp Z &kp X &kp C &kp V &kp B &kp N &kp M &kp CMMA &kp DOT &kp FSLH &kp RSFT + &kp LGUI &kp LALT &kp LCTL &mo 1 &kp RET &kp SPC &mo 2 &kp RCTL &kp RALT &kp RGUI + >; + + sensor-bindings = <&inc_dec_cp M_VOLU M_VOLD &inc_dec_kp PGUP PGDN>; + }; + + lower_layer { +// ------------------------------------------------------------------------------------------------------------ +// | | F1 | F2 | F3 | F4 | F5 | | F6 | F7 | F8 | F9 | F10 | F11 | +// | | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | F12 | +// | TAB | ! | @ | # | $ | % | | ^ | & | * | ( | ) | | | +// | | = | - | + | { | } | | [ | ] | ; | : | \ | | +// | | | | | | | | | | | | + bindings = < +&trans &kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &kp F6 &kp F7 &kp F8 &kp F9 &kp F10 &kp F11 +&trans &kp 1 &kp 2 &kp 3 &kp 4 &kp 5 &kp 6 &kp 7 &kp 8 &kp 9 &kp 0 &kp F12 +&kp TAB &kp BANG &kp ATSN &kp HASH &kp CURU &kp PRCT &kp CRRT &kp AMPS &kp KMLT &kp LPRN &kp RPRN &kp PIPE +&trans &kp EQL &kp MINUS &kp KPLS &kp LCUR &kp RCUR &kp LBKT &kp RKBT &kp SCLN &kp COLN &kp BSLH &trans + &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans + >; + + sensor-bindings = <&inc_dec_cp M_VOLU M_VOLD &inc_dec_kp PGUP PGDN>; + }; + + raise_layer { +// ------------------------------------------------------------------------------------------------------------ +// | | | | | | | | | | | | | | +// | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | | +// | F1 | F2 | F3 | F4 | F5 | F6 | | | <- | ^ | v | -> | | +// | F7 | F8 | F9 | F10 | F11 | F12 | | + | - | = | [ | ] | \ | +// | | | | | | | | | | | | + bindings = < +&trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans +&kp GRAV &kp NUM_1 &kp NUM_2 &kp NUM_3 &kp NUM_4 &kp NUM_5 &kp NUM_6 &kp NUM_7 &kp NUM_8 &kp NUM_9 &kp NUM_0 &trans +&kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &kp F6 &trans &kp LARW &kp UARW &kp DARW & RARW &trans +&kp F7 &kp F8 &kp F9 &kp F10 &kp F11 &kp F12 &kp KPLS &kp MINUS &kp EQL &kp LBKT &kp RBKT &kp BSLH + &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans + >; + }; + + sensor-bindings = <&inc_dec_cp M_VOLU M_VOLD &inc_dec_kp PGUP PGDN>; + }; +}; diff --git a/app/boards/shields/sofle/sofle_left.conf b/app/boards/shields/sofle/sofle_left.conf new file mode 100644 index 0000000..e51dee4 --- /dev/null +++ b/app/boards/shields/sofle/sofle_left.conf @@ -0,0 +1,2 @@ +CONFIG_ZMK_SPLIT=y +CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y \ No newline at end of file diff --git a/app/boards/shields/sofle/sofle_left.overlay b/app/boards/shields/sofle/sofle_left.overlay new file mode 100644 index 0000000..bcfb558 --- /dev/null +++ b/app/boards/shields/sofle/sofle_left.overlay @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2020 Pete Johanson + * + * SPDX-License-Identifier: MIT + */ + +#include "sofle.dtsi" + +&kscan0 { + col-gpios + = <&pro_micro_a 1 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 0 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 15 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 14 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 16 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 10 GPIO_ACTIVE_HIGH> + ; +}; + +&left_encoder { + status = "okay"; +}; + diff --git a/app/boards/shields/sofle/sofle_right.conf b/app/boards/shields/sofle/sofle_right.conf new file mode 100644 index 0000000..990cf7c --- /dev/null +++ b/app/boards/shields/sofle/sofle_right.conf @@ -0,0 +1,2 @@ +CONFIG_ZMK_SPLIT=y +CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y diff --git a/app/boards/shields/sofle/sofle_right.overlay b/app/boards/shields/sofle/sofle_right.overlay new file mode 100644 index 0000000..133f926 --- /dev/null +++ b/app/boards/shields/sofle/sofle_right.overlay @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2020 Pete Johanson + * + * SPDX-License-Identifier: MIT + */ + +#include "sofle.dtsi" + +&default_transform { + col-offset = <6>; +}; + +&kscan0 { + col-gpios + = <&pro_micro_d 10 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 16 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 14 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 15 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 0 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 1 GPIO_ACTIVE_HIGH> + ; +}; + +&right_encoder { + status = "okay"; +}; -- cgit v1.2.3 From 3e264e46d4c53ed7198731fcdfefc74396b48f1a Mon Sep 17 00:00:00 2001 From: Derek Date: Sat, 15 Aug 2020 16:01:35 -0400 Subject: Add splitreus62 shield --- app/boards/shields/splitreus62/Kconfig.defconfig | 54 ++++++++++++++++++++++ app/boards/shields/splitreus62/Kconfig.shield | 8 ++++ app/boards/shields/splitreus62/splitreus62.conf | 2 + app/boards/shields/splitreus62/splitreus62.dtsi | 50 ++++++++++++++++++++ app/boards/shields/splitreus62/splitreus62.keymap | 25 ++++++++++ .../shields/splitreus62/splitreus62_left.conf | 2 + .../shields/splitreus62/splitreus62_left.overlay | 19 ++++++++ .../shields/splitreus62/splitreus62_right.conf | 3 ++ .../shields/splitreus62/splitreus62_right.overlay | 22 +++++++++ 9 files changed, 185 insertions(+) create mode 100644 app/boards/shields/splitreus62/Kconfig.defconfig create mode 100644 app/boards/shields/splitreus62/Kconfig.shield create mode 100644 app/boards/shields/splitreus62/splitreus62.conf create mode 100644 app/boards/shields/splitreus62/splitreus62.dtsi create mode 100644 app/boards/shields/splitreus62/splitreus62.keymap create mode 100644 app/boards/shields/splitreus62/splitreus62_left.conf create mode 100644 app/boards/shields/splitreus62/splitreus62_left.overlay create mode 100644 app/boards/shields/splitreus62/splitreus62_right.conf create mode 100644 app/boards/shields/splitreus62/splitreus62_right.overlay diff --git a/app/boards/shields/splitreus62/Kconfig.defconfig b/app/boards/shields/splitreus62/Kconfig.defconfig new file mode 100644 index 0000000..c52752a --- /dev/null +++ b/app/boards/shields/splitreus62/Kconfig.defconfig @@ -0,0 +1,54 @@ + +if SHIELD_SPLITREUS62_LEFT + +config ZMK_KEYBOARD_NAME + default "Splitreus62 Left" + +endif + +if SHIELD_SPLITREUS62_RIGHT + +config ZMK_KEYBOARD_NAME + default "Splitreus62 Right" + +endif + +if SHIELD_SPLITREUS62_LEFT || SHIELD_SPLITREUS62_RIGHT + +if ZMK_DISPLAY + +config I2C + default n + +config SSD1306 + default n + +config SSD1306_REVERSE_MODE + default n + +endif # ZMK_DISPLAY + +if LVGL + +config LVGL_HOR_RES + default 128 + +config LVGL_VER_RES + default 32 + +config LVGL_VDB_SIZE + default 64 + +config LVGL_DPI + default 148 + +config LVGL_BITS_PER_PIXEL + default 1 + +choice LVGL_COLOR_DEPTH + default LVGL_COLOR_DEPTH_1 +endchoice + +endif # LVGL + +endif diff --git a/app/boards/shields/splitreus62/Kconfig.shield b/app/boards/shields/splitreus62/Kconfig.shield new file mode 100644 index 0000000..f20f236 --- /dev/null +++ b/app/boards/shields/splitreus62/Kconfig.shield @@ -0,0 +1,8 @@ +# Copyright (c) 2020 Pete Johanson +# SPDX-License-Identifier: MIT + +config SHIELD_SPLITREUS62_LEFT + def_bool $(shields_list_contains,splitreus62_left) + +config SHIELD_SPLITREUS62_RIGHT + def_bool $(shields_list_contains,splitreus62_right) diff --git a/app/boards/shields/splitreus62/splitreus62.conf b/app/boards/shields/splitreus62/splitreus62.conf new file mode 100644 index 0000000..73f0d9d --- /dev/null +++ b/app/boards/shields/splitreus62/splitreus62.conf @@ -0,0 +1,2 @@ +# Uncomment the following line to enable the Lily58 OLED Display +# CONFIG_ZMK_DISPLAY=y diff --git a/app/boards/shields/splitreus62/splitreus62.dtsi b/app/boards/shields/splitreus62/splitreus62.dtsi new file mode 100644 index 0000000..e1fb40b --- /dev/null +++ b/app/boards/shields/splitreus62/splitreus62.dtsi @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2020 Pete Johanson, Derek Schmell + * + * SPDX-License-Identifier: MIT + */ + +#include + +/ { + chosen { + zmk,kscan = &kscan0; + zmk,matrix_transform = &default_transform; + }; + + default_transform: keymap_transform_0 { + compatible = "zmk,matrix-transform"; + columns = <12>; + rows = <6>; +// | SW0 | SW5 | SW10 | SW15 | SW20 | SW25 | SW25 | SW20 | SW15 | SW10 | SW5 | SW1 | +// | SW1 | SW6 | SW11 | SW16 | SW21 | SW26 | SW26 | SW21 | SW16 | SW11 | SW6 | SW2 | +// | SW2 | SW7 | SW12 | SW17 | SW22 | SW27 | SW27 | SW22 | SW17 | SW12 | SW7 | SW3 | +// | SW3 | SW8 | SW13 | SW18 | SW23 | SW28 | SW28 | SW23 | SW18 | SW13 | SW8 | SW4 | +// | SW4 | SW9 | SW14 | SW19 | SW24 | SW29 | SW29 | SW24 | SW19 | SW14 | SW9 | SW5 | +// SW30 | SW30 + map = < +RC(0,0) RC(0,1) RC(0,2) RC(0,3) RC(0,4) RC(0,5) RC(0,6) RC(0,7) RC(0,8) RC(0,9) RC(0,10) RC(0,11) +RC(1,0) RC(1,1) RC(1,2) RC(1,3) RC(1,4) RC(1,5) RC(1,6) RC(1,7) RC(1,8) RC(1,9) RC(1,10) RC(1,11) +RC(2,0) RC(2,1) RC(2,2) RC(2,3) RC(2,4) RC(2,5) RC(2,6) RC(2,7) RC(2,8) RC(2,9) RC(2,10) RC(2,11) +RC(3,0) RC(3,1) RC(3,2) RC(3,3) RC(3,4) RC(3,5) RC(3,6) RC(3,7) RC(3,8) RC(3,9) RC(3,10) RC(3,11) +RC(4,0) RC(4,1) RC(4,2) RC(4,3) RC(4,4) RC(4,5) RC(4,6) RC(4,7) RC(4,8) RC(4,9) RC(4,10) RC(4,11) + RC(5,5) RC(5,6) + >; + }; + + kscan0: kscan { + compatible = "zmk,kscan-gpio-matrix"; + label = "KSCAN"; + + diode-direction = "row2col"; + row-gpios + = <&pro_micro_d 1 GPIO_ACTIVE_HIGH > + , <&pro_micro_d 0 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 2 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 4 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 5 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 6 GPIO_ACTIVE_HIGH> + ; + + }; +}; diff --git a/app/boards/shields/splitreus62/splitreus62.keymap b/app/boards/shields/splitreus62/splitreus62.keymap new file mode 100644 index 0000000..cd683a2 --- /dev/null +++ b/app/boards/shields/splitreus62/splitreus62.keymap @@ -0,0 +1,25 @@ +#include +#include + +/ { + keymap { + compatible = "zmk,keymap"; + + default_layer { +// ------------------------------------------------------------------------------------------------------------ +// | ESC | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | - | +// | TAB | Q | W | E | R | T | | Y | U | I | O | P | \ | +// | CTRL | A | S | D | F | G | | H | J | K | L | ; | ' | +// | SHIFT | Z | X | C | V | B | | N | M | , | . | / | SHIFT | +// | LCTL | LGUI | LALT | GRAV | | EQL | DEL | BKSP| | RET | SPC | LBKT | RBKT | LBKT | HOME | END | + bindings = < +&kp ESC &kp NUM_1 &kp NUM_2 &kp NUM_3 &kp NUM_4 &kp NUM_5 &kp NUM_6 &kp NUM_7 &kp NUM_8 &kp NUM_9 &kp NUM_0 &kp MINUS +&kp TAB &kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P &kp BSLH +&kp LCTL &kp A &kp S &kp D &kp F &kp G &kp H &kp J &kp K &kp L &kp SCLN &kp QUOT +&kp LSFT &kp Z &kp X &kp C &kp V &kp B &kp N &kp M &kp CMMA &kp DOT &kp FSLH &kp RSFT +&kp LCTL &kp LGUI &kp LALT &kp GRAV &kp EQL &kp DEL &kp SPC &kp LBKT &kp RBKT &kp MINUS &kp HOME &kp END + &kp BKSP &kp RET + >; + }; + }; +}; diff --git a/app/boards/shields/splitreus62/splitreus62_left.conf b/app/boards/shields/splitreus62/splitreus62_left.conf new file mode 100644 index 0000000..a835adc --- /dev/null +++ b/app/boards/shields/splitreus62/splitreus62_left.conf @@ -0,0 +1,2 @@ +CONFIG_ZMK_SPLIT=y +CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y \ No newline at end of file diff --git a/app/boards/shields/splitreus62/splitreus62_left.overlay b/app/boards/shields/splitreus62/splitreus62_left.overlay new file mode 100644 index 0000000..aea374a --- /dev/null +++ b/app/boards/shields/splitreus62/splitreus62_left.overlay @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2020 Pete Johanson + * + * SPDX-License-Identifier: MIT + */ + +#include "splitreus62.dtsi" + +&kscan0 { + col-gpios + = <&pro_micro_d 7 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 8 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 9 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 10 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 16 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 14 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + ; +}; + diff --git a/app/boards/shields/splitreus62/splitreus62_right.conf b/app/boards/shields/splitreus62/splitreus62_right.conf new file mode 100644 index 0000000..ab43d04 --- /dev/null +++ b/app/boards/shields/splitreus62/splitreus62_right.conf @@ -0,0 +1,3 @@ +CONFIG_ZMK_SPLIT=y +CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y +#CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y diff --git a/app/boards/shields/splitreus62/splitreus62_right.overlay b/app/boards/shields/splitreus62/splitreus62_right.overlay new file mode 100644 index 0000000..3c0f989 --- /dev/null +++ b/app/boards/shields/splitreus62/splitreus62_right.overlay @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2020 Pete Johanson + * + * SPDX-License-Identifier: MIT + */ + +#include "splitreus62.dtsi" + +&default_transform { + col-offset = <6>; +}; + +&kscan0 { + col-gpios + = <&pro_micro_d 14 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 16 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 10 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 9 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 8 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 7 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + ; +}; \ No newline at end of file -- cgit v1.2.3 From bb5eb51df743bd1c56c814c62f10d022c388df67 Mon Sep 17 00:00:00 2001 From: Derek Date: Sat, 15 Aug 2020 16:11:18 -0400 Subject: Updated comment and removed display flag --- app/boards/shields/splitreus62/splitreus62.conf | 2 -- app/boards/shields/splitreus62/splitreus62_right.conf | 3 +-- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/app/boards/shields/splitreus62/splitreus62.conf b/app/boards/shields/splitreus62/splitreus62.conf index 73f0d9d..e69de29 100644 --- a/app/boards/shields/splitreus62/splitreus62.conf +++ b/app/boards/shields/splitreus62/splitreus62.conf @@ -1,2 +0,0 @@ -# Uncomment the following line to enable the Lily58 OLED Display -# CONFIG_ZMK_DISPLAY=y diff --git a/app/boards/shields/splitreus62/splitreus62_right.conf b/app/boards/shields/splitreus62/splitreus62_right.conf index ab43d04..e51dee4 100644 --- a/app/boards/shields/splitreus62/splitreus62_right.conf +++ b/app/boards/shields/splitreus62/splitreus62_right.conf @@ -1,3 +1,2 @@ CONFIG_ZMK_SPLIT=y -CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y -#CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y +CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y \ No newline at end of file -- cgit v1.2.3 From ce7d7cd51d35bf22cf92a3765e021c10b583c587 Mon Sep 17 00:00:00 2001 From: Derek Date: Sat, 15 Aug 2020 16:21:38 -0400 Subject: Undo build.yaml changles --- .github/workflows/build.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5eb7971..a8bddf6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,6 +16,10 @@ jobs: - kyria_right - lily58_left - lily58_right +<<<<<<< HEAD + +======= +>>>>>>> parent of c3164f4... Updated build.yaml include: - board: proton_c shield: clueboard_california -- cgit v1.2.3 From 1fa993fca22860d4706364e72116ffd154d01bac Mon Sep 17 00:00:00 2001 From: Derek Date: Sat, 15 Aug 2020 16:21:54 -0400 Subject: Update app/boards/shields/splitreus62/splitreus62_right.overlay Co-authored-by: Nick Winans --- app/boards/shields/splitreus62/splitreus62_right.overlay | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/boards/shields/splitreus62/splitreus62_right.overlay b/app/boards/shields/splitreus62/splitreus62_right.overlay index 3c0f989..35375cc 100644 --- a/app/boards/shields/splitreus62/splitreus62_right.overlay +++ b/app/boards/shields/splitreus62/splitreus62_right.overlay @@ -15,8 +15,8 @@ = <&pro_micro_d 14 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> , <&pro_micro_d 16 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> , <&pro_micro_d 10 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> - , <&pro_micro_d 9 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 9 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> , <&pro_micro_d 8 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> , <&pro_micro_d 7 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> ; -}; \ No newline at end of file +}; -- cgit v1.2.3 From ba136eb9eed862aefe2cacd83f24194c62a00459 Mon Sep 17 00:00:00 2001 From: Derek Date: Sat, 15 Aug 2020 16:22:00 -0400 Subject: Update app/boards/shields/splitreus62/splitreus62_left.overlay Co-authored-by: Nick Winans --- app/boards/shields/splitreus62/splitreus62_left.overlay | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/boards/shields/splitreus62/splitreus62_left.overlay b/app/boards/shields/splitreus62/splitreus62_left.overlay index aea374a..7210ca4 100644 --- a/app/boards/shields/splitreus62/splitreus62_left.overlay +++ b/app/boards/shields/splitreus62/splitreus62_left.overlay @@ -10,10 +10,9 @@ col-gpios = <&pro_micro_d 7 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> , <&pro_micro_d 8 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> - , <&pro_micro_d 9 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 9 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> , <&pro_micro_d 10 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> , <&pro_micro_d 16 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> , <&pro_micro_d 14 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> ; }; - -- cgit v1.2.3 From ff3b1d3fa31d8dbc226ae75e601ba0a9800252b0 Mon Sep 17 00:00:00 2001 From: Derek Date: Sat, 15 Aug 2020 16:26:55 -0400 Subject: Revert "Undo build.yaml changles" This reverts commit ce7d7cd51d35bf22cf92a3765e021c10b583c587. --- .github/workflows/build.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a8bddf6..5eb7971 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,10 +16,6 @@ jobs: - kyria_right - lily58_left - lily58_right -<<<<<<< HEAD - -======= ->>>>>>> parent of c3164f4... Updated build.yaml include: - board: proton_c shield: clueboard_california -- cgit v1.2.3 From caecce62b7805e7fa3db814f2eb1616ba3661262 Mon Sep 17 00:00:00 2001 From: Derek Date: Sat, 15 Aug 2020 16:32:14 -0400 Subject: Drop OLED support. --- app/boards/shields/splitreus62/Kconfig.defconfig | 36 ------------------------ 1 file changed, 36 deletions(-) diff --git a/app/boards/shields/splitreus62/Kconfig.defconfig b/app/boards/shields/splitreus62/Kconfig.defconfig index c52752a..1f5b324 100644 --- a/app/boards/shields/splitreus62/Kconfig.defconfig +++ b/app/boards/shields/splitreus62/Kconfig.defconfig @@ -15,40 +15,4 @@ endif if SHIELD_SPLITREUS62_LEFT || SHIELD_SPLITREUS62_RIGHT -if ZMK_DISPLAY - -config I2C - default n - -config SSD1306 - default n - -config SSD1306_REVERSE_MODE - default n - -endif # ZMK_DISPLAY - -if LVGL - -config LVGL_HOR_RES - default 128 - -config LVGL_VER_RES - default 32 - -config LVGL_VDB_SIZE - default 64 - -config LVGL_DPI - default 148 - -config LVGL_BITS_PER_PIXEL - default 1 - -choice LVGL_COLOR_DEPTH - default LVGL_COLOR_DEPTH_1 -endchoice - -endif # LVGL - endif -- cgit v1.2.3 From 892394d9e6b795f3f7c60e5e4d433760b5fc64ed Mon Sep 17 00:00:00 2001 From: CrossR Date: Sun, 16 Aug 2020 12:44:18 +0100 Subject: Update to include missing encoder config. --- app/boards/shields/sofle/Kconfig.defconfig | 2 -- app/boards/shields/sofle/sofle.conf | 4 ++++ app/boards/shields/sofle/sofle.dtsi | 25 ++++++++++++++++++++++++- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/app/boards/shields/sofle/Kconfig.defconfig b/app/boards/shields/sofle/Kconfig.defconfig index 4437868..2ccf147 100644 --- a/app/boards/shields/sofle/Kconfig.defconfig +++ b/app/boards/shields/sofle/Kconfig.defconfig @@ -3,14 +3,12 @@ if SHIELD_SOFLE_LEFT config ZMK_KEYBOARD_NAME default "Sofle Left" - endif if SHIELD_SOFLE_RIGHT config ZMK_KEYBOARD_NAME default "Sofle Right" - endif if SHIELD_SOFLE_LEFT || SHIELD_SOFLE_RIGHT diff --git a/app/boards/shields/sofle/sofle.conf b/app/boards/shields/sofle/sofle.conf index 60c20dc..2194add 100644 --- a/app/boards/shields/sofle/sofle.conf +++ b/app/boards/shields/sofle/sofle.conf @@ -1,2 +1,6 @@ # Uncomment the following line to enable the Sofle OLED Display # CONFIG_ZMK_DISPLAY=y + +# Uncomment these two lines to add support for encoders +# CONFIG_EC11=y +# CONFIG_EC11_TRIGGER_GLOBAL_THREAD=y diff --git a/app/boards/shields/sofle/sofle.dtsi b/app/boards/shields/sofle/sofle.dtsi index dfa001c..cfd7a95 100644 --- a/app/boards/shields/sofle/sofle.dtsi +++ b/app/boards/shields/sofle/sofle.dtsi @@ -42,7 +42,30 @@ RC(3,0) RC(3,1) RC(3,2) RC(3,3) RC(3,4) RC(3,5) RC(3,6) RC(3,7) , <&pro_micro_d 8 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> , <&pro_micro_d 9 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> ; - + }; + + // TODO: Check these pins! + left_encoder: encoder_left { + compatible = "alps,ec11"; + label = "LEFT_ENCODER"; + a-gpios = <&pro_micro_d 9 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; + b-gpios = <&pro_micro_d 5 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; + resolution = <4>; + status = "disabled"; + }; + + right_encoder: encoder_right { + compatible = "alps,ec11"; + label = "RIGHT_ENCODER"; + a-gpios = <&pro_micro_d 5 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; + b-gpios = <&pro_micro_d 9 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; + resolution = <4>; + status = "disabled"; + }; + + sensors { + compatible = "zmk,keymap-sensors"; + sensors = <&left_encoder &right_encoder>; }; }; -- cgit v1.2.3 From 5bb01c802b792dd016b2cd091b0983806b658f43 Mon Sep 17 00:00:00 2001 From: Derek Date: Sun, 16 Aug 2020 08:49:17 -0400 Subject: Update setup.sh --- docs/static/setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/static/setup.sh b/docs/static/setup.sh index 27dcb0b..45eccd6 100644 --- a/docs/static/setup.sh +++ b/docs/static/setup.sh @@ -37,7 +37,7 @@ echo "" echo "Keyboard Shield Selection:" prompt="Pick an keyboard:" -options=("Kyria" "Lily58" "Corne") +options=("Kyria" "Lily58" "Corne" "Splitreus62") PS3="$prompt " # TODO: Add support for "Other" and linking to docs on adding custom shields in user config repos. -- cgit v1.2.3 From eff6934066e0d898c6dcf3e450d6381073d2bdef Mon Sep 17 00:00:00 2001 From: CrossR Date: Sun, 16 Aug 2020 19:15:47 +0100 Subject: Update pins. --- app/boards/shields/sofle/sofle.dtsi | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/app/boards/shields/sofle/sofle.dtsi b/app/boards/shields/sofle/sofle.dtsi index cfd7a95..4c220a2 100644 --- a/app/boards/shields/sofle/sofle.dtsi +++ b/app/boards/shields/sofle/sofle.dtsi @@ -44,22 +44,23 @@ RC(3,0) RC(3,1) RC(3,2) RC(3,3) RC(3,4) RC(3,5) RC(3,6) RC(3,7) ; }; - // TODO: Check these pins! + // TODO: Check these pins and resolution! + left_encoder: encoder_left { compatible = "alps,ec11"; label = "LEFT_ENCODER"; - a-gpios = <&pro_micro_d 9 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; - b-gpios = <&pro_micro_d 5 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; - resolution = <4>; + a-gpios = <&pro_micro_a 1 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; + b-gpios = <&pro_micro_a 3 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; + resolution = <2>; status = "disabled"; }; right_encoder: encoder_right { compatible = "alps,ec11"; label = "RIGHT_ENCODER"; - a-gpios = <&pro_micro_d 5 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; - b-gpios = <&pro_micro_d 9 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; - resolution = <4>; + a-gpios = <&pro_micro_a 3 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; + b-gpios = <&pro_micro_a 1 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; + resolution = <2>; status = "disabled"; }; -- cgit v1.2.3 From aa187a54d475b6ac6fe8c78f9365332465ed3029 Mon Sep 17 00:00:00 2001 From: CrossR Date: Wed, 19 Aug 2020 20:18:27 +0100 Subject: Fix keymap. --- app/boards/shields/sofle/sofle.dtsi | 18 +++++------ app/boards/shields/sofle/sofle.keymap | 56 +++++++++++++++++------------------ 2 files changed, 36 insertions(+), 38 deletions(-) diff --git a/app/boards/shields/sofle/sofle.dtsi b/app/boards/shields/sofle/sofle.dtsi index 4c220a2..d6f29d3 100644 --- a/app/boards/shields/sofle/sofle.dtsi +++ b/app/boards/shields/sofle/sofle.dtsi @@ -19,14 +19,14 @@ // | SW6 | SW5 | SW4 | SW3 | SW2 | SW1 | | SW1 | SW2 | SW3 | SW4 | SW5 | SW6 | // | SW12 | SW11 | SW10 | SW9 | SW8 | SW7 | | SW7 | SW8 | SW9 | SW10 | SW11 | SW12 | // | SW18 | SW17 | SW16 | SW15 | SW14 | SW13 | | SW13 | SW14 | SW15 | SW16 | SW17 | SW18 | -// | SW24 | SW23 | SW22 | SW21 | SW20 | SW19 | | SW19 | SW20 | SW21 | SW22 | SW23 | SW24 | -// | SW29 | SW28 | SW27 | SW26 | SW25 | | SW25 | SW26 | SW27 | SW28 | SW29 | +// | SW24 | SW23 | SW22 | SW21 | SW20 | SW19 | SW25 | | SW25 | SW19 | SW20 | SW21 | SW22 | SW23 | SW24 | +// | SW30 | SW29 | SW28 | SW27 | SW26 | | SW26 | SW27 | SW28 | SW29 | SW30 | map = < -RC(0,0) RC(0,1) RC(0,2) RC(0,3) RC(0,4) RC(0,5) RC(0,6) RC(0,7) RC(0,8) RC(0,9) RC(0,10) RC(0,11) -RC(1,0) RC(1,1) RC(1,2) RC(1,3) RC(1,4) RC(1,5) RC(1,6) RC(1,7) RC(1,8) RC(1,9) RC(1,10) RC(1,11) -RC(2,0) RC(2,1) RC(2,2) RC(2,3) RC(2,4) RC(2,5) RC(2,6) RC(2,7) RC(2,8) RC(2,9) RC(2,10) RC(2,11) -RC(3,0) RC(3,1) RC(3,2) RC(3,3) RC(3,4) RC(3,5) RC(3,6) RC(3,7) RC(3,8) RC(3,9) RC(3,10) RC(3,11) - RC(4,1) RC(4,2) RC(4,3) RC(4,4) RC(4,5) RC(4,9) RC(4,10) RC(4,11) RC(4,12) RC(4,13) +RC(0,0) RC(0,1) RC(0,2) RC(0,3) RC(0,4) RC(0,5) RC(0,6) RC(0,7) RC(0,8) RC(0,9) RC(0,10) RC(0,11) +RC(1,0) RC(1,1) RC(1,2) RC(1,3) RC(1,4) RC(1,5) RC(1,6) RC(1,7) RC(1,8) RC(1,9) RC(1,10) RC(1,11) +RC(2,0) RC(2,1) RC(2,2) RC(2,3) RC(2,4) RC(2,5) RC(2,6) RC(2,7) RC(2,8) RC(2,9) RC(2,10) RC(2,11) +RC(3,0) RC(3,1) RC(3,2) RC(3,3) RC(3,4) RC(3,5) RC(4,5) RC(4,6) RC(3,6) RC(3,7) RC(3,8) RC(3,9) RC(3,10) RC(3,11) + RC(4,0) RC(4,1) RC(4,2) RC(4,3) RC(4,4) RC(4,7) RC(4,8) RC(4,9) RC(4,10) RC(4,11) >; }; @@ -49,7 +49,7 @@ RC(3,0) RC(3,1) RC(3,2) RC(3,3) RC(3,4) RC(3,5) RC(3,6) RC(3,7) left_encoder: encoder_left { compatible = "alps,ec11"; label = "LEFT_ENCODER"; - a-gpios = <&pro_micro_a 1 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; + a-gpios = <&pro_micro_a 2 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; b-gpios = <&pro_micro_a 3 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; resolution = <2>; status = "disabled"; @@ -59,7 +59,7 @@ RC(3,0) RC(3,1) RC(3,2) RC(3,3) RC(3,4) RC(3,5) RC(3,6) RC(3,7) compatible = "alps,ec11"; label = "RIGHT_ENCODER"; a-gpios = <&pro_micro_a 3 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; - b-gpios = <&pro_micro_a 1 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; + b-gpios = <&pro_micro_a 2 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; resolution = <2>; status = "disabled"; }; diff --git a/app/boards/shields/sofle/sofle.keymap b/app/boards/shields/sofle/sofle.keymap index 45c20cb..02f4560 100644 --- a/app/boards/shields/sofle/sofle.keymap +++ b/app/boards/shields/sofle/sofle.keymap @@ -1,25 +1,23 @@ #include #include -//TODO: Is the encoder stuff needed on every single layer? - / { keymap { compatible = "zmk,keymap"; default_layer { // ------------------------------------------------------------------------------------------------------------ -// | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | ` | -// | ESC | Q | W | E | R | T | | Y | U | I | O | P | Bkspc | -// | CTRL | A | S | D | F | G | | H | J | K | L | ; | ' | -// | SHIFT | Z | X | C | V | B | | N | M | , | . | / | SHIFT | +// | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | | +// | ESC | Q | W | E | R | T | | Y | U | I | O | P | BKSPC | +// | TAB | A | S | D | F | G | | H | J | K | L | ; | ' | +// | SHIFT | Z | X | C | V | B | MUTE | | | N | M | , | . | / | SHIFT | // | GUI | ALT | CTRL | LOWER| ENTER | | SPACE | RAISE| CTRL | ALT | GUI | bindings = < -&kp GRAV &kp NUM_1 &kp NUM_2 &kp NUM_3 &kp NUM_4 &kp NUM_5 &kp NUM_6 &kp NUM_7 &kp NUM_8 &kp NUM_9 &kp NUM_0 &kp GRAV -&kp ESC &kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P &kp BKSP -&kp LCTL &kp A &kp S &kp D &kp F &kp G &kp H &kp J &kp K &kp L &kp SCLN &kp QUOT -&kp LSFT &kp Z &kp X &kp C &kp V &kp B &kp N &kp M &kp CMMA &kp DOT &kp FSLH &kp RSFT - &kp LGUI &kp LALT &kp LCTL &mo 1 &kp RET &kp SPC &mo 2 &kp RCTL &kp RALT &kp RGUI +&kp GRAV &kp NUM_1 &kp NUM_2 &kp NUM_3 &kp NUM_4 &kp NUM_5 &kp NUM_6 &kp NUM_7 &kp NUM_8 &kp NUM_9 &kp NUM_0 &none +&kp ESC &kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P &kp BKSP +&kp TAB &kp A &kp S &kp D &kp F &kp G &kp H &kp J &kp K &kp L &kp SCLN &kp QUOT +&kp LSFT &kp Z &kp X &kp C &kp V &kp B &kp M_MUTE &none &kp N &kp M &kp CMMA &kp DOT &kp FSLH &kp RSFT + &kp LGUI &kp LALT &kp LCTL &mo 1 &kp RET &kp SPC &mo 2 &kp RCTL &kp RALT &kp RGUI >; sensor-bindings = <&inc_dec_cp M_VOLU M_VOLD &inc_dec_kp PGUP PGDN>; @@ -28,16 +26,16 @@ lower_layer { // ------------------------------------------------------------------------------------------------------------ // | | F1 | F2 | F3 | F4 | F5 | | F6 | F7 | F8 | F9 | F10 | F11 | -// | | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | F12 | -// | TAB | ! | @ | # | $ | % | | ^ | & | * | ( | ) | | | -// | | = | - | + | { | } | | [ | ] | ; | : | \ | | +// | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | F12 | +// | | ! | @ | # | $ | % | | ^ | & | * | ( | ) | | | +// | | = | - | + | { | } | | | | [ | ] | ; | : | \ | | // | | | | | | | | | | | | bindings = < -&trans &kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &kp F6 &kp F7 &kp F8 &kp F9 &kp F10 &kp F11 -&trans &kp 1 &kp 2 &kp 3 &kp 4 &kp 5 &kp 6 &kp 7 &kp 8 &kp 9 &kp 0 &kp F12 -&kp TAB &kp BANG &kp ATSN &kp HASH &kp CURU &kp PRCT &kp CRRT &kp AMPS &kp KMLT &kp LPRN &kp RPRN &kp PIPE -&trans &kp EQL &kp MINUS &kp KPLS &kp LCUR &kp RCUR &kp LBKT &kp RKBT &kp SCLN &kp COLN &kp BSLH &trans - &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans +&trans &kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &kp F6 &kp F7 &kp F8 &kp F9 &kp F10 &kp F11 +&kp GRAV &kp 1 &kp 2 &kp 3 &kp 4 &kp 5 &kp 6 &kp 7 &kp 8 &kp 9 &kp 0 &kp F12 +&trans &kp BANG &kp ATSN &kp HASH &kp CURU &kp PRCT &kp CRRT &kp AMPS &kp KMLT &kp LPRN &kp RPRN &kp PIPE +&trans &kp EQL &kp MINUS &kp KPLS &kp LCUR &kp RCUR &trans &trans &kp LBKT &kp RKBT &kp SCLN &kp COLN &kp BSLH &trans + &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans >; sensor-bindings = <&inc_dec_cp M_VOLU M_VOLD &inc_dec_kp PGUP PGDN>; @@ -45,17 +43,17 @@ raise_layer { // ------------------------------------------------------------------------------------------------------------ -// | | | | | | | | | | | | | | -// | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | | -// | F1 | F2 | F3 | F4 | F5 | F6 | | | <- | ^ | v | -> | | -// | F7 | F8 | F9 | F10 | F11 | F12 | | + | - | = | [ | ] | \ | -// | | | | | | | | | | | | +// | | | | | | | | | | | | | | +// | | INS | PSCR | GUI | | | | PGUP | | ^ | | | | +// | | ALT | CTRL | SHIFT | | CAPS | | PGDN | <- | v | -> | DEL | BKSPC | +// | | UNDO | CUT | COPY | PASTE | | | | | | | | | | | +// | | | | | | | | | | | | bindings = < -&trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans -&kp GRAV &kp NUM_1 &kp NUM_2 &kp NUM_3 &kp NUM_4 &kp NUM_5 &kp NUM_6 &kp NUM_7 &kp NUM_8 &kp NUM_9 &kp NUM_0 &trans -&kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &kp F6 &trans &kp LARW &kp UARW &kp DARW & RARW &trans -&kp F7 &kp F8 &kp F9 &kp F10 &kp F11 &kp F12 &kp KPLS &kp MINUS &kp EQL &kp LBKT &kp RBKT &kp BSLH - &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans +&trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans +&trans &kp INS &kp PRSC &kp GUI &trans &trans &kp PGUP &trans &kp UARW &trans &kp NUM_0 &trans +&trans &kp LALT &kp LCTL &kp LSFT &trans &kp CLCK &kp PGDN &kp LARW &kp DARW &kp RARW &kp DEL &kp BKSP +&trans &kp 0x7A &kp 0x7B &kp 0x7C &kp 0x7D &trans &trans &trans &trans &trans &trans &trans &trans &trans + &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans >; }; -- cgit v1.2.3 From dcd36f12e049ee2c423204ebaaa3c16062d9fd5e Mon Sep 17 00:00:00 2001 From: CrossR Date: Wed, 19 Aug 2020 20:53:22 +0100 Subject: Add BT clear bind. Should check the positions are correct. --- app/boards/shields/sofle/sofle.dtsi | 122 ++++++++++++++------------- app/boards/shields/sofle/sofle_left.conf | 3 +- app/boards/shields/sofle/sofle_left.overlay | 3 + app/boards/shields/sofle/sofle_right.conf | 1 + app/boards/shields/sofle/sofle_right.overlay | 4 + 5 files changed, 72 insertions(+), 61 deletions(-) diff --git a/app/boards/shields/sofle/sofle.dtsi b/app/boards/shields/sofle/sofle.dtsi index d6f29d3..1a5ea84 100644 --- a/app/boards/shields/sofle/sofle.dtsi +++ b/app/boards/shields/sofle/sofle.dtsi @@ -7,85 +7,87 @@ #include / { - chosen { - zmk,kscan = &kscan0; - zmk,matrix_transform = &default_transform; - }; + chosen { + zmk,kscan = &kscan0; + zmk,matrix_transform = &default_transform; + }; - default_transform: keymap_transform_0 { - compatible = "zmk,matrix-transform"; - columns = <16>; - rows = <4>; + default_transform: keymap_transform_0 { + compatible = "zmk,matrix-transform"; + columns = <16>; + rows = <4>; // | SW6 | SW5 | SW4 | SW3 | SW2 | SW1 | | SW1 | SW2 | SW3 | SW4 | SW5 | SW6 | // | SW12 | SW11 | SW10 | SW9 | SW8 | SW7 | | SW7 | SW8 | SW9 | SW10 | SW11 | SW12 | // | SW18 | SW17 | SW16 | SW15 | SW14 | SW13 | | SW13 | SW14 | SW15 | SW16 | SW17 | SW18 | // | SW24 | SW23 | SW22 | SW21 | SW20 | SW19 | SW25 | | SW25 | SW19 | SW20 | SW21 | SW22 | SW23 | SW24 | // | SW30 | SW29 | SW28 | SW27 | SW26 | | SW26 | SW27 | SW28 | SW29 | SW30 | - map = < + map = < RC(0,0) RC(0,1) RC(0,2) RC(0,3) RC(0,4) RC(0,5) RC(0,6) RC(0,7) RC(0,8) RC(0,9) RC(0,10) RC(0,11) RC(1,0) RC(1,1) RC(1,2) RC(1,3) RC(1,4) RC(1,5) RC(1,6) RC(1,7) RC(1,8) RC(1,9) RC(1,10) RC(1,11) RC(2,0) RC(2,1) RC(2,2) RC(2,3) RC(2,4) RC(2,5) RC(2,6) RC(2,7) RC(2,8) RC(2,9) RC(2,10) RC(2,11) RC(3,0) RC(3,1) RC(3,2) RC(3,3) RC(3,4) RC(3,5) RC(4,5) RC(4,6) RC(3,6) RC(3,7) RC(3,8) RC(3,9) RC(3,10) RC(3,11) RC(4,0) RC(4,1) RC(4,2) RC(4,3) RC(4,4) RC(4,7) RC(4,8) RC(4,9) RC(4,10) RC(4,11) - >; - }; + >; + }; - kscan0: kscan { - compatible = "zmk,kscan-gpio-matrix"; - label = "KSCAN"; + kscan0: kscan { + compatible = "zmk,kscan-gpio-matrix"; + label = "KSCAN"; - diode-direction = "col2row"; - row-gpios - = <&pro_micro_d 5 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> - , <&pro_micro_d 6 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> - , <&pro_micro_d 7 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> - , <&pro_micro_d 8 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> - , <&pro_micro_d 9 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> - ; - }; + diode-direction = "col2row"; + row-gpios + = <&pro_micro_d 5 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 6 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 7 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 8 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 9 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + ; + }; - // TODO: Check these pins and resolution! + left_encoder: encoder_left { + compatible = "alps,ec11"; + label = "LEFT_ENCODER"; + a-gpios = <&pro_micro_a 2 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; + b-gpios = <&pro_micro_a 3 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; + resolution = <2>; + status = "disabled"; + }; - left_encoder: encoder_left { - compatible = "alps,ec11"; - label = "LEFT_ENCODER"; - a-gpios = <&pro_micro_a 2 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; - b-gpios = <&pro_micro_a 3 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; - resolution = <2>; - status = "disabled"; - }; + right_encoder: encoder_right { + compatible = "alps,ec11"; + label = "RIGHT_ENCODER"; + a-gpios = <&pro_micro_a 3 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; + b-gpios = <&pro_micro_a 2 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; + resolution = <2>; + status = "disabled"; + }; - right_encoder: encoder_right { - compatible = "alps,ec11"; - label = "RIGHT_ENCODER"; - a-gpios = <&pro_micro_a 3 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; - b-gpios = <&pro_micro_a 2 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; - resolution = <2>; - status = "disabled"; - }; + sensors { + compatible = "zmk,keymap-sensors"; + sensors = <&left_encoder &right_encoder>; + }; - sensors { - compatible = "zmk,keymap-sensors"; - sensors = <&left_encoder &right_encoder>; - }; + bt_unpair_combo: bt_unpair_combo { + compatible = "zmk,bt-unpair-combo"; + }; }; &pro_micro_i2c { - status = "okay"; + status = "okay"; - ssd1306@3c { - compatible = "solomon,ssd1306fb"; - reg = <0x3c>; - label = "DISPLAY"; - width = <128>; - height = <32>; - segment-offset = <0>; - page-offset = <0>; - display-offset = <0>; - multiplex-ratio = <31>; - segment-remap; - com-invdir; - com-sequential; - prechargep = <0x22>; - }; + ssd1306@3c { + compatible = "solomon,ssd1306fb"; + reg = <0x3c>; + label = "DISPLAY"; + width = <128>; + height = <32>; + segment-offset = <0>; + page-offset = <0>; + display-offset = <0>; + multiplex-ratio = <31>; + segment-remap; + com-invdir; + com-sequential; + prechargep = <0x22>; + }; }; diff --git a/app/boards/shields/sofle/sofle_left.conf b/app/boards/shields/sofle/sofle_left.conf index e51dee4..d2d1e3c 100644 --- a/app/boards/shields/sofle/sofle_left.conf +++ b/app/boards/shields/sofle/sofle_left.conf @@ -1,2 +1,3 @@ CONFIG_ZMK_SPLIT=y -CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y \ No newline at end of file +CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y +CONFIG_ZMK_BLE_UNPAIR_COMBO=y diff --git a/app/boards/shields/sofle/sofle_left.overlay b/app/boards/shields/sofle/sofle_left.overlay index bcfb558..f6719dd 100644 --- a/app/boards/shields/sofle/sofle_left.overlay +++ b/app/boards/shields/sofle/sofle_left.overlay @@ -21,3 +21,6 @@ status = "okay"; }; +&bt_unpair_combo { + key-positions = <0 52>; +}; diff --git a/app/boards/shields/sofle/sofle_right.conf b/app/boards/shields/sofle/sofle_right.conf index 990cf7c..cf16779 100644 --- a/app/boards/shields/sofle/sofle_right.conf +++ b/app/boards/shields/sofle/sofle_right.conf @@ -1,2 +1,3 @@ CONFIG_ZMK_SPLIT=y CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y +CONFIG_ZMK_BLE_UNPAIR_COMBO=y diff --git a/app/boards/shields/sofle/sofle_right.overlay b/app/boards/shields/sofle/sofle_right.overlay index 133f926..ee1a606 100644 --- a/app/boards/shields/sofle/sofle_right.overlay +++ b/app/boards/shields/sofle/sofle_right.overlay @@ -24,3 +24,7 @@ &right_encoder { status = "okay"; }; + +&bt_unpair_combo { + key-positions = <11 55>; +}; -- cgit v1.2.3 From 0d7bf03158b6c49c6db65732dd086820bc4fc64b Mon Sep 17 00:00:00 2001 From: CrossR Date: Wed, 19 Aug 2020 21:52:31 +0100 Subject: Fix BT unpair combo. --- app/boards/shields/sofle/sofle_left.overlay | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/boards/shields/sofle/sofle_left.overlay b/app/boards/shields/sofle/sofle_left.overlay index f6719dd..9dfe52d 100644 --- a/app/boards/shields/sofle/sofle_left.overlay +++ b/app/boards/shields/sofle/sofle_left.overlay @@ -22,5 +22,5 @@ }; &bt_unpair_combo { - key-positions = <0 52>; + key-positions = <0 54>; }; -- cgit v1.2.3 From a65b746a863bbd8e07cf404b4249526f75b069a3 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Wed, 19 Aug 2020 23:34:34 -0400 Subject: fix(bluetooth): Add unpair combo if DT node exists --- app/CMakeLists.txt | 2 +- app/Kconfig | 6 ------ app/boards/shields/corne/corne_left.conf | 1 - app/boards/shields/corne/corne_right.conf | 1 - app/boards/shields/kyria/kyria_left.conf | 3 +-- app/boards/shields/kyria/kyria_right.conf | 1 - app/boards/shields/lily58/lily58_left.conf | 1 - app/boards/shields/lily58/lily58_right.conf | 1 - app/src/ble_unpair_combo.c | 7 +++++-- 9 files changed, 7 insertions(+), 16 deletions(-) diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 054f84a..de67dfe 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -44,7 +44,7 @@ target_sources(app PRIVATE src/behaviors/behavior_none.c) target_sources(app PRIVATE src/behaviors/behavior_sensor_rotate_key_press.c) target_sources_ifdef(CONFIG_ZMK_RGB_UNDERGLOW app PRIVATE src/behaviors/behavior_rgb_underglow.c) target_sources_ifdef(CONFIG_ZMK_BLE app PRIVATE src/ble.c) -target_sources_ifdef(CONFIG_ZMK_BLE_UNPAIR_COMBO app PRIVATE src/ble_unpair_combo.c) +target_sources_ifdef(CONFIG_ZMK_BLE app PRIVATE src/ble_unpair_combo.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) diff --git a/app/Kconfig b/app/Kconfig index 416c985..5f618b1 100644 --- a/app/Kconfig +++ b/app/Kconfig @@ -45,12 +45,6 @@ menuconfig ZMK_BLE if ZMK_BLE -config ZMK_BLE_UNPAIR_COMBO - bool "Enable BT unpair combo" - help - Adds a magic key combo that can be held on startup to remove all paired devices - default n - config ZMK_BLE_INIT_PRIORITY int "Init Priority" default 50 diff --git a/app/boards/shields/corne/corne_left.conf b/app/boards/shields/corne/corne_left.conf index 338fa59..1e028a7 100644 --- a/app/boards/shields/corne/corne_left.conf +++ b/app/boards/shields/corne/corne_left.conf @@ -1,3 +1,2 @@ CONFIG_ZMK_SPLIT=y CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y -CONFIG_ZMK_BLE_UNPAIR_COMBO=y \ No newline at end of file diff --git a/app/boards/shields/corne/corne_right.conf b/app/boards/shields/corne/corne_right.conf index be344c4..990cf7c 100644 --- a/app/boards/shields/corne/corne_right.conf +++ b/app/boards/shields/corne/corne_right.conf @@ -1,3 +1,2 @@ CONFIG_ZMK_SPLIT=y CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y -CONFIG_ZMK_BLE_UNPAIR_COMBO=y \ No newline at end of file diff --git a/app/boards/shields/kyria/kyria_left.conf b/app/boards/shields/kyria/kyria_left.conf index 338fa59..e51dee4 100644 --- a/app/boards/shields/kyria/kyria_left.conf +++ b/app/boards/shields/kyria/kyria_left.conf @@ -1,3 +1,2 @@ CONFIG_ZMK_SPLIT=y -CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y -CONFIG_ZMK_BLE_UNPAIR_COMBO=y \ No newline at end of file +CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y \ No newline at end of file diff --git a/app/boards/shields/kyria/kyria_right.conf b/app/boards/shields/kyria/kyria_right.conf index be344c4..990cf7c 100644 --- a/app/boards/shields/kyria/kyria_right.conf +++ b/app/boards/shields/kyria/kyria_right.conf @@ -1,3 +1,2 @@ CONFIG_ZMK_SPLIT=y CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y -CONFIG_ZMK_BLE_UNPAIR_COMBO=y \ No newline at end of file diff --git a/app/boards/shields/lily58/lily58_left.conf b/app/boards/shields/lily58/lily58_left.conf index 338fa59..1e028a7 100644 --- a/app/boards/shields/lily58/lily58_left.conf +++ b/app/boards/shields/lily58/lily58_left.conf @@ -1,3 +1,2 @@ CONFIG_ZMK_SPLIT=y CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y -CONFIG_ZMK_BLE_UNPAIR_COMBO=y \ No newline at end of file diff --git a/app/boards/shields/lily58/lily58_right.conf b/app/boards/shields/lily58/lily58_right.conf index cf16779..990cf7c 100644 --- a/app/boards/shields/lily58/lily58_right.conf +++ b/app/boards/shields/lily58/lily58_right.conf @@ -1,3 +1,2 @@ CONFIG_ZMK_SPLIT=y CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y -CONFIG_ZMK_BLE_UNPAIR_COMBO=y diff --git a/app/src/ble_unpair_combo.c b/app/src/ble_unpair_combo.c index a33a8e2..f9d0551 100644 --- a/app/src/ble_unpair_combo.c +++ b/app/src/ble_unpair_combo.c @@ -7,10 +7,11 @@ #include #include -#include - #define DT_DRV_COMPAT zmk_bt_unpair_combo +#if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) + +#include LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); #include @@ -78,3 +79,5 @@ ZMK_SUBSCRIPTION(zmk_ble_unpair_combo, position_state_changed); SYS_INIT(zmk_ble_unpair_combo_init, APPLICATION, CONFIG_APPLICATION_INIT_PRIORITY); + +#endif DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) -- cgit v1.2.3 From 6ca8e673ac494b836ef692f11e90e8b8b6f28528 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Thu, 20 Aug 2020 00:01:59 -0400 Subject: fix(bluetooth): Typo for closed conditional. --- app/src/ble_unpair_combo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/ble_unpair_combo.c b/app/src/ble_unpair_combo.c index f9d0551..82fa834 100644 --- a/app/src/ble_unpair_combo.c +++ b/app/src/ble_unpair_combo.c @@ -80,4 +80,4 @@ SYS_INIT(zmk_ble_unpair_combo_init, APPLICATION, CONFIG_APPLICATION_INIT_PRIORITY); -#endif DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) +#endif /* DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) */ -- cgit v1.2.3 From 11e3566277eac787f00ad479dc8a9eeffcfd1504 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Thu, 20 Aug 2020 00:11:07 -0400 Subject: fix(docs): Link to 2.3.0 docs, macOS toolchain fix * Link explicitly to the 2.3.0 docs from upstream Zephyr. * Update the macOS toolchain section to properly refer to the 3rd party toolchain setup. --- docs/docs/dev-setup.md | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/docs/docs/dev-setup.md b/docs/docs/dev-setup.md index 5cceb73..6e893b3 100644 --- a/docs/docs/dev-setup.md +++ b/docs/docs/dev-setup.md @@ -180,7 +180,7 @@ brew install cmake ninja python3 ccache dtc git wget ### West Build Command -`west` is the [Zephyrâ„¢ meta-tool](https://docs.zephyrproject.org/latest/guides/west/index.html) used to configure and build Zephyrâ„¢ applications. +`west` is the [Zephyrâ„¢ meta-tool](https://docs.zephyrproject.org/2.3.0/guides/west/index.html) used to configure and build Zephyrâ„¢ applications. West can be installed by using the `pip` python package manager. @@ -223,7 +223,7 @@ The installation will prompt with several questions about installation location, Because Raspberry OS (Raspbian) runs on the same architecture (but different ABI) as the keyboard MCUs, -the operating system's installed [cross compilers](https://docs.zephyrproject.org/latest/getting_started/toolchain_other_x_compilers.html) can be used to target the different ABI. +the operating system's installed [cross compilers](https://docs.zephyrproject.org/2.3.0/getting_started/toolchain_other_x_compilers.html) can be used to target the different ABI. First, the cross compiler should be installed: @@ -259,23 +259,20 @@ The installation will prompt with several questions about installation location, #### GNU ARM Embedded -Since the Zephyrâ„¢ SDK is not available for Windows, we recommending following the steps to install the [GNU ARM Embedded](https://docs.zephyrproject.org/latest/getting_started/toolchain_3rd_party_x_compilers.html#gnu-arm-embedded). +Since the Zephyrâ„¢ SDK is not available for Windows, we recommending following the steps to install the [GNU ARM Embedded](https://docs.zephyrproject.org/2.3.0/getting_started/toolchain_3rd_party_x_compilers.html#gnu-arm-embedded). -#### Zephyrâ„¢ ARM SDK +#### GNU ARM Embedded -To build firmwares for the ARM architecture (all supported MCUs/keyboards at this point), you'll need to install the Zephyrâ„¢ ARM SDK to your system: +Since the Zephyrâ„¢ SDK is not available for macOS, we recommending following the steps to install the [GNU ARM Embedded](https://docs.zephyrproject.org/2.3.0/getting_started/toolchain_3rd_party_x_compilers.html#gnu-arm-embedded). -``` -export ZSDK_VERSION=0.11.2 -wget -q "https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v${ZSDK_VERSION}/zephyr-toolchain-arm-${ZSDK_VERSION}-setup.run" && \ - sh "zephyr-toolchain-arm-${ZSDK_VERSION}-setup.run" --quiet -- -d ~/.local/zephyr-sdk-${ZSDK_VERSION} && \ - rm "zephyr-toolchain-arm-\${ZSDK_VERSION}-setup.run" -``` +:::warning Security Controls Workaround -The installation will prompt with several questions about installation location, and creating a default `~/.zephyrrc` for you with various variables. The defaults should normally work as expected. +Please be sure to read the [additional setup instructions](https://docs.zephyrproject.org/2.3.0/getting_started/installation_mac.html#mac-gatekeeper) needed to address security controls found in macOS 10.15 Catalina and newer + +::: @@ -342,7 +339,7 @@ pip3 install --user -r zephyr/scripts/requirements-base.txt ### Environment Variables By default, the Zephyrâ„¢ SDK will create a file named `~/.zephyrrc` with the correct environment variables to build ZMK. -We suggest two main [options](https://docs.zephyrproject.org/latest/guides/env_vars.html?highlight=zephyrrc) for how to load those settings. +We suggest two main [options](https://docs.zephyrproject.org/2.3.0/guides/env_vars.html?highlight=zephyrrc) for how to load those settings. #### Per Shell @@ -442,7 +439,7 @@ an onboard MCU, or one that uses a MCU board addon. ### Keyboard (Shield) + MCU Board -ZMK treats keyboards that take a MCU addon board as [shields](https://docs.zephyrproject.org/latest/guides/porting/shields.html), and treats the smaller MCU board as the true [board](https://docs.zephyrproject.org/latest/guides/porting/board_porting.html) +ZMK treats keyboards that take a MCU addon board as [shields](https://docs.zephyrproject.org/2.3.0/guides/porting/shields.html), and treats the smaller MCU board as the true [board](https://docs.zephyrproject.org/2.3.0/guides/porting/board_porting.html) Given the following: @@ -458,7 +455,7 @@ west build -b proton_c -- -DSHIELD=kyria_left -DKEYMAP=default ### Keyboard With Onboard MCU -Keyboards with onboard MCU chips are simply treated as the [board](https://docs.zephyrproject.org/latest/guides/porting/board_porting.html) as far as Zephyrâ„¢ is concerned. +Keyboards with onboard MCU chips are simply treated as the [board](https://docs.zephyrproject.org/2.3.0/guides/porting/board_porting.html) as far as Zephyrâ„¢ is concerned. Given the following: -- cgit v1.2.3 From 4efce4223ae38306a254b11db628d782f1d7f382 Mon Sep 17 00:00:00 2001 From: Mega Mind <68985133+megamind4089@users.noreply.github.com> Date: Thu, 20 Aug 2020 18:59:41 +0800 Subject: Use correct macro for board --- app/CMakeLists.txt | 2 +- app/boards/arm/nrfmicro/pinmux.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index de67dfe..9fce3b6 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -1,4 +1,3 @@ -# Find Zephyr. This also loads Zephyr's build system. cmake_minimum_required(VERSION 3.13.1) set(CONFIG_APPLICATION_DEFINED_SYSCALL true) @@ -15,6 +14,7 @@ list(APPEND SYSCALL_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/drivers/zephyr) include(cmake/zmk_config.cmake) +# Find Zephyr. This also loads Zephyr's build system. find_package(Zephyr REQUIRED HINTS ../zephyr) project(zmk) diff --git a/app/boards/arm/nrfmicro/pinmux.c b/app/boards/arm/nrfmicro/pinmux.c index 803d20d..c02ca92 100644 --- a/app/boards/arm/nrfmicro/pinmux.c +++ b/app/boards/arm/nrfmicro/pinmux.c @@ -17,7 +17,7 @@ static int pinmux_nrfmicro_init(struct device *port) struct device *p1 = device_get_binding("GPIO_1"); -#if defined(BOARD_NRFMICRO_13) +#if CONFIG_BOARD_NRFMICRO_13 struct device *p0 = device_get_binding("GPIO_0"); // enable EXT_VCC (use 0 for nRFMicro 1.3, use 1 for nRFMicro 1.1) gpio_pin_configure(p1, 9, GPIO_OUTPUT); @@ -34,4 +34,4 @@ static int pinmux_nrfmicro_init(struct device *port) return 0; } -SYS_INIT(pinmux_nrfmicro_init, APPLICATION, CONFIG_APPLICATION_INIT_PRIORITY); \ No newline at end of file +SYS_INIT(pinmux_nrfmicro_init, APPLICATION, CONFIG_APPLICATION_INIT_PRIORITY); -- cgit v1.2.3 From fb3dadba8721b4e63d1284b90c3380b7897b2f50 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Thu, 20 Aug 2020 07:39:14 -0400 Subject: fix(bluetooth): disable BT_SETTINGS for now. --- app/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Kconfig b/app/Kconfig index 5f618b1..00d4ae3 100644 --- a/app/Kconfig +++ b/app/Kconfig @@ -41,7 +41,7 @@ menuconfig ZMK_BLE select BT_GATT_DIS select BT_GATT_BAS select SETTINGS - select BT_SETTINGS + # select BT_SETTINGS if ZMK_BLE -- cgit v1.2.3 From 973087639329893e916d3d341ee4326d1c14a711 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Thu, 20 Aug 2020 10:51:35 -0400 Subject: fix(shields): Load Kconfig for out-of-tree shields --- app/Kconfig | 4 ++++ app/cmake/zmk_config.cmake | 1 + 2 files changed, 5 insertions(+) diff --git a/app/Kconfig b/app/Kconfig index 00d4ae3..877fce4 100644 --- a/app/Kconfig +++ b/app/Kconfig @@ -193,6 +193,10 @@ source "subsys/logging/Kconfig.template.log_config" rsource "boards/Kconfig" rsource "boards/shields/*/Kconfig.defconfig" +rsource "boards/shields/*/Kconfig.shield" + +osource "$(ZMK_CONFIG)/boards/shields/*/Kconfig.defconfig" +osource "$(ZMK_CONFIG)/boards/shields/*/Kconfig.shield" source "Kconfig.zephyr" diff --git a/app/cmake/zmk_config.cmake b/app/cmake/zmk_config.cmake index 518c3c3..017dd11 100644 --- a/app/cmake/zmk_config.cmake +++ b/app/cmake/zmk_config.cmake @@ -44,6 +44,7 @@ endif() set(CACHED_ZMK_CONFIG ${ZMK_CONFIG} CACHE STRING "Selected user ZMK config") if (ZMK_CONFIG) + set(ENV{ZMK_CONFIG} "${ZMK_CONFIG}") if(EXISTS ${ZMK_CONFIG}/boards) message(STATUS "Adding ZMK config directory as board root: ${ZMK_CONFIG}") list(APPEND BOARD_ROOT ${ZMK_CONFIG}) -- cgit v1.2.3 From 8aae2231e242a1c8b9daf8fba96cc9bc5ba336a2 Mon Sep 17 00:00:00 2001 From: Nick Date: Thu, 20 Aug 2020 13:43:03 -0500 Subject: fix(actions): timeout stuck cache west modules --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0f0e74a..85397a4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,6 +25,7 @@ jobs: - name: Checkout uses: actions/checkout@v2 - name: Cache west modules + timeout-minutes: 2 uses: actions/cache@v2 env: cache-name: cache-zephyr-modules -- cgit v1.2.3 From dc1bb3663962acb08fadb6920d4983dafc0c91e6 Mon Sep 17 00:00:00 2001 From: Nick Date: Thu, 20 Aug 2020 13:54:58 -0500 Subject: fix(actions): continue build on failed west cache --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 85397a4..5086bf8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -26,6 +26,7 @@ jobs: uses: actions/checkout@v2 - name: Cache west modules timeout-minutes: 2 + continue-on-error: true uses: actions/cache@v2 env: cache-name: cache-zephyr-modules -- cgit v1.2.3 From 7aea57328c1f48e95de2013843e8947c1eb0e752 Mon Sep 17 00:00:00 2001 From: Mega Mind <68985133+megamind4089@users.noreply.github.com> Date: Fri, 21 Aug 2020 03:12:06 +0800 Subject: Add KConfig for board battery charger --- app/boards/arm/nrfmicro/Kconfig | 5 +++++ app/boards/arm/nrfmicro/Kconfig.defconfig | 9 ++++++++- app/boards/arm/nrfmicro/pinmux.c | 6 +++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/app/boards/arm/nrfmicro/Kconfig b/app/boards/arm/nrfmicro/Kconfig index 17a3347..80039e9 100644 --- a/app/boards/arm/nrfmicro/Kconfig +++ b/app/boards/arm/nrfmicro/Kconfig @@ -3,3 +3,8 @@ config BOARD_ENABLE_DCDC select SOC_DCDC_NRF52X default y depends on (BOARD_NRFMICRO_11 || BOARD_NRFMICRO_11_FLIPPED || BOARD_NRFMICRO_13) + +config BOARD_ENABLE_CHARGER + bool "Enable battery charger" + default y + depends on (BOARD_NRFMICRO_13) diff --git a/app/boards/arm/nrfmicro/Kconfig.defconfig b/app/boards/arm/nrfmicro/Kconfig.defconfig index 2212277..69b59ee 100644 --- a/app/boards/arm/nrfmicro/Kconfig.defconfig +++ b/app/boards/arm/nrfmicro/Kconfig.defconfig @@ -29,5 +29,12 @@ config ZMK_USB config PINMUX default y - + +if BOARD_NRFMICRO_13 + +config BOARD_ENABLE_CHARGER + default y + +endif # BOARD_NRFMICRO_13 + endif # BOARD_NRFMICRO_11 || BOARD_NRFMICRO_11_FLIPPED || BOARD_NRFMICRO_13 diff --git a/app/boards/arm/nrfmicro/pinmux.c b/app/boards/arm/nrfmicro/pinmux.c index c02ca92..be1a4de 100644 --- a/app/boards/arm/nrfmicro/pinmux.c +++ b/app/boards/arm/nrfmicro/pinmux.c @@ -23,9 +23,13 @@ static int pinmux_nrfmicro_init(struct device *port) gpio_pin_configure(p1, 9, GPIO_OUTPUT); gpio_pin_set(p1, 9, 0); - // enable charger (nRFMicro 1.3 only) +#if CONFIG_BOARD_ENABLE_CHARGER gpio_pin_configure(p0, 5, GPIO_OUTPUT); gpio_pin_set(p0, 5, 0); +#else + gpio_pin_configure(p0, 5, GPIO_INPUT); +#endif + #else // enable EXT_VCC (use 0 for nRFMicro 1.3, use 1 for nRFMicro 1.1) gpio_pin_configure(p1, 9, GPIO_OUTPUT); -- cgit v1.2.3 From 94c7d27f04263b42669ae6d1777765ba811ed6bf Mon Sep 17 00:00:00 2001 From: Derek Date: Thu, 20 Aug 2020 15:13:51 -0400 Subject: Updated files as per request Updated --- app/boards/shields/splitreus62/Kconfig.defconfig | 7 ++++++- app/boards/shields/splitreus62/Kconfig.shield | 2 +- app/boards/shields/splitreus62/splitreus62.dtsi | 2 +- app/boards/shields/splitreus62/splitreus62.keymap | 6 ++++++ app/boards/shields/splitreus62/splitreus62_left.overlay | 2 +- app/boards/shields/splitreus62/splitreus62_right.overlay | 4 ++-- docs/static/setup.sh | 1 + 7 files changed, 18 insertions(+), 6 deletions(-) diff --git a/app/boards/shields/splitreus62/Kconfig.defconfig b/app/boards/shields/splitreus62/Kconfig.defconfig index 1f5b324..6e35b06 100644 --- a/app/boards/shields/splitreus62/Kconfig.defconfig +++ b/app/boards/shields/splitreus62/Kconfig.defconfig @@ -1,4 +1,9 @@ - +/* + * Copyright (c) 2020 Derek Schmell + * + * SPDX-License-Identifier: MIT + */ + if SHIELD_SPLITREUS62_LEFT config ZMK_KEYBOARD_NAME diff --git a/app/boards/shields/splitreus62/Kconfig.shield b/app/boards/shields/splitreus62/Kconfig.shield index f20f236..762d991 100644 --- a/app/boards/shields/splitreus62/Kconfig.shield +++ b/app/boards/shields/splitreus62/Kconfig.shield @@ -1,4 +1,4 @@ -# Copyright (c) 2020 Pete Johanson +# Copyright (c) 2020 Derek Schmell # SPDX-License-Identifier: MIT config SHIELD_SPLITREUS62_LEFT diff --git a/app/boards/shields/splitreus62/splitreus62.dtsi b/app/boards/shields/splitreus62/splitreus62.dtsi index e1fb40b..c2bfbc4 100644 --- a/app/boards/shields/splitreus62/splitreus62.dtsi +++ b/app/boards/shields/splitreus62/splitreus62.dtsi @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Pete Johanson, Derek Schmell + * Copyright (c) 2020 Derek Schmell * * SPDX-License-Identifier: MIT */ diff --git a/app/boards/shields/splitreus62/splitreus62.keymap b/app/boards/shields/splitreus62/splitreus62.keymap index cd683a2..920e61a 100644 --- a/app/boards/shields/splitreus62/splitreus62.keymap +++ b/app/boards/shields/splitreus62/splitreus62.keymap @@ -1,3 +1,9 @@ +/* + * Copyright (c) 2020 Derek Schmell + * + * SPDX-License-Identifier: MIT + */ + #include #include diff --git a/app/boards/shields/splitreus62/splitreus62_left.overlay b/app/boards/shields/splitreus62/splitreus62_left.overlay index 7210ca4..b156d60 100644 --- a/app/boards/shields/splitreus62/splitreus62_left.overlay +++ b/app/boards/shields/splitreus62/splitreus62_left.overlay @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Pete Johanson + * Copyright (c) 2020 Derek Schmell * * SPDX-License-Identifier: MIT */ diff --git a/app/boards/shields/splitreus62/splitreus62_right.overlay b/app/boards/shields/splitreus62/splitreus62_right.overlay index 35375cc..5db87cc 100644 --- a/app/boards/shields/splitreus62/splitreus62_right.overlay +++ b/app/boards/shields/splitreus62/splitreus62_right.overlay @@ -1,9 +1,9 @@ /* - * Copyright (c) 2020 Pete Johanson + * Copyright (c) 2020 Derek Schmell * * SPDX-License-Identifier: MIT */ - + #include "splitreus62.dtsi" &default_transform { diff --git a/docs/static/setup.sh b/docs/static/setup.sh index 45eccd6..e75b529 100644 --- a/docs/static/setup.sh +++ b/docs/static/setup.sh @@ -49,6 +49,7 @@ select opt in "${options[@]}" "Quit"; do 1 ) shield_title="Kyria" shield="kyria"; split="y"; break;; 2 ) shield_title="Lily58" shield="lily58"; split="y"; break;; 3 ) shield_title="Corne" shield="corne"; split="y"; break;; + 4 ) shield_title="Splitreus62" shield="splitreus62"; split="y"; break;; # Add link to docs on adding your own custom shield in your ZMK config! # $(( ${#options[@]}+1 )) ) echo "Other!"; break;; -- cgit v1.2.3 From 3b71c4311bae62c2e14b028324f831837742d1f5 Mon Sep 17 00:00:00 2001 From: Derek Date: Thu, 20 Aug 2020 17:27:41 -0400 Subject: Update Kconfig.defconfig --- app/boards/shields/splitreus62/Kconfig.defconfig | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app/boards/shields/splitreus62/Kconfig.defconfig b/app/boards/shields/splitreus62/Kconfig.defconfig index 6e35b06..a2464a7 100644 --- a/app/boards/shields/splitreus62/Kconfig.defconfig +++ b/app/boards/shields/splitreus62/Kconfig.defconfig @@ -1,8 +1,7 @@ -/* - * Copyright (c) 2020 Derek Schmell - * - * SPDX-License-Identifier: MIT - */ + +#Copyright (c) 2020 Derek Schmell +#SPDX-License-Identifier: MIT + if SHIELD_SPLITREUS62_LEFT -- cgit v1.2.3 From f3361e79ceb03167d9e239582162ba2c5d66fb5a Mon Sep 17 00:00:00 2001 From: tjcampie Date: Thu, 20 Aug 2020 20:22:55 -0500 Subject: Add QAZ to zmk --- app/boards/shields/qaz/Kconfig.defconfig | 6 +++++ app/boards/shields/qaz/Kconfig.shield | 2 ++ app/boards/shields/qaz/qaz.keymap | 19 +++++++++++++ app/boards/shields/qaz/qaz.overlay | 46 ++++++++++++++++++++++++++++++++ 4 files changed, 73 insertions(+) create mode 100644 app/boards/shields/qaz/Kconfig.defconfig create mode 100644 app/boards/shields/qaz/Kconfig.shield create mode 100644 app/boards/shields/qaz/qaz.keymap create mode 100644 app/boards/shields/qaz/qaz.overlay diff --git a/app/boards/shields/qaz/Kconfig.defconfig b/app/boards/shields/qaz/Kconfig.defconfig new file mode 100644 index 0000000..148a630 --- /dev/null +++ b/app/boards/shields/qaz/Kconfig.defconfig @@ -0,0 +1,6 @@ +if SHIELD_QAZ + +config ZMK_KEYBOARD_NAME + default "QAZ_zmk" + +endif \ No newline at end of file diff --git a/app/boards/shields/qaz/Kconfig.shield b/app/boards/shields/qaz/Kconfig.shield new file mode 100644 index 0000000..c365539 --- /dev/null +++ b/app/boards/shields/qaz/Kconfig.shield @@ -0,0 +1,2 @@ +config SHIELD_MY_BOARD + def_bool $(shields_list_contains,qaz) \ No newline at end of file diff --git a/app/boards/shields/qaz/qaz.keymap b/app/boards/shields/qaz/qaz.keymap new file mode 100644 index 0000000..b83bb47 --- /dev/null +++ b/app/boards/shields/qaz/qaz.keymap @@ -0,0 +1,19 @@ +#include +#include + +/ { + keymap { + compatible = "zmk,keymap"; + + default_layer { + + bindings = < + &kp Q &kp W &kp F &kp P &kp G &kp J &kp L &kp U &kp Y &kp QUOT + &mt MOD_LGUI A &mt MOD_LALT R &mt MOD_LCTL S &mt MOD_LSFT T &kp D &kp H &mt MOD_RSFT N &mt MOD_RCTL E &mt MOD_RALT I &mt MOD_RGUI O + &kp Z &kp X &kp C &kp V &kp B &kp K &kp M &kp CMMA &kp DOT + &kp LGUI &kp LALT &kp LCTL &kp BKSP &kp SPC &kp RET &kp TAB &kp FSLH + >; + + }; + }; +}; diff --git a/app/boards/shields/qaz/qaz.overlay b/app/boards/shields/qaz/qaz.overlay new file mode 100644 index 0000000..75c4d1d --- /dev/null +++ b/app/boards/shields/qaz/qaz.overlay @@ -0,0 +1,46 @@ +#include + +/ { + chosen { + zmk,kscan = &kscan0; + zmk,matrix_transform = &default_transform; + }; + + default_transform: keymap_transform_0 { + compatible = "zmk,matrix-transform"; + columns = <7>; + rows = <6>; + map = < + RC(0,0) RC(0,1) RC(0,2) RC(0,3) RC(0,4) RC(0,5) RC(0,6) RC(4,0) RC(4,1) RC(4,2) + RC(1,0) RC(1,1) RC(1,2) RC(1,3) RC(1,4) RC(1,5) RC(1,6) RC(5,0) RC(5,1) RC(5,2) + RC(2,0) RC(2,1) RC(2,2) RC(2,3) RC(2,4) RC(2,5) RC(2,6) RC(4,3) RC(5,3) + RC(3,0) RC(3,1) RC(3,2) RC(3,3) RC(3,4) RC(3,5) RC(3,6) RC(4,4) + >; + }; + + + kscan0: kscan_0 { + compatible = "zmk,kscan-gpio-matrix"; + label = "KSCAN"; + diode-direction = "col2row"; + + col-gpios + = <&pro_micro_d 8 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 1 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 0 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 2 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 9 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 1 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 6 GPIO_ACTIVE_HIGH> + ; + + row-gpios + = <&pro_micro_a 3 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 4 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 5 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 7 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 2 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 3 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + ; + }; +}; \ No newline at end of file -- cgit v1.2.3 From 1ff13676f7fbab5c0d69317be0d186709a7872c8 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Fri, 21 Aug 2020 00:31:28 -0400 Subject: fix(docs): Better behavior sidebar label/titles. --- docs/docs/behavior/key-press.md | 3 ++- docs/docs/behavior/layers.md | 8 +++++--- docs/docs/behavior/lighting.md | 11 ++++++----- docs/docs/behavior/misc.md | 3 ++- docs/docs/behavior/mod-tap.md | 3 ++- 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/docs/docs/behavior/key-press.md b/docs/docs/behavior/key-press.md index 1ae7e31..2edce1d 100644 --- a/docs/docs/behavior/key-press.md +++ b/docs/docs/behavior/key-press.md @@ -1,5 +1,6 @@ --- -title: Key Presses +title: Key Press Behaviors +sidebar_label: Key Press --- ## Summary diff --git a/docs/docs/behavior/layers.md b/docs/docs/behavior/layers.md index 3e520ca..da7f07f 100644 --- a/docs/docs/behavior/layers.md +++ b/docs/docs/behavior/layers.md @@ -1,5 +1,6 @@ --- -title: Layers +title: Layer Behaviors +sidebar_label: Layers --- ## Summary @@ -56,12 +57,13 @@ Example: ``` "Toggle layer" for a : + ``` #define DEFAULT 0 #define NAVI 1 #define NONE 0 - + / { keymap { compatible = "zmk,keymap"; @@ -89,4 +91,4 @@ Example: }; ``` -It is possible to use "toggle layer" to have keys that raise and lower the layers as well. \ No newline at end of file +It is possible to use "toggle layer" to have keys that raise and lower the layers as well. diff --git a/docs/docs/behavior/lighting.md b/docs/docs/behavior/lighting.md index 432960e..2d4f532 100644 --- a/docs/docs/behavior/lighting.md +++ b/docs/docs/behavior/lighting.md @@ -1,15 +1,16 @@ --- -title: Lighting +title: Lighting Behavior +sidebar_label: Lighting --- ## Summary -Lighting is often used for either aesthetics or for the practical purposes of lighting up keys in the dark. +Lighting is often used for either aesthetics or for the practical purposes of lighting up keys in the dark. Currently ZMK supports RGB underglow, which can be changed and configured using its behavior. ## RGB Action Defines -RGB actions defines are provided through the [`dt-bindings/zmk/rgb.h`](https://github.com/zmkfirmware/zmk/blob/main/app/include/dt-bindings/zmk/rgb.h) header, +RGB actions defines are provided through the [`dt-bindings/zmk/rgb.h`](https://github.com/zmkfirmware/zmk/blob/main/app/include/dt-bindings/zmk/rgb.h) header, which is added at the top of the keymap file: ``` @@ -21,7 +22,7 @@ This will allow you to reference the actions defined in this header such as `RGB Here is a table describing the action for each define: | Define | Action | -|-----------|-----------------------------------------------------------| +| --------- | --------------------------------------------------------- | | `RGB_TOG` | Toggles the RGB feature on and off | | `RGB_HUI` | Increases the hue of the RGB feature | | `RGB_HUD` | Decreases the hue of the RGB feature | @@ -47,4 +48,4 @@ Example: ``` &rgb_ug RGB_TOG -``` \ No newline at end of file +``` diff --git a/docs/docs/behavior/misc.md b/docs/docs/behavior/misc.md index 799c91c..446ba33 100644 --- a/docs/docs/behavior/misc.md +++ b/docs/docs/behavior/misc.md @@ -1,5 +1,6 @@ --- -title: Miscellaneous +title: Miscellaneous Behaviors +sidebar_label: Miscellaneous --- ## Summary diff --git a/docs/docs/behavior/mod-tap.md b/docs/docs/behavior/mod-tap.md index cae667e..08e9b65 100644 --- a/docs/docs/behavior/mod-tap.md +++ b/docs/docs/behavior/mod-tap.md @@ -1,5 +1,6 @@ --- -title: Mod-Tap +title: Mod-Tap Behavior +sidebar_label: Mod-Tap --- ## Summary -- cgit v1.2.3 From 5b76179bf6db93717cde0c4da39b5421a0c5bad3 Mon Sep 17 00:00:00 2001 From: tjcampie Date: Fri, 21 Aug 2020 06:31:08 -0500 Subject: Accidentally added these to main branch. --- app/boards/shields/qaz/Kconfig.defconfig | 6 ----- app/boards/shields/qaz/Kconfig.shield | 2 -- app/boards/shields/qaz/qaz.keymap | 19 ------------- app/boards/shields/qaz/qaz.overlay | 46 -------------------------------- 4 files changed, 73 deletions(-) delete mode 100644 app/boards/shields/qaz/Kconfig.defconfig delete mode 100644 app/boards/shields/qaz/Kconfig.shield delete mode 100644 app/boards/shields/qaz/qaz.keymap delete mode 100644 app/boards/shields/qaz/qaz.overlay diff --git a/app/boards/shields/qaz/Kconfig.defconfig b/app/boards/shields/qaz/Kconfig.defconfig deleted file mode 100644 index 148a630..0000000 --- a/app/boards/shields/qaz/Kconfig.defconfig +++ /dev/null @@ -1,6 +0,0 @@ -if SHIELD_QAZ - -config ZMK_KEYBOARD_NAME - default "QAZ_zmk" - -endif \ No newline at end of file diff --git a/app/boards/shields/qaz/Kconfig.shield b/app/boards/shields/qaz/Kconfig.shield deleted file mode 100644 index c365539..0000000 --- a/app/boards/shields/qaz/Kconfig.shield +++ /dev/null @@ -1,2 +0,0 @@ -config SHIELD_MY_BOARD - def_bool $(shields_list_contains,qaz) \ No newline at end of file diff --git a/app/boards/shields/qaz/qaz.keymap b/app/boards/shields/qaz/qaz.keymap deleted file mode 100644 index b83bb47..0000000 --- a/app/boards/shields/qaz/qaz.keymap +++ /dev/null @@ -1,19 +0,0 @@ -#include -#include - -/ { - keymap { - compatible = "zmk,keymap"; - - default_layer { - - bindings = < - &kp Q &kp W &kp F &kp P &kp G &kp J &kp L &kp U &kp Y &kp QUOT - &mt MOD_LGUI A &mt MOD_LALT R &mt MOD_LCTL S &mt MOD_LSFT T &kp D &kp H &mt MOD_RSFT N &mt MOD_RCTL E &mt MOD_RALT I &mt MOD_RGUI O - &kp Z &kp X &kp C &kp V &kp B &kp K &kp M &kp CMMA &kp DOT - &kp LGUI &kp LALT &kp LCTL &kp BKSP &kp SPC &kp RET &kp TAB &kp FSLH - >; - - }; - }; -}; diff --git a/app/boards/shields/qaz/qaz.overlay b/app/boards/shields/qaz/qaz.overlay deleted file mode 100644 index 75c4d1d..0000000 --- a/app/boards/shields/qaz/qaz.overlay +++ /dev/null @@ -1,46 +0,0 @@ -#include - -/ { - chosen { - zmk,kscan = &kscan0; - zmk,matrix_transform = &default_transform; - }; - - default_transform: keymap_transform_0 { - compatible = "zmk,matrix-transform"; - columns = <7>; - rows = <6>; - map = < - RC(0,0) RC(0,1) RC(0,2) RC(0,3) RC(0,4) RC(0,5) RC(0,6) RC(4,0) RC(4,1) RC(4,2) - RC(1,0) RC(1,1) RC(1,2) RC(1,3) RC(1,4) RC(1,5) RC(1,6) RC(5,0) RC(5,1) RC(5,2) - RC(2,0) RC(2,1) RC(2,2) RC(2,3) RC(2,4) RC(2,5) RC(2,6) RC(4,3) RC(5,3) - RC(3,0) RC(3,1) RC(3,2) RC(3,3) RC(3,4) RC(3,5) RC(3,6) RC(4,4) - >; - }; - - - kscan0: kscan_0 { - compatible = "zmk,kscan-gpio-matrix"; - label = "KSCAN"; - diode-direction = "col2row"; - - col-gpios - = <&pro_micro_d 8 GPIO_ACTIVE_HIGH> - , <&pro_micro_d 1 GPIO_ACTIVE_HIGH> - , <&pro_micro_d 0 GPIO_ACTIVE_HIGH> - , <&pro_micro_a 2 GPIO_ACTIVE_HIGH> - , <&pro_micro_d 9 GPIO_ACTIVE_HIGH> - , <&pro_micro_a 1 GPIO_ACTIVE_HIGH> - , <&pro_micro_d 6 GPIO_ACTIVE_HIGH> - ; - - row-gpios - = <&pro_micro_a 3 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> - , <&pro_micro_d 4 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> - , <&pro_micro_d 5 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> - , <&pro_micro_d 7 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> - , <&pro_micro_d 2 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> - , <&pro_micro_d 3 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> - ; - }; -}; \ No newline at end of file -- cgit v1.2.3 From 805ea770053269278fe0ed443b68f600021d82d1 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Fri, 21 Aug 2020 00:33:48 -0400 Subject: feat(behaviors): Add `&bootloader` behavior. * Allow reset behavior to have a type property. * Add `bootloader` node that triggers DFU UF2 bootloader mode using the AdaFruit nrf52 bootloader. --- app/dts/behaviors/reset.dtsi | 9 +++++ app/dts/bindings/behaviors/zmk,behavior-reset.yaml | 5 +++ app/include/dt-bindings/zmk/reset.h | 12 ++++++ app/src/behaviors/behavior_reset.c | 29 +++++++++------ docs/docs/behavior/reset.md | 43 ++++++++++++++++++++++ docs/sidebars.js | 1 + 6 files changed, 87 insertions(+), 12 deletions(-) create mode 100644 app/include/dt-bindings/zmk/reset.h create mode 100644 docs/docs/behavior/reset.md diff --git a/app/dts/behaviors/reset.dtsi b/app/dts/behaviors/reset.dtsi index 4e3b444..fc4fa14 100644 --- a/app/dts/behaviors/reset.dtsi +++ b/app/dts/behaviors/reset.dtsi @@ -1,3 +1,5 @@ +#include + / { behaviors { reset: behavior_reset { @@ -5,5 +7,12 @@ label = "RESET"; #binding-cells = <0>; }; + + bootloader: behavior_reset_dfu { + compatible = "zmk,behavior-reset"; + label = "BOOTLOADER_RESET"; + type = ; + #binding-cells = <0>; + }; }; }; diff --git a/app/dts/bindings/behaviors/zmk,behavior-reset.yaml b/app/dts/bindings/behaviors/zmk,behavior-reset.yaml index c8e5e6f..061b15e 100644 --- a/app/dts/bindings/behaviors/zmk,behavior-reset.yaml +++ b/app/dts/bindings/behaviors/zmk,behavior-reset.yaml @@ -6,3 +6,8 @@ description: Keyboard Reset Behavior compatible: "zmk,behavior-reset" include: zero_param.yaml + +properties: + type: + type: int + default: 0 diff --git a/app/include/dt-bindings/zmk/reset.h b/app/include/dt-bindings/zmk/reset.h new file mode 100644 index 0000000..b513649 --- /dev/null +++ b/app/include/dt-bindings/zmk/reset.h @@ -0,0 +1,12 @@ +/* + * Copyright (c) 2020 Peter Johanson + * + * SPDX-License-Identifier: MIT + */ + +#define RST_WARM 0x00 +#define RST_COLD 0x01 + +// AdaFruit nrf52 Bootloader Specific. See https://github.com/adafruit/Adafruit_nRF52_Bootloader/blob/d6b28e66053eea467166f44875e3c7ec741cb471/src/main.c#L107 + +#define RST_UF2 0x57 \ No newline at end of file diff --git a/app/src/behaviors/behavior_reset.c b/app/src/behaviors/behavior_reset.c index 44cbc21..30a96ea 100644 --- a/app/src/behaviors/behavior_reset.c +++ b/app/src/behaviors/behavior_reset.c @@ -13,8 +13,9 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); -struct behavior_reset_config { }; -struct behavior_reset_data { }; +struct behavior_reset_config { + int type; +}; static int behavior_reset_init(struct device *dev) { @@ -23,9 +24,11 @@ static int behavior_reset_init(struct device *dev) static int on_keymap_binding_pressed(struct device *dev, u32_t position, u32_t _param1, u32_t _param2) { + const struct behavior_reset_config *cfg = dev->config_info; + // TODO: Correct magic code for going into DFU? // See https://github.com/adafruit/Adafruit_nRF52_Bootloader/blob/d6b28e66053eea467166f44875e3c7ec741cb471/src/main.c#L107 - sys_reboot(0); + sys_reboot(cfg->type); return 0; } @@ -34,12 +37,14 @@ static const struct behavior_driver_api behavior_reset_driver_api = { }; -static const struct behavior_reset_config behavior_reset_config = {}; - -static struct behavior_reset_data behavior_reset_data; - -DEVICE_AND_API_INIT(behavior_reset, DT_INST_LABEL(0), behavior_reset_init, - &behavior_reset_data, - &behavior_reset_config, - APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, - &behavior_reset_driver_api); \ No newline at end of file +#define RST_INST(n) \ + static const struct behavior_reset_config behavior_reset_config_##n = { \ + .type = DT_INST_PROP(n, type) \ + }; \ + DEVICE_AND_API_INIT(behavior_reset_##n, DT_INST_LABEL(n), behavior_reset_init, \ + NULL, \ + &behavior_reset_config_##n, \ + APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, \ + &behavior_reset_driver_api); + +DT_INST_FOREACH_STATUS_OKAY(RST_INST) \ No newline at end of file diff --git a/docs/docs/behavior/reset.md b/docs/docs/behavior/reset.md new file mode 100644 index 0000000..8cf122b --- /dev/null +++ b/docs/docs/behavior/reset.md @@ -0,0 +1,43 @@ +--- +title: Reset Behaviors +sidebar_label: Reset +--- + +## Summary + +There are two available behaviors that can be used to trigger a reset of the keyboard. +The first is a soft reset, that will simply reset and re-run the currently flashed +firmware; the second when triggered will reset into the bootloader, allowing you to +flash a new firmware to the keyboard. + +## Reset + +The basic reset behavior will reset the keyboard and re-run the firmware flashed +to the device + +### Behavior Binding + +- Reference: `&reset` +- Parameters: None + +Example: + +``` +&reset +``` + +## Bootloader Reset + +The bootloader reset behavior will reset the keyboard and put it into bootloader mode, allowing +you to flash a new firmware. + +### Behavior Binding + +- Reference: `&bootloader` +- Parameters: None + +Example: + +``` +&bootloader +``` diff --git a/docs/sidebars.js b/docs/sidebars.js index 8c7c97f..51313fc 100644 --- a/docs/sidebars.js +++ b/docs/sidebars.js @@ -12,6 +12,7 @@ module.exports = { "behavior/layers", "behavior/misc", "behavior/mod-tap", + "behavior/reset", "behavior/lighting", ], Development: [ -- cgit v1.2.3 From d4e8312db6766b8fb4c8b76e14a4be9225d918a7 Mon Sep 17 00:00:00 2001 From: CrossR Date: Fri, 21 Aug 2020 17:08:43 +0100 Subject: Mute is a consumer keypress. --- app/boards/shields/sofle/sofle.keymap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/boards/shields/sofle/sofle.keymap b/app/boards/shields/sofle/sofle.keymap index 02f4560..1d7dab0 100644 --- a/app/boards/shields/sofle/sofle.keymap +++ b/app/boards/shields/sofle/sofle.keymap @@ -16,7 +16,7 @@ &kp GRAV &kp NUM_1 &kp NUM_2 &kp NUM_3 &kp NUM_4 &kp NUM_5 &kp NUM_6 &kp NUM_7 &kp NUM_8 &kp NUM_9 &kp NUM_0 &none &kp ESC &kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P &kp BKSP &kp TAB &kp A &kp S &kp D &kp F &kp G &kp H &kp J &kp K &kp L &kp SCLN &kp QUOT -&kp LSFT &kp Z &kp X &kp C &kp V &kp B &kp M_MUTE &none &kp N &kp M &kp CMMA &kp DOT &kp FSLH &kp RSFT +&kp LSFT &kp Z &kp X &kp C &kp V &kp B &cp M_MUTE &none &kp N &kp M &kp CMMA &kp DOT &kp FSLH &kp RSFT &kp LGUI &kp LALT &kp LCTL &mo 1 &kp RET &kp SPC &mo 2 &kp RCTL &kp RALT &kp RGUI >; -- cgit v1.2.3 From 5c29259fedc4a0265064afc0bc141e6bf33425f2 Mon Sep 17 00:00:00 2001 From: CrossR Date: Fri, 21 Aug 2020 17:10:29 +0100 Subject: Remove unpair combo config option. --- app/boards/shields/sofle/sofle_left.conf | 1 - app/boards/shields/sofle/sofle_right.conf | 1 - 2 files changed, 2 deletions(-) diff --git a/app/boards/shields/sofle/sofle_left.conf b/app/boards/shields/sofle/sofle_left.conf index d2d1e3c..1e028a7 100644 --- a/app/boards/shields/sofle/sofle_left.conf +++ b/app/boards/shields/sofle/sofle_left.conf @@ -1,3 +1,2 @@ CONFIG_ZMK_SPLIT=y CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y -CONFIG_ZMK_BLE_UNPAIR_COMBO=y diff --git a/app/boards/shields/sofle/sofle_right.conf b/app/boards/shields/sofle/sofle_right.conf index cf16779..990cf7c 100644 --- a/app/boards/shields/sofle/sofle_right.conf +++ b/app/boards/shields/sofle/sofle_right.conf @@ -1,3 +1,2 @@ CONFIG_ZMK_SPLIT=y CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y -CONFIG_ZMK_BLE_UNPAIR_COMBO=y -- cgit v1.2.3 From d848034c81ff3dea95a6ca98c0b05c76971647eb Mon Sep 17 00:00:00 2001 From: CrossR Date: Fri, 21 Aug 2020 22:15:27 +0100 Subject: Add keycodes properly. --- app/boards/shields/sofle/sofle.keymap | 2 +- app/include/dt-bindings/zmk/keys.h | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/boards/shields/sofle/sofle.keymap b/app/boards/shields/sofle/sofle.keymap index 1d7dab0..f3b276b 100644 --- a/app/boards/shields/sofle/sofle.keymap +++ b/app/boards/shields/sofle/sofle.keymap @@ -52,7 +52,7 @@ &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &kp INS &kp PRSC &kp GUI &trans &trans &kp PGUP &trans &kp UARW &trans &kp NUM_0 &trans &trans &kp LALT &kp LCTL &kp LSFT &trans &kp CLCK &kp PGDN &kp LARW &kp DARW &kp RARW &kp DEL &kp BKSP -&trans &kp 0x7A &kp 0x7B &kp 0x7C &kp 0x7D &trans &trans &trans &trans &trans &trans &trans &trans &trans +&trans &kp UNDO &kp CUT &kp COPY &kp PSTE &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans >; }; diff --git a/app/include/dt-bindings/zmk/keys.h b/app/include/dt-bindings/zmk/keys.h index 0a52857..cd9261d 100644 --- a/app/include/dt-bindings/zmk/keys.h +++ b/app/include/dt-bindings/zmk/keys.h @@ -92,6 +92,11 @@ #define GUI 0x65 +#define UNDO 0x7A +#define CUT 0x7B +#define COPY 0x7C +#define PSTE 0x7D + #define CURU 0xB4 #define LPRN 0xB6 -- cgit v1.2.3 From 39fd98236763bd325059ec0d775bad08babcd332 Mon Sep 17 00:00:00 2001 From: Derek Date: Fri, 21 Aug 2020 17:29:18 -0400 Subject: Swap central back to left hand --- app/boards/shields/splitreus62/splitreus62_left.conf | 2 +- app/boards/shields/splitreus62/splitreus62_right.conf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/boards/shields/splitreus62/splitreus62_left.conf b/app/boards/shields/splitreus62/splitreus62_left.conf index a835adc..e51dee4 100644 --- a/app/boards/shields/splitreus62/splitreus62_left.conf +++ b/app/boards/shields/splitreus62/splitreus62_left.conf @@ -1,2 +1,2 @@ CONFIG_ZMK_SPLIT=y -CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y \ No newline at end of file +CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y \ No newline at end of file diff --git a/app/boards/shields/splitreus62/splitreus62_right.conf b/app/boards/shields/splitreus62/splitreus62_right.conf index e51dee4..a835adc 100644 --- a/app/boards/shields/splitreus62/splitreus62_right.conf +++ b/app/boards/shields/splitreus62/splitreus62_right.conf @@ -1,2 +1,2 @@ CONFIG_ZMK_SPLIT=y -CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y \ No newline at end of file +CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y \ No newline at end of file -- cgit v1.2.3 From 796b2dddd98cceae8b6243e61b7c1869929ede8a Mon Sep 17 00:00:00 2001 From: CrossR Date: Fri, 21 Aug 2020 22:41:57 +0100 Subject: Remove erroneous key. --- app/boards/shields/sofle/sofle.keymap | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/boards/shields/sofle/sofle.keymap b/app/boards/shields/sofle/sofle.keymap index f3b276b..b3bf74e 100644 --- a/app/boards/shields/sofle/sofle.keymap +++ b/app/boards/shields/sofle/sofle.keymap @@ -35,7 +35,7 @@ &kp GRAV &kp 1 &kp 2 &kp 3 &kp 4 &kp 5 &kp 6 &kp 7 &kp 8 &kp 9 &kp 0 &kp F12 &trans &kp BANG &kp ATSN &kp HASH &kp CURU &kp PRCT &kp CRRT &kp AMPS &kp KMLT &kp LPRN &kp RPRN &kp PIPE &trans &kp EQL &kp MINUS &kp KPLS &kp LCUR &kp RCUR &trans &trans &kp LBKT &kp RKBT &kp SCLN &kp COLN &kp BSLH &trans - &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans + &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans >; sensor-bindings = <&inc_dec_cp M_VOLU M_VOLD &inc_dec_kp PGUP PGDN>; @@ -55,8 +55,8 @@ &trans &kp UNDO &kp CUT &kp COPY &kp PSTE &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans >; - }; sensor-bindings = <&inc_dec_cp M_VOLU M_VOLD &inc_dec_kp PGUP PGDN>; + }; }; }; -- cgit v1.2.3 From c84516bfcfa7e578bd7d30ab6426550b6834ab2d Mon Sep 17 00:00:00 2001 From: CrossR Date: Sat, 22 Aug 2020 09:51:01 +0100 Subject: Fix PR issues. --- app/boards/shields/sofle/Kconfig.shield | 2 +- app/boards/shields/sofle/sofle.dtsi | 2 +- app/boards/shields/sofle/sofle.keymap | 11 ++++++----- app/boards/shields/sofle/sofle_left.overlay | 2 +- app/boards/shields/sofle/sofle_right.overlay | 2 +- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/app/boards/shields/sofle/Kconfig.shield b/app/boards/shields/sofle/Kconfig.shield index d8d5d75..e23a97a 100644 --- a/app/boards/shields/sofle/Kconfig.shield +++ b/app/boards/shields/sofle/Kconfig.shield @@ -1,4 +1,4 @@ -# Copyright (c) 2020 Pete Johanson +# Copyright (c) 2020 Ryan Cross # SPDX-License-Identifier: MIT config SHIELD_SOFLE_LEFT diff --git a/app/boards/shields/sofle/sofle.dtsi b/app/boards/shields/sofle/sofle.dtsi index 1a5ea84..9b3d3c0 100644 --- a/app/boards/shields/sofle/sofle.dtsi +++ b/app/boards/shields/sofle/sofle.dtsi @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Pete Johanson + * Copyright (c) 2020 Pete Johanson, Ryan Cross * * SPDX-License-Identifier: MIT */ diff --git a/app/boards/shields/sofle/sofle.keymap b/app/boards/shields/sofle/sofle.keymap index b3bf74e..aadffa1 100644 --- a/app/boards/shields/sofle/sofle.keymap +++ b/app/boards/shields/sofle/sofle.keymap @@ -24,6 +24,7 @@ }; lower_layer { +// TODO: Some binds are waiting for shifted keycode support. // ------------------------------------------------------------------------------------------------------------ // | | F1 | F2 | F3 | F4 | F5 | | F6 | F7 | F8 | F9 | F10 | F11 | // | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | F12 | @@ -31,11 +32,11 @@ // | | = | - | + | { | } | | | | [ | ] | ; | : | \ | | // | | | | | | | | | | | | bindings = < -&trans &kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &kp F6 &kp F7 &kp F8 &kp F9 &kp F10 &kp F11 -&kp GRAV &kp 1 &kp 2 &kp 3 &kp 4 &kp 5 &kp 6 &kp 7 &kp 8 &kp 9 &kp 0 &kp F12 -&trans &kp BANG &kp ATSN &kp HASH &kp CURU &kp PRCT &kp CRRT &kp AMPS &kp KMLT &kp LPRN &kp RPRN &kp PIPE -&trans &kp EQL &kp MINUS &kp KPLS &kp LCUR &kp RCUR &trans &trans &kp LBKT &kp RKBT &kp SCLN &kp COLN &kp BSLH &trans - &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans +&trans &kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &kp F6 &kp F7 &kp F8 &kp F9 &kp F10 &kp F11 +&kp GRAV &kp NUM_1 &kp NUM_2 &kp NUM_3 &kp NUM_4 &kp NUM_5 &kp NUM_6 &kp NUM_7 &kp NUM_8 &kp NUM_9 &kp NUM_0 &kp F12 +&trans &kp BANG &kp ATSN &kp HASH &kp CURU &kp PRCT &kp CRRT &kp AMPS &kp KMLT &kp LPRN &kp RPRN &kp PIPE +&trans &kp EQL &kp MINUS &kp KPLS &kp LCUR &kp RCUR &trans &trans &kp LBKT &kp RBKT &kp SCLN &kp COLN &kp BSLH &trans + &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans >; sensor-bindings = <&inc_dec_cp M_VOLU M_VOLD &inc_dec_kp PGUP PGDN>; diff --git a/app/boards/shields/sofle/sofle_left.overlay b/app/boards/shields/sofle/sofle_left.overlay index 9dfe52d..0dfb753 100644 --- a/app/boards/shields/sofle/sofle_left.overlay +++ b/app/boards/shields/sofle/sofle_left.overlay @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Pete Johanson + * Copyright (c) 2020 Ryan Cross * * SPDX-License-Identifier: MIT */ diff --git a/app/boards/shields/sofle/sofle_right.overlay b/app/boards/shields/sofle/sofle_right.overlay index ee1a606..8eaf076 100644 --- a/app/boards/shields/sofle/sofle_right.overlay +++ b/app/boards/shields/sofle/sofle_right.overlay @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Pete Johanson + * Copyright (c) 2020 Ryan Cross * * SPDX-License-Identifier: MIT */ -- cgit v1.2.3 From 0c255aee84155405741ba8fa0c81c6d711106033 Mon Sep 17 00:00:00 2001 From: crd Date: Sat, 22 Aug 2020 09:29:23 -0700 Subject: [docs] Add bzip to deps --- docs/docs/dev-setup.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/docs/dev-setup.md b/docs/docs/dev-setup.md index 6e893b3..fae0aa0 100644 --- a/docs/docs/dev-setup.md +++ b/docs/docs/dev-setup.md @@ -52,6 +52,7 @@ sudo apt install -y \ autoconf \ automake \ build-essential \ + bzip2 \ ccache \ device-tree-compiler \ dfu-util \ @@ -91,6 +92,7 @@ sudo apt install -y \ autoconf \ automake \ build-essential \ + bzip2 \ ccache \ device-tree-compiler \ dfu-util \ @@ -130,6 +132,7 @@ sudo dnf install -y \ wget \ autoconf \ automake \ + bzip2 \ ccache \ dtc \ dfu-util \ -- cgit v1.2.3 From a0a4b8a2f5abf9e393c1d35e794b2c2e8c0e7abc Mon Sep 17 00:00:00 2001 From: Richard Jones Date: Sat, 22 Aug 2020 21:47:29 +0100 Subject: Romac (#1) * New shield: romac 2.1 --- app/boards/shields/romac/Kconfig.defconfig | 8 ++++ app/boards/shields/romac/Kconfig.shield | 5 +++ app/boards/shields/romac/boards/nice_nano.overlay | 10 +++++ app/boards/shields/romac/romac.conf | 2 + app/boards/shields/romac/romac.dtsi | 50 +++++++++++++++++++++++ app/boards/shields/romac/romac.keymap | 40 ++++++++++++++++++ app/boards/shields/romac/romac.overlay | 19 +++++++++ 7 files changed, 134 insertions(+) create mode 100644 app/boards/shields/romac/Kconfig.defconfig create mode 100644 app/boards/shields/romac/Kconfig.shield create mode 100644 app/boards/shields/romac/boards/nice_nano.overlay create mode 100644 app/boards/shields/romac/romac.conf create mode 100644 app/boards/shields/romac/romac.dtsi create mode 100644 app/boards/shields/romac/romac.keymap create mode 100644 app/boards/shields/romac/romac.overlay diff --git a/app/boards/shields/romac/Kconfig.defconfig b/app/boards/shields/romac/Kconfig.defconfig new file mode 100644 index 0000000..da50e5c --- /dev/null +++ b/app/boards/shields/romac/Kconfig.defconfig @@ -0,0 +1,8 @@ + +if SHIELD_ROMAC + +config ZMK_KEYBOARD_NAME + default "romac" + +endif + diff --git a/app/boards/shields/romac/Kconfig.shield b/app/boards/shields/romac/Kconfig.shield new file mode 100644 index 0000000..a081728 --- /dev/null +++ b/app/boards/shields/romac/Kconfig.shield @@ -0,0 +1,5 @@ +# Copyright (c) 2020 Pete Johansen, Richard Jones +# SPDX-License-Identifier: MIT + +config SHIELD_ROMAC + def_bool $(shields_list_contains,romac) diff --git a/app/boards/shields/romac/boards/nice_nano.overlay b/app/boards/shields/romac/boards/nice_nano.overlay new file mode 100644 index 0000000..1f246d3 --- /dev/null +++ b/app/boards/shields/romac/boards/nice_nano.overlay @@ -0,0 +1,10 @@ +&spi1 { + compatible = "nordic,nrf-spi"; + /* Cannot be used together with i2c0. */ + status = "okay"; + sck-pin = <5>; + mosi-pin = <6>; + miso-pin = <7>; + +}; + diff --git a/app/boards/shields/romac/romac.conf b/app/boards/shields/romac/romac.conf new file mode 100644 index 0000000..5b40fdf --- /dev/null +++ b/app/boards/shields/romac/romac.conf @@ -0,0 +1,2 @@ +CONFIG_ZMK_RGB_UNDERGLOW=n +CONFIG_WS2812_STRIP=n diff --git a/app/boards/shields/romac/romac.dtsi b/app/boards/shields/romac/romac.dtsi new file mode 100644 index 0000000..db9685f --- /dev/null +++ b/app/boards/shields/romac/romac.dtsi @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2020 Pete Johansen, Richard Jones + * + * SPDX-License-Identifier: MIT + */ + +#include + +/ { + chosen { + zmk,kscan = &kscan0; + zmk,matrix_transform = &default_transform; + }; + + default_transform: keymap_transform_0 { + compatible = "zmk,matrix-transform"; + columns = <3>; + rows = <4>; +// | SW1 | SW2 | SW3 | +// | SW4 | SW5 | SW6 | +// | SW7 | SW8 | SW9 | +// | SW10 | SW11 | SW12 | + map = < +RC(0,0) RC(0,1) RC(0,2) +RC(1,0) RC(1,1) RC(1,2) +RC(2,0) RC(2,1) RC(2,2) +RC(3,0) RC(3,1) RC(3,2) + >; + }; + + kscan0: kscan { + compatible = "zmk,kscan-gpio-matrix"; + label = "KSCAN"; + + diode-direction = "col2row"; + row-gpios + = <&pro_micro_d 4 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 5 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 6 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 7 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + ; + + }; + + bt_unpair_combo: bt_unpair_combo { + compatible = "zmk,bt-unpair-combo"; + }; + +}; + diff --git a/app/boards/shields/romac/romac.keymap b/app/boards/shields/romac/romac.keymap new file mode 100644 index 0000000..101bfaa --- /dev/null +++ b/app/boards/shields/romac/romac.keymap @@ -0,0 +1,40 @@ +#include +#include + +/ { + keymap { + compatible = "zmk,keymap"; + + default_layer { +// ------------------- +// | 7 | 8 | 9 | +// | 4 | 5 | 6 | +// | 1 | 2 | 3 | +// | MO(1) | 0 | . | +// ---------------------- + bindings = < + &kp NUM_7 &kp NUM_8 &kp NUM_9 + &kp NUM_4 &kp NUM_5 &kp NUM_6 + &kp NUM_1 &kp NUM_2 &kp NUM_3 + &mo 1 &kp NUM_0 &kp DOT + >; + }; + + nav_layer { +// ----------------------- +// | _ | HOME | PGUP | +// | _ | END | PGDN | +// | _ | _ | _ | +// | _ | _ | RET | +// ----------------------- + bindings = < + &trans &kp HOME &kp PGUP + &trans &kp END &kp PGDN + &trans &trans &trans + &trans &trans &kp RET + >; + }; + }; +}; + + diff --git a/app/boards/shields/romac/romac.overlay b/app/boards/shields/romac/romac.overlay new file mode 100644 index 0000000..f16c900 --- /dev/null +++ b/app/boards/shields/romac/romac.overlay @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2020 Pete Johansen, Richard Jones + * + * SPDX-License-Identifier: MIT + */ + +#include "romac.dtsi" + +&kscan0 { + col-gpios + = <&pro_micro_a 0 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 15 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 14 GPIO_ACTIVE_HIGH> + ; +}; + +&bt_unpair_combo { + key-positions = <0 11>; +}; -- cgit v1.2.3 From bc023baa7d0a319c5468f0ce4839d1722f17b905 Mon Sep 17 00:00:00 2001 From: Mega Mind <68985133+megamind4089@users.noreply.github.com> Date: Sun, 23 Aug 2020 12:59:39 +0800 Subject: Incorporate comments - Change config name to nrfmicro specific --- app/boards/arm/nrfmicro/Kconfig | 2 +- app/boards/arm/nrfmicro/Kconfig.defconfig | 2 +- app/boards/arm/nrfmicro/pinmux.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/boards/arm/nrfmicro/Kconfig b/app/boards/arm/nrfmicro/Kconfig index 80039e9..3501972 100644 --- a/app/boards/arm/nrfmicro/Kconfig +++ b/app/boards/arm/nrfmicro/Kconfig @@ -4,7 +4,7 @@ config BOARD_ENABLE_DCDC default y depends on (BOARD_NRFMICRO_11 || BOARD_NRFMICRO_11_FLIPPED || BOARD_NRFMICRO_13) -config BOARD_ENABLE_CHARGER +config BOARD_NRFMICRO_CHARGER bool "Enable battery charger" default y depends on (BOARD_NRFMICRO_13) diff --git a/app/boards/arm/nrfmicro/Kconfig.defconfig b/app/boards/arm/nrfmicro/Kconfig.defconfig index 69b59ee..9cce5a9 100644 --- a/app/boards/arm/nrfmicro/Kconfig.defconfig +++ b/app/boards/arm/nrfmicro/Kconfig.defconfig @@ -32,7 +32,7 @@ config PINMUX if BOARD_NRFMICRO_13 -config BOARD_ENABLE_CHARGER +config BOARD_NRFMICRO_CHARGER default y endif # BOARD_NRFMICRO_13 diff --git a/app/boards/arm/nrfmicro/pinmux.c b/app/boards/arm/nrfmicro/pinmux.c index be1a4de..3792b59 100644 --- a/app/boards/arm/nrfmicro/pinmux.c +++ b/app/boards/arm/nrfmicro/pinmux.c @@ -23,7 +23,7 @@ static int pinmux_nrfmicro_init(struct device *port) gpio_pin_configure(p1, 9, GPIO_OUTPUT); gpio_pin_set(p1, 9, 0); -#if CONFIG_BOARD_ENABLE_CHARGER +#if CONFIG_BOARD_NRFMICRO_CHARGER gpio_pin_configure(p0, 5, GPIO_OUTPUT); gpio_pin_set(p0, 5, 0); #else -- cgit v1.2.3 From ebc3542aa6a4b45be197aa990e2abd514f92ce00 Mon Sep 17 00:00:00 2001 From: Okke Formsma Date: Sun, 23 Aug 2020 14:46:52 +0200 Subject: fix bug in modtap bahavior which cleared the wrong keycode events --- app/src/behaviors/behavior_mod_tap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/behaviors/behavior_mod_tap.c b/app/src/behaviors/behavior_mod_tap.c index 6151f7e..5a2f60e 100644 --- a/app/src/behaviors/behavior_mod_tap.c +++ b/app/src/behaviors/behavior_mod_tap.c @@ -193,8 +193,8 @@ static int on_keymap_binding_released(struct device *dev, u32_t position, u32_t } struct keycode_state_changed *ev = data->captured_keycode_events[j].event; - data->captured_keycode_events[i].event = NULL; - data->captured_keycode_events[i].active_mods = 0; + data->captured_keycode_events[j].event = NULL; + data->captured_keycode_events[j].active_mods = 0; LOG_DBG("Re-sending latched key press for usage page 0x%02X keycode 0x%02X state %s", ev->usage_page, ev->keycode, (ev->state ? "pressed" : "released")); ZMK_EVENT_RELEASE(ev); k_msleep(10); -- cgit v1.2.3 From 7abcae6949834a4dd9d4fdb41ebc68acb36d3db7 Mon Sep 17 00:00:00 2001 From: CrossR Date: Sun, 23 Aug 2020 18:48:28 +0100 Subject: Update License info. --- app/boards/shields/sofle/Kconfig.defconfig | 2 ++ app/boards/shields/sofle/sofle.conf | 3 +++ app/boards/shields/sofle/sofle_left.conf | 3 +++ app/boards/shields/sofle/sofle_right.conf | 3 +++ 4 files changed, 11 insertions(+) diff --git a/app/boards/shields/sofle/Kconfig.defconfig b/app/boards/shields/sofle/Kconfig.defconfig index 2ccf147..58d8217 100644 --- a/app/boards/shields/sofle/Kconfig.defconfig +++ b/app/boards/shields/sofle/Kconfig.defconfig @@ -1,3 +1,5 @@ +# Copyright (c) 2020 Ryan Cross +# SPDX-License-Identifier: MIT if SHIELD_SOFLE_LEFT diff --git a/app/boards/shields/sofle/sofle.conf b/app/boards/shields/sofle/sofle.conf index 2194add..fe3f0f4 100644 --- a/app/boards/shields/sofle/sofle.conf +++ b/app/boards/shields/sofle/sofle.conf @@ -1,3 +1,6 @@ +# Copyright (c) 2020 Ryan Cross +# SPDX-License-Identifier: MIT + # Uncomment the following line to enable the Sofle OLED Display # CONFIG_ZMK_DISPLAY=y diff --git a/app/boards/shields/sofle/sofle_left.conf b/app/boards/shields/sofle/sofle_left.conf index 1e028a7..bbac735 100644 --- a/app/boards/shields/sofle/sofle_left.conf +++ b/app/boards/shields/sofle/sofle_left.conf @@ -1,2 +1,5 @@ +# Copyright (c) 2020 Ryan Cross +# SPDX-License-Identifier: MIT + CONFIG_ZMK_SPLIT=y CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y diff --git a/app/boards/shields/sofle/sofle_right.conf b/app/boards/shields/sofle/sofle_right.conf index 990cf7c..ca5de38 100644 --- a/app/boards/shields/sofle/sofle_right.conf +++ b/app/boards/shields/sofle/sofle_right.conf @@ -1,2 +1,5 @@ +# Copyright (c) 2020 Ryan Cross +# SPDX-License-Identifier: MIT + CONFIG_ZMK_SPLIT=y CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y -- cgit v1.2.3 From 221535fdc1c921c132d8a8539c62eb18e9c5f681 Mon Sep 17 00:00:00 2001 From: Richard Jones Date: Sun, 23 Aug 2020 19:28:03 +0100 Subject: refactor to remove SPI; no need for shared DTSI --- app/boards/shields/romac/boards/nice_nano.overlay | 10 ---- app/boards/shields/romac/romac.conf | 2 - app/boards/shields/romac/romac.dtsi | 50 ------------------- app/boards/shields/romac/romac.overlay | 60 ++++++++++++++++++----- 4 files changed, 49 insertions(+), 73 deletions(-) delete mode 100644 app/boards/shields/romac/boards/nice_nano.overlay delete mode 100644 app/boards/shields/romac/romac.dtsi diff --git a/app/boards/shields/romac/boards/nice_nano.overlay b/app/boards/shields/romac/boards/nice_nano.overlay deleted file mode 100644 index 1f246d3..0000000 --- a/app/boards/shields/romac/boards/nice_nano.overlay +++ /dev/null @@ -1,10 +0,0 @@ -&spi1 { - compatible = "nordic,nrf-spi"; - /* Cannot be used together with i2c0. */ - status = "okay"; - sck-pin = <5>; - mosi-pin = <6>; - miso-pin = <7>; - -}; - diff --git a/app/boards/shields/romac/romac.conf b/app/boards/shields/romac/romac.conf index 5b40fdf..e69de29 100644 --- a/app/boards/shields/romac/romac.conf +++ b/app/boards/shields/romac/romac.conf @@ -1,2 +0,0 @@ -CONFIG_ZMK_RGB_UNDERGLOW=n -CONFIG_WS2812_STRIP=n diff --git a/app/boards/shields/romac/romac.dtsi b/app/boards/shields/romac/romac.dtsi deleted file mode 100644 index db9685f..0000000 --- a/app/boards/shields/romac/romac.dtsi +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2020 Pete Johansen, Richard Jones - * - * SPDX-License-Identifier: MIT - */ - -#include - -/ { - chosen { - zmk,kscan = &kscan0; - zmk,matrix_transform = &default_transform; - }; - - default_transform: keymap_transform_0 { - compatible = "zmk,matrix-transform"; - columns = <3>; - rows = <4>; -// | SW1 | SW2 | SW3 | -// | SW4 | SW5 | SW6 | -// | SW7 | SW8 | SW9 | -// | SW10 | SW11 | SW12 | - map = < -RC(0,0) RC(0,1) RC(0,2) -RC(1,0) RC(1,1) RC(1,2) -RC(2,0) RC(2,1) RC(2,2) -RC(3,0) RC(3,1) RC(3,2) - >; - }; - - kscan0: kscan { - compatible = "zmk,kscan-gpio-matrix"; - label = "KSCAN"; - - diode-direction = "col2row"; - row-gpios - = <&pro_micro_d 4 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> - , <&pro_micro_d 5 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> - , <&pro_micro_d 6 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> - , <&pro_micro_d 7 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> - ; - - }; - - bt_unpair_combo: bt_unpair_combo { - compatible = "zmk,bt-unpair-combo"; - }; - -}; - diff --git a/app/boards/shields/romac/romac.overlay b/app/boards/shields/romac/romac.overlay index f16c900..7449703 100644 --- a/app/boards/shields/romac/romac.overlay +++ b/app/boards/shields/romac/romac.overlay @@ -4,16 +4,54 @@ * SPDX-License-Identifier: MIT */ -#include "romac.dtsi" - -&kscan0 { - col-gpios - = <&pro_micro_a 0 GPIO_ACTIVE_HIGH> - , <&pro_micro_d 15 GPIO_ACTIVE_HIGH> - , <&pro_micro_d 14 GPIO_ACTIVE_HIGH> - ; -}; +#include + +/ { + chosen { + zmk,kscan = &kscan0; + zmk,matrix_transform = &default_transform; + }; + + default_transform: keymap_transform_0 { + compatible = "zmk,matrix-transform"; + columns = <3>; + rows = <4>; +// | SW1 | SW2 | SW3 | +// | SW4 | SW5 | SW6 | +// | SW7 | SW8 | SW9 | +// | SW10 | SW11 | SW12 | + map = < +RC(0,0) RC(0,1) RC(0,2) +RC(1,0) RC(1,1) RC(1,2) +RC(2,0) RC(2,1) RC(2,2) +RC(3,0) RC(3,1) RC(3,2) + >; + }; + + kscan0: kscan { + compatible = "zmk,kscan-gpio-matrix"; + label = "KSCAN"; + + diode-direction = "col2row"; + row-gpios + = <&pro_micro_d 4 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 5 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 6 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 7 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + ; + + col-gpios + = <&pro_micro_a 0 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 15 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 14 GPIO_ACTIVE_HIGH> + ; + + }; + + bt_unpair_combo: bt_unpair_combo { + compatible = "zmk,bt-unpair-combo"; + key-positions = <0 11>; + }; -&bt_unpair_combo { - key-positions = <0 11>; }; + -- cgit v1.2.3 From 9b5af05f164582f22f3b4021c48660153f510ef2 Mon Sep 17 00:00:00 2001 From: Richard Jones Date: Sun, 23 Aug 2020 19:59:41 +0100 Subject: Make the shield name on-brand --- app/boards/shields/romac/Kconfig.defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/boards/shields/romac/Kconfig.defconfig b/app/boards/shields/romac/Kconfig.defconfig index da50e5c..b6490ac 100644 --- a/app/boards/shields/romac/Kconfig.defconfig +++ b/app/boards/shields/romac/Kconfig.defconfig @@ -2,7 +2,7 @@ if SHIELD_ROMAC config ZMK_KEYBOARD_NAME - default "romac" + default "RoMac" endif -- cgit v1.2.3 From 3ce94593652b89a6f5a59fce9fba284b022cc946 Mon Sep 17 00:00:00 2001 From: Richard Jones Date: Sun, 23 Aug 2020 20:02:28 +0100 Subject: Add license / copyright --- app/boards/shields/romac/Kconfig.defconfig | 5 +++++ app/boards/shields/romac/romac.keymap | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/app/boards/shields/romac/Kconfig.defconfig b/app/boards/shields/romac/Kconfig.defconfig index b6490ac..0ef6f6b 100644 --- a/app/boards/shields/romac/Kconfig.defconfig +++ b/app/boards/shields/romac/Kconfig.defconfig @@ -1,3 +1,8 @@ +/* + * Copyright (c) 2020 Pete Johansen, Richard Jones + * + * SPDX-License-Identifier: MIT + */ if SHIELD_ROMAC diff --git a/app/boards/shields/romac/romac.keymap b/app/boards/shields/romac/romac.keymap index 101bfaa..5557383 100644 --- a/app/boards/shields/romac/romac.keymap +++ b/app/boards/shields/romac/romac.keymap @@ -1,3 +1,9 @@ +/* + * Copyright (c) 2020 Pete Johansen, Richard Jones + * + * SPDX-License-Identifier: MIT + */ + #include #include -- cgit v1.2.3 From cafd5c1fe2fade4646bc901d2aa6a185ca842f4d Mon Sep 17 00:00:00 2001 From: Richard Jones Date: Sun, 23 Aug 2020 20:05:56 +0100 Subject: Oops comment format --- app/boards/shields/romac/Kconfig.defconfig | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/app/boards/shields/romac/Kconfig.defconfig b/app/boards/shields/romac/Kconfig.defconfig index 0ef6f6b..50e4fdc 100644 --- a/app/boards/shields/romac/Kconfig.defconfig +++ b/app/boards/shields/romac/Kconfig.defconfig @@ -1,8 +1,6 @@ -/* - * Copyright (c) 2020 Pete Johansen, Richard Jones - * - * SPDX-License-Identifier: MIT - */ +# Copyright (c) 2020 Pete Johansen, Richard Jones +# +# SPDX-License-Identifier: MIT if SHIELD_ROMAC -- cgit v1.2.3 From 3affd45f0d4c85e417a9da27737cef4350c43a84 Mon Sep 17 00:00:00 2001 From: Richard Jones Date: Sun, 23 Aug 2020 20:08:00 +0100 Subject: Formatting --- app/boards/shields/romac/Kconfig.defconfig | 1 - 1 file changed, 1 deletion(-) diff --git a/app/boards/shields/romac/Kconfig.defconfig b/app/boards/shields/romac/Kconfig.defconfig index 50e4fdc..22be9fe 100644 --- a/app/boards/shields/romac/Kconfig.defconfig +++ b/app/boards/shields/romac/Kconfig.defconfig @@ -1,5 +1,4 @@ # Copyright (c) 2020 Pete Johansen, Richard Jones -# # SPDX-License-Identifier: MIT if SHIELD_ROMAC -- cgit v1.2.3 From 6ac1a324e0bf91a405333e4bf89b4b35a50afc49 Mon Sep 17 00:00:00 2001 From: Richard Jones Date: Wed, 26 Aug 2020 21:25:26 +0100 Subject: Typo --- app/boards/shields/romac/Kconfig.defconfig | 2 +- app/boards/shields/romac/Kconfig.shield | 2 +- app/boards/shields/romac/romac.keymap | 2 +- app/boards/shields/romac/romac.overlay | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/boards/shields/romac/Kconfig.defconfig b/app/boards/shields/romac/Kconfig.defconfig index 22be9fe..5352797 100644 --- a/app/boards/shields/romac/Kconfig.defconfig +++ b/app/boards/shields/romac/Kconfig.defconfig @@ -1,4 +1,4 @@ -# Copyright (c) 2020 Pete Johansen, Richard Jones +# Copyright (c) 2020 Pete Johanson, Richard Jones # SPDX-License-Identifier: MIT if SHIELD_ROMAC diff --git a/app/boards/shields/romac/Kconfig.shield b/app/boards/shields/romac/Kconfig.shield index a081728..59669d3 100644 --- a/app/boards/shields/romac/Kconfig.shield +++ b/app/boards/shields/romac/Kconfig.shield @@ -1,4 +1,4 @@ -# Copyright (c) 2020 Pete Johansen, Richard Jones +# Copyright (c) 2020 Pete Johanson, Richard Jones # SPDX-License-Identifier: MIT config SHIELD_ROMAC diff --git a/app/boards/shields/romac/romac.keymap b/app/boards/shields/romac/romac.keymap index 5557383..f94a829 100644 --- a/app/boards/shields/romac/romac.keymap +++ b/app/boards/shields/romac/romac.keymap @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Pete Johansen, Richard Jones + * Copyright (c) 2020 Pete Johanson, Richard Jones * * SPDX-License-Identifier: MIT */ diff --git a/app/boards/shields/romac/romac.overlay b/app/boards/shields/romac/romac.overlay index 7449703..cae0568 100644 --- a/app/boards/shields/romac/romac.overlay +++ b/app/boards/shields/romac/romac.overlay @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Pete Johansen, Richard Jones + * Copyright (c) 2020 Pete Johanson, Richard Jones * * SPDX-License-Identifier: MIT */ -- cgit v1.2.3 From b8fbc3784d0e3dcb3bfba39c0936b2a110894ef8 Mon Sep 17 00:00:00 2001 From: Richard Jones Date: Wed, 26 Aug 2020 21:25:46 +0100 Subject: Not needed --- app/boards/shields/romac/romac.overlay | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/app/boards/shields/romac/romac.overlay b/app/boards/shields/romac/romac.overlay index cae0568..67d5868 100644 --- a/app/boards/shields/romac/romac.overlay +++ b/app/boards/shields/romac/romac.overlay @@ -9,23 +9,6 @@ / { chosen { zmk,kscan = &kscan0; - zmk,matrix_transform = &default_transform; - }; - - default_transform: keymap_transform_0 { - compatible = "zmk,matrix-transform"; - columns = <3>; - rows = <4>; -// | SW1 | SW2 | SW3 | -// | SW4 | SW5 | SW6 | -// | SW7 | SW8 | SW9 | -// | SW10 | SW11 | SW12 | - map = < -RC(0,0) RC(0,1) RC(0,2) -RC(1,0) RC(1,1) RC(1,2) -RC(2,0) RC(2,1) RC(2,2) -RC(3,0) RC(3,1) RC(3,2) - >; }; kscan0: kscan { -- cgit v1.2.3 From e5da5ea40d3971af272e5004deb6ed3f1d151788 Mon Sep 17 00:00:00 2001 From: Richard Jones Date: Wed, 26 Aug 2020 21:31:46 +0100 Subject: add romac to build --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5086bf8..c8a711c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,6 +16,7 @@ jobs: - kyria_right - lily58_left - lily58_right + - romac include: - board: proton_c shield: clueboard_california -- cgit v1.2.3 From 79f0ecf8b5a79f280c5f25209701218caa8e8b2a Mon Sep 17 00:00:00 2001 From: jrhe <4038905+jrhe@users.noreply.github.com> Date: Fri, 28 Aug 2020 01:02:50 +0100 Subject: Correct number of rows in Lily58 shield --- app/boards/shields/lily58/lily58.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/boards/shields/lily58/lily58.dtsi b/app/boards/shields/lily58/lily58.dtsi index 24f6805..23f5644 100644 --- a/app/boards/shields/lily58/lily58.dtsi +++ b/app/boards/shields/lily58/lily58.dtsi @@ -15,7 +15,7 @@ default_transform: keymap_transform_0 { compatible = "zmk,matrix-transform"; columns = <16>; - rows = <4>; + rows = <5>; // | SW6 | SW5 | SW4 | SW3 | SW2 | SW1 | | SW1 | SW2 | SW3 | SW4 | SW5 | SW6 | // | SW12 | SW11 | SW10 | SW9 | SW8 | SW7 | | SW7 | SW8 | SW9 | SW10 | SW11 | SW12 | // | SW18 | SW17 | SW16 | SW15 | SW14 | SW13 | | SW13 | SW14 | SW15 | SW16 | SW17 | SW18 | -- cgit v1.2.3 From ac3e4af1ce7fb40495c50eb2184b43ecbe1f11a9 Mon Sep 17 00:00:00 2001 From: tominabox1 Date: Thu, 27 Aug 2020 19:09:40 -0500 Subject: Add QAZ shield --- app/boards/shields/qaz/Kconfig.defconfig | 6 ++ app/boards/shields/qaz/Kconfig.shield | 2 + app/boards/shields/qaz/boards/nice_nano.overlay | 22 ++++++++ app/boards/shields/qaz/qaz.conf | 26 +++++++++ app/boards/shields/qaz/qaz.keymap | 75 +++++++++++++++++++++++++ app/boards/shields/qaz/qaz.overlay | 48 ++++++++++++++++ 6 files changed, 179 insertions(+) create mode 100644 app/boards/shields/qaz/Kconfig.defconfig create mode 100644 app/boards/shields/qaz/Kconfig.shield create mode 100644 app/boards/shields/qaz/boards/nice_nano.overlay create mode 100644 app/boards/shields/qaz/qaz.conf create mode 100644 app/boards/shields/qaz/qaz.keymap create mode 100644 app/boards/shields/qaz/qaz.overlay diff --git a/app/boards/shields/qaz/Kconfig.defconfig b/app/boards/shields/qaz/Kconfig.defconfig new file mode 100644 index 0000000..18cceaa --- /dev/null +++ b/app/boards/shields/qaz/Kconfig.defconfig @@ -0,0 +1,6 @@ +if SHIELD_QAZ + +config ZMK_KEYBOARD_NAME + default "QAZ" + +endif \ No newline at end of file diff --git a/app/boards/shields/qaz/Kconfig.shield b/app/boards/shields/qaz/Kconfig.shield new file mode 100644 index 0000000..1e1112a --- /dev/null +++ b/app/boards/shields/qaz/Kconfig.shield @@ -0,0 +1,2 @@ +config SHIELD_MY_BOARD + def_bool $(shields_list_contains,qaz) diff --git a/app/boards/shields/qaz/boards/nice_nano.overlay b/app/boards/shields/qaz/boards/nice_nano.overlay new file mode 100644 index 0000000..2927d0d --- /dev/null +++ b/app/boards/shields/qaz/boards/nice_nano.overlay @@ -0,0 +1,22 @@ +&spi1 { + compatible = "nordic,nrf-spi"; + status = "okay"; + mosi-pin = <47>; + // Unused pins, needed for SPI definition, but not used by the ws2812 driver itself. + sck-pin = <5>; + miso-pin = <7>; + + led_strip: ws2812@0 { + compatible = "worldsemi,ws2812-spi"; + label = "WS2812"; + + /* SPI */ + reg = <0>; /* ignored, but necessary for SPI bindings */ + spi-max-frequency = <4000000>; + + /* WS2812 */ + chain-length = <21>; /* number of LEDs */ + spi-one-frame = <0x70>; + spi-zero-frame = <0x40>; + }; +}; \ No newline at end of file diff --git a/app/boards/shields/qaz/qaz.conf b/app/boards/shields/qaz/qaz.conf new file mode 100644 index 0000000..7d6da43 --- /dev/null +++ b/app/boards/shields/qaz/qaz.conf @@ -0,0 +1,26 @@ +CONFIG_ZMK_RGB_UNDERGLOW=n +# Use the STRIP config specific to the LEDs you're using +CONFIG_WS2812_STRIP=n +# Turn on logging, and set ZMK logging to debug output +CONFIG_LOG=y +CONFIG_ZMK_LOG_LEVEL_DBG=y + +# Turn on USB CDC ACM device +CONFIG_USB=y +CONFIG_USB_DEVICE_STACK=y +CONFIG_USB_CDC_ACM=y +CONFIG_USB_CDC_ACM_RINGBUF_SIZE=1024 +CONFIG_USB_CDC_ACM_DEVICE_NAME="CDC_ACM" +CONFIG_USB_CDC_ACM_DEVICE_COUNT=1 + +# Enable serial console +CONFIG_SERIAL=y +CONFIG_CONSOLE=y +CONFIG_UART_INTERRUPT_DRIVEN=y +CONFIG_UART_LINE_CTRL=y + +# Enable USB UART, and set the console device +CONFIG_UART_CONSOLE=y +CONFIG_USB_UART_CONSOLE=y +CONFIG_UART_CONSOLE_ON_DEV_NAME="CDC_ACM_0" +CONFIG_USB_UART_DTR_WAIT=n \ No newline at end of file diff --git a/app/boards/shields/qaz/qaz.keymap b/app/boards/shields/qaz/qaz.keymap new file mode 100644 index 0000000..fa4ede1 --- /dev/null +++ b/app/boards/shields/qaz/qaz.keymap @@ -0,0 +1,75 @@ +#include +#include +#include + +#define DEFAULT 0 +#define NUM_SYM 1 +#define NAV 2 + +/ { + behaviors { + rst: behavior_tap_hold1 { + compatible = "zmk,behavior-tap-hold"; + label = "Bootloader Tap - Reset Hold"; + #binding-cells = <0>; + hold_ms = <200>; + bindings = <&bootloader>, <&reset>, <&kp BKSP>; + }; + + num_spc: behavior_tap_hold2 { + compatible = "zmk,behavior-tap-hold"; + label = "Space Tap - Num/Sym Hold"; + #binding-cells = <0>; + hold_ms = <300>; + bindings = <&kp SPC>, <&mo NUM_SYM>; + }; + + ent_nav: behavior_tap_hold{ + compatible = "zmk,behavior-tap-hold"; + label = "Return Tap - Nav Hold"; + #binding-cells = <0>; + hold_ms = <100>; + bindings = <&kp RET>, <&mo NAV>; + }; + + com_col: behavior_tap_hold10 { + compatible = "zmk,behavior-tap-hold"; + label = ", tap, hold"; + #binding-cells = <0>; + hold_ms = <200>; + bindings = <&kp CMMA>, <&kp SCLN>, <&kp BKSP>; + }; + }; + }; + +/ { + keymap { + compatible = "zmk,keymap"; + + default_layer { + bindings = < + &kp Q &kp W &kp F &kp P &kp G &kp J &kp L &kp U &kp Y &kp QUOT + &kp A &kp R &kp S &kp T &kp D &kp H &kp N &kp E &kp I &kp O + &kp Z &kp X &kp C &kp V &kp B &kp K &kp M &com_col &kp DOT + &kp LSFT &kp LGUI &kp TAB &ent_nav &num_spc &kp LCTL &kp LALT &kp FSLH + >; + }; + num_sym { + bindings = < + &kp NUM_1 &kp NUM_2 &kp NUM_3 &kp NUM_4 &kp NUM_5 &kp NUM_6 &kp NUM_7 &kp NUM_8 &kp NUM_9 &kp NUM_0 + &trans &trans &trans &trans &trans &trans &trans &trans &kp EQL &kp MINUS + &kp DEL &none &none &none &none &none &none &none &kp DOT + &rst &none &none &trans &trans &kp RET &trans &kp FSLH + >; + }; + + nav { + bindings = < + &none &none &none &none &none &none &none &kp UARW &none &kp BKSP + &trans &trans &trans &trans &none &none &kp LARW &kp DARW &kp RARW &none + &none &none &none &none &none &none &none &none &none + &rgb_ug RGB_TOG &rgb_ug RGB_EFF &none &trans &trans &kp RET &trans &kp FSLH + >; + }; + }; +}; \ No newline at end of file diff --git a/app/boards/shields/qaz/qaz.overlay b/app/boards/shields/qaz/qaz.overlay new file mode 100644 index 0000000..3dae7dd --- /dev/null +++ b/app/boards/shields/qaz/qaz.overlay @@ -0,0 +1,48 @@ +#include + +/ { + chosen { + zmk,kscan = &kscan0; + zmk,matrix_transform = &default_transform; + zmk,underglow = &led_strip; + }; + + default_transform: keymap_transform_0 { + compatible = "zmk,matrix-transform"; + columns = <7>; + rows = <6>; + map = < + RC(0,0) RC(0,1) RC(0,2) RC(0,3) RC(0,4) RC(0,5) RC(0,6) RC(4,0) RC(4,1) RC(4,2) + RC(1,0) RC(1,1) RC(1,2) RC(1,3) RC(1,4) RC(1,5) RC(1,6) RC(5,0) RC(5,1) RC(5,2) + RC(2,0) RC(2,1) RC(2,2) RC(2,3) RC(2,4) RC(2,5) RC(2,6) RC(4,3) RC(5,3) + RC(3,0) RC(3,1) RC(3,2) RC(3,3) RC(3,4) RC(3,5) RC(3,6) RC(4,4) + >; + }; + + + kscan0: kscan_0 { + compatible = "zmk,kscan-gpio-matrix"; + label = "KSCAN"; + diode-direction = "col2row"; + + col-gpios + = <&pro_micro_d 8 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 1 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 0 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 2 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 9 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 1 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 6 GPIO_ACTIVE_HIGH> + ; + + row-gpios + = <&pro_micro_a 3 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 4 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 5 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 7 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 2 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 3 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + ; + }; + +}; \ No newline at end of file -- cgit v1.2.3 From cbea2d5bed4562a9fea8480c9c23b2365c2378a4 Mon Sep 17 00:00:00 2001 From: Cody McGinnis Date: Thu, 27 Aug 2020 23:12:56 -0400 Subject: fix(behavior): none should not be transparent --- app/src/behaviors/behavior_none.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/behaviors/behavior_none.c b/app/src/behaviors/behavior_none.c index 7e77e54..e822d5e 100644 --- a/app/src/behaviors/behavior_none.c +++ b/app/src/behaviors/behavior_none.c @@ -23,12 +23,12 @@ static int behavior_none_init(struct device *dev) static int on_keymap_binding_pressed(struct device *dev, u32_t position, u32_t _param1, u32_t _param2) { - return 1; + return 0; } static int on_keymap_binding_released(struct device *dev, u32_t position, u32_t _param1, u32_t _param2) { - return 1; + return 0; } static const struct behavior_driver_api behavior_none_driver_api = { -- cgit v1.2.3 From cf003262e63a29dd6384645a8c96951a963f30d3 Mon Sep 17 00:00:00 2001 From: tominabox1 Date: Thu, 27 Aug 2020 22:23:27 -0500 Subject: Remove RGB, Remove debug, Add Copyright and Licenses --- app/boards/shields/qaz/Kconfig.defconfig | 3 ++ app/boards/shields/qaz/Kconfig.shield | 5 ++- app/boards/shields/qaz/boards/nice_nano.overlay | 22 ----------- app/boards/shields/qaz/qaz.conf | 26 ------------- app/boards/shields/qaz/qaz.keymap | 49 +++---------------------- app/boards/shields/qaz/qaz.overlay | 7 +++- 6 files changed, 19 insertions(+), 93 deletions(-) delete mode 100644 app/boards/shields/qaz/boards/nice_nano.overlay delete mode 100644 app/boards/shields/qaz/qaz.conf diff --git a/app/boards/shields/qaz/Kconfig.defconfig b/app/boards/shields/qaz/Kconfig.defconfig index 18cceaa..f82f458 100644 --- a/app/boards/shields/qaz/Kconfig.defconfig +++ b/app/boards/shields/qaz/Kconfig.defconfig @@ -1,3 +1,6 @@ + # Copyright (c) 2020 TJ Campie + # SPDX-License-Identifier: MIT + if SHIELD_QAZ config ZMK_KEYBOARD_NAME diff --git a/app/boards/shields/qaz/Kconfig.shield b/app/boards/shields/qaz/Kconfig.shield index 1e1112a..9da6077 100644 --- a/app/boards/shields/qaz/Kconfig.shield +++ b/app/boards/shields/qaz/Kconfig.shield @@ -1,2 +1,5 @@ -config SHIELD_MY_BOARD +# Copyright (c) 2020 TJ Campie +# SPDX-License-Identifier: MIT + + config SHIELD_MY_BOARD def_bool $(shields_list_contains,qaz) diff --git a/app/boards/shields/qaz/boards/nice_nano.overlay b/app/boards/shields/qaz/boards/nice_nano.overlay deleted file mode 100644 index 2927d0d..0000000 --- a/app/boards/shields/qaz/boards/nice_nano.overlay +++ /dev/null @@ -1,22 +0,0 @@ -&spi1 { - compatible = "nordic,nrf-spi"; - status = "okay"; - mosi-pin = <47>; - // Unused pins, needed for SPI definition, but not used by the ws2812 driver itself. - sck-pin = <5>; - miso-pin = <7>; - - led_strip: ws2812@0 { - compatible = "worldsemi,ws2812-spi"; - label = "WS2812"; - - /* SPI */ - reg = <0>; /* ignored, but necessary for SPI bindings */ - spi-max-frequency = <4000000>; - - /* WS2812 */ - chain-length = <21>; /* number of LEDs */ - spi-one-frame = <0x70>; - spi-zero-frame = <0x40>; - }; -}; \ No newline at end of file diff --git a/app/boards/shields/qaz/qaz.conf b/app/boards/shields/qaz/qaz.conf deleted file mode 100644 index 7d6da43..0000000 --- a/app/boards/shields/qaz/qaz.conf +++ /dev/null @@ -1,26 +0,0 @@ -CONFIG_ZMK_RGB_UNDERGLOW=n -# Use the STRIP config specific to the LEDs you're using -CONFIG_WS2812_STRIP=n -# Turn on logging, and set ZMK logging to debug output -CONFIG_LOG=y -CONFIG_ZMK_LOG_LEVEL_DBG=y - -# Turn on USB CDC ACM device -CONFIG_USB=y -CONFIG_USB_DEVICE_STACK=y -CONFIG_USB_CDC_ACM=y -CONFIG_USB_CDC_ACM_RINGBUF_SIZE=1024 -CONFIG_USB_CDC_ACM_DEVICE_NAME="CDC_ACM" -CONFIG_USB_CDC_ACM_DEVICE_COUNT=1 - -# Enable serial console -CONFIG_SERIAL=y -CONFIG_CONSOLE=y -CONFIG_UART_INTERRUPT_DRIVEN=y -CONFIG_UART_LINE_CTRL=y - -# Enable USB UART, and set the console device -CONFIG_UART_CONSOLE=y -CONFIG_USB_UART_CONSOLE=y -CONFIG_UART_CONSOLE_ON_DEV_NAME="CDC_ACM_0" -CONFIG_USB_UART_DTR_WAIT=n \ No newline at end of file diff --git a/app/boards/shields/qaz/qaz.keymap b/app/boards/shields/qaz/qaz.keymap index fa4ede1..cebcd4b 100644 --- a/app/boards/shields/qaz/qaz.keymap +++ b/app/boards/shields/qaz/qaz.keymap @@ -1,46 +1,9 @@ #include #include -#include #define DEFAULT 0 #define NUM_SYM 1 #define NAV 2 - -/ { - behaviors { - rst: behavior_tap_hold1 { - compatible = "zmk,behavior-tap-hold"; - label = "Bootloader Tap - Reset Hold"; - #binding-cells = <0>; - hold_ms = <200>; - bindings = <&bootloader>, <&reset>, <&kp BKSP>; - }; - - num_spc: behavior_tap_hold2 { - compatible = "zmk,behavior-tap-hold"; - label = "Space Tap - Num/Sym Hold"; - #binding-cells = <0>; - hold_ms = <300>; - bindings = <&kp SPC>, <&mo NUM_SYM>; - }; - - ent_nav: behavior_tap_hold{ - compatible = "zmk,behavior-tap-hold"; - label = "Return Tap - Nav Hold"; - #binding-cells = <0>; - hold_ms = <100>; - bindings = <&kp RET>, <&mo NAV>; - }; - - com_col: behavior_tap_hold10 { - compatible = "zmk,behavior-tap-hold"; - label = ", tap, hold"; - #binding-cells = <0>; - hold_ms = <200>; - bindings = <&kp CMMA>, <&kp SCLN>, <&kp BKSP>; - }; - }; - }; / { keymap { @@ -48,10 +11,10 @@ default_layer { bindings = < - &kp Q &kp W &kp F &kp P &kp G &kp J &kp L &kp U &kp Y &kp QUOT - &kp A &kp R &kp S &kp T &kp D &kp H &kp N &kp E &kp I &kp O - &kp Z &kp X &kp C &kp V &kp B &kp K &kp M &com_col &kp DOT - &kp LSFT &kp LGUI &kp TAB &ent_nav &num_spc &kp LCTL &kp LALT &kp FSLH + &kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P + &kp A &kp S &kp D &kp F &kp G &kp H &kp J &kp K &kp L &kp RET + &kp Z &kp X &kp C &kp V &kp B &kp N &kp M &kp CMMA &kp DOT + &kp LSFT &kp LGUI &kp LALT &mo NAV &kp SPC &mo NUM_SYM &kp QUOT &kp FSLH >; }; num_sym { @@ -59,7 +22,7 @@ &kp NUM_1 &kp NUM_2 &kp NUM_3 &kp NUM_4 &kp NUM_5 &kp NUM_6 &kp NUM_7 &kp NUM_8 &kp NUM_9 &kp NUM_0 &trans &trans &trans &trans &trans &trans &trans &trans &kp EQL &kp MINUS &kp DEL &none &none &none &none &none &none &none &kp DOT - &rst &none &none &trans &trans &kp RET &trans &kp FSLH + &bootloader &reset &none &trans &trans &kp RET &trans &kp FSLH >; }; @@ -68,7 +31,7 @@ &none &none &none &none &none &none &none &kp UARW &none &kp BKSP &trans &trans &trans &trans &none &none &kp LARW &kp DARW &kp RARW &none &none &none &none &none &none &none &none &none &none - &rgb_ug RGB_TOG &rgb_ug RGB_EFF &none &trans &trans &kp RET &trans &kp FSLH + &none &none &none &none &none &trans &trans &kp RET &trans &kp FSLH >; }; }; diff --git a/app/boards/shields/qaz/qaz.overlay b/app/boards/shields/qaz/qaz.overlay index 3dae7dd..472005b 100644 --- a/app/boards/shields/qaz/qaz.overlay +++ b/app/boards/shields/qaz/qaz.overlay @@ -1,10 +1,15 @@ +/* + * Copyright (c) 2020 TJ Campie + * + * SPDX-License-Identifier: MIT + */ + #include / { chosen { zmk,kscan = &kscan0; zmk,matrix_transform = &default_transform; - zmk,underglow = &led_strip; }; default_transform: keymap_transform_0 { -- cgit v1.2.3 From f02fa01e9a9af1a1637a387f3e8044a791b47ced Mon Sep 17 00:00:00 2001 From: Cody McGinnis Date: Fri, 28 Aug 2020 16:21:31 -0400 Subject: fix(test): change the layout --- app/boards/native_posix.conf | 3 +- app/boards/native_posix.overlay | 73 ++-------------------- app/dts/bindings/zmk,kscan-mock.yaml | 2 + app/include/dt-bindings/zmk/kscan-mock.h | 8 +++ app/include/zmk/kscan-mock.h | 8 --- app/prj.conf | 0 app/run-test.sh | 17 +++++ app/src/kscan_mock.c | 12 +++- app/tests/keypress/behavior_keymap.dtsi | 28 +++++++++ .../keypress/cp-press-release/events.patterns | 1 + .../cp-press-release/keycode_events.snapshot | 2 + .../keypress/cp-press-release/native_posix.keymap | 5 ++ .../keypress/kp-press-release/events.patterns | 1 + .../kp-press-release/keycode_events.snapshot | 2 + .../keypress/kp-press-release/native_posix.keymap | 8 +++ 15 files changed, 90 insertions(+), 80 deletions(-) create mode 100644 app/include/dt-bindings/zmk/kscan-mock.h delete mode 100644 app/include/zmk/kscan-mock.h create mode 100644 app/prj.conf create mode 100755 app/run-test.sh create mode 100644 app/tests/keypress/behavior_keymap.dtsi create mode 100644 app/tests/keypress/cp-press-release/events.patterns create mode 100644 app/tests/keypress/cp-press-release/keycode_events.snapshot create mode 100644 app/tests/keypress/cp-press-release/native_posix.keymap create mode 100644 app/tests/keypress/kp-press-release/events.patterns create mode 100644 app/tests/keypress/kp-press-release/keycode_events.snapshot create mode 100644 app/tests/keypress/kp-press-release/native_posix.keymap diff --git a/app/boards/native_posix.conf b/app/boards/native_posix.conf index 5bfb366..357b1b8 100644 --- a/app/boards/native_posix.conf +++ b/app/boards/native_posix.conf @@ -1,9 +1,8 @@ CONFIG_KSCAN=n CONFIG_ZMK_KSCAN_MOCK_DRIVER=y -CONFIG_ZMK_KSCAN_COMPOSITE_DRIVER=y CONFIG_ZMK_KSCAN_GPIO_DRIVER=n CONFIG_GPIO=n CONFIG_ZMK_BLE=n CONFIG_LOG=y -CONFIG_KSCAN_LOG_LEVEL_DBG=y +CONFIG_LOG_BACKEND_SHOW_COLOR=n CONFIG_ZMK_LOG_LEVEL_DBG=y diff --git a/app/boards/native_posix.overlay b/app/boards/native_posix.overlay index e9c4c95..bbb23b6 100644 --- a/app/boards/native_posix.overlay +++ b/app/boards/native_posix.overlay @@ -1,79 +1,18 @@ -#include #include -#include +#include +#include / { chosen { - zmk,kscan = &kscan0; - zmk,keymap = &keymap0; - }; - - kscan0: kscan_0 { - compatible = "zmk,kscan-composite"; - label = "KSCAN_COMP"; - rows = <2>; - columns = <4>; - - left: left { - kscan = <&left_hand>; - }; - - right: right { - kscan = <&right_hand>; - column-offset = <2>; - }; + zmk,kscan = &kscan; }; - left_hand: kscan_1 { + kscan: kscan { compatible = "zmk,kscan-mock"; - label = "KSCAN_LEFT"; + label = "KSCAN_MOCK"; rows = <2>; columns = <2>; - events = ; - // events = ; - }; - - right_hand: kscan_2 { - compatible = "zmk,kscan-mock"; - label = "KSCAN_RIGHT"; - - rows = <2>; - columns = <2>; - events = ; - }; - - keymap0: keymap { - compatible = "zmk,keymap"; - label ="Default keymap"; - layers = <&default &lower &raise>; - }; - - layers { - compatible = "zmk,layers"; - - default: layer_0 { - label = "DEFAULT"; - - bindings = < - &kp B &mo 1 &kp C &kp E - &kp D &kp G &kp F &kp Q>; - }; - - lower: layer_1 { - label = "LOWER"; - - bindings = < - &cp M_NEXT &trans &kp O &kp Q - &kp L &kp J &kp P &kp K>; - }; - - raise: layer_2 { - label = "RAISE"; - - bindings = < - &kp W &kp U &kp I &kp N - &kp X &kp M &kp C &kp B>; - }; + exit-after; }; }; diff --git a/app/dts/bindings/zmk,kscan-mock.yaml b/app/dts/bindings/zmk,kscan-mock.yaml index 41dd5b8..f9d83fa 100644 --- a/app/dts/bindings/zmk,kscan-mock.yaml +++ b/app/dts/bindings/zmk,kscan-mock.yaml @@ -15,3 +15,5 @@ properties: type: int columns: type: int + exit-after: + type: boolean diff --git a/app/include/dt-bindings/zmk/kscan-mock.h b/app/include/dt-bindings/zmk/kscan-mock.h new file mode 100644 index 0000000..d481899 --- /dev/null +++ b/app/include/dt-bindings/zmk/kscan-mock.h @@ -0,0 +1,8 @@ +#pragma once + +#define ZMK_MOCK_IS_PRESS(v) ((v & (0x01 << 31)) != 0) +#define ZMK_MOCK_PRESS(row, col, msec) (row + (col << 8) + (msec << 16) + (0x01 << 31)) +#define ZMK_MOCK_RELEASE(row, col, msec) (row + (col << 8) + (msec << 16)) +#define ZMK_MOCK_ROW(v) (v & 0xFF) +#define ZMK_MOCK_COL(v) ((v >> 8) & 0xFF) +#define ZMK_MOCK_MSEC(v) ((v & ~(0x01 << 31)) >> 16) diff --git a/app/include/zmk/kscan-mock.h b/app/include/zmk/kscan-mock.h deleted file mode 100644 index d481899..0000000 --- a/app/include/zmk/kscan-mock.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -#define ZMK_MOCK_IS_PRESS(v) ((v & (0x01 << 31)) != 0) -#define ZMK_MOCK_PRESS(row, col, msec) (row + (col << 8) + (msec << 16) + (0x01 << 31)) -#define ZMK_MOCK_RELEASE(row, col, msec) (row + (col << 8) + (msec << 16)) -#define ZMK_MOCK_ROW(v) (v & 0xFF) -#define ZMK_MOCK_COL(v) ((v >> 8) & 0xFF) -#define ZMK_MOCK_MSEC(v) ((v & ~(0x01 << 31)) >> 16) diff --git a/app/prj.conf b/app/prj.conf new file mode 100644 index 0000000..e69de29 diff --git a/app/run-test.sh b/app/run-test.sh new file mode 100755 index 0000000..4ed12a2 --- /dev/null +++ b/app/run-test.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +if [ -z "$1" ]; then + echo "Usage: ./run-test.sh " + exit 1 +elif [ "$1" = "all" ]; then + find tests -name native_posix.keymap -exec dirname \{\} \; | xargs -l -P 2 ./run-test.sh + exit $? +fi + +testcase="$1" +echo "Running $testcase:" + +west build --pristine -d build/$testcase -b native_posix -- -DZMK_CONFIG=$testcase > /dev/null +./build/$testcase/zephyr/zmk.exe | sed -e "s/.*> //" | sed -n -f $testcase/events.patterns > build/$testcase/keycode_events.log + +diff -au $testcase/keycode_events.snapshot build/$testcase/keycode_events.log diff --git a/app/src/kscan_mock.c b/app/src/kscan_mock.c index b0ba90b..1bd8a74 100644 --- a/app/src/kscan_mock.c +++ b/app/src/kscan_mock.c @@ -6,13 +6,14 @@ #define DT_DRV_COMPAT zmk_kscan_mock +#include #include #include #include LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); -#include +#include struct kscan_mock_data { @@ -50,6 +51,7 @@ static int kscan_mock_configure(struct device *dev, kscan_callback_t callback) struct kscan_mock_config_##n \ { \ u32_t events[DT_INST_PROP_LEN(n, events)]; \ + bool exit_after; \ }; \ static void kscan_mock_schedule_next_event_##n(struct device *dev) \ { \ @@ -60,6 +62,9 @@ static int kscan_mock_configure(struct device *dev, kscan_callback_t callback) u32_t ev = cfg->events[data->event_index]; \ LOG_DBG("delaying next keypress: %d", ZMK_MOCK_MSEC(ev)); \ k_delayed_work_submit(&data->work, K_MSEC(ZMK_MOCK_MSEC(ev))); \ + } else if (cfg->exit_after) { \ + LOG_DBG("Exiting"); \ + exit(0); \ } \ } \ static void kscan_mock_work_handler_##n(struct k_work *work) \ @@ -93,11 +98,12 @@ static int kscan_mock_configure(struct device *dev, kscan_callback_t callback) }; \ static struct kscan_mock_data kscan_mock_data_##n; \ static const struct kscan_mock_config_##n kscan_mock_config_##n = { \ - .events = DT_INST_PROP(n, events)}; \ + .events = DT_INST_PROP(n, events), \ + .exit_after = DT_INST_PROP(n, exit_after) }; \ DEVICE_AND_API_INIT(kscan_mock_##n, DT_INST_LABEL(n), kscan_mock_init_##n, \ &kscan_mock_data_##n, \ &kscan_mock_config_##n, \ APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, \ &mock_driver_api_##n); -DT_INST_FOREACH_STATUS_OKAY(MOCK_INST_INIT) \ No newline at end of file +DT_INST_FOREACH_STATUS_OKAY(MOCK_INST_INIT) diff --git a/app/tests/keypress/behavior_keymap.dtsi b/app/tests/keypress/behavior_keymap.dtsi new file mode 100644 index 0000000..34c445c --- /dev/null +++ b/app/tests/keypress/behavior_keymap.dtsi @@ -0,0 +1,28 @@ +#include +#include +#include + +/ { + keymap { + compatible = "zmk,keymap"; + label ="Default keymap"; + + default_layer { + bindings = < + &kp B &mo 1 + &kp D &kp G>; + }; + + lower_layer { + bindings = < + &cp M_NEXT &trans + &kp L &kp J>; + }; + + raise_layer { + bindings = < + &kp W &kp U + &kp X &kp M>; + }; + }; +}; diff --git a/app/tests/keypress/cp-press-release/events.patterns b/app/tests/keypress/cp-press-release/events.patterns new file mode 100644 index 0000000..833100f --- /dev/null +++ b/app/tests/keypress/cp-press-release/events.patterns @@ -0,0 +1 @@ +s/.*hid_listener_keycode_//p \ No newline at end of file diff --git a/app/tests/keypress/cp-press-release/keycode_events.snapshot b/app/tests/keypress/cp-press-release/keycode_events.snapshot new file mode 100644 index 0000000..f1ef0ed --- /dev/null +++ b/app/tests/keypress/cp-press-release/keycode_events.snapshot @@ -0,0 +1,2 @@ +pressed: usage_page 0x0c keycode 0xb5 +released: usage_page 0x0c keycode 0xb5 diff --git a/app/tests/keypress/cp-press-release/native_posix.keymap b/app/tests/keypress/cp-press-release/native_posix.keymap new file mode 100644 index 0000000..7f9ae8a --- /dev/null +++ b/app/tests/keypress/cp-press-release/native_posix.keymap @@ -0,0 +1,5 @@ +#include "../behavior_keymap.dtsi" + +&kscan { + events = ; +}; \ No newline at end of file diff --git a/app/tests/keypress/kp-press-release/events.patterns b/app/tests/keypress/kp-press-release/events.patterns new file mode 100644 index 0000000..833100f --- /dev/null +++ b/app/tests/keypress/kp-press-release/events.patterns @@ -0,0 +1 @@ +s/.*hid_listener_keycode_//p \ No newline at end of file diff --git a/app/tests/keypress/kp-press-release/keycode_events.snapshot b/app/tests/keypress/kp-press-release/keycode_events.snapshot new file mode 100644 index 0000000..f1ef0ed --- /dev/null +++ b/app/tests/keypress/kp-press-release/keycode_events.snapshot @@ -0,0 +1,2 @@ +pressed: usage_page 0x0c keycode 0xb5 +released: usage_page 0x0c keycode 0xb5 diff --git a/app/tests/keypress/kp-press-release/native_posix.keymap b/app/tests/keypress/kp-press-release/native_posix.keymap new file mode 100644 index 0000000..235348e --- /dev/null +++ b/app/tests/keypress/kp-press-release/native_posix.keymap @@ -0,0 +1,8 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = ; +}; \ No newline at end of file -- cgit v1.2.3 From 5b21f15a0a3e2d27d57b7a657d031a66d1124701 Mon Sep 17 00:00:00 2001 From: Cody McGinnis Date: Fri, 28 Aug 2020 16:21:31 -0400 Subject: fix(test): off by one error with kscan processing --- app/src/kscan_mock.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/kscan_mock.c b/app/src/kscan_mock.c index 1bd8a74..d626c71 100644 --- a/app/src/kscan_mock.c +++ b/app/src/kscan_mock.c @@ -72,12 +72,13 @@ static int kscan_mock_configure(struct device *dev, kscan_callback_t callback) struct kscan_mock_data *data = \ CONTAINER_OF(work, struct kscan_mock_data, work); \ const struct kscan_mock_config_##n *cfg = data->dev->config_info; \ - u32_t ev = cfg->events[data->event_index++]; \ + u32_t ev = cfg->events[data->event_index]; \ LOG_DBG("ev %u row %d column %d state %d\n", ev, \ ZMK_MOCK_ROW(ev), ZMK_MOCK_COL(ev), ZMK_MOCK_IS_PRESS(ev)); \ data->callback(data->dev, \ ZMK_MOCK_ROW(ev), ZMK_MOCK_COL(ev), ZMK_MOCK_IS_PRESS(ev)); \ kscan_mock_schedule_next_event_##n(data->dev); \ + data->event_index++; \ } \ static int kscan_mock_init_##n(struct device *dev) \ { \ -- cgit v1.2.3 From 5f56266a6953dd1ebeb95ded4213e74f9572ae4d Mon Sep 17 00:00:00 2001 From: Cody McGinnis Date: Fri, 28 Aug 2020 16:21:31 -0400 Subject: feat(test): add tests for momentary layers --- app/tests/momentary-layer/behavior_keymap.dtsi | 28 ++++++++++++++++++++++ .../early-key-release/events.patterns | 2 ++ .../early-key-release/keycode_events.snapshot | 4 ++++ .../early-key-release/native_posix.keymap | 8 +++++++ app/tests/momentary-layer/normal/events.patterns | 2 ++ .../momentary-layer/normal/keycode_events.snapshot | 4 ++++ .../momentary-layer/normal/native_posix.keymap | 8 +++++++ 7 files changed, 56 insertions(+) create mode 100644 app/tests/momentary-layer/behavior_keymap.dtsi create mode 100644 app/tests/momentary-layer/early-key-release/events.patterns create mode 100644 app/tests/momentary-layer/early-key-release/keycode_events.snapshot create mode 100644 app/tests/momentary-layer/early-key-release/native_posix.keymap create mode 100644 app/tests/momentary-layer/normal/events.patterns create mode 100644 app/tests/momentary-layer/normal/keycode_events.snapshot create mode 100644 app/tests/momentary-layer/normal/native_posix.keymap diff --git a/app/tests/momentary-layer/behavior_keymap.dtsi b/app/tests/momentary-layer/behavior_keymap.dtsi new file mode 100644 index 0000000..34c445c --- /dev/null +++ b/app/tests/momentary-layer/behavior_keymap.dtsi @@ -0,0 +1,28 @@ +#include +#include +#include + +/ { + keymap { + compatible = "zmk,keymap"; + label ="Default keymap"; + + default_layer { + bindings = < + &kp B &mo 1 + &kp D &kp G>; + }; + + lower_layer { + bindings = < + &cp M_NEXT &trans + &kp L &kp J>; + }; + + raise_layer { + bindings = < + &kp W &kp U + &kp X &kp M>; + }; + }; +}; diff --git a/app/tests/momentary-layer/early-key-release/events.patterns b/app/tests/momentary-layer/early-key-release/events.patterns new file mode 100644 index 0000000..bd7b488 --- /dev/null +++ b/app/tests/momentary-layer/early-key-release/events.patterns @@ -0,0 +1,2 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p \ No newline at end of file diff --git a/app/tests/momentary-layer/early-key-release/keycode_events.snapshot b/app/tests/momentary-layer/early-key-release/keycode_events.snapshot new file mode 100644 index 0000000..474eef7 --- /dev/null +++ b/app/tests/momentary-layer/early-key-release/keycode_events.snapshot @@ -0,0 +1,4 @@ +kp_pressed: usage_page 0x07 keycode 0x05 +mo_pressed: position 1 layer 1 +kp_released: usage_page 0x07 keycode 0x05 +mo_released: position 1 layer 1 diff --git a/app/tests/momentary-layer/early-key-release/native_posix.keymap b/app/tests/momentary-layer/early-key-release/native_posix.keymap new file mode 100644 index 0000000..a58ad26 --- /dev/null +++ b/app/tests/momentary-layer/early-key-release/native_posix.keymap @@ -0,0 +1,8 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = ; +}; \ No newline at end of file diff --git a/app/tests/momentary-layer/normal/events.patterns b/app/tests/momentary-layer/normal/events.patterns new file mode 100644 index 0000000..bd7b488 --- /dev/null +++ b/app/tests/momentary-layer/normal/events.patterns @@ -0,0 +1,2 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p \ No newline at end of file diff --git a/app/tests/momentary-layer/normal/keycode_events.snapshot b/app/tests/momentary-layer/normal/keycode_events.snapshot new file mode 100644 index 0000000..f3fca66 --- /dev/null +++ b/app/tests/momentary-layer/normal/keycode_events.snapshot @@ -0,0 +1,4 @@ +mo_pressed: position 1 layer 1 +kp_pressed: usage_page 0x0c keycode 0xb5 +kp_released: usage_page 0x0c keycode 0xb5 +mo_released: position 1 layer 1 \ No newline at end of file diff --git a/app/tests/momentary-layer/normal/native_posix.keymap b/app/tests/momentary-layer/normal/native_posix.keymap new file mode 100644 index 0000000..1b67858 --- /dev/null +++ b/app/tests/momentary-layer/normal/native_posix.keymap @@ -0,0 +1,8 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = ; +}; \ No newline at end of file -- cgit v1.2.3 From f1224422c502cb86c9138c42e28eb645fe62272f Mon Sep 17 00:00:00 2001 From: Cody McGinnis Date: Fri, 28 Aug 2020 16:21:31 -0400 Subject: fix(test): stop using pristine and use 4 threads --- app/run-test.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/run-test.sh b/app/run-test.sh index 4ed12a2..722cb93 100755 --- a/app/run-test.sh +++ b/app/run-test.sh @@ -4,14 +4,14 @@ if [ -z "$1" ]; then echo "Usage: ./run-test.sh " exit 1 elif [ "$1" = "all" ]; then - find tests -name native_posix.keymap -exec dirname \{\} \; | xargs -l -P 2 ./run-test.sh + find tests -name native_posix.keymap -exec dirname \{\} \; | xargs -l -P 4 ./run-test.sh exit $? fi testcase="$1" echo "Running $testcase:" -west build --pristine -d build/$testcase -b native_posix -- -DZMK_CONFIG=$testcase > /dev/null +west build -d build/$testcase -b native_posix -- -DZMK_CONFIG=$testcase > /dev/null ./build/$testcase/zephyr/zmk.exe | sed -e "s/.*> //" | sed -n -f $testcase/events.patterns > build/$testcase/keycode_events.log diff -au $testcase/keycode_events.snapshot build/$testcase/keycode_events.log -- cgit v1.2.3 From de92bf2b2de4a895dd36cffb549772f48428a0db Mon Sep 17 00:00:00 2001 From: Cody McGinnis Date: Fri, 28 Aug 2020 16:21:31 -0400 Subject: fix(test): use a smaller value for mock key intervals --- app/tests/keypress/cp-press-release/native_posix.keymap | 2 +- app/tests/keypress/kp-press-release/native_posix.keymap | 2 +- app/tests/momentary-layer/early-key-release/native_posix.keymap | 2 +- app/tests/momentary-layer/normal/native_posix.keymap | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/tests/keypress/cp-press-release/native_posix.keymap b/app/tests/keypress/cp-press-release/native_posix.keymap index 7f9ae8a..0e86f93 100644 --- a/app/tests/keypress/cp-press-release/native_posix.keymap +++ b/app/tests/keypress/cp-press-release/native_posix.keymap @@ -1,5 +1,5 @@ #include "../behavior_keymap.dtsi" &kscan { - events = ; + events = ; }; \ No newline at end of file diff --git a/app/tests/keypress/kp-press-release/native_posix.keymap b/app/tests/keypress/kp-press-release/native_posix.keymap index 235348e..7f73690 100644 --- a/app/tests/keypress/kp-press-release/native_posix.keymap +++ b/app/tests/keypress/kp-press-release/native_posix.keymap @@ -4,5 +4,5 @@ #include "../behavior_keymap.dtsi" &kscan { - events = ; + events = ; }; \ No newline at end of file diff --git a/app/tests/momentary-layer/early-key-release/native_posix.keymap b/app/tests/momentary-layer/early-key-release/native_posix.keymap index a58ad26..e7628c0 100644 --- a/app/tests/momentary-layer/early-key-release/native_posix.keymap +++ b/app/tests/momentary-layer/early-key-release/native_posix.keymap @@ -4,5 +4,5 @@ #include "../behavior_keymap.dtsi" &kscan { - events = ; + events = ; }; \ No newline at end of file diff --git a/app/tests/momentary-layer/normal/native_posix.keymap b/app/tests/momentary-layer/normal/native_posix.keymap index 1b67858..7f73690 100644 --- a/app/tests/momentary-layer/normal/native_posix.keymap +++ b/app/tests/momentary-layer/normal/native_posix.keymap @@ -4,5 +4,5 @@ #include "../behavior_keymap.dtsi" &kscan { - events = ; + events = ; }; \ No newline at end of file -- cgit v1.2.3 From abf8b5abfae2c240e71db11f13183369a14333d7 Mon Sep 17 00:00:00 2001 From: Cody McGinnis Date: Fri, 28 Aug 2020 16:21:31 -0400 Subject: fix(test): fix normal momentary-layer test snapshot --- app/tests/momentary-layer/normal/keycode_events.snapshot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/tests/momentary-layer/normal/keycode_events.snapshot b/app/tests/momentary-layer/normal/keycode_events.snapshot index f3fca66..9dc6101 100644 --- a/app/tests/momentary-layer/normal/keycode_events.snapshot +++ b/app/tests/momentary-layer/normal/keycode_events.snapshot @@ -1,4 +1,4 @@ mo_pressed: position 1 layer 1 kp_pressed: usage_page 0x0c keycode 0xb5 kp_released: usage_page 0x0c keycode 0xb5 -mo_released: position 1 layer 1 \ No newline at end of file +mo_released: position 1 layer 1 -- cgit v1.2.3 From 3d325ccb84ecd3b25dd86d829c448dfd9b41a08f Mon Sep 17 00:00:00 2001 From: Cody McGinnis Date: Fri, 28 Aug 2020 16:21:31 -0400 Subject: feat(test): add tests for none behavior --- app/tests/none/behavior_keymap.dtsi | 22 ++++++++++++++++++++++ app/tests/none/layered/events.patterns | 1 + app/tests/none/layered/keycode_events.snapshot | 0 app/tests/none/layered/native_posix.keymap | 8 ++++++++ app/tests/none/normal/events.patterns | 1 + app/tests/none/normal/keycode_events.snapshot | 0 app/tests/none/normal/native_posix.keymap | 8 ++++++++ 7 files changed, 40 insertions(+) create mode 100644 app/tests/none/behavior_keymap.dtsi create mode 100644 app/tests/none/layered/events.patterns create mode 100644 app/tests/none/layered/keycode_events.snapshot create mode 100644 app/tests/none/layered/native_posix.keymap create mode 100644 app/tests/none/normal/events.patterns create mode 100644 app/tests/none/normal/keycode_events.snapshot create mode 100644 app/tests/none/normal/native_posix.keymap diff --git a/app/tests/none/behavior_keymap.dtsi b/app/tests/none/behavior_keymap.dtsi new file mode 100644 index 0000000..0a4f7cb --- /dev/null +++ b/app/tests/none/behavior_keymap.dtsi @@ -0,0 +1,22 @@ +#include +#include +#include + +/ { + keymap { + compatible = "zmk,keymap"; + label ="Default keymap"; + + default_layer { + bindings = < + &none &mo 1 + &kp A &none>; + }; + + lower_layer { + bindings = < + &none &trans + &none &kp A>; + }; + }; +}; diff --git a/app/tests/none/layered/events.patterns b/app/tests/none/layered/events.patterns new file mode 100644 index 0000000..3c9d3f8 --- /dev/null +++ b/app/tests/none/layered/events.patterns @@ -0,0 +1 @@ +s/.*hid_listener_keycode/kp/p \ No newline at end of file diff --git a/app/tests/none/layered/keycode_events.snapshot b/app/tests/none/layered/keycode_events.snapshot new file mode 100644 index 0000000..e69de29 diff --git a/app/tests/none/layered/native_posix.keymap b/app/tests/none/layered/native_posix.keymap new file mode 100644 index 0000000..59ea481 --- /dev/null +++ b/app/tests/none/layered/native_posix.keymap @@ -0,0 +1,8 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = ; +}; \ No newline at end of file diff --git a/app/tests/none/normal/events.patterns b/app/tests/none/normal/events.patterns new file mode 100644 index 0000000..3c9d3f8 --- /dev/null +++ b/app/tests/none/normal/events.patterns @@ -0,0 +1 @@ +s/.*hid_listener_keycode/kp/p \ No newline at end of file diff --git a/app/tests/none/normal/keycode_events.snapshot b/app/tests/none/normal/keycode_events.snapshot new file mode 100644 index 0000000..e69de29 diff --git a/app/tests/none/normal/native_posix.keymap b/app/tests/none/normal/native_posix.keymap new file mode 100644 index 0000000..94d7539 --- /dev/null +++ b/app/tests/none/normal/native_posix.keymap @@ -0,0 +1,8 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = ; +}; \ No newline at end of file -- cgit v1.2.3 From 033bb7bfc4e1772ea19784bd71a57f49b4368e2d Mon Sep 17 00:00:00 2001 From: Cody McGinnis Date: Fri, 28 Aug 2020 16:21:31 -0400 Subject: fix(behavior): add logging to toggle layer for tests --- app/src/behaviors/behavior_toggle_layer.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/app/src/behaviors/behavior_toggle_layer.c b/app/src/behaviors/behavior_toggle_layer.c index 13f4a29..02a76d2 100644 --- a/app/src/behaviors/behavior_toggle_layer.c +++ b/app/src/behaviors/behavior_toggle_layer.c @@ -14,28 +14,35 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); -struct behavior_tog_config { }; -struct behavior_tog_data { }; +struct behavior_tog_config +{ +}; +struct behavior_tog_data +{ +}; static int behavior_tog_init(struct device *dev) { - return 0; + return 0; }; - static int tog_keymap_binding_pressed(struct device *dev, u32_t position, u32_t layer, u32_t _) { + LOG_DBG("position %d layer %d", position, layer); + return zmk_keymap_layer_toggle(layer); } static int tog_keymap_binding_released(struct device *dev, u32_t position, u32_t layer, u32_t _) { + LOG_DBG("position %d layer %d", position, layer); + return 0; } static const struct behavior_driver_api behavior_tog_driver_api = { - .binding_pressed = tog_keymap_binding_pressed, - .binding_released = tog_keymap_binding_released, + .binding_pressed = tog_keymap_binding_pressed, + .binding_released = tog_keymap_binding_released, }; static const struct behavior_tog_config behavior_tog_config = {}; -- cgit v1.2.3 From a722cbcea37e276a1778c6b0d0e3154fbe70334f Mon Sep 17 00:00:00 2001 From: Cody McGinnis Date: Fri, 28 Aug 2020 16:21:31 -0400 Subject: feat(test): add tests for toggle layer --- app/tests/toggle-layer/behavior_keymap.dtsi | 28 ++++++++++++++++++++++ .../toggle-layer/early-key-release/events.patterns | 2 ++ .../early-key-release/keycode_events.snapshot | 6 +++++ .../early-key-release/native_posix.keymap | 9 +++++++ app/tests/toggle-layer/normal/events.patterns | 2 ++ .../toggle-layer/normal/keycode_events.snapshot | 4 ++++ app/tests/toggle-layer/normal/native_posix.keymap | 8 +++++++ 7 files changed, 59 insertions(+) create mode 100644 app/tests/toggle-layer/behavior_keymap.dtsi create mode 100644 app/tests/toggle-layer/early-key-release/events.patterns create mode 100644 app/tests/toggle-layer/early-key-release/keycode_events.snapshot create mode 100644 app/tests/toggle-layer/early-key-release/native_posix.keymap create mode 100644 app/tests/toggle-layer/normal/events.patterns create mode 100644 app/tests/toggle-layer/normal/keycode_events.snapshot create mode 100644 app/tests/toggle-layer/normal/native_posix.keymap diff --git a/app/tests/toggle-layer/behavior_keymap.dtsi b/app/tests/toggle-layer/behavior_keymap.dtsi new file mode 100644 index 0000000..d2b41a9 --- /dev/null +++ b/app/tests/toggle-layer/behavior_keymap.dtsi @@ -0,0 +1,28 @@ +#include +#include +#include + +/ { + keymap { + compatible = "zmk,keymap"; + label ="Default keymap"; + + default_layer { + bindings = < + &kp B &tog 1 + &kp D &kp G>; + }; + + lower_layer { + bindings = < + &cp M_NEXT &trans + &kp L &kp J>; + }; + + raise_layer { + bindings = < + &kp W &kp U + &kp X &kp M>; + }; + }; +}; diff --git a/app/tests/toggle-layer/early-key-release/events.patterns b/app/tests/toggle-layer/early-key-release/events.patterns new file mode 100644 index 0000000..397fef4 --- /dev/null +++ b/app/tests/toggle-layer/early-key-release/events.patterns @@ -0,0 +1,2 @@ +s/.*hid_listener_keycode/kp/p +s/.*tog_keymap_binding/tog/p \ No newline at end of file diff --git a/app/tests/toggle-layer/early-key-release/keycode_events.snapshot b/app/tests/toggle-layer/early-key-release/keycode_events.snapshot new file mode 100644 index 0000000..3ac017c --- /dev/null +++ b/app/tests/toggle-layer/early-key-release/keycode_events.snapshot @@ -0,0 +1,6 @@ +kp_pressed: usage_page 0x07 keycode 0x05 +tog_pressed: position 1 layer 1 +kp_released: usage_page 0x07 keycode 0x05 +tog_released: position 1 layer 1 +kp_pressed: usage_page 0x0c keycode 0xb5 +kp_released: usage_page 0x0c keycode 0xb5 diff --git a/app/tests/toggle-layer/early-key-release/native_posix.keymap b/app/tests/toggle-layer/early-key-release/native_posix.keymap new file mode 100644 index 0000000..6b2b8f2 --- /dev/null +++ b/app/tests/toggle-layer/early-key-release/native_posix.keymap @@ -0,0 +1,9 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = ; +}; \ No newline at end of file diff --git a/app/tests/toggle-layer/normal/events.patterns b/app/tests/toggle-layer/normal/events.patterns new file mode 100644 index 0000000..397fef4 --- /dev/null +++ b/app/tests/toggle-layer/normal/events.patterns @@ -0,0 +1,2 @@ +s/.*hid_listener_keycode/kp/p +s/.*tog_keymap_binding/tog/p \ No newline at end of file diff --git a/app/tests/toggle-layer/normal/keycode_events.snapshot b/app/tests/toggle-layer/normal/keycode_events.snapshot new file mode 100644 index 0000000..42174cc --- /dev/null +++ b/app/tests/toggle-layer/normal/keycode_events.snapshot @@ -0,0 +1,4 @@ +tog_pressed: position 1 layer 1 +tog_released: position 1 layer 1 +kp_pressed: usage_page 0x0c keycode 0xb5 +kp_released: usage_page 0x0c keycode 0xb5 diff --git a/app/tests/toggle-layer/normal/native_posix.keymap b/app/tests/toggle-layer/normal/native_posix.keymap new file mode 100644 index 0000000..202c105 --- /dev/null +++ b/app/tests/toggle-layer/normal/native_posix.keymap @@ -0,0 +1,8 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = ; +}; \ No newline at end of file -- cgit v1.2.3 From e2f77f25c8212856a5b3b3995b8e9199b59c2650 Mon Sep 17 00:00:00 2001 From: Cody McGinnis Date: Fri, 28 Aug 2020 16:21:31 -0400 Subject: feat(test): add testing for transparent --- app/tests/transparent/behavior_keymap.dtsi | 22 ++++++++++++++++++++++ app/tests/transparent/layered/events.patterns | 1 + .../transparent/layered/keycode_events.snapshot | 2 ++ app/tests/transparent/layered/native_posix.keymap | 8 ++++++++ app/tests/transparent/normal/events.patterns | 1 + .../transparent/normal/keycode_events.snapshot | 0 app/tests/transparent/normal/native_posix.keymap | 8 ++++++++ 7 files changed, 42 insertions(+) create mode 100644 app/tests/transparent/behavior_keymap.dtsi create mode 100644 app/tests/transparent/layered/events.patterns create mode 100644 app/tests/transparent/layered/keycode_events.snapshot create mode 100644 app/tests/transparent/layered/native_posix.keymap create mode 100644 app/tests/transparent/normal/events.patterns create mode 100644 app/tests/transparent/normal/keycode_events.snapshot create mode 100644 app/tests/transparent/normal/native_posix.keymap diff --git a/app/tests/transparent/behavior_keymap.dtsi b/app/tests/transparent/behavior_keymap.dtsi new file mode 100644 index 0000000..d6c5e27 --- /dev/null +++ b/app/tests/transparent/behavior_keymap.dtsi @@ -0,0 +1,22 @@ +#include +#include +#include + +/ { + keymap { + compatible = "zmk,keymap"; + label ="Default keymap"; + + default_layer { + bindings = < + &trans &mo 1 + &kp A &none>; + }; + + lower_layer { + bindings = < + &trans &trans + &trans &kp A>; + }; + }; +}; diff --git a/app/tests/transparent/layered/events.patterns b/app/tests/transparent/layered/events.patterns new file mode 100644 index 0000000..3c9d3f8 --- /dev/null +++ b/app/tests/transparent/layered/events.patterns @@ -0,0 +1 @@ +s/.*hid_listener_keycode/kp/p \ No newline at end of file diff --git a/app/tests/transparent/layered/keycode_events.snapshot b/app/tests/transparent/layered/keycode_events.snapshot new file mode 100644 index 0000000..d0bd245 --- /dev/null +++ b/app/tests/transparent/layered/keycode_events.snapshot @@ -0,0 +1,2 @@ +kp_pressed: usage_page 0x07 keycode 0x04 +kp_released: usage_page 0x07 keycode 0x04 diff --git a/app/tests/transparent/layered/native_posix.keymap b/app/tests/transparent/layered/native_posix.keymap new file mode 100644 index 0000000..59ea481 --- /dev/null +++ b/app/tests/transparent/layered/native_posix.keymap @@ -0,0 +1,8 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = ; +}; \ No newline at end of file diff --git a/app/tests/transparent/normal/events.patterns b/app/tests/transparent/normal/events.patterns new file mode 100644 index 0000000..3c9d3f8 --- /dev/null +++ b/app/tests/transparent/normal/events.patterns @@ -0,0 +1 @@ +s/.*hid_listener_keycode/kp/p \ No newline at end of file diff --git a/app/tests/transparent/normal/keycode_events.snapshot b/app/tests/transparent/normal/keycode_events.snapshot new file mode 100644 index 0000000..e69de29 diff --git a/app/tests/transparent/normal/native_posix.keymap b/app/tests/transparent/normal/native_posix.keymap new file mode 100644 index 0000000..94d7539 --- /dev/null +++ b/app/tests/transparent/normal/native_posix.keymap @@ -0,0 +1,8 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = ; +}; \ No newline at end of file -- cgit v1.2.3 From 79bff11ddd55204cf0ed4f43985e096a30cbf137 Mon Sep 17 00:00:00 2001 From: Cody McGinnis Date: Fri, 28 Aug 2020 16:21:31 -0400 Subject: fancier run test stuff --- app/run-test.sh | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/app/run-test.sh b/app/run-test.sh index 722cb93..d923e85 100755 --- a/app/run-test.sh +++ b/app/run-test.sh @@ -4,14 +4,25 @@ if [ -z "$1" ]; then echo "Usage: ./run-test.sh " exit 1 elif [ "$1" = "all" ]; then + echo "" > ./build/tests/pass-fail.log find tests -name native_posix.keymap -exec dirname \{\} \; | xargs -l -P 4 ./run-test.sh - exit $? + err=$? + sort -k2 ./build/tests/pass-fail.log + exit $err fi testcase="$1" echo "Running $testcase:" -west build -d build/$testcase -b native_posix -- -DZMK_CONFIG=$testcase > /dev/null -./build/$testcase/zephyr/zmk.exe | sed -e "s/.*> //" | sed -n -f $testcase/events.patterns > build/$testcase/keycode_events.log - -diff -au $testcase/keycode_events.snapshot build/$testcase/keycode_events.log +west build -d build/$testcase -b native_posix -- -DZMK_CONFIG=$testcase > /dev/null 2>&1 +if [ $? -gt 0 ]; then + echo "FAIL: $testcase did not build" >> ./build/tests/pass-fail.log +else + ./build/$testcase/zephyr/zmk.exe | sed -e "s/.*> //" | sed -n -f $testcase/events.patterns > build/$testcase/keycode_events.log + diff -au $testcase/keycode_events.snapshot build/$testcase/keycode_events.log + if [ $? -gt 0 ]; then + echo "FAIL: $testcase" >> ./build/tests/pass-fail.log + else + echo "PASS: $testcase" >> ./build/tests/pass-fail.log + fi +fi \ No newline at end of file -- cgit v1.2.3 From 4564d374776b0ade3c69bdddbf0a654aff38985e Mon Sep 17 00:00:00 2001 From: Cody McGinnis Date: Fri, 28 Aug 2020 16:21:31 -0400 Subject: feat(test): create simple docs for creating tests --- app/tests/Creating Tests.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 app/tests/Creating Tests.md diff --git a/app/tests/Creating Tests.md b/app/tests/Creating Tests.md new file mode 100644 index 0000000..5e211c0 --- /dev/null +++ b/app/tests/Creating Tests.md @@ -0,0 +1,23 @@ +# Basics +Any folder under `/app/tests` containing `native_posix.keymap` will be selected when running +`./run-test.sh all`. + +`test_case/events.patterns` contains sed patterns that will select the interesting output from the +application + +`test_case/keycode_events.snapshot` contains the expected output after applying `events.pattern` to +the output + +`test_case/native_posix.keymap` defines the keys and the mock key presses. Most tests include a +common keymap for their test set + +## Creating a New Test Set +1. Copy the test set that most closely resembles the tests you will be creating. +2. Rename the newly created test set to the behavior you're testing e.g, toggle-layer +3. Modify `behavior_keymap.dtsi` to create a keymap using the behavior and related behaviors +4. Modify `test_case/native_posix.keymap` for a simulated use case +5. Modify `test_case/events.patterns` to collect relevant logs to the test + - See: [sed manual](https://www.gnu.org/software/sed/manual/sed.html) and + [tutorial](https://www.digitalocean.com/community/tutorials/the-basics-of-using-the-sed-stream-editor-to-manipulate-text-in-linux) +6. Modify `test_case/keycode_events.snapshot` for to include the expected output +7. Repeat steps 4 to 6 for every test case \ No newline at end of file -- cgit v1.2.3 From aff39e57d041b9b3c895d3968912ef4fd9b6c6ce Mon Sep 17 00:00:00 2001 From: Cody McGinnis Date: Fri, 28 Aug 2020 16:21:31 -0400 Subject: fix: add license header to run-test.sh --- app/run-test.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/run-test.sh b/app/run-test.sh index d923e85..6c3e878 100755 --- a/app/run-test.sh +++ b/app/run-test.sh @@ -1,4 +1,9 @@ #!/bin/sh +# +# Copyright (c) 2020 Peter Johanson; Cody McGinnis +# +# SPDX-License-Identifier: MIT +# if [ -z "$1" ]; then echo "Usage: ./run-test.sh " -- cgit v1.2.3 From b1d9a7b68450438a7ac6bce26bf89dfdf00a4393 Mon Sep 17 00:00:00 2001 From: Cody McGinnis Date: Fri, 28 Aug 2020 16:21:31 -0400 Subject: feat(test): record full key log as well --- app/run-test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/run-test.sh b/app/run-test.sh index 6c3e878..53277ba 100755 --- a/app/run-test.sh +++ b/app/run-test.sh @@ -23,7 +23,7 @@ west build -d build/$testcase -b native_posix -- -DZMK_CONFIG=$testcase > /dev/n if [ $? -gt 0 ]; then echo "FAIL: $testcase did not build" >> ./build/tests/pass-fail.log else - ./build/$testcase/zephyr/zmk.exe | sed -e "s/.*> //" | sed -n -f $testcase/events.patterns > build/$testcase/keycode_events.log + ./build/$testcase/zephyr/zmk.exe | sed -e "s/.*> //" | tee build/$testcase/keycode_events_full.log | sed -n -f $testcase/events.patterns > build/$testcase/keycode_events.log diff -au $testcase/keycode_events.snapshot build/$testcase/keycode_events.log if [ $? -gt 0 ]; then echo "FAIL: $testcase" >> ./build/tests/pass-fail.log -- cgit v1.2.3 From 26414a69824a37a65c0fb3a6c423f4cb6c1ef068 Mon Sep 17 00:00:00 2001 From: Cody McGinnis Date: Fri, 28 Aug 2020 16:21:31 -0400 Subject: fix(docs): move testing docs to website docs --- app/tests/Creating Tests.md | 23 ----------------------- docs/docs/dev-tests.md | 23 +++++++++++++++++++++++ docs/sidebars.js | 1 + 3 files changed, 24 insertions(+), 23 deletions(-) delete mode 100644 app/tests/Creating Tests.md create mode 100644 docs/docs/dev-tests.md diff --git a/app/tests/Creating Tests.md b/app/tests/Creating Tests.md deleted file mode 100644 index 5e211c0..0000000 --- a/app/tests/Creating Tests.md +++ /dev/null @@ -1,23 +0,0 @@ -# Basics -Any folder under `/app/tests` containing `native_posix.keymap` will be selected when running -`./run-test.sh all`. - -`test_case/events.patterns` contains sed patterns that will select the interesting output from the -application - -`test_case/keycode_events.snapshot` contains the expected output after applying `events.pattern` to -the output - -`test_case/native_posix.keymap` defines the keys and the mock key presses. Most tests include a -common keymap for their test set - -## Creating a New Test Set -1. Copy the test set that most closely resembles the tests you will be creating. -2. Rename the newly created test set to the behavior you're testing e.g, toggle-layer -3. Modify `behavior_keymap.dtsi` to create a keymap using the behavior and related behaviors -4. Modify `test_case/native_posix.keymap` for a simulated use case -5. Modify `test_case/events.patterns` to collect relevant logs to the test - - See: [sed manual](https://www.gnu.org/software/sed/manual/sed.html) and - [tutorial](https://www.digitalocean.com/community/tutorials/the-basics-of-using-the-sed-stream-editor-to-manipulate-text-in-linux) -6. Modify `test_case/keycode_events.snapshot` for to include the expected output -7. Repeat steps 4 to 6 for every test case \ No newline at end of file diff --git a/docs/docs/dev-tests.md b/docs/docs/dev-tests.md new file mode 100644 index 0000000..1709ccd --- /dev/null +++ b/docs/docs/dev-tests.md @@ -0,0 +1,23 @@ +# Basics +Running tests requires native [posix support](./dev-posix-board). Any folder under `/app/tests` +containing `native_posix.keymap` will be selected when running `./run-test.sh all`. + +`test_case/events.patterns` contains sed patterns that will select the interesting output from the +application + +`test_case/keycode_events.snapshot` contains the expected output after applying `events.pattern` to +the output + +`test_case/native_posix.keymap` defines the keys and the mock key presses. Most tests include a +common keymap for their test set + +## Creating a New Test Set +1. Copy the test set that most closely resembles the tests you will be creating. +2. Rename the newly created test set to the behavior you're testing e.g, toggle-layer +3. Modify `behavior_keymap.dtsi` to create a keymap using the behavior and related behaviors +4. Modify `test_case/native_posix.keymap` for a simulated use case +5. Modify `test_case/events.patterns` to collect relevant logs to the test + - See: [sed manual](https://www.gnu.org/software/sed/manual/sed.html) and + [tutorial](https://www.digitalocean.com/community/tutorials/the-basics-of-using-the-sed-stream-editor-to-manipulate-text-in-linux) +6. Modify `test_case/keycode_events.snapshot` for to include the expected output +7. Repeat steps 4 to 6 for every test case \ No newline at end of file diff --git a/docs/sidebars.js b/docs/sidebars.js index 51313fc..d426667 100644 --- a/docs/sidebars.js +++ b/docs/sidebars.js @@ -20,6 +20,7 @@ module.exports = { "dev-setup", "dev-boards-shields-keymaps", "dev-posix-board", + "dev-tests", ], "Dev Guides": ["dev-guide-new-shield", "dev-guide-usb-logging"], }, -- cgit v1.2.3 From 205a54baeb75f631795c3de34948e5e9f1af0083 Mon Sep 17 00:00:00 2001 From: Cody McGinnis Date: Fri, 28 Aug 2020 16:21:31 -0400 Subject: fix(docs): update the testing docs --- docs/docs/dev-tests.md | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/docs/docs/dev-tests.md b/docs/docs/dev-tests.md index 1709ccd..68d4725 100644 --- a/docs/docs/dev-tests.md +++ b/docs/docs/dev-tests.md @@ -1,15 +1,11 @@ -# Basics -Running tests requires native [posix support](./dev-posix-board). Any folder under `/app/tests` -containing `native_posix.keymap` will be selected when running `./run-test.sh all`. - -`test_case/events.patterns` contains sed patterns that will select the interesting output from the -application +--- +id: dev-tests +title: Tests +sidebar_label: Tests +--- -`test_case/keycode_events.snapshot` contains the expected output after applying `events.pattern` to -the output - -`test_case/native_posix.keymap` defines the keys and the mock key presses. Most tests include a -common keymap for their test set +Running tests requires [native posix support](./dev-posix-board). Any folder under `/app/tests` +containing `native_posix.keymap` will be selected when running `./run-test.sh all`. ## Creating a New Test Set 1. Copy the test set that most closely resembles the tests you will be creating. @@ -20,4 +16,5 @@ common keymap for their test set - See: [sed manual](https://www.gnu.org/software/sed/manual/sed.html) and [tutorial](https://www.digitalocean.com/community/tutorials/the-basics-of-using-the-sed-stream-editor-to-manipulate-text-in-linux) 6. Modify `test_case/keycode_events.snapshot` for to include the expected output -7. Repeat steps 4 to 6 for every test case \ No newline at end of file +7. Rename the `test_case` folder to describe the test. +8. Repeat steps 4 to 7 for every test case \ No newline at end of file -- cgit v1.2.3 From 80bef160fcb3c2c63f11c71832c9afd959a1828c Mon Sep 17 00:00:00 2001 From: Cody McGinnis Date: Fri, 28 Aug 2020 16:28:49 -0400 Subject: feat(tests): allow tests to be marked as pending pending tests will not fail the build --- app/run-test.sh | 9 ++++++++- app/tests/momentary-layer/early-key-release/pending | 0 app/tests/toggle-layer/early-key-release/pending | 0 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 app/tests/momentary-layer/early-key-release/pending create mode 100644 app/tests/toggle-layer/early-key-release/pending diff --git a/app/run-test.sh b/app/run-test.sh index 53277ba..be335c6 100755 --- a/app/run-test.sh +++ b/app/run-test.sh @@ -26,8 +26,15 @@ else ./build/$testcase/zephyr/zmk.exe | sed -e "s/.*> //" | tee build/$testcase/keycode_events_full.log | sed -n -f $testcase/events.patterns > build/$testcase/keycode_events.log diff -au $testcase/keycode_events.snapshot build/$testcase/keycode_events.log if [ $? -gt 0 ]; then - echo "FAIL: $testcase" >> ./build/tests/pass-fail.log + if [ -f $testcase/pending ]; then + echo "PEND: $testcase" >> ./build/tests/pass-fail.log + exit 0 + else + echo "FAIL: $testcase" >> ./build/tests/pass-fail.log + exit 1 + fi else echo "PASS: $testcase" >> ./build/tests/pass-fail.log + exit 0 fi fi \ No newline at end of file diff --git a/app/tests/momentary-layer/early-key-release/pending b/app/tests/momentary-layer/early-key-release/pending new file mode 100644 index 0000000..e69de29 diff --git a/app/tests/toggle-layer/early-key-release/pending b/app/tests/toggle-layer/early-key-release/pending new file mode 100644 index 0000000..e69de29 -- cgit v1.2.3 From 887ba47cbe173ff65204b6f454e4070768994abf Mon Sep 17 00:00:00 2001 From: tominabox1 Date: Fri, 28 Aug 2020 16:38:40 -0500 Subject: Add copyright header --- app/boards/shields/qaz/qaz.keymap | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/boards/shields/qaz/qaz.keymap b/app/boards/shields/qaz/qaz.keymap index cebcd4b..ffa2f6c 100644 --- a/app/boards/shields/qaz/qaz.keymap +++ b/app/boards/shields/qaz/qaz.keymap @@ -1,3 +1,9 @@ +/* + * Copyright (c) 2020 TJ Campie + * + * SPDX-License-Identifier: MIT + */ + #include #include -- cgit v1.2.3 From 6475009da9baad358302fbff3db7d88d63f9ce50 Mon Sep 17 00:00:00 2001 From: Kevin Date: Fri, 28 Aug 2020 20:36:28 -0700 Subject: Added encoder and changed BT unpair keys in overlays --- app/boards/shields/lily58/lily58_left.overlay | 6 +++++- app/boards/shields/lily58/lily58_right.overlay | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/boards/shields/lily58/lily58_left.overlay b/app/boards/shields/lily58/lily58_left.overlay index c6f630f..1752b6e 100644 --- a/app/boards/shields/lily58/lily58_left.overlay +++ b/app/boards/shields/lily58/lily58_left.overlay @@ -17,6 +17,10 @@ ; }; +&left_encoder { + status = "okay"; +}; + &bt_unpair_combo { - key-positions = <0 42>; + key-positions = <0 53>; }; diff --git a/app/boards/shields/lily58/lily58_right.overlay b/app/boards/shields/lily58/lily58_right.overlay index 84f0b06..6c8e493 100644 --- a/app/boards/shields/lily58/lily58_right.overlay +++ b/app/boards/shields/lily58/lily58_right.overlay @@ -22,5 +22,5 @@ }; &bt_unpair_combo { - key-positions = <11 43>; + key-positions = <11 54>; }; -- cgit v1.2.3 From e616fc2c8124a98e2abe2279d952783ea98b5cd5 Mon Sep 17 00:00:00 2001 From: Kevin Date: Fri, 28 Aug 2020 20:36:43 -0700 Subject: Added left encoder support --- app/.gitignore | 3 +++ app/boards/shields/lily58/lily58.conf | 4 ++++ app/boards/shields/lily58/lily58.dtsi | 14 +++++++++++ app/boards/shields/lily58/lily58.keymap | 42 +++++++++++++++++++-------------- 4 files changed, 45 insertions(+), 18 deletions(-) diff --git a/app/.gitignore b/app/.gitignore index 567609b..73a4457 100644 --- a/app/.gitignore +++ b/app/.gitignore @@ -1 +1,4 @@ build/ +build_left.bat +flash.bat +prj.conf \ No newline at end of file diff --git a/app/boards/shields/lily58/lily58.conf b/app/boards/shields/lily58/lily58.conf index 73f0d9d..14c1841 100644 --- a/app/boards/shields/lily58/lily58.conf +++ b/app/boards/shields/lily58/lily58.conf @@ -1,2 +1,6 @@ +# Enable encoder +CONFIG_EC11=y +CONFIG_EC11_TRIGGER_GLOBAL_THREAD=y + # Uncomment the following line to enable the Lily58 OLED Display # CONFIG_ZMK_DISPLAY=y diff --git a/app/boards/shields/lily58/lily58.dtsi b/app/boards/shields/lily58/lily58.dtsi index 23f5644..aea36c8 100644 --- a/app/boards/shields/lily58/lily58.dtsi +++ b/app/boards/shields/lily58/lily58.dtsi @@ -45,6 +45,20 @@ RC(3,0) RC(3,1) RC(3,2) RC(3,3) RC(3,4) RC(3,5) RC(4,5) RC(4,6) RC(3,6) RC(3,7) }; + left_encoder: encoder_left { + compatible = "alps,ec11"; + label = "LEFT_ENCODER"; + a-gpios = <&pro_micro_a 3 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; + b-gpios = <&pro_micro_a 2 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; + resolution = <4>; + status = "disabled"; + }; + + sensors { + compatible = "zmk,keymap-sensors"; + sensors = <&left_encoder>; + }; + bt_unpair_combo: bt_unpair_combo { compatible = "zmk,bt-unpair-combo"; }; diff --git a/app/boards/shields/lily58/lily58.keymap b/app/boards/shields/lily58/lily58.keymap index 71bf4ad..590d7b6 100644 --- a/app/boards/shields/lily58/lily58.keymap +++ b/app/boards/shields/lily58/lily58.keymap @@ -16,41 +16,47 @@ &kp ESC &kp NUM_1 &kp NUM_2 &kp NUM_3 &kp NUM_4 &kp NUM_5 &kp NUM_6 &kp NUM_7 &kp NUM_8 &kp NUM_9 &kp NUM_0 &kp GRAV &kp TAB &kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P &kp MINUS &kp LCTL &kp A &kp S &kp D &kp F &kp G &kp H &kp J &kp K &kp L &kp SCLN &kp QUOT -&kp LSFT &kp Z &kp X &kp C &kp V &kp B &kp LBKT &kp RBKT &kp N &kp M &kp CMMA &kp DOT &kp FSLH &kp RSFT - &kp LALT &kp LGUI &mo 1 &kp SPC &kp RET &mo 2 &kp BKSP &kp RGUI +&kp LSFT &kp Z &kp X &kp C &kp V &kp B &cp M_PLAY &kp DEL &kp N &kp M &kp CMMA &kp DOT &kp FSLH &kp RSFT + &kp LGUI &kp LALT &kp BKSP &mo 1 &mo 2 &kp SPC &kp RET &kp RGUI >; + + sensor-bindings = <&inc_dec_cp LBKT RBKT>; }; lower_layer { // ------------------------------------------------------------------------------------------------------------ // | | | | | | | | | | | | | | -// | F1 | F2 | F3 | F4 | F5 | F6 | | F7 | F8 | F9 | F10 | F11 | F12 | -// | ` | ! | @ | # | $ | % | | ^ | & | * | ( | ) | ~ | -// | | | | | | | | | | | _ | + | { | } | "|" | +// | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | | +// | F1 | F2 | F3 | F4 | F5 | F6 | | | <- | ^ | v | -> | | +// | F7 | F8 | F9 | F10 | F11 | F12 | | | | + | - | = | [ | ] | \ | // | | | | | | | | | | bindings = < -&trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans -&kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &kp F6 &kp F7 &kp F8 &kp F9 &kp F10 &kp F11 &kp F12 -&kp GRAV &kp BANG &kp ATSN &kp HASH &kp CURU &kp PRCT &kp CRRT &kp AMPS &kp KMLT &kp LPRN &kp RPRN &kp TILD -&trans &trans &trans &trans &trans &trans &trans &trans &trans &kp MINUS &kp KPLS &kp LCUR &kp RCUR &kp PIPE - &trans &trans &trans &trans &trans &trans &trans &trans +&trans &kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &kp F6 &kp F7 &kp F8 &kp F9 &kp F10 &kp F11 +&trans &kp LCUR &kp AMPS &kp KMLT &kp LPRN &kp RCUR &trans &trans &trans &trans &trans &kp F12 +&trans &kp COLN &kp CURU &kp PRCT &kp CRRT &kp KPLS &kp CLCK &kp LARW &kp DARW &kp UARW &kp RARW &trans +&trans &kp GRAV &kp BANG &kp ATSN &kp HASH &kp PIPE &trans &trans &kp INS &kp HOME &kp PGDN &kp PGUP &kp END &trans + &kp LPRN &kp RPRN &trans &trans &trans &trans &trans &trans >; + + sensor-bindings = <&inc_dec_cp M_VOLU M_VOLD>; }; raise_layer { // ------------------------------------------------------------------------------------------------------------ // | | | | | | | | | | | | | | -// | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | | -// | F1 | F2 | F3 | F4 | F5 | F6 | | | <- | ^ | v | -> | | -// | F7 | F8 | F9 | F10 | F11 | F12 | | | | + | - | = | [ | ] | \ | +// | F1 | F2 | F3 | F4 | F5 | F6 | | F7 | F8 | F9 | F10 | F11 | F12 | +// | ` | ! | @ | # | $ | % | | ^ | & | * | ( | ) | ~ | +// | | | | | | | | | | | _ | + | { | } | "|" | // | | | | | | | | | | bindings = < -&trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans -&kp GRAV &kp NUM_1 &kp NUM_2 &kp NUM_3 &kp NUM_4 &kp NUM_5 &kp NUM_6 &kp NUM_7 &kp NUM_8 &kp NUM_9 &kp NUM_0 &trans -&kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &kp F6 &trans &kp LARW &kp DARW &kp UARW &kp RARW &trans -&kp F7 &kp F8 &kp F9 &kp F10 &kp F11 &kp F12 &trans &trans &kp KPLS &kp MINUS &kp EQL &kp LBKT &kp RBKT &kp BSLH - &trans &trans &trans &trans &trans &trans &trans &trans +&trans &tog 2 &kp KPLS &kp KDIV &kp KMLT &kp KMIN &trans &trans &trans &trans &trans &trans +&trans &kp LBKT &kp NUM_7 &kp NUM_8 &kp NUM_9 &kp RBKT &trans &trans &trans &trans &trans &trans +&trans &kp SCLN &kp NUM_4 &kp NUM_5 &kp NUM_6 &kp EQL &trans &cp M_PREV &cp M_VOLD &cp M_VOLU &cp M_NEXT &trans +&trans &kp TILD &kp NUM_1 &kp NUM_2 &kp NUM_3 &kp BSLH &trans &trans &cp M_STOP &cp M_PLAY &cp M_MUTE &trans &trans &trans + &kp NUM_0 &kp DOT &kp RET &trans &trans &trans &trans &trans >; + + sensor-bindings = <&inc_dec_cp M_VOLU M_VOLD>; }; }; }; -- cgit v1.2.3 From 8b38193ec206505e6e493a7d7bb88010b57af7b3 Mon Sep 17 00:00:00 2001 From: Kevin Date: Fri, 28 Aug 2020 23:33:29 -0700 Subject: Removed status line --- app/boards/shields/lily58/lily58.dtsi | 1 - 1 file changed, 1 deletion(-) diff --git a/app/boards/shields/lily58/lily58.dtsi b/app/boards/shields/lily58/lily58.dtsi index aea36c8..556909f 100644 --- a/app/boards/shields/lily58/lily58.dtsi +++ b/app/boards/shields/lily58/lily58.dtsi @@ -51,7 +51,6 @@ RC(3,0) RC(3,1) RC(3,2) RC(3,3) RC(3,4) RC(3,5) RC(4,5) RC(4,6) RC(3,6) RC(3,7) a-gpios = <&pro_micro_a 3 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; b-gpios = <&pro_micro_a 2 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; resolution = <4>; - status = "disabled"; }; sensors { -- cgit v1.2.3 From d69c94a183f3f91bddde2f1cc9dcf28db418ebac Mon Sep 17 00:00:00 2001 From: Kevin Date: Fri, 28 Aug 2020 23:43:41 -0700 Subject: Added helper scrpits and config file --- app/.gitignore | 5 +---- app/build_left.bat | 1 + app/flash.bat | 2 ++ app/prj.conf | 23 +++++++++++++++++++++++ 4 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 app/build_left.bat create mode 100644 app/flash.bat create mode 100644 app/prj.conf diff --git a/app/.gitignore b/app/.gitignore index 73a4457..d163863 100644 --- a/app/.gitignore +++ b/app/.gitignore @@ -1,4 +1 @@ -build/ -build_left.bat -flash.bat -prj.conf \ No newline at end of file +build/ \ No newline at end of file diff --git a/app/build_left.bat b/app/build_left.bat new file mode 100644 index 0000000..f9d9150 --- /dev/null +++ b/app/build_left.bat @@ -0,0 +1 @@ +west build -p -- -DSHIELD=lily58_left \ No newline at end of file diff --git a/app/flash.bat b/app/flash.bat new file mode 100644 index 0000000..241b5b6 --- /dev/null +++ b/app/flash.bat @@ -0,0 +1,2 @@ +timeout 10 +copy "C:\Users\Kevin\zmk\app\build\zephyr\zmk.uf2" D: \ No newline at end of file diff --git a/app/prj.conf b/app/prj.conf new file mode 100644 index 0000000..c82fc5d --- /dev/null +++ b/app/prj.conf @@ -0,0 +1,23 @@ +# Turn on logging, and set ZMK logging to debug output +CONFIG_LOG=y +CONFIG_ZMK_LOG_LEVEL_DBG=y + +# Turn on USB CDC ACM device +CONFIG_USB=y +CONFIG_USB_DEVICE_STACK=y +CONFIG_USB_CDC_ACM=y +CONFIG_USB_CDC_ACM_RINGBUF_SIZE=1024 +CONFIG_USB_CDC_ACM_DEVICE_NAME="CDC_ACM" +CONFIG_USB_CDC_ACM_DEVICE_COUNT=1 + +# Enable serial console +CONFIG_SERIAL=y +CONFIG_CONSOLE=y +CONFIG_UART_INTERRUPT_DRIVEN=y +CONFIG_UART_LINE_CTRL=y + +# Enable USB UART, and set the console device +CONFIG_UART_CONSOLE=y +CONFIG_USB_UART_CONSOLE=y +CONFIG_UART_CONSOLE_ON_DEV_NAME="CDC_ACM_0" +CONFIG_USB_UART_DTR_WAIT=n \ No newline at end of file -- cgit v1.2.3 From 72232b4ec7ead37bf765acd16e1ea4490651260a Mon Sep 17 00:00:00 2001 From: Kevin Date: Sat, 29 Aug 2020 11:36:48 -0700 Subject: Fixed encoder config and added build_right script --- app/boards/shields/lily58/lily58.keymap | 2 +- app/boards/shields/lily58/lily58_left.conf | 4 ++++ app/build_right.bat | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 app/build_right.bat diff --git a/app/boards/shields/lily58/lily58.keymap b/app/boards/shields/lily58/lily58.keymap index 590d7b6..b8d4a21 100644 --- a/app/boards/shields/lily58/lily58.keymap +++ b/app/boards/shields/lily58/lily58.keymap @@ -20,7 +20,7 @@ &kp LGUI &kp LALT &kp BKSP &mo 1 &mo 2 &kp SPC &kp RET &kp RGUI >; - sensor-bindings = <&inc_dec_cp LBKT RBKT>; + sensor-bindings = <&inc_dec_cp M_VOLU M_VOLD>; }; lower_layer { diff --git a/app/boards/shields/lily58/lily58_left.conf b/app/boards/shields/lily58/lily58_left.conf index 1e028a7..2bd5872 100644 --- a/app/boards/shields/lily58/lily58_left.conf +++ b/app/boards/shields/lily58/lily58_left.conf @@ -1,2 +1,6 @@ +# Enable encoder +CONFIG_EC11=y +CONFIG_EC11_TRIGGER_GLOBAL_THREAD=y + CONFIG_ZMK_SPLIT=y CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y diff --git a/app/build_right.bat b/app/build_right.bat new file mode 100644 index 0000000..4fa87e0 --- /dev/null +++ b/app/build_right.bat @@ -0,0 +1 @@ +west build -p -- -DSHIELD=lily58_right \ No newline at end of file -- cgit v1.2.3 From 8b6e912d36b1e9d1a0efb09cd429714572a23e27 Mon Sep 17 00:00:00 2001 From: Kevin Date: Sat, 29 Aug 2020 11:48:33 -0700 Subject: Reverted back to default keymap --- app/boards/shields/lily58/lily58.keymap | 36 +++++++++++++++--------------- app/boards/shields/lily58/lily58_left.conf | 8 +++---- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/app/boards/shields/lily58/lily58.keymap b/app/boards/shields/lily58/lily58.keymap index b8d4a21..afd2694 100644 --- a/app/boards/shields/lily58/lily58.keymap +++ b/app/boards/shields/lily58/lily58.keymap @@ -16,8 +16,8 @@ &kp ESC &kp NUM_1 &kp NUM_2 &kp NUM_3 &kp NUM_4 &kp NUM_5 &kp NUM_6 &kp NUM_7 &kp NUM_8 &kp NUM_9 &kp NUM_0 &kp GRAV &kp TAB &kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P &kp MINUS &kp LCTL &kp A &kp S &kp D &kp F &kp G &kp H &kp J &kp K &kp L &kp SCLN &kp QUOT -&kp LSFT &kp Z &kp X &kp C &kp V &kp B &cp M_PLAY &kp DEL &kp N &kp M &kp CMMA &kp DOT &kp FSLH &kp RSFT - &kp LGUI &kp LALT &kp BKSP &mo 1 &mo 2 &kp SPC &kp RET &kp RGUI +&kp LSFT &kp Z &kp X &kp C &kp V &kp B &kp LBKT &kp RBKT &kp N &kp M &kp CMMA &kp DOT &kp FSLH &kp RSFT + &kp LALT &kp LGUI &mo 1 &kp SPC &kp RET &mo 2 &kp BKSP &kp RGUI >; sensor-bindings = <&inc_dec_cp M_VOLU M_VOLD>; @@ -26,16 +26,16 @@ lower_layer { // ------------------------------------------------------------------------------------------------------------ // | | | | | | | | | | | | | | -// | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | | -// | F1 | F2 | F3 | F4 | F5 | F6 | | | <- | ^ | v | -> | | -// | F7 | F8 | F9 | F10 | F11 | F12 | | | | + | - | = | [ | ] | \ | +// | F1 | F2 | F3 | F4 | F5 | F6 | | F7 | F8 | F9 | F10 | F11 | F12 | +// | ` | ! | @ | # | $ | % | | ^ | & | * | ( | ) | ~ | +// | | | | | | | | | | | _ | + | { | } | "|" | // | | | | | | | | | | bindings = < -&trans &kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &kp F6 &kp F7 &kp F8 &kp F9 &kp F10 &kp F11 -&trans &kp LCUR &kp AMPS &kp KMLT &kp LPRN &kp RCUR &trans &trans &trans &trans &trans &kp F12 -&trans &kp COLN &kp CURU &kp PRCT &kp CRRT &kp KPLS &kp CLCK &kp LARW &kp DARW &kp UARW &kp RARW &trans -&trans &kp GRAV &kp BANG &kp ATSN &kp HASH &kp PIPE &trans &trans &kp INS &kp HOME &kp PGDN &kp PGUP &kp END &trans - &kp LPRN &kp RPRN &trans &trans &trans &trans &trans &trans +&trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans +&kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &kp F6 &kp F7 &kp F8 &kp F9 &kp F10 &kp F11 &kp F12 +&kp GRAV &kp BANG &kp ATSN &kp HASH &kp CURU &kp PRCT &kp CRRT &kp AMPS &kp KMLT &kp LPRN &kp RPRN &kp TILD +&trans &trans &trans &trans &trans &trans &trans &trans &trans &kp MINUS &kp KPLS &kp LCUR &kp RCUR &kp PIPE + &trans &trans &trans &trans &trans &trans &trans &trans >; sensor-bindings = <&inc_dec_cp M_VOLU M_VOLD>; @@ -44,16 +44,16 @@ raise_layer { // ------------------------------------------------------------------------------------------------------------ // | | | | | | | | | | | | | | -// | F1 | F2 | F3 | F4 | F5 | F6 | | F7 | F8 | F9 | F10 | F11 | F12 | -// | ` | ! | @ | # | $ | % | | ^ | & | * | ( | ) | ~ | -// | | | | | | | | | | | _ | + | { | } | "|" | +// | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | | +// | F1 | F2 | F3 | F4 | F5 | F6 | | | <- | ^ | v | -> | | +// | F7 | F8 | F9 | F10 | F11 | F12 | | | | + | - | = | [ | ] | \ | // | | | | | | | | | | bindings = < -&trans &tog 2 &kp KPLS &kp KDIV &kp KMLT &kp KMIN &trans &trans &trans &trans &trans &trans -&trans &kp LBKT &kp NUM_7 &kp NUM_8 &kp NUM_9 &kp RBKT &trans &trans &trans &trans &trans &trans -&trans &kp SCLN &kp NUM_4 &kp NUM_5 &kp NUM_6 &kp EQL &trans &cp M_PREV &cp M_VOLD &cp M_VOLU &cp M_NEXT &trans -&trans &kp TILD &kp NUM_1 &kp NUM_2 &kp NUM_3 &kp BSLH &trans &trans &cp M_STOP &cp M_PLAY &cp M_MUTE &trans &trans &trans - &kp NUM_0 &kp DOT &kp RET &trans &trans &trans &trans &trans +&trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans +&kp GRAV &kp NUM_1 &kp NUM_2 &kp NUM_3 &kp NUM_4 &kp NUM_5 &kp NUM_6 &kp NUM_7 &kp NUM_8 &kp NUM_9 &kp NUM_0 &trans +&kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &kp F6 &trans &kp LARW &kp DARW &kp UARW &kp RARW &trans +&kp F7 &kp F8 &kp F9 &kp F10 &kp F11 &kp F12 &trans &trans &kp KPLS &kp MINUS &kp EQL &kp LBKT &kp RBKT &kp BSLH + &trans &trans &trans &trans &trans &trans &trans &trans >; sensor-bindings = <&inc_dec_cp M_VOLU M_VOLD>; diff --git a/app/boards/shields/lily58/lily58_left.conf b/app/boards/shields/lily58/lily58_left.conf index 2bd5872..6ff95d5 100644 --- a/app/boards/shields/lily58/lily58_left.conf +++ b/app/boards/shields/lily58/lily58_left.conf @@ -1,6 +1,6 @@ -# Enable encoder -CONFIG_EC11=y -CONFIG_EC11_TRIGGER_GLOBAL_THREAD=y +# Uncomment to enable encoder +# CONFIG_EC11=y +# CONFIG_EC11_TRIGGER_GLOBAL_THREAD=y CONFIG_ZMK_SPLIT=y -CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y +CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y \ No newline at end of file -- cgit v1.2.3 From 14c05c92e973d92398d0970ad4a5dd2b9d32becd Mon Sep 17 00:00:00 2001 From: Kevin Date: Sat, 29 Aug 2020 11:53:53 -0700 Subject: Removed development files --- app/.gitignore | 2 +- app/build_left.bat | 1 - app/build_right.bat | 1 - app/flash.bat | 2 -- app/prj.conf | 23 ----------------------- 5 files changed, 1 insertion(+), 28 deletions(-) delete mode 100644 app/build_left.bat delete mode 100644 app/build_right.bat delete mode 100644 app/flash.bat delete mode 100644 app/prj.conf diff --git a/app/.gitignore b/app/.gitignore index d163863..567609b 100644 --- a/app/.gitignore +++ b/app/.gitignore @@ -1 +1 @@ -build/ \ No newline at end of file +build/ diff --git a/app/build_left.bat b/app/build_left.bat deleted file mode 100644 index f9d9150..0000000 --- a/app/build_left.bat +++ /dev/null @@ -1 +0,0 @@ -west build -p -- -DSHIELD=lily58_left \ No newline at end of file diff --git a/app/build_right.bat b/app/build_right.bat deleted file mode 100644 index 4fa87e0..0000000 --- a/app/build_right.bat +++ /dev/null @@ -1 +0,0 @@ -west build -p -- -DSHIELD=lily58_right \ No newline at end of file diff --git a/app/flash.bat b/app/flash.bat deleted file mode 100644 index 241b5b6..0000000 --- a/app/flash.bat +++ /dev/null @@ -1,2 +0,0 @@ -timeout 10 -copy "C:\Users\Kevin\zmk\app\build\zephyr\zmk.uf2" D: \ No newline at end of file diff --git a/app/prj.conf b/app/prj.conf deleted file mode 100644 index c82fc5d..0000000 --- a/app/prj.conf +++ /dev/null @@ -1,23 +0,0 @@ -# Turn on logging, and set ZMK logging to debug output -CONFIG_LOG=y -CONFIG_ZMK_LOG_LEVEL_DBG=y - -# Turn on USB CDC ACM device -CONFIG_USB=y -CONFIG_USB_DEVICE_STACK=y -CONFIG_USB_CDC_ACM=y -CONFIG_USB_CDC_ACM_RINGBUF_SIZE=1024 -CONFIG_USB_CDC_ACM_DEVICE_NAME="CDC_ACM" -CONFIG_USB_CDC_ACM_DEVICE_COUNT=1 - -# Enable serial console -CONFIG_SERIAL=y -CONFIG_CONSOLE=y -CONFIG_UART_INTERRUPT_DRIVEN=y -CONFIG_UART_LINE_CTRL=y - -# Enable USB UART, and set the console device -CONFIG_UART_CONSOLE=y -CONFIG_USB_UART_CONSOLE=y -CONFIG_UART_CONSOLE_ON_DEV_NAME="CDC_ACM_0" -CONFIG_USB_UART_DTR_WAIT=n \ No newline at end of file -- cgit v1.2.3 From 03319438553e68a29a8c66abc47686e0934afc71 Mon Sep 17 00:00:00 2001 From: Kevin Date: Sat, 29 Aug 2020 13:48:40 -0700 Subject: Removed extra encoder config lines --- app/boards/shields/lily58/lily58.conf | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/boards/shields/lily58/lily58.conf b/app/boards/shields/lily58/lily58.conf index 14c1841..73f0d9d 100644 --- a/app/boards/shields/lily58/lily58.conf +++ b/app/boards/shields/lily58/lily58.conf @@ -1,6 +1,2 @@ -# Enable encoder -CONFIG_EC11=y -CONFIG_EC11_TRIGGER_GLOBAL_THREAD=y - # Uncomment the following line to enable the Lily58 OLED Display # CONFIG_ZMK_DISPLAY=y -- cgit v1.2.3 From ec6215f38e4f178740e0838bba3bf8ca6d9f1f0c Mon Sep 17 00:00:00 2001 From: Kevin Date: Sat, 29 Aug 2020 15:05:43 -0700 Subject: Added Arduino IDE to USB Logging --- docs/docs/dev-guide-usb-logging.md | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/docs/docs/dev-guide-usb-logging.md b/docs/docs/dev-guide-usb-logging.md index 3bc8a0c..bb09364 100644 --- a/docs/docs/dev-guide-usb-logging.md +++ b/docs/docs/dev-guide-usb-logging.md @@ -3,6 +3,9 @@ id: dev-guide-usb-logging title: USB Logging --- +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + ## Overview If you are developing ZMK on a device that does not have a built in UART for debugging and log/console output, @@ -11,7 +14,7 @@ messages to that device instead. ## Kconfig -The following KConfig values need to be set, either by copy and paste into the `app/prj.conf` file, or by running +The following KConfig values need to be set, either by copy and pasting into the `app/prj.conf` file, or by running `west build -t menuconfig` and manually enabling the various settings in that UI. ``` @@ -42,12 +45,26 @@ CONFIG_USB_UART_DTR_WAIT=n ## Viewing Logs -After flashing the updated ZMK image, the board should expose a USB CDC ACM device, that you can connect to and view the logs. +After flashing the updated ZMK image, the board should expose a USB CDC ACM device that you can connect to and view the logs. -On Linux, this should be a device like `/dev/ttyACM0` and you can connect with `minicom` or `tio` as usual, e.g.: + + +On Linux, this should be a device like `/dev/ttyACM0` and you can connect with `minicom` or `tio` as usual, e.g.: ``` sudo tio /dev/ttyACM0 ``` + + + +On Windows, you can use the Arduino IDE which contains a built-in Serial Monitor. Download and install it from [their website](https://www.arduino.cc/en/main/software), then connect your board and under Tools select "Serial Monitor". + + + From there, you should see the various log messages from ZMK and Zephyr, depending on which systems you have set to what log levels. -- cgit v1.2.3 From 35dc46bfbb472c01c2c791233bbe32734cb6dfd5 Mon Sep 17 00:00:00 2001 From: Kevin Date: Sat, 29 Aug 2020 15:51:08 -0700 Subject: Made separate build and flash page with updated content --- docs/docs/dev-build.md | 88 ++++++++++++++++++++++++++++++++++++++ docs/docs/dev-guide-usb-logging.md | 4 +- docs/docs/dev-setup.md | 77 ++++++++++----------------------- docs/sidebars.js | 1 + 4 files changed, 113 insertions(+), 57 deletions(-) create mode 100644 docs/docs/dev-build.md diff --git a/docs/docs/dev-build.md b/docs/docs/dev-build.md new file mode 100644 index 0000000..2df15cd --- /dev/null +++ b/docs/docs/dev-build.md @@ -0,0 +1,88 @@ +--- +id: dev-build-flash +title: Building and Flashing +sidebar_label: Building and Flashing +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +export const OsTabs = (props) => ({props.children}); + +## Building + +From here on, building and flashing ZMK should all be done from the `app/` subdirectory of the ZMK checkout: + +```sh +cd app +``` + +To build for your particular keyboard, the behaviour varies slightly depending on if you are building for a keyboard with +an onboard MCU, or one that uses an MCU board addon. + +### Keyboard (Shield) + MCU Board + +ZMK treats keyboards that take an MCU addon board as [shields](https://docs.zephyrproject.org/2.3.0/guides/porting/shields.html), and treats the smaller MCU board as the true [board](https://docs.zephyrproject.org/2.3.0/guides/porting/board_porting.html) + +Given the following: + +- MCU Board: Proton-C +- Keyboard PCB: kyria_left +- Keymap: default + +You can build ZMK with the following: + +```sh +west build -b proton_c -- -DSHIELD=kyria_left -DKEYMAP=default +``` + +### Keyboard With Onboard MCU + +Keyboards with onboard MCU chips are simply treated as the [board](https://docs.zephyrproject.org/2.3.0/guides/porting/board_porting.html) as far as Zephyrâ„¢ is concerned. + +Given the following: + +- Keyboard: Planck (rev6) +- Keymap: default + +you can build ZMK with the following: + +```sh +west build -b planck_rev6 -- -DKEYMAP=default +``` + +### Pristine Building +When building for a new board and/or shield after having built one previously, you may need to enable the pristine build option. This option removes all existing files in the build directory and regenerates them, and can be enabled by adding either --pristine or -p to the command: + +```sh +west build -p -b proton_c -- -DSHIELD=kyria_left -DKEYMAP=default +``` + +## Flashing + +Once built, the previously supplied parameters will be remembered so you can run the following to flash your +board with it in bootloader mode: + +``` +west flash +``` + +For boards that have drag and drop .uf2 flashing capability, the .uf2 file to flash can be found in `build\zephyr` and is by default named `zmk.uf2`. + +:::note +For split keyboards, you will have to build and flash each side separately the first time you install ZMK. By default the `build` command outputs a single .uf2 file named `zmk.uf2`, so you will have to +1. Build the left side with the `build` command provided above +2. Flash `zmk.uf2` to the left side +3. Replace DSHIELD with the right side (for the above example, this would be `kyria_right`) and build again +4. Flash `zmk.uf2` the right side +::: diff --git a/docs/docs/dev-guide-usb-logging.md b/docs/docs/dev-guide-usb-logging.md index bb09364..fa4b63b 100644 --- a/docs/docs/dev-guide-usb-logging.md +++ b/docs/docs/dev-guide-usb-logging.md @@ -51,7 +51,7 @@ After flashing the updated ZMK image, the board should expose a USB CDC ACM devi defaultValue="linux" values={[ {label: 'Linux', value: 'linux'}, -{label: 'Windows', value: 'windows'}, +{label: 'Windows', value: 'win'}, ]}> @@ -60,7 +60,7 @@ On Linux, this should be a device like `/dev/ttyACM0` and you can connect with ` sudo tio /dev/ttyACM0 ``` - + On Windows, you can use the Arduino IDE which contains a built-in Serial Monitor. Download and install it from [their website](https://www.arduino.cc/en/main/software), then connect your board and under Tools select "Serial Monitor". diff --git a/docs/docs/dev-setup.md b/docs/docs/dev-setup.md index fae0aa0..1c5c9dd 100644 --- a/docs/docs/dev-setup.md +++ b/docs/docs/dev-setup.md @@ -181,7 +181,7 @@ brew install cmake ninja python3 ccache dtc git wget ## Setup -### West Build Command +### West Installation `west` is the [Zephyrâ„¢ meta-tool](https://docs.zephyrproject.org/2.3.0/guides/west/index.html) used to configure and build Zephyrâ„¢ applications. @@ -192,14 +192,32 @@ pip3 install --user -U west ``` :::danger pip user packages -If you haven't done so yet, you may need to add the Python Pip user package directory to your `PATH`, e.g.: +If you haven't done so yet, you may need to add the Python Pip user package directory to your `PATH` otherwise your computer will not be able to find the `west` command. +::: -``` + + +Run the following commands: + +```sh echo 'export PATH=~/.local/bin:"$PATH"' >> ~/.bashrc source ~/.bashrc ``` -::: + + + +1. Go to the Start Menu and type "environment variables" to find and open the "Edit the system environment variables" option. +2. Click "Environment Variables...", and select the "Path" variable under System variables. +3. Click "Edit..." and then "New" to add the directory where your west.exe is located. By default this should be something like `C:\Python38\Scripts`. + + + ### Toolchain Installation @@ -428,54 +446,3 @@ cat ~/.zephyrrc >> ~/.zshrc - -## Build - -From here on, building and flashing ZMK should all be done from the `app/` subdirectory of the ZMK checkout: - -```sh -cd app -``` - -To build for your particular keyboard, the behaviour varies slightly depending on if you are building for a keyboard with -an onboard MCU, or one that uses a MCU board addon. - -### Keyboard (Shield) + MCU Board - -ZMK treats keyboards that take a MCU addon board as [shields](https://docs.zephyrproject.org/2.3.0/guides/porting/shields.html), and treats the smaller MCU board as the true [board](https://docs.zephyrproject.org/2.3.0/guides/porting/board_porting.html) - -Given the following: - -- MCU Board: Proton-C -- Keyboard PCB: kyria_left -- Keymap: default - -You can build ZMK with the following: - -```sh -west build -b proton_c -- -DSHIELD=kyria_left -DKEYMAP=default -``` - -### Keyboard With Onboard MCU - -Keyboards with onboard MCU chips are simply treated as the [board](https://docs.zephyrproject.org/2.3.0/guides/porting/board_porting.html) as far as Zephyrâ„¢ is concerned. - -Given the following: - -- Keyboard: Planck (rev6) -- Keymap: default - -you can build ZMK with the following: - -```sh -west build -b planck_rev6 -- -DKEYMAP=default -``` - -## Flashing - -Once built, the previously supplied parameters will be remember, so you can simply run the following to flash your -board, with it in bootloader mode: - -``` -west flash -``` diff --git a/docs/sidebars.js b/docs/sidebars.js index d426667..3710137 100644 --- a/docs/sidebars.js +++ b/docs/sidebars.js @@ -18,6 +18,7 @@ module.exports = { Development: [ "dev-clean-room", "dev-setup", + "dev-build-flash", "dev-boards-shields-keymaps", "dev-posix-board", "dev-tests", -- cgit v1.2.3 From 96020a469a5524817732dec59c2b22e0e6172504 Mon Sep 17 00:00:00 2001 From: Kevin Date: Sat, 29 Aug 2020 17:21:56 -0700 Subject: Added win environment variables instructions --- docs/docs/dev-setup.md | 45 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/docs/docs/dev-setup.md b/docs/docs/dev-setup.md index 1c5c9dd..151a032 100644 --- a/docs/docs/dev-setup.md +++ b/docs/docs/dev-setup.md @@ -212,8 +212,7 @@ source ~/.bashrc -1. Go to the Start Menu and type "environment variables" to find and open the "Edit the system environment variables" option. -2. Click "Environment Variables...", and select the "Path" variable under System variables. +1. See the [Environment Variables](#environment-variables) section on how to get to the Environment Variables page. 3. Click "Edit..." and then "New" to add the directory where your west.exe is located. By default this should be something like `C:\Python38\Scripts`. @@ -359,10 +358,41 @@ pip3 install --user -r zephyr/scripts/requirements-base.txt ### Environment Variables +#### GNU ARM Embedded on Windows + +On Windows, you will have to set two environment variables for ZMK to build properly: `ZEPHYR_TOOLCHAIN_VARIANT` and `GNUARMEMB_TOOLCHAIN_PATH`. + +
+ Steps to Update Environment Variables + +1. Open Start Menu and type 'env' to find the 'Edit the system environment variables' option. Open it. + +![start menu](assets/env-var/start_menu.png) + +2. Click 'Environment Variables...'. + +![start menu](assets/env-var/env_var.png) + +3. Click "New..." under System variables to create a new system variable. + +![start menu](assets/env-var/new_variable.png) + +4. Set the variable name to 'ZEPHYR_TOOLCHAIN_VARIANT' and value to 'gnuarmemb'. Click OK to save. + +![start menu](assets/env-var/zephyr_toolchain.png) + +5. Create another variable with variable name 'GNUARMEMB_TOOLCHAIN_PATH' and value set to wherever you installed your toolchain. Click OK to save. + +![start menu](assets/env-var/gnuarmemb.png) + +
+ +#### For Zephyr + By default, the Zephyr™ SDK will create a file named `~/.zephyrrc` with the correct environment variables to build ZMK. We suggest two main [options](https://docs.zephyrproject.org/2.3.0/guides/env_vars.html?highlight=zephyrrc) for how to load those settings. -#### Per Shell +##### Per Shell To load the Zephyr environment properly for just one transient shell, run the following from your ZMK checkout directory: @@ -408,7 +438,7 @@ source zephyr/zephyr-env.cmd -#### All Shells +##### All Shells To load the environment variables for your shell every time, append the existing `~/.zephyrrc` file to your shell's RC file and then start a new shell. @@ -419,7 +449,6 @@ defaultValue="bash" values={[ {label: 'bash', value: 'bash'}, {label: 'zsh', value: 'zsh'}, -{label: 'cmd.exe', value: 'cmd'}, ] }> @@ -439,10 +468,4 @@ cat ~/.zephyrrc >> ~/.zshrc - - -`cmd.exe` instructions coming soon! - - - -- cgit v1.2.3 From 9b9174cc574b5d8d55cd2b4b583f44f0f7421404 Mon Sep 17 00:00:00 2001 From: Kevin Date: Sat, 29 Aug 2020 17:22:39 -0700 Subject: Added lily58 reset photo --- docs/docs/assets/bond-clearing/lily58.jpg | Bin 0 -> 2566639 bytes docs/docs/bond-reset.md | 16 ++++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 docs/docs/assets/bond-clearing/lily58.jpg diff --git a/docs/docs/assets/bond-clearing/lily58.jpg b/docs/docs/assets/bond-clearing/lily58.jpg new file mode 100644 index 0000000..4087e7d Binary files /dev/null and b/docs/docs/assets/bond-clearing/lily58.jpg differ diff --git a/docs/docs/bond-reset.md b/docs/docs/bond-reset.md index 1d3732b..1ba79ee 100644 --- a/docs/docs/bond-reset.md +++ b/docs/docs/bond-reset.md @@ -4,8 +4,8 @@ title: Reset BLE Connections sidebar_label: BLE Reset --- -Known as a 'bond reset', a special key combination, that is not related to the user defined key map, which -clears all wireless connection configurations. The keys must be held for 3 to 5 seconds after the device is +Known as a 'bond reset', each keyboard has a special key combination independent of the user defined key map which will +clear all wireless connection configurations. The keys must be held for 3 to 5 seconds after the device is reset. :::warning @@ -13,15 +13,19 @@ Currently, ZMK only supports a single BLE host. If you remove the keyboard from list, you will need to clear the bonds. ::: -### Split Keyboards +## Split Keyboards Split keyboards will need to be cleared on both halves. For best results try to reset them at the same time. -## Kyria +### Kyria ![Kyria bond-reset combo](assets/bond-clearing/kyria.jpg) -## Corne +### Corne -![Corne bond-reset combo](assets/bond-clearing/corne.jpg) \ No newline at end of file +![Corne bond-reset combo](assets/bond-clearing/corne.jpg) + +### Lily58 + +![Lily58 bond-reset combo](assets/bond-clearing/lily58.jpg) \ No newline at end of file -- cgit v1.2.3 From 133166c392540f8496f2dd42671ddda1bd547d2f Mon Sep 17 00:00:00 2001 From: Kevin Date: Sat, 29 Aug 2020 17:23:17 -0700 Subject: Pictures for environment variables --- docs/docs/assets/env-var/env_var.png | Bin 0 -> 17317 bytes docs/docs/assets/env-var/gnuarmemb.png | Bin 0 -> 7914 bytes docs/docs/assets/env-var/new_variable.png | Bin 0 -> 60899 bytes docs/docs/assets/env-var/start_menu.png | Bin 0 -> 51108 bytes docs/docs/assets/env-var/zephyr_toolchain.png | Bin 0 -> 7282 bytes 5 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 docs/docs/assets/env-var/env_var.png create mode 100644 docs/docs/assets/env-var/gnuarmemb.png create mode 100644 docs/docs/assets/env-var/new_variable.png create mode 100644 docs/docs/assets/env-var/start_menu.png create mode 100644 docs/docs/assets/env-var/zephyr_toolchain.png diff --git a/docs/docs/assets/env-var/env_var.png b/docs/docs/assets/env-var/env_var.png new file mode 100644 index 0000000..77ebbc5 Binary files /dev/null and b/docs/docs/assets/env-var/env_var.png differ diff --git a/docs/docs/assets/env-var/gnuarmemb.png b/docs/docs/assets/env-var/gnuarmemb.png new file mode 100644 index 0000000..42e38ec Binary files /dev/null and b/docs/docs/assets/env-var/gnuarmemb.png differ diff --git a/docs/docs/assets/env-var/new_variable.png b/docs/docs/assets/env-var/new_variable.png new file mode 100644 index 0000000..3cc72bd Binary files /dev/null and b/docs/docs/assets/env-var/new_variable.png differ diff --git a/docs/docs/assets/env-var/start_menu.png b/docs/docs/assets/env-var/start_menu.png new file mode 100644 index 0000000..fc7d9b5 Binary files /dev/null and b/docs/docs/assets/env-var/start_menu.png differ diff --git a/docs/docs/assets/env-var/zephyr_toolchain.png b/docs/docs/assets/env-var/zephyr_toolchain.png new file mode 100644 index 0000000..5a8ec50 Binary files /dev/null and b/docs/docs/assets/env-var/zephyr_toolchain.png differ -- cgit v1.2.3 From 76095c64c6d51c2c7aaf9856d50847998a41b263 Mon Sep 17 00:00:00 2001 From: Kevin Date: Sat, 29 Aug 2020 17:25:00 -0700 Subject: Fixed title --- docs/docs/dev-setup.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/dev-setup.md b/docs/docs/dev-setup.md index 151a032..e9c635a 100644 --- a/docs/docs/dev-setup.md +++ b/docs/docs/dev-setup.md @@ -358,7 +358,7 @@ pip3 install --user -r zephyr/scripts/requirements-base.txt ### Environment Variables -#### GNU ARM Embedded on Windows +#### For GNU ARM Embedded on Windows On Windows, you will have to set two environment variables for ZMK to build properly: `ZEPHYR_TOOLCHAIN_VARIANT` and `GNUARMEMB_TOOLCHAIN_PATH`. -- cgit v1.2.3 From d7bd09149b347c71259eb299f8e8f7ddaa4055f7 Mon Sep 17 00:00:00 2001 From: Kevin Date: Sat, 29 Aug 2020 17:25:37 -0700 Subject: Added info on connecting keyboard --- docs/docs/user-setup.md | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/docs/docs/user-setup.md b/docs/docs/user-setup.md index be230d2..b1ffefa 100644 --- a/docs/docs/user-setup.md +++ b/docs/docs/user-setup.md @@ -11,8 +11,7 @@ Unlike other keyboard firmwares, ZMK Firmware has been built from the ground up their own keyboard configurations, including keymaps, specific hardware details, etc. all outside of the core ZMK Firmware source repository. -In addition to this, most users do not need to install any complicated toolchains or tools to build ZMK, -instead using GitHub Actions to automatically build the user's configured firmware for them. +In addition to this, most users will not need to install any complicated toolchains or tools to build ZMK. GitHub Actions is used instead to automatically build the user's configured firmware for them. ## Summary @@ -170,7 +169,7 @@ a link to download the `firmware` upload: Once downloaded, extract the zip and you can verify it should contain one or more `uf2` files, which will be copied to your keyboard. -### Installing UF2 Files +### Flashing UF2 Files To flash the firmware, first put your board into bootloader mode by double clicking the reset button (either on the MCU board itself, or the one that is part of your keyboard). The controller should appear in your OS as a new USB storage device. @@ -178,6 +177,14 @@ or the one that is part of your keyboard). The controller should appear in your Once this happens, copy the correct UF2 file (e.g. left or right if working on a split), and paste it onto the root of that USB mass storage device. Once the flash is complete, the controller should automatically restart, and load your newfly flashed firmware. +## Wirelessly Connecting Your Keyboard + +Connecting your keyboard wirelessly is the same as adding other Bluetooth devides: press the reset button and scan for devices. However, pairing and bonding is still currently being worked on to increase relability and ease of use. In addition, users have in general reported that Bluetooth pairing with computers tends to be quite finnicky. Try out the connection with your tablet or phone first, as those devices seem to work much more consistently. See [BLE Reset](./bond-reset.md) for help on resetting your MCUs if you're experiencing connection issues. + +### Connecting Split Keyboard Halves + +For split keyboards, after flashing each half individually you can connect them together by resetting them at the same time. Within a few seconds of resetting, both halves should automatically connect to each other. + ## Customization ### Configuration Changes @@ -199,3 +206,5 @@ GitHub Actions job to build your firmware which you can download once it complet :::note If you need to, a review of [Learn The Basics Of Git In Under 10 Minutes](https://www.freecodecamp.org/news/learn-the-basics-of-git-in-under-10-minutes-da548267cc91/) will help you get these steps right. ::: + +For split keyboards, only the central (usually left) side will need to be reflashed after making updates to your keymap. -- cgit v1.2.3 From dad2d339b3fa038af1b87cdb60b79081d681a6c3 Mon Sep 17 00:00:00 2001 From: Kevin Date: Sat, 29 Aug 2020 17:46:00 -0700 Subject: Added customization page --- docs/docs/customization.md | 33 +++++++++++++++++++++++++++++++++ docs/docs/feature/keymaps.md | 2 +- docs/docs/hardware.md | 2 +- docs/docs/intro.md | 2 +- docs/docs/user-setup.md | 24 ------------------------ docs/sidebars.js | 2 +- 6 files changed, 37 insertions(+), 28 deletions(-) create mode 100644 docs/docs/customization.md diff --git a/docs/docs/customization.md b/docs/docs/customization.md new file mode 100644 index 0000000..0bb1794 --- /dev/null +++ b/docs/docs/customization.md @@ -0,0 +1,33 @@ +--- +id: customization +title: Customizing ZMK +sidebar_label: Customizing ZMK +--- + +After verifying you can successfully flash the default firmware, you will probably want to begin customizing your keymap and other keyboard options. + +## Configuration Changes + +The setup script creates a `config/.conf` file that allows you to add additional configuration options to +control what features and options are built into your firmware. Opening that file with your text editor will allow you to see the +various config settings that can be commented/uncommented to modify how your firmware is built. + +## Keymap + +Once you have the basic user config completed, you can find the keymap file in `config/.keymap` and customize from there. +Refer to the [Keymap](/docs/feature/keymaps) documentation to learn more. + +## Publishing + +After making any changes you want, you should commit the changes and then push them to GitHub. That will trigger a new +GitHub Actions job to build your firmware which you can download once it completes. + +:::note +If you need to, a review of [Learn The Basics Of Git In Under 10 Minutes](https://www.freecodecamp.org/news/learn-the-basics-of-git-in-under-10-minutes-da548267cc91/) will help you get these steps right. +::: + +## Flashing Your Changes + +For normal keyboards, follow the same flashing instructions as before to flash your updated firmware. + +For split keyboards, only the central (left) side will need to be reflashed if you are just updating your keymap. diff --git a/docs/docs/feature/keymaps.md b/docs/docs/feature/keymaps.md index 020df17..367b03c 100644 --- a/docs/docs/feature/keymaps.md +++ b/docs/docs/feature/keymaps.md @@ -4,7 +4,7 @@ title: Keymaps & Behaviors sidebar_label: Keymaps --- -ZMK uses an declarative approach to keymaps, instead of using C code for all keymap configuration. +ZMK uses a declarative approach to keymaps instead of using C code for all keymap configuration. Right now, ZMK uses the devicetree syntax to declare those keymaps; future work is envisioned for supporting dynamic loading of declarative keymaps, e.g. over USB Mass Storage or via a custom BLE service. diff --git a/docs/docs/hardware.md b/docs/docs/hardware.md index 9e6a956..299d1f5 100644 --- a/docs/docs/hardware.md +++ b/docs/docs/hardware.md @@ -11,7 +11,7 @@ have had their hardware details codified in boards/shields for ZMK. ::: -Being built on a solid technical foundation of the Zephyr™ RTOS, it's possible to make ZMK support a wide diversity of hardware targets. +With the solid technical foundation of Zephyr™ RTOS, ZMK can support a wide diversity of hardware targets. That being said, there are currently only a few specific [boards](/docs/faq#what-is-a-board)/[shields](/docs/faq#what-is-a-shield) that have been written and tested by the ZMK contributors. ## Boards diff --git a/docs/docs/intro.md b/docs/docs/intro.md index 514c76e..29045f7 100644 --- a/docs/docs/intro.md +++ b/docs/docs/intro.md @@ -5,7 +5,7 @@ sidebar_label: Introduction --- ZMK Firmware is an open source (MIT) keyboard -firmware built on the [Zephyr™ Project](https://zephyrproject.com/) RTOS. +firmware built on the [Zephyr™ Project](https://zephyrproject.com/) Real Time Operating System (RTOS). The goal is to provider a powerful, featureful keyboard firmware that is free of licensing issues that prevent upstream BLE support as a first-class diff --git a/docs/docs/user-setup.md b/docs/docs/user-setup.md index b1ffefa..2aade82 100644 --- a/docs/docs/user-setup.md +++ b/docs/docs/user-setup.md @@ -184,27 +184,3 @@ Connecting your keyboard wirelessly is the same as adding other Bluetooth devide ### Connecting Split Keyboard Halves For split keyboards, after flashing each half individually you can connect them together by resetting them at the same time. Within a few seconds of resetting, both halves should automatically connect to each other. - -## Customization - -### Configuration Changes - -The setup script creates a `config/.conf` file that allows you to add additional configuration options to -control what features and options are built into your firmware. Opening that file with your text editor you should see -various config settings that can be commented/uncommented to modify how your firmware is built. - -### Keymap - -Once you have the basic user config completed, you can find the file in `config/.keymap` and customize from there. -Refer to the [Keymap](/docs/feature/keymaps) documentation to learn more. - -### Publishing - -After making any changes you want, you should commit the changes and then push them to GitHub. That will trigger a new -GitHub Actions job to build your firmware which you can download once it completes. - -:::note -If you need to, a review of [Learn The Basics Of Git In Under 10 Minutes](https://www.freecodecamp.org/news/learn-the-basics-of-git-in-under-10-minutes-da548267cc91/) will help you get these steps right. -::: - -For split keyboards, only the central (usually left) side will need to be reflashed after making updates to your keymap. diff --git a/docs/sidebars.js b/docs/sidebars.js index 3710137..53c5cf3 100644 --- a/docs/sidebars.js +++ b/docs/sidebars.js @@ -1,6 +1,6 @@ module.exports = { someSidebar: { - "Getting Started": ["intro", "hardware", "faq", "user-setup", "bond-reset"], + "Getting Started": ["intro", "hardware", "faq", "user-setup","customization", "bond-reset"], Features: [ "feature/keymaps", "feature/displays", -- cgit v1.2.3 From 276a2620b9a5259dd15cd4a6038a6144e5da9432 Mon Sep 17 00:00:00 2001 From: Kevin Date: Sat, 29 Aug 2020 17:47:41 -0700 Subject: Minor capitalization fix --- docs/docs/feature/keymaps.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/feature/keymaps.md b/docs/docs/feature/keymaps.md index 367b03c..d991925 100644 --- a/docs/docs/feature/keymaps.md +++ b/docs/docs/feature/keymaps.md @@ -80,7 +80,7 @@ A keymap file is composed of several sections, that together make up a valid dev ### Includes -THe devicetree files are actually preprocessed before being finally leveraged by Zephyr. This allows using standard C defines to create meaningful placeholders +The devicetree files are actually preprocessed before being finally leveraged by Zephyr. This allows using standard C defines to create meaningful placeholders for what would otherwise be cryptic integer keycodes, etc. This also allows bringing in _other_ devicetree nodes from separate files. The top two lines of most keymaps should include: -- cgit v1.2.3 From 1ffcbefd728f2b47fcbb5e4e8b117adf893f059a Mon Sep 17 00:00:00 2001 From: Kevin Date: Sat, 29 Aug 2020 18:12:12 -0700 Subject: Added encoder to unified conf file --- app/boards/shields/lily58/lily58.conf | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/boards/shields/lily58/lily58.conf b/app/boards/shields/lily58/lily58.conf index 73f0d9d..31eb7c6 100644 --- a/app/boards/shields/lily58/lily58.conf +++ b/app/boards/shields/lily58/lily58.conf @@ -1,2 +1,6 @@ +# Uncomment to enable encoder +# CONFIG_EC11=y +# CONFIG_EC11_TRIGGER_GLOBAL_THREAD=y + # Uncomment the following line to enable the Lily58 OLED Display # CONFIG_ZMK_DISPLAY=y -- cgit v1.2.3 From 037970fe8c0122d156de4db92e3ef335e1902e55 Mon Sep 17 00:00:00 2001 From: Kevin Date: Sat, 29 Aug 2020 18:43:13 -0700 Subject: Removed DKEYMAP and added split build directories --- docs/docs/dev-build.md | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/docs/docs/dev-build.md b/docs/docs/dev-build.md index 2df15cd..393f483 100644 --- a/docs/docs/dev-build.md +++ b/docs/docs/dev-build.md @@ -43,7 +43,7 @@ Given the following: You can build ZMK with the following: ```sh -west build -b proton_c -- -DSHIELD=kyria_left -DKEYMAP=default +west build -b proton_c -- -DSHIELD=kyria_left ``` ### Keyboard With Onboard MCU @@ -58,14 +58,29 @@ Given the following: you can build ZMK with the following: ```sh -west build -b planck_rev6 -- -DKEYMAP=default +west build -b planck_rev6 ``` ### Pristine Building When building for a new board and/or shield after having built one previously, you may need to enable the pristine build option. This option removes all existing files in the build directory and regenerates them, and can be enabled by adding either --pristine or -p to the command: ```sh -west build -p -b proton_c -- -DSHIELD=kyria_left -DKEYMAP=default +west build -p -b proton_c -- -DSHIELD=kyria_left +``` +### Split Keyboards + +:::note +For split keyboards, you will have to build and flash each side separately the first time you install ZMK. +::: + +By default, the `build` command outputs a single .uf2 file named `zmk.uf2` so building left and then right immediately after will overwrite your left firmware. In addition, you will need to pristine build each side to ensure the correct files are used. To avoid having to pristine build each time and separate the left and right build files, we recommend setting up separate build directories for each half. You can do this by first building left into `build\left`: + +``` +west build -d build/left -b nice_nano -- -DSHIELD=kyria_left +``` +and then building right into `build\right`: +``` +west build -d build/right -b nice_nano -- -DSHIELD=kyria_right ``` ## Flashing @@ -79,10 +94,3 @@ west flash For boards that have drag and drop .uf2 flashing capability, the .uf2 file to flash can be found in `build\zephyr` and is by default named `zmk.uf2`. -:::note -For split keyboards, you will have to build and flash each side separately the first time you install ZMK. By default the `build` command outputs a single .uf2 file named `zmk.uf2`, so you will have to -1. Build the left side with the `build` command provided above -2. Flash `zmk.uf2` to the left side -3. Replace DSHIELD with the right side (for the above example, this would be `kyria_right`) and build again -4. Flash `zmk.uf2` the right side -::: -- cgit v1.2.3 From d2f4f00f69955d7befb9eec41c9c02094f3318aa Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Fri, 28 Aug 2020 23:10:25 -0400 Subject: feat(test): Add GH Action for tests. --- .github/workflows/test.yml | 62 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..3d2c76b --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,62 @@ +on: [push, pull_request] + +name: Test + +jobs: + integration_test: + runs-on: ubuntu-latest + name: Integration Tests + steps: + # To use this repository's private action, + # you must check out the repository + - name: Checkout + uses: actions/checkout@v2 + - name: Cache west modules + timeout-minutes: 2 + continue-on-error: true + uses: actions/cache@v2 + env: + cache-name: cache-zephyr-modules + with: + path: | + modules/ + tools/ + zephyr/ + bootloader/ + key: 2-${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('app/west.yml') }} + restore-keys: | + 2-${{ runner.os }}-build-${{ env.cache-name }}- + 2-${{ runner.os }}-build- + 2-${{ runner.os }}- + - name: West Init + uses: "docker://zmkfirmware/zephyr-west-action-arm:latest" + id: west-init + with: + args: 'init "-l app"' + - name: West Update + uses: "docker://zmkfirmware/zephyr-west-action-arm:latest" + id: west-update + with: + args: "update" + - name: West Config Zephyr Base + uses: "docker://zmkfirmware/zephyr-west-action-arm:latest" + id: west-config + with: + args: 'config "--global zephyr.base-prefer configfile"' + - name: West Zephyr Export + uses: "docker://zmkfirmware/zephyr-west-action-arm:latest" + id: west-zephyr-export + with: + args: "zephyr-export" + - name: Test All + uses: "docker://zmkfirmware/zephyr-west-action-arm:latest" + id: west-build + with: + entrypoint: /bin/bash + args: '-c "cd app && ./run-test.sh all"' + - name: Archive Build + if: ${{ always() }} + uses: actions/upload-artifact@v2 + with: + name: "log-files" + path: app/build/**/*.log -- cgit v1.2.3 From bc13cd1de1b647a519d051ed44f69a09ad75bfbf Mon Sep 17 00:00:00 2001 From: Kevin Date: Sat, 29 Aug 2020 19:22:43 -0700 Subject: Added PuTTY to USB Logging --- docs/docs/assets/usb-logging/com_port.PNG | Bin 0 -> 14258 bytes docs/docs/assets/usb-logging/putty.PNG | Bin 0 -> 19822 bytes docs/docs/dev-guide-usb-logging.md | 8 +++++++- 3 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 docs/docs/assets/usb-logging/com_port.PNG create mode 100644 docs/docs/assets/usb-logging/putty.PNG diff --git a/docs/docs/assets/usb-logging/com_port.PNG b/docs/docs/assets/usb-logging/com_port.PNG new file mode 100644 index 0000000..35934b8 Binary files /dev/null and b/docs/docs/assets/usb-logging/com_port.PNG differ diff --git a/docs/docs/assets/usb-logging/putty.PNG b/docs/docs/assets/usb-logging/putty.PNG new file mode 100644 index 0000000..b53d536 Binary files /dev/null and b/docs/docs/assets/usb-logging/putty.PNG differ diff --git a/docs/docs/dev-guide-usb-logging.md b/docs/docs/dev-guide-usb-logging.md index fa4b63b..62977c7 100644 --- a/docs/docs/dev-guide-usb-logging.md +++ b/docs/docs/dev-guide-usb-logging.md @@ -62,7 +62,13 @@ sudo tio /dev/ttyACM0 -On Windows, you can use the Arduino IDE which contains a built-in Serial Monitor. Download and install it from [their website](https://www.arduino.cc/en/main/software), then connect your board and under Tools select "Serial Monitor". +On Windows, you can use [PuTTY](https://www.putty.org/). Once installed, use Device Manager to figure out which COM port your controller is communicating on (listed under 'Ports (COM & LPT)') and specify that as the 'Serial line' in PuTTY. + +![Controller COM port](assets/usb-logging/com_port.png) + +![PuTTY settings](assets/usb-logging/putty.png) + +If you already have the Ardunio IDE installed you can also use its built-in Serial Monitor. -- cgit v1.2.3 From 8594d832b663c92d5d1ccfe14c65419835f4059e Mon Sep 17 00:00:00 2001 From: Kevin Date: Sat, 29 Aug 2020 19:23:25 -0700 Subject: Added split build directories --- docs/docs/dev-build.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/docs/dev-build.md b/docs/docs/dev-build.md index 393f483..b962a7d 100644 --- a/docs/docs/dev-build.md +++ b/docs/docs/dev-build.md @@ -62,26 +62,27 @@ west build -b planck_rev6 ``` ### Pristine Building -When building for a new board and/or shield after having built one previously, you may need to enable the pristine build option. This option removes all existing files in the build directory and regenerates them, and can be enabled by adding either --pristine or -p to the command: +When building for a new board and/or shield after having built one previously, you may need to enable the pristine build option. This option removes all existing files in the build directory before regenerating them, and can be enabled by adding either --pristine or -p to the command: ```sh west build -p -b proton_c -- -DSHIELD=kyria_left ``` -### Split Keyboards +### Building For Split Keyboards :::note For split keyboards, you will have to build and flash each side separately the first time you install ZMK. ::: -By default, the `build` command outputs a single .uf2 file named `zmk.uf2` so building left and then right immediately after will overwrite your left firmware. In addition, you will need to pristine build each side to ensure the correct files are used. To avoid having to pristine build each time and separate the left and right build files, we recommend setting up separate build directories for each half. You can do this by first building left into `build\left`: +By default, the `build` command outputs a single .uf2 file named `zmk.uf2` so building left and then right immediately after will overwrite your left firmware. In addition, you will need to pristine build each side to ensure the correct files are used. To avoid having to pristine build every time and separate the left and right build files, we recommend setting up separate build directories for each half. You can do this by using the `-d` parameter and first building left into `build/left`: ``` west build -d build/left -b nice_nano -- -DSHIELD=kyria_left ``` -and then building right into `build\right`: +and then building right into `build/right`: ``` west build -d build/right -b nice_nano -- -DSHIELD=kyria_right ``` +This produces `left` and `right` subfolders under the `build` directory and two separate .uf2 files. For future work on a specific half, use the `-d` parameter again to ensure you are building into the correct location. ## Flashing @@ -92,5 +93,5 @@ board with it in bootloader mode: west flash ``` -For boards that have drag and drop .uf2 flashing capability, the .uf2 file to flash can be found in `build\zephyr` and is by default named `zmk.uf2`. +For boards that have drag and drop .uf2 flashing capability, the .uf2 file to flash can be found in `build\zephyr` (or `build\left|right\zephyr` if you followed the instructions for splits) and is by default named `zmk.uf2`. -- cgit v1.2.3 From 0a06760cda0cc9cbce4b4c188ea169194903a695 Mon Sep 17 00:00:00 2001 From: Kevin Date: Sat, 29 Aug 2020 19:26:11 -0700 Subject: Updated alt text --- docs/docs/dev-setup.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/docs/dev-setup.md b/docs/docs/dev-setup.md index e9c635a..1d7d703 100644 --- a/docs/docs/dev-setup.md +++ b/docs/docs/dev-setup.md @@ -367,23 +367,23 @@ On Windows, you will have to set two environment variables for ZMK to build prop 1. Open Start Menu and type 'env' to find the 'Edit the system environment variables' option. Open it. -![start menu](assets/env-var/start_menu.png) +![Environment variables in Start Menu](assets/env-var/start_menu.png) 2. Click 'Environment Variables...'. -![start menu](assets/env-var/env_var.png) +![Environment variables button](assets/env-var/env_var.png) 3. Click "New..." under System variables to create a new system variable. -![start menu](assets/env-var/new_variable.png) +![Environment variables menu](assets/env-var/new_variable.png) 4. Set the variable name to 'ZEPHYR_TOOLCHAIN_VARIANT' and value to 'gnuarmemb'. Click OK to save. -![start menu](assets/env-var/zephyr_toolchain.png) +![Adding Zephyr toolchain variable](assets/env-var/zephyr_toolchain.png) 5. Create another variable with variable name 'GNUARMEMB_TOOLCHAIN_PATH' and value set to wherever you installed your toolchain. Click OK to save. -![start menu](assets/env-var/gnuarmemb.png) +![Adding GNUARMEMB variable](assets/env-var/gnuarmemb.png) -- cgit v1.2.3 From 0e04596ef610aa5c23cae5bdc80fd63ee28b3701 Mon Sep 17 00:00:00 2001 From: Kevin Date: Sat, 29 Aug 2020 21:04:32 -0700 Subject: Renamed COM port image --- docs/docs/assets/usb-logging/com-port.PNG | Bin 0 -> 14258 bytes docs/docs/assets/usb-logging/com_port.PNG | Bin 14258 -> 0 bytes docs/docs/dev-guide-usb-logging.md | 2 +- 3 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 docs/docs/assets/usb-logging/com-port.PNG delete mode 100644 docs/docs/assets/usb-logging/com_port.PNG diff --git a/docs/docs/assets/usb-logging/com-port.PNG b/docs/docs/assets/usb-logging/com-port.PNG new file mode 100644 index 0000000..35934b8 Binary files /dev/null and b/docs/docs/assets/usb-logging/com-port.PNG differ diff --git a/docs/docs/assets/usb-logging/com_port.PNG b/docs/docs/assets/usb-logging/com_port.PNG deleted file mode 100644 index 35934b8..0000000 Binary files a/docs/docs/assets/usb-logging/com_port.PNG and /dev/null differ diff --git a/docs/docs/dev-guide-usb-logging.md b/docs/docs/dev-guide-usb-logging.md index 62977c7..b63494d 100644 --- a/docs/docs/dev-guide-usb-logging.md +++ b/docs/docs/dev-guide-usb-logging.md @@ -64,7 +64,7 @@ sudo tio /dev/ttyACM0 On Windows, you can use [PuTTY](https://www.putty.org/). Once installed, use Device Manager to figure out which COM port your controller is communicating on (listed under 'Ports (COM & LPT)') and specify that as the 'Serial line' in PuTTY. -![Controller COM port](assets/usb-logging/com_port.png) +![Controller COM port](assets/usb-logging/com-port.png) ![PuTTY settings](assets/usb-logging/putty.png) -- cgit v1.2.3 From af23445aa02cea100ba064770a139b4971a6fc39 Mon Sep 17 00:00:00 2001 From: Kevin Date: Sat, 29 Aug 2020 21:13:48 -0700 Subject: COM image fix --- docs/docs/assets/usb-logging/com-port.PNG | Bin 14258 -> 0 bytes docs/docs/assets/usb-logging/com.PNG | Bin 0 -> 14258 bytes docs/docs/dev-guide-usb-logging.md | 2 +- 3 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 docs/docs/assets/usb-logging/com-port.PNG create mode 100644 docs/docs/assets/usb-logging/com.PNG diff --git a/docs/docs/assets/usb-logging/com-port.PNG b/docs/docs/assets/usb-logging/com-port.PNG deleted file mode 100644 index 35934b8..0000000 Binary files a/docs/docs/assets/usb-logging/com-port.PNG and /dev/null differ diff --git a/docs/docs/assets/usb-logging/com.PNG b/docs/docs/assets/usb-logging/com.PNG new file mode 100644 index 0000000..35934b8 Binary files /dev/null and b/docs/docs/assets/usb-logging/com.PNG differ diff --git a/docs/docs/dev-guide-usb-logging.md b/docs/docs/dev-guide-usb-logging.md index b63494d..6eca165 100644 --- a/docs/docs/dev-guide-usb-logging.md +++ b/docs/docs/dev-guide-usb-logging.md @@ -64,7 +64,7 @@ sudo tio /dev/ttyACM0 On Windows, you can use [PuTTY](https://www.putty.org/). Once installed, use Device Manager to figure out which COM port your controller is communicating on (listed under 'Ports (COM & LPT)') and specify that as the 'Serial line' in PuTTY. -![Controller COM port](assets/usb-logging/com-port.png) +![Controller COM port](./assets/usb-logging/com.png) ![PuTTY settings](assets/usb-logging/putty.png) -- cgit v1.2.3 From 06af711f57df20b195a1cf37b1a31ceee9a672b6 Mon Sep 17 00:00:00 2001 From: Kevin Date: Sat, 29 Aug 2020 21:20:38 -0700 Subject: Replaced png with jpg --- docs/docs/assets/usb-logging/com.PNG | Bin 14258 -> 0 bytes docs/docs/assets/usb-logging/com.jpg | Bin 0 -> 10993 bytes docs/docs/dev-guide-usb-logging.md | 2 +- 3 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 docs/docs/assets/usb-logging/com.PNG create mode 100644 docs/docs/assets/usb-logging/com.jpg diff --git a/docs/docs/assets/usb-logging/com.PNG b/docs/docs/assets/usb-logging/com.PNG deleted file mode 100644 index 35934b8..0000000 Binary files a/docs/docs/assets/usb-logging/com.PNG and /dev/null differ diff --git a/docs/docs/assets/usb-logging/com.jpg b/docs/docs/assets/usb-logging/com.jpg new file mode 100644 index 0000000..e2ab9a8 Binary files /dev/null and b/docs/docs/assets/usb-logging/com.jpg differ diff --git a/docs/docs/dev-guide-usb-logging.md b/docs/docs/dev-guide-usb-logging.md index 6eca165..11b568e 100644 --- a/docs/docs/dev-guide-usb-logging.md +++ b/docs/docs/dev-guide-usb-logging.md @@ -64,7 +64,7 @@ sudo tio /dev/ttyACM0 On Windows, you can use [PuTTY](https://www.putty.org/). Once installed, use Device Manager to figure out which COM port your controller is communicating on (listed under 'Ports (COM & LPT)') and specify that as the 'Serial line' in PuTTY. -![Controller COM port](./assets/usb-logging/com.png) +![Controller COM port](./assets/usb-logging/com.jpg) ![PuTTY settings](assets/usb-logging/putty.png) -- cgit v1.2.3 From 212dd91e2910e58e5a5c0c32e8726f2efc396c22 Mon Sep 17 00:00:00 2001 From: Kevin Date: Sat, 29 Aug 2020 21:27:03 -0700 Subject: PuTTY image fix --- docs/docs/assets/bond-clearing/debug.log | 0 docs/docs/assets/usb-logging/putty.PNG | Bin 19822 -> 0 bytes docs/docs/assets/usb-logging/putty.jpg | Bin 0 -> 160650 bytes docs/docs/dev-guide-usb-logging.md | 2 +- 4 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 docs/docs/assets/bond-clearing/debug.log delete mode 100644 docs/docs/assets/usb-logging/putty.PNG create mode 100644 docs/docs/assets/usb-logging/putty.jpg diff --git a/docs/docs/assets/bond-clearing/debug.log b/docs/docs/assets/bond-clearing/debug.log new file mode 100644 index 0000000..e69de29 diff --git a/docs/docs/assets/usb-logging/putty.PNG b/docs/docs/assets/usb-logging/putty.PNG deleted file mode 100644 index b53d536..0000000 Binary files a/docs/docs/assets/usb-logging/putty.PNG and /dev/null differ diff --git a/docs/docs/assets/usb-logging/putty.jpg b/docs/docs/assets/usb-logging/putty.jpg new file mode 100644 index 0000000..dfbb4bd Binary files /dev/null and b/docs/docs/assets/usb-logging/putty.jpg differ diff --git a/docs/docs/dev-guide-usb-logging.md b/docs/docs/dev-guide-usb-logging.md index 11b568e..c5fb4b9 100644 --- a/docs/docs/dev-guide-usb-logging.md +++ b/docs/docs/dev-guide-usb-logging.md @@ -66,7 +66,7 @@ On Windows, you can use [PuTTY](https://www.putty.org/). Once installed, use Dev ![Controller COM port](./assets/usb-logging/com.jpg) -![PuTTY settings](assets/usb-logging/putty.png) +![PuTTY settings](assets/usb-logging/putty.jpg) If you already have the Ardunio IDE installed you can also use its built-in Serial Monitor. -- cgit v1.2.3 From 45b1756a700ba0603f0a3b7708108c9ebc9fc945 Mon Sep 17 00:00:00 2001 From: Kevin Chen Date: Sat, 29 Aug 2020 21:36:00 -0700 Subject: Replaced \ with / Co-authored-by: Pete Johanson --- docs/docs/dev-build.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/docs/dev-build.md b/docs/docs/dev-build.md index b962a7d..816468e 100644 --- a/docs/docs/dev-build.md +++ b/docs/docs/dev-build.md @@ -93,5 +93,4 @@ board with it in bootloader mode: west flash ``` -For boards that have drag and drop .uf2 flashing capability, the .uf2 file to flash can be found in `build\zephyr` (or `build\left|right\zephyr` if you followed the instructions for splits) and is by default named `zmk.uf2`. - +For boards that have drag and drop .uf2 flashing capability, the .uf2 file to flash can be found in `build/zephyr` (or `build/left|right/zephyr` if you followed the instructions for splits) and is by default named `zmk.uf2`. -- cgit v1.2.3 From 96fde775604be02f2aeee04f3cd6d4edff2815bd Mon Sep 17 00:00:00 2001 From: Kurtis Lew Date: Sun, 30 Aug 2020 20:12:53 -0700 Subject: Update key-press.md Specified keypress and consumer press pages --- docs/docs/behavior/key-press.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/behavior/key-press.md b/docs/docs/behavior/key-press.md index 2edce1d..f58225d 100644 --- a/docs/docs/behavior/key-press.md +++ b/docs/docs/behavior/key-press.md @@ -8,7 +8,7 @@ sidebar_label: Key Press The most basic of behaviors, is the ability to send certain keycode presses and releases in response to activating a certain key. -For reference on keycode values, see the [USB HID Usage Tables](https://www.usb.org/document-library/hid-usage-tables-12). +For reference on keycode values, see pages 83-89 of the [USB HID Usage Tables](https://www.usb.org/document-library/hid-usage-tables-12). ## Keycode Defines -- cgit v1.2.3 From 21fcab208e50bf8ccbe9e238662ca86c35dab077 Mon Sep 17 00:00:00 2001 From: Okke Formsma Date: Mon, 31 Aug 2020 22:24:36 +0200 Subject: stop on fatal errors --- app/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 9fce3b6..db56c53 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -56,3 +56,5 @@ target_sources_ifdef(CONFIG_ZMK_RGB_UNDERGLOW app PRIVATE src/rgb_underglow.c) target_sources(app PRIVATE src/endpoints.c) target_sources(app PRIVATE src/hid_listener.c) target_sources(app PRIVATE src/main.c) + +zephyr_cc_option(-Wfatal-errors) \ No newline at end of file -- cgit v1.2.3 From 639a338c2dd6801ae8fa4d82c9d7101405b2dc7b Mon Sep 17 00:00:00 2001 From: Cody McGinnis Date: Tue, 1 Sep 2020 09:34:06 -0400 Subject: fix(core): track layer state with keypress --- app/src/keymap.c | 56 ++++++++++++++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/app/src/keymap.c b/app/src/keymap.c index ee6e370..57cdad6 100644 --- a/app/src/keymap.c +++ b/app/src/keymap.c @@ -51,10 +51,10 @@ static u8_t zmk_keymap_layer_default = 0; // State -// When a behavior handles a key position "down" event, we record that layer +// When a behavior handles a key position "down" event, we record the layer state // here so that even if that layer is deactivated before the "up", event, we // still send the release event to the behavior in that layer also. -static u8_t zmk_keymap_active_behavior_layer[ZMK_KEYMAP_LEN]; +static u32_t zmk_keymap_active_behavior_layer[ZMK_KEYMAP_LEN]; static struct zmk_behavior_binding zmk_keymap[ZMK_KEYMAP_LAYERS_LEN][ZMK_KEYMAP_LEN] = { DT_INST_FOREACH_CHILD(0, TRANSFORMED_LAYER) @@ -101,47 +101,51 @@ int zmk_keymap_layer_toggle(u8_t layer) return zmk_keymap_layer_activate(layer); }; -bool is_active_position(u32_t position, u8_t layer) +bool is_active_layer(u8_t layer, u32_t layer_state) { - return (zmk_keymap_layer_state & BIT(layer)) == BIT(layer) - || layer == zmk_keymap_layer_default - || zmk_keymap_active_behavior_layer[position] == layer; + return (layer_state & BIT(layer)) == BIT(layer) + || layer == zmk_keymap_layer_default; } +int zmk_keymap_apply_position_state(int layer, u32_t position, bool pressed) +{ + struct zmk_behavior_binding *binding = &zmk_keymap[layer][position]; + struct device *behavior; + + LOG_DBG("layer: %d position: %d, binding name: %s", layer, position, log_strdup(binding->behavior_dev)); + + behavior = device_get_binding(binding->behavior_dev); + + if (!behavior) { + LOG_DBG("No behavior assigned to %d on layer %d", position, layer); + return 1; + } + + if (pressed) { + return behavior_keymap_binding_pressed(behavior, position, binding->param1, binding->param2); + } else { + return behavior_keymap_binding_released(behavior, position, binding->param1, binding->param2); + } +} + int zmk_keymap_position_state_changed(u32_t position, bool pressed) { for (int layer = ZMK_KEYMAP_LAYERS_LEN - 1; layer >= zmk_keymap_layer_default; layer--) { - if (is_active_position(position, layer)) + u32_t layer_state = pressed ? zmk_keymap_layer_state : zmk_keymap_active_behavior_layer[position]; + if (is_active_layer(layer, layer_state)) { - struct zmk_behavior_binding *binding = &zmk_keymap[layer][position]; - struct device *behavior; - int ret; - - LOG_DBG("layer: %d position: %d, binding name: %s", layer, position, log_strdup(binding->behavior_dev)); + int ret = zmk_keymap_apply_position_state(layer, position, pressed); - behavior = device_get_binding(binding->behavior_dev); - - if (!behavior) { - LOG_DBG("No behavior assigned to %d on layer %d", position, layer); - continue; - } - if (pressed) { - ret = behavior_keymap_binding_pressed(behavior, position, binding->param1, binding->param2); - } else { - ret = behavior_keymap_binding_released(behavior, position, binding->param1, binding->param2); - } - + zmk_keymap_active_behavior_layer[position] = zmk_keymap_layer_state; if (ret > 0) { LOG_DBG("behavior processing to continue to next layer"); continue; } else if (ret < 0) { LOG_DBG("Behavior returned error: %d", ret); - zmk_keymap_active_behavior_layer[position] = 0; return ret; } else { - zmk_keymap_active_behavior_layer[position] = pressed ? layer : 0; return ret; } } -- cgit v1.2.3 From 01db53b46a6eaf3126e0b44e2f3fc18fd4ae0114 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Tue, 1 Sep 2020 09:55:25 -0400 Subject: fix(kscan): Avoid sending duplicate kscan events. --- app/drivers/zephyr/kscan_gpio_direct.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/drivers/zephyr/kscan_gpio_direct.c b/app/drivers/zephyr/kscan_gpio_direct.c index 6e0beb0..a3aa8c4 100644 --- a/app/drivers/zephyr/kscan_gpio_direct.c +++ b/app/drivers/zephyr/kscan_gpio_direct.c @@ -156,7 +156,6 @@ static int kscan_gpio_read(struct device *dev) struct kscan_gpio_data *data = dev->driver_data; const struct kscan_gpio_config *cfg = dev->config_info; u32_t read_state = data->pin_state; - LOG_DBG("Scanning the pins for updated state"); for (int i = 0; i < cfg->num_of_inputs; i++) { struct device *in_dev = kscan_gpio_input_devices(dev)[i]; @@ -165,8 +164,9 @@ static int kscan_gpio_read(struct device *dev) } for (int i = 0; i < cfg->num_of_inputs; i++) { + bool prev_pressed = BIT(i) & data->pin_state; bool pressed = BIT(i) & read_state; - if (pressed != (BIT(i) & data->pin_state)) + if (pressed != prev_pressed) { LOG_DBG("Sending event at %d,%d state %s", 0, i, (pressed ? "on" : "off")); -- cgit v1.2.3 From ca0f2bb074a103b871a3e0f7f5e1fed8b6b4069b Mon Sep 17 00:00:00 2001 From: CrossR Date: Tue, 1 Sep 2020 18:32:45 +0100 Subject: Add to setup. --- app/boards/shields/sofle/sofle.dtsi | 14 ++++++-------- docs/static/setup.sh | 3 ++- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/app/boards/shields/sofle/sofle.dtsi b/app/boards/shields/sofle/sofle.dtsi index 9b3d3c0..653a772 100644 --- a/app/boards/shields/sofle/sofle.dtsi +++ b/app/boards/shields/sofle/sofle.dtsi @@ -47,19 +47,17 @@ RC(3,0) RC(3,1) RC(3,2) RC(3,3) RC(3,4) RC(3,5) RC(4,5) RC(4,6) RC(3,6) RC(3,7) left_encoder: encoder_left { compatible = "alps,ec11"; label = "LEFT_ENCODER"; - a-gpios = <&pro_micro_a 2 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; - b-gpios = <&pro_micro_a 3 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; - resolution = <2>; - status = "disabled"; + a-gpios = <&pro_micro_a 3 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; + b-gpios = <&pro_micro_a 2 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; + resolution = <4>; }; right_encoder: encoder_right { compatible = "alps,ec11"; label = "RIGHT_ENCODER"; - a-gpios = <&pro_micro_a 3 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; - b-gpios = <&pro_micro_a 2 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; - resolution = <2>; - status = "disabled"; + a-gpios = <&pro_micro_a 2 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; + b-gpios = <&pro_micro_a 3 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; + resolution = <4>; }; sensors { diff --git a/docs/static/setup.sh b/docs/static/setup.sh index 4dc740a..a32718d 100644 --- a/docs/static/setup.sh +++ b/docs/static/setup.sh @@ -38,7 +38,7 @@ echo "" echo "Keyboard Shield Selection:" prompt="Pick an keyboard:" -options=("Kyria" "Lily58" "Corne" "Splitreus62") +options=("Kyria" "Lily58" "Corne" "Splitreus62" "Sofle") PS3="$prompt " # TODO: Add support for "Other" and linking to docs on adding custom shields in user config repos. @@ -51,6 +51,7 @@ select opt in "${options[@]}" "Quit"; do 2 ) shield_title="Lily58" shield="lily58"; split="y"; break;; 3 ) shield_title="Corne" shield="corne"; split="y"; break;; 4 ) shield_title="Splitreus62" shield="splitreus62"; split="y"; break;; + 5 ) shield_title="Sofle" shield="sofle"; split="y"; break;; # Add link to docs on adding your own custom shield in your ZMK config! # $(( ${#options[@]}+1 )) ) echo "Other!"; break;; -- cgit v1.2.3 From c33931c72c179d19028b2d70ec043cbc3d786137 Mon Sep 17 00:00:00 2001 From: Okke Formsma Date: Tue, 1 Sep 2020 14:37:37 +0200 Subject: Initial implementation of hold-tap --- app/CMakeLists.txt | 4 +- app/dts/behaviors.dtsi | 2 + app/dts/behaviors/homerow_tap.dtsi | 12 + app/dts/behaviors/layer_tap.dtsi | 12 + app/dts/behaviors/mod_tap.dtsi | 5 +- .../bindings/behaviors/zmk,behavior-mod-tap.yaml | 8 - .../bindings/behaviors/zmk,behavior-tap-hold.yaml | 23 + app/include/zmk/event-manager.h | 4 + app/run-test-debug.sh | 44 ++ app/src/behaviors/behavior_hold_tap.c | 491 +++++++++++++++++++++ app/src/behaviors/behavior_mod_tap.c | 252 ----------- app/src/event_manager.c | 6 + app/tests/hold-tap/balanced/1/events.patterns | 4 + .../hold-tap/balanced/1/keycode_events.snapshot | 5 + app/tests/hold-tap/balanced/1/native_posix.keymap | 11 + app/tests/hold-tap/balanced/2/events.patterns | 4 + .../hold-tap/balanced/2/keycode_events.snapshot | 5 + app/tests/hold-tap/balanced/2/native_posix.keymap | 11 + app/tests/hold-tap/balanced/3a/events.patterns | 4 + .../hold-tap/balanced/3a/keycode_events.snapshot | 7 + app/tests/hold-tap/balanced/3a/native_posix.keymap | 13 + app/tests/hold-tap/balanced/3b/events.patterns | 4 + .../hold-tap/balanced/3b/keycode_events.snapshot | 7 + app/tests/hold-tap/balanced/3b/native_posix.keymap | 14 + app/tests/hold-tap/balanced/3c/events.patterns | 4 + .../hold-tap/balanced/3c/keycode_events.snapshot | 7 + app/tests/hold-tap/balanced/3c/native_posix.keymap | 13 + app/tests/hold-tap/balanced/3d/events.patterns | 4 + .../hold-tap/balanced/3d/keycode_events.snapshot | 7 + app/tests/hold-tap/balanced/3d/native_posix.keymap | 13 + .../hold-tap/balanced/4a-nested/events.patterns | 4 + .../balanced/4a-nested/keycode_events.snapshot | 10 + .../balanced/4a-nested/native_posix.keymap | 14 + app/tests/hold-tap/balanced/4a/events.patterns | 4 + .../hold-tap/balanced/4a/keycode_events.snapshot | 7 + app/tests/hold-tap/balanced/4a/native_posix.keymap | 14 + app/tests/hold-tap/balanced/4b/events.patterns | 4 + .../hold-tap/balanced/4b/keycode_events.snapshot | 7 + app/tests/hold-tap/balanced/4b/native_posix.keymap | 14 + app/tests/hold-tap/balanced/4c/events.patterns | 4 + .../hold-tap/balanced/4c/keycode_events.snapshot | 7 + app/tests/hold-tap/balanced/4c/native_posix.keymap | 14 + app/tests/hold-tap/balanced/4d/events.patterns | 4 + .../hold-tap/balanced/4d/keycode_events.snapshot | 7 + app/tests/hold-tap/balanced/4d/native_posix.keymap | 14 + app/tests/hold-tap/balanced/behavior_keymap.dtsi | 27 ++ .../hold-tap/hold-preferred/1/events.patterns | 4 + .../hold-preferred/1/keycode_events.snapshot | 5 + .../hold-tap/hold-preferred/1/native_posix.keymap | 11 + .../hold-tap/hold-preferred/2/events.patterns | 4 + .../hold-preferred/2/keycode_events.snapshot | 5 + .../hold-tap/hold-preferred/2/native_posix.keymap | 11 + .../hold-tap/hold-preferred/3a/events.patterns | 4 + .../hold-preferred/3a/keycode_events.snapshot | 7 + .../hold-tap/hold-preferred/3a/native_posix.keymap | 13 + .../hold-tap/hold-preferred/3b/events.patterns | 4 + .../hold-preferred/3b/keycode_events.snapshot | 7 + .../hold-tap/hold-preferred/3b/native_posix.keymap | 14 + .../hold-tap/hold-preferred/3c/events.patterns | 4 + .../hold-preferred/3c/keycode_events.snapshot | 7 + .../hold-tap/hold-preferred/3c/native_posix.keymap | 13 + .../hold-tap/hold-preferred/3d/events.patterns | 4 + .../hold-preferred/3d/keycode_events.snapshot | 7 + .../hold-tap/hold-preferred/3d/native_posix.keymap | 13 + .../hold-preferred/4a-nested/events.patterns | 4 + .../4a-nested/keycode_events.snapshot | 10 + .../hold-preferred/4a-nested/native_posix.keymap | 14 + .../hold-tap/hold-preferred/4a/events.patterns | 4 + .../hold-preferred/4a/keycode_events.snapshot | 7 + .../hold-tap/hold-preferred/4a/native_posix.keymap | 14 + .../hold-tap/hold-preferred/4b/events.patterns | 4 + .../hold-preferred/4b/keycode_events.snapshot | 7 + .../hold-tap/hold-preferred/4b/native_posix.keymap | 14 + .../hold-tap/hold-preferred/4c/events.patterns | 4 + .../hold-preferred/4c/keycode_events.snapshot | 7 + .../hold-tap/hold-preferred/4c/native_posix.keymap | 14 + .../hold-tap/hold-preferred/4d/events.patterns | 4 + .../hold-preferred/4d/keycode_events.snapshot | 7 + .../hold-tap/hold-preferred/4d/native_posix.keymap | 14 + .../hold-tap/hold-preferred/behavior_keymap.dtsi | 29 ++ app/tests/hold-tap/tap-preferred/1/events.patterns | 4 + .../tap-preferred/1/keycode_events.snapshot | 5 + .../hold-tap/tap-preferred/1/native_posix.keymap | 11 + app/tests/hold-tap/tap-preferred/2/events.patterns | 4 + .../tap-preferred/2/keycode_events.snapshot | 5 + .../hold-tap/tap-preferred/2/native_posix.keymap | 11 + .../hold-tap/tap-preferred/3a/events.patterns | 4 + .../tap-preferred/3a/keycode_events.snapshot | 7 + .../hold-tap/tap-preferred/3a/native_posix.keymap | 13 + .../hold-tap/tap-preferred/3b/events.patterns | 4 + .../tap-preferred/3b/keycode_events.snapshot | 7 + .../hold-tap/tap-preferred/3b/native_posix.keymap | 14 + .../hold-tap/tap-preferred/3c/events.patterns | 4 + .../tap-preferred/3c/keycode_events.snapshot | 7 + .../hold-tap/tap-preferred/3c/native_posix.keymap | 13 + .../hold-tap/tap-preferred/3d/events.patterns | 4 + .../tap-preferred/3d/keycode_events.snapshot | 7 + .../hold-tap/tap-preferred/3d/native_posix.keymap | 13 + .../tap-preferred/4a-nested/events.patterns | 4 + .../4a-nested/keycode_events.snapshot | 10 + .../tap-preferred/4a-nested/native_posix.keymap | 14 + .../hold-tap/tap-preferred/4a/events.patterns | 4 + .../tap-preferred/4a/keycode_events.snapshot | 7 + .../hold-tap/tap-preferred/4a/native_posix.keymap | 14 + .../hold-tap/tap-preferred/4b/events.patterns | 4 + .../tap-preferred/4b/keycode_events.snapshot | 7 + .../hold-tap/tap-preferred/4b/native_posix.keymap | 14 + .../hold-tap/tap-preferred/4c/events.patterns | 4 + .../tap-preferred/4c/keycode_events.snapshot | 7 + .../hold-tap/tap-preferred/4c/native_posix.keymap | 14 + .../hold-tap/tap-preferred/4d/events.patterns | 4 + .../tap-preferred/4d/keycode_events.snapshot | 7 + .../hold-tap/tap-preferred/4d/native_posix.keymap | 14 + .../hold-tap/tap-preferred/behavior_keymap.dtsi | 27 ++ app/tests/hold-tap/zmk-modtap-proposal.odg | Bin 0 -> 23148 bytes app/tests/hold-tap/zmk-modtap-proposal.pdf | Bin 0 -> 25493 bytes app/tests/tap-hold/balanced/behavior_keymap.dtsi | 27 ++ .../tap-hold/hold-preferred/behavior_keymap.dtsi | 29 ++ .../tap-hold/tap-preferred/behavior_keymap.dtsi | 27 ++ 119 files changed, 1561 insertions(+), 263 deletions(-) create mode 100644 app/dts/behaviors/homerow_tap.dtsi create mode 100644 app/dts/behaviors/layer_tap.dtsi delete mode 100644 app/dts/bindings/behaviors/zmk,behavior-mod-tap.yaml create mode 100644 app/dts/bindings/behaviors/zmk,behavior-tap-hold.yaml create mode 100755 app/run-test-debug.sh create mode 100644 app/src/behaviors/behavior_hold_tap.c delete mode 100644 app/src/behaviors/behavior_mod_tap.c create mode 100644 app/tests/hold-tap/balanced/1/events.patterns create mode 100644 app/tests/hold-tap/balanced/1/keycode_events.snapshot create mode 100644 app/tests/hold-tap/balanced/1/native_posix.keymap create mode 100644 app/tests/hold-tap/balanced/2/events.patterns create mode 100644 app/tests/hold-tap/balanced/2/keycode_events.snapshot create mode 100644 app/tests/hold-tap/balanced/2/native_posix.keymap create mode 100644 app/tests/hold-tap/balanced/3a/events.patterns create mode 100644 app/tests/hold-tap/balanced/3a/keycode_events.snapshot create mode 100644 app/tests/hold-tap/balanced/3a/native_posix.keymap create mode 100644 app/tests/hold-tap/balanced/3b/events.patterns create mode 100644 app/tests/hold-tap/balanced/3b/keycode_events.snapshot create mode 100644 app/tests/hold-tap/balanced/3b/native_posix.keymap create mode 100644 app/tests/hold-tap/balanced/3c/events.patterns create mode 100644 app/tests/hold-tap/balanced/3c/keycode_events.snapshot create mode 100644 app/tests/hold-tap/balanced/3c/native_posix.keymap create mode 100644 app/tests/hold-tap/balanced/3d/events.patterns create mode 100644 app/tests/hold-tap/balanced/3d/keycode_events.snapshot create mode 100644 app/tests/hold-tap/balanced/3d/native_posix.keymap create mode 100644 app/tests/hold-tap/balanced/4a-nested/events.patterns create mode 100644 app/tests/hold-tap/balanced/4a-nested/keycode_events.snapshot create mode 100644 app/tests/hold-tap/balanced/4a-nested/native_posix.keymap create mode 100644 app/tests/hold-tap/balanced/4a/events.patterns create mode 100644 app/tests/hold-tap/balanced/4a/keycode_events.snapshot create mode 100644 app/tests/hold-tap/balanced/4a/native_posix.keymap create mode 100644 app/tests/hold-tap/balanced/4b/events.patterns create mode 100644 app/tests/hold-tap/balanced/4b/keycode_events.snapshot create mode 100644 app/tests/hold-tap/balanced/4b/native_posix.keymap create mode 100644 app/tests/hold-tap/balanced/4c/events.patterns create mode 100644 app/tests/hold-tap/balanced/4c/keycode_events.snapshot create mode 100644 app/tests/hold-tap/balanced/4c/native_posix.keymap create mode 100644 app/tests/hold-tap/balanced/4d/events.patterns create mode 100644 app/tests/hold-tap/balanced/4d/keycode_events.snapshot create mode 100644 app/tests/hold-tap/balanced/4d/native_posix.keymap create mode 100644 app/tests/hold-tap/balanced/behavior_keymap.dtsi create mode 100644 app/tests/hold-tap/hold-preferred/1/events.patterns create mode 100644 app/tests/hold-tap/hold-preferred/1/keycode_events.snapshot create mode 100644 app/tests/hold-tap/hold-preferred/1/native_posix.keymap create mode 100644 app/tests/hold-tap/hold-preferred/2/events.patterns create mode 100644 app/tests/hold-tap/hold-preferred/2/keycode_events.snapshot create mode 100644 app/tests/hold-tap/hold-preferred/2/native_posix.keymap create mode 100644 app/tests/hold-tap/hold-preferred/3a/events.patterns create mode 100644 app/tests/hold-tap/hold-preferred/3a/keycode_events.snapshot create mode 100644 app/tests/hold-tap/hold-preferred/3a/native_posix.keymap create mode 100644 app/tests/hold-tap/hold-preferred/3b/events.patterns create mode 100644 app/tests/hold-tap/hold-preferred/3b/keycode_events.snapshot create mode 100644 app/tests/hold-tap/hold-preferred/3b/native_posix.keymap create mode 100644 app/tests/hold-tap/hold-preferred/3c/events.patterns create mode 100644 app/tests/hold-tap/hold-preferred/3c/keycode_events.snapshot create mode 100644 app/tests/hold-tap/hold-preferred/3c/native_posix.keymap create mode 100644 app/tests/hold-tap/hold-preferred/3d/events.patterns create mode 100644 app/tests/hold-tap/hold-preferred/3d/keycode_events.snapshot create mode 100644 app/tests/hold-tap/hold-preferred/3d/native_posix.keymap create mode 100644 app/tests/hold-tap/hold-preferred/4a-nested/events.patterns create mode 100644 app/tests/hold-tap/hold-preferred/4a-nested/keycode_events.snapshot create mode 100644 app/tests/hold-tap/hold-preferred/4a-nested/native_posix.keymap create mode 100644 app/tests/hold-tap/hold-preferred/4a/events.patterns create mode 100644 app/tests/hold-tap/hold-preferred/4a/keycode_events.snapshot create mode 100644 app/tests/hold-tap/hold-preferred/4a/native_posix.keymap create mode 100644 app/tests/hold-tap/hold-preferred/4b/events.patterns create mode 100644 app/tests/hold-tap/hold-preferred/4b/keycode_events.snapshot create mode 100644 app/tests/hold-tap/hold-preferred/4b/native_posix.keymap create mode 100644 app/tests/hold-tap/hold-preferred/4c/events.patterns create mode 100644 app/tests/hold-tap/hold-preferred/4c/keycode_events.snapshot create mode 100644 app/tests/hold-tap/hold-preferred/4c/native_posix.keymap create mode 100644 app/tests/hold-tap/hold-preferred/4d/events.patterns create mode 100644 app/tests/hold-tap/hold-preferred/4d/keycode_events.snapshot create mode 100644 app/tests/hold-tap/hold-preferred/4d/native_posix.keymap create mode 100644 app/tests/hold-tap/hold-preferred/behavior_keymap.dtsi create mode 100644 app/tests/hold-tap/tap-preferred/1/events.patterns create mode 100644 app/tests/hold-tap/tap-preferred/1/keycode_events.snapshot create mode 100644 app/tests/hold-tap/tap-preferred/1/native_posix.keymap create mode 100644 app/tests/hold-tap/tap-preferred/2/events.patterns create mode 100644 app/tests/hold-tap/tap-preferred/2/keycode_events.snapshot create mode 100644 app/tests/hold-tap/tap-preferred/2/native_posix.keymap create mode 100644 app/tests/hold-tap/tap-preferred/3a/events.patterns create mode 100644 app/tests/hold-tap/tap-preferred/3a/keycode_events.snapshot create mode 100644 app/tests/hold-tap/tap-preferred/3a/native_posix.keymap create mode 100644 app/tests/hold-tap/tap-preferred/3b/events.patterns create mode 100644 app/tests/hold-tap/tap-preferred/3b/keycode_events.snapshot create mode 100644 app/tests/hold-tap/tap-preferred/3b/native_posix.keymap create mode 100644 app/tests/hold-tap/tap-preferred/3c/events.patterns create mode 100644 app/tests/hold-tap/tap-preferred/3c/keycode_events.snapshot create mode 100644 app/tests/hold-tap/tap-preferred/3c/native_posix.keymap create mode 100644 app/tests/hold-tap/tap-preferred/3d/events.patterns create mode 100644 app/tests/hold-tap/tap-preferred/3d/keycode_events.snapshot create mode 100644 app/tests/hold-tap/tap-preferred/3d/native_posix.keymap create mode 100644 app/tests/hold-tap/tap-preferred/4a-nested/events.patterns create mode 100644 app/tests/hold-tap/tap-preferred/4a-nested/keycode_events.snapshot create mode 100644 app/tests/hold-tap/tap-preferred/4a-nested/native_posix.keymap create mode 100644 app/tests/hold-tap/tap-preferred/4a/events.patterns create mode 100644 app/tests/hold-tap/tap-preferred/4a/keycode_events.snapshot create mode 100644 app/tests/hold-tap/tap-preferred/4a/native_posix.keymap create mode 100644 app/tests/hold-tap/tap-preferred/4b/events.patterns create mode 100644 app/tests/hold-tap/tap-preferred/4b/keycode_events.snapshot create mode 100644 app/tests/hold-tap/tap-preferred/4b/native_posix.keymap create mode 100644 app/tests/hold-tap/tap-preferred/4c/events.patterns create mode 100644 app/tests/hold-tap/tap-preferred/4c/keycode_events.snapshot create mode 100644 app/tests/hold-tap/tap-preferred/4c/native_posix.keymap create mode 100644 app/tests/hold-tap/tap-preferred/4d/events.patterns create mode 100644 app/tests/hold-tap/tap-preferred/4d/keycode_events.snapshot create mode 100644 app/tests/hold-tap/tap-preferred/4d/native_posix.keymap create mode 100644 app/tests/hold-tap/tap-preferred/behavior_keymap.dtsi create mode 100644 app/tests/hold-tap/zmk-modtap-proposal.odg create mode 100644 app/tests/hold-tap/zmk-modtap-proposal.pdf create mode 100644 app/tests/tap-hold/balanced/behavior_keymap.dtsi create mode 100644 app/tests/tap-hold/hold-preferred/behavior_keymap.dtsi create mode 100644 app/tests/tap-hold/tap-preferred/behavior_keymap.dtsi diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index db56c53..2e24fdc 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -25,7 +25,6 @@ zephyr_linker_sources(RODATA include/linker/zmk-events.ld) target_include_directories(app PRIVATE include) target_sources(app PRIVATE src/kscan.c) target_sources(app PRIVATE src/matrix_transform.c) -target_sources(app PRIVATE src/keymap.c) target_sources(app PRIVATE src/hid.c) target_sources(app PRIVATE src/sensors.c) target_sources_ifdef(CONFIG_ZMK_DISPLAY app PRIVATE src/display.c) @@ -36,12 +35,13 @@ target_sources(app PRIVATE src/events/modifiers_state_changed.c) target_sources(app PRIVATE src/events/sensor_event.c) 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_mod_tap.c) +target_sources(app PRIVATE src/behaviors/behavior_hold_tap.c) target_sources(app PRIVATE src/behaviors/behavior_momentary_layer.c) target_sources(app PRIVATE src/behaviors/behavior_toggle_layer.c) target_sources(app PRIVATE src/behaviors/behavior_transparent.c) target_sources(app PRIVATE src/behaviors/behavior_none.c) target_sources(app PRIVATE src/behaviors/behavior_sensor_rotate_key_press.c) +target_sources(app PRIVATE src/keymap.c) target_sources_ifdef(CONFIG_ZMK_RGB_UNDERGLOW app PRIVATE src/behaviors/behavior_rgb_underglow.c) target_sources_ifdef(CONFIG_ZMK_BLE app PRIVATE src/ble.c) target_sources_ifdef(CONFIG_ZMK_BLE app PRIVATE src/ble_unpair_combo.c) diff --git a/app/dts/behaviors.dtsi b/app/dts/behaviors.dtsi index 4cfb7a0..fdcf426 100644 --- a/app/dts/behaviors.dtsi +++ b/app/dts/behaviors.dtsi @@ -2,6 +2,8 @@ #include #include #include +#include +#include #include #include #include diff --git a/app/dts/behaviors/homerow_tap.dtsi b/app/dts/behaviors/homerow_tap.dtsi new file mode 100644 index 0000000..21c1531 --- /dev/null +++ b/app/dts/behaviors/homerow_tap.dtsi @@ -0,0 +1,12 @@ +/ { + behaviors { + ht: behavior_homerow_mod { + compatible = "zmk,behavior-hold-tap"; + label = "homerow_mod"; + #binding-cells = <2>; + flavor = "balanced"; + tapping_term_ms = <200>; + bindings = <&kp>, <&kp>; + }; + }; +}; diff --git a/app/dts/behaviors/layer_tap.dtsi b/app/dts/behaviors/layer_tap.dtsi new file mode 100644 index 0000000..af7319b --- /dev/null +++ b/app/dts/behaviors/layer_tap.dtsi @@ -0,0 +1,12 @@ +/ { + behaviors { + lt: behavior_layer_tap { + compatible = "zmk,behavior-hold-tap"; + label = "LAYER_TAP"; + #binding-cells = <2>; + flavor = "tap-preferred"; + tapping_term_ms = <200>; + bindings = <&mo>, <&kp>; + }; + }; +}; diff --git a/app/dts/behaviors/mod_tap.dtsi b/app/dts/behaviors/mod_tap.dtsi index 8e3b4e9..4ce732b 100644 --- a/app/dts/behaviors/mod_tap.dtsi +++ b/app/dts/behaviors/mod_tap.dtsi @@ -1,9 +1,12 @@ / { behaviors { mt: behavior_mod_tap { - compatible = "zmk,behavior-mod-tap"; + compatible = "zmk,behavior-hold-tap"; label = "MOD_TAP"; #binding-cells = <2>; + flavor = "hold-preferred"; + tapping_term_ms = <200>; + bindings = <&kp>, <&kp>; }; }; }; diff --git a/app/dts/bindings/behaviors/zmk,behavior-mod-tap.yaml b/app/dts/bindings/behaviors/zmk,behavior-mod-tap.yaml deleted file mode 100644 index 7911082..0000000 --- a/app/dts/bindings/behaviors/zmk,behavior-mod-tap.yaml +++ /dev/null @@ -1,8 +0,0 @@ -# Copyright (c) 2020, Pete Johanson -# SPDX-License-Identifier: MIT - -description: Mod-Tap Beavhior - -compatible: "zmk,behavior-mod-tap" - -include: two_param.yaml diff --git a/app/dts/bindings/behaviors/zmk,behavior-tap-hold.yaml b/app/dts/bindings/behaviors/zmk,behavior-tap-hold.yaml new file mode 100644 index 0000000..a20578f --- /dev/null +++ b/app/dts/bindings/behaviors/zmk,behavior-tap-hold.yaml @@ -0,0 +1,23 @@ +# Copyright (c) 2020, Cody McGinnis; Okke Formsma +# SPDX-License-Identifier: MIT + +description: Hold or Tap behavior + +compatible: "zmk,behavior-hold-tap" + +include: two_param.yaml + +properties: + bindings: + type: phandles + required: true + tapping_term_ms: + type: int + flavor: + type: string + required: false + default: "hold-preferred" + enum: + - "hold-preferred" + - "balanced" + - "tap-preferred" \ No newline at end of file diff --git a/app/include/zmk/event-manager.h b/app/include/zmk/event-manager.h index 43d3f29..07c0aa9 100644 --- a/app/include/zmk/event-manager.h +++ b/app/include/zmk/event-manager.h @@ -78,6 +78,10 @@ struct zmk_event_subscription { #define ZMK_EVENT_RELEASE(ev) \ zmk_event_manager_release((struct zmk_event_header *)ev); +#define ZMK_EVENT_RELEASE_AGAIN(ev) \ + zmk_event_manager_release_again((struct zmk_event_header *)ev); + int zmk_event_manager_raise(struct zmk_event_header *event); int zmk_event_manager_raise_after(struct zmk_event_header *event, const struct zmk_listener *listener); int zmk_event_manager_release(struct zmk_event_header *event); +int zmk_event_manager_release_again(struct zmk_event_header *event); diff --git a/app/run-test-debug.sh b/app/run-test-debug.sh new file mode 100755 index 0000000..f6696a1 --- /dev/null +++ b/app/run-test-debug.sh @@ -0,0 +1,44 @@ +#!/bin/sh +# +# Copyright (c) 2020 Peter Johanson; Cody McGinnis; Okke Formsma +# +# SPDX-License-Identifier: MIT +# +set -e +set -x + +if [ -z "$1" ]; then + echo "Usage: ./run-test.sh " + exit 1 +elif [ "$1" = "all" ]; then + echo "" > ./build/tests/pass-fail.log + find tests -name native_posix.keymap -exec dirname \{\} \; | xargs -l -P 4 ./run-test.sh + err=$? + sort -k2 ./build/tests/pass-fail.log + exit $err +fi + +testcase="$1" +echo "Running $testcase:" + +west build -d build/$testcase -b native_posix --pristine -- -DZMK_CONFIG=$testcase +if [ $? -gt 0 ]; then + echo "FAIL: $testcase did not build" +else + ./build/$testcase/zephyr/zmk.exe | sed -e "s/.*> //" | tee build/$testcase/keycode_events_full.log | sed -n -f $testcase/events.patterns > build/$testcase/keycode_events.log + cat build/$testcase/keycode_events_full.log + cat build/$testcase/keycode_events.log + diff -au $testcase/keycode_events.snapshot build/$testcase/keycode_events.log + if [ $? -gt 0 ]; then + if [ -f $testcase/pending ]; then + echo "PEND: $testcase" + exit 0 + else + echo "FAIL: $testcase" + exit 1 + fi + else + echo "PASS: $testcase" + exit 0 + fi +fi \ No newline at end of file diff --git a/app/src/behaviors/behavior_hold_tap.c b/app/src/behaviors/behavior_hold_tap.c new file mode 100644 index 0000000..08fa139 --- /dev/null +++ b/app/src/behaviors/behavior_hold_tap.c @@ -0,0 +1,491 @@ +/* + * Copyright (c) 2020 Cody McGinnis, Okke Formsma + * + * SPDX-License-Identifier: MIT + */ + +#define DT_DRV_COMPAT zmk_behavior_hold_tap + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); + +#if DT_NODE_EXISTS(DT_DRV_INST(0)) + +/************************************************************ DATA SETUP */ +#define ZMK_BHV_HOLD_TAP_MAX_HELD 10 +#define ZMK_BHV_HOLD_TAP_MAX_CAPTURED_EVENTS 40 + +// increase if you have keyboard with more keys. +#define ZMK_BHV_HOLD_TAP_POSITION_NOT_USED 9999 + +struct behavior_hold_tap_behaviors { + struct zmk_behavior_binding tap; + struct zmk_behavior_binding hold; +}; + +typedef k_timeout_t (*timer_func)(); + +struct behavior_hold_tap_config { + timer_func tapping_term_ms; + struct behavior_hold_tap_behaviors *behaviors; + char *flavor; +}; + +// this data is specific for each hold-tap +struct active_hold_tap { + s32_t position; + u32_t param_hold; + u32_t param_tap; + bool is_decided; + bool is_hold; + const struct behavior_hold_tap_config *config; + struct k_delayed_work work; + bool work_is_cancelled; +}; + +// The undecided hold tap is the hold tap that needs to be decided before +// other keypress events can be released. While the undecided_hold_tap is +// not NULL, most events are captured in captured_events. +// After the hold_tap is decided, it will stay in the active_hold_taps until +// its key-up has been processed and the delayed work is cleaned up. +struct active_hold_tap *undecided_hold_tap = NULL; +struct active_hold_tap active_hold_taps[ZMK_BHV_HOLD_TAP_MAX_HELD] = {}; +// We capture most position_state_changed events and some modifiers_state_changed events. +const struct zmk_event_header *captured_events[ZMK_BHV_HOLD_TAP_MAX_CAPTURED_EVENTS] = {}; + +/************************************************************ CAPTURED POSITION HELPER FUNCTIONS */ +static int capture_event(const struct zmk_event_header *event) +{ + for (int i = 0; i < ZMK_BHV_HOLD_TAP_MAX_CAPTURED_EVENTS; i++) { + if (captured_events[i] == NULL) { + captured_events[i] = event; + return 0; + } + } + return -ENOMEM; +} + +static struct position_state_changed *find_captured_keydown_event(u32_t position) +{ + struct position_state_changed *last_match = NULL; + for (int i = 0; i < ZMK_BHV_HOLD_TAP_MAX_CAPTURED_EVENTS; i++) { + const struct zmk_event_header *eh = captured_events[i]; + if (eh == NULL) { + return last_match; + } + if (!is_position_state_changed(eh)) { + continue; + } + struct position_state_changed *position_event = cast_position_state_changed(eh); + if (position_event->position == position && position_event->state) { + last_match = position_event; + } + } + return last_match; +} + +static void release_captured_events() +{ + if (undecided_hold_tap != NULL) { + return; + } + + // We use a trick to prevent copying the captured_events array. + // + // Events for different mod-tap instances are separated by a NULL pointer. + // + // The first event popped will never be catched by the next active hold-tap + // because to start capturing a mod-tap-key-down event must first completely + // go through the events queue. + // + // Example of this release process; + // [mt2_down, k1_down, k1_up, mt2_up, null, ...] + // ^ + // mt2_down position event isn't captured because no hold-tap is active. + // mt2_down behavior event is handled, now we have an undecided hold-tap + // [null, k1_down, k1_up, mt2_up, null, ...] + // ^ + // k1_down is captured by the mt2 mod-tap + // !note that searches for find_captured_keydown_event by the mt2 behavior will stop at the first null encountered + // [mt1_down, null, k1_up, mt2_up, null, ...] + // ^ + // k1_up event is captured by the new hold-tap: + // [k1_down, k1_up, null, mt2_up, null, ...] + // ^ + // mt2_up event is not captured but causes release of mt2 behavior + // [k1_down, k1_up, null, null, null, ...] + // now mt2 will start releasing it's own captured positions. + for (int i = 0; i < ZMK_BHV_HOLD_TAP_MAX_CAPTURED_EVENTS; i++) { + const struct zmk_event_header *captured_event = captured_events[i]; + if (captured_event == NULL) { + return; + } + captured_events[i] = NULL; + if (undecided_hold_tap != NULL) { + k_msleep(10); + } + if (is_position_state_changed(captured_event)) { + struct position_state_changed *position_event = cast_position_state_changed(captured_event); + LOG_DBG("Releasing key position event for position %d %s", position_event->position, (position_event->state ? "pressed" : "released")); + } else { + struct keycode_state_changed *modifier_event = cast_keycode_state_changed(captured_event); + LOG_DBG("Releasing mods changed event 0x%02X %s", modifier_event->keycode, (modifier_event->state ? "pressed" : "released")); + } + ZMK_EVENT_RELEASE_AGAIN(captured_event); + } +} + + +/************************************************************ ACTIVE TAP HOLD HELPER FUNCTIONS */ + +static struct active_hold_tap *find_hold_tap(u32_t position) +{ + for (int i = 0; i < ZMK_BHV_HOLD_TAP_MAX_HELD; i++) { + if (active_hold_taps[i].position == position) { + return &active_hold_taps[i]; + } + } + return NULL; +} + +static struct active_hold_tap *store_hold_tap(u32_t position, u32_t param_hold, u32_t param_tap, const struct behavior_hold_tap_config *config) +{ + for (int i = 0; i < ZMK_BHV_HOLD_TAP_MAX_HELD; i++) { + if (active_hold_taps[i].position != ZMK_BHV_HOLD_TAP_POSITION_NOT_USED) { + continue; + } + active_hold_taps[i].position = position; + active_hold_taps[i].is_decided = false; + active_hold_taps[i].is_hold = false; + active_hold_taps[i].config = config; + active_hold_taps[i].param_hold = param_hold; + active_hold_taps[i].param_tap = param_tap; + return &active_hold_taps[i]; + } + return NULL; +} + +static void clear_hold_tap(struct active_hold_tap *hold_tap) +{ + hold_tap->position = ZMK_BHV_HOLD_TAP_POSITION_NOT_USED; + hold_tap->is_decided = false; + hold_tap->is_hold = false; + hold_tap->work_is_cancelled = false; +} + +enum decision_moment { + HT_KEY_UP = 0, + HT_OTHER_KEY_DOWN = 1, + HT_OTHER_KEY_UP = 2, + HT_TIMER_EVENT = 3, +}; + +static void decide_balanced(struct active_hold_tap *hold_tap, enum decision_moment event) +{ + switch (event) { + case HT_KEY_UP: + hold_tap->is_hold = 0; + hold_tap->is_decided = true; + break; + case HT_OTHER_KEY_UP: + hold_tap->is_hold = 1; + hold_tap->is_decided = true; + break; + case HT_TIMER_EVENT: + hold_tap->is_hold = 1; + hold_tap->is_decided = true; + break; + default: return; + } +} + +static void decide_tap_preferred(struct active_hold_tap *hold_tap, enum decision_moment event) +{ + switch (event) { + case HT_KEY_UP: + hold_tap->is_hold = 0; + hold_tap->is_decided = true; + break; + case HT_TIMER_EVENT: + hold_tap->is_hold = 1; + hold_tap->is_decided = true; + break; + default: return; + } +} + +static void decide_hold_preferred(struct active_hold_tap *hold_tap, enum decision_moment event) +{ + switch (event) { + case HT_KEY_UP: + hold_tap->is_hold = 0; + hold_tap->is_decided = true; + break; + case HT_OTHER_KEY_DOWN: + hold_tap->is_hold = 1; + hold_tap->is_decided = true; + break; + case HT_TIMER_EVENT: + hold_tap->is_hold = 1; + hold_tap->is_decided = true; + break; + default: return; + } +} + +static void decide_hold_tap(struct active_hold_tap *hold_tap, enum decision_moment event) +{ + if (hold_tap->is_decided) { + return; + } + + if (hold_tap != undecided_hold_tap) { + LOG_DBG("ERROR found undecided tap hold that is not the active tap hold"); + return; + } + + char *flavor = hold_tap->config->flavor; + if (strcmp(flavor, "balanced") == 0) { + decide_balanced(hold_tap, event); + } else if (strcmp(flavor, "tap-preferred") == 0) { + decide_tap_preferred(hold_tap, event); + } else if (strcmp(flavor, "hold-preferred") == 0) { + decide_hold_preferred(hold_tap, event); + } + + if (!hold_tap->is_decided) { + return; + } + + LOG_DBG("%d decided %s (%s event %d)", hold_tap->position, hold_tap->is_hold ? "hold" : "tap", flavor, event); + undecided_hold_tap = NULL; + + struct zmk_behavior_binding *behavior; + if (hold_tap->is_hold) { + behavior = &hold_tap->config->behaviors->hold; + struct device *behavior_device = device_get_binding(behavior->behavior_dev); + behavior_keymap_binding_pressed(behavior_device, hold_tap->position, hold_tap->param_hold, 0); + } else { + behavior = &hold_tap->config->behaviors->tap; + struct device *behavior_device = device_get_binding(behavior->behavior_dev); + behavior_keymap_binding_pressed(behavior_device, hold_tap->position, hold_tap->param_tap, 0); + } + release_captured_events(); +} + +/************************************************************ hold_tap_binding and key handlers */ +static int on_hold_tap_binding_pressed(struct device *dev, u32_t position, u32_t param_hold, u32_t param_tap) +{ + const struct behavior_hold_tap_config *cfg = dev->config_info; + + if (undecided_hold_tap != NULL) { + LOG_DBG("ERROR another hold-tap behavior is undecided."); + // if this happens, make sure the behavior events occur AFTER other position events. + return 0; + } + + struct active_hold_tap *hold_tap = store_hold_tap(position, param_hold, param_tap, cfg); + if (hold_tap == NULL) { + LOG_ERR("unable to store hold-tap info, did you press more than %d hold-taps?", ZMK_BHV_HOLD_TAP_MAX_HELD); + return 0; + } + + LOG_DBG("%d new undecided hold_tap", position); + undecided_hold_tap = hold_tap; + k_delayed_work_submit(&hold_tap->work, cfg->tapping_term_ms()); + + // todo: once we get timing info for keypresses, start the timer relative to the original keypress + // don't forget to simulate a timer-event before the event after that time was handled. + + return 0; +} + +static int on_hold_tap_binding_released(struct device *dev, u32_t position, u32_t _, u32_t __) +{ + struct active_hold_tap *hold_tap = find_hold_tap(position); + + if (hold_tap == NULL) { + LOG_ERR("ACTIVE_HOLD_TAP_CLEANED_UP_TOO_EARLY"); + return 0; + } + + int work_cancel_result = k_delayed_work_cancel(&hold_tap->work); + decide_hold_tap(hold_tap, HT_KEY_UP); + + struct zmk_behavior_binding *behavior; + if (hold_tap->is_hold) { + behavior = &hold_tap->config->behaviors->hold; + struct device *behavior_device = device_get_binding(behavior->behavior_dev); + behavior_keymap_binding_released(behavior_device, hold_tap->position, hold_tap->param_hold, 0); + } else { + behavior = &hold_tap->config->behaviors->tap; + struct device *behavior_device = device_get_binding(behavior->behavior_dev); + behavior_keymap_binding_released(behavior_device, hold_tap->position, hold_tap->param_tap, 0); + } + + + if (work_cancel_result == -EINPROGRESS) { + // let the timer handler clean up + // if we'd clear now, the timer may call back for an uninitialized active_hold_tap. + LOG_DBG("%d hold-tap timer work in event queue", position); + hold_tap->work_is_cancelled = true; + } else { + LOG_DBG("%d cleaning up hold-tap", position); + clear_hold_tap(hold_tap); + } + + return 0; +} + +static const struct behavior_driver_api behavior_hold_tap_driver_api = { + .binding_pressed = on_hold_tap_binding_pressed, + .binding_released = on_hold_tap_binding_released, +}; + + +static int position_state_changed_listener(const struct zmk_event_header *eh) +{ + struct position_state_changed *ev = cast_position_state_changed(eh); + + if (undecided_hold_tap == NULL) { + LOG_DBG("%d bubble (no undecided hold_tap active)", ev->position); + return 0; + } + + if (undecided_hold_tap->position == ev->position) { + if (ev->state) { // keydown + LOG_ERR("hold-tap listener should be called before before most other listeners!"); + return 0; + } else { // keyup + LOG_DBG("%d bubble undecided hold-tap keyrelease event", undecided_hold_tap->position); + return 0; + } + } + + if (!ev->state && find_captured_keydown_event(ev->position) == NULL) { + // no keydown event has been captured, let it bubble. + // we'll catch modifiers later in modifier_state_changed_listener + LOG_DBG("%d bubbling %d %s event", undecided_hold_tap->position, ev->position, ev->state ? "down" : "up"); + return 0; + } + + LOG_DBG("%d capturing %d %s event", undecided_hold_tap->position, ev->position, ev->state ? "down" : "up"); + capture_event(eh); + decide_hold_tap(undecided_hold_tap, ev->state ? HT_OTHER_KEY_DOWN : HT_OTHER_KEY_UP); + return ZMK_EV_EVENT_CAPTURED; +} + +static bool is_mod(struct keycode_state_changed *ev) +{ + return ev->usage_page == USAGE_KEYPAD && ev->keycode >= LCTL && ev->keycode <= RGUI; +} + +static int keycode_state_changed_listener(const struct zmk_event_header *eh) +{ + // we want to catch layer-up events too... how? + struct keycode_state_changed *ev = cast_keycode_state_changed(eh); + + if (undecided_hold_tap == NULL) { + // LOG_DBG("0x%02X bubble (no undecided hold_tap active)", ev->keycode); + return 0; + } + + if (!is_mod(ev)) { + // LOG_DBG("0x%02X bubble (not a mod)", ev->keycode); + return 0; + } + + // only key-up events will bubble through position_state_changed_listener + // if a undecided_hold_tap is active. + LOG_DBG("%d capturing 0x%02X %s event", undecided_hold_tap->position, ev->keycode, ev->state ? "down" : "up"); + capture_event(eh); + return ZMK_EV_EVENT_CAPTURED; +} + + +int behavior_hold_tap_listener(const struct zmk_event_header *eh) +{ + if (is_position_state_changed(eh)) { + return position_state_changed_listener(eh); + } else if (is_keycode_state_changed(eh)) { + return keycode_state_changed_listener(eh); + } + return 0; +} + +ZMK_LISTENER(behavior_hold_tap, behavior_hold_tap_listener); +ZMK_SUBSCRIPTION(behavior_hold_tap, position_state_changed); +// this should be modifiers_state_changed, but unfrotunately that's not implemented yet. +ZMK_SUBSCRIPTION(behavior_hold_tap, keycode_state_changed); + +/************************************************************ TIMER FUNCTIONS */ +void behavior_hold_tap_timer_work_handler(struct k_work *item) +{ + struct active_hold_tap *hold_tap = CONTAINER_OF(item, struct active_hold_tap, work); + + if (hold_tap->work_is_cancelled) { + clear_hold_tap(hold_tap); + } else { + decide_hold_tap(hold_tap, HT_TIMER_EVENT); + } +} + +static int behavior_hold_tap_init(struct device *dev) +{ + static bool init_first_run = true; + + if (init_first_run) { + for (int i = 0; i < ZMK_BHV_HOLD_TAP_MAX_HELD; i++) { + k_delayed_work_init(&active_hold_taps[i].work, behavior_hold_tap_timer_work_handler); + active_hold_taps[i].position = ZMK_BHV_HOLD_TAP_POSITION_NOT_USED; + } + } + init_first_run = false; + return 0; +} + +struct behavior_hold_tap_data {}; +static struct behavior_hold_tap_data behavior_hold_tap_data; + +/************************************************************ NODE CONFIG */ +#define _TRANSFORM_ENTRY(idx, node) \ + { \ + .behavior_dev = DT_LABEL(DT_INST_PHANDLE_BY_IDX(node, bindings, idx)), \ + .param1 = COND_CODE_0(DT_INST_PHA_HAS_CELL_AT_IDX(node, bindings, idx, param1), (0), (DT_INST_PHA_BY_IDX(node, bindings, idx, param1))), \ + .param2 = COND_CODE_0(DT_INST_PHA_HAS_CELL_AT_IDX(node, bindings, idx, param2), (0), (DT_INST_PHA_BY_IDX(node, bindings, idx, param2))), \ + }, + +#define KP_INST(n) \ + static k_timeout_t behavior_hold_tap_config_##n##_gettime() { return K_MSEC(DT_INST_PROP(n, tapping_term_ms)); } \ + static struct behavior_hold_tap_behaviors behavior_hold_tap_behaviors_##n = { \ + .hold = _TRANSFORM_ENTRY(0, n) \ + .tap = _TRANSFORM_ENTRY(1, n) \ + }; \ + static struct behavior_hold_tap_config behavior_hold_tap_config_##n = { \ + .behaviors = &behavior_hold_tap_behaviors_##n, \ + .tapping_term_ms = &behavior_hold_tap_config_##n##_gettime, \ + .flavor = DT_INST_PROP(n, flavor), \ + }; \ + DEVICE_AND_API_INIT( \ + behavior_hold_tap_##n, DT_INST_LABEL(n), behavior_hold_tap_init, \ + &behavior_hold_tap_data, \ + &behavior_hold_tap_config_##n, \ + APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, \ + &behavior_hold_tap_driver_api); + +DT_INST_FOREACH_STATUS_OKAY(KP_INST) + + +#endif \ No newline at end of file diff --git a/app/src/behaviors/behavior_mod_tap.c b/app/src/behaviors/behavior_mod_tap.c deleted file mode 100644 index 5a2f60e..0000000 --- a/app/src/behaviors/behavior_mod_tap.c +++ /dev/null @@ -1,252 +0,0 @@ -/* - * Copyright (c) 2020 Peter Johanson - * - * SPDX-License-Identifier: MIT - */ - -#define DT_DRV_COMPAT zmk_behavior_mod_tap - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); - -#define ZMK_BHV_MOD_TAP_MAX_HELD 4 -#define ZMK_BHV_MOD_TAP_MAX_PENDING_KC 4 - -struct active_mod_tap_item { - u32_t keycode; - u8_t mods; - bool pending; - zmk_mod_flags active_mods; -}; - -struct captured_keycode_state_change_item { - struct keycode_state_changed* event; - zmk_mod_flags active_mods; -}; - -struct behavior_mod_tap_config { }; -struct behavior_mod_tap_data { - struct active_mod_tap_item active_mod_taps[ZMK_BHV_MOD_TAP_MAX_HELD]; - struct captured_keycode_state_change_item captured_keycode_events[ZMK_BHV_MOD_TAP_MAX_PENDING_KC]; -}; - -bool have_pending_mods(char *label) { - struct device *dev = device_get_binding(label); - struct behavior_mod_tap_data *data = dev->driver_data; - - for (int i = 0; i < ZMK_BHV_MOD_TAP_MAX_HELD; i++) { - if (data->active_mod_taps[i].mods) { - LOG_DBG("Found pending mods for %d and keycode 0x%02X", data->active_mod_taps[i].mods, data->active_mod_taps[i].keycode); - return true; - } - } - - return false; -} - -struct captured_keycode_state_change_item* find_pending_keycode(struct behavior_mod_tap_data *data, u32_t keycode) -{ - for (int i = 0; i < ZMK_BHV_MOD_TAP_MAX_PENDING_KC; i++) { - if (data->captured_keycode_events[i].event == NULL) { - continue; - } - - if (data->captured_keycode_events[i].event->keycode == keycode) { - return &data->captured_keycode_events[i]; - } - } - - return NULL; -} - -zmk_mod_flags behavior_mod_tap_active_mods(struct behavior_mod_tap_data *data) -{ - zmk_mod_flags mods = 0; - - for (int i = 0; i < ZMK_BHV_MOD_TAP_MAX_HELD; i++) { - mods |= data->active_mod_taps[i].mods; - } - - return mods; -} - -int behavior_mod_tap_capture_keycode_event(struct behavior_mod_tap_data *data, struct keycode_state_changed *ev) -{ - for (int i = 0; i < ZMK_BHV_MOD_TAP_MAX_PENDING_KC; i++) { - if (data->captured_keycode_events[i].event != NULL) { - continue; - } - - data->captured_keycode_events[i].event = ev; - data->captured_keycode_events[i].active_mods = behavior_mod_tap_active_mods(data); - return 0; - } - - return -ENOMEM; -} - -void behavior_mod_tap_update_active_mods_state(struct behavior_mod_tap_data *data, zmk_mod_flags used_flags) -{ - for (int i = 0; i < ZMK_BHV_MOD_TAP_MAX_HELD; i++) { - if ((data->active_mod_taps[i].mods & used_flags) == data->active_mod_taps[i].mods) { - data->active_mod_taps[i].pending = false; - } - } -} - -// How to pass context to subscription?! -int behavior_mod_tap_listener(const struct zmk_event_header *eh) -{ - if (is_keycode_state_changed(eh) && have_pending_mods(DT_INST_LABEL(0))) { - struct device *dev = device_get_binding(DT_INST_LABEL(0)); - struct keycode_state_changed *ev = cast_keycode_state_changed(eh); - struct behavior_mod_tap_data *data = dev->driver_data; - struct captured_keycode_state_change_item* pending_keycode; - if (ev->state) { - LOG_DBG("Have pending mods, capturing keycode 0x%02X event to ressend later", ev->keycode); - behavior_mod_tap_capture_keycode_event(data, ev); - return ZMK_EV_EVENT_CAPTURED; - } else if ((pending_keycode = find_pending_keycode(data, ev->keycode)) != NULL) { - LOG_DBG("Key released, going to activate mods 0x%02X then send pending key press for keycode 0x%02X", - pending_keycode->active_mods, pending_keycode->event->keycode); - - zmk_hid_register_mods(pending_keycode->active_mods); - behavior_mod_tap_update_active_mods_state(data, pending_keycode->active_mods); - - ZMK_EVENT_RELEASE(pending_keycode->event); - k_msleep(10); - - pending_keycode->event = NULL; - pending_keycode->active_mods = 0; - } - } - return 0; -} - -ZMK_LISTENER(behavior_mod_tap, behavior_mod_tap_listener); -ZMK_SUBSCRIPTION(behavior_mod_tap, keycode_state_changed); - -static int behavior_mod_tap_init(struct device *dev) -{ - return 0; -}; - - -static int on_keymap_binding_pressed(struct device *dev, u32_t position, u32_t mods, u32_t keycode) -{ - struct behavior_mod_tap_data *data = dev->driver_data; - LOG_DBG("mods: %d, keycode: 0x%02X", mods, keycode); - for (int i = 0; i < ZMK_BHV_MOD_TAP_MAX_HELD; i++) { - if (data->active_mod_taps[i].mods != 0) { - continue; - } - - zmk_mod_flags active_mods = behavior_mod_tap_active_mods(data); - - data->active_mod_taps[i].active_mods = active_mods; - data->active_mod_taps[i].mods = mods; - data->active_mod_taps[i].keycode = keycode; - data->active_mod_taps[i].pending = true; - - return 0; - } - - LOG_WRN("Failed to record mod-tap activation, at maximum concurrent mod-tap activations"); - - return -ENOMEM; -} - -static int on_keymap_binding_released(struct device *dev, u32_t position, u32_t mods, u32_t keycode) -{ - struct behavior_mod_tap_data *data = dev->driver_data; - LOG_DBG("mods: %d, keycode: %d", mods, keycode); - - for (int i = 0; i < ZMK_BHV_MOD_TAP_MAX_HELD; i++) { - struct active_mod_tap_item *item = &data->active_mod_taps[i]; - if (item->mods == mods && item->keycode == keycode) { - if (item->pending) { - LOG_DBG("Sending un-triggered mod-tap for keycode: 0x%02X", keycode); - - if (item->active_mods) { - LOG_DBG("Registering recorded active mods captured when mod-tap initially activated: 0x%02X", item->active_mods); - behavior_mod_tap_update_active_mods_state(data, item->active_mods); - zmk_hid_register_mods(item->active_mods); - } - - struct keycode_state_changed *key_press = create_keycode_state_changed(USAGE_KEYPAD, item->keycode, true); - ZMK_EVENT_RAISE_AFTER(key_press, behavior_mod_tap); - k_msleep(10); - - for (int j = 0; j < ZMK_BHV_MOD_TAP_MAX_PENDING_KC; j++) { - if (data->captured_keycode_events[j].event == NULL) { - continue; - } - - struct keycode_state_changed *ev = data->captured_keycode_events[j].event; - data->captured_keycode_events[j].event = NULL; - data->captured_keycode_events[j].active_mods = 0; - LOG_DBG("Re-sending latched key press for usage page 0x%02X keycode 0x%02X state %s", ev->usage_page, ev->keycode, (ev->state ? "pressed" : "released")); - ZMK_EVENT_RELEASE(ev); - k_msleep(10); - } - - struct keycode_state_changed *key_release = create_keycode_state_changed(USAGE_KEYPAD, keycode, false); - LOG_DBG("Sending un-triggered mod-tap release for keycode: 0x%02X", keycode); - ZMK_EVENT_RAISE_AFTER(key_release, behavior_mod_tap); - k_msleep(10); - - if (item->active_mods) { - LOG_DBG("Unregistering recorded active mods captured when mod-tap initially activated: 0x%02X", item->active_mods); - zmk_hid_unregister_mods(item->active_mods); - zmk_endpoints_send_report(USAGE_KEYPAD); - } - - - } else { - LOG_DBG("Releasing triggered mods: %d", mods); - zmk_hid_unregister_mods(mods); - zmk_endpoints_send_report(USAGE_KEYPAD); - } - - item->mods = 0; - item->keycode = 0; - item->active_mods = 0; - - LOG_DBG("Removing mods %d from active_mods for other held mod-taps", mods); - for (int j = 0; j < ZMK_BHV_MOD_TAP_MAX_HELD; j++) { - if (data->active_mod_taps[j].active_mods & mods) { - LOG_DBG("Removing 0x%02X from active mod tap mods 0x%02X keycode 0x%02X", mods, data->active_mod_taps[j].mods, data->active_mod_taps[j].keycode); - data->active_mod_taps[j].active_mods &= ~mods; - } - } - break; - } - } - - return 0; -} - -static const struct behavior_driver_api behavior_mod_tap_driver_api = { - .binding_pressed = on_keymap_binding_pressed, - .binding_released = on_keymap_binding_released, -}; - -static const struct behavior_mod_tap_config behavior_mod_tap_config = {}; - -static struct behavior_mod_tap_data behavior_mod_tap_data; - -DEVICE_AND_API_INIT(behavior_mod_tap, DT_INST_LABEL(0), behavior_mod_tap_init, - &behavior_mod_tap_data, - &behavior_mod_tap_config, - APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, - &behavior_mod_tap_driver_api); diff --git a/app/src/event_manager.c b/app/src/event_manager.c index c405176..2f423fc 100644 --- a/app/src/event_manager.c +++ b/app/src/event_manager.c @@ -74,4 +74,10 @@ int zmk_event_manager_raise_after(struct zmk_event_header *event, const struct z int zmk_event_manager_release(struct zmk_event_header *event) { return zmk_event_manager_handle_from(event, event->last_listener_index + 1); +} + + +int zmk_event_manager_release_again(struct zmk_event_header *event) +{ + return zmk_event_manager_handle_from(event, event->last_listener_index); } \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/1/events.patterns b/app/tests/hold-tap/balanced/1/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/balanced/1/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/1/keycode_events.snapshot b/app/tests/hold-tap/balanced/1/keycode_events.snapshot new file mode 100644 index 0000000..5f6a266 --- /dev/null +++ b/app/tests/hold-tap/balanced/1/keycode_events.snapshot @@ -0,0 +1,5 @@ +ht_binding_pressed: 0 new undecided hold_tap +ht_decide: 0 decided tap (balanced event 0) +kp_pressed: usage_page 0x07 keycode 0x09 +kp_released: usage_page 0x07 keycode 0x09 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/balanced/1/native_posix.keymap b/app/tests/hold-tap/balanced/1/native_posix.keymap new file mode 100644 index 0000000..10336ef --- /dev/null +++ b/app/tests/hold-tap/balanced/1/native_posix.keymap @@ -0,0 +1,11 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(0,0,10) + ZMK_MOCK_RELEASE(0,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/2/events.patterns b/app/tests/hold-tap/balanced/2/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/balanced/2/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/2/keycode_events.snapshot b/app/tests/hold-tap/balanced/2/keycode_events.snapshot new file mode 100644 index 0000000..ddda1ae --- /dev/null +++ b/app/tests/hold-tap/balanced/2/keycode_events.snapshot @@ -0,0 +1,5 @@ +ht_binding_pressed: 0 new undecided hold_tap +ht_decide: 0 decided hold (balanced event 3) +kp_pressed: usage_page 0x07 keycode 0xe1 +kp_released: usage_page 0x07 keycode 0xe1 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/balanced/2/native_posix.keymap b/app/tests/hold-tap/balanced/2/native_posix.keymap new file mode 100644 index 0000000..aa93b86 --- /dev/null +++ b/app/tests/hold-tap/balanced/2/native_posix.keymap @@ -0,0 +1,11 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(0,0,500) + ZMK_MOCK_RELEASE(0,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/3a/events.patterns b/app/tests/hold-tap/balanced/3a/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/balanced/3a/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/3a/keycode_events.snapshot b/app/tests/hold-tap/balanced/3a/keycode_events.snapshot new file mode 100644 index 0000000..a435103 --- /dev/null +++ b/app/tests/hold-tap/balanced/3a/keycode_events.snapshot @@ -0,0 +1,7 @@ +kp_pressed: usage_page 0x07 keycode 0xe4 +ht_binding_pressed: 0 new undecided hold_tap +ht_decide: 0 decided tap (balanced event 0) +kp_pressed: usage_page 0x07 keycode 0x09 +kp_released: usage_page 0x07 keycode 0xe4 +kp_released: usage_page 0x07 keycode 0x09 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/balanced/3a/native_posix.keymap b/app/tests/hold-tap/balanced/3a/native_posix.keymap new file mode 100644 index 0000000..6f08689 --- /dev/null +++ b/app/tests/hold-tap/balanced/3a/native_posix.keymap @@ -0,0 +1,13 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(1,1,10) /*ctrl*/ + ZMK_MOCK_PRESS(0,0,100) /*mt f-shift */ + ZMK_MOCK_RELEASE(1,1,10) + ZMK_MOCK_RELEASE(0,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/3b/events.patterns b/app/tests/hold-tap/balanced/3b/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/balanced/3b/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/3b/keycode_events.snapshot b/app/tests/hold-tap/balanced/3b/keycode_events.snapshot new file mode 100644 index 0000000..c0da94f --- /dev/null +++ b/app/tests/hold-tap/balanced/3b/keycode_events.snapshot @@ -0,0 +1,7 @@ +kp_pressed: usage_page 0x07 keycode 0xe4 +ht_binding_pressed: 0 new undecided hold_tap +ht_decide: 0 decided hold (balanced event 3) +kp_pressed: usage_page 0x07 keycode 0xe1 +kp_released: usage_page 0x07 keycode 0xe4 +kp_released: usage_page 0x07 keycode 0xe1 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/balanced/3b/native_posix.keymap b/app/tests/hold-tap/balanced/3b/native_posix.keymap new file mode 100644 index 0000000..392d328 --- /dev/null +++ b/app/tests/hold-tap/balanced/3b/native_posix.keymap @@ -0,0 +1,14 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(1,1,10) /*ctrl*/ + ZMK_MOCK_PRESS(0,0,50) /*mt f-shift */ + ZMK_MOCK_RELEASE(1,1,300) + /*timer*/ + ZMK_MOCK_RELEASE(0,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/3c/events.patterns b/app/tests/hold-tap/balanced/3c/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/balanced/3c/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/3c/keycode_events.snapshot b/app/tests/hold-tap/balanced/3c/keycode_events.snapshot new file mode 100644 index 0000000..ce6e7b7 --- /dev/null +++ b/app/tests/hold-tap/balanced/3c/keycode_events.snapshot @@ -0,0 +1,7 @@ +kp_pressed: usage_page 0x07 keycode 0x07 +ht_binding_pressed: 0 new undecided hold_tap +kp_released: usage_page 0x07 keycode 0x07 +ht_decide: 0 decided tap (balanced event 0) +kp_pressed: usage_page 0x07 keycode 0x09 +kp_released: usage_page 0x07 keycode 0x09 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/balanced/3c/native_posix.keymap b/app/tests/hold-tap/balanced/3c/native_posix.keymap new file mode 100644 index 0000000..77306cd --- /dev/null +++ b/app/tests/hold-tap/balanced/3c/native_posix.keymap @@ -0,0 +1,13 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(1,0,10) /*d*/ + ZMK_MOCK_PRESS(0,0,100) /*mt f-shift */ + ZMK_MOCK_RELEASE(1,0,10) + ZMK_MOCK_RELEASE(0,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/3d/events.patterns b/app/tests/hold-tap/balanced/3d/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/balanced/3d/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/3d/keycode_events.snapshot b/app/tests/hold-tap/balanced/3d/keycode_events.snapshot new file mode 100644 index 0000000..1ec384a --- /dev/null +++ b/app/tests/hold-tap/balanced/3d/keycode_events.snapshot @@ -0,0 +1,7 @@ +kp_pressed: usage_page 0x07 keycode 0x07 +ht_binding_pressed: 0 new undecided hold_tap +kp_released: usage_page 0x07 keycode 0x07 +ht_decide: 0 decided hold (balanced event 3) +kp_pressed: usage_page 0x07 keycode 0xe1 +kp_released: usage_page 0x07 keycode 0xe1 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/balanced/3d/native_posix.keymap b/app/tests/hold-tap/balanced/3d/native_posix.keymap new file mode 100644 index 0000000..1441331 --- /dev/null +++ b/app/tests/hold-tap/balanced/3d/native_posix.keymap @@ -0,0 +1,13 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(1,0,10) /* d */ + ZMK_MOCK_PRESS(0,0,100) /* mt f-shift */ + ZMK_MOCK_RELEASE(1,0,400) + ZMK_MOCK_RELEASE(0,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/4a-nested/events.patterns b/app/tests/hold-tap/balanced/4a-nested/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/balanced/4a-nested/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/4a-nested/keycode_events.snapshot b/app/tests/hold-tap/balanced/4a-nested/keycode_events.snapshot new file mode 100644 index 0000000..8a1980b --- /dev/null +++ b/app/tests/hold-tap/balanced/4a-nested/keycode_events.snapshot @@ -0,0 +1,10 @@ +ht_binding_pressed: 0 new undecided hold_tap +ht_decide: 0 decided hold (balanced event 3) +kp_pressed: usage_page 0x07 keycode 0xe1 +ht_binding_pressed: 1 new undecided hold_tap +ht_decide: 1 decided tap (balanced event 0) +kp_pressed: usage_page 0x07 keycode 0x0d +kp_released: usage_page 0x07 keycode 0x0d +ht_binding_released: 1 cleaning up hold-tap +kp_released: usage_page 0x07 keycode 0xe1 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/balanced/4a-nested/native_posix.keymap b/app/tests/hold-tap/balanced/4a-nested/native_posix.keymap new file mode 100644 index 0000000..c10c6d6 --- /dev/null +++ b/app/tests/hold-tap/balanced/4a-nested/native_posix.keymap @@ -0,0 +1,14 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(0,0,200) + ZMK_MOCK_PRESS(0,1,200) + /* timer fires */ + ZMK_MOCK_RELEASE(0,1,10) + ZMK_MOCK_RELEASE(0,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/4a/events.patterns b/app/tests/hold-tap/balanced/4a/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/balanced/4a/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/4a/keycode_events.snapshot b/app/tests/hold-tap/balanced/4a/keycode_events.snapshot new file mode 100644 index 0000000..b89b21d --- /dev/null +++ b/app/tests/hold-tap/balanced/4a/keycode_events.snapshot @@ -0,0 +1,7 @@ +ht_binding_pressed: 0 new undecided hold_tap +ht_decide: 0 decided hold (balanced event 3) +kp_pressed: usage_page 0x07 keycode 0xe1 +kp_pressed: usage_page 0x07 keycode 0x07 +kp_released: usage_page 0x07 keycode 0x07 +kp_released: usage_page 0x07 keycode 0xe1 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/balanced/4a/native_posix.keymap b/app/tests/hold-tap/balanced/4a/native_posix.keymap new file mode 100644 index 0000000..ce163f5 --- /dev/null +++ b/app/tests/hold-tap/balanced/4a/native_posix.keymap @@ -0,0 +1,14 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(0,0,200) + ZMK_MOCK_PRESS(1,0,200) + /* timer fires */ + ZMK_MOCK_RELEASE(1,0,10) + ZMK_MOCK_RELEASE(0,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/4b/events.patterns b/app/tests/hold-tap/balanced/4b/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/balanced/4b/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/4b/keycode_events.snapshot b/app/tests/hold-tap/balanced/4b/keycode_events.snapshot new file mode 100644 index 0000000..798e2ee --- /dev/null +++ b/app/tests/hold-tap/balanced/4b/keycode_events.snapshot @@ -0,0 +1,7 @@ +ht_binding_pressed: 0 new undecided hold_tap +ht_decide: 0 decided hold (balanced event 2) +kp_pressed: usage_page 0x07 keycode 0xe1 +kp_pressed: usage_page 0x07 keycode 0x07 +kp_released: usage_page 0x07 keycode 0x07 +kp_released: usage_page 0x07 keycode 0xe1 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/balanced/4b/native_posix.keymap b/app/tests/hold-tap/balanced/4b/native_posix.keymap new file mode 100644 index 0000000..7abda41 --- /dev/null +++ b/app/tests/hold-tap/balanced/4b/native_posix.keymap @@ -0,0 +1,14 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(0,0,100) + ZMK_MOCK_PRESS(1,0,100) + ZMK_MOCK_RELEASE(1,0,200) + /* timer fires */ + ZMK_MOCK_RELEASE(0,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/4c/events.patterns b/app/tests/hold-tap/balanced/4c/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/balanced/4c/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/4c/keycode_events.snapshot b/app/tests/hold-tap/balanced/4c/keycode_events.snapshot new file mode 100644 index 0000000..798e2ee --- /dev/null +++ b/app/tests/hold-tap/balanced/4c/keycode_events.snapshot @@ -0,0 +1,7 @@ +ht_binding_pressed: 0 new undecided hold_tap +ht_decide: 0 decided hold (balanced event 2) +kp_pressed: usage_page 0x07 keycode 0xe1 +kp_pressed: usage_page 0x07 keycode 0x07 +kp_released: usage_page 0x07 keycode 0x07 +kp_released: usage_page 0x07 keycode 0xe1 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/balanced/4c/native_posix.keymap b/app/tests/hold-tap/balanced/4c/native_posix.keymap new file mode 100644 index 0000000..ce030af --- /dev/null +++ b/app/tests/hold-tap/balanced/4c/native_posix.keymap @@ -0,0 +1,14 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(0,0,10) + ZMK_MOCK_PRESS(1,0,10) + ZMK_MOCK_RELEASE(1,0,10) + ZMK_MOCK_RELEASE(0,0,10) + /* timer */ + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/4d/events.patterns b/app/tests/hold-tap/balanced/4d/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/balanced/4d/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/4d/keycode_events.snapshot b/app/tests/hold-tap/balanced/4d/keycode_events.snapshot new file mode 100644 index 0000000..5c9f4e3 --- /dev/null +++ b/app/tests/hold-tap/balanced/4d/keycode_events.snapshot @@ -0,0 +1,7 @@ +ht_binding_pressed: 0 new undecided hold_tap +ht_decide: 0 decided tap (balanced event 0) +kp_pressed: usage_page 0x07 keycode 0x09 +kp_pressed: usage_page 0x07 keycode 0x07 +kp_released: usage_page 0x07 keycode 0x09 +ht_binding_released: 0 cleaning up hold-tap +kp_released: usage_page 0x07 keycode 0x07 diff --git a/app/tests/hold-tap/balanced/4d/native_posix.keymap b/app/tests/hold-tap/balanced/4d/native_posix.keymap new file mode 100644 index 0000000..5467660 --- /dev/null +++ b/app/tests/hold-tap/balanced/4d/native_posix.keymap @@ -0,0 +1,14 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(0,0,100) + ZMK_MOCK_PRESS(1,0,100) + ZMK_MOCK_RELEASE(0,0,200) + /* timer fires */ + ZMK_MOCK_RELEASE(1,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/behavior_keymap.dtsi b/app/tests/hold-tap/balanced/behavior_keymap.dtsi new file mode 100644 index 0000000..df56fb5 --- /dev/null +++ b/app/tests/hold-tap/balanced/behavior_keymap.dtsi @@ -0,0 +1,27 @@ +#include +#include +#include + +/ { + behaviors { + ht_bal: behavior_hold_tap_balanced { + compatible = "zmk,behavior-hold-tap"; + label = "HOLD_TAP_BALANCED"; + #binding-cells = <2>; + flavor = "balanced"; + tapping_term_ms = <300>; + bindings = <&kp>, <&kp>; + }; + }; + + keymap { + compatible = "zmk,keymap"; + label ="Default keymap"; + + default_layer { + bindings = < + &ht_bal LSFT F &ht_bal LCTL J + &kp D &kp RCTL>; + }; + }; +}; diff --git a/app/tests/hold-tap/hold-preferred/1/events.patterns b/app/tests/hold-tap/hold-preferred/1/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/1/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/1/keycode_events.snapshot b/app/tests/hold-tap/hold-preferred/1/keycode_events.snapshot new file mode 100644 index 0000000..cf787d8 --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/1/keycode_events.snapshot @@ -0,0 +1,5 @@ +ht_binding_pressed: 0 new undecided hold_tap +ht_decide: 0 decided tap (hold-preferred event 0) +kp_pressed: usage_page 0x07 keycode 0x09 +kp_released: usage_page 0x07 keycode 0x09 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/hold-preferred/1/native_posix.keymap b/app/tests/hold-tap/hold-preferred/1/native_posix.keymap new file mode 100644 index 0000000..10336ef --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/1/native_posix.keymap @@ -0,0 +1,11 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(0,0,10) + ZMK_MOCK_RELEASE(0,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/2/events.patterns b/app/tests/hold-tap/hold-preferred/2/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/2/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/2/keycode_events.snapshot b/app/tests/hold-tap/hold-preferred/2/keycode_events.snapshot new file mode 100644 index 0000000..03329d5 --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/2/keycode_events.snapshot @@ -0,0 +1,5 @@ +ht_binding_pressed: 0 new undecided hold_tap +ht_decide: 0 decided hold (hold-preferred event 3) +kp_pressed: usage_page 0x07 keycode 0xe1 +kp_released: usage_page 0x07 keycode 0xe1 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/hold-preferred/2/native_posix.keymap b/app/tests/hold-tap/hold-preferred/2/native_posix.keymap new file mode 100644 index 0000000..aa93b86 --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/2/native_posix.keymap @@ -0,0 +1,11 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(0,0,500) + ZMK_MOCK_RELEASE(0,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/3a/events.patterns b/app/tests/hold-tap/hold-preferred/3a/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/3a/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/3a/keycode_events.snapshot b/app/tests/hold-tap/hold-preferred/3a/keycode_events.snapshot new file mode 100644 index 0000000..adf4fe2 --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/3a/keycode_events.snapshot @@ -0,0 +1,7 @@ +kp_pressed: usage_page 0x07 keycode 0xe4 +ht_binding_pressed: 0 new undecided hold_tap +ht_decide: 0 decided tap (hold-preferred event 0) +kp_pressed: usage_page 0x07 keycode 0x09 +kp_released: usage_page 0x07 keycode 0xe4 +kp_released: usage_page 0x07 keycode 0x09 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/hold-preferred/3a/native_posix.keymap b/app/tests/hold-tap/hold-preferred/3a/native_posix.keymap new file mode 100644 index 0000000..6f08689 --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/3a/native_posix.keymap @@ -0,0 +1,13 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(1,1,10) /*ctrl*/ + ZMK_MOCK_PRESS(0,0,100) /*mt f-shift */ + ZMK_MOCK_RELEASE(1,1,10) + ZMK_MOCK_RELEASE(0,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/3b/events.patterns b/app/tests/hold-tap/hold-preferred/3b/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/3b/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/3b/keycode_events.snapshot b/app/tests/hold-tap/hold-preferred/3b/keycode_events.snapshot new file mode 100644 index 0000000..69b64a9 --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/3b/keycode_events.snapshot @@ -0,0 +1,7 @@ +kp_pressed: usage_page 0x07 keycode 0xe4 +ht_binding_pressed: 0 new undecided hold_tap +ht_decide: 0 decided hold (hold-preferred event 3) +kp_pressed: usage_page 0x07 keycode 0xe1 +kp_released: usage_page 0x07 keycode 0xe4 +kp_released: usage_page 0x07 keycode 0xe1 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/hold-preferred/3b/native_posix.keymap b/app/tests/hold-tap/hold-preferred/3b/native_posix.keymap new file mode 100644 index 0000000..392d328 --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/3b/native_posix.keymap @@ -0,0 +1,14 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(1,1,10) /*ctrl*/ + ZMK_MOCK_PRESS(0,0,50) /*mt f-shift */ + ZMK_MOCK_RELEASE(1,1,300) + /*timer*/ + ZMK_MOCK_RELEASE(0,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/3c/events.patterns b/app/tests/hold-tap/hold-preferred/3c/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/3c/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/3c/keycode_events.snapshot b/app/tests/hold-tap/hold-preferred/3c/keycode_events.snapshot new file mode 100644 index 0000000..b06a1d7 --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/3c/keycode_events.snapshot @@ -0,0 +1,7 @@ +kp_pressed: usage_page 0x07 keycode 0x07 +ht_binding_pressed: 0 new undecided hold_tap +kp_released: usage_page 0x07 keycode 0x07 +ht_decide: 0 decided tap (hold-preferred event 0) +kp_pressed: usage_page 0x07 keycode 0x09 +kp_released: usage_page 0x07 keycode 0x09 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/hold-preferred/3c/native_posix.keymap b/app/tests/hold-tap/hold-preferred/3c/native_posix.keymap new file mode 100644 index 0000000..77306cd --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/3c/native_posix.keymap @@ -0,0 +1,13 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(1,0,10) /*d*/ + ZMK_MOCK_PRESS(0,0,100) /*mt f-shift */ + ZMK_MOCK_RELEASE(1,0,10) + ZMK_MOCK_RELEASE(0,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/3d/events.patterns b/app/tests/hold-tap/hold-preferred/3d/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/3d/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/3d/keycode_events.snapshot b/app/tests/hold-tap/hold-preferred/3d/keycode_events.snapshot new file mode 100644 index 0000000..bf31955 --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/3d/keycode_events.snapshot @@ -0,0 +1,7 @@ +kp_pressed: usage_page 0x07 keycode 0x07 +ht_binding_pressed: 0 new undecided hold_tap +kp_released: usage_page 0x07 keycode 0x07 +ht_decide: 0 decided hold (hold-preferred event 3) +kp_pressed: usage_page 0x07 keycode 0xe1 +kp_released: usage_page 0x07 keycode 0xe1 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/hold-preferred/3d/native_posix.keymap b/app/tests/hold-tap/hold-preferred/3d/native_posix.keymap new file mode 100644 index 0000000..1441331 --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/3d/native_posix.keymap @@ -0,0 +1,13 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(1,0,10) /* d */ + ZMK_MOCK_PRESS(0,0,100) /* mt f-shift */ + ZMK_MOCK_RELEASE(1,0,400) + ZMK_MOCK_RELEASE(0,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/4a-nested/events.patterns b/app/tests/hold-tap/hold-preferred/4a-nested/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/4a-nested/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/4a-nested/keycode_events.snapshot b/app/tests/hold-tap/hold-preferred/4a-nested/keycode_events.snapshot new file mode 100644 index 0000000..3ed7de0 --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/4a-nested/keycode_events.snapshot @@ -0,0 +1,10 @@ +ht_binding_pressed: 0 new undecided hold_tap +ht_decide: 0 decided hold (hold-preferred event 1) +kp_pressed: usage_page 0x07 keycode 0xe1 +ht_binding_pressed: 1 new undecided hold_tap +ht_decide: 1 decided tap (hold-preferred event 0) +kp_pressed: usage_page 0x07 keycode 0x0d +kp_released: usage_page 0x07 keycode 0x0d +ht_binding_released: 1 cleaning up hold-tap +kp_released: usage_page 0x07 keycode 0xe1 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/hold-preferred/4a-nested/native_posix.keymap b/app/tests/hold-tap/hold-preferred/4a-nested/native_posix.keymap new file mode 100644 index 0000000..c10c6d6 --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/4a-nested/native_posix.keymap @@ -0,0 +1,14 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(0,0,200) + ZMK_MOCK_PRESS(0,1,200) + /* timer fires */ + ZMK_MOCK_RELEASE(0,1,10) + ZMK_MOCK_RELEASE(0,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/4a/events.patterns b/app/tests/hold-tap/hold-preferred/4a/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/4a/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/4a/keycode_events.snapshot b/app/tests/hold-tap/hold-preferred/4a/keycode_events.snapshot new file mode 100644 index 0000000..e0b57fd --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/4a/keycode_events.snapshot @@ -0,0 +1,7 @@ +ht_binding_pressed: 0 new undecided hold_tap +ht_decide: 0 decided hold (hold-preferred event 1) +kp_pressed: usage_page 0x07 keycode 0xe1 +kp_pressed: usage_page 0x07 keycode 0x07 +kp_released: usage_page 0x07 keycode 0x07 +kp_released: usage_page 0x07 keycode 0xe1 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/hold-preferred/4a/native_posix.keymap b/app/tests/hold-tap/hold-preferred/4a/native_posix.keymap new file mode 100644 index 0000000..ce163f5 --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/4a/native_posix.keymap @@ -0,0 +1,14 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(0,0,200) + ZMK_MOCK_PRESS(1,0,200) + /* timer fires */ + ZMK_MOCK_RELEASE(1,0,10) + ZMK_MOCK_RELEASE(0,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/4b/events.patterns b/app/tests/hold-tap/hold-preferred/4b/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/4b/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/4b/keycode_events.snapshot b/app/tests/hold-tap/hold-preferred/4b/keycode_events.snapshot new file mode 100644 index 0000000..e0b57fd --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/4b/keycode_events.snapshot @@ -0,0 +1,7 @@ +ht_binding_pressed: 0 new undecided hold_tap +ht_decide: 0 decided hold (hold-preferred event 1) +kp_pressed: usage_page 0x07 keycode 0xe1 +kp_pressed: usage_page 0x07 keycode 0x07 +kp_released: usage_page 0x07 keycode 0x07 +kp_released: usage_page 0x07 keycode 0xe1 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/hold-preferred/4b/native_posix.keymap b/app/tests/hold-tap/hold-preferred/4b/native_posix.keymap new file mode 100644 index 0000000..7abda41 --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/4b/native_posix.keymap @@ -0,0 +1,14 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(0,0,100) + ZMK_MOCK_PRESS(1,0,100) + ZMK_MOCK_RELEASE(1,0,200) + /* timer fires */ + ZMK_MOCK_RELEASE(0,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/4c/events.patterns b/app/tests/hold-tap/hold-preferred/4c/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/4c/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/4c/keycode_events.snapshot b/app/tests/hold-tap/hold-preferred/4c/keycode_events.snapshot new file mode 100644 index 0000000..e0b57fd --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/4c/keycode_events.snapshot @@ -0,0 +1,7 @@ +ht_binding_pressed: 0 new undecided hold_tap +ht_decide: 0 decided hold (hold-preferred event 1) +kp_pressed: usage_page 0x07 keycode 0xe1 +kp_pressed: usage_page 0x07 keycode 0x07 +kp_released: usage_page 0x07 keycode 0x07 +kp_released: usage_page 0x07 keycode 0xe1 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/hold-preferred/4c/native_posix.keymap b/app/tests/hold-tap/hold-preferred/4c/native_posix.keymap new file mode 100644 index 0000000..ce030af --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/4c/native_posix.keymap @@ -0,0 +1,14 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(0,0,10) + ZMK_MOCK_PRESS(1,0,10) + ZMK_MOCK_RELEASE(1,0,10) + ZMK_MOCK_RELEASE(0,0,10) + /* timer */ + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/4d/events.patterns b/app/tests/hold-tap/hold-preferred/4d/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/4d/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/4d/keycode_events.snapshot b/app/tests/hold-tap/hold-preferred/4d/keycode_events.snapshot new file mode 100644 index 0000000..cac579d --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/4d/keycode_events.snapshot @@ -0,0 +1,7 @@ +ht_binding_pressed: 0 new undecided hold_tap +ht_decide: 0 decided hold (hold-preferred event 1) +kp_pressed: usage_page 0x07 keycode 0xe1 +kp_pressed: usage_page 0x07 keycode 0x07 +kp_released: usage_page 0x07 keycode 0xe1 +ht_binding_released: 0 cleaning up hold-tap +kp_released: usage_page 0x07 keycode 0x07 diff --git a/app/tests/hold-tap/hold-preferred/4d/native_posix.keymap b/app/tests/hold-tap/hold-preferred/4d/native_posix.keymap new file mode 100644 index 0000000..5467660 --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/4d/native_posix.keymap @@ -0,0 +1,14 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(0,0,100) + ZMK_MOCK_PRESS(1,0,100) + ZMK_MOCK_RELEASE(0,0,200) + /* timer fires */ + ZMK_MOCK_RELEASE(1,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/behavior_keymap.dtsi b/app/tests/hold-tap/hold-preferred/behavior_keymap.dtsi new file mode 100644 index 0000000..375ffd9 --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/behavior_keymap.dtsi @@ -0,0 +1,29 @@ +#include +#include +#include + + + +/ { + behaviors { + ht_hold: behavior_hold_hold_tap { + compatible = "zmk,behavior-hold-tap"; + label = "hold_hold_tap"; + #binding-cells = <2>; + flavor = "hold-preferred"; + tapping_term_ms = <300>; + bindings = <&kp>, <&kp>; + }; + }; + + keymap { + compatible = "zmk,keymap"; + label ="Default keymap"; + + default_layer { + bindings = < + &ht_hold LSFT F &ht_hold LCTL J + &kp D &kp RCTL>; + }; + }; +}; diff --git a/app/tests/hold-tap/tap-preferred/1/events.patterns b/app/tests/hold-tap/tap-preferred/1/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/1/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/1/keycode_events.snapshot b/app/tests/hold-tap/tap-preferred/1/keycode_events.snapshot new file mode 100644 index 0000000..2a250fb --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/1/keycode_events.snapshot @@ -0,0 +1,5 @@ +ht_binding_pressed: 0 new undecided hold_tap +ht_decide: 0 decided tap (tap-preferred event 0) +kp_pressed: usage_page 0x07 keycode 0x09 +kp_released: usage_page 0x07 keycode 0x09 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/tap-preferred/1/native_posix.keymap b/app/tests/hold-tap/tap-preferred/1/native_posix.keymap new file mode 100644 index 0000000..10336ef --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/1/native_posix.keymap @@ -0,0 +1,11 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(0,0,10) + ZMK_MOCK_RELEASE(0,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/2/events.patterns b/app/tests/hold-tap/tap-preferred/2/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/2/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/2/keycode_events.snapshot b/app/tests/hold-tap/tap-preferred/2/keycode_events.snapshot new file mode 100644 index 0000000..4f1ee63 --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/2/keycode_events.snapshot @@ -0,0 +1,5 @@ +ht_binding_pressed: 0 new undecided hold_tap +ht_decide: 0 decided hold (tap-preferred event 3) +kp_pressed: usage_page 0x07 keycode 0xe1 +kp_released: usage_page 0x07 keycode 0xe1 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/tap-preferred/2/native_posix.keymap b/app/tests/hold-tap/tap-preferred/2/native_posix.keymap new file mode 100644 index 0000000..aa93b86 --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/2/native_posix.keymap @@ -0,0 +1,11 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(0,0,500) + ZMK_MOCK_RELEASE(0,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/3a/events.patterns b/app/tests/hold-tap/tap-preferred/3a/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/3a/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/3a/keycode_events.snapshot b/app/tests/hold-tap/tap-preferred/3a/keycode_events.snapshot new file mode 100644 index 0000000..87d1406 --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/3a/keycode_events.snapshot @@ -0,0 +1,7 @@ +kp_pressed: usage_page 0x07 keycode 0xe4 +ht_binding_pressed: 0 new undecided hold_tap +ht_decide: 0 decided tap (tap-preferred event 0) +kp_pressed: usage_page 0x07 keycode 0x09 +kp_released: usage_page 0x07 keycode 0xe4 +kp_released: usage_page 0x07 keycode 0x09 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/tap-preferred/3a/native_posix.keymap b/app/tests/hold-tap/tap-preferred/3a/native_posix.keymap new file mode 100644 index 0000000..6f08689 --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/3a/native_posix.keymap @@ -0,0 +1,13 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(1,1,10) /*ctrl*/ + ZMK_MOCK_PRESS(0,0,100) /*mt f-shift */ + ZMK_MOCK_RELEASE(1,1,10) + ZMK_MOCK_RELEASE(0,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/3b/events.patterns b/app/tests/hold-tap/tap-preferred/3b/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/3b/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/3b/keycode_events.snapshot b/app/tests/hold-tap/tap-preferred/3b/keycode_events.snapshot new file mode 100644 index 0000000..7455d2a --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/3b/keycode_events.snapshot @@ -0,0 +1,7 @@ +kp_pressed: usage_page 0x07 keycode 0xe4 +ht_binding_pressed: 0 new undecided hold_tap +ht_decide: 0 decided hold (tap-preferred event 3) +kp_pressed: usage_page 0x07 keycode 0xe1 +kp_released: usage_page 0x07 keycode 0xe4 +kp_released: usage_page 0x07 keycode 0xe1 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/tap-preferred/3b/native_posix.keymap b/app/tests/hold-tap/tap-preferred/3b/native_posix.keymap new file mode 100644 index 0000000..392d328 --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/3b/native_posix.keymap @@ -0,0 +1,14 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(1,1,10) /*ctrl*/ + ZMK_MOCK_PRESS(0,0,50) /*mt f-shift */ + ZMK_MOCK_RELEASE(1,1,300) + /*timer*/ + ZMK_MOCK_RELEASE(0,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/3c/events.patterns b/app/tests/hold-tap/tap-preferred/3c/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/3c/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/3c/keycode_events.snapshot b/app/tests/hold-tap/tap-preferred/3c/keycode_events.snapshot new file mode 100644 index 0000000..3d7eaf1 --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/3c/keycode_events.snapshot @@ -0,0 +1,7 @@ +kp_pressed: usage_page 0x07 keycode 0x07 +ht_binding_pressed: 0 new undecided hold_tap +kp_released: usage_page 0x07 keycode 0x07 +ht_decide: 0 decided tap (tap-preferred event 0) +kp_pressed: usage_page 0x07 keycode 0x09 +kp_released: usage_page 0x07 keycode 0x09 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/tap-preferred/3c/native_posix.keymap b/app/tests/hold-tap/tap-preferred/3c/native_posix.keymap new file mode 100644 index 0000000..77306cd --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/3c/native_posix.keymap @@ -0,0 +1,13 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(1,0,10) /*d*/ + ZMK_MOCK_PRESS(0,0,100) /*mt f-shift */ + ZMK_MOCK_RELEASE(1,0,10) + ZMK_MOCK_RELEASE(0,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/3d/events.patterns b/app/tests/hold-tap/tap-preferred/3d/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/3d/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/3d/keycode_events.snapshot b/app/tests/hold-tap/tap-preferred/3d/keycode_events.snapshot new file mode 100644 index 0000000..059d99c --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/3d/keycode_events.snapshot @@ -0,0 +1,7 @@ +kp_pressed: usage_page 0x07 keycode 0x07 +ht_binding_pressed: 0 new undecided hold_tap +kp_released: usage_page 0x07 keycode 0x07 +ht_decide: 0 decided hold (tap-preferred event 3) +kp_pressed: usage_page 0x07 keycode 0xe1 +kp_released: usage_page 0x07 keycode 0xe1 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/tap-preferred/3d/native_posix.keymap b/app/tests/hold-tap/tap-preferred/3d/native_posix.keymap new file mode 100644 index 0000000..1441331 --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/3d/native_posix.keymap @@ -0,0 +1,13 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(1,0,10) /* d */ + ZMK_MOCK_PRESS(0,0,100) /* mt f-shift */ + ZMK_MOCK_RELEASE(1,0,400) + ZMK_MOCK_RELEASE(0,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/4a-nested/events.patterns b/app/tests/hold-tap/tap-preferred/4a-nested/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/4a-nested/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/4a-nested/keycode_events.snapshot b/app/tests/hold-tap/tap-preferred/4a-nested/keycode_events.snapshot new file mode 100644 index 0000000..a8cf490 --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/4a-nested/keycode_events.snapshot @@ -0,0 +1,10 @@ +ht_binding_pressed: 0 new undecided hold_tap +ht_decide: 0 decided hold (tap-preferred event 3) +kp_pressed: usage_page 0x07 keycode 0xe1 +ht_binding_pressed: 1 new undecided hold_tap +ht_decide: 1 decided tap (tap-preferred event 0) +kp_pressed: usage_page 0x07 keycode 0x0d +kp_released: usage_page 0x07 keycode 0x0d +ht_binding_released: 1 cleaning up hold-tap +kp_released: usage_page 0x07 keycode 0xe1 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/tap-preferred/4a-nested/native_posix.keymap b/app/tests/hold-tap/tap-preferred/4a-nested/native_posix.keymap new file mode 100644 index 0000000..c10c6d6 --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/4a-nested/native_posix.keymap @@ -0,0 +1,14 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(0,0,200) + ZMK_MOCK_PRESS(0,1,200) + /* timer fires */ + ZMK_MOCK_RELEASE(0,1,10) + ZMK_MOCK_RELEASE(0,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/4a/events.patterns b/app/tests/hold-tap/tap-preferred/4a/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/4a/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/4a/keycode_events.snapshot b/app/tests/hold-tap/tap-preferred/4a/keycode_events.snapshot new file mode 100644 index 0000000..92a3569 --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/4a/keycode_events.snapshot @@ -0,0 +1,7 @@ +ht_binding_pressed: 0 new undecided hold_tap +ht_decide: 0 decided hold (tap-preferred event 3) +kp_pressed: usage_page 0x07 keycode 0xe1 +kp_pressed: usage_page 0x07 keycode 0x07 +kp_released: usage_page 0x07 keycode 0x07 +kp_released: usage_page 0x07 keycode 0xe1 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/tap-preferred/4a/native_posix.keymap b/app/tests/hold-tap/tap-preferred/4a/native_posix.keymap new file mode 100644 index 0000000..ce163f5 --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/4a/native_posix.keymap @@ -0,0 +1,14 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(0,0,200) + ZMK_MOCK_PRESS(1,0,200) + /* timer fires */ + ZMK_MOCK_RELEASE(1,0,10) + ZMK_MOCK_RELEASE(0,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/4b/events.patterns b/app/tests/hold-tap/tap-preferred/4b/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/4b/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/4b/keycode_events.snapshot b/app/tests/hold-tap/tap-preferred/4b/keycode_events.snapshot new file mode 100644 index 0000000..92a3569 --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/4b/keycode_events.snapshot @@ -0,0 +1,7 @@ +ht_binding_pressed: 0 new undecided hold_tap +ht_decide: 0 decided hold (tap-preferred event 3) +kp_pressed: usage_page 0x07 keycode 0xe1 +kp_pressed: usage_page 0x07 keycode 0x07 +kp_released: usage_page 0x07 keycode 0x07 +kp_released: usage_page 0x07 keycode 0xe1 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/tap-preferred/4b/native_posix.keymap b/app/tests/hold-tap/tap-preferred/4b/native_posix.keymap new file mode 100644 index 0000000..7abda41 --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/4b/native_posix.keymap @@ -0,0 +1,14 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(0,0,100) + ZMK_MOCK_PRESS(1,0,100) + ZMK_MOCK_RELEASE(1,0,200) + /* timer fires */ + ZMK_MOCK_RELEASE(0,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/4c/events.patterns b/app/tests/hold-tap/tap-preferred/4c/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/4c/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/4c/keycode_events.snapshot b/app/tests/hold-tap/tap-preferred/4c/keycode_events.snapshot new file mode 100644 index 0000000..bc8aa8e --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/4c/keycode_events.snapshot @@ -0,0 +1,7 @@ +ht_binding_pressed: 0 new undecided hold_tap +ht_decide: 0 decided tap (tap-preferred event 0) +kp_pressed: usage_page 0x07 keycode 0x09 +kp_pressed: usage_page 0x07 keycode 0x07 +kp_released: usage_page 0x07 keycode 0x07 +kp_released: usage_page 0x07 keycode 0x09 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/tap-preferred/4c/native_posix.keymap b/app/tests/hold-tap/tap-preferred/4c/native_posix.keymap new file mode 100644 index 0000000..ce030af --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/4c/native_posix.keymap @@ -0,0 +1,14 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(0,0,10) + ZMK_MOCK_PRESS(1,0,10) + ZMK_MOCK_RELEASE(1,0,10) + ZMK_MOCK_RELEASE(0,0,10) + /* timer */ + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/4d/events.patterns b/app/tests/hold-tap/tap-preferred/4d/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/4d/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/4d/keycode_events.snapshot b/app/tests/hold-tap/tap-preferred/4d/keycode_events.snapshot new file mode 100644 index 0000000..b106f13 --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/4d/keycode_events.snapshot @@ -0,0 +1,7 @@ +ht_binding_pressed: 0 new undecided hold_tap +ht_decide: 0 decided tap (tap-preferred event 0) +kp_pressed: usage_page 0x07 keycode 0x09 +kp_pressed: usage_page 0x07 keycode 0x07 +kp_released: usage_page 0x07 keycode 0x09 +ht_binding_released: 0 cleaning up hold-tap +kp_released: usage_page 0x07 keycode 0x07 diff --git a/app/tests/hold-tap/tap-preferred/4d/native_posix.keymap b/app/tests/hold-tap/tap-preferred/4d/native_posix.keymap new file mode 100644 index 0000000..5467660 --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/4d/native_posix.keymap @@ -0,0 +1,14 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(0,0,100) + ZMK_MOCK_PRESS(1,0,100) + ZMK_MOCK_RELEASE(0,0,200) + /* timer fires */ + ZMK_MOCK_RELEASE(1,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/behavior_keymap.dtsi b/app/tests/hold-tap/tap-preferred/behavior_keymap.dtsi new file mode 100644 index 0000000..e514fa6 --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/behavior_keymap.dtsi @@ -0,0 +1,27 @@ +#include +#include +#include + +/ { + behaviors { + tp: behavior_tap_preferred { + compatible = "zmk,behavior-hold-tap"; + label = "MOD_TAP"; + #binding-cells = <2>; + flavor = "tap-preferred"; + tapping_term_ms = <300>; + bindings = <&kp>, <&kp>; + }; + }; + + keymap { + compatible = "zmk,keymap"; + label ="Default keymap"; + + default_layer { + bindings = < + &tp LSFT F &tp LCTL J + &kp D &kp RCTL>; + }; + }; +}; diff --git a/app/tests/hold-tap/zmk-modtap-proposal.odg b/app/tests/hold-tap/zmk-modtap-proposal.odg new file mode 100644 index 0000000..82f8436 Binary files /dev/null and b/app/tests/hold-tap/zmk-modtap-proposal.odg differ diff --git a/app/tests/hold-tap/zmk-modtap-proposal.pdf b/app/tests/hold-tap/zmk-modtap-proposal.pdf new file mode 100644 index 0000000..33048ca Binary files /dev/null and b/app/tests/hold-tap/zmk-modtap-proposal.pdf differ diff --git a/app/tests/tap-hold/balanced/behavior_keymap.dtsi b/app/tests/tap-hold/balanced/behavior_keymap.dtsi new file mode 100644 index 0000000..df56fb5 --- /dev/null +++ b/app/tests/tap-hold/balanced/behavior_keymap.dtsi @@ -0,0 +1,27 @@ +#include +#include +#include + +/ { + behaviors { + ht_bal: behavior_hold_tap_balanced { + compatible = "zmk,behavior-hold-tap"; + label = "HOLD_TAP_BALANCED"; + #binding-cells = <2>; + flavor = "balanced"; + tapping_term_ms = <300>; + bindings = <&kp>, <&kp>; + }; + }; + + keymap { + compatible = "zmk,keymap"; + label ="Default keymap"; + + default_layer { + bindings = < + &ht_bal LSFT F &ht_bal LCTL J + &kp D &kp RCTL>; + }; + }; +}; diff --git a/app/tests/tap-hold/hold-preferred/behavior_keymap.dtsi b/app/tests/tap-hold/hold-preferred/behavior_keymap.dtsi new file mode 100644 index 0000000..375ffd9 --- /dev/null +++ b/app/tests/tap-hold/hold-preferred/behavior_keymap.dtsi @@ -0,0 +1,29 @@ +#include +#include +#include + + + +/ { + behaviors { + ht_hold: behavior_hold_hold_tap { + compatible = "zmk,behavior-hold-tap"; + label = "hold_hold_tap"; + #binding-cells = <2>; + flavor = "hold-preferred"; + tapping_term_ms = <300>; + bindings = <&kp>, <&kp>; + }; + }; + + keymap { + compatible = "zmk,keymap"; + label ="Default keymap"; + + default_layer { + bindings = < + &ht_hold LSFT F &ht_hold LCTL J + &kp D &kp RCTL>; + }; + }; +}; diff --git a/app/tests/tap-hold/tap-preferred/behavior_keymap.dtsi b/app/tests/tap-hold/tap-preferred/behavior_keymap.dtsi new file mode 100644 index 0000000..e514fa6 --- /dev/null +++ b/app/tests/tap-hold/tap-preferred/behavior_keymap.dtsi @@ -0,0 +1,27 @@ +#include +#include +#include + +/ { + behaviors { + tp: behavior_tap_preferred { + compatible = "zmk,behavior-hold-tap"; + label = "MOD_TAP"; + #binding-cells = <2>; + flavor = "tap-preferred"; + tapping_term_ms = <300>; + bindings = <&kp>, <&kp>; + }; + }; + + keymap { + compatible = "zmk,keymap"; + label ="Default keymap"; + + default_layer { + bindings = < + &tp LSFT F &tp LCTL J + &kp D &kp RCTL>; + }; + }; +}; -- cgit v1.2.3 From 29a23f018235ede8cfe65f5ede5014408eee879a Mon Sep 17 00:00:00 2001 From: Okke Formsma Date: Tue, 1 Sep 2020 16:04:58 +0200 Subject: Add tap-hold docs, update mod-tap docs --- docs/docs/assets/hold-tap/case1_2.png | Bin 0 -> 10323 bytes docs/docs/assets/hold-tap/case_hold_preferred.png | Bin 0 -> 6380 bytes docs/docs/assets/hold-tap/comparison.png | Bin 0 -> 158912 bytes docs/docs/behavior/hold-tap.md | 62 ++++++++++++++++++++++ docs/docs/behavior/mod-tap.md | 27 +++++++--- 5 files changed, 82 insertions(+), 7 deletions(-) create mode 100644 docs/docs/assets/hold-tap/case1_2.png create mode 100644 docs/docs/assets/hold-tap/case_hold_preferred.png create mode 100644 docs/docs/assets/hold-tap/comparison.png create mode 100644 docs/docs/behavior/hold-tap.md diff --git a/docs/docs/assets/hold-tap/case1_2.png b/docs/docs/assets/hold-tap/case1_2.png new file mode 100644 index 0000000..818ac83 Binary files /dev/null and b/docs/docs/assets/hold-tap/case1_2.png differ diff --git a/docs/docs/assets/hold-tap/case_hold_preferred.png b/docs/docs/assets/hold-tap/case_hold_preferred.png new file mode 100644 index 0000000..6d7fd43 Binary files /dev/null and b/docs/docs/assets/hold-tap/case_hold_preferred.png differ diff --git a/docs/docs/assets/hold-tap/comparison.png b/docs/docs/assets/hold-tap/comparison.png new file mode 100644 index 0000000..419b204 Binary files /dev/null and b/docs/docs/assets/hold-tap/comparison.png differ diff --git a/docs/docs/behavior/hold-tap.md b/docs/docs/behavior/hold-tap.md new file mode 100644 index 0000000..b586b90 --- /dev/null +++ b/docs/docs/behavior/hold-tap.md @@ -0,0 +1,62 @@ +--- +title: Hold-tap behavior +sidebar_label: Hold-Tap +--- + +## Summary +Hold-tap is the basis for other behaviors such as layer-tap and mod-tap. + +Simply put, the hold-tap key will output the 'hold' behavior if it's held for a while, and output the 'tap' behavior when it's tapped quickly. + + +### Hold-Tap +The `tapping_term_ms` parameter decides between a 'tap' and a 'hold'. + +![Simple behavior](../assets/hold-tap/case1_2.png) + +By default, the hold-tap is configured to also select the 'hold' functionality if another key is tapped while it's active: + +![Hold preferred behavior](../assets/hold-tap/case1_2.png) + +We call this the 'hold-preferred' flavor of hold-taps. While this flavor may work very well for a ctrl/escape key, it's not very well suited for home-row mods or layer-taps. That's why there are two more flavors to choose from: 'tap-preferred' and 'balanced'. + +![Hold-tap comparison](../assets/hold-tap/comparison.png) + +### Configuration +A code example which configures a mod-tap setting that works with homerow mods: + +``` +#include +#include + +/ { + behaviors { + &hm: homerow_mods { + compatible = "zmk,behavior-hold-tap"; + label = "homerow_mods"; + #binding-cells = <2>; + tapping_term_ms = <175>; + flavor = "balanced"; + bindings = <&kp>, <&kp>; + }; + }; + + keymap { + compatible = "zmk,keymap"; + + default_layer { + bindings = < + &hm LCTL A &hm LGUI S &hm LALT D &hm LSFT F + >; + }; + }; +}; + +``` + +If this config does not work for you, try the flavor "tap-preferred" and a short tapping_term_ms such as 120ms. + +If you want to use a tap-hold with a keycode from a different code page, you have to define another behavior with another "bindings" parameter.For example, if you want to use SHIFT and volume up, define the bindings like `bindings = <&kp>, <&cp>;`. Only single-argument behaviors are supported at the moment. + +#### Note +Astute readers may notice similarities between the possible behaviors in ZMK and other firmware, such as QMK. The hold-preferred flavor works similar to the `HOLD_ON_OTHER_KEY_PRESS` setting. The 'balanced' flavor is similar to the `PERMISSIVE_HOLD` setting, and the `tap-preferred` flavor is similar to `IGNORE_MOD_TAP_INTERRUPT`. \ No newline at end of file diff --git a/docs/docs/behavior/mod-tap.md b/docs/docs/behavior/mod-tap.md index 08e9b65..cbe95e4 100644 --- a/docs/docs/behavior/mod-tap.md +++ b/docs/docs/behavior/mod-tap.md @@ -5,13 +5,9 @@ sidebar_label: Mod-Tap ## Summary -The Mod-Tap behavior allows varying the effect of pressing and releasing a key position depending -on whether it is used with other simultaneous key presses at the same time. +The Mod-Tap sends a different keypress, if it's tapped or held. When you tap the key shortly, the first keycode is sent. If you hold the key for longer than 200ms, the second keycode is sent. -If pressed and released independently, the Mod-Tap behavior will send the press and release events -for the configure keycode. If pressed and held while another key is pressed and released, then -the configured modifiers will be applied to that _other_ key press, and no press will be generated -on the release of the Mod-Tap key. +If you press another key within the 200ms, the 'mod' behavior is also activated. ## Mod-Tap @@ -20,7 +16,7 @@ The Mod-Tap behavior either acts as a held modifier, or as a tapped keycode. ### Behavior Binding - Reference: `&mt` -- Parameter #1: The modifiers to be used when activating as a modifier, e.g. `MOD_LSFT` +- Parameter #1: The keycode to be sent when activating as a modifier, e.g. `LSFT` - Parameter #2: The keycode to sent when used as a tap, e.g. `A`, `B`. Example: @@ -28,3 +24,20 @@ Example: ``` &mt MOD_LSFT A ``` + +### Configuration + +You can configure a different tapping term in your keymap: + +``` +&mt { + tapping_term_ms: <400>; +} + +/ { + keymap { + ... + } +} +``` + -- cgit v1.2.3 From 081ae84d0ed4e5fd5a90e9a5e279cfcea55e81b4 Mon Sep 17 00:00:00 2001 From: kurtis-lew Date: Tue, 1 Sep 2020 20:22:11 -0700 Subject: Added Iris Shield --- app/boards/shields/iris/Kconfig.defconfig | 14 ++++++++ app/boards/shields/iris/Kconfig.shield | 8 +++++ app/boards/shields/iris/iris.conf | 0 app/boards/shields/iris/iris.dtsi | 51 +++++++++++++++++++++++++++ app/boards/shields/iris/iris.keymap | 56 ++++++++++++++++++++++++++++++ app/boards/shields/iris/iris_left.conf | 2 ++ app/boards/shields/iris/iris_left.overlay | 22 ++++++++++++ app/boards/shields/iris/iris_right.conf | 2 ++ app/boards/shields/iris/iris_right.overlay | 26 ++++++++++++++ 9 files changed, 181 insertions(+) create mode 100644 app/boards/shields/iris/Kconfig.defconfig create mode 100644 app/boards/shields/iris/Kconfig.shield create mode 100644 app/boards/shields/iris/iris.conf create mode 100644 app/boards/shields/iris/iris.dtsi create mode 100644 app/boards/shields/iris/iris.keymap create mode 100644 app/boards/shields/iris/iris_left.conf create mode 100644 app/boards/shields/iris/iris_left.overlay create mode 100644 app/boards/shields/iris/iris_right.conf create mode 100644 app/boards/shields/iris/iris_right.overlay diff --git a/app/boards/shields/iris/Kconfig.defconfig b/app/boards/shields/iris/Kconfig.defconfig new file mode 100644 index 0000000..bf4919a --- /dev/null +++ b/app/boards/shields/iris/Kconfig.defconfig @@ -0,0 +1,14 @@ + +if SHIELD_IRIS_LEFT + +config ZMK_KEYBOARD_NAME + default "Iris Left" + +endif + +if SHIELD_IRIS_RIGHT + +config ZMK_KEYBOARD_NAME + default "Iris Right" + +endif \ No newline at end of file diff --git a/app/boards/shields/iris/Kconfig.shield b/app/boards/shields/iris/Kconfig.shield new file mode 100644 index 0000000..370bd22 --- /dev/null +++ b/app/boards/shields/iris/Kconfig.shield @@ -0,0 +1,8 @@ +# Copyright (c) 2020 Pete Johanson, Kurtis Lew +# SPDX-License-Identifier: MIT + +config SHIELD_IRIS_LEFT + def_bool $(shields_list_contains,iris_left) + +config SHIELD_IRIS_RIGHT + def_bool $(shields_list_contains,iris_right) diff --git a/app/boards/shields/iris/iris.conf b/app/boards/shields/iris/iris.conf new file mode 100644 index 0000000..e69de29 diff --git a/app/boards/shields/iris/iris.dtsi b/app/boards/shields/iris/iris.dtsi new file mode 100644 index 0000000..f6e32c4 --- /dev/null +++ b/app/boards/shields/iris/iris.dtsi @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2020 Pete Johanson, Kurtis Lew + * + * SPDX-License-Identifier: MIT + */ + +#include + +/ { + chosen { + zmk,kscan = &kscan0; + zmk,matrix_transform = &default_transform; + }; + + default_transform: keymap_transform_0 { + compatible = "zmk,matrix-transform"; + columns = <16>; + rows = <4>; +// | SW6 | SW5 | SW4 | SW3 | SW2 | SW1 | | SW1 | SW2 | SW3 | SW4 | SW5 | SW6 | +// | SW12 | SW11 | SW10 | SW9 | SW8 | SW7 | | SW7 | SW8 | SW9 | SW10 | SW11 | SW12 | +// | SW18 | SW17 | SW16 | SW15 | SW14 | SW13 | | SW13 | SW14 | SW15 | SW16 | SW17 | SW18 | +// | SW24 | SW23 | SW22 | SW21 | SW20 | SW19 | SW25 | | SW25 | SW19 | SW20 | SW21 | SW22 | SW23 | SW24 | +// | SW29 | SW28 | SW27 | SW26 | | SW26 | SW27 | SW28 | SW29 | + map = < +RC(0,0) RC(0,1) RC(0,2) RC(0,3) RC(0,4) RC(0,5) RC(0,6) RC(0,7) RC(0,8) RC(0,9) RC(0,10) RC(0,11) +RC(1,0) RC(1,1) RC(1,2) RC(1,3) RC(1,4) RC(1,5) RC(1,6) RC(1,7) RC(1,8) RC(1,9) RC(1,10) RC(1,11) +RC(2,0) RC(2,1) RC(2,2) RC(2,3) RC(2,4) RC(2,5) RC(2,6) RC(2,7) RC(2,8) RC(2,9) RC(2,10) RC(2,11) +RC(3,0) RC(3,1) RC(3,2) RC(3,3) RC(3,4) RC(3,5) RC(4,2) RC(4,9) RC(3,6) RC(3,7) RC(3,8) RC(3,9) RC(3,10) RC(3,11) + RC(4,3) RC(4,4) RC(4,5) RC(4,6) RC(4,7) RC(4,8) + >; + }; + + kscan0: kscan { + compatible = "zmk,kscan-gpio-matrix"; + label = "KSCAN"; + + diode-direction = "col2row"; + row-gpios + = <&pro_micro_d 6 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 7 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 8 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 0 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 4 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + ; + + }; + + bt_unpair_combo: bt_unpair_combo { + compatible = "zmk,bt-unpair-combo"; + }; +}; \ No newline at end of file diff --git a/app/boards/shields/iris/iris.keymap b/app/boards/shields/iris/iris.keymap new file mode 100644 index 0000000..4607adf --- /dev/null +++ b/app/boards/shields/iris/iris.keymap @@ -0,0 +1,56 @@ +#include +#include + +/ { + keymap { + compatible = "zmk,keymap"; + + default_layer { +// ------------------------------------------------------------------------------------------------------------ +// | ESC | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | ` | +// | TAB | Q | W | E | R | T | | Y | U | I | O | P | - | +// | CTRL | A | S | D | F | G | | H | J | K | L | ; | ' | +// | SHIFT | Z | X | C | V | B | "[" | | "]" | N | M | , | . | / | SHIFT | +// | GUI | LOWER| SPACE | | ENTER | RAISE| ALT | + bindings = < +&kp ESC &kp NUM_1 &kp NUM_2 &kp NUM_3 &kp NUM_4 &kp NUM_5 &kp NUM_6 &kp NUM_7 &kp NUM_8 &kp NUM_9 &kp NUM_0 &kp GRAV +&kp TAB &kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P &kp MINUS +&kp LCTL &kp A &kp S &kp D &kp F &kp G &kp H &kp J &kp K &kp L &kp SCLN &kp QUOT +&kp LSFT &kp Z &kp X &kp C &kp V &kp B &kp LBKT &kp RBKT &kp N &kp M &kp CMMA &kp DOT &kp FSLH &kp RSFT + &kp LGUI &mo 1 &kp SPC &kp RET &mo 2 &kp RALT + >; + }; + + lower_layer { +// ------------------------------------------------------------------------------------------------------------ +// | | | | | | | | | | | | | | +// | F1 | F2 | F3 | F4 | F5 | F6 | | F7 | F8 | F9 | F10 | F11 | F12 | +// | ` | ! | @ | # | $ | % | | ^ | & | * | ( | ) | ~ | +// | | | | | | | | | | | _ | + | { | } | "|" | +// | | | | | | | | + bindings = < +&trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans +&kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &kp F6 &kp F7 &kp F8 &kp F9 &kp F10 &kp F11 &kp F12 +&kp GRAV &kp BANG &kp ATSN &kp HASH &kp CURU &kp PRCT &kp CRRT &kp AMPS &kp KMLT &kp LPRN &kp RPRN &kp TILD +&trans &trans &trans &trans &trans &trans &trans &trans &trans &kp MINUS &kp KPLS &kp LCUR &kp RCUR &kp PIPE + &trans &trans &trans &trans &trans &trans + >; + }; + + raise_layer { +// ------------------------------------------------------------------------------------------------------------ +// | | | | | | | | | | | | | | +// | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | | +// | F1 | F2 | F3 | F4 | F5 | F6 | | | <- | ^ | v | -> | | +// | F7 | F8 | F9 | F10 | F11 | F12 | | | | + | - | = | [ | ] | \ | +// | | | | | | | | + bindings = < +&trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans +&kp GRAV &kp NUM_1 &kp NUM_2 &kp NUM_3 &kp NUM_4 &kp NUM_5 &kp NUM_6 &kp NUM_7 &kp NUM_8 &kp NUM_9 &kp NUM_0 &trans +&kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &kp F6 &trans &kp LARW &kp DARW &kp UARW &kp RARW &trans +&kp F7 &kp F8 &kp F9 &kp F10 &kp F11 &kp F12 &trans &trans &kp KPLS &kp MINUS &kp EQL &kp LBKT &kp RBKT &kp BSLH + &trans &trans &trans &trans &trans &trans + >; + }; + }; +}; diff --git a/app/boards/shields/iris/iris_left.conf b/app/boards/shields/iris/iris_left.conf new file mode 100644 index 0000000..1e028a7 --- /dev/null +++ b/app/boards/shields/iris/iris_left.conf @@ -0,0 +1,2 @@ +CONFIG_ZMK_SPLIT=y +CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y diff --git a/app/boards/shields/iris/iris_left.overlay b/app/boards/shields/iris/iris_left.overlay new file mode 100644 index 0000000..e04638e --- /dev/null +++ b/app/boards/shields/iris/iris_left.overlay @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2020 Pete Johanson, Kurtis Lew + * + * SPDX-License-Identifier: MIT + */ + +#include "iris.dtsi" + +&kscan0 { + col-gpios + = <&pro_micro_a 1 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 0 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 15 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 14 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 16 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 10 GPIO_ACTIVE_HIGH> + ; +}; + +&bt_unpair_combo { + key-positions = <0 42>; +}; diff --git a/app/boards/shields/iris/iris_right.conf b/app/boards/shields/iris/iris_right.conf new file mode 100644 index 0000000..990cf7c --- /dev/null +++ b/app/boards/shields/iris/iris_right.conf @@ -0,0 +1,2 @@ +CONFIG_ZMK_SPLIT=y +CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y diff --git a/app/boards/shields/iris/iris_right.overlay b/app/boards/shields/iris/iris_right.overlay new file mode 100644 index 0000000..3f3dcb8 --- /dev/null +++ b/app/boards/shields/iris/iris_right.overlay @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2020 Pete Johanson, Kurtis Lew + * + * SPDX-License-Identifier: MIT + */ + +#include "iris.dtsi" + +&default_transform { + col-offset = <6>; +}; + +&kscan0 { + col-gpios + = <&pro_micro_a 1 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 0 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 15 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 14 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 16 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 10 GPIO_ACTIVE_HIGH> + ; +}; + +&bt_unpair_combo { + key-positions = <11 43>; +}; -- cgit v1.2.3 From 068626d1a74d3883a8ccb2cd514a217098e99420 Mon Sep 17 00:00:00 2001 From: Kevin Date: Tue, 1 Sep 2020 21:12:09 -0700 Subject: Some work on encoder docs --- docs/docs/dev-guide-add-encoders.md | 53 +++++++++++++++++++++++++++++++++++++ docs/docs/feature/encoders.md | 36 ++++++++++++++++++++++++- docs/sidebars.js | 5 +++- 3 files changed, 92 insertions(+), 2 deletions(-) create mode 100644 docs/docs/dev-guide-add-encoders.md diff --git a/docs/docs/dev-guide-add-encoders.md b/docs/docs/dev-guide-add-encoders.md new file mode 100644 index 0000000..79f353f --- /dev/null +++ b/docs/docs/dev-guide-add-encoders.md @@ -0,0 +1,53 @@ +--- +id: dev-guide-add-encoders +title: Adding Encoders +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +EC11 encoder support can be added to your board or shield by adding the appropriate lines to your board/shield's .conf, .dtsi, and .overlay files. + + + + +In your .conf file you will need to add the following lines so that the EC11 drivers can be enabled: + +``` +# Uncomment to enable encoder +# CONFIG_EC11=y +# CONFIG_EC11_TRIGGER_GLOBAL_THREAD=y +``` + +These should be commented by default if encoders are optional, but can be uncommented if encoders are part of the original design. + + + +In your .dtsi file you will need to add the following lines to define the encoder sensor: + + +``` +left_encoder: encoder_left { + compatible = "alps,ec11"; + label = "LEFT_ENCODER"; + a-gpios = ; + b-gpios = ; + resolution = <4>; + }; +``` +Here you will have to replace PIN_A and PIN_B with the appropriate pins that your PCB utilizes for the encoder(s). + +For keyboards that use the Pro Micro or any of the Pro Micro replacements, Sparkfun's [Pro Micro Hookup Guide](https://learn.sparkfun.com/tutorials/pro-micro--fio-v3-hookup-guide/hardware-overview-pro-micro) has a pinout diagram that can be useful to determine the right pins. Reference either the blue numbers labeled "Arduino" (digital pins) or the green numbers labeled "Analog" (analog pins). For pins that are labeled as both digital and analog, refer to your specific board's .dtsi file to determine how you should refer to that pin. + +Replace `left` with `right` to define a right-side encoder, although note that support for peripheral side sensors is still in progress. + + + + + diff --git a/docs/docs/feature/encoders.md b/docs/docs/feature/encoders.md index 16537ad..9f583cb 100644 --- a/docs/docs/feature/encoders.md +++ b/docs/docs/feature/encoders.md @@ -3,4 +3,38 @@ title: Encoders sidebar_label: Encoders --- -TODO: Documentation on encoders. +Existing support for encoders in ZMK is focused around the EC11 rotary encoder with push button design used in the majority of current keyboard and macropad designs. + +## Enabling EC11 Encoders + +To enable encoders for boards that have existing encoder support, uncomment the `EC11_CONFIG=y` and `CONFIG_EC11_TRIGGER_GLOBAL_THREAD=y` lines in your board's .conf file in your `zmk-config/config` folder. Save and push your changes, then download and flash the new firmware. + +## Customizing EC11 Encoder Behavior + +Encoder behavior in ZMK is configured in two different locations as the push button and rotation behaviors are handled in two separate ways. + +### Push Button + +Keyboards and macropads with encoder support will typically take the two EC11 pins responsible for the push button and include them as part of the matrix for the keys. To configure what is sent by the push button, find the encoder's position in the keyboard matrix and assign it a behavior the same as you would any other key. + +### Rotation + +Rotation is handled separately as a type of sensor. The behavior for this is set by defining `sensor-bindings` within a layer but below the `bindings` for the regular keys in the following format: + +``` +sensor-bindings = ; +``` + +- `BINDING` is one of two rotation bindings that are currently defined, `&inc_dec_cp` for consumer key presses or `&inc_dec_kp` for normal key presses (see [Key Press](<(/docs/behavior/key-press)>) for the difference between the two). +- `CW_KEY` is the keycode activated by a clockwise turn. +- `CCW_KEY` is the keycode activated by a counter-clockwise turn. + +Behaviors for additional encoders can be configured by adding more `BINDING CW_KEY CCW_KEY` sets immediately after the first. + +As an example, a complete `sensor-bindings` for a Kyria would look like: + +``` +sensor-bindings = <&inc_dec_cp M_VOLU M_VOLD &inc_dec_kp PGUP PGDN>; +``` + +In this example, the left encoder is configured to control volume up and down while the right encoder sends either Page Up or Page Down. diff --git a/docs/sidebars.js b/docs/sidebars.js index 53c5cf3..924010e 100644 --- a/docs/sidebars.js +++ b/docs/sidebars.js @@ -23,6 +23,9 @@ module.exports = { "dev-posix-board", "dev-tests", ], - "Dev Guides": ["dev-guide-new-shield", "dev-guide-usb-logging"], + "Dev Guides": [ + "dev-guide-new-shield", + "dev-guide-add-encoders", + "dev-guide-usb-logging"], }, }; -- cgit v1.2.3 From f6a9c1ee57e9e8b5a6d2fd7cd5a60c32138a4404 Mon Sep 17 00:00:00 2001 From: Okke Formsma Date: Wed, 2 Sep 2020 15:10:46 +0200 Subject: rename tests --- .../hold-tap/balanced/1-dn-up/events.patterns | 4 +++ .../balanced/1-dn-up/keycode_events.snapshot | 5 ++++ .../hold-tap/balanced/1-dn-up/native_posix.keymap | 11 ++++++++ app/tests/hold-tap/balanced/1/events.patterns | 4 --- .../hold-tap/balanced/1/keycode_events.snapshot | 5 ---- app/tests/hold-tap/balanced/1/native_posix.keymap | 11 -------- .../balanced/2-dn-timer-up/events.patterns | 4 +++ .../balanced/2-dn-timer-up/keycode_events.snapshot | 5 ++++ .../balanced/2-dn-timer-up/native_posix.keymap | 11 ++++++++ app/tests/hold-tap/balanced/2/events.patterns | 4 --- .../hold-tap/balanced/2/keycode_events.snapshot | 5 ---- app/tests/hold-tap/balanced/2/native_posix.keymap | 11 -------- .../balanced/3a-moddn-dn-modup-up/events.patterns | 4 +++ .../3a-moddn-dn-modup-up/keycode_events.snapshot | 7 ++++++ .../3a-moddn-dn-modup-up/native_posix.keymap | 13 ++++++++++ app/tests/hold-tap/balanced/3a/events.patterns | 4 --- .../hold-tap/balanced/3a/keycode_events.snapshot | 7 ------ app/tests/hold-tap/balanced/3a/native_posix.keymap | 13 ---------- .../3b-moddn-dn-modup-timer-up/events.patterns | 4 +++ .../keycode_events.snapshot | 7 ++++++ .../3b-moddn-dn-modup-timer-up/native_posix.keymap | 14 +++++++++++ app/tests/hold-tap/balanced/3b/events.patterns | 4 --- .../hold-tap/balanced/3b/keycode_events.snapshot | 7 ------ app/tests/hold-tap/balanced/3b/native_posix.keymap | 14 ----------- .../balanced/3c-kcdn-dn-kcup-up/events.patterns | 4 +++ .../3c-kcdn-dn-kcup-up/keycode_events.snapshot | 7 ++++++ .../3c-kcdn-dn-kcup-up/native_posix.keymap | 13 ++++++++++ app/tests/hold-tap/balanced/3c/events.patterns | 4 --- .../hold-tap/balanced/3c/keycode_events.snapshot | 7 ------ app/tests/hold-tap/balanced/3c/native_posix.keymap | 13 ---------- .../3d-kcdn-dn-kcup-timer-up/events.patterns | 4 +++ .../keycode_events.snapshot | 7 ++++++ .../3d-kcdn-dn-kcup-timer-up/native_posix.keymap | 13 ++++++++++ app/tests/hold-tap/balanced/3d/events.patterns | 4 --- .../hold-tap/balanced/3d/keycode_events.snapshot | 7 ------ app/tests/hold-tap/balanced/3d/native_posix.keymap | 13 ---------- .../4a-dn-htdn-timer-htup-up/events.patterns | 4 +++ .../keycode_events.snapshot | 10 ++++++++ .../4a-dn-htdn-timer-htup-up/native_posix.keymap | 14 +++++++++++ .../4a-dn-kcdn-timer-kcup-up/events.patterns | 4 +++ .../keycode_events.snapshot | 7 ++++++ .../4a-dn-kcdn-timer-kcup-up/native_posix.keymap | 14 +++++++++++ .../hold-tap/balanced/4a-nested/events.patterns | 4 --- .../balanced/4a-nested/keycode_events.snapshot | 10 -------- .../balanced/4a-nested/native_posix.keymap | 14 ----------- app/tests/hold-tap/balanced/4a/events.patterns | 4 --- .../hold-tap/balanced/4a/keycode_events.snapshot | 7 ------ app/tests/hold-tap/balanced/4a/native_posix.keymap | 14 ----------- .../4b-dn-kcdn-kcup-timer-up/events.patterns | 4 +++ .../keycode_events.snapshot | 7 ++++++ .../4b-dn-kcdn-kcup-timer-up/native_posix.keymap | 14 +++++++++++ app/tests/hold-tap/balanced/4b/events.patterns | 4 --- .../hold-tap/balanced/4b/keycode_events.snapshot | 7 ------ app/tests/hold-tap/balanced/4b/native_posix.keymap | 14 ----------- .../balanced/4c-dn-kcdn-kcup-up/events.patterns | 4 +++ .../4c-dn-kcdn-kcup-up/keycode_events.snapshot | 7 ++++++ .../4c-dn-kcdn-kcup-up/native_posix.keymap | 14 +++++++++++ app/tests/hold-tap/balanced/4c/events.patterns | 4 --- .../hold-tap/balanced/4c/keycode_events.snapshot | 7 ------ app/tests/hold-tap/balanced/4c/native_posix.keymap | 14 ----------- .../4d-dn-kcdn-timer-up-kcup/events.patterns | 4 +++ .../keycode_events.snapshot | 7 ++++++ .../4d-dn-kcdn-timer-up-kcup/native_posix.keymap | 14 +++++++++++ app/tests/hold-tap/balanced/4d/events.patterns | 4 --- .../hold-tap/balanced/4d/keycode_events.snapshot | 7 ------ app/tests/hold-tap/balanced/4d/native_posix.keymap | 14 ----------- .../hold-preferred/1-dn-up/events.patterns | 4 +++ .../hold-preferred/1-dn-up/keycode_events.snapshot | 5 ++++ .../hold-preferred/1-dn-up/native_posix.keymap | 11 ++++++++ .../hold-tap/hold-preferred/1/events.patterns | 4 --- .../hold-preferred/1/keycode_events.snapshot | 5 ---- .../hold-tap/hold-preferred/1/native_posix.keymap | 11 -------- .../hold-preferred/2-dn-timer-up/events.patterns | 4 +++ .../2-dn-timer-up/keycode_events.snapshot | 5 ++++ .../2-dn-timer-up/native_posix.keymap | 11 ++++++++ .../hold-tap/hold-preferred/2/events.patterns | 4 --- .../hold-preferred/2/keycode_events.snapshot | 5 ---- .../hold-tap/hold-preferred/2/native_posix.keymap | 11 -------- .../3a-moddn-dn-modup-up/events.patterns | 4 +++ .../3a-moddn-dn-modup-up/keycode_events.snapshot | 7 ++++++ .../3a-moddn-dn-modup-up/native_posix.keymap | 13 ++++++++++ .../hold-tap/hold-preferred/3a/events.patterns | 4 --- .../hold-preferred/3a/keycode_events.snapshot | 7 ------ .../hold-tap/hold-preferred/3a/native_posix.keymap | 13 ---------- .../3b-moddn-dn-modup-timer-up/events.patterns | 4 +++ .../keycode_events.snapshot | 7 ++++++ .../3b-moddn-dn-modup-timer-up/native_posix.keymap | 14 +++++++++++ .../hold-tap/hold-preferred/3b/events.patterns | 4 --- .../hold-preferred/3b/keycode_events.snapshot | 7 ------ .../hold-tap/hold-preferred/3b/native_posix.keymap | 14 ----------- .../3c-kcdn-dn-kcup-up/events.patterns | 4 +++ .../3c-kcdn-dn-kcup-up/keycode_events.snapshot | 7 ++++++ .../3c-kcdn-dn-kcup-up/native_posix.keymap | 13 ++++++++++ .../hold-tap/hold-preferred/3c/events.patterns | 4 --- .../hold-preferred/3c/keycode_events.snapshot | 7 ------ .../hold-tap/hold-preferred/3c/native_posix.keymap | 13 ---------- .../3d-kcdn-dn-kcup-timer-up/events.patterns | 4 +++ .../keycode_events.snapshot | 7 ++++++ .../3d-kcdn-dn-kcup-timer-up/native_posix.keymap | 13 ++++++++++ .../hold-tap/hold-preferred/3d/events.patterns | 4 --- .../hold-preferred/3d/keycode_events.snapshot | 7 ------ .../hold-tap/hold-preferred/3d/native_posix.keymap | 13 ---------- .../4a-dn-htdn-timer-htup-up/events.patterns | 4 +++ .../keycode_events.snapshot | 10 ++++++++ .../4a-dn-htdn-timer-htup-up/native_posix.keymap | 14 +++++++++++ .../4a-dn-kcdn-timer-kcup-up/events.patterns | 4 +++ .../keycode_events.snapshot | 7 ++++++ .../4a-dn-kcdn-timer-kcup-up/native_posix.keymap | 14 +++++++++++ .../hold-preferred/4a-nested/events.patterns | 4 --- .../4a-nested/keycode_events.snapshot | 10 -------- .../hold-preferred/4a-nested/native_posix.keymap | 14 ----------- .../hold-tap/hold-preferred/4a/events.patterns | 4 --- .../hold-preferred/4a/keycode_events.snapshot | 7 ------ .../hold-tap/hold-preferred/4a/native_posix.keymap | 14 ----------- .../4b-dn-kcdn-kcup-timer-up/events.patterns | 4 +++ .../keycode_events.snapshot | 7 ++++++ .../4b-dn-kcdn-kcup-timer-up/native_posix.keymap | 14 +++++++++++ .../hold-tap/hold-preferred/4b/events.patterns | 4 --- .../hold-preferred/4b/keycode_events.snapshot | 7 ------ .../hold-tap/hold-preferred/4b/native_posix.keymap | 14 ----------- .../4c-dn-kcdn-kcup-up/events.patterns | 4 +++ .../4c-dn-kcdn-kcup-up/keycode_events.snapshot | 7 ++++++ .../4c-dn-kcdn-kcup-up/native_posix.keymap | 14 +++++++++++ .../hold-tap/hold-preferred/4c/events.patterns | 4 --- .../hold-preferred/4c/keycode_events.snapshot | 7 ------ .../hold-tap/hold-preferred/4c/native_posix.keymap | 14 ----------- .../4d-dn-kcdn-timer-up-kcup/events.patterns | 4 +++ .../keycode_events.snapshot | 7 ++++++ .../4d-dn-kcdn-timer-up-kcup/native_posix.keymap | 14 +++++++++++ .../hold-tap/hold-preferred/4d/events.patterns | 4 --- .../hold-preferred/4d/keycode_events.snapshot | 7 ------ .../hold-tap/hold-preferred/4d/native_posix.keymap | 14 ----------- .../hold-tap/tap-preferred/1-dn-up/events.patterns | 4 +++ .../tap-preferred/1-dn-up/keycode_events.snapshot | 5 ++++ .../tap-preferred/1-dn-up/native_posix.keymap | 11 ++++++++ app/tests/hold-tap/tap-preferred/1/events.patterns | 4 --- .../tap-preferred/1/keycode_events.snapshot | 5 ---- .../hold-tap/tap-preferred/1/native_posix.keymap | 11 -------- .../tap-preferred/2-dn-timer-up/events.patterns | 4 +++ .../2-dn-timer-up/keycode_events.snapshot | 5 ++++ .../2-dn-timer-up/native_posix.keymap | 11 ++++++++ app/tests/hold-tap/tap-preferred/2/events.patterns | 4 --- .../tap-preferred/2/keycode_events.snapshot | 5 ---- .../hold-tap/tap-preferred/2/native_posix.keymap | 11 -------- .../3a-moddn-dn-modup-up/events.patterns | 4 +++ .../3a-moddn-dn-modup-up/keycode_events.snapshot | 7 ++++++ .../3a-moddn-dn-modup-up/native_posix.keymap | 13 ++++++++++ .../hold-tap/tap-preferred/3a/events.patterns | 4 --- .../tap-preferred/3a/keycode_events.snapshot | 7 ------ .../hold-tap/tap-preferred/3a/native_posix.keymap | 13 ---------- .../3b-moddn-dn-modup-timer-up/events.patterns | 4 +++ .../keycode_events.snapshot | 7 ++++++ .../3b-moddn-dn-modup-timer-up/native_posix.keymap | 14 +++++++++++ .../hold-tap/tap-preferred/3b/events.patterns | 4 --- .../tap-preferred/3b/keycode_events.snapshot | 7 ------ .../hold-tap/tap-preferred/3b/native_posix.keymap | 14 ----------- .../3c-kcdn-dn-kcup-up/events.patterns | 4 +++ .../3c-kcdn-dn-kcup-up/keycode_events.snapshot | 7 ++++++ .../3c-kcdn-dn-kcup-up/native_posix.keymap | 13 ++++++++++ .../hold-tap/tap-preferred/3c/events.patterns | 4 --- .../tap-preferred/3c/keycode_events.snapshot | 7 ------ .../hold-tap/tap-preferred/3c/native_posix.keymap | 13 ---------- .../3d-kcdn-dn-kcup-timer-up/events.patterns | 4 +++ .../keycode_events.snapshot | 7 ++++++ .../3d-kcdn-dn-kcup-timer-up/native_posix.keymap | 13 ++++++++++ .../hold-tap/tap-preferred/3d/events.patterns | 4 --- .../tap-preferred/3d/keycode_events.snapshot | 7 ------ .../hold-tap/tap-preferred/3d/native_posix.keymap | 13 ---------- .../4a-dn-htdn-timer-htup-up/events.patterns | 4 +++ .../keycode_events.snapshot | 10 ++++++++ .../4a-dn-htdn-timer-htup-up/native_posix.keymap | 14 +++++++++++ .../4a-dn-kcdn-timer-kcup-up/events.patterns | 4 +++ .../keycode_events.snapshot | 7 ++++++ .../4a-dn-kcdn-timer-kcup-up/native_posix.keymap | 14 +++++++++++ .../tap-preferred/4a-nested/events.patterns | 4 --- .../4a-nested/keycode_events.snapshot | 10 -------- .../tap-preferred/4a-nested/native_posix.keymap | 14 ----------- .../hold-tap/tap-preferred/4a/events.patterns | 4 --- .../tap-preferred/4a/keycode_events.snapshot | 7 ------ .../hold-tap/tap-preferred/4a/native_posix.keymap | 14 ----------- .../4b-dn-kcdn-kcup-timer-up/events.patterns | 4 +++ .../keycode_events.snapshot | 7 ++++++ .../4b-dn-kcdn-kcup-timer-up/native_posix.keymap | 14 +++++++++++ .../hold-tap/tap-preferred/4b/events.patterns | 4 --- .../tap-preferred/4b/keycode_events.snapshot | 7 ------ .../hold-tap/tap-preferred/4b/native_posix.keymap | 14 ----------- .../4c-dn-kcdn-kcup-up/events.patterns | 4 +++ .../4c-dn-kcdn-kcup-up/keycode_events.snapshot | 7 ++++++ .../4c-dn-kcdn-kcup-up/native_posix.keymap | 14 +++++++++++ .../hold-tap/tap-preferred/4c/events.patterns | 4 --- .../tap-preferred/4c/keycode_events.snapshot | 7 ------ .../hold-tap/tap-preferred/4c/native_posix.keymap | 14 ----------- .../4d-dn-kcdn-timer-up-kcup/events.patterns | 4 +++ .../keycode_events.snapshot | 7 ++++++ .../4d-dn-kcdn-timer-up-kcup/native_posix.keymap | 14 +++++++++++ .../hold-tap/tap-preferred/4d/events.patterns | 4 --- .../tap-preferred/4d/keycode_events.snapshot | 7 ------ .../hold-tap/tap-preferred/4d/native_posix.keymap | 14 ----------- app/tests/tap-hold/balanced/behavior_keymap.dtsi | 27 -------------------- .../tap-hold/hold-preferred/behavior_keymap.dtsi | 29 ---------------------- .../tap-hold/tap-preferred/behavior_keymap.dtsi | 27 -------------------- 201 files changed, 795 insertions(+), 878 deletions(-) create mode 100644 app/tests/hold-tap/balanced/1-dn-up/events.patterns create mode 100644 app/tests/hold-tap/balanced/1-dn-up/keycode_events.snapshot create mode 100644 app/tests/hold-tap/balanced/1-dn-up/native_posix.keymap delete mode 100644 app/tests/hold-tap/balanced/1/events.patterns delete mode 100644 app/tests/hold-tap/balanced/1/keycode_events.snapshot delete mode 100644 app/tests/hold-tap/balanced/1/native_posix.keymap create mode 100644 app/tests/hold-tap/balanced/2-dn-timer-up/events.patterns create mode 100644 app/tests/hold-tap/balanced/2-dn-timer-up/keycode_events.snapshot create mode 100644 app/tests/hold-tap/balanced/2-dn-timer-up/native_posix.keymap delete mode 100644 app/tests/hold-tap/balanced/2/events.patterns delete mode 100644 app/tests/hold-tap/balanced/2/keycode_events.snapshot delete mode 100644 app/tests/hold-tap/balanced/2/native_posix.keymap create mode 100644 app/tests/hold-tap/balanced/3a-moddn-dn-modup-up/events.patterns create mode 100644 app/tests/hold-tap/balanced/3a-moddn-dn-modup-up/keycode_events.snapshot create mode 100644 app/tests/hold-tap/balanced/3a-moddn-dn-modup-up/native_posix.keymap delete mode 100644 app/tests/hold-tap/balanced/3a/events.patterns delete mode 100644 app/tests/hold-tap/balanced/3a/keycode_events.snapshot delete mode 100644 app/tests/hold-tap/balanced/3a/native_posix.keymap create mode 100644 app/tests/hold-tap/balanced/3b-moddn-dn-modup-timer-up/events.patterns create mode 100644 app/tests/hold-tap/balanced/3b-moddn-dn-modup-timer-up/keycode_events.snapshot create mode 100644 app/tests/hold-tap/balanced/3b-moddn-dn-modup-timer-up/native_posix.keymap delete mode 100644 app/tests/hold-tap/balanced/3b/events.patterns delete mode 100644 app/tests/hold-tap/balanced/3b/keycode_events.snapshot delete mode 100644 app/tests/hold-tap/balanced/3b/native_posix.keymap create mode 100644 app/tests/hold-tap/balanced/3c-kcdn-dn-kcup-up/events.patterns create mode 100644 app/tests/hold-tap/balanced/3c-kcdn-dn-kcup-up/keycode_events.snapshot create mode 100644 app/tests/hold-tap/balanced/3c-kcdn-dn-kcup-up/native_posix.keymap delete mode 100644 app/tests/hold-tap/balanced/3c/events.patterns delete mode 100644 app/tests/hold-tap/balanced/3c/keycode_events.snapshot delete mode 100644 app/tests/hold-tap/balanced/3c/native_posix.keymap create mode 100644 app/tests/hold-tap/balanced/3d-kcdn-dn-kcup-timer-up/events.patterns create mode 100644 app/tests/hold-tap/balanced/3d-kcdn-dn-kcup-timer-up/keycode_events.snapshot create mode 100644 app/tests/hold-tap/balanced/3d-kcdn-dn-kcup-timer-up/native_posix.keymap delete mode 100644 app/tests/hold-tap/balanced/3d/events.patterns delete mode 100644 app/tests/hold-tap/balanced/3d/keycode_events.snapshot delete mode 100644 app/tests/hold-tap/balanced/3d/native_posix.keymap create mode 100644 app/tests/hold-tap/balanced/4a-dn-htdn-timer-htup-up/events.patterns create mode 100644 app/tests/hold-tap/balanced/4a-dn-htdn-timer-htup-up/keycode_events.snapshot create mode 100644 app/tests/hold-tap/balanced/4a-dn-htdn-timer-htup-up/native_posix.keymap create mode 100644 app/tests/hold-tap/balanced/4a-dn-kcdn-timer-kcup-up/events.patterns create mode 100644 app/tests/hold-tap/balanced/4a-dn-kcdn-timer-kcup-up/keycode_events.snapshot create mode 100644 app/tests/hold-tap/balanced/4a-dn-kcdn-timer-kcup-up/native_posix.keymap delete mode 100644 app/tests/hold-tap/balanced/4a-nested/events.patterns delete mode 100644 app/tests/hold-tap/balanced/4a-nested/keycode_events.snapshot delete mode 100644 app/tests/hold-tap/balanced/4a-nested/native_posix.keymap delete mode 100644 app/tests/hold-tap/balanced/4a/events.patterns delete mode 100644 app/tests/hold-tap/balanced/4a/keycode_events.snapshot delete mode 100644 app/tests/hold-tap/balanced/4a/native_posix.keymap create mode 100644 app/tests/hold-tap/balanced/4b-dn-kcdn-kcup-timer-up/events.patterns create mode 100644 app/tests/hold-tap/balanced/4b-dn-kcdn-kcup-timer-up/keycode_events.snapshot create mode 100644 app/tests/hold-tap/balanced/4b-dn-kcdn-kcup-timer-up/native_posix.keymap delete mode 100644 app/tests/hold-tap/balanced/4b/events.patterns delete mode 100644 app/tests/hold-tap/balanced/4b/keycode_events.snapshot delete mode 100644 app/tests/hold-tap/balanced/4b/native_posix.keymap create mode 100644 app/tests/hold-tap/balanced/4c-dn-kcdn-kcup-up/events.patterns create mode 100644 app/tests/hold-tap/balanced/4c-dn-kcdn-kcup-up/keycode_events.snapshot create mode 100644 app/tests/hold-tap/balanced/4c-dn-kcdn-kcup-up/native_posix.keymap delete mode 100644 app/tests/hold-tap/balanced/4c/events.patterns delete mode 100644 app/tests/hold-tap/balanced/4c/keycode_events.snapshot delete mode 100644 app/tests/hold-tap/balanced/4c/native_posix.keymap create mode 100644 app/tests/hold-tap/balanced/4d-dn-kcdn-timer-up-kcup/events.patterns create mode 100644 app/tests/hold-tap/balanced/4d-dn-kcdn-timer-up-kcup/keycode_events.snapshot create mode 100644 app/tests/hold-tap/balanced/4d-dn-kcdn-timer-up-kcup/native_posix.keymap delete mode 100644 app/tests/hold-tap/balanced/4d/events.patterns delete mode 100644 app/tests/hold-tap/balanced/4d/keycode_events.snapshot delete mode 100644 app/tests/hold-tap/balanced/4d/native_posix.keymap create mode 100644 app/tests/hold-tap/hold-preferred/1-dn-up/events.patterns create mode 100644 app/tests/hold-tap/hold-preferred/1-dn-up/keycode_events.snapshot create mode 100644 app/tests/hold-tap/hold-preferred/1-dn-up/native_posix.keymap delete mode 100644 app/tests/hold-tap/hold-preferred/1/events.patterns delete mode 100644 app/tests/hold-tap/hold-preferred/1/keycode_events.snapshot delete mode 100644 app/tests/hold-tap/hold-preferred/1/native_posix.keymap create mode 100644 app/tests/hold-tap/hold-preferred/2-dn-timer-up/events.patterns create mode 100644 app/tests/hold-tap/hold-preferred/2-dn-timer-up/keycode_events.snapshot create mode 100644 app/tests/hold-tap/hold-preferred/2-dn-timer-up/native_posix.keymap delete mode 100644 app/tests/hold-tap/hold-preferred/2/events.patterns delete mode 100644 app/tests/hold-tap/hold-preferred/2/keycode_events.snapshot delete mode 100644 app/tests/hold-tap/hold-preferred/2/native_posix.keymap create mode 100644 app/tests/hold-tap/hold-preferred/3a-moddn-dn-modup-up/events.patterns create mode 100644 app/tests/hold-tap/hold-preferred/3a-moddn-dn-modup-up/keycode_events.snapshot create mode 100644 app/tests/hold-tap/hold-preferred/3a-moddn-dn-modup-up/native_posix.keymap delete mode 100644 app/tests/hold-tap/hold-preferred/3a/events.patterns delete mode 100644 app/tests/hold-tap/hold-preferred/3a/keycode_events.snapshot delete mode 100644 app/tests/hold-tap/hold-preferred/3a/native_posix.keymap create mode 100644 app/tests/hold-tap/hold-preferred/3b-moddn-dn-modup-timer-up/events.patterns create mode 100644 app/tests/hold-tap/hold-preferred/3b-moddn-dn-modup-timer-up/keycode_events.snapshot create mode 100644 app/tests/hold-tap/hold-preferred/3b-moddn-dn-modup-timer-up/native_posix.keymap delete mode 100644 app/tests/hold-tap/hold-preferred/3b/events.patterns delete mode 100644 app/tests/hold-tap/hold-preferred/3b/keycode_events.snapshot delete mode 100644 app/tests/hold-tap/hold-preferred/3b/native_posix.keymap create mode 100644 app/tests/hold-tap/hold-preferred/3c-kcdn-dn-kcup-up/events.patterns create mode 100644 app/tests/hold-tap/hold-preferred/3c-kcdn-dn-kcup-up/keycode_events.snapshot create mode 100644 app/tests/hold-tap/hold-preferred/3c-kcdn-dn-kcup-up/native_posix.keymap delete mode 100644 app/tests/hold-tap/hold-preferred/3c/events.patterns delete mode 100644 app/tests/hold-tap/hold-preferred/3c/keycode_events.snapshot delete mode 100644 app/tests/hold-tap/hold-preferred/3c/native_posix.keymap create mode 100644 app/tests/hold-tap/hold-preferred/3d-kcdn-dn-kcup-timer-up/events.patterns create mode 100644 app/tests/hold-tap/hold-preferred/3d-kcdn-dn-kcup-timer-up/keycode_events.snapshot create mode 100644 app/tests/hold-tap/hold-preferred/3d-kcdn-dn-kcup-timer-up/native_posix.keymap delete mode 100644 app/tests/hold-tap/hold-preferred/3d/events.patterns delete mode 100644 app/tests/hold-tap/hold-preferred/3d/keycode_events.snapshot delete mode 100644 app/tests/hold-tap/hold-preferred/3d/native_posix.keymap create mode 100644 app/tests/hold-tap/hold-preferred/4a-dn-htdn-timer-htup-up/events.patterns create mode 100644 app/tests/hold-tap/hold-preferred/4a-dn-htdn-timer-htup-up/keycode_events.snapshot create mode 100644 app/tests/hold-tap/hold-preferred/4a-dn-htdn-timer-htup-up/native_posix.keymap create mode 100644 app/tests/hold-tap/hold-preferred/4a-dn-kcdn-timer-kcup-up/events.patterns create mode 100644 app/tests/hold-tap/hold-preferred/4a-dn-kcdn-timer-kcup-up/keycode_events.snapshot create mode 100644 app/tests/hold-tap/hold-preferred/4a-dn-kcdn-timer-kcup-up/native_posix.keymap delete mode 100644 app/tests/hold-tap/hold-preferred/4a-nested/events.patterns delete mode 100644 app/tests/hold-tap/hold-preferred/4a-nested/keycode_events.snapshot delete mode 100644 app/tests/hold-tap/hold-preferred/4a-nested/native_posix.keymap delete mode 100644 app/tests/hold-tap/hold-preferred/4a/events.patterns delete mode 100644 app/tests/hold-tap/hold-preferred/4a/keycode_events.snapshot delete mode 100644 app/tests/hold-tap/hold-preferred/4a/native_posix.keymap create mode 100644 app/tests/hold-tap/hold-preferred/4b-dn-kcdn-kcup-timer-up/events.patterns create mode 100644 app/tests/hold-tap/hold-preferred/4b-dn-kcdn-kcup-timer-up/keycode_events.snapshot create mode 100644 app/tests/hold-tap/hold-preferred/4b-dn-kcdn-kcup-timer-up/native_posix.keymap delete mode 100644 app/tests/hold-tap/hold-preferred/4b/events.patterns delete mode 100644 app/tests/hold-tap/hold-preferred/4b/keycode_events.snapshot delete mode 100644 app/tests/hold-tap/hold-preferred/4b/native_posix.keymap create mode 100644 app/tests/hold-tap/hold-preferred/4c-dn-kcdn-kcup-up/events.patterns create mode 100644 app/tests/hold-tap/hold-preferred/4c-dn-kcdn-kcup-up/keycode_events.snapshot create mode 100644 app/tests/hold-tap/hold-preferred/4c-dn-kcdn-kcup-up/native_posix.keymap delete mode 100644 app/tests/hold-tap/hold-preferred/4c/events.patterns delete mode 100644 app/tests/hold-tap/hold-preferred/4c/keycode_events.snapshot delete mode 100644 app/tests/hold-tap/hold-preferred/4c/native_posix.keymap create mode 100644 app/tests/hold-tap/hold-preferred/4d-dn-kcdn-timer-up-kcup/events.patterns create mode 100644 app/tests/hold-tap/hold-preferred/4d-dn-kcdn-timer-up-kcup/keycode_events.snapshot create mode 100644 app/tests/hold-tap/hold-preferred/4d-dn-kcdn-timer-up-kcup/native_posix.keymap delete mode 100644 app/tests/hold-tap/hold-preferred/4d/events.patterns delete mode 100644 app/tests/hold-tap/hold-preferred/4d/keycode_events.snapshot delete mode 100644 app/tests/hold-tap/hold-preferred/4d/native_posix.keymap create mode 100644 app/tests/hold-tap/tap-preferred/1-dn-up/events.patterns create mode 100644 app/tests/hold-tap/tap-preferred/1-dn-up/keycode_events.snapshot create mode 100644 app/tests/hold-tap/tap-preferred/1-dn-up/native_posix.keymap delete mode 100644 app/tests/hold-tap/tap-preferred/1/events.patterns delete mode 100644 app/tests/hold-tap/tap-preferred/1/keycode_events.snapshot delete mode 100644 app/tests/hold-tap/tap-preferred/1/native_posix.keymap create mode 100644 app/tests/hold-tap/tap-preferred/2-dn-timer-up/events.patterns create mode 100644 app/tests/hold-tap/tap-preferred/2-dn-timer-up/keycode_events.snapshot create mode 100644 app/tests/hold-tap/tap-preferred/2-dn-timer-up/native_posix.keymap delete mode 100644 app/tests/hold-tap/tap-preferred/2/events.patterns delete mode 100644 app/tests/hold-tap/tap-preferred/2/keycode_events.snapshot delete mode 100644 app/tests/hold-tap/tap-preferred/2/native_posix.keymap create mode 100644 app/tests/hold-tap/tap-preferred/3a-moddn-dn-modup-up/events.patterns create mode 100644 app/tests/hold-tap/tap-preferred/3a-moddn-dn-modup-up/keycode_events.snapshot create mode 100644 app/tests/hold-tap/tap-preferred/3a-moddn-dn-modup-up/native_posix.keymap delete mode 100644 app/tests/hold-tap/tap-preferred/3a/events.patterns delete mode 100644 app/tests/hold-tap/tap-preferred/3a/keycode_events.snapshot delete mode 100644 app/tests/hold-tap/tap-preferred/3a/native_posix.keymap create mode 100644 app/tests/hold-tap/tap-preferred/3b-moddn-dn-modup-timer-up/events.patterns create mode 100644 app/tests/hold-tap/tap-preferred/3b-moddn-dn-modup-timer-up/keycode_events.snapshot create mode 100644 app/tests/hold-tap/tap-preferred/3b-moddn-dn-modup-timer-up/native_posix.keymap delete mode 100644 app/tests/hold-tap/tap-preferred/3b/events.patterns delete mode 100644 app/tests/hold-tap/tap-preferred/3b/keycode_events.snapshot delete mode 100644 app/tests/hold-tap/tap-preferred/3b/native_posix.keymap create mode 100644 app/tests/hold-tap/tap-preferred/3c-kcdn-dn-kcup-up/events.patterns create mode 100644 app/tests/hold-tap/tap-preferred/3c-kcdn-dn-kcup-up/keycode_events.snapshot create mode 100644 app/tests/hold-tap/tap-preferred/3c-kcdn-dn-kcup-up/native_posix.keymap delete mode 100644 app/tests/hold-tap/tap-preferred/3c/events.patterns delete mode 100644 app/tests/hold-tap/tap-preferred/3c/keycode_events.snapshot delete mode 100644 app/tests/hold-tap/tap-preferred/3c/native_posix.keymap create mode 100644 app/tests/hold-tap/tap-preferred/3d-kcdn-dn-kcup-timer-up/events.patterns create mode 100644 app/tests/hold-tap/tap-preferred/3d-kcdn-dn-kcup-timer-up/keycode_events.snapshot create mode 100644 app/tests/hold-tap/tap-preferred/3d-kcdn-dn-kcup-timer-up/native_posix.keymap delete mode 100644 app/tests/hold-tap/tap-preferred/3d/events.patterns delete mode 100644 app/tests/hold-tap/tap-preferred/3d/keycode_events.snapshot delete mode 100644 app/tests/hold-tap/tap-preferred/3d/native_posix.keymap create mode 100644 app/tests/hold-tap/tap-preferred/4a-dn-htdn-timer-htup-up/events.patterns create mode 100644 app/tests/hold-tap/tap-preferred/4a-dn-htdn-timer-htup-up/keycode_events.snapshot create mode 100644 app/tests/hold-tap/tap-preferred/4a-dn-htdn-timer-htup-up/native_posix.keymap create mode 100644 app/tests/hold-tap/tap-preferred/4a-dn-kcdn-timer-kcup-up/events.patterns create mode 100644 app/tests/hold-tap/tap-preferred/4a-dn-kcdn-timer-kcup-up/keycode_events.snapshot create mode 100644 app/tests/hold-tap/tap-preferred/4a-dn-kcdn-timer-kcup-up/native_posix.keymap delete mode 100644 app/tests/hold-tap/tap-preferred/4a-nested/events.patterns delete mode 100644 app/tests/hold-tap/tap-preferred/4a-nested/keycode_events.snapshot delete mode 100644 app/tests/hold-tap/tap-preferred/4a-nested/native_posix.keymap delete mode 100644 app/tests/hold-tap/tap-preferred/4a/events.patterns delete mode 100644 app/tests/hold-tap/tap-preferred/4a/keycode_events.snapshot delete mode 100644 app/tests/hold-tap/tap-preferred/4a/native_posix.keymap create mode 100644 app/tests/hold-tap/tap-preferred/4b-dn-kcdn-kcup-timer-up/events.patterns create mode 100644 app/tests/hold-tap/tap-preferred/4b-dn-kcdn-kcup-timer-up/keycode_events.snapshot create mode 100644 app/tests/hold-tap/tap-preferred/4b-dn-kcdn-kcup-timer-up/native_posix.keymap delete mode 100644 app/tests/hold-tap/tap-preferred/4b/events.patterns delete mode 100644 app/tests/hold-tap/tap-preferred/4b/keycode_events.snapshot delete mode 100644 app/tests/hold-tap/tap-preferred/4b/native_posix.keymap create mode 100644 app/tests/hold-tap/tap-preferred/4c-dn-kcdn-kcup-up/events.patterns create mode 100644 app/tests/hold-tap/tap-preferred/4c-dn-kcdn-kcup-up/keycode_events.snapshot create mode 100644 app/tests/hold-tap/tap-preferred/4c-dn-kcdn-kcup-up/native_posix.keymap delete mode 100644 app/tests/hold-tap/tap-preferred/4c/events.patterns delete mode 100644 app/tests/hold-tap/tap-preferred/4c/keycode_events.snapshot delete mode 100644 app/tests/hold-tap/tap-preferred/4c/native_posix.keymap create mode 100644 app/tests/hold-tap/tap-preferred/4d-dn-kcdn-timer-up-kcup/events.patterns create mode 100644 app/tests/hold-tap/tap-preferred/4d-dn-kcdn-timer-up-kcup/keycode_events.snapshot create mode 100644 app/tests/hold-tap/tap-preferred/4d-dn-kcdn-timer-up-kcup/native_posix.keymap delete mode 100644 app/tests/hold-tap/tap-preferred/4d/events.patterns delete mode 100644 app/tests/hold-tap/tap-preferred/4d/keycode_events.snapshot delete mode 100644 app/tests/hold-tap/tap-preferred/4d/native_posix.keymap delete mode 100644 app/tests/tap-hold/balanced/behavior_keymap.dtsi delete mode 100644 app/tests/tap-hold/hold-preferred/behavior_keymap.dtsi delete mode 100644 app/tests/tap-hold/tap-preferred/behavior_keymap.dtsi diff --git a/app/tests/hold-tap/balanced/1-dn-up/events.patterns b/app/tests/hold-tap/balanced/1-dn-up/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/balanced/1-dn-up/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/1-dn-up/keycode_events.snapshot b/app/tests/hold-tap/balanced/1-dn-up/keycode_events.snapshot new file mode 100644 index 0000000..5f6a266 --- /dev/null +++ b/app/tests/hold-tap/balanced/1-dn-up/keycode_events.snapshot @@ -0,0 +1,5 @@ +ht_binding_pressed: 0 new undecided hold_tap +ht_decide: 0 decided tap (balanced event 0) +kp_pressed: usage_page 0x07 keycode 0x09 +kp_released: usage_page 0x07 keycode 0x09 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/balanced/1-dn-up/native_posix.keymap b/app/tests/hold-tap/balanced/1-dn-up/native_posix.keymap new file mode 100644 index 0000000..10336ef --- /dev/null +++ b/app/tests/hold-tap/balanced/1-dn-up/native_posix.keymap @@ -0,0 +1,11 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(0,0,10) + ZMK_MOCK_RELEASE(0,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/1/events.patterns b/app/tests/hold-tap/balanced/1/events.patterns deleted file mode 100644 index fdf2b15..0000000 --- a/app/tests/hold-tap/balanced/1/events.patterns +++ /dev/null @@ -1,4 +0,0 @@ -s/.*hid_listener_keycode/kp/p -s/.*mo_keymap_binding/mo/p -s/.*on_hold_tap_binding/ht_binding/p -s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/1/keycode_events.snapshot b/app/tests/hold-tap/balanced/1/keycode_events.snapshot deleted file mode 100644 index 5f6a266..0000000 --- a/app/tests/hold-tap/balanced/1/keycode_events.snapshot +++ /dev/null @@ -1,5 +0,0 @@ -ht_binding_pressed: 0 new undecided hold_tap -ht_decide: 0 decided tap (balanced event 0) -kp_pressed: usage_page 0x07 keycode 0x09 -kp_released: usage_page 0x07 keycode 0x09 -ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/balanced/1/native_posix.keymap b/app/tests/hold-tap/balanced/1/native_posix.keymap deleted file mode 100644 index 10336ef..0000000 --- a/app/tests/hold-tap/balanced/1/native_posix.keymap +++ /dev/null @@ -1,11 +0,0 @@ -#include -#include -#include -#include "../behavior_keymap.dtsi" - -&kscan { - events = < - ZMK_MOCK_PRESS(0,0,10) - ZMK_MOCK_RELEASE(0,0,10) - >; -}; \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/2-dn-timer-up/events.patterns b/app/tests/hold-tap/balanced/2-dn-timer-up/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/balanced/2-dn-timer-up/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/2-dn-timer-up/keycode_events.snapshot b/app/tests/hold-tap/balanced/2-dn-timer-up/keycode_events.snapshot new file mode 100644 index 0000000..ddda1ae --- /dev/null +++ b/app/tests/hold-tap/balanced/2-dn-timer-up/keycode_events.snapshot @@ -0,0 +1,5 @@ +ht_binding_pressed: 0 new undecided hold_tap +ht_decide: 0 decided hold (balanced event 3) +kp_pressed: usage_page 0x07 keycode 0xe1 +kp_released: usage_page 0x07 keycode 0xe1 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/balanced/2-dn-timer-up/native_posix.keymap b/app/tests/hold-tap/balanced/2-dn-timer-up/native_posix.keymap new file mode 100644 index 0000000..aa93b86 --- /dev/null +++ b/app/tests/hold-tap/balanced/2-dn-timer-up/native_posix.keymap @@ -0,0 +1,11 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(0,0,500) + ZMK_MOCK_RELEASE(0,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/2/events.patterns b/app/tests/hold-tap/balanced/2/events.patterns deleted file mode 100644 index fdf2b15..0000000 --- a/app/tests/hold-tap/balanced/2/events.patterns +++ /dev/null @@ -1,4 +0,0 @@ -s/.*hid_listener_keycode/kp/p -s/.*mo_keymap_binding/mo/p -s/.*on_hold_tap_binding/ht_binding/p -s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/2/keycode_events.snapshot b/app/tests/hold-tap/balanced/2/keycode_events.snapshot deleted file mode 100644 index ddda1ae..0000000 --- a/app/tests/hold-tap/balanced/2/keycode_events.snapshot +++ /dev/null @@ -1,5 +0,0 @@ -ht_binding_pressed: 0 new undecided hold_tap -ht_decide: 0 decided hold (balanced event 3) -kp_pressed: usage_page 0x07 keycode 0xe1 -kp_released: usage_page 0x07 keycode 0xe1 -ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/balanced/2/native_posix.keymap b/app/tests/hold-tap/balanced/2/native_posix.keymap deleted file mode 100644 index aa93b86..0000000 --- a/app/tests/hold-tap/balanced/2/native_posix.keymap +++ /dev/null @@ -1,11 +0,0 @@ -#include -#include -#include -#include "../behavior_keymap.dtsi" - -&kscan { - events = < - ZMK_MOCK_PRESS(0,0,500) - ZMK_MOCK_RELEASE(0,0,10) - >; -}; \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/3a-moddn-dn-modup-up/events.patterns b/app/tests/hold-tap/balanced/3a-moddn-dn-modup-up/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/balanced/3a-moddn-dn-modup-up/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/3a-moddn-dn-modup-up/keycode_events.snapshot b/app/tests/hold-tap/balanced/3a-moddn-dn-modup-up/keycode_events.snapshot new file mode 100644 index 0000000..a435103 --- /dev/null +++ b/app/tests/hold-tap/balanced/3a-moddn-dn-modup-up/keycode_events.snapshot @@ -0,0 +1,7 @@ +kp_pressed: usage_page 0x07 keycode 0xe4 +ht_binding_pressed: 0 new undecided hold_tap +ht_decide: 0 decided tap (balanced event 0) +kp_pressed: usage_page 0x07 keycode 0x09 +kp_released: usage_page 0x07 keycode 0xe4 +kp_released: usage_page 0x07 keycode 0x09 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/balanced/3a-moddn-dn-modup-up/native_posix.keymap b/app/tests/hold-tap/balanced/3a-moddn-dn-modup-up/native_posix.keymap new file mode 100644 index 0000000..6f08689 --- /dev/null +++ b/app/tests/hold-tap/balanced/3a-moddn-dn-modup-up/native_posix.keymap @@ -0,0 +1,13 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(1,1,10) /*ctrl*/ + ZMK_MOCK_PRESS(0,0,100) /*mt f-shift */ + ZMK_MOCK_RELEASE(1,1,10) + ZMK_MOCK_RELEASE(0,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/3a/events.patterns b/app/tests/hold-tap/balanced/3a/events.patterns deleted file mode 100644 index fdf2b15..0000000 --- a/app/tests/hold-tap/balanced/3a/events.patterns +++ /dev/null @@ -1,4 +0,0 @@ -s/.*hid_listener_keycode/kp/p -s/.*mo_keymap_binding/mo/p -s/.*on_hold_tap_binding/ht_binding/p -s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/3a/keycode_events.snapshot b/app/tests/hold-tap/balanced/3a/keycode_events.snapshot deleted file mode 100644 index a435103..0000000 --- a/app/tests/hold-tap/balanced/3a/keycode_events.snapshot +++ /dev/null @@ -1,7 +0,0 @@ -kp_pressed: usage_page 0x07 keycode 0xe4 -ht_binding_pressed: 0 new undecided hold_tap -ht_decide: 0 decided tap (balanced event 0) -kp_pressed: usage_page 0x07 keycode 0x09 -kp_released: usage_page 0x07 keycode 0xe4 -kp_released: usage_page 0x07 keycode 0x09 -ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/balanced/3a/native_posix.keymap b/app/tests/hold-tap/balanced/3a/native_posix.keymap deleted file mode 100644 index 6f08689..0000000 --- a/app/tests/hold-tap/balanced/3a/native_posix.keymap +++ /dev/null @@ -1,13 +0,0 @@ -#include -#include -#include -#include "../behavior_keymap.dtsi" - -&kscan { - events = < - ZMK_MOCK_PRESS(1,1,10) /*ctrl*/ - ZMK_MOCK_PRESS(0,0,100) /*mt f-shift */ - ZMK_MOCK_RELEASE(1,1,10) - ZMK_MOCK_RELEASE(0,0,10) - >; -}; \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/3b-moddn-dn-modup-timer-up/events.patterns b/app/tests/hold-tap/balanced/3b-moddn-dn-modup-timer-up/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/balanced/3b-moddn-dn-modup-timer-up/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/3b-moddn-dn-modup-timer-up/keycode_events.snapshot b/app/tests/hold-tap/balanced/3b-moddn-dn-modup-timer-up/keycode_events.snapshot new file mode 100644 index 0000000..c0da94f --- /dev/null +++ b/app/tests/hold-tap/balanced/3b-moddn-dn-modup-timer-up/keycode_events.snapshot @@ -0,0 +1,7 @@ +kp_pressed: usage_page 0x07 keycode 0xe4 +ht_binding_pressed: 0 new undecided hold_tap +ht_decide: 0 decided hold (balanced event 3) +kp_pressed: usage_page 0x07 keycode 0xe1 +kp_released: usage_page 0x07 keycode 0xe4 +kp_released: usage_page 0x07 keycode 0xe1 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/balanced/3b-moddn-dn-modup-timer-up/native_posix.keymap b/app/tests/hold-tap/balanced/3b-moddn-dn-modup-timer-up/native_posix.keymap new file mode 100644 index 0000000..392d328 --- /dev/null +++ b/app/tests/hold-tap/balanced/3b-moddn-dn-modup-timer-up/native_posix.keymap @@ -0,0 +1,14 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(1,1,10) /*ctrl*/ + ZMK_MOCK_PRESS(0,0,50) /*mt f-shift */ + ZMK_MOCK_RELEASE(1,1,300) + /*timer*/ + ZMK_MOCK_RELEASE(0,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/3b/events.patterns b/app/tests/hold-tap/balanced/3b/events.patterns deleted file mode 100644 index fdf2b15..0000000 --- a/app/tests/hold-tap/balanced/3b/events.patterns +++ /dev/null @@ -1,4 +0,0 @@ -s/.*hid_listener_keycode/kp/p -s/.*mo_keymap_binding/mo/p -s/.*on_hold_tap_binding/ht_binding/p -s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/3b/keycode_events.snapshot b/app/tests/hold-tap/balanced/3b/keycode_events.snapshot deleted file mode 100644 index c0da94f..0000000 --- a/app/tests/hold-tap/balanced/3b/keycode_events.snapshot +++ /dev/null @@ -1,7 +0,0 @@ -kp_pressed: usage_page 0x07 keycode 0xe4 -ht_binding_pressed: 0 new undecided hold_tap -ht_decide: 0 decided hold (balanced event 3) -kp_pressed: usage_page 0x07 keycode 0xe1 -kp_released: usage_page 0x07 keycode 0xe4 -kp_released: usage_page 0x07 keycode 0xe1 -ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/balanced/3b/native_posix.keymap b/app/tests/hold-tap/balanced/3b/native_posix.keymap deleted file mode 100644 index 392d328..0000000 --- a/app/tests/hold-tap/balanced/3b/native_posix.keymap +++ /dev/null @@ -1,14 +0,0 @@ -#include -#include -#include -#include "../behavior_keymap.dtsi" - -&kscan { - events = < - ZMK_MOCK_PRESS(1,1,10) /*ctrl*/ - ZMK_MOCK_PRESS(0,0,50) /*mt f-shift */ - ZMK_MOCK_RELEASE(1,1,300) - /*timer*/ - ZMK_MOCK_RELEASE(0,0,10) - >; -}; \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/3c-kcdn-dn-kcup-up/events.patterns b/app/tests/hold-tap/balanced/3c-kcdn-dn-kcup-up/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/balanced/3c-kcdn-dn-kcup-up/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/3c-kcdn-dn-kcup-up/keycode_events.snapshot b/app/tests/hold-tap/balanced/3c-kcdn-dn-kcup-up/keycode_events.snapshot new file mode 100644 index 0000000..ce6e7b7 --- /dev/null +++ b/app/tests/hold-tap/balanced/3c-kcdn-dn-kcup-up/keycode_events.snapshot @@ -0,0 +1,7 @@ +kp_pressed: usage_page 0x07 keycode 0x07 +ht_binding_pressed: 0 new undecided hold_tap +kp_released: usage_page 0x07 keycode 0x07 +ht_decide: 0 decided tap (balanced event 0) +kp_pressed: usage_page 0x07 keycode 0x09 +kp_released: usage_page 0x07 keycode 0x09 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/balanced/3c-kcdn-dn-kcup-up/native_posix.keymap b/app/tests/hold-tap/balanced/3c-kcdn-dn-kcup-up/native_posix.keymap new file mode 100644 index 0000000..77306cd --- /dev/null +++ b/app/tests/hold-tap/balanced/3c-kcdn-dn-kcup-up/native_posix.keymap @@ -0,0 +1,13 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(1,0,10) /*d*/ + ZMK_MOCK_PRESS(0,0,100) /*mt f-shift */ + ZMK_MOCK_RELEASE(1,0,10) + ZMK_MOCK_RELEASE(0,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/3c/events.patterns b/app/tests/hold-tap/balanced/3c/events.patterns deleted file mode 100644 index fdf2b15..0000000 --- a/app/tests/hold-tap/balanced/3c/events.patterns +++ /dev/null @@ -1,4 +0,0 @@ -s/.*hid_listener_keycode/kp/p -s/.*mo_keymap_binding/mo/p -s/.*on_hold_tap_binding/ht_binding/p -s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/3c/keycode_events.snapshot b/app/tests/hold-tap/balanced/3c/keycode_events.snapshot deleted file mode 100644 index ce6e7b7..0000000 --- a/app/tests/hold-tap/balanced/3c/keycode_events.snapshot +++ /dev/null @@ -1,7 +0,0 @@ -kp_pressed: usage_page 0x07 keycode 0x07 -ht_binding_pressed: 0 new undecided hold_tap -kp_released: usage_page 0x07 keycode 0x07 -ht_decide: 0 decided tap (balanced event 0) -kp_pressed: usage_page 0x07 keycode 0x09 -kp_released: usage_page 0x07 keycode 0x09 -ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/balanced/3c/native_posix.keymap b/app/tests/hold-tap/balanced/3c/native_posix.keymap deleted file mode 100644 index 77306cd..0000000 --- a/app/tests/hold-tap/balanced/3c/native_posix.keymap +++ /dev/null @@ -1,13 +0,0 @@ -#include -#include -#include -#include "../behavior_keymap.dtsi" - -&kscan { - events = < - ZMK_MOCK_PRESS(1,0,10) /*d*/ - ZMK_MOCK_PRESS(0,0,100) /*mt f-shift */ - ZMK_MOCK_RELEASE(1,0,10) - ZMK_MOCK_RELEASE(0,0,10) - >; -}; \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/3d-kcdn-dn-kcup-timer-up/events.patterns b/app/tests/hold-tap/balanced/3d-kcdn-dn-kcup-timer-up/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/balanced/3d-kcdn-dn-kcup-timer-up/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/3d-kcdn-dn-kcup-timer-up/keycode_events.snapshot b/app/tests/hold-tap/balanced/3d-kcdn-dn-kcup-timer-up/keycode_events.snapshot new file mode 100644 index 0000000..1ec384a --- /dev/null +++ b/app/tests/hold-tap/balanced/3d-kcdn-dn-kcup-timer-up/keycode_events.snapshot @@ -0,0 +1,7 @@ +kp_pressed: usage_page 0x07 keycode 0x07 +ht_binding_pressed: 0 new undecided hold_tap +kp_released: usage_page 0x07 keycode 0x07 +ht_decide: 0 decided hold (balanced event 3) +kp_pressed: usage_page 0x07 keycode 0xe1 +kp_released: usage_page 0x07 keycode 0xe1 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/balanced/3d-kcdn-dn-kcup-timer-up/native_posix.keymap b/app/tests/hold-tap/balanced/3d-kcdn-dn-kcup-timer-up/native_posix.keymap new file mode 100644 index 0000000..1441331 --- /dev/null +++ b/app/tests/hold-tap/balanced/3d-kcdn-dn-kcup-timer-up/native_posix.keymap @@ -0,0 +1,13 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(1,0,10) /* d */ + ZMK_MOCK_PRESS(0,0,100) /* mt f-shift */ + ZMK_MOCK_RELEASE(1,0,400) + ZMK_MOCK_RELEASE(0,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/3d/events.patterns b/app/tests/hold-tap/balanced/3d/events.patterns deleted file mode 100644 index fdf2b15..0000000 --- a/app/tests/hold-tap/balanced/3d/events.patterns +++ /dev/null @@ -1,4 +0,0 @@ -s/.*hid_listener_keycode/kp/p -s/.*mo_keymap_binding/mo/p -s/.*on_hold_tap_binding/ht_binding/p -s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/3d/keycode_events.snapshot b/app/tests/hold-tap/balanced/3d/keycode_events.snapshot deleted file mode 100644 index 1ec384a..0000000 --- a/app/tests/hold-tap/balanced/3d/keycode_events.snapshot +++ /dev/null @@ -1,7 +0,0 @@ -kp_pressed: usage_page 0x07 keycode 0x07 -ht_binding_pressed: 0 new undecided hold_tap -kp_released: usage_page 0x07 keycode 0x07 -ht_decide: 0 decided hold (balanced event 3) -kp_pressed: usage_page 0x07 keycode 0xe1 -kp_released: usage_page 0x07 keycode 0xe1 -ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/balanced/3d/native_posix.keymap b/app/tests/hold-tap/balanced/3d/native_posix.keymap deleted file mode 100644 index 1441331..0000000 --- a/app/tests/hold-tap/balanced/3d/native_posix.keymap +++ /dev/null @@ -1,13 +0,0 @@ -#include -#include -#include -#include "../behavior_keymap.dtsi" - -&kscan { - events = < - ZMK_MOCK_PRESS(1,0,10) /* d */ - ZMK_MOCK_PRESS(0,0,100) /* mt f-shift */ - ZMK_MOCK_RELEASE(1,0,400) - ZMK_MOCK_RELEASE(0,0,10) - >; -}; \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/4a-dn-htdn-timer-htup-up/events.patterns b/app/tests/hold-tap/balanced/4a-dn-htdn-timer-htup-up/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/balanced/4a-dn-htdn-timer-htup-up/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/4a-dn-htdn-timer-htup-up/keycode_events.snapshot b/app/tests/hold-tap/balanced/4a-dn-htdn-timer-htup-up/keycode_events.snapshot new file mode 100644 index 0000000..8a1980b --- /dev/null +++ b/app/tests/hold-tap/balanced/4a-dn-htdn-timer-htup-up/keycode_events.snapshot @@ -0,0 +1,10 @@ +ht_binding_pressed: 0 new undecided hold_tap +ht_decide: 0 decided hold (balanced event 3) +kp_pressed: usage_page 0x07 keycode 0xe1 +ht_binding_pressed: 1 new undecided hold_tap +ht_decide: 1 decided tap (balanced event 0) +kp_pressed: usage_page 0x07 keycode 0x0d +kp_released: usage_page 0x07 keycode 0x0d +ht_binding_released: 1 cleaning up hold-tap +kp_released: usage_page 0x07 keycode 0xe1 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/balanced/4a-dn-htdn-timer-htup-up/native_posix.keymap b/app/tests/hold-tap/balanced/4a-dn-htdn-timer-htup-up/native_posix.keymap new file mode 100644 index 0000000..c10c6d6 --- /dev/null +++ b/app/tests/hold-tap/balanced/4a-dn-htdn-timer-htup-up/native_posix.keymap @@ -0,0 +1,14 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(0,0,200) + ZMK_MOCK_PRESS(0,1,200) + /* timer fires */ + ZMK_MOCK_RELEASE(0,1,10) + ZMK_MOCK_RELEASE(0,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/4a-dn-kcdn-timer-kcup-up/events.patterns b/app/tests/hold-tap/balanced/4a-dn-kcdn-timer-kcup-up/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/balanced/4a-dn-kcdn-timer-kcup-up/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/4a-dn-kcdn-timer-kcup-up/keycode_events.snapshot b/app/tests/hold-tap/balanced/4a-dn-kcdn-timer-kcup-up/keycode_events.snapshot new file mode 100644 index 0000000..b89b21d --- /dev/null +++ b/app/tests/hold-tap/balanced/4a-dn-kcdn-timer-kcup-up/keycode_events.snapshot @@ -0,0 +1,7 @@ +ht_binding_pressed: 0 new undecided hold_tap +ht_decide: 0 decided hold (balanced event 3) +kp_pressed: usage_page 0x07 keycode 0xe1 +kp_pressed: usage_page 0x07 keycode 0x07 +kp_released: usage_page 0x07 keycode 0x07 +kp_released: usage_page 0x07 keycode 0xe1 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/balanced/4a-dn-kcdn-timer-kcup-up/native_posix.keymap b/app/tests/hold-tap/balanced/4a-dn-kcdn-timer-kcup-up/native_posix.keymap new file mode 100644 index 0000000..ce163f5 --- /dev/null +++ b/app/tests/hold-tap/balanced/4a-dn-kcdn-timer-kcup-up/native_posix.keymap @@ -0,0 +1,14 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(0,0,200) + ZMK_MOCK_PRESS(1,0,200) + /* timer fires */ + ZMK_MOCK_RELEASE(1,0,10) + ZMK_MOCK_RELEASE(0,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/4a-nested/events.patterns b/app/tests/hold-tap/balanced/4a-nested/events.patterns deleted file mode 100644 index fdf2b15..0000000 --- a/app/tests/hold-tap/balanced/4a-nested/events.patterns +++ /dev/null @@ -1,4 +0,0 @@ -s/.*hid_listener_keycode/kp/p -s/.*mo_keymap_binding/mo/p -s/.*on_hold_tap_binding/ht_binding/p -s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/4a-nested/keycode_events.snapshot b/app/tests/hold-tap/balanced/4a-nested/keycode_events.snapshot deleted file mode 100644 index 8a1980b..0000000 --- a/app/tests/hold-tap/balanced/4a-nested/keycode_events.snapshot +++ /dev/null @@ -1,10 +0,0 @@ -ht_binding_pressed: 0 new undecided hold_tap -ht_decide: 0 decided hold (balanced event 3) -kp_pressed: usage_page 0x07 keycode 0xe1 -ht_binding_pressed: 1 new undecided hold_tap -ht_decide: 1 decided tap (balanced event 0) -kp_pressed: usage_page 0x07 keycode 0x0d -kp_released: usage_page 0x07 keycode 0x0d -ht_binding_released: 1 cleaning up hold-tap -kp_released: usage_page 0x07 keycode 0xe1 -ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/balanced/4a-nested/native_posix.keymap b/app/tests/hold-tap/balanced/4a-nested/native_posix.keymap deleted file mode 100644 index c10c6d6..0000000 --- a/app/tests/hold-tap/balanced/4a-nested/native_posix.keymap +++ /dev/null @@ -1,14 +0,0 @@ -#include -#include -#include -#include "../behavior_keymap.dtsi" - -&kscan { - events = < - ZMK_MOCK_PRESS(0,0,200) - ZMK_MOCK_PRESS(0,1,200) - /* timer fires */ - ZMK_MOCK_RELEASE(0,1,10) - ZMK_MOCK_RELEASE(0,0,10) - >; -}; \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/4a/events.patterns b/app/tests/hold-tap/balanced/4a/events.patterns deleted file mode 100644 index fdf2b15..0000000 --- a/app/tests/hold-tap/balanced/4a/events.patterns +++ /dev/null @@ -1,4 +0,0 @@ -s/.*hid_listener_keycode/kp/p -s/.*mo_keymap_binding/mo/p -s/.*on_hold_tap_binding/ht_binding/p -s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/4a/keycode_events.snapshot b/app/tests/hold-tap/balanced/4a/keycode_events.snapshot deleted file mode 100644 index b89b21d..0000000 --- a/app/tests/hold-tap/balanced/4a/keycode_events.snapshot +++ /dev/null @@ -1,7 +0,0 @@ -ht_binding_pressed: 0 new undecided hold_tap -ht_decide: 0 decided hold (balanced event 3) -kp_pressed: usage_page 0x07 keycode 0xe1 -kp_pressed: usage_page 0x07 keycode 0x07 -kp_released: usage_page 0x07 keycode 0x07 -kp_released: usage_page 0x07 keycode 0xe1 -ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/balanced/4a/native_posix.keymap b/app/tests/hold-tap/balanced/4a/native_posix.keymap deleted file mode 100644 index ce163f5..0000000 --- a/app/tests/hold-tap/balanced/4a/native_posix.keymap +++ /dev/null @@ -1,14 +0,0 @@ -#include -#include -#include -#include "../behavior_keymap.dtsi" - -&kscan { - events = < - ZMK_MOCK_PRESS(0,0,200) - ZMK_MOCK_PRESS(1,0,200) - /* timer fires */ - ZMK_MOCK_RELEASE(1,0,10) - ZMK_MOCK_RELEASE(0,0,10) - >; -}; \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/4b-dn-kcdn-kcup-timer-up/events.patterns b/app/tests/hold-tap/balanced/4b-dn-kcdn-kcup-timer-up/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/balanced/4b-dn-kcdn-kcup-timer-up/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/4b-dn-kcdn-kcup-timer-up/keycode_events.snapshot b/app/tests/hold-tap/balanced/4b-dn-kcdn-kcup-timer-up/keycode_events.snapshot new file mode 100644 index 0000000..798e2ee --- /dev/null +++ b/app/tests/hold-tap/balanced/4b-dn-kcdn-kcup-timer-up/keycode_events.snapshot @@ -0,0 +1,7 @@ +ht_binding_pressed: 0 new undecided hold_tap +ht_decide: 0 decided hold (balanced event 2) +kp_pressed: usage_page 0x07 keycode 0xe1 +kp_pressed: usage_page 0x07 keycode 0x07 +kp_released: usage_page 0x07 keycode 0x07 +kp_released: usage_page 0x07 keycode 0xe1 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/balanced/4b-dn-kcdn-kcup-timer-up/native_posix.keymap b/app/tests/hold-tap/balanced/4b-dn-kcdn-kcup-timer-up/native_posix.keymap new file mode 100644 index 0000000..7abda41 --- /dev/null +++ b/app/tests/hold-tap/balanced/4b-dn-kcdn-kcup-timer-up/native_posix.keymap @@ -0,0 +1,14 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(0,0,100) + ZMK_MOCK_PRESS(1,0,100) + ZMK_MOCK_RELEASE(1,0,200) + /* timer fires */ + ZMK_MOCK_RELEASE(0,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/4b/events.patterns b/app/tests/hold-tap/balanced/4b/events.patterns deleted file mode 100644 index fdf2b15..0000000 --- a/app/tests/hold-tap/balanced/4b/events.patterns +++ /dev/null @@ -1,4 +0,0 @@ -s/.*hid_listener_keycode/kp/p -s/.*mo_keymap_binding/mo/p -s/.*on_hold_tap_binding/ht_binding/p -s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/4b/keycode_events.snapshot b/app/tests/hold-tap/balanced/4b/keycode_events.snapshot deleted file mode 100644 index 798e2ee..0000000 --- a/app/tests/hold-tap/balanced/4b/keycode_events.snapshot +++ /dev/null @@ -1,7 +0,0 @@ -ht_binding_pressed: 0 new undecided hold_tap -ht_decide: 0 decided hold (balanced event 2) -kp_pressed: usage_page 0x07 keycode 0xe1 -kp_pressed: usage_page 0x07 keycode 0x07 -kp_released: usage_page 0x07 keycode 0x07 -kp_released: usage_page 0x07 keycode 0xe1 -ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/balanced/4b/native_posix.keymap b/app/tests/hold-tap/balanced/4b/native_posix.keymap deleted file mode 100644 index 7abda41..0000000 --- a/app/tests/hold-tap/balanced/4b/native_posix.keymap +++ /dev/null @@ -1,14 +0,0 @@ -#include -#include -#include -#include "../behavior_keymap.dtsi" - -&kscan { - events = < - ZMK_MOCK_PRESS(0,0,100) - ZMK_MOCK_PRESS(1,0,100) - ZMK_MOCK_RELEASE(1,0,200) - /* timer fires */ - ZMK_MOCK_RELEASE(0,0,10) - >; -}; \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/4c-dn-kcdn-kcup-up/events.patterns b/app/tests/hold-tap/balanced/4c-dn-kcdn-kcup-up/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/balanced/4c-dn-kcdn-kcup-up/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/4c-dn-kcdn-kcup-up/keycode_events.snapshot b/app/tests/hold-tap/balanced/4c-dn-kcdn-kcup-up/keycode_events.snapshot new file mode 100644 index 0000000..798e2ee --- /dev/null +++ b/app/tests/hold-tap/balanced/4c-dn-kcdn-kcup-up/keycode_events.snapshot @@ -0,0 +1,7 @@ +ht_binding_pressed: 0 new undecided hold_tap +ht_decide: 0 decided hold (balanced event 2) +kp_pressed: usage_page 0x07 keycode 0xe1 +kp_pressed: usage_page 0x07 keycode 0x07 +kp_released: usage_page 0x07 keycode 0x07 +kp_released: usage_page 0x07 keycode 0xe1 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/balanced/4c-dn-kcdn-kcup-up/native_posix.keymap b/app/tests/hold-tap/balanced/4c-dn-kcdn-kcup-up/native_posix.keymap new file mode 100644 index 0000000..ce030af --- /dev/null +++ b/app/tests/hold-tap/balanced/4c-dn-kcdn-kcup-up/native_posix.keymap @@ -0,0 +1,14 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(0,0,10) + ZMK_MOCK_PRESS(1,0,10) + ZMK_MOCK_RELEASE(1,0,10) + ZMK_MOCK_RELEASE(0,0,10) + /* timer */ + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/4c/events.patterns b/app/tests/hold-tap/balanced/4c/events.patterns deleted file mode 100644 index fdf2b15..0000000 --- a/app/tests/hold-tap/balanced/4c/events.patterns +++ /dev/null @@ -1,4 +0,0 @@ -s/.*hid_listener_keycode/kp/p -s/.*mo_keymap_binding/mo/p -s/.*on_hold_tap_binding/ht_binding/p -s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/4c/keycode_events.snapshot b/app/tests/hold-tap/balanced/4c/keycode_events.snapshot deleted file mode 100644 index 798e2ee..0000000 --- a/app/tests/hold-tap/balanced/4c/keycode_events.snapshot +++ /dev/null @@ -1,7 +0,0 @@ -ht_binding_pressed: 0 new undecided hold_tap -ht_decide: 0 decided hold (balanced event 2) -kp_pressed: usage_page 0x07 keycode 0xe1 -kp_pressed: usage_page 0x07 keycode 0x07 -kp_released: usage_page 0x07 keycode 0x07 -kp_released: usage_page 0x07 keycode 0xe1 -ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/balanced/4c/native_posix.keymap b/app/tests/hold-tap/balanced/4c/native_posix.keymap deleted file mode 100644 index ce030af..0000000 --- a/app/tests/hold-tap/balanced/4c/native_posix.keymap +++ /dev/null @@ -1,14 +0,0 @@ -#include -#include -#include -#include "../behavior_keymap.dtsi" - -&kscan { - events = < - ZMK_MOCK_PRESS(0,0,10) - ZMK_MOCK_PRESS(1,0,10) - ZMK_MOCK_RELEASE(1,0,10) - ZMK_MOCK_RELEASE(0,0,10) - /* timer */ - >; -}; \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/4d-dn-kcdn-timer-up-kcup/events.patterns b/app/tests/hold-tap/balanced/4d-dn-kcdn-timer-up-kcup/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/balanced/4d-dn-kcdn-timer-up-kcup/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/4d-dn-kcdn-timer-up-kcup/keycode_events.snapshot b/app/tests/hold-tap/balanced/4d-dn-kcdn-timer-up-kcup/keycode_events.snapshot new file mode 100644 index 0000000..5c9f4e3 --- /dev/null +++ b/app/tests/hold-tap/balanced/4d-dn-kcdn-timer-up-kcup/keycode_events.snapshot @@ -0,0 +1,7 @@ +ht_binding_pressed: 0 new undecided hold_tap +ht_decide: 0 decided tap (balanced event 0) +kp_pressed: usage_page 0x07 keycode 0x09 +kp_pressed: usage_page 0x07 keycode 0x07 +kp_released: usage_page 0x07 keycode 0x09 +ht_binding_released: 0 cleaning up hold-tap +kp_released: usage_page 0x07 keycode 0x07 diff --git a/app/tests/hold-tap/balanced/4d-dn-kcdn-timer-up-kcup/native_posix.keymap b/app/tests/hold-tap/balanced/4d-dn-kcdn-timer-up-kcup/native_posix.keymap new file mode 100644 index 0000000..5467660 --- /dev/null +++ b/app/tests/hold-tap/balanced/4d-dn-kcdn-timer-up-kcup/native_posix.keymap @@ -0,0 +1,14 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(0,0,100) + ZMK_MOCK_PRESS(1,0,100) + ZMK_MOCK_RELEASE(0,0,200) + /* timer fires */ + ZMK_MOCK_RELEASE(1,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/4d/events.patterns b/app/tests/hold-tap/balanced/4d/events.patterns deleted file mode 100644 index fdf2b15..0000000 --- a/app/tests/hold-tap/balanced/4d/events.patterns +++ /dev/null @@ -1,4 +0,0 @@ -s/.*hid_listener_keycode/kp/p -s/.*mo_keymap_binding/mo/p -s/.*on_hold_tap_binding/ht_binding/p -s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/4d/keycode_events.snapshot b/app/tests/hold-tap/balanced/4d/keycode_events.snapshot deleted file mode 100644 index 5c9f4e3..0000000 --- a/app/tests/hold-tap/balanced/4d/keycode_events.snapshot +++ /dev/null @@ -1,7 +0,0 @@ -ht_binding_pressed: 0 new undecided hold_tap -ht_decide: 0 decided tap (balanced event 0) -kp_pressed: usage_page 0x07 keycode 0x09 -kp_pressed: usage_page 0x07 keycode 0x07 -kp_released: usage_page 0x07 keycode 0x09 -ht_binding_released: 0 cleaning up hold-tap -kp_released: usage_page 0x07 keycode 0x07 diff --git a/app/tests/hold-tap/balanced/4d/native_posix.keymap b/app/tests/hold-tap/balanced/4d/native_posix.keymap deleted file mode 100644 index 5467660..0000000 --- a/app/tests/hold-tap/balanced/4d/native_posix.keymap +++ /dev/null @@ -1,14 +0,0 @@ -#include -#include -#include -#include "../behavior_keymap.dtsi" - -&kscan { - events = < - ZMK_MOCK_PRESS(0,0,100) - ZMK_MOCK_PRESS(1,0,100) - ZMK_MOCK_RELEASE(0,0,200) - /* timer fires */ - ZMK_MOCK_RELEASE(1,0,10) - >; -}; \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/1-dn-up/events.patterns b/app/tests/hold-tap/hold-preferred/1-dn-up/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/1-dn-up/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/1-dn-up/keycode_events.snapshot b/app/tests/hold-tap/hold-preferred/1-dn-up/keycode_events.snapshot new file mode 100644 index 0000000..cf787d8 --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/1-dn-up/keycode_events.snapshot @@ -0,0 +1,5 @@ +ht_binding_pressed: 0 new undecided hold_tap +ht_decide: 0 decided tap (hold-preferred event 0) +kp_pressed: usage_page 0x07 keycode 0x09 +kp_released: usage_page 0x07 keycode 0x09 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/hold-preferred/1-dn-up/native_posix.keymap b/app/tests/hold-tap/hold-preferred/1-dn-up/native_posix.keymap new file mode 100644 index 0000000..10336ef --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/1-dn-up/native_posix.keymap @@ -0,0 +1,11 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(0,0,10) + ZMK_MOCK_RELEASE(0,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/1/events.patterns b/app/tests/hold-tap/hold-preferred/1/events.patterns deleted file mode 100644 index fdf2b15..0000000 --- a/app/tests/hold-tap/hold-preferred/1/events.patterns +++ /dev/null @@ -1,4 +0,0 @@ -s/.*hid_listener_keycode/kp/p -s/.*mo_keymap_binding/mo/p -s/.*on_hold_tap_binding/ht_binding/p -s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/1/keycode_events.snapshot b/app/tests/hold-tap/hold-preferred/1/keycode_events.snapshot deleted file mode 100644 index cf787d8..0000000 --- a/app/tests/hold-tap/hold-preferred/1/keycode_events.snapshot +++ /dev/null @@ -1,5 +0,0 @@ -ht_binding_pressed: 0 new undecided hold_tap -ht_decide: 0 decided tap (hold-preferred event 0) -kp_pressed: usage_page 0x07 keycode 0x09 -kp_released: usage_page 0x07 keycode 0x09 -ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/hold-preferred/1/native_posix.keymap b/app/tests/hold-tap/hold-preferred/1/native_posix.keymap deleted file mode 100644 index 10336ef..0000000 --- a/app/tests/hold-tap/hold-preferred/1/native_posix.keymap +++ /dev/null @@ -1,11 +0,0 @@ -#include -#include -#include -#include "../behavior_keymap.dtsi" - -&kscan { - events = < - ZMK_MOCK_PRESS(0,0,10) - ZMK_MOCK_RELEASE(0,0,10) - >; -}; \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/2-dn-timer-up/events.patterns b/app/tests/hold-tap/hold-preferred/2-dn-timer-up/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/2-dn-timer-up/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/2-dn-timer-up/keycode_events.snapshot b/app/tests/hold-tap/hold-preferred/2-dn-timer-up/keycode_events.snapshot new file mode 100644 index 0000000..03329d5 --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/2-dn-timer-up/keycode_events.snapshot @@ -0,0 +1,5 @@ +ht_binding_pressed: 0 new undecided hold_tap +ht_decide: 0 decided hold (hold-preferred event 3) +kp_pressed: usage_page 0x07 keycode 0xe1 +kp_released: usage_page 0x07 keycode 0xe1 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/hold-preferred/2-dn-timer-up/native_posix.keymap b/app/tests/hold-tap/hold-preferred/2-dn-timer-up/native_posix.keymap new file mode 100644 index 0000000..aa93b86 --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/2-dn-timer-up/native_posix.keymap @@ -0,0 +1,11 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(0,0,500) + ZMK_MOCK_RELEASE(0,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/2/events.patterns b/app/tests/hold-tap/hold-preferred/2/events.patterns deleted file mode 100644 index fdf2b15..0000000 --- a/app/tests/hold-tap/hold-preferred/2/events.patterns +++ /dev/null @@ -1,4 +0,0 @@ -s/.*hid_listener_keycode/kp/p -s/.*mo_keymap_binding/mo/p -s/.*on_hold_tap_binding/ht_binding/p -s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/2/keycode_events.snapshot b/app/tests/hold-tap/hold-preferred/2/keycode_events.snapshot deleted file mode 100644 index 03329d5..0000000 --- a/app/tests/hold-tap/hold-preferred/2/keycode_events.snapshot +++ /dev/null @@ -1,5 +0,0 @@ -ht_binding_pressed: 0 new undecided hold_tap -ht_decide: 0 decided hold (hold-preferred event 3) -kp_pressed: usage_page 0x07 keycode 0xe1 -kp_released: usage_page 0x07 keycode 0xe1 -ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/hold-preferred/2/native_posix.keymap b/app/tests/hold-tap/hold-preferred/2/native_posix.keymap deleted file mode 100644 index aa93b86..0000000 --- a/app/tests/hold-tap/hold-preferred/2/native_posix.keymap +++ /dev/null @@ -1,11 +0,0 @@ -#include -#include -#include -#include "../behavior_keymap.dtsi" - -&kscan { - events = < - ZMK_MOCK_PRESS(0,0,500) - ZMK_MOCK_RELEASE(0,0,10) - >; -}; \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/3a-moddn-dn-modup-up/events.patterns b/app/tests/hold-tap/hold-preferred/3a-moddn-dn-modup-up/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/3a-moddn-dn-modup-up/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/3a-moddn-dn-modup-up/keycode_events.snapshot b/app/tests/hold-tap/hold-preferred/3a-moddn-dn-modup-up/keycode_events.snapshot new file mode 100644 index 0000000..adf4fe2 --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/3a-moddn-dn-modup-up/keycode_events.snapshot @@ -0,0 +1,7 @@ +kp_pressed: usage_page 0x07 keycode 0xe4 +ht_binding_pressed: 0 new undecided hold_tap +ht_decide: 0 decided tap (hold-preferred event 0) +kp_pressed: usage_page 0x07 keycode 0x09 +kp_released: usage_page 0x07 keycode 0xe4 +kp_released: usage_page 0x07 keycode 0x09 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/hold-preferred/3a-moddn-dn-modup-up/native_posix.keymap b/app/tests/hold-tap/hold-preferred/3a-moddn-dn-modup-up/native_posix.keymap new file mode 100644 index 0000000..6f08689 --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/3a-moddn-dn-modup-up/native_posix.keymap @@ -0,0 +1,13 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(1,1,10) /*ctrl*/ + ZMK_MOCK_PRESS(0,0,100) /*mt f-shift */ + ZMK_MOCK_RELEASE(1,1,10) + ZMK_MOCK_RELEASE(0,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/3a/events.patterns b/app/tests/hold-tap/hold-preferred/3a/events.patterns deleted file mode 100644 index fdf2b15..0000000 --- a/app/tests/hold-tap/hold-preferred/3a/events.patterns +++ /dev/null @@ -1,4 +0,0 @@ -s/.*hid_listener_keycode/kp/p -s/.*mo_keymap_binding/mo/p -s/.*on_hold_tap_binding/ht_binding/p -s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/3a/keycode_events.snapshot b/app/tests/hold-tap/hold-preferred/3a/keycode_events.snapshot deleted file mode 100644 index adf4fe2..0000000 --- a/app/tests/hold-tap/hold-preferred/3a/keycode_events.snapshot +++ /dev/null @@ -1,7 +0,0 @@ -kp_pressed: usage_page 0x07 keycode 0xe4 -ht_binding_pressed: 0 new undecided hold_tap -ht_decide: 0 decided tap (hold-preferred event 0) -kp_pressed: usage_page 0x07 keycode 0x09 -kp_released: usage_page 0x07 keycode 0xe4 -kp_released: usage_page 0x07 keycode 0x09 -ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/hold-preferred/3a/native_posix.keymap b/app/tests/hold-tap/hold-preferred/3a/native_posix.keymap deleted file mode 100644 index 6f08689..0000000 --- a/app/tests/hold-tap/hold-preferred/3a/native_posix.keymap +++ /dev/null @@ -1,13 +0,0 @@ -#include -#include -#include -#include "../behavior_keymap.dtsi" - -&kscan { - events = < - ZMK_MOCK_PRESS(1,1,10) /*ctrl*/ - ZMK_MOCK_PRESS(0,0,100) /*mt f-shift */ - ZMK_MOCK_RELEASE(1,1,10) - ZMK_MOCK_RELEASE(0,0,10) - >; -}; \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/3b-moddn-dn-modup-timer-up/events.patterns b/app/tests/hold-tap/hold-preferred/3b-moddn-dn-modup-timer-up/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/3b-moddn-dn-modup-timer-up/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/3b-moddn-dn-modup-timer-up/keycode_events.snapshot b/app/tests/hold-tap/hold-preferred/3b-moddn-dn-modup-timer-up/keycode_events.snapshot new file mode 100644 index 0000000..69b64a9 --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/3b-moddn-dn-modup-timer-up/keycode_events.snapshot @@ -0,0 +1,7 @@ +kp_pressed: usage_page 0x07 keycode 0xe4 +ht_binding_pressed: 0 new undecided hold_tap +ht_decide: 0 decided hold (hold-preferred event 3) +kp_pressed: usage_page 0x07 keycode 0xe1 +kp_released: usage_page 0x07 keycode 0xe4 +kp_released: usage_page 0x07 keycode 0xe1 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/hold-preferred/3b-moddn-dn-modup-timer-up/native_posix.keymap b/app/tests/hold-tap/hold-preferred/3b-moddn-dn-modup-timer-up/native_posix.keymap new file mode 100644 index 0000000..392d328 --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/3b-moddn-dn-modup-timer-up/native_posix.keymap @@ -0,0 +1,14 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(1,1,10) /*ctrl*/ + ZMK_MOCK_PRESS(0,0,50) /*mt f-shift */ + ZMK_MOCK_RELEASE(1,1,300) + /*timer*/ + ZMK_MOCK_RELEASE(0,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/3b/events.patterns b/app/tests/hold-tap/hold-preferred/3b/events.patterns deleted file mode 100644 index fdf2b15..0000000 --- a/app/tests/hold-tap/hold-preferred/3b/events.patterns +++ /dev/null @@ -1,4 +0,0 @@ -s/.*hid_listener_keycode/kp/p -s/.*mo_keymap_binding/mo/p -s/.*on_hold_tap_binding/ht_binding/p -s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/3b/keycode_events.snapshot b/app/tests/hold-tap/hold-preferred/3b/keycode_events.snapshot deleted file mode 100644 index 69b64a9..0000000 --- a/app/tests/hold-tap/hold-preferred/3b/keycode_events.snapshot +++ /dev/null @@ -1,7 +0,0 @@ -kp_pressed: usage_page 0x07 keycode 0xe4 -ht_binding_pressed: 0 new undecided hold_tap -ht_decide: 0 decided hold (hold-preferred event 3) -kp_pressed: usage_page 0x07 keycode 0xe1 -kp_released: usage_page 0x07 keycode 0xe4 -kp_released: usage_page 0x07 keycode 0xe1 -ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/hold-preferred/3b/native_posix.keymap b/app/tests/hold-tap/hold-preferred/3b/native_posix.keymap deleted file mode 100644 index 392d328..0000000 --- a/app/tests/hold-tap/hold-preferred/3b/native_posix.keymap +++ /dev/null @@ -1,14 +0,0 @@ -#include -#include -#include -#include "../behavior_keymap.dtsi" - -&kscan { - events = < - ZMK_MOCK_PRESS(1,1,10) /*ctrl*/ - ZMK_MOCK_PRESS(0,0,50) /*mt f-shift */ - ZMK_MOCK_RELEASE(1,1,300) - /*timer*/ - ZMK_MOCK_RELEASE(0,0,10) - >; -}; \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/3c-kcdn-dn-kcup-up/events.patterns b/app/tests/hold-tap/hold-preferred/3c-kcdn-dn-kcup-up/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/3c-kcdn-dn-kcup-up/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/3c-kcdn-dn-kcup-up/keycode_events.snapshot b/app/tests/hold-tap/hold-preferred/3c-kcdn-dn-kcup-up/keycode_events.snapshot new file mode 100644 index 0000000..b06a1d7 --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/3c-kcdn-dn-kcup-up/keycode_events.snapshot @@ -0,0 +1,7 @@ +kp_pressed: usage_page 0x07 keycode 0x07 +ht_binding_pressed: 0 new undecided hold_tap +kp_released: usage_page 0x07 keycode 0x07 +ht_decide: 0 decided tap (hold-preferred event 0) +kp_pressed: usage_page 0x07 keycode 0x09 +kp_released: usage_page 0x07 keycode 0x09 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/hold-preferred/3c-kcdn-dn-kcup-up/native_posix.keymap b/app/tests/hold-tap/hold-preferred/3c-kcdn-dn-kcup-up/native_posix.keymap new file mode 100644 index 0000000..77306cd --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/3c-kcdn-dn-kcup-up/native_posix.keymap @@ -0,0 +1,13 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(1,0,10) /*d*/ + ZMK_MOCK_PRESS(0,0,100) /*mt f-shift */ + ZMK_MOCK_RELEASE(1,0,10) + ZMK_MOCK_RELEASE(0,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/3c/events.patterns b/app/tests/hold-tap/hold-preferred/3c/events.patterns deleted file mode 100644 index fdf2b15..0000000 --- a/app/tests/hold-tap/hold-preferred/3c/events.patterns +++ /dev/null @@ -1,4 +0,0 @@ -s/.*hid_listener_keycode/kp/p -s/.*mo_keymap_binding/mo/p -s/.*on_hold_tap_binding/ht_binding/p -s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/3c/keycode_events.snapshot b/app/tests/hold-tap/hold-preferred/3c/keycode_events.snapshot deleted file mode 100644 index b06a1d7..0000000 --- a/app/tests/hold-tap/hold-preferred/3c/keycode_events.snapshot +++ /dev/null @@ -1,7 +0,0 @@ -kp_pressed: usage_page 0x07 keycode 0x07 -ht_binding_pressed: 0 new undecided hold_tap -kp_released: usage_page 0x07 keycode 0x07 -ht_decide: 0 decided tap (hold-preferred event 0) -kp_pressed: usage_page 0x07 keycode 0x09 -kp_released: usage_page 0x07 keycode 0x09 -ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/hold-preferred/3c/native_posix.keymap b/app/tests/hold-tap/hold-preferred/3c/native_posix.keymap deleted file mode 100644 index 77306cd..0000000 --- a/app/tests/hold-tap/hold-preferred/3c/native_posix.keymap +++ /dev/null @@ -1,13 +0,0 @@ -#include -#include -#include -#include "../behavior_keymap.dtsi" - -&kscan { - events = < - ZMK_MOCK_PRESS(1,0,10) /*d*/ - ZMK_MOCK_PRESS(0,0,100) /*mt f-shift */ - ZMK_MOCK_RELEASE(1,0,10) - ZMK_MOCK_RELEASE(0,0,10) - >; -}; \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/3d-kcdn-dn-kcup-timer-up/events.patterns b/app/tests/hold-tap/hold-preferred/3d-kcdn-dn-kcup-timer-up/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/3d-kcdn-dn-kcup-timer-up/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/3d-kcdn-dn-kcup-timer-up/keycode_events.snapshot b/app/tests/hold-tap/hold-preferred/3d-kcdn-dn-kcup-timer-up/keycode_events.snapshot new file mode 100644 index 0000000..bf31955 --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/3d-kcdn-dn-kcup-timer-up/keycode_events.snapshot @@ -0,0 +1,7 @@ +kp_pressed: usage_page 0x07 keycode 0x07 +ht_binding_pressed: 0 new undecided hold_tap +kp_released: usage_page 0x07 keycode 0x07 +ht_decide: 0 decided hold (hold-preferred event 3) +kp_pressed: usage_page 0x07 keycode 0xe1 +kp_released: usage_page 0x07 keycode 0xe1 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/hold-preferred/3d-kcdn-dn-kcup-timer-up/native_posix.keymap b/app/tests/hold-tap/hold-preferred/3d-kcdn-dn-kcup-timer-up/native_posix.keymap new file mode 100644 index 0000000..1441331 --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/3d-kcdn-dn-kcup-timer-up/native_posix.keymap @@ -0,0 +1,13 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(1,0,10) /* d */ + ZMK_MOCK_PRESS(0,0,100) /* mt f-shift */ + ZMK_MOCK_RELEASE(1,0,400) + ZMK_MOCK_RELEASE(0,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/3d/events.patterns b/app/tests/hold-tap/hold-preferred/3d/events.patterns deleted file mode 100644 index fdf2b15..0000000 --- a/app/tests/hold-tap/hold-preferred/3d/events.patterns +++ /dev/null @@ -1,4 +0,0 @@ -s/.*hid_listener_keycode/kp/p -s/.*mo_keymap_binding/mo/p -s/.*on_hold_tap_binding/ht_binding/p -s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/3d/keycode_events.snapshot b/app/tests/hold-tap/hold-preferred/3d/keycode_events.snapshot deleted file mode 100644 index bf31955..0000000 --- a/app/tests/hold-tap/hold-preferred/3d/keycode_events.snapshot +++ /dev/null @@ -1,7 +0,0 @@ -kp_pressed: usage_page 0x07 keycode 0x07 -ht_binding_pressed: 0 new undecided hold_tap -kp_released: usage_page 0x07 keycode 0x07 -ht_decide: 0 decided hold (hold-preferred event 3) -kp_pressed: usage_page 0x07 keycode 0xe1 -kp_released: usage_page 0x07 keycode 0xe1 -ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/hold-preferred/3d/native_posix.keymap b/app/tests/hold-tap/hold-preferred/3d/native_posix.keymap deleted file mode 100644 index 1441331..0000000 --- a/app/tests/hold-tap/hold-preferred/3d/native_posix.keymap +++ /dev/null @@ -1,13 +0,0 @@ -#include -#include -#include -#include "../behavior_keymap.dtsi" - -&kscan { - events = < - ZMK_MOCK_PRESS(1,0,10) /* d */ - ZMK_MOCK_PRESS(0,0,100) /* mt f-shift */ - ZMK_MOCK_RELEASE(1,0,400) - ZMK_MOCK_RELEASE(0,0,10) - >; -}; \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/4a-dn-htdn-timer-htup-up/events.patterns b/app/tests/hold-tap/hold-preferred/4a-dn-htdn-timer-htup-up/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/4a-dn-htdn-timer-htup-up/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/4a-dn-htdn-timer-htup-up/keycode_events.snapshot b/app/tests/hold-tap/hold-preferred/4a-dn-htdn-timer-htup-up/keycode_events.snapshot new file mode 100644 index 0000000..3ed7de0 --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/4a-dn-htdn-timer-htup-up/keycode_events.snapshot @@ -0,0 +1,10 @@ +ht_binding_pressed: 0 new undecided hold_tap +ht_decide: 0 decided hold (hold-preferred event 1) +kp_pressed: usage_page 0x07 keycode 0xe1 +ht_binding_pressed: 1 new undecided hold_tap +ht_decide: 1 decided tap (hold-preferred event 0) +kp_pressed: usage_page 0x07 keycode 0x0d +kp_released: usage_page 0x07 keycode 0x0d +ht_binding_released: 1 cleaning up hold-tap +kp_released: usage_page 0x07 keycode 0xe1 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/hold-preferred/4a-dn-htdn-timer-htup-up/native_posix.keymap b/app/tests/hold-tap/hold-preferred/4a-dn-htdn-timer-htup-up/native_posix.keymap new file mode 100644 index 0000000..c10c6d6 --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/4a-dn-htdn-timer-htup-up/native_posix.keymap @@ -0,0 +1,14 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(0,0,200) + ZMK_MOCK_PRESS(0,1,200) + /* timer fires */ + ZMK_MOCK_RELEASE(0,1,10) + ZMK_MOCK_RELEASE(0,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/4a-dn-kcdn-timer-kcup-up/events.patterns b/app/tests/hold-tap/hold-preferred/4a-dn-kcdn-timer-kcup-up/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/4a-dn-kcdn-timer-kcup-up/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/4a-dn-kcdn-timer-kcup-up/keycode_events.snapshot b/app/tests/hold-tap/hold-preferred/4a-dn-kcdn-timer-kcup-up/keycode_events.snapshot new file mode 100644 index 0000000..e0b57fd --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/4a-dn-kcdn-timer-kcup-up/keycode_events.snapshot @@ -0,0 +1,7 @@ +ht_binding_pressed: 0 new undecided hold_tap +ht_decide: 0 decided hold (hold-preferred event 1) +kp_pressed: usage_page 0x07 keycode 0xe1 +kp_pressed: usage_page 0x07 keycode 0x07 +kp_released: usage_page 0x07 keycode 0x07 +kp_released: usage_page 0x07 keycode 0xe1 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/hold-preferred/4a-dn-kcdn-timer-kcup-up/native_posix.keymap b/app/tests/hold-tap/hold-preferred/4a-dn-kcdn-timer-kcup-up/native_posix.keymap new file mode 100644 index 0000000..ce163f5 --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/4a-dn-kcdn-timer-kcup-up/native_posix.keymap @@ -0,0 +1,14 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(0,0,200) + ZMK_MOCK_PRESS(1,0,200) + /* timer fires */ + ZMK_MOCK_RELEASE(1,0,10) + ZMK_MOCK_RELEASE(0,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/4a-nested/events.patterns b/app/tests/hold-tap/hold-preferred/4a-nested/events.patterns deleted file mode 100644 index fdf2b15..0000000 --- a/app/tests/hold-tap/hold-preferred/4a-nested/events.patterns +++ /dev/null @@ -1,4 +0,0 @@ -s/.*hid_listener_keycode/kp/p -s/.*mo_keymap_binding/mo/p -s/.*on_hold_tap_binding/ht_binding/p -s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/4a-nested/keycode_events.snapshot b/app/tests/hold-tap/hold-preferred/4a-nested/keycode_events.snapshot deleted file mode 100644 index 3ed7de0..0000000 --- a/app/tests/hold-tap/hold-preferred/4a-nested/keycode_events.snapshot +++ /dev/null @@ -1,10 +0,0 @@ -ht_binding_pressed: 0 new undecided hold_tap -ht_decide: 0 decided hold (hold-preferred event 1) -kp_pressed: usage_page 0x07 keycode 0xe1 -ht_binding_pressed: 1 new undecided hold_tap -ht_decide: 1 decided tap (hold-preferred event 0) -kp_pressed: usage_page 0x07 keycode 0x0d -kp_released: usage_page 0x07 keycode 0x0d -ht_binding_released: 1 cleaning up hold-tap -kp_released: usage_page 0x07 keycode 0xe1 -ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/hold-preferred/4a-nested/native_posix.keymap b/app/tests/hold-tap/hold-preferred/4a-nested/native_posix.keymap deleted file mode 100644 index c10c6d6..0000000 --- a/app/tests/hold-tap/hold-preferred/4a-nested/native_posix.keymap +++ /dev/null @@ -1,14 +0,0 @@ -#include -#include -#include -#include "../behavior_keymap.dtsi" - -&kscan { - events = < - ZMK_MOCK_PRESS(0,0,200) - ZMK_MOCK_PRESS(0,1,200) - /* timer fires */ - ZMK_MOCK_RELEASE(0,1,10) - ZMK_MOCK_RELEASE(0,0,10) - >; -}; \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/4a/events.patterns b/app/tests/hold-tap/hold-preferred/4a/events.patterns deleted file mode 100644 index fdf2b15..0000000 --- a/app/tests/hold-tap/hold-preferred/4a/events.patterns +++ /dev/null @@ -1,4 +0,0 @@ -s/.*hid_listener_keycode/kp/p -s/.*mo_keymap_binding/mo/p -s/.*on_hold_tap_binding/ht_binding/p -s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/4a/keycode_events.snapshot b/app/tests/hold-tap/hold-preferred/4a/keycode_events.snapshot deleted file mode 100644 index e0b57fd..0000000 --- a/app/tests/hold-tap/hold-preferred/4a/keycode_events.snapshot +++ /dev/null @@ -1,7 +0,0 @@ -ht_binding_pressed: 0 new undecided hold_tap -ht_decide: 0 decided hold (hold-preferred event 1) -kp_pressed: usage_page 0x07 keycode 0xe1 -kp_pressed: usage_page 0x07 keycode 0x07 -kp_released: usage_page 0x07 keycode 0x07 -kp_released: usage_page 0x07 keycode 0xe1 -ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/hold-preferred/4a/native_posix.keymap b/app/tests/hold-tap/hold-preferred/4a/native_posix.keymap deleted file mode 100644 index ce163f5..0000000 --- a/app/tests/hold-tap/hold-preferred/4a/native_posix.keymap +++ /dev/null @@ -1,14 +0,0 @@ -#include -#include -#include -#include "../behavior_keymap.dtsi" - -&kscan { - events = < - ZMK_MOCK_PRESS(0,0,200) - ZMK_MOCK_PRESS(1,0,200) - /* timer fires */ - ZMK_MOCK_RELEASE(1,0,10) - ZMK_MOCK_RELEASE(0,0,10) - >; -}; \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/4b-dn-kcdn-kcup-timer-up/events.patterns b/app/tests/hold-tap/hold-preferred/4b-dn-kcdn-kcup-timer-up/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/4b-dn-kcdn-kcup-timer-up/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/4b-dn-kcdn-kcup-timer-up/keycode_events.snapshot b/app/tests/hold-tap/hold-preferred/4b-dn-kcdn-kcup-timer-up/keycode_events.snapshot new file mode 100644 index 0000000..e0b57fd --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/4b-dn-kcdn-kcup-timer-up/keycode_events.snapshot @@ -0,0 +1,7 @@ +ht_binding_pressed: 0 new undecided hold_tap +ht_decide: 0 decided hold (hold-preferred event 1) +kp_pressed: usage_page 0x07 keycode 0xe1 +kp_pressed: usage_page 0x07 keycode 0x07 +kp_released: usage_page 0x07 keycode 0x07 +kp_released: usage_page 0x07 keycode 0xe1 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/hold-preferred/4b-dn-kcdn-kcup-timer-up/native_posix.keymap b/app/tests/hold-tap/hold-preferred/4b-dn-kcdn-kcup-timer-up/native_posix.keymap new file mode 100644 index 0000000..7abda41 --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/4b-dn-kcdn-kcup-timer-up/native_posix.keymap @@ -0,0 +1,14 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(0,0,100) + ZMK_MOCK_PRESS(1,0,100) + ZMK_MOCK_RELEASE(1,0,200) + /* timer fires */ + ZMK_MOCK_RELEASE(0,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/4b/events.patterns b/app/tests/hold-tap/hold-preferred/4b/events.patterns deleted file mode 100644 index fdf2b15..0000000 --- a/app/tests/hold-tap/hold-preferred/4b/events.patterns +++ /dev/null @@ -1,4 +0,0 @@ -s/.*hid_listener_keycode/kp/p -s/.*mo_keymap_binding/mo/p -s/.*on_hold_tap_binding/ht_binding/p -s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/4b/keycode_events.snapshot b/app/tests/hold-tap/hold-preferred/4b/keycode_events.snapshot deleted file mode 100644 index e0b57fd..0000000 --- a/app/tests/hold-tap/hold-preferred/4b/keycode_events.snapshot +++ /dev/null @@ -1,7 +0,0 @@ -ht_binding_pressed: 0 new undecided hold_tap -ht_decide: 0 decided hold (hold-preferred event 1) -kp_pressed: usage_page 0x07 keycode 0xe1 -kp_pressed: usage_page 0x07 keycode 0x07 -kp_released: usage_page 0x07 keycode 0x07 -kp_released: usage_page 0x07 keycode 0xe1 -ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/hold-preferred/4b/native_posix.keymap b/app/tests/hold-tap/hold-preferred/4b/native_posix.keymap deleted file mode 100644 index 7abda41..0000000 --- a/app/tests/hold-tap/hold-preferred/4b/native_posix.keymap +++ /dev/null @@ -1,14 +0,0 @@ -#include -#include -#include -#include "../behavior_keymap.dtsi" - -&kscan { - events = < - ZMK_MOCK_PRESS(0,0,100) - ZMK_MOCK_PRESS(1,0,100) - ZMK_MOCK_RELEASE(1,0,200) - /* timer fires */ - ZMK_MOCK_RELEASE(0,0,10) - >; -}; \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/4c-dn-kcdn-kcup-up/events.patterns b/app/tests/hold-tap/hold-preferred/4c-dn-kcdn-kcup-up/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/4c-dn-kcdn-kcup-up/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/4c-dn-kcdn-kcup-up/keycode_events.snapshot b/app/tests/hold-tap/hold-preferred/4c-dn-kcdn-kcup-up/keycode_events.snapshot new file mode 100644 index 0000000..e0b57fd --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/4c-dn-kcdn-kcup-up/keycode_events.snapshot @@ -0,0 +1,7 @@ +ht_binding_pressed: 0 new undecided hold_tap +ht_decide: 0 decided hold (hold-preferred event 1) +kp_pressed: usage_page 0x07 keycode 0xe1 +kp_pressed: usage_page 0x07 keycode 0x07 +kp_released: usage_page 0x07 keycode 0x07 +kp_released: usage_page 0x07 keycode 0xe1 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/hold-preferred/4c-dn-kcdn-kcup-up/native_posix.keymap b/app/tests/hold-tap/hold-preferred/4c-dn-kcdn-kcup-up/native_posix.keymap new file mode 100644 index 0000000..ce030af --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/4c-dn-kcdn-kcup-up/native_posix.keymap @@ -0,0 +1,14 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(0,0,10) + ZMK_MOCK_PRESS(1,0,10) + ZMK_MOCK_RELEASE(1,0,10) + ZMK_MOCK_RELEASE(0,0,10) + /* timer */ + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/4c/events.patterns b/app/tests/hold-tap/hold-preferred/4c/events.patterns deleted file mode 100644 index fdf2b15..0000000 --- a/app/tests/hold-tap/hold-preferred/4c/events.patterns +++ /dev/null @@ -1,4 +0,0 @@ -s/.*hid_listener_keycode/kp/p -s/.*mo_keymap_binding/mo/p -s/.*on_hold_tap_binding/ht_binding/p -s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/4c/keycode_events.snapshot b/app/tests/hold-tap/hold-preferred/4c/keycode_events.snapshot deleted file mode 100644 index e0b57fd..0000000 --- a/app/tests/hold-tap/hold-preferred/4c/keycode_events.snapshot +++ /dev/null @@ -1,7 +0,0 @@ -ht_binding_pressed: 0 new undecided hold_tap -ht_decide: 0 decided hold (hold-preferred event 1) -kp_pressed: usage_page 0x07 keycode 0xe1 -kp_pressed: usage_page 0x07 keycode 0x07 -kp_released: usage_page 0x07 keycode 0x07 -kp_released: usage_page 0x07 keycode 0xe1 -ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/hold-preferred/4c/native_posix.keymap b/app/tests/hold-tap/hold-preferred/4c/native_posix.keymap deleted file mode 100644 index ce030af..0000000 --- a/app/tests/hold-tap/hold-preferred/4c/native_posix.keymap +++ /dev/null @@ -1,14 +0,0 @@ -#include -#include -#include -#include "../behavior_keymap.dtsi" - -&kscan { - events = < - ZMK_MOCK_PRESS(0,0,10) - ZMK_MOCK_PRESS(1,0,10) - ZMK_MOCK_RELEASE(1,0,10) - ZMK_MOCK_RELEASE(0,0,10) - /* timer */ - >; -}; \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/4d-dn-kcdn-timer-up-kcup/events.patterns b/app/tests/hold-tap/hold-preferred/4d-dn-kcdn-timer-up-kcup/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/4d-dn-kcdn-timer-up-kcup/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/4d-dn-kcdn-timer-up-kcup/keycode_events.snapshot b/app/tests/hold-tap/hold-preferred/4d-dn-kcdn-timer-up-kcup/keycode_events.snapshot new file mode 100644 index 0000000..cac579d --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/4d-dn-kcdn-timer-up-kcup/keycode_events.snapshot @@ -0,0 +1,7 @@ +ht_binding_pressed: 0 new undecided hold_tap +ht_decide: 0 decided hold (hold-preferred event 1) +kp_pressed: usage_page 0x07 keycode 0xe1 +kp_pressed: usage_page 0x07 keycode 0x07 +kp_released: usage_page 0x07 keycode 0xe1 +ht_binding_released: 0 cleaning up hold-tap +kp_released: usage_page 0x07 keycode 0x07 diff --git a/app/tests/hold-tap/hold-preferred/4d-dn-kcdn-timer-up-kcup/native_posix.keymap b/app/tests/hold-tap/hold-preferred/4d-dn-kcdn-timer-up-kcup/native_posix.keymap new file mode 100644 index 0000000..5467660 --- /dev/null +++ b/app/tests/hold-tap/hold-preferred/4d-dn-kcdn-timer-up-kcup/native_posix.keymap @@ -0,0 +1,14 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(0,0,100) + ZMK_MOCK_PRESS(1,0,100) + ZMK_MOCK_RELEASE(0,0,200) + /* timer fires */ + ZMK_MOCK_RELEASE(1,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/4d/events.patterns b/app/tests/hold-tap/hold-preferred/4d/events.patterns deleted file mode 100644 index fdf2b15..0000000 --- a/app/tests/hold-tap/hold-preferred/4d/events.patterns +++ /dev/null @@ -1,4 +0,0 @@ -s/.*hid_listener_keycode/kp/p -s/.*mo_keymap_binding/mo/p -s/.*on_hold_tap_binding/ht_binding/p -s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/hold-preferred/4d/keycode_events.snapshot b/app/tests/hold-tap/hold-preferred/4d/keycode_events.snapshot deleted file mode 100644 index cac579d..0000000 --- a/app/tests/hold-tap/hold-preferred/4d/keycode_events.snapshot +++ /dev/null @@ -1,7 +0,0 @@ -ht_binding_pressed: 0 new undecided hold_tap -ht_decide: 0 decided hold (hold-preferred event 1) -kp_pressed: usage_page 0x07 keycode 0xe1 -kp_pressed: usage_page 0x07 keycode 0x07 -kp_released: usage_page 0x07 keycode 0xe1 -ht_binding_released: 0 cleaning up hold-tap -kp_released: usage_page 0x07 keycode 0x07 diff --git a/app/tests/hold-tap/hold-preferred/4d/native_posix.keymap b/app/tests/hold-tap/hold-preferred/4d/native_posix.keymap deleted file mode 100644 index 5467660..0000000 --- a/app/tests/hold-tap/hold-preferred/4d/native_posix.keymap +++ /dev/null @@ -1,14 +0,0 @@ -#include -#include -#include -#include "../behavior_keymap.dtsi" - -&kscan { - events = < - ZMK_MOCK_PRESS(0,0,100) - ZMK_MOCK_PRESS(1,0,100) - ZMK_MOCK_RELEASE(0,0,200) - /* timer fires */ - ZMK_MOCK_RELEASE(1,0,10) - >; -}; \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/1-dn-up/events.patterns b/app/tests/hold-tap/tap-preferred/1-dn-up/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/1-dn-up/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/1-dn-up/keycode_events.snapshot b/app/tests/hold-tap/tap-preferred/1-dn-up/keycode_events.snapshot new file mode 100644 index 0000000..2a250fb --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/1-dn-up/keycode_events.snapshot @@ -0,0 +1,5 @@ +ht_binding_pressed: 0 new undecided hold_tap +ht_decide: 0 decided tap (tap-preferred event 0) +kp_pressed: usage_page 0x07 keycode 0x09 +kp_released: usage_page 0x07 keycode 0x09 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/tap-preferred/1-dn-up/native_posix.keymap b/app/tests/hold-tap/tap-preferred/1-dn-up/native_posix.keymap new file mode 100644 index 0000000..10336ef --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/1-dn-up/native_posix.keymap @@ -0,0 +1,11 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(0,0,10) + ZMK_MOCK_RELEASE(0,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/1/events.patterns b/app/tests/hold-tap/tap-preferred/1/events.patterns deleted file mode 100644 index fdf2b15..0000000 --- a/app/tests/hold-tap/tap-preferred/1/events.patterns +++ /dev/null @@ -1,4 +0,0 @@ -s/.*hid_listener_keycode/kp/p -s/.*mo_keymap_binding/mo/p -s/.*on_hold_tap_binding/ht_binding/p -s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/1/keycode_events.snapshot b/app/tests/hold-tap/tap-preferred/1/keycode_events.snapshot deleted file mode 100644 index 2a250fb..0000000 --- a/app/tests/hold-tap/tap-preferred/1/keycode_events.snapshot +++ /dev/null @@ -1,5 +0,0 @@ -ht_binding_pressed: 0 new undecided hold_tap -ht_decide: 0 decided tap (tap-preferred event 0) -kp_pressed: usage_page 0x07 keycode 0x09 -kp_released: usage_page 0x07 keycode 0x09 -ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/tap-preferred/1/native_posix.keymap b/app/tests/hold-tap/tap-preferred/1/native_posix.keymap deleted file mode 100644 index 10336ef..0000000 --- a/app/tests/hold-tap/tap-preferred/1/native_posix.keymap +++ /dev/null @@ -1,11 +0,0 @@ -#include -#include -#include -#include "../behavior_keymap.dtsi" - -&kscan { - events = < - ZMK_MOCK_PRESS(0,0,10) - ZMK_MOCK_RELEASE(0,0,10) - >; -}; \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/2-dn-timer-up/events.patterns b/app/tests/hold-tap/tap-preferred/2-dn-timer-up/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/2-dn-timer-up/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/2-dn-timer-up/keycode_events.snapshot b/app/tests/hold-tap/tap-preferred/2-dn-timer-up/keycode_events.snapshot new file mode 100644 index 0000000..4f1ee63 --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/2-dn-timer-up/keycode_events.snapshot @@ -0,0 +1,5 @@ +ht_binding_pressed: 0 new undecided hold_tap +ht_decide: 0 decided hold (tap-preferred event 3) +kp_pressed: usage_page 0x07 keycode 0xe1 +kp_released: usage_page 0x07 keycode 0xe1 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/tap-preferred/2-dn-timer-up/native_posix.keymap b/app/tests/hold-tap/tap-preferred/2-dn-timer-up/native_posix.keymap new file mode 100644 index 0000000..aa93b86 --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/2-dn-timer-up/native_posix.keymap @@ -0,0 +1,11 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(0,0,500) + ZMK_MOCK_RELEASE(0,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/2/events.patterns b/app/tests/hold-tap/tap-preferred/2/events.patterns deleted file mode 100644 index fdf2b15..0000000 --- a/app/tests/hold-tap/tap-preferred/2/events.patterns +++ /dev/null @@ -1,4 +0,0 @@ -s/.*hid_listener_keycode/kp/p -s/.*mo_keymap_binding/mo/p -s/.*on_hold_tap_binding/ht_binding/p -s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/2/keycode_events.snapshot b/app/tests/hold-tap/tap-preferred/2/keycode_events.snapshot deleted file mode 100644 index 4f1ee63..0000000 --- a/app/tests/hold-tap/tap-preferred/2/keycode_events.snapshot +++ /dev/null @@ -1,5 +0,0 @@ -ht_binding_pressed: 0 new undecided hold_tap -ht_decide: 0 decided hold (tap-preferred event 3) -kp_pressed: usage_page 0x07 keycode 0xe1 -kp_released: usage_page 0x07 keycode 0xe1 -ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/tap-preferred/2/native_posix.keymap b/app/tests/hold-tap/tap-preferred/2/native_posix.keymap deleted file mode 100644 index aa93b86..0000000 --- a/app/tests/hold-tap/tap-preferred/2/native_posix.keymap +++ /dev/null @@ -1,11 +0,0 @@ -#include -#include -#include -#include "../behavior_keymap.dtsi" - -&kscan { - events = < - ZMK_MOCK_PRESS(0,0,500) - ZMK_MOCK_RELEASE(0,0,10) - >; -}; \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/3a-moddn-dn-modup-up/events.patterns b/app/tests/hold-tap/tap-preferred/3a-moddn-dn-modup-up/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/3a-moddn-dn-modup-up/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/3a-moddn-dn-modup-up/keycode_events.snapshot b/app/tests/hold-tap/tap-preferred/3a-moddn-dn-modup-up/keycode_events.snapshot new file mode 100644 index 0000000..87d1406 --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/3a-moddn-dn-modup-up/keycode_events.snapshot @@ -0,0 +1,7 @@ +kp_pressed: usage_page 0x07 keycode 0xe4 +ht_binding_pressed: 0 new undecided hold_tap +ht_decide: 0 decided tap (tap-preferred event 0) +kp_pressed: usage_page 0x07 keycode 0x09 +kp_released: usage_page 0x07 keycode 0xe4 +kp_released: usage_page 0x07 keycode 0x09 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/tap-preferred/3a-moddn-dn-modup-up/native_posix.keymap b/app/tests/hold-tap/tap-preferred/3a-moddn-dn-modup-up/native_posix.keymap new file mode 100644 index 0000000..6f08689 --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/3a-moddn-dn-modup-up/native_posix.keymap @@ -0,0 +1,13 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(1,1,10) /*ctrl*/ + ZMK_MOCK_PRESS(0,0,100) /*mt f-shift */ + ZMK_MOCK_RELEASE(1,1,10) + ZMK_MOCK_RELEASE(0,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/3a/events.patterns b/app/tests/hold-tap/tap-preferred/3a/events.patterns deleted file mode 100644 index fdf2b15..0000000 --- a/app/tests/hold-tap/tap-preferred/3a/events.patterns +++ /dev/null @@ -1,4 +0,0 @@ -s/.*hid_listener_keycode/kp/p -s/.*mo_keymap_binding/mo/p -s/.*on_hold_tap_binding/ht_binding/p -s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/3a/keycode_events.snapshot b/app/tests/hold-tap/tap-preferred/3a/keycode_events.snapshot deleted file mode 100644 index 87d1406..0000000 --- a/app/tests/hold-tap/tap-preferred/3a/keycode_events.snapshot +++ /dev/null @@ -1,7 +0,0 @@ -kp_pressed: usage_page 0x07 keycode 0xe4 -ht_binding_pressed: 0 new undecided hold_tap -ht_decide: 0 decided tap (tap-preferred event 0) -kp_pressed: usage_page 0x07 keycode 0x09 -kp_released: usage_page 0x07 keycode 0xe4 -kp_released: usage_page 0x07 keycode 0x09 -ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/tap-preferred/3a/native_posix.keymap b/app/tests/hold-tap/tap-preferred/3a/native_posix.keymap deleted file mode 100644 index 6f08689..0000000 --- a/app/tests/hold-tap/tap-preferred/3a/native_posix.keymap +++ /dev/null @@ -1,13 +0,0 @@ -#include -#include -#include -#include "../behavior_keymap.dtsi" - -&kscan { - events = < - ZMK_MOCK_PRESS(1,1,10) /*ctrl*/ - ZMK_MOCK_PRESS(0,0,100) /*mt f-shift */ - ZMK_MOCK_RELEASE(1,1,10) - ZMK_MOCK_RELEASE(0,0,10) - >; -}; \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/3b-moddn-dn-modup-timer-up/events.patterns b/app/tests/hold-tap/tap-preferred/3b-moddn-dn-modup-timer-up/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/3b-moddn-dn-modup-timer-up/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/3b-moddn-dn-modup-timer-up/keycode_events.snapshot b/app/tests/hold-tap/tap-preferred/3b-moddn-dn-modup-timer-up/keycode_events.snapshot new file mode 100644 index 0000000..7455d2a --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/3b-moddn-dn-modup-timer-up/keycode_events.snapshot @@ -0,0 +1,7 @@ +kp_pressed: usage_page 0x07 keycode 0xe4 +ht_binding_pressed: 0 new undecided hold_tap +ht_decide: 0 decided hold (tap-preferred event 3) +kp_pressed: usage_page 0x07 keycode 0xe1 +kp_released: usage_page 0x07 keycode 0xe4 +kp_released: usage_page 0x07 keycode 0xe1 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/tap-preferred/3b-moddn-dn-modup-timer-up/native_posix.keymap b/app/tests/hold-tap/tap-preferred/3b-moddn-dn-modup-timer-up/native_posix.keymap new file mode 100644 index 0000000..392d328 --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/3b-moddn-dn-modup-timer-up/native_posix.keymap @@ -0,0 +1,14 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(1,1,10) /*ctrl*/ + ZMK_MOCK_PRESS(0,0,50) /*mt f-shift */ + ZMK_MOCK_RELEASE(1,1,300) + /*timer*/ + ZMK_MOCK_RELEASE(0,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/3b/events.patterns b/app/tests/hold-tap/tap-preferred/3b/events.patterns deleted file mode 100644 index fdf2b15..0000000 --- a/app/tests/hold-tap/tap-preferred/3b/events.patterns +++ /dev/null @@ -1,4 +0,0 @@ -s/.*hid_listener_keycode/kp/p -s/.*mo_keymap_binding/mo/p -s/.*on_hold_tap_binding/ht_binding/p -s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/3b/keycode_events.snapshot b/app/tests/hold-tap/tap-preferred/3b/keycode_events.snapshot deleted file mode 100644 index 7455d2a..0000000 --- a/app/tests/hold-tap/tap-preferred/3b/keycode_events.snapshot +++ /dev/null @@ -1,7 +0,0 @@ -kp_pressed: usage_page 0x07 keycode 0xe4 -ht_binding_pressed: 0 new undecided hold_tap -ht_decide: 0 decided hold (tap-preferred event 3) -kp_pressed: usage_page 0x07 keycode 0xe1 -kp_released: usage_page 0x07 keycode 0xe4 -kp_released: usage_page 0x07 keycode 0xe1 -ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/tap-preferred/3b/native_posix.keymap b/app/tests/hold-tap/tap-preferred/3b/native_posix.keymap deleted file mode 100644 index 392d328..0000000 --- a/app/tests/hold-tap/tap-preferred/3b/native_posix.keymap +++ /dev/null @@ -1,14 +0,0 @@ -#include -#include -#include -#include "../behavior_keymap.dtsi" - -&kscan { - events = < - ZMK_MOCK_PRESS(1,1,10) /*ctrl*/ - ZMK_MOCK_PRESS(0,0,50) /*mt f-shift */ - ZMK_MOCK_RELEASE(1,1,300) - /*timer*/ - ZMK_MOCK_RELEASE(0,0,10) - >; -}; \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/3c-kcdn-dn-kcup-up/events.patterns b/app/tests/hold-tap/tap-preferred/3c-kcdn-dn-kcup-up/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/3c-kcdn-dn-kcup-up/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/3c-kcdn-dn-kcup-up/keycode_events.snapshot b/app/tests/hold-tap/tap-preferred/3c-kcdn-dn-kcup-up/keycode_events.snapshot new file mode 100644 index 0000000..3d7eaf1 --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/3c-kcdn-dn-kcup-up/keycode_events.snapshot @@ -0,0 +1,7 @@ +kp_pressed: usage_page 0x07 keycode 0x07 +ht_binding_pressed: 0 new undecided hold_tap +kp_released: usage_page 0x07 keycode 0x07 +ht_decide: 0 decided tap (tap-preferred event 0) +kp_pressed: usage_page 0x07 keycode 0x09 +kp_released: usage_page 0x07 keycode 0x09 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/tap-preferred/3c-kcdn-dn-kcup-up/native_posix.keymap b/app/tests/hold-tap/tap-preferred/3c-kcdn-dn-kcup-up/native_posix.keymap new file mode 100644 index 0000000..77306cd --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/3c-kcdn-dn-kcup-up/native_posix.keymap @@ -0,0 +1,13 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(1,0,10) /*d*/ + ZMK_MOCK_PRESS(0,0,100) /*mt f-shift */ + ZMK_MOCK_RELEASE(1,0,10) + ZMK_MOCK_RELEASE(0,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/3c/events.patterns b/app/tests/hold-tap/tap-preferred/3c/events.patterns deleted file mode 100644 index fdf2b15..0000000 --- a/app/tests/hold-tap/tap-preferred/3c/events.patterns +++ /dev/null @@ -1,4 +0,0 @@ -s/.*hid_listener_keycode/kp/p -s/.*mo_keymap_binding/mo/p -s/.*on_hold_tap_binding/ht_binding/p -s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/3c/keycode_events.snapshot b/app/tests/hold-tap/tap-preferred/3c/keycode_events.snapshot deleted file mode 100644 index 3d7eaf1..0000000 --- a/app/tests/hold-tap/tap-preferred/3c/keycode_events.snapshot +++ /dev/null @@ -1,7 +0,0 @@ -kp_pressed: usage_page 0x07 keycode 0x07 -ht_binding_pressed: 0 new undecided hold_tap -kp_released: usage_page 0x07 keycode 0x07 -ht_decide: 0 decided tap (tap-preferred event 0) -kp_pressed: usage_page 0x07 keycode 0x09 -kp_released: usage_page 0x07 keycode 0x09 -ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/tap-preferred/3c/native_posix.keymap b/app/tests/hold-tap/tap-preferred/3c/native_posix.keymap deleted file mode 100644 index 77306cd..0000000 --- a/app/tests/hold-tap/tap-preferred/3c/native_posix.keymap +++ /dev/null @@ -1,13 +0,0 @@ -#include -#include -#include -#include "../behavior_keymap.dtsi" - -&kscan { - events = < - ZMK_MOCK_PRESS(1,0,10) /*d*/ - ZMK_MOCK_PRESS(0,0,100) /*mt f-shift */ - ZMK_MOCK_RELEASE(1,0,10) - ZMK_MOCK_RELEASE(0,0,10) - >; -}; \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/3d-kcdn-dn-kcup-timer-up/events.patterns b/app/tests/hold-tap/tap-preferred/3d-kcdn-dn-kcup-timer-up/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/3d-kcdn-dn-kcup-timer-up/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/3d-kcdn-dn-kcup-timer-up/keycode_events.snapshot b/app/tests/hold-tap/tap-preferred/3d-kcdn-dn-kcup-timer-up/keycode_events.snapshot new file mode 100644 index 0000000..059d99c --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/3d-kcdn-dn-kcup-timer-up/keycode_events.snapshot @@ -0,0 +1,7 @@ +kp_pressed: usage_page 0x07 keycode 0x07 +ht_binding_pressed: 0 new undecided hold_tap +kp_released: usage_page 0x07 keycode 0x07 +ht_decide: 0 decided hold (tap-preferred event 3) +kp_pressed: usage_page 0x07 keycode 0xe1 +kp_released: usage_page 0x07 keycode 0xe1 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/tap-preferred/3d-kcdn-dn-kcup-timer-up/native_posix.keymap b/app/tests/hold-tap/tap-preferred/3d-kcdn-dn-kcup-timer-up/native_posix.keymap new file mode 100644 index 0000000..1441331 --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/3d-kcdn-dn-kcup-timer-up/native_posix.keymap @@ -0,0 +1,13 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(1,0,10) /* d */ + ZMK_MOCK_PRESS(0,0,100) /* mt f-shift */ + ZMK_MOCK_RELEASE(1,0,400) + ZMK_MOCK_RELEASE(0,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/3d/events.patterns b/app/tests/hold-tap/tap-preferred/3d/events.patterns deleted file mode 100644 index fdf2b15..0000000 --- a/app/tests/hold-tap/tap-preferred/3d/events.patterns +++ /dev/null @@ -1,4 +0,0 @@ -s/.*hid_listener_keycode/kp/p -s/.*mo_keymap_binding/mo/p -s/.*on_hold_tap_binding/ht_binding/p -s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/3d/keycode_events.snapshot b/app/tests/hold-tap/tap-preferred/3d/keycode_events.snapshot deleted file mode 100644 index 059d99c..0000000 --- a/app/tests/hold-tap/tap-preferred/3d/keycode_events.snapshot +++ /dev/null @@ -1,7 +0,0 @@ -kp_pressed: usage_page 0x07 keycode 0x07 -ht_binding_pressed: 0 new undecided hold_tap -kp_released: usage_page 0x07 keycode 0x07 -ht_decide: 0 decided hold (tap-preferred event 3) -kp_pressed: usage_page 0x07 keycode 0xe1 -kp_released: usage_page 0x07 keycode 0xe1 -ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/tap-preferred/3d/native_posix.keymap b/app/tests/hold-tap/tap-preferred/3d/native_posix.keymap deleted file mode 100644 index 1441331..0000000 --- a/app/tests/hold-tap/tap-preferred/3d/native_posix.keymap +++ /dev/null @@ -1,13 +0,0 @@ -#include -#include -#include -#include "../behavior_keymap.dtsi" - -&kscan { - events = < - ZMK_MOCK_PRESS(1,0,10) /* d */ - ZMK_MOCK_PRESS(0,0,100) /* mt f-shift */ - ZMK_MOCK_RELEASE(1,0,400) - ZMK_MOCK_RELEASE(0,0,10) - >; -}; \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/4a-dn-htdn-timer-htup-up/events.patterns b/app/tests/hold-tap/tap-preferred/4a-dn-htdn-timer-htup-up/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/4a-dn-htdn-timer-htup-up/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/4a-dn-htdn-timer-htup-up/keycode_events.snapshot b/app/tests/hold-tap/tap-preferred/4a-dn-htdn-timer-htup-up/keycode_events.snapshot new file mode 100644 index 0000000..a8cf490 --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/4a-dn-htdn-timer-htup-up/keycode_events.snapshot @@ -0,0 +1,10 @@ +ht_binding_pressed: 0 new undecided hold_tap +ht_decide: 0 decided hold (tap-preferred event 3) +kp_pressed: usage_page 0x07 keycode 0xe1 +ht_binding_pressed: 1 new undecided hold_tap +ht_decide: 1 decided tap (tap-preferred event 0) +kp_pressed: usage_page 0x07 keycode 0x0d +kp_released: usage_page 0x07 keycode 0x0d +ht_binding_released: 1 cleaning up hold-tap +kp_released: usage_page 0x07 keycode 0xe1 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/tap-preferred/4a-dn-htdn-timer-htup-up/native_posix.keymap b/app/tests/hold-tap/tap-preferred/4a-dn-htdn-timer-htup-up/native_posix.keymap new file mode 100644 index 0000000..c10c6d6 --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/4a-dn-htdn-timer-htup-up/native_posix.keymap @@ -0,0 +1,14 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(0,0,200) + ZMK_MOCK_PRESS(0,1,200) + /* timer fires */ + ZMK_MOCK_RELEASE(0,1,10) + ZMK_MOCK_RELEASE(0,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/4a-dn-kcdn-timer-kcup-up/events.patterns b/app/tests/hold-tap/tap-preferred/4a-dn-kcdn-timer-kcup-up/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/4a-dn-kcdn-timer-kcup-up/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/4a-dn-kcdn-timer-kcup-up/keycode_events.snapshot b/app/tests/hold-tap/tap-preferred/4a-dn-kcdn-timer-kcup-up/keycode_events.snapshot new file mode 100644 index 0000000..92a3569 --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/4a-dn-kcdn-timer-kcup-up/keycode_events.snapshot @@ -0,0 +1,7 @@ +ht_binding_pressed: 0 new undecided hold_tap +ht_decide: 0 decided hold (tap-preferred event 3) +kp_pressed: usage_page 0x07 keycode 0xe1 +kp_pressed: usage_page 0x07 keycode 0x07 +kp_released: usage_page 0x07 keycode 0x07 +kp_released: usage_page 0x07 keycode 0xe1 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/tap-preferred/4a-dn-kcdn-timer-kcup-up/native_posix.keymap b/app/tests/hold-tap/tap-preferred/4a-dn-kcdn-timer-kcup-up/native_posix.keymap new file mode 100644 index 0000000..ce163f5 --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/4a-dn-kcdn-timer-kcup-up/native_posix.keymap @@ -0,0 +1,14 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(0,0,200) + ZMK_MOCK_PRESS(1,0,200) + /* timer fires */ + ZMK_MOCK_RELEASE(1,0,10) + ZMK_MOCK_RELEASE(0,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/4a-nested/events.patterns b/app/tests/hold-tap/tap-preferred/4a-nested/events.patterns deleted file mode 100644 index fdf2b15..0000000 --- a/app/tests/hold-tap/tap-preferred/4a-nested/events.patterns +++ /dev/null @@ -1,4 +0,0 @@ -s/.*hid_listener_keycode/kp/p -s/.*mo_keymap_binding/mo/p -s/.*on_hold_tap_binding/ht_binding/p -s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/4a-nested/keycode_events.snapshot b/app/tests/hold-tap/tap-preferred/4a-nested/keycode_events.snapshot deleted file mode 100644 index a8cf490..0000000 --- a/app/tests/hold-tap/tap-preferred/4a-nested/keycode_events.snapshot +++ /dev/null @@ -1,10 +0,0 @@ -ht_binding_pressed: 0 new undecided hold_tap -ht_decide: 0 decided hold (tap-preferred event 3) -kp_pressed: usage_page 0x07 keycode 0xe1 -ht_binding_pressed: 1 new undecided hold_tap -ht_decide: 1 decided tap (tap-preferred event 0) -kp_pressed: usage_page 0x07 keycode 0x0d -kp_released: usage_page 0x07 keycode 0x0d -ht_binding_released: 1 cleaning up hold-tap -kp_released: usage_page 0x07 keycode 0xe1 -ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/tap-preferred/4a-nested/native_posix.keymap b/app/tests/hold-tap/tap-preferred/4a-nested/native_posix.keymap deleted file mode 100644 index c10c6d6..0000000 --- a/app/tests/hold-tap/tap-preferred/4a-nested/native_posix.keymap +++ /dev/null @@ -1,14 +0,0 @@ -#include -#include -#include -#include "../behavior_keymap.dtsi" - -&kscan { - events = < - ZMK_MOCK_PRESS(0,0,200) - ZMK_MOCK_PRESS(0,1,200) - /* timer fires */ - ZMK_MOCK_RELEASE(0,1,10) - ZMK_MOCK_RELEASE(0,0,10) - >; -}; \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/4a/events.patterns b/app/tests/hold-tap/tap-preferred/4a/events.patterns deleted file mode 100644 index fdf2b15..0000000 --- a/app/tests/hold-tap/tap-preferred/4a/events.patterns +++ /dev/null @@ -1,4 +0,0 @@ -s/.*hid_listener_keycode/kp/p -s/.*mo_keymap_binding/mo/p -s/.*on_hold_tap_binding/ht_binding/p -s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/4a/keycode_events.snapshot b/app/tests/hold-tap/tap-preferred/4a/keycode_events.snapshot deleted file mode 100644 index 92a3569..0000000 --- a/app/tests/hold-tap/tap-preferred/4a/keycode_events.snapshot +++ /dev/null @@ -1,7 +0,0 @@ -ht_binding_pressed: 0 new undecided hold_tap -ht_decide: 0 decided hold (tap-preferred event 3) -kp_pressed: usage_page 0x07 keycode 0xe1 -kp_pressed: usage_page 0x07 keycode 0x07 -kp_released: usage_page 0x07 keycode 0x07 -kp_released: usage_page 0x07 keycode 0xe1 -ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/tap-preferred/4a/native_posix.keymap b/app/tests/hold-tap/tap-preferred/4a/native_posix.keymap deleted file mode 100644 index ce163f5..0000000 --- a/app/tests/hold-tap/tap-preferred/4a/native_posix.keymap +++ /dev/null @@ -1,14 +0,0 @@ -#include -#include -#include -#include "../behavior_keymap.dtsi" - -&kscan { - events = < - ZMK_MOCK_PRESS(0,0,200) - ZMK_MOCK_PRESS(1,0,200) - /* timer fires */ - ZMK_MOCK_RELEASE(1,0,10) - ZMK_MOCK_RELEASE(0,0,10) - >; -}; \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/4b-dn-kcdn-kcup-timer-up/events.patterns b/app/tests/hold-tap/tap-preferred/4b-dn-kcdn-kcup-timer-up/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/4b-dn-kcdn-kcup-timer-up/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/4b-dn-kcdn-kcup-timer-up/keycode_events.snapshot b/app/tests/hold-tap/tap-preferred/4b-dn-kcdn-kcup-timer-up/keycode_events.snapshot new file mode 100644 index 0000000..92a3569 --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/4b-dn-kcdn-kcup-timer-up/keycode_events.snapshot @@ -0,0 +1,7 @@ +ht_binding_pressed: 0 new undecided hold_tap +ht_decide: 0 decided hold (tap-preferred event 3) +kp_pressed: usage_page 0x07 keycode 0xe1 +kp_pressed: usage_page 0x07 keycode 0x07 +kp_released: usage_page 0x07 keycode 0x07 +kp_released: usage_page 0x07 keycode 0xe1 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/tap-preferred/4b-dn-kcdn-kcup-timer-up/native_posix.keymap b/app/tests/hold-tap/tap-preferred/4b-dn-kcdn-kcup-timer-up/native_posix.keymap new file mode 100644 index 0000000..7abda41 --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/4b-dn-kcdn-kcup-timer-up/native_posix.keymap @@ -0,0 +1,14 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(0,0,100) + ZMK_MOCK_PRESS(1,0,100) + ZMK_MOCK_RELEASE(1,0,200) + /* timer fires */ + ZMK_MOCK_RELEASE(0,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/4b/events.patterns b/app/tests/hold-tap/tap-preferred/4b/events.patterns deleted file mode 100644 index fdf2b15..0000000 --- a/app/tests/hold-tap/tap-preferred/4b/events.patterns +++ /dev/null @@ -1,4 +0,0 @@ -s/.*hid_listener_keycode/kp/p -s/.*mo_keymap_binding/mo/p -s/.*on_hold_tap_binding/ht_binding/p -s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/4b/keycode_events.snapshot b/app/tests/hold-tap/tap-preferred/4b/keycode_events.snapshot deleted file mode 100644 index 92a3569..0000000 --- a/app/tests/hold-tap/tap-preferred/4b/keycode_events.snapshot +++ /dev/null @@ -1,7 +0,0 @@ -ht_binding_pressed: 0 new undecided hold_tap -ht_decide: 0 decided hold (tap-preferred event 3) -kp_pressed: usage_page 0x07 keycode 0xe1 -kp_pressed: usage_page 0x07 keycode 0x07 -kp_released: usage_page 0x07 keycode 0x07 -kp_released: usage_page 0x07 keycode 0xe1 -ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/tap-preferred/4b/native_posix.keymap b/app/tests/hold-tap/tap-preferred/4b/native_posix.keymap deleted file mode 100644 index 7abda41..0000000 --- a/app/tests/hold-tap/tap-preferred/4b/native_posix.keymap +++ /dev/null @@ -1,14 +0,0 @@ -#include -#include -#include -#include "../behavior_keymap.dtsi" - -&kscan { - events = < - ZMK_MOCK_PRESS(0,0,100) - ZMK_MOCK_PRESS(1,0,100) - ZMK_MOCK_RELEASE(1,0,200) - /* timer fires */ - ZMK_MOCK_RELEASE(0,0,10) - >; -}; \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/4c-dn-kcdn-kcup-up/events.patterns b/app/tests/hold-tap/tap-preferred/4c-dn-kcdn-kcup-up/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/4c-dn-kcdn-kcup-up/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/4c-dn-kcdn-kcup-up/keycode_events.snapshot b/app/tests/hold-tap/tap-preferred/4c-dn-kcdn-kcup-up/keycode_events.snapshot new file mode 100644 index 0000000..bc8aa8e --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/4c-dn-kcdn-kcup-up/keycode_events.snapshot @@ -0,0 +1,7 @@ +ht_binding_pressed: 0 new undecided hold_tap +ht_decide: 0 decided tap (tap-preferred event 0) +kp_pressed: usage_page 0x07 keycode 0x09 +kp_pressed: usage_page 0x07 keycode 0x07 +kp_released: usage_page 0x07 keycode 0x07 +kp_released: usage_page 0x07 keycode 0x09 +ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/tap-preferred/4c-dn-kcdn-kcup-up/native_posix.keymap b/app/tests/hold-tap/tap-preferred/4c-dn-kcdn-kcup-up/native_posix.keymap new file mode 100644 index 0000000..ce030af --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/4c-dn-kcdn-kcup-up/native_posix.keymap @@ -0,0 +1,14 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(0,0,10) + ZMK_MOCK_PRESS(1,0,10) + ZMK_MOCK_RELEASE(1,0,10) + ZMK_MOCK_RELEASE(0,0,10) + /* timer */ + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/4c/events.patterns b/app/tests/hold-tap/tap-preferred/4c/events.patterns deleted file mode 100644 index fdf2b15..0000000 --- a/app/tests/hold-tap/tap-preferred/4c/events.patterns +++ /dev/null @@ -1,4 +0,0 @@ -s/.*hid_listener_keycode/kp/p -s/.*mo_keymap_binding/mo/p -s/.*on_hold_tap_binding/ht_binding/p -s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/4c/keycode_events.snapshot b/app/tests/hold-tap/tap-preferred/4c/keycode_events.snapshot deleted file mode 100644 index bc8aa8e..0000000 --- a/app/tests/hold-tap/tap-preferred/4c/keycode_events.snapshot +++ /dev/null @@ -1,7 +0,0 @@ -ht_binding_pressed: 0 new undecided hold_tap -ht_decide: 0 decided tap (tap-preferred event 0) -kp_pressed: usage_page 0x07 keycode 0x09 -kp_pressed: usage_page 0x07 keycode 0x07 -kp_released: usage_page 0x07 keycode 0x07 -kp_released: usage_page 0x07 keycode 0x09 -ht_binding_released: 0 cleaning up hold-tap diff --git a/app/tests/hold-tap/tap-preferred/4c/native_posix.keymap b/app/tests/hold-tap/tap-preferred/4c/native_posix.keymap deleted file mode 100644 index ce030af..0000000 --- a/app/tests/hold-tap/tap-preferred/4c/native_posix.keymap +++ /dev/null @@ -1,14 +0,0 @@ -#include -#include -#include -#include "../behavior_keymap.dtsi" - -&kscan { - events = < - ZMK_MOCK_PRESS(0,0,10) - ZMK_MOCK_PRESS(1,0,10) - ZMK_MOCK_RELEASE(1,0,10) - ZMK_MOCK_RELEASE(0,0,10) - /* timer */ - >; -}; \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/4d-dn-kcdn-timer-up-kcup/events.patterns b/app/tests/hold-tap/tap-preferred/4d-dn-kcdn-timer-up-kcup/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/4d-dn-kcdn-timer-up-kcup/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/4d-dn-kcdn-timer-up-kcup/keycode_events.snapshot b/app/tests/hold-tap/tap-preferred/4d-dn-kcdn-timer-up-kcup/keycode_events.snapshot new file mode 100644 index 0000000..b106f13 --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/4d-dn-kcdn-timer-up-kcup/keycode_events.snapshot @@ -0,0 +1,7 @@ +ht_binding_pressed: 0 new undecided hold_tap +ht_decide: 0 decided tap (tap-preferred event 0) +kp_pressed: usage_page 0x07 keycode 0x09 +kp_pressed: usage_page 0x07 keycode 0x07 +kp_released: usage_page 0x07 keycode 0x09 +ht_binding_released: 0 cleaning up hold-tap +kp_released: usage_page 0x07 keycode 0x07 diff --git a/app/tests/hold-tap/tap-preferred/4d-dn-kcdn-timer-up-kcup/native_posix.keymap b/app/tests/hold-tap/tap-preferred/4d-dn-kcdn-timer-up-kcup/native_posix.keymap new file mode 100644 index 0000000..5467660 --- /dev/null +++ b/app/tests/hold-tap/tap-preferred/4d-dn-kcdn-timer-up-kcup/native_posix.keymap @@ -0,0 +1,14 @@ +#include +#include +#include +#include "../behavior_keymap.dtsi" + +&kscan { + events = < + ZMK_MOCK_PRESS(0,0,100) + ZMK_MOCK_PRESS(1,0,100) + ZMK_MOCK_RELEASE(0,0,200) + /* timer fires */ + ZMK_MOCK_RELEASE(1,0,10) + >; +}; \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/4d/events.patterns b/app/tests/hold-tap/tap-preferred/4d/events.patterns deleted file mode 100644 index fdf2b15..0000000 --- a/app/tests/hold-tap/tap-preferred/4d/events.patterns +++ /dev/null @@ -1,4 +0,0 @@ -s/.*hid_listener_keycode/kp/p -s/.*mo_keymap_binding/mo/p -s/.*on_hold_tap_binding/ht_binding/p -s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/tap-preferred/4d/keycode_events.snapshot b/app/tests/hold-tap/tap-preferred/4d/keycode_events.snapshot deleted file mode 100644 index b106f13..0000000 --- a/app/tests/hold-tap/tap-preferred/4d/keycode_events.snapshot +++ /dev/null @@ -1,7 +0,0 @@ -ht_binding_pressed: 0 new undecided hold_tap -ht_decide: 0 decided tap (tap-preferred event 0) -kp_pressed: usage_page 0x07 keycode 0x09 -kp_pressed: usage_page 0x07 keycode 0x07 -kp_released: usage_page 0x07 keycode 0x09 -ht_binding_released: 0 cleaning up hold-tap -kp_released: usage_page 0x07 keycode 0x07 diff --git a/app/tests/hold-tap/tap-preferred/4d/native_posix.keymap b/app/tests/hold-tap/tap-preferred/4d/native_posix.keymap deleted file mode 100644 index 5467660..0000000 --- a/app/tests/hold-tap/tap-preferred/4d/native_posix.keymap +++ /dev/null @@ -1,14 +0,0 @@ -#include -#include -#include -#include "../behavior_keymap.dtsi" - -&kscan { - events = < - ZMK_MOCK_PRESS(0,0,100) - ZMK_MOCK_PRESS(1,0,100) - ZMK_MOCK_RELEASE(0,0,200) - /* timer fires */ - ZMK_MOCK_RELEASE(1,0,10) - >; -}; \ No newline at end of file diff --git a/app/tests/tap-hold/balanced/behavior_keymap.dtsi b/app/tests/tap-hold/balanced/behavior_keymap.dtsi deleted file mode 100644 index df56fb5..0000000 --- a/app/tests/tap-hold/balanced/behavior_keymap.dtsi +++ /dev/null @@ -1,27 +0,0 @@ -#include -#include -#include - -/ { - behaviors { - ht_bal: behavior_hold_tap_balanced { - compatible = "zmk,behavior-hold-tap"; - label = "HOLD_TAP_BALANCED"; - #binding-cells = <2>; - flavor = "balanced"; - tapping_term_ms = <300>; - bindings = <&kp>, <&kp>; - }; - }; - - keymap { - compatible = "zmk,keymap"; - label ="Default keymap"; - - default_layer { - bindings = < - &ht_bal LSFT F &ht_bal LCTL J - &kp D &kp RCTL>; - }; - }; -}; diff --git a/app/tests/tap-hold/hold-preferred/behavior_keymap.dtsi b/app/tests/tap-hold/hold-preferred/behavior_keymap.dtsi deleted file mode 100644 index 375ffd9..0000000 --- a/app/tests/tap-hold/hold-preferred/behavior_keymap.dtsi +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include -#include - - - -/ { - behaviors { - ht_hold: behavior_hold_hold_tap { - compatible = "zmk,behavior-hold-tap"; - label = "hold_hold_tap"; - #binding-cells = <2>; - flavor = "hold-preferred"; - tapping_term_ms = <300>; - bindings = <&kp>, <&kp>; - }; - }; - - keymap { - compatible = "zmk,keymap"; - label ="Default keymap"; - - default_layer { - bindings = < - &ht_hold LSFT F &ht_hold LCTL J - &kp D &kp RCTL>; - }; - }; -}; diff --git a/app/tests/tap-hold/tap-preferred/behavior_keymap.dtsi b/app/tests/tap-hold/tap-preferred/behavior_keymap.dtsi deleted file mode 100644 index e514fa6..0000000 --- a/app/tests/tap-hold/tap-preferred/behavior_keymap.dtsi +++ /dev/null @@ -1,27 +0,0 @@ -#include -#include -#include - -/ { - behaviors { - tp: behavior_tap_preferred { - compatible = "zmk,behavior-hold-tap"; - label = "MOD_TAP"; - #binding-cells = <2>; - flavor = "tap-preferred"; - tapping_term_ms = <300>; - bindings = <&kp>, <&kp>; - }; - }; - - keymap { - compatible = "zmk,keymap"; - label ="Default keymap"; - - default_layer { - bindings = < - &tp LSFT F &tp LCTL J - &kp D &kp RCTL>; - }; - }; -}; -- cgit v1.2.3 From c5ca66441172114b57ca7f7b27d13d0d342d4fcc Mon Sep 17 00:00:00 2001 From: Okke Formsma Date: Wed, 2 Sep 2020 15:11:56 +0200 Subject: some fixes based on feedback --- app/dts/behaviors/homerow_tap.dtsi | 2 +- .../bindings/behaviors/zmk,behavior-hold-tap.yaml | 23 +++++++++++ .../bindings/behaviors/zmk,behavior-tap-hold.yaml | 23 ----------- app/include/zmk/event-manager.h | 9 +++-- app/run-test-debug.sh | 44 ---------------------- app/src/behaviors/behavior_hold_tap.c | 30 +++++++-------- app/src/event_manager.c | 22 ++++++++--- app/tests/hold-tap/README.md | 1 + docs/docs/behavior/mod-tap.md | 2 +- 9 files changed, 61 insertions(+), 95 deletions(-) create mode 100644 app/dts/bindings/behaviors/zmk,behavior-hold-tap.yaml delete mode 100644 app/dts/bindings/behaviors/zmk,behavior-tap-hold.yaml delete mode 100755 app/run-test-debug.sh create mode 100644 app/tests/hold-tap/README.md diff --git a/app/dts/behaviors/homerow_tap.dtsi b/app/dts/behaviors/homerow_tap.dtsi index 21c1531..4162c28 100644 --- a/app/dts/behaviors/homerow_tap.dtsi +++ b/app/dts/behaviors/homerow_tap.dtsi @@ -2,7 +2,7 @@ behaviors { ht: behavior_homerow_mod { compatible = "zmk,behavior-hold-tap"; - label = "homerow_mod"; + label = "HOMEROW_MOD"; #binding-cells = <2>; flavor = "balanced"; tapping_term_ms = <200>; diff --git a/app/dts/bindings/behaviors/zmk,behavior-hold-tap.yaml b/app/dts/bindings/behaviors/zmk,behavior-hold-tap.yaml new file mode 100644 index 0000000..a20578f --- /dev/null +++ b/app/dts/bindings/behaviors/zmk,behavior-hold-tap.yaml @@ -0,0 +1,23 @@ +# Copyright (c) 2020, Cody McGinnis; Okke Formsma +# SPDX-License-Identifier: MIT + +description: Hold or Tap behavior + +compatible: "zmk,behavior-hold-tap" + +include: two_param.yaml + +properties: + bindings: + type: phandles + required: true + tapping_term_ms: + type: int + flavor: + type: string + required: false + default: "hold-preferred" + enum: + - "hold-preferred" + - "balanced" + - "tap-preferred" \ No newline at end of file diff --git a/app/dts/bindings/behaviors/zmk,behavior-tap-hold.yaml b/app/dts/bindings/behaviors/zmk,behavior-tap-hold.yaml deleted file mode 100644 index a20578f..0000000 --- a/app/dts/bindings/behaviors/zmk,behavior-tap-hold.yaml +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright (c) 2020, Cody McGinnis; Okke Formsma -# SPDX-License-Identifier: MIT - -description: Hold or Tap behavior - -compatible: "zmk,behavior-hold-tap" - -include: two_param.yaml - -properties: - bindings: - type: phandles - required: true - tapping_term_ms: - type: int - flavor: - type: string - required: false - default: "hold-preferred" - enum: - - "hold-preferred" - - "balanced" - - "tap-preferred" \ No newline at end of file diff --git a/app/include/zmk/event-manager.h b/app/include/zmk/event-manager.h index 07c0aa9..d9a56a4 100644 --- a/app/include/zmk/event-manager.h +++ b/app/include/zmk/event-manager.h @@ -75,13 +75,14 @@ struct zmk_event_subscription { #define ZMK_EVENT_RAISE_AFTER(ev, mod) \ zmk_event_manager_raise_after((struct zmk_event_header *)ev, &zmk_listener_##mod); + +#define ZMK_EVENT_RAISE_AT(ev, mod) \ + zmk_event_manager_raise_at((struct zmk_event_header *)ev, &zmk_listener_##mod); + #define ZMK_EVENT_RELEASE(ev) \ zmk_event_manager_release((struct zmk_event_header *)ev); -#define ZMK_EVENT_RELEASE_AGAIN(ev) \ - zmk_event_manager_release_again((struct zmk_event_header *)ev); - int zmk_event_manager_raise(struct zmk_event_header *event); int zmk_event_manager_raise_after(struct zmk_event_header *event, const struct zmk_listener *listener); +int zmk_event_manager_raise_at(struct zmk_event_header *event, const struct zmk_listener *listener); int zmk_event_manager_release(struct zmk_event_header *event); -int zmk_event_manager_release_again(struct zmk_event_header *event); diff --git a/app/run-test-debug.sh b/app/run-test-debug.sh deleted file mode 100755 index f6696a1..0000000 --- a/app/run-test-debug.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/sh -# -# Copyright (c) 2020 Peter Johanson; Cody McGinnis; Okke Formsma -# -# SPDX-License-Identifier: MIT -# -set -e -set -x - -if [ -z "$1" ]; then - echo "Usage: ./run-test.sh " - exit 1 -elif [ "$1" = "all" ]; then - echo "" > ./build/tests/pass-fail.log - find tests -name native_posix.keymap -exec dirname \{\} \; | xargs -l -P 4 ./run-test.sh - err=$? - sort -k2 ./build/tests/pass-fail.log - exit $err -fi - -testcase="$1" -echo "Running $testcase:" - -west build -d build/$testcase -b native_posix --pristine -- -DZMK_CONFIG=$testcase -if [ $? -gt 0 ]; then - echo "FAIL: $testcase did not build" -else - ./build/$testcase/zephyr/zmk.exe | sed -e "s/.*> //" | tee build/$testcase/keycode_events_full.log | sed -n -f $testcase/events.patterns > build/$testcase/keycode_events.log - cat build/$testcase/keycode_events_full.log - cat build/$testcase/keycode_events.log - diff -au $testcase/keycode_events.snapshot build/$testcase/keycode_events.log - if [ $? -gt 0 ]; then - if [ -f $testcase/pending ]; then - echo "PEND: $testcase" - exit 0 - else - echo "FAIL: $testcase" - exit 1 - fi - else - echo "PASS: $testcase" - exit 0 - fi -fi \ No newline at end of file diff --git a/app/src/behaviors/behavior_hold_tap.c b/app/src/behaviors/behavior_hold_tap.c index 08fa139..cd788f7 100644 --- a/app/src/behaviors/behavior_hold_tap.c +++ b/app/src/behaviors/behavior_hold_tap.c @@ -23,7 +23,6 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); #if DT_NODE_EXISTS(DT_DRV_INST(0)) -/************************************************************ DATA SETUP */ #define ZMK_BHV_HOLD_TAP_MAX_HELD 10 #define ZMK_BHV_HOLD_TAP_MAX_CAPTURED_EVENTS 40 @@ -40,7 +39,7 @@ typedef k_timeout_t (*timer_func)(); struct behavior_hold_tap_config { timer_func tapping_term_ms; struct behavior_hold_tap_behaviors *behaviors; - char *flavor; + int flavor; }; // this data is specific for each hold-tap @@ -65,7 +64,6 @@ struct active_hold_tap active_hold_taps[ZMK_BHV_HOLD_TAP_MAX_HELD] = {}; // We capture most position_state_changed events and some modifiers_state_changed events. const struct zmk_event_header *captured_events[ZMK_BHV_HOLD_TAP_MAX_CAPTURED_EVENTS] = {}; -/************************************************************ CAPTURED POSITION HELPER FUNCTIONS */ static int capture_event(const struct zmk_event_header *event) { for (int i = 0; i < ZMK_BHV_HOLD_TAP_MAX_CAPTURED_EVENTS; i++) { @@ -96,6 +94,8 @@ static struct position_state_changed *find_captured_keydown_event(u32_t position return last_match; } +const struct zmk_listener zmk_listener_behavior_hold_tap; + static void release_captured_events() { if (undecided_hold_tap != NULL) { @@ -143,13 +143,10 @@ static void release_captured_events() struct keycode_state_changed *modifier_event = cast_keycode_state_changed(captured_event); LOG_DBG("Releasing mods changed event 0x%02X %s", modifier_event->keycode, (modifier_event->state ? "pressed" : "released")); } - ZMK_EVENT_RELEASE_AGAIN(captured_event); + ZMK_EVENT_RAISE_AT(captured_event, behavior_hold_tap); } } - -/************************************************************ ACTIVE TAP HOLD HELPER FUNCTIONS */ - static struct active_hold_tap *find_hold_tap(u32_t position) { for (int i = 0; i < ZMK_BHV_HOLD_TAP_MAX_HELD; i++) { @@ -256,12 +253,12 @@ static void decide_hold_tap(struct active_hold_tap *hold_tap, enum decision_mome return; } - char *flavor = hold_tap->config->flavor; - if (strcmp(flavor, "balanced") == 0) { + int flavor = hold_tap->config->flavor; + if (flavor == 1) { decide_balanced(hold_tap, event); - } else if (strcmp(flavor, "tap-preferred") == 0) { + } else if (flavor == 2) { decide_tap_preferred(hold_tap, event); - } else if (strcmp(flavor, "hold-preferred") == 0) { + } else if (flavor == 0) { decide_hold_preferred(hold_tap, event); } @@ -269,7 +266,11 @@ static void decide_hold_tap(struct active_hold_tap *hold_tap, enum decision_mome return; } - LOG_DBG("%d decided %s (%s event %d)", hold_tap->position, hold_tap->is_hold ? "hold" : "tap", flavor, event); + LOG_DBG("%d decided %s (%s event %d)", + hold_tap->position, + hold_tap->is_hold ? "hold" : "tap", + flavor == 0 ? "hold-preferred" : flavor == 1 ? "balanced": "tap-preferred", + event); undecided_hold_tap = NULL; struct zmk_behavior_binding *behavior; @@ -285,7 +286,6 @@ static void decide_hold_tap(struct active_hold_tap *hold_tap, enum decision_mome release_captured_events(); } -/************************************************************ hold_tap_binding and key handlers */ static int on_hold_tap_binding_pressed(struct device *dev, u32_t position, u32_t param_hold, u32_t param_tap) { const struct behavior_hold_tap_config *cfg = dev->config_info; @@ -430,7 +430,6 @@ ZMK_SUBSCRIPTION(behavior_hold_tap, position_state_changed); // this should be modifiers_state_changed, but unfrotunately that's not implemented yet. ZMK_SUBSCRIPTION(behavior_hold_tap, keycode_state_changed); -/************************************************************ TIMER FUNCTIONS */ void behavior_hold_tap_timer_work_handler(struct k_work *item) { struct active_hold_tap *hold_tap = CONTAINER_OF(item, struct active_hold_tap, work); @@ -459,7 +458,6 @@ static int behavior_hold_tap_init(struct device *dev) struct behavior_hold_tap_data {}; static struct behavior_hold_tap_data behavior_hold_tap_data; -/************************************************************ NODE CONFIG */ #define _TRANSFORM_ENTRY(idx, node) \ { \ .behavior_dev = DT_LABEL(DT_INST_PHANDLE_BY_IDX(node, bindings, idx)), \ @@ -476,7 +474,7 @@ static struct behavior_hold_tap_data behavior_hold_tap_data; static struct behavior_hold_tap_config behavior_hold_tap_config_##n = { \ .behaviors = &behavior_hold_tap_behaviors_##n, \ .tapping_term_ms = &behavior_hold_tap_config_##n##_gettime, \ - .flavor = DT_INST_PROP(n, flavor), \ + .flavor = DT_ENUM_IDX(DT_DRV_INST(n), flavor), \ }; \ DEVICE_AND_API_INIT( \ behavior_hold_tap_##n, DT_INST_LABEL(n), behavior_hold_tap_init, \ diff --git a/app/src/event_manager.c b/app/src/event_manager.c index 2f423fc..47ad6b7 100644 --- a/app/src/event_manager.c +++ b/app/src/event_manager.c @@ -71,13 +71,23 @@ int zmk_event_manager_raise_after(struct zmk_event_header *event, const struct z return -EINVAL; } -int zmk_event_manager_release(struct zmk_event_header *event) +int zmk_event_manager_raise_at(struct zmk_event_header *event, const struct zmk_listener *listener) { - return zmk_event_manager_handle_from(event, event->last_listener_index + 1); -} + u8_t len = __event_subscriptions_end - __event_subscriptions_start; + for (int i = 0; i < len; i++) { + struct zmk_event_subscription *ev_sub = __event_subscriptions_start + i; + + if (ev_sub->event_type == event->event && ev_sub->listener == listener) { + return zmk_event_manager_handle_from(event, i); + } + } + LOG_WRN("Unable to find where to raise this event"); + + return -EINVAL; +} -int zmk_event_manager_release_again(struct zmk_event_header *event) +int zmk_event_manager_release(struct zmk_event_header *event) { - return zmk_event_manager_handle_from(event, event->last_listener_index); -} \ No newline at end of file + return zmk_event_manager_handle_from(event, event->last_listener_index + 1); +} diff --git a/app/tests/hold-tap/README.md b/app/tests/hold-tap/README.md new file mode 100644 index 0000000..0630132 --- /dev/null +++ b/app/tests/hold-tap/README.md @@ -0,0 +1 @@ +Refer to the pdf/open document "zmk-modtap-proposal.{pdf,odt}" in this directory for a visual representation of the numbered tests for hold-tap. diff --git a/docs/docs/behavior/mod-tap.md b/docs/docs/behavior/mod-tap.md index cbe95e4..dcac492 100644 --- a/docs/docs/behavior/mod-tap.md +++ b/docs/docs/behavior/mod-tap.md @@ -22,7 +22,7 @@ The Mod-Tap behavior either acts as a held modifier, or as a tapped keycode. Example: ``` -&mt MOD_LSFT A +&mt LSFT A ``` ### Configuration -- cgit v1.2.3 From c2ffeb1cf4a27b79c9fcc7cf0c83deab3cd4b84e Mon Sep 17 00:00:00 2001 From: Kurtis Lew Date: Wed, 2 Sep 2020 07:21:45 -0700 Subject: Added Copyright Header to Kconfig.defconfig --- app/boards/shields/iris/Kconfig.defconfig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/boards/shields/iris/Kconfig.defconfig b/app/boards/shields/iris/Kconfig.defconfig index bf4919a..6439780 100644 --- a/app/boards/shields/iris/Kconfig.defconfig +++ b/app/boards/shields/iris/Kconfig.defconfig @@ -1,3 +1,5 @@ +# Copyright (c) 2020 Pete Johanson, Kurtis Lew +# SPDX-License-Identifier: MIT if SHIELD_IRIS_LEFT @@ -11,4 +13,4 @@ if SHIELD_IRIS_RIGHT config ZMK_KEYBOARD_NAME default "Iris Right" -endif \ No newline at end of file +endif -- cgit v1.2.3 From 6e8f19028a58d5238aa75b3fef3551e2cedaebdc Mon Sep 17 00:00:00 2001 From: Kurtis Lew Date: Wed, 2 Sep 2020 07:22:39 -0700 Subject: Added copyright header to iris.keymap --- app/boards/shields/iris/iris.keymap | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/boards/shields/iris/iris.keymap b/app/boards/shields/iris/iris.keymap index 4607adf..46b0817 100644 --- a/app/boards/shields/iris/iris.keymap +++ b/app/boards/shields/iris/iris.keymap @@ -1,3 +1,6 @@ +# Copyright (c) 2020 Pete Johanson, Kurtis Lew +# SPDX-License-Identifier: MIT + #include #include -- cgit v1.2.3 From c9a82d71d06146dfe706a2e8d223dab593dffffc Mon Sep 17 00:00:00 2001 From: Okke Formsma Date: Wed, 2 Sep 2020 16:41:39 +0200 Subject: fixes for feedback round 2 --- app/dts/behaviors.dtsi | 1 - app/dts/behaviors/homerow_tap.dtsi | 12 ----------- app/src/behaviors/behavior_hold_tap.c | 39 +++++++++++++++++++++++------------ docs/docs/behavior/hold-tap.md | 4 ++-- 4 files changed, 28 insertions(+), 28 deletions(-) delete mode 100644 app/dts/behaviors/homerow_tap.dtsi diff --git a/app/dts/behaviors.dtsi b/app/dts/behaviors.dtsi index fdcf426..ab70bcc 100644 --- a/app/dts/behaviors.dtsi +++ b/app/dts/behaviors.dtsi @@ -3,7 +3,6 @@ #include #include #include -#include #include #include #include diff --git a/app/dts/behaviors/homerow_tap.dtsi b/app/dts/behaviors/homerow_tap.dtsi deleted file mode 100644 index 4162c28..0000000 --- a/app/dts/behaviors/homerow_tap.dtsi +++ /dev/null @@ -1,12 +0,0 @@ -/ { - behaviors { - ht: behavior_homerow_mod { - compatible = "zmk,behavior-hold-tap"; - label = "HOMEROW_MOD"; - #binding-cells = <2>; - flavor = "balanced"; - tapping_term_ms = <200>; - bindings = <&kp>, <&kp>; - }; - }; -}; diff --git a/app/src/behaviors/behavior_hold_tap.c b/app/src/behaviors/behavior_hold_tap.c index cd788f7..2c6d996 100644 --- a/app/src/behaviors/behavior_hold_tap.c +++ b/app/src/behaviors/behavior_hold_tap.c @@ -29,6 +29,13 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); // increase if you have keyboard with more keys. #define ZMK_BHV_HOLD_TAP_POSITION_NOT_USED 9999 + +enum flavor { + ZMK_BHV_HOLD_TAP_FLAVOR_HOLD_PREFERRED = 0, + ZMK_BHV_HOLD_TAP_FLAVOR_BALANCED = 1, + ZMK_BHV_HOLD_TAP_FLAVOR_TAP_PREFERRED = 2, +}; + struct behavior_hold_tap_behaviors { struct zmk_behavior_binding tap; struct zmk_behavior_binding hold; @@ -39,7 +46,7 @@ typedef k_timeout_t (*timer_func)(); struct behavior_hold_tap_config { timer_func tapping_term_ms; struct behavior_hold_tap_behaviors *behaviors; - int flavor; + enum flavor flavor; }; // this data is specific for each hold-tap @@ -197,9 +204,6 @@ static void decide_balanced(struct active_hold_tap *hold_tap, enum decision_mome hold_tap->is_decided = true; break; case HT_OTHER_KEY_UP: - hold_tap->is_hold = 1; - hold_tap->is_decided = true; - break; case HT_TIMER_EVENT: hold_tap->is_hold = 1; hold_tap->is_decided = true; @@ -231,9 +235,6 @@ static void decide_hold_preferred(struct active_hold_tap *hold_tap, enum decisio hold_tap->is_decided = true; break; case HT_OTHER_KEY_DOWN: - hold_tap->is_hold = 1; - hold_tap->is_decided = true; - break; case HT_TIMER_EVENT: hold_tap->is_hold = 1; hold_tap->is_decided = true; @@ -242,6 +243,18 @@ static void decide_hold_preferred(struct active_hold_tap *hold_tap, enum decisio } } +static inline char* flavor_str(enum flavor flavor) { + switch(flavor) { + case ZMK_BHV_HOLD_TAP_FLAVOR_HOLD_PREFERRED: + return "hold-preferred"; + case ZMK_BHV_HOLD_TAP_FLAVOR_BALANCED: + return "balanced"; + case ZMK_BHV_HOLD_TAP_FLAVOR_TAP_PREFERRED: + return "tap-preferred"; + } + return "UNKNOWN FLAVOR"; +} + static void decide_hold_tap(struct active_hold_tap *hold_tap, enum decision_moment event) { if (hold_tap->is_decided) { @@ -253,13 +266,13 @@ static void decide_hold_tap(struct active_hold_tap *hold_tap, enum decision_mome return; } - int flavor = hold_tap->config->flavor; - if (flavor == 1) { + switch(hold_tap->config->flavor) { + case ZMK_BHV_HOLD_TAP_FLAVOR_HOLD_PREFERRED: + decide_hold_preferred(hold_tap, event); + case ZMK_BHV_HOLD_TAP_FLAVOR_BALANCED: decide_balanced(hold_tap, event); - } else if (flavor == 2) { + case ZMK_BHV_HOLD_TAP_FLAVOR_TAP_PREFERRED: decide_tap_preferred(hold_tap, event); - } else if (flavor == 0) { - decide_hold_preferred(hold_tap, event); } if (!hold_tap->is_decided) { @@ -269,7 +282,7 @@ static void decide_hold_tap(struct active_hold_tap *hold_tap, enum decision_mome LOG_DBG("%d decided %s (%s event %d)", hold_tap->position, hold_tap->is_hold ? "hold" : "tap", - flavor == 0 ? "hold-preferred" : flavor == 1 ? "balanced": "tap-preferred", + flavor_str(hold_tap->config->flavor), event); undecided_hold_tap = NULL; diff --git a/docs/docs/behavior/hold-tap.md b/docs/docs/behavior/hold-tap.md index b586b90..fa68538 100644 --- a/docs/docs/behavior/hold-tap.md +++ b/docs/docs/behavior/hold-tap.md @@ -31,9 +31,9 @@ A code example which configures a mod-tap setting that works with homerow mods: / { behaviors { - &hm: homerow_mods { + hm: homerow_mods { compatible = "zmk,behavior-hold-tap"; - label = "homerow_mods"; + label = "HOMEROW_MODS"; #binding-cells = <2>; tapping_term_ms = <175>; flavor = "balanced"; -- cgit v1.2.3 From 6f74e61dd383f7b62280f230dafa66014800bd78 Mon Sep 17 00:00:00 2001 From: Kevin Date: Wed, 2 Sep 2020 18:25:46 -0700 Subject: Added user and dev encoder docs --- docs/docs/dev-guide-new-shield.md | 79 +++++++++++++++++++++++++++++++++++++++ docs/docs/feature/encoders.md | 14 ++++--- docs/sidebars.js | 1 - 3 files changed, 88 insertions(+), 6 deletions(-) diff --git a/docs/docs/dev-guide-new-shield.md b/docs/docs/dev-guide-new-shield.md index 8556623..7825d8b 100644 --- a/docs/docs/dev-guide-new-shield.md +++ b/docs/docs/dev-guide-new-shield.md @@ -3,6 +3,9 @@ id: dev-guide-new-shield title: New Keyboard Shield --- +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + ## Overview This guide will walk through the steps necessary to add ZMK support for a keyboard the uses a (Pro Micro compatible) addon MCU board to provide the microprocessor. @@ -13,6 +16,7 @@ The high level steps are: - Add the shield overlay file to define the [KSCAN driver]() for detecting key press/release. - (Optional) Add the matrix transform for mapping KSCAN row/column values to sane key positions. This is needed for non-rectangular keyboards, or where the underlying row/column pin arrangement does not map one to one with logical locations on the keyboard. - Add a default keymap, which users can override in their own configs as needed. +- Add support for features such as encoders, OLED displays, or RGB underglow. It may be helpful to review the upstream [shields documentation](https://docs.zephyrproject.org/2.3.0/guides/porting/shields.html#shields) to get a proper understanding of the underlying system before continuing. @@ -195,6 +199,81 @@ Further documentation on behaviors and bindings is forthcoming, but a summary of - `trans` is the "transparent" behavior, useful to be place in higher layers above `mo` bindings to be sure the key release is handled by the lower layer. No binding arguments are required. - `mt` is the "mod-tap" behavior, and takes two binding arguments, the modifier to use if held, and the keycode to send if tapped. +## Adding Features + +### Encoders + +EC11 encoder support can be added to your board or shield by adding the appropriate lines to your board/shield's configuration (.conf), device tree (.dtsi), and overlay (.overlay) files. + + + + +In your configuration file you will need to add the following lines so that the encoders can be enabled/disabled: + +``` +# Uncomment to enable encoder +# CONFIG_EC11=y +# CONFIG_EC11_TRIGGER_GLOBAL_THREAD=y +``` + +These should be commented by default for encoders that are optional/can be swapped with switches, but can be uncommented if encoders are part of the default design. + +:::note +If building locally for split boards, you may need to add these lines to the specific half's configuration file as well as the combined configuration file. +::: + + + +In your device tree file you will need to add the following lines to define the encoder sensor: + + +``` +left_encoder: encoder_left { + compatible = "alps,ec11"; + label = "LEFT_ENCODER"; + a-gpios = ; + b-gpios = ; + resolution = <4>; + }; +``` +Here you will have to replace PIN_A and PIN_B with the appropriate pins that your PCB utilizes for the encoder(s). For keyboards that use the Pro Micro or any of the Pro Micro replacements, Sparkfun's [Pro Micro Hookup Guide](https://learn.sparkfun.com/tutorials/pro-micro--fio-v3-hookup-guide/hardware-overview-pro-micro) has a pinout diagram that can be useful to determine the right pins. Reference either the blue numbers labeled "Arduino" (digital pins) or the green numbers labeled "Analog" (analog pins). For pins that are labeled as both digital and analog, refer to your specific board's .dtsi file to determine how you should refer to that pin. + +Add additional encoders as necessary by duplicating the above lines, replacing `left` with whatever you would like to call your encoder, and updating the pins. Note that support for peripheral (right) side sensors over BLE is still in progress. + +Once you have defined the encoder sensors, you will have to add them to the list of sensors: + +``` +sensors { + compatible = "zmk,keymap-sensors"; + sensors = <&left_encoder &right_encoder>; + }; +``` + +In this example, a left_encoder and right_encoder are both added. Additional encoders can be added with spaces separating each, and the order they are added here determines the order in which you define their behavior in your keymap. + + + +Add the following lines to your overlay file(s) to enable the encoder: + +``` +&left_encoder { + status = "okay"; +}; +``` + +:::note +For split keyboards, make sure to add left hand encoders to the left .overlay file and right hand encoders to the right .overlay file. +::: + + + + ## Testing Once you've fully created the new keyboard shield definition, diff --git a/docs/docs/feature/encoders.md b/docs/docs/feature/encoders.md index 9f583cb..a5a796d 100644 --- a/docs/docs/feature/encoders.md +++ b/docs/docs/feature/encoders.md @@ -3,7 +3,7 @@ title: Encoders sidebar_label: Encoders --- -Existing support for encoders in ZMK is focused around the EC11 rotary encoder with push button design used in the majority of current keyboard and macropad designs. +Existing support for encoders in ZMK is focused around the five pin EC11 rotary encoder with push button design used in the majority of current keyboard and macropad designs. ## Enabling EC11 Encoders @@ -19,7 +19,7 @@ Keyboards and macropads with encoder support will typically take the two EC11 pi ### Rotation -Rotation is handled separately as a type of sensor. The behavior for this is set by defining `sensor-bindings` within a layer but below the `bindings` for the regular keys in the following format: +Rotation is handled separately as a type of sensor. The behavior for this is set in `sensor-bindings`, which is defined in each keymap layer in the following format: ``` sensor-bindings = ; @@ -29,12 +29,16 @@ sensor-bindings = ; - `CW_KEY` is the keycode activated by a clockwise turn. - `CCW_KEY` is the keycode activated by a counter-clockwise turn. -Behaviors for additional encoders can be configured by adding more `BINDING CW_KEY CCW_KEY` sets immediately after the first. +Additional encoders can be configured by adding more `BINDING CW_KEY CCW_KEY` sets immediately after the first. -As an example, a complete `sensor-bindings` for a Kyria would look like: +As an example, a complete `sensor-bindings` for a Kyria with two encoders could look like: ``` sensor-bindings = <&inc_dec_cp M_VOLU M_VOLD &inc_dec_kp PGUP PGDN>; ``` -In this example, the left encoder is configured to control volume up and down while the right encoder sends either Page Up or Page Down. +Here, the left encoder is configured to control volume up and down while the right encoder sends either Page Up or Page Down. + +## Adding Encoder Support + +See the [New Keyboard Shield](docs/dev-guide-new-shield) documentation for how to add or modify additional encoders to your shield. diff --git a/docs/sidebars.js b/docs/sidebars.js index 924010e..fb82dfa 100644 --- a/docs/sidebars.js +++ b/docs/sidebars.js @@ -25,7 +25,6 @@ module.exports = { ], "Dev Guides": [ "dev-guide-new-shield", - "dev-guide-add-encoders", "dev-guide-usb-logging"], }, }; -- cgit v1.2.3 From 2629aa354f3d908e3afc13e3cd12a79974d77234 Mon Sep 17 00:00:00 2001 From: Kevin Date: Wed, 2 Sep 2020 18:28:00 -0700 Subject: Removed old dev encoder page --- docs/docs/dev-guide-add-encoders.md | 53 ------------------------------------- 1 file changed, 53 deletions(-) delete mode 100644 docs/docs/dev-guide-add-encoders.md diff --git a/docs/docs/dev-guide-add-encoders.md b/docs/docs/dev-guide-add-encoders.md deleted file mode 100644 index 79f353f..0000000 --- a/docs/docs/dev-guide-add-encoders.md +++ /dev/null @@ -1,53 +0,0 @@ ---- -id: dev-guide-add-encoders -title: Adding Encoders ---- - -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; - -EC11 encoder support can be added to your board or shield by adding the appropriate lines to your board/shield's .conf, .dtsi, and .overlay files. - - - - -In your .conf file you will need to add the following lines so that the EC11 drivers can be enabled: - -``` -# Uncomment to enable encoder -# CONFIG_EC11=y -# CONFIG_EC11_TRIGGER_GLOBAL_THREAD=y -``` - -These should be commented by default if encoders are optional, but can be uncommented if encoders are part of the original design. - - - -In your .dtsi file you will need to add the following lines to define the encoder sensor: - - -``` -left_encoder: encoder_left { - compatible = "alps,ec11"; - label = "LEFT_ENCODER"; - a-gpios = ; - b-gpios = ; - resolution = <4>; - }; -``` -Here you will have to replace PIN_A and PIN_B with the appropriate pins that your PCB utilizes for the encoder(s). - -For keyboards that use the Pro Micro or any of the Pro Micro replacements, Sparkfun's [Pro Micro Hookup Guide](https://learn.sparkfun.com/tutorials/pro-micro--fio-v3-hookup-guide/hardware-overview-pro-micro) has a pinout diagram that can be useful to determine the right pins. Reference either the blue numbers labeled "Arduino" (digital pins) or the green numbers labeled "Analog" (analog pins). For pins that are labeled as both digital and analog, refer to your specific board's .dtsi file to determine how you should refer to that pin. - -Replace `left` with `right` to define a right-side encoder, although note that support for peripheral side sensors is still in progress. - - - - - -- cgit v1.2.3 From 5eb50d7b181d2c61099b49f74b1b54c996370914 Mon Sep 17 00:00:00 2001 From: Kevin Date: Wed, 2 Sep 2020 18:36:35 -0700 Subject: Fixed links --- docs/docs/feature/encoders.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/docs/feature/encoders.md b/docs/docs/feature/encoders.md index a5a796d..38ff9d3 100644 --- a/docs/docs/feature/encoders.md +++ b/docs/docs/feature/encoders.md @@ -25,7 +25,7 @@ Rotation is handled separately as a type of sensor. The behavior for this is set sensor-bindings = ; ``` -- `BINDING` is one of two rotation bindings that are currently defined, `&inc_dec_cp` for consumer key presses or `&inc_dec_kp` for normal key presses (see [Key Press](<(/docs/behavior/key-press)>) for the difference between the two). +- `BINDING` is one of two rotation bindings that are currently defined, `&inc_dec_cp` for consumer key presses or `&inc_dec_kp` for normal key presses (see [Key Press](/docs/behavior/key-press) for the difference between the two). - `CW_KEY` is the keycode activated by a clockwise turn. - `CCW_KEY` is the keycode activated by a counter-clockwise turn. @@ -41,4 +41,4 @@ Here, the left encoder is configured to control volume up and down while the rig ## Adding Encoder Support -See the [New Keyboard Shield](docs/dev-guide-new-shield) documentation for how to add or modify additional encoders to your shield. +See the [New Keyboard Shield](/docs/dev-guide-new-shield) documentation for how to add or modify additional encoders to your shield. -- cgit v1.2.3 From 9b1fd1323f4fe4a812a08f0d6b762250f54d191f Mon Sep 17 00:00:00 2001 From: kurtis-lew Date: Wed, 2 Sep 2020 20:53:14 -0700 Subject: Update setup.sh --- docs/static/setup.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/static/setup.sh b/docs/static/setup.sh index a32718d..ad5416b 100644 --- a/docs/static/setup.sh +++ b/docs/static/setup.sh @@ -52,6 +52,7 @@ select opt in "${options[@]}" "Quit"; do 3 ) shield_title="Corne" shield="corne"; split="y"; break;; 4 ) shield_title="Splitreus62" shield="splitreus62"; split="y"; break;; 5 ) shield_title="Sofle" shield="sofle"; split="y"; break;; + 6 ) shield_title="Iris" shield="iris"; split="y"; break;; # Add link to docs on adding your own custom shield in your ZMK config! # $(( ${#options[@]}+1 )) ) echo "Other!"; break;; -- cgit v1.2.3 From f738fd7a670994bfbe20601a4de9a64cd98020ad Mon Sep 17 00:00:00 2001 From: Kurtis Lew Date: Wed, 2 Sep 2020 20:57:42 -0700 Subject: Update setup.sh --- docs/static/setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/static/setup.sh b/docs/static/setup.sh index ad5416b..70defdf 100644 --- a/docs/static/setup.sh +++ b/docs/static/setup.sh @@ -38,7 +38,7 @@ echo "" echo "Keyboard Shield Selection:" prompt="Pick an keyboard:" -options=("Kyria" "Lily58" "Corne" "Splitreus62" "Sofle") +options=("Kyria" "Lily58" "Corne" "Splitreus62" "Sofle" "Iris") PS3="$prompt " # TODO: Add support for "Other" and linking to docs on adding custom shields in user config repos. -- cgit v1.2.3 From e904a098b3ad2af28485e0f79287ac3b04947d1c Mon Sep 17 00:00:00 2001 From: Kevin Date: Wed, 2 Sep 2020 21:12:22 -0700 Subject: Added keymap update to encoder docs --- docs/docs/dev-guide-new-shield.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/docs/docs/dev-guide-new-shield.md b/docs/docs/dev-guide-new-shield.md index 7825d8b..bc5175b 100644 --- a/docs/docs/dev-guide-new-shield.md +++ b/docs/docs/dev-guide-new-shield.md @@ -203,7 +203,7 @@ Further documentation on behaviors and bindings is forthcoming, but a summary of ### Encoders -EC11 encoder support can be added to your board or shield by adding the appropriate lines to your board/shield's configuration (.conf), device tree (.dtsi), and overlay (.overlay) files. +EC11 encoder support can be added to your board or shield by adding the appropriate lines to your board/shield's configuration (.conf), device tree (.dtsi), overlay (.overlay), and keymap (.keymap) files. @@ -271,6 +272,15 @@ Add the following lines to your overlay file(s) to enable the encoder: For split keyboards, make sure to add left hand encoders to the left .overlay file and right hand encoders to the right .overlay file. ::: + + +Add the following line to your keymap file to add default encoder behavior bindings: + +``` +sensor-bindings = <&inc_dec_cp M_VOLU M_VOLD>; +``` +Add additional bindings as necessary to match the default number of encoders on your board. See the [Encoders](/docs/feature/encoders) and [Keymap](/docs/feature/keymaps) feature documentation for more details. + -- cgit v1.2.3 From e559cb2d713b4248697518f6bf3ece2e05b87ab3 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Thu, 3 Sep 2020 10:14:16 -0400 Subject: Add hold-tap to sidebar. --- docs/sidebars.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/sidebars.js b/docs/sidebars.js index 53c5cf3..3df183b 100644 --- a/docs/sidebars.js +++ b/docs/sidebars.js @@ -1,6 +1,13 @@ module.exports = { someSidebar: { - "Getting Started": ["intro", "hardware", "faq", "user-setup","customization", "bond-reset"], + "Getting Started": [ + "intro", + "hardware", + "faq", + "user-setup", + "customization", + "bond-reset", + ], Features: [ "feature/keymaps", "feature/displays", @@ -11,6 +18,7 @@ module.exports = { "behavior/key-press", "behavior/layers", "behavior/misc", + "behavior/hold-tap", "behavior/mod-tap", "behavior/reset", "behavior/lighting", -- cgit v1.2.3 From 0ede549a13d6f79ef30ef6cb6e056ae94034ea8d Mon Sep 17 00:00:00 2001 From: CrossR Date: Thu, 3 Sep 2020 22:54:06 +0100 Subject: Fix Sofle build, update Intro page. --- app/boards/shields/sofle/sofle.dtsi | 2 ++ docs/docs/feature/keymaps.md | 2 +- docs/docs/intro.md | 6 ++++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/boards/shields/sofle/sofle.dtsi b/app/boards/shields/sofle/sofle.dtsi index 653a772..bff42f6 100644 --- a/app/boards/shields/sofle/sofle.dtsi +++ b/app/boards/shields/sofle/sofle.dtsi @@ -50,6 +50,7 @@ RC(3,0) RC(3,1) RC(3,2) RC(3,3) RC(3,4) RC(3,5) RC(4,5) RC(4,6) RC(3,6) RC(3,7) a-gpios = <&pro_micro_a 3 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; b-gpios = <&pro_micro_a 2 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; resolution = <4>; + status = "disabled"; }; right_encoder: encoder_right { @@ -58,6 +59,7 @@ RC(3,0) RC(3,1) RC(3,2) RC(3,3) RC(3,4) RC(3,5) RC(4,5) RC(4,6) RC(3,6) RC(3,7) a-gpios = <&pro_micro_a 2 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; b-gpios = <&pro_micro_a 3 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; resolution = <4>; + status = "disabled"; }; sensors { diff --git a/docs/docs/feature/keymaps.md b/docs/docs/feature/keymaps.md index d991925..56fc2cc 100644 --- a/docs/docs/feature/keymaps.md +++ b/docs/docs/feature/keymaps.md @@ -55,7 +55,7 @@ in the stack _also_ get the event. ## Behavior Bindings Binding a behavior at a certain key position may include up to two extra parameters that are used to -alter the behavior when that specific key position is activated/deactived. For example, when binding +alter the behavior when that specific key position is activated/deactivated. For example, when binding the "key press" (`kp`) behavior at a certain key position, you must specific _which_ keycode should be used for that key position. diff --git a/docs/docs/intro.md b/docs/docs/intro.md index 29045f7..e75ca3c 100644 --- a/docs/docs/intro.md +++ b/docs/docs/intro.md @@ -18,21 +18,23 @@ include: - HID Over GATT (HOG) - This is the official term for BLE HID devices - Keymaps and layers with basic keycodes -- Some initial work on one "behavior", Mod-Tap +- Mod-Tap +- Layer Tap - Basic HID over USB - Basic consumer (media) keycodes. - Basic OLED display logic - Basic Split support +- Basic RGB Underglow - Encoders ## Missing Features - One Shot -- Layer Tap - Complete split support - Battery reporting - Low power mode - Shell over BLE +- Macros ## Code Of Conduct -- cgit v1.2.3 From 89d604b74bb3292af53dba7d67b2ae27edfed420 Mon Sep 17 00:00:00 2001 From: CrossR Date: Fri, 4 Sep 2020 19:31:04 +0100 Subject: Clarify low power mode wording. --- docs/docs/intro.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/intro.md b/docs/docs/intro.md index e75ca3c..e20f053 100644 --- a/docs/docs/intro.md +++ b/docs/docs/intro.md @@ -32,7 +32,7 @@ include: - One Shot - Complete split support - Battery reporting -- Low power mode +- Low power sleep states - Shell over BLE - Macros -- cgit v1.2.3 From df422e0205a63110094bf8bbe1a839ab52c97abb Mon Sep 17 00:00:00 2001 From: CrossR Date: Fri, 4 Sep 2020 20:45:10 +0100 Subject: Revert changes to Intro page. --- docs/docs/intro.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/docs/docs/intro.md b/docs/docs/intro.md index e20f053..29045f7 100644 --- a/docs/docs/intro.md +++ b/docs/docs/intro.md @@ -18,23 +18,21 @@ include: - HID Over GATT (HOG) - This is the official term for BLE HID devices - Keymaps and layers with basic keycodes -- Mod-Tap -- Layer Tap +- Some initial work on one "behavior", Mod-Tap - Basic HID over USB - Basic consumer (media) keycodes. - Basic OLED display logic - Basic Split support -- Basic RGB Underglow - Encoders ## Missing Features - One Shot +- Layer Tap - Complete split support - Battery reporting -- Low power sleep states +- Low power mode - Shell over BLE -- Macros ## Code Of Conduct -- cgit v1.2.3 From 4ce42350e70a7e4f6b9b7ad3b262d0f00f485995 Mon Sep 17 00:00:00 2001 From: kurtis-lew Date: Fri, 4 Sep 2020 20:28:45 -0700 Subject: Update iris_right.overlay --- app/boards/shields/iris/iris_right.overlay | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/boards/shields/iris/iris_right.overlay b/app/boards/shields/iris/iris_right.overlay index 3f3dcb8..2d5dce8 100644 --- a/app/boards/shields/iris/iris_right.overlay +++ b/app/boards/shields/iris/iris_right.overlay @@ -12,12 +12,12 @@ &kscan0 { col-gpios - = <&pro_micro_a 1 GPIO_ACTIVE_HIGH> - , <&pro_micro_a 0 GPIO_ACTIVE_HIGH> - , <&pro_micro_d 15 GPIO_ACTIVE_HIGH> - , <&pro_micro_d 14 GPIO_ACTIVE_HIGH> + = <&pro_micro_d 10 GPIO_ACTIVE_HIGH> , <&pro_micro_d 16 GPIO_ACTIVE_HIGH> - , <&pro_micro_d 10 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 14 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 15 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 0 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 1 GPIO_ACTIVE_HIGH> ; }; -- cgit v1.2.3 From 0559ec9013c02a878d94b0d7ad37fa2e9b00b58c Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Fri, 4 Sep 2020 23:58:31 -0400 Subject: fix(ci): Only run tests if app/{src,tests} changes --- .github/workflows/test.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3d2c76b..a6af058 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,12 @@ -on: [push, pull_request] +on: + push: + paths: + - "app/tests/**" + - "app/src/**" + pull_request: + paths: + - "app/tests/**" + - "app/src/**" name: Test -- cgit v1.2.3 From 80034c007826a026833d85d4fde7fc9be3898229 Mon Sep 17 00:00:00 2001 From: Richard Jones Date: Sun, 6 Sep 2020 15:51:12 +0100 Subject: Add RoMac / non-split template support --- docs/static/setup.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/static/setup.sh b/docs/static/setup.sh index 70defdf..83e7451 100644 --- a/docs/static/setup.sh +++ b/docs/static/setup.sh @@ -38,7 +38,7 @@ echo "" echo "Keyboard Shield Selection:" prompt="Pick an keyboard:" -options=("Kyria" "Lily58" "Corne" "Splitreus62" "Sofle" "Iris") +options=("Kyria" "Lily58" "Corne" "Splitreus62" "Sofle" "Iris" "RoMac") PS3="$prompt " # TODO: Add support for "Other" and linking to docs on adding custom shields in user config repos. @@ -53,6 +53,7 @@ select opt in "${options[@]}" "Quit"; do 4 ) shield_title="Splitreus62" shield="splitreus62"; split="y"; break;; 5 ) shield_title="Sofle" shield="sofle"; split="y"; break;; 6 ) shield_title="Iris" shield="iris"; split="y"; break;; + 7 ) shield_title="RoMac" shield="romac"; split="n"; break;; # Add link to docs on adding your own custom shield in your ZMK config! # $(( ${#options[@]}+1 )) ) echo "Other!"; break;; @@ -62,6 +63,10 @@ select opt in "${options[@]}" "Quit"; do esac done +if [ "$split" == "n" ]; then + repo_path="https://github.com/bmcgavin/zmk-config-template.git" +fi + read -e -p "Copy in the stock keymap for customization? [Yn]: " copy_keymap if [ -z "$copy_keymap" ] || [ "$copy_keymap" == "Y" ] || [ "$copy_keymap" == "y" ]; then copy_keymap="yes"; fi -- cgit v1.2.3 From 01da54aadfe1ed9027e71754f9d897f68da900ea Mon Sep 17 00:00:00 2001 From: Richard Jones Date: Sun, 6 Sep 2020 17:54:45 +0100 Subject: point setup.sh at upstream --- docs/static/setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/static/setup.sh b/docs/static/setup.sh index 83e7451..5d203a4 100644 --- a/docs/static/setup.sh +++ b/docs/static/setup.sh @@ -64,7 +64,7 @@ select opt in "${options[@]}" "Quit"; do done if [ "$split" == "n" ]; then - repo_path="https://github.com/bmcgavin/zmk-config-template.git" + repo_path="https://github.com/zmkfirmware/zmk-config-template.git" fi read -e -p "Copy in the stock keymap for customization? [Yn]: " copy_keymap -- cgit v1.2.3 From bdeb6865e18c211a2d26a1f007711710f489db27 Mon Sep 17 00:00:00 2001 From: kurtis-lew Date: Sun, 6 Sep 2020 19:55:56 -0700 Subject: Update sidebars.js --- docs/sidebars.js | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/sidebars.js b/docs/sidebars.js index 3df183b..7da0f5b 100644 --- a/docs/sidebars.js +++ b/docs/sidebars.js @@ -7,6 +7,7 @@ module.exports = { "user-setup", "customization", "bond-reset", + "troubleshooting" ], Features: [ "feature/keymaps", -- cgit v1.2.3 From cb95b9f11a687cb165adaffdeed866e80c7fdc7b Mon Sep 17 00:00:00 2001 From: kurtis-lew Date: Sun, 6 Sep 2020 20:03:33 -0700 Subject: Restored Troubleshooting.md and associated files --- .../assets/troubleshooting/keymaps/errorscreen.png | Bin 0 -> 186351 bytes .../assets/troubleshooting/keymaps/healthyEDIT.png | Bin 0 -> 188078 bytes .../troubleshooting/keymaps/unhealthyEDIT.png | Bin 0 -> 187729 bytes docs/docs/behavior/key-press.md | 7 ++++- docs/docs/troubleshooting.md | 33 +++++++++++++++++++++ 5 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 docs/docs/assets/troubleshooting/keymaps/errorscreen.png create mode 100644 docs/docs/assets/troubleshooting/keymaps/healthyEDIT.png create mode 100644 docs/docs/assets/troubleshooting/keymaps/unhealthyEDIT.png create mode 100644 docs/docs/troubleshooting.md diff --git a/docs/docs/assets/troubleshooting/keymaps/errorscreen.png b/docs/docs/assets/troubleshooting/keymaps/errorscreen.png new file mode 100644 index 0000000..73b5b58 Binary files /dev/null and b/docs/docs/assets/troubleshooting/keymaps/errorscreen.png differ diff --git a/docs/docs/assets/troubleshooting/keymaps/healthyEDIT.png b/docs/docs/assets/troubleshooting/keymaps/healthyEDIT.png new file mode 100644 index 0000000..50d2c73 Binary files /dev/null and b/docs/docs/assets/troubleshooting/keymaps/healthyEDIT.png differ diff --git a/docs/docs/assets/troubleshooting/keymaps/unhealthyEDIT.png b/docs/docs/assets/troubleshooting/keymaps/unhealthyEDIT.png new file mode 100644 index 0000000..3fd8dc7 Binary files /dev/null and b/docs/docs/assets/troubleshooting/keymaps/unhealthyEDIT.png differ diff --git a/docs/docs/behavior/key-press.md b/docs/docs/behavior/key-press.md index f58225d..d427f9d 100644 --- a/docs/docs/behavior/key-press.md +++ b/docs/docs/behavior/key-press.md @@ -27,6 +27,11 @@ There is an [open issue](https://github.com/zmkfirmware/zmk/issues/21) to provid complete set of defines for the full keypad and consumer usage pages in the future for ZMK. ::: +### Improperly defined keymap - `dtlib.DTError: .dts.pre.tmp:` + +When compiling firmware from a keymap, it may be common to encounter an error in the form of a`dtlib.DTError: .dts.pre.tmp:`. +For instructions to resolve such an error, click [here](../troubleshooting###Improperly-defined-keymap) + ## Keypad Key Press The "keypad key press" behavior sends standard keypad keycodes on press/release. @@ -59,4 +64,4 @@ Example: ``` &cp M_PREV -``` +``` \ No newline at end of file diff --git a/docs/docs/troubleshooting.md b/docs/docs/troubleshooting.md new file mode 100644 index 0000000..cecee25 --- /dev/null +++ b/docs/docs/troubleshooting.md @@ -0,0 +1,33 @@ +--- +id: troubleshooting +title: Troubleshooting +sidebar_title: Troubleshooting +--- +### Summary + +The following page provides suggestions for common errors that may occur during firmware compilation. If the information provided is insufficient to resolve the issue, feel free to seek out help from the [ZMK Discord](https://zmkfirmware.dev/community/discord/invite). + +### Environment Variables not Defined + +An error along the lines of `CMake Error at (zmk directory)/zephyr/cmake/generic_toolchain.cmake:64 (include): include could not find load file:` during firmware compilation indicates that the Zephyr Environment Variables are not properly defined. +For more information, click [here](../docs/dev-setup#environment-variables). + +### Improperly defined keymap + +An error along the lines of `dtlib.DTError: .dts.pre.tmp:` during firmware compilation indicates an issue within the `.keymap` file. +This can be verified by checking the file in question, found in `mkdir/app/build`. + +| ![Example Error Screen](../docs/assets/troubleshooting/keymaps/errorscreen.png) | +| :-------------------------------------------------------------------------------: | +| An example of the dtlib.DTError when compiling an iris with the nice!nano while the keymap is not properly defined | + +After opening the `.dts.pre.tmp:` and scrolling down to the referenced line, one can locate errors within their shield's keymap by checking if the referenced keycodes were properly converted into the correct [USB HID Usage ID](https://www.usb.org/document-library/hid-usage-tables-12). + +| ![Unhealthy Keymap Temp](../docs/assets/troubleshooting/keymaps/unhealthyEDIT.png) | +| :-------------------------------------------------------------------------------: | +| An incorrectly defined keymap unable to compile. As shown in red, `&kp SPAC` is not a valid +reference to the [USB HID Usage ID](https://www.usb.org/document-library/hid-usage-tables-12) used for "Keyboard Spacebar" | + +| ![Healthy Keymap Temp](../docs/assets/troubleshooting/keymaps/healthyEDIT.png) | +| :-------------------------------------------------------------------------------: | +| A properly defined keymap with successful compilation. As shown in red, the corrected keycode (`&kp SPC`) references the proper Usage ID defined in the [USB HID Usage Tables](https://www.usb.org/document-library/hid-usage-tables-12)| \ No newline at end of file -- cgit v1.2.3 From 336cae9d0fd0aa84a30768f2629bbbf357e8cdaa Mon Sep 17 00:00:00 2001 From: kurtis-lew Date: Sun, 6 Sep 2020 20:13:45 -0700 Subject: Adjusted lines to fix caption format --- docs/docs/troubleshooting.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/docs/troubleshooting.md b/docs/docs/troubleshooting.md index cecee25..61c6e79 100644 --- a/docs/docs/troubleshooting.md +++ b/docs/docs/troubleshooting.md @@ -24,9 +24,8 @@ This can be verified by checking the file in question, found in `mkdir/app/build After opening the `.dts.pre.tmp:` and scrolling down to the referenced line, one can locate errors within their shield's keymap by checking if the referenced keycodes were properly converted into the correct [USB HID Usage ID](https://www.usb.org/document-library/hid-usage-tables-12). | ![Unhealthy Keymap Temp](../docs/assets/troubleshooting/keymaps/unhealthyEDIT.png) | -| :-------------------------------------------------------------------------------: | -| An incorrectly defined keymap unable to compile. As shown in red, `&kp SPAC` is not a valid -reference to the [USB HID Usage ID](https://www.usb.org/document-library/hid-usage-tables-12) used for "Keyboard Spacebar" | +| :-------------------------------------------------------------------------------: | +| An incorrectly defined keymap unable to compile. As shown in red, `&kp SPAC` is not a valid reference to the [USB HID Usage ID](https://www.usb.org/document-library/hid-usage-tables-12) used for "Keyboard Spacebar" | | ![Healthy Keymap Temp](../docs/assets/troubleshooting/keymaps/healthyEDIT.png) | | :-------------------------------------------------------------------------------: | -- cgit v1.2.3 From 618c537be14e3bf8ba0515784078df1b42c60915 Mon Sep 17 00:00:00 2001 From: Kurtis Lew Date: Sun, 6 Sep 2020 20:45:28 -0700 Subject: Updated Headers --- docs/docs/troubleshooting.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/docs/troubleshooting.md b/docs/docs/troubleshooting.md index 61c6e79..cd8bfd6 100644 --- a/docs/docs/troubleshooting.md +++ b/docs/docs/troubleshooting.md @@ -7,12 +7,12 @@ sidebar_title: Troubleshooting The following page provides suggestions for common errors that may occur during firmware compilation. If the information provided is insufficient to resolve the issue, feel free to seek out help from the [ZMK Discord](https://zmkfirmware.dev/community/discord/invite). -### Environment Variables not Defined +### CMake Error An error along the lines of `CMake Error at (zmk directory)/zephyr/cmake/generic_toolchain.cmake:64 (include): include could not find load file:` during firmware compilation indicates that the Zephyr Environment Variables are not properly defined. For more information, click [here](../docs/dev-setup#environment-variables). -### Improperly defined keymap +### dtlib.DTError An error along the lines of `dtlib.DTError: .dts.pre.tmp:` during firmware compilation indicates an issue within the `.keymap` file. This can be verified by checking the file in question, found in `mkdir/app/build`. @@ -29,4 +29,4 @@ After opening the `.dts.pre.tmp:` and scrolling down to the | ![Healthy Keymap Temp](../docs/assets/troubleshooting/keymaps/healthyEDIT.png) | | :-------------------------------------------------------------------------------: | -| A properly defined keymap with successful compilation. As shown in red, the corrected keycode (`&kp SPC`) references the proper Usage ID defined in the [USB HID Usage Tables](https://www.usb.org/document-library/hid-usage-tables-12)| \ No newline at end of file +| A properly defined keymap with successful compilation. As shown in red, the corrected keycode (`&kp SPC`) references the proper Usage ID defined in the [USB HID Usage Tables](https://www.usb.org/document-library/hid-usage-tables-12)| -- cgit v1.2.3 From 6b433fdefd0793e836574f528445b7d4b6d781bc Mon Sep 17 00:00:00 2001 From: Nick Date: Mon, 7 Sep 2020 12:24:47 -0500 Subject: Finish DZ60RGB board definition --- app/boards/arm/dz60rgb/CMakeLists.txt | 2 -- app/boards/arm/dz60rgb/board.cmake | 3 ++- app/boards/arm/dz60rgb/dz60rgb_rev1.dts | 5 ++-- app/boards/arm/dz60rgb/dz60rgb_rev1.keymap | 25 ++++++++++++++++++ app/boards/arm/dz60rgb/dz60rgb_rev1_defconfig | 3 --- app/boards/arm/dz60rgb/keymap/keymap.overlay | 37 --------------------------- app/boards/arm/dz60rgb/pinmux.c | 32 +++++++++++------------ 7 files changed, 46 insertions(+), 61 deletions(-) create mode 100644 app/boards/arm/dz60rgb/dz60rgb_rev1.keymap delete mode 100644 app/boards/arm/dz60rgb/keymap/keymap.overlay diff --git a/app/boards/arm/dz60rgb/CMakeLists.txt b/app/boards/arm/dz60rgb/CMakeLists.txt index 6a0ec73..940af1f 100644 --- a/app/boards/arm/dz60rgb/CMakeLists.txt +++ b/app/boards/arm/dz60rgb/CMakeLists.txt @@ -1,7 +1,5 @@ # SPDX-License-Identifier: MIT -list(APPEND EXTRA_DTC_FLAGS "-qq") - if(CONFIG_PINMUX) zephyr_library() zephyr_library_sources(pinmux.c) diff --git a/app/boards/arm/dz60rgb/board.cmake b/app/boards/arm/dz60rgb/board.cmake index 4843c41..10f6e29 100644 --- a/app/boards/arm/dz60rgb/board.cmake +++ b/app/boards/arm/dz60rgb/board.cmake @@ -1,6 +1,7 @@ # SPDX-License-Identifier: MIT -board_runner_args(jlink "--device=STM32F303VC" "--speed=4000") +board_runner_args(dfu-util "--pid=0483:df11" "--alt=0" "--dfuse") +board_runner_args(jlink "--device=STM32F303CC" "--speed=4000") include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake) include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake) diff --git a/app/boards/arm/dz60rgb/dz60rgb_rev1.dts b/app/boards/arm/dz60rgb/dz60rgb_rev1.dts index 8066b5a..dc1b6ea 100644 --- a/app/boards/arm/dz60rgb/dz60rgb_rev1.dts +++ b/app/boards/arm/dz60rgb/dz60rgb_rev1.dts @@ -17,6 +17,7 @@ zephyr,sram = &sram0; zephyr,flash = &flash0; zmk,kscan = &kscan0; + zmk,matrix_transform = &default_transform; }; default_transform: keymap_transform_0 { @@ -28,7 +29,7 @@ RC(0,0) RC(0,1) RC(0,2) RC(0,3) RC(0,4) RC(0,5) RC(0,6) RC(0,7) RC(0,8) RC(0,9) RC(1,0) RC(1,1) RC(1,2) RC(1,3) RC(1,4) RC(1,5) RC(1,6) RC(1,7) RC(1,8) RC(1,9) RC(1,10) RC(1,11) RC(1,12) RC(1,13) RC(2,0) RC(2,1) RC(2,2) RC(2,3) RC(2,4) RC(2,5) RC(2,6) RC(2,7) RC(2,8) RC(2,9) RC(2,10) RC(2,11) RC(2,13) RC(3,0) RC(3,1) RC(3,2) RC(3,3) RC(3,4) RC(3,5) RC(3,6) RC(3,7) RC(3,8) RC(3,9) RC(3,10) RC(3,11) RC(3,13) -RC(4,0) RC(4,1) RC(4,2) RC(4,5) RC(4,9) RC(4,10) RC(4,11) RC(4,12) RC(4,13) +RC(4,0) RC(4,1) RC(4,2) RC(4,5) RC(4,8) RC(4,9) RC(4,10) RC(4,11) RC(4,13) >; }; @@ -55,7 +56,7 @@ RC(4,0) RC(4,1) RC(4,2) RC(4,5) RC(4 , <&gpiob 3 GPIO_ACTIVE_HIGH> , <&gpiob 4 GPIO_ACTIVE_HIGH> , <&gpiob 5 GPIO_ACTIVE_HIGH> - , <&gpiob 6 GPIO_ACTIVE_HIGH> + , <&gpiob 8 GPIO_ACTIVE_HIGH> , <&gpiob 9 GPIO_ACTIVE_HIGH> , <&gpioc 13 GPIO_ACTIVE_HIGH> , <&gpioc 14 GPIO_ACTIVE_HIGH> diff --git a/app/boards/arm/dz60rgb/dz60rgb_rev1.keymap b/app/boards/arm/dz60rgb/dz60rgb_rev1.keymap new file mode 100644 index 0000000..8de01c1 --- /dev/null +++ b/app/boards/arm/dz60rgb/dz60rgb_rev1.keymap @@ -0,0 +1,25 @@ +#include +#include + +/ { + keymap { + compatible = "zmk,keymap"; + + default_layer { +// ------------------------------------------------------------------------------------------ +// | ESC | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | BKSP | +// | TAB | Q | W | E | R | T | Y | U | I | O | P | [ | ] | "|" | +// | CAPS | A | S | D | F | G | H | J | K | L | ; | ' | ENTER | +// | SHIFT | Z | X | C | V | B | N | M | , | . | SHIFT(/) | ^ | DEL | +// | CTL | WIN | ALT | SPACE | ALT | MO(1) | <- | v | -> | +// ------------------------------------------------------------------------------------------ + bindings = < + &kp ESC &kp NUM_1 &kp NUM_2 &kp NUM_3 &kp NUM_4 &kp NUM_5 &kp NUM_6 &kp NUM_7 &kp NUM_8 &kp NUM_9 &kp NUM_0 &kp MINUS &kp EQL &kp BKSP + &kp TAB &kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P &kp LBKT &kp RBKT &kp BSLH + &kp CLCK &kp A &kp S &kp D &kp F &kp G &kp H &kp J &kp K &kp L &kp SCLN &kp QUOT &kp RET + &kp LSFT &kp Z &kp X &kp C &kp V &kp B &kp N &kp M &kp CMMA &kp DOT &mt MOD_RSFT FSLH &kp UARW &kp DEL + &kp LCTL &kp LGUI &kp LALT &kp SPC &kp RALT &mo 1 &kp LARW &kp DARW &kp RARW + >; + }; + }; +}; \ No newline at end of file diff --git a/app/boards/arm/dz60rgb/dz60rgb_rev1_defconfig b/app/boards/arm/dz60rgb/dz60rgb_rev1_defconfig index 5a4c099..33840f9 100644 --- a/app/boards/arm/dz60rgb/dz60rgb_rev1_defconfig +++ b/app/boards/arm/dz60rgb/dz60rgb_rev1_defconfig @@ -19,9 +19,6 @@ CONFIG_CLOCK_STM32_HSE_CLOCK=8000000 CONFIG_CLOCK_STM32_SYSCLK_SRC_PLL=y # use HSE as PLL input CONFIG_CLOCK_STM32_PLL_SRC_HSE=y -# however, the board does not have an external oscillator, so just use -# the 8MHz clock signal coming from integrated STLink -CONFIG_CLOCK_STM32_HSE_BYPASS=y # produce 72MHz clock at PLL output CONFIG_CLOCK_STM32_PLL_PREDIV=1 CONFIG_CLOCK_STM32_PLL_MULTIPLIER=9 diff --git a/app/boards/arm/dz60rgb/keymap/keymap.overlay b/app/boards/arm/dz60rgb/keymap/keymap.overlay deleted file mode 100644 index 9d83adc..0000000 --- a/app/boards/arm/dz60rgb/keymap/keymap.overlay +++ /dev/null @@ -1,37 +0,0 @@ -#include -#include -#include - -/ { - chosen { - zmk,keymap = &keymap0; - }; - - keymap0: keymap { - compatible = "zmk,keymap"; - label ="Default DZ60RGB Keymap"; - layers = <&default>; - }; - - layers { - compatible = "zmk,layers"; - - default: layer_0 { - label = "DEFAULT"; -// ------------------------------------------------------------------------------------------ -// | ESC | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | BKSP | -// | TAB | Q | W | E | R | T | Y | U | I | O | P | [ | ] | "|" | -// | CAPS | A | S | D | F | G | H | J | K | L | ; | ' | ENTER | -// | SHIFT | Z | X | C | V | B | N | M | , | . | SHIFT(/) | ^ | DEL | -// | CTL | WIN | ALT | SPACE | ALT | MO(1) | <- | v | -> | -// ------------------------------------------------------------------------------------------ - bindings = < - &kp ESC &kp NUM_1 &kp NUM_2 &kp NUM_3 &kp NUM_4 &kp NUM_5 &kp NUM_6 &kp NUM_7 &kp NUM_8 &kp NUM_9 &kp NUM_0 &kp MINUS &kp EQL &kp BKSP - &kp TAB &kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P &kp LBKT &kp RBKT &kp BSLH - &kp CLCK &kp A &kp S &kp D &kp F &kp G &kp H &kp J &kp K &kp L &kp SCLN &kp QUOT &kp RET - &kp LSFT &kp Z &kp X &kp C &kp V &kp B &kp N &kp M &kp CMMA &kp DOT &mt MOD_RSFT FSLH &kp UARW &kp DEL - &kp LCTL &kp LGUI &kp LALT &kp SPC &kp RALT &mo 1 &kp LARW &kp DARW &kp RARW - >; - }; - }; -}; diff --git a/app/boards/arm/dz60rgb/pinmux.c b/app/boards/arm/dz60rgb/pinmux.c index 5df5c90..60e231b 100644 --- a/app/boards/arm/dz60rgb/pinmux.c +++ b/app/boards/arm/dz60rgb/pinmux.c @@ -14,46 +14,46 @@ /* pin assignments for STM32F3DISCOVERY board */ static const struct pin_config pinconf[] = { -#ifdef CONFIG_UART_1 +#if DT_NODE_HAS_STATUS(DT_NODELABEL(usart1), okay) && CONFIG_SERIAL {STM32_PIN_PC4, STM32F3_PINMUX_FUNC_PC4_USART1_TX}, {STM32_PIN_PC5, STM32F3_PINMUX_FUNC_PC5_USART1_RX}, -#endif /* CONFIG_UART_1 */ -#ifdef CONFIG_UART_2 +#endif +#if DT_NODE_HAS_STATUS(DT_NODELABEL(usart2), okay) && CONFIG_SERIAL {STM32_PIN_PA2, STM32F3_PINMUX_FUNC_PA2_USART2_TX}, {STM32_PIN_PA3, STM32F3_PINMUX_FUNC_PA3_USART2_RX}, -#endif /* CONFIG_UART_2 */ -#ifdef CONFIG_I2C_1 +#endif +#if DT_NODE_HAS_STATUS(DT_NODELABEL(i2c1), okay) && CONFIG_I2C {STM32_PIN_PB6, STM32F3_PINMUX_FUNC_PB6_I2C1_SCL}, {STM32_PIN_PB7, STM32F3_PINMUX_FUNC_PB7_I2C1_SDA}, -#endif /* CONFIG_I2C_1 */ -#ifdef CONFIG_I2C_2 +#endif +#if DT_NODE_HAS_STATUS(DT_NODELABEL(i2c2), okay) && CONFIG_I2C {STM32_PIN_PA9, STM32F3_PINMUX_FUNC_PA9_I2C2_SCL}, {STM32_PIN_PA10, STM32F3_PINMUX_FUNC_PA10_I2C2_SDA}, -#endif /* CONFIG_I2C_2 */ -#ifdef CONFIG_SPI_1 +#endif +#if DT_NODE_HAS_STATUS(DT_NODELABEL(spi1), okay) && CONFIG_SPI #ifdef CONFIG_SPI_STM32_USE_HW_SS {STM32_PIN_PA4, STM32F3_PINMUX_FUNC_PA4_SPI1_NSS}, #endif /* CONFIG_SPI_STM32_USE_HW_SS */ {STM32_PIN_PA5, STM32F3_PINMUX_FUNC_PA5_SPI1_SCK}, {STM32_PIN_PA6, STM32F3_PINMUX_FUNC_PA6_SPI1_MISO}, {STM32_PIN_PA7, STM32F3_PINMUX_FUNC_PA7_SPI1_MOSI}, -#endif /* CONFIG_SPI_1 */ -#ifdef CONFIG_SPI_2 +#endif +#if DT_NODE_HAS_STATUS(DT_NODELABEL(spi2), okay) && CONFIG_SPI #ifdef CONFIG_SPI_STM32_USE_HW_SS {STM32_PIN_PB12, STM32F3_PINMUX_FUNC_PB12_SPI2_NSS}, #endif /* CONFIG_SPI_STM32_USE_HW_SS */ {STM32_PIN_PB13, STM32F3_PINMUX_FUNC_PB13_SPI2_SCK}, {STM32_PIN_PB14, STM32F3_PINMUX_FUNC_PB14_SPI2_MISO}, {STM32_PIN_PB15, STM32F3_PINMUX_FUNC_PB15_SPI2_MOSI}, -#endif /* CONFIG_SPI_2 */ +#endif #ifdef CONFIG_USB_DC_STM32 {STM32_PIN_PA11, STM32F3_PINMUX_FUNC_PA11_USB_DM}, {STM32_PIN_PA12, STM32F3_PINMUX_FUNC_PA12_USB_DP}, -#endif /* CONFIG_USB_DC_STM32 */ -#ifdef CONFIG_CAN_1 +#endif /* CONFIG_USB_DC_STM32 */ +#if DT_NODE_HAS_STATUS(DT_NODELABEL(can1), okay) && CONFIG_CAN {STM32_PIN_PD0, STM32F3_PINMUX_FUNC_PD0_CAN1_RX}, {STM32_PIN_PD1, STM32F3_PINMUX_FUNC_PD1_CAN1_TX}, -#endif /* CONFIG_CAN_1 */ +#endif }; static int pinmux_stm32_init(struct device *port) @@ -66,4 +66,4 @@ static int pinmux_stm32_init(struct device *port) } SYS_INIT(pinmux_stm32_init, PRE_KERNEL_1, - CONFIG_PINMUX_STM32_DEVICE_INITIALIZATION_PRIORITY); + CONFIG_PINMUX_STM32_DEVICE_INITIALIZATION_PRIORITY); \ No newline at end of file -- cgit v1.2.3 From e845995c2d5ea90327e68495569f7d1a25242ee2 Mon Sep 17 00:00:00 2001 From: Nick Date: Mon, 7 Sep 2020 12:25:11 -0500 Subject: Fix Planck defconfig --- app/boards/arm/planck/planck_rev6_defconfig | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/boards/arm/planck/planck_rev6_defconfig b/app/boards/arm/planck/planck_rev6_defconfig index a440ff1..e34ce00 100644 --- a/app/boards/arm/planck/planck_rev6_defconfig +++ b/app/boards/arm/planck/planck_rev6_defconfig @@ -20,9 +20,6 @@ CONFIG_CLOCK_STM32_HSE_CLOCK=8000000 CONFIG_CLOCK_STM32_SYSCLK_SRC_PLL=y # use HSE as PLL input CONFIG_CLOCK_STM32_PLL_SRC_HSE=y -# however, the board does not have an external oscillator, so just use -# the 8MHz clock signal coming from integrated STLink -CONFIG_CLOCK_STM32_HSE_BYPASS=y # produce 72MHz clock at PLL output CONFIG_CLOCK_STM32_PLL_PREDIV=1 CONFIG_CLOCK_STM32_PLL_MULTIPLIER=9 -- cgit v1.2.3 From ceda57ddfd7b49dd61e8795c37cd678b69a4a76f Mon Sep 17 00:00:00 2001 From: Nick Date: Mon, 7 Sep 2020 12:32:25 -0500 Subject: Fix comment name of keyboard --- app/boards/arm/dz60rgb/Kconfig.defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/boards/arm/dz60rgb/Kconfig.defconfig b/app/boards/arm/dz60rgb/Kconfig.defconfig index cfa71d3..c97a308 100644 --- a/app/boards/arm/dz60rgb/Kconfig.defconfig +++ b/app/boards/arm/dz60rgb/Kconfig.defconfig @@ -1,4 +1,4 @@ -# Planck keyboard configuration +# DZ60RGB keyboard configuration # Copyright (c) 2020 Nick Winans # SPDX-License-Identifier: MIT -- cgit v1.2.3 From a65de800bf8779191c6b0e6ef17f12d1559389e1 Mon Sep 17 00:00:00 2001 From: Cody McGinnis Date: Tue, 8 Sep 2020 12:00:46 -0400 Subject: fix(tests): pending tests pass now --- app/tests/momentary-layer/early-key-release/pending | 0 app/tests/toggle-layer/early-key-release/pending | 0 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 app/tests/momentary-layer/early-key-release/pending delete mode 100644 app/tests/toggle-layer/early-key-release/pending diff --git a/app/tests/momentary-layer/early-key-release/pending b/app/tests/momentary-layer/early-key-release/pending deleted file mode 100644 index e69de29..0000000 diff --git a/app/tests/toggle-layer/early-key-release/pending b/app/tests/toggle-layer/early-key-release/pending deleted file mode 100644 index e69de29..0000000 -- cgit v1.2.3 From df2da813f1f50dbd20ef226a439208fbf5d23c17 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Tue, 8 Sep 2020 16:08:09 -0400 Subject: fix(docs): Remove broken Discord invite links. --- docs/docs/faq.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/docs/faq.md b/docs/docs/faq.md index 2ab158d..d8bbd71 100644 --- a/docs/docs/faq.md +++ b/docs/docs/faq.md @@ -76,7 +76,7 @@ Please note, many keyboards only have a single PCB which includes the “brains ### What bootloader does ZMK use? -ZMK isn’t designed for any particular bootloader, and supports flashing different boards with different flash utilities (e.g. OpenOCD, nrfjprog, etc.). So if you have any difficulties, please let us know on [Discord](https://discord.gg/VJnx9kr)! +ZMK isn’t designed for any particular bootloader, and supports flashing different boards with different flash utilities (e.g. OpenOCD, nrfjprog, etc.). So if you have any difficulties, please let us know on [Discord](https://zmkfirmware.dev/community/discord/invite)! ### Can I contribute? @@ -84,11 +84,11 @@ Of course! Please use the developer [documentation](/docs) to get started! ### I have an idea! What should I do? -Please join us on [Discord](https://discord.gg/VJnx9kr) and discuss it with us! +Please join us on [Discord](https://zmkfirmware.dev/community/discord/invite) and discuss it with us! ### I want to add a new keyboard! What should I do? -The exact process for the management of all the possible hardware is still being finalized, but any developer looking to contribute new keyboard definitions should chat with us on [Discord](https://discord.gg/VJnx9kr) to get started. +The exact process for the management of all the possible hardware is still being finalized, but any developer looking to contribute new keyboard definitions should chat with us on [Discord](https://zmkfirmware.dev/community/discord/invite) to get started. ### Does ZMK have a Code of Conduct? -- cgit v1.2.3 From 6456fab8e0278d3cd5b73ef4ddca49845c00c19d Mon Sep 17 00:00:00 2001 From: Alexander Elias Date: Wed, 9 Sep 2020 09:14:01 -0700 Subject: Should this be org instead of com? --- docs/docs/intro.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/intro.md b/docs/docs/intro.md index 29045f7..50a747c 100644 --- a/docs/docs/intro.md +++ b/docs/docs/intro.md @@ -5,7 +5,7 @@ sidebar_label: Introduction --- ZMK Firmware is an open source (MIT) keyboard -firmware built on the [Zephyr™ Project](https://zephyrproject.com/) Real Time Operating System (RTOS). +firmware built on the [Zephyr™ Project](https://zephyrproject.org/) Real Time Operating System (RTOS). The goal is to provider a powerful, featureful keyboard firmware that is free of licensing issues that prevent upstream BLE support as a first-class -- cgit v1.2.3 From 6a0e85ea726ac49bb95bdfd1c7770f7da826bf1a Mon Sep 17 00:00:00 2001 From: Mamoor Jaan Khan <56243233+LowNightSnack@users.noreply.github.com> Date: Thu, 10 Sep 2020 09:54:22 +0530 Subject: labelled image to be added --- docs/docs/pro-micro-labelled-image.jpg | Bin 0 -> 115573 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 docs/docs/pro-micro-labelled-image.jpg diff --git a/docs/docs/pro-micro-labelled-image.jpg b/docs/docs/pro-micro-labelled-image.jpg new file mode 100644 index 0000000..f72d407 Binary files /dev/null and b/docs/docs/pro-micro-labelled-image.jpg differ -- cgit v1.2.3 From 82ddf81fcb4f1f5e629fe2c2dd0c8c0ba803964f Mon Sep 17 00:00:00 2001 From: Mamoor Jaan Khan <56243233+LowNightSnack@users.noreply.github.com> Date: Thu, 10 Sep 2020 09:59:33 +0530 Subject: Update dev-guide-new-shield.md --- docs/docs/dev-guide-new-shield.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/docs/dev-guide-new-shield.md b/docs/docs/dev-guide-new-shield.md index bc5175b..8aa62da 100644 --- a/docs/docs/dev-guide-new-shield.md +++ b/docs/docs/dev-guide-new-shield.md @@ -64,6 +64,8 @@ endif ## Shield Overlay +![Labelled Pro Micro Image](pro-micro-labelled-image.jpg) + The `.overlay` is the devicetree description of the keyboard shield that is merged with the primary board devicetree description before the build. For ZMK, this file at a minimum should include the [chosen]() node named `zmk,kscan` that references a KSCAN driver instance. For a simple 3x3 macropad matrix, this might look something like: -- cgit v1.2.3 From d02fc07c4f53868cc0b498cdc2fb6b0768cbe8cb Mon Sep 17 00:00:00 2001 From: Mamoor Jaan Khan <56243233+LowNightSnack@users.noreply.github.com> Date: Thu, 10 Sep 2020 10:02:25 +0530 Subject: Update dev-boards-shields-keymaps.md --- docs/docs/dev-boards-shields-keymaps.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/docs/dev-boards-shields-keymaps.md b/docs/docs/dev-boards-shields-keymaps.md index cfe5252..9810558 100644 --- a/docs/docs/dev-boards-shields-keymaps.md +++ b/docs/docs/dev-boards-shields-keymaps.md @@ -35,6 +35,8 @@ in the `app/boards/${arch}/${board_name}` directory, e.g. `app/boards/arm/planck ## Pro Micro Compatible Keyboard +![Labelled Pro Micro Image](pro-micro-labelled-image.jpg) + For keyboards that require a (usually Pro Micro compatible) add-on board to operate, the ZMK integration pieces are places in the _shield_ definition for that keyboard, allowing users to swap in different Pro Micro compatible boards (e.g. Proton-C, or nice!nano) and build a firmware the matches their actual -- cgit v1.2.3 From 3c9f58f9d40d21f5c0bec20b6da75e135503af0a Mon Sep 17 00:00:00 2001 From: Mamoor Jaan Khan <56243233+LowNightSnack@users.noreply.github.com> Date: Thu, 10 Sep 2020 10:03:48 +0530 Subject: Update dev-boards-shields-keymaps.md --- docs/docs/dev-boards-shields-keymaps.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/dev-boards-shields-keymaps.md b/docs/docs/dev-boards-shields-keymaps.md index 9810558..17a3847 100644 --- a/docs/docs/dev-boards-shields-keymaps.md +++ b/docs/docs/dev-boards-shields-keymaps.md @@ -35,7 +35,7 @@ in the `app/boards/${arch}/${board_name}` directory, e.g. `app/boards/arm/planck ## Pro Micro Compatible Keyboard -![Labelled Pro Micro Image](pro-micro-labelled-image.jpg) +![Labelled Pro Micro pins](pro-micro-labelled-image.jpg) For keyboards that require a (usually Pro Micro compatible) add-on board to operate, the ZMK integration pieces are places in the _shield_ definition for that keyboard, allowing users to -- cgit v1.2.3 From 92b3ea8a6b75764acab216470050c8138acf2643 Mon Sep 17 00:00:00 2001 From: Mamoor Jaan Khan <56243233+LowNightSnack@users.noreply.github.com> Date: Thu, 10 Sep 2020 10:04:15 +0530 Subject: Update dev-guide-new-shield.md --- docs/docs/dev-guide-new-shield.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/dev-guide-new-shield.md b/docs/docs/dev-guide-new-shield.md index 8aa62da..23d2387 100644 --- a/docs/docs/dev-guide-new-shield.md +++ b/docs/docs/dev-guide-new-shield.md @@ -64,7 +64,7 @@ endif ## Shield Overlay -![Labelled Pro Micro Image](pro-micro-labelled-image.jpg) +![Labelled Pro Micro pins](pro-micro-labelled-image.jpg) The `.overlay` is the devicetree description of the keyboard shield that is merged with the primary board devicetree description before the build. For ZMK, this file at a minimum should include the [chosen]() node named `zmk,kscan` that references a KSCAN driver instance. For a simple 3x3 macropad matrix, this might look something like: -- cgit v1.2.3 From 68e72f9275401c3cb7541259c692a704cbfc5e82 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Wed, 9 Sep 2020 23:57:44 -0400 Subject: fix: Switch to single AUTHORS file.* Closes #164 --- AUTHORS | 11 +++++++++++ app/boards/arm/dz60rgb/Kconfig.board | 2 +- app/boards/arm/dz60rgb/Kconfig.defconfig | 2 +- app/boards/arm/dz60rgb/dz60rgb_rev1.dts | 2 +- app/boards/arm/nrfmicro/Kconfig.board | 2 +- app/boards/arm/nrfmicro/Kconfig.defconfig | 2 +- app/boards/arm/nrfmicro/arduino_pro_micro_pins.dtsi | 2 +- app/boards/arm/nrfmicro/arduino_pro_micro_pins_flipped.dtsi | 2 +- app/boards/arm/nrfmicro/nrfmicro_11.dts | 2 +- app/boards/arm/nrfmicro/nrfmicro_11_flipped.dts | 2 +- app/boards/arm/nrfmicro/nrfmicro_13.dts | 2 +- app/boards/arm/nrfmicro/pinmux.c | 2 +- app/boards/arm/planck/Kconfig.board | 2 +- app/boards/arm/planck/Kconfig.defconfig | 2 +- app/drivers/zephyr/ec11.c | 2 +- app/drivers/zephyr/ec11.h | 2 +- app/drivers/zephyr/ec11_trigger.c | 2 +- app/drivers/zephyr/kscan_gpio_direct.c | 2 +- app/drivers/zephyr/kscan_gpio_matrix.c | 2 +- app/dts/behaviors/toggle_layer.dtsi | 6 +++--- app/dts/bindings/behaviors/zmk,behavior-hold-tap.yaml | 10 +++++----- app/dts/bindings/behaviors/zmk,behavior-rgb-underglow.yaml | 4 ++-- app/dts/bindings/behaviors/zmk,behavior-toggle-layer.yaml | 2 +- app/include/drivers/behavior.h | 2 +- app/include/dt-bindings/zmk/reset.h | 2 +- app/include/linker/zmk-events.ld | 2 +- app/include/zmk/behavior.h | 5 +++++ app/include/zmk/ble.h | 5 +++++ app/include/zmk/display.h | 2 +- app/include/zmk/endpoints.h | 6 ++++++ app/include/zmk/event-manager.h | 2 +- app/include/zmk/events/keycode-state-changed.h | 2 +- app/include/zmk/events/modifiers-state-changed.h | 2 +- app/include/zmk/events/position-state-changed.h | 2 +- app/include/zmk/events/sensor-event.h | 2 +- app/include/zmk/handlers.h | 6 ++++++ app/include/zmk/hid.h | 6 ++++++ app/include/zmk/hog.h | 5 +++++ app/include/zmk/keymap.h | 6 ++++++ app/include/zmk/keys.h | 6 ++++++ app/include/zmk/kscan.h | 6 ++++++ app/include/zmk/matrix.h | 6 ++++++ app/include/zmk/matrix_transform.h | 6 ++++++ app/include/zmk/rgb_underglow.h | 2 +- app/include/zmk/sensors.h | 2 +- app/include/zmk/usb_hid.h | 11 +++++++---- app/run-test.sh | 2 +- app/src/behaviors/behavior_hold_tap.c | 2 +- app/src/behaviors/behavior_key_press.c | 2 +- app/src/behaviors/behavior_momentary_layer.c | 2 +- app/src/behaviors/behavior_none.c | 2 +- app/src/behaviors/behavior_reset.c | 2 +- app/src/behaviors/behavior_rgb_underglow.c | 2 +- app/src/behaviors/behavior_sensor_rotate_key_press.c | 2 +- app/src/behaviors/behavior_toggle_layer.c | 2 +- app/src/behaviors/behavior_transparent.c | 2 +- app/src/ble.c | 2 +- app/src/ble_unpair_combo.c | 2 +- app/src/display.c | 2 +- app/src/endpoints.c | 5 +++++ app/src/event_manager.c | 2 +- app/src/events/keycode_state_changed.c | 2 +- app/src/events/modifiers_state_changed.c | 2 +- app/src/events/position_state_changed.c | 2 +- app/src/events/sensor_event.c | 2 +- app/src/hid.c | 6 ++++++ app/src/hid_listener.c | 2 +- app/src/hog.c | 6 ++++++ app/src/keymap.c | 5 +++++ app/src/kscan.c | 2 +- app/src/kscan_composite.c | 2 +- app/src/kscan_mock.c | 2 +- app/src/main.c | 2 +- app/src/matrix_transform.c | 5 +++++ app/src/rgb_underglow.c | 2 +- app/src/sensors.c | 2 +- app/src/split/bluetooth/central.c | 2 +- app/src/split/bluetooth/service.c | 5 +++++ app/src/split_listener.c | 2 +- app/src/usb_hid.c | 5 +++++ 80 files changed, 185 insertions(+), 71 deletions(-) create mode 100644 AUTHORS diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..8052fd9 --- /dev/null +++ b/AUTHORS @@ -0,0 +1,11 @@ +# The ZMK Project consists of many contributors. This file includes individuals +# who have contributed significant changes to the project. To be added to here, +# please submit a PR to the project repo. +Peter Johanson (@petejohanson) +Innovaker (@innovaker) +Nick Winans (@Nicell) +Okke Formsma (@okke-formsma) +Cody McGinnis (@BrainWart) +Kurtis Lew (@kurtis-lew) +Richard Jones (@bmcgavin) +Kevin Chen (@chenkevinh) \ No newline at end of file diff --git a/app/boards/arm/dz60rgb/Kconfig.board b/app/boards/arm/dz60rgb/Kconfig.board index a96271f..ec8dad6 100644 --- a/app/boards/arm/dz60rgb/Kconfig.board +++ b/app/boards/arm/dz60rgb/Kconfig.board @@ -1,4 +1,4 @@ -# Copyright (c) 2020 Nick Winans +# Copyright (c) 2020 The ZMK Contributors # SPDX-License-Identifier: MIT config BOARD_DZ60RGB_REV1 diff --git a/app/boards/arm/dz60rgb/Kconfig.defconfig b/app/boards/arm/dz60rgb/Kconfig.defconfig index c97a308..779d312 100644 --- a/app/boards/arm/dz60rgb/Kconfig.defconfig +++ b/app/boards/arm/dz60rgb/Kconfig.defconfig @@ -1,6 +1,6 @@ # DZ60RGB keyboard configuration -# Copyright (c) 2020 Nick Winans +# Copyright (c) 2020 The ZMK Contributors # SPDX-License-Identifier: MIT if BOARD_DZ60RGB_REV1 diff --git a/app/boards/arm/dz60rgb/dz60rgb_rev1.dts b/app/boards/arm/dz60rgb/dz60rgb_rev1.dts index dc1b6ea..85c4ca5 100644 --- a/app/boards/arm/dz60rgb/dz60rgb_rev1.dts +++ b/app/boards/arm/dz60rgb/dz60rgb_rev1.dts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Nick Winans + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/boards/arm/nrfmicro/Kconfig.board b/app/boards/arm/nrfmicro/Kconfig.board index 177373a..36b2d55 100644 --- a/app/boards/arm/nrfmicro/Kconfig.board +++ b/app/boards/arm/nrfmicro/Kconfig.board @@ -1,6 +1,6 @@ # nrfmicro board configuration -# Copyright (c) 2020 Okke Formsma, joric +# Copyright (c) 2020 The ZMK Contributors # SPDX-License-Identifier: MIT config BOARD_NRFMICRO_11 diff --git a/app/boards/arm/nrfmicro/Kconfig.defconfig b/app/boards/arm/nrfmicro/Kconfig.defconfig index 9cce5a9..7957b4a 100644 --- a/app/boards/arm/nrfmicro/Kconfig.defconfig +++ b/app/boards/arm/nrfmicro/Kconfig.defconfig @@ -1,6 +1,6 @@ # Electronut Labs Papyr board configuration -# Copyright (c) 2020 Okke Formsma, joric +# Copyright (c) 2020 The ZMK Contributors # SPDX-License-Identifier: MIT if BOARD_NRFMICRO_11 || BOARD_NRFMICRO_11_FLIPPED || BOARD_NRFMICRO_13 diff --git a/app/boards/arm/nrfmicro/arduino_pro_micro_pins.dtsi b/app/boards/arm/nrfmicro/arduino_pro_micro_pins.dtsi index 6cde2b4..558391d 100644 --- a/app/boards/arm/nrfmicro/arduino_pro_micro_pins.dtsi +++ b/app/boards/arm/nrfmicro/arduino_pro_micro_pins.dtsi @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Okke Formsma, joric + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/boards/arm/nrfmicro/arduino_pro_micro_pins_flipped.dtsi b/app/boards/arm/nrfmicro/arduino_pro_micro_pins_flipped.dtsi index 9bad7f4..68ca266 100644 --- a/app/boards/arm/nrfmicro/arduino_pro_micro_pins_flipped.dtsi +++ b/app/boards/arm/nrfmicro/arduino_pro_micro_pins_flipped.dtsi @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Okke Formsma, joric + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/boards/arm/nrfmicro/nrfmicro_11.dts b/app/boards/arm/nrfmicro/nrfmicro_11.dts index dc07ac8..95bd8ad 100644 --- a/app/boards/arm/nrfmicro/nrfmicro_11.dts +++ b/app/boards/arm/nrfmicro/nrfmicro_11.dts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Okke Formsma, joric + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/boards/arm/nrfmicro/nrfmicro_11_flipped.dts b/app/boards/arm/nrfmicro/nrfmicro_11_flipped.dts index 5bf493f..85693a8 100644 --- a/app/boards/arm/nrfmicro/nrfmicro_11_flipped.dts +++ b/app/boards/arm/nrfmicro/nrfmicro_11_flipped.dts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Okke Formsma, joric + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/boards/arm/nrfmicro/nrfmicro_13.dts b/app/boards/arm/nrfmicro/nrfmicro_13.dts index dc07ac8..95bd8ad 100644 --- a/app/boards/arm/nrfmicro/nrfmicro_13.dts +++ b/app/boards/arm/nrfmicro/nrfmicro_13.dts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Okke Formsma, joric + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/boards/arm/nrfmicro/pinmux.c b/app/boards/arm/nrfmicro/pinmux.c index 3792b59..0536fe0 100644 --- a/app/boards/arm/nrfmicro/pinmux.c +++ b/app/boards/arm/nrfmicro/pinmux.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Okke Formsma, joric + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/boards/arm/planck/Kconfig.board b/app/boards/arm/planck/Kconfig.board index 0952448..fe15e1a 100644 --- a/app/boards/arm/planck/Kconfig.board +++ b/app/boards/arm/planck/Kconfig.board @@ -1,6 +1,6 @@ # Planck V6 board configuration -# Copyright (c) 2020 Peter Johanson +# Copyright (c) 2020 The ZMK Contributors # SPDX-License-Identifier: MIT config BOARD_PLANCK_REV6 diff --git a/app/boards/arm/planck/Kconfig.defconfig b/app/boards/arm/planck/Kconfig.defconfig index 93118d4..6f5bf52 100644 --- a/app/boards/arm/planck/Kconfig.defconfig +++ b/app/boards/arm/planck/Kconfig.defconfig @@ -1,6 +1,6 @@ # Planck keyboard configuration -# Copyright (c) 2020 Peter Johanson +# Copyright (c) 2020 The ZMK Contributors # SPDX-License-Identifier: MIT if BOARD_PLANCK_REV6 diff --git a/app/drivers/zephyr/ec11.c b/app/drivers/zephyr/ec11.c index 1bc5d6a..dfa86ef 100644 --- a/app/drivers/zephyr/ec11.c +++ b/app/drivers/zephyr/ec11.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Peter Johanson + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/drivers/zephyr/ec11.h b/app/drivers/zephyr/ec11.h index 823d92d..27fed9b 100644 --- a/app/drivers/zephyr/ec11.h +++ b/app/drivers/zephyr/ec11.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Peter Johanson + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/drivers/zephyr/ec11_trigger.c b/app/drivers/zephyr/ec11_trigger.c index 709d1fb..a04a561 100644 --- a/app/drivers/zephyr/ec11_trigger.c +++ b/app/drivers/zephyr/ec11_trigger.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Intel Corporation + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/drivers/zephyr/kscan_gpio_direct.c b/app/drivers/zephyr/kscan_gpio_direct.c index a3aa8c4..6e6a01f 100644 --- a/app/drivers/zephyr/kscan_gpio_direct.c +++ b/app/drivers/zephyr/kscan_gpio_direct.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Peter Johanson + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/drivers/zephyr/kscan_gpio_matrix.c b/app/drivers/zephyr/kscan_gpio_matrix.c index b19c492..079a830 100644 --- a/app/drivers/zephyr/kscan_gpio_matrix.c +++ b/app/drivers/zephyr/kscan_gpio_matrix.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Peter Johanson + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/dts/behaviors/toggle_layer.dtsi b/app/dts/behaviors/toggle_layer.dtsi index 86a050d..4045396 100644 --- a/app/dts/behaviors/toggle_layer.dtsi +++ b/app/dts/behaviors/toggle_layer.dtsi @@ -1,10 +1,10 @@ /* - * Copyright (c) 2020 Cody McGinnis + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ - - / { + +/ { behaviors { tog: behavior_toggle_layer { compatible = "zmk,behavior-toggle-layer"; diff --git a/app/dts/bindings/behaviors/zmk,behavior-hold-tap.yaml b/app/dts/bindings/behaviors/zmk,behavior-hold-tap.yaml index a20578f..5f74e9a 100644 --- a/app/dts/bindings/behaviors/zmk,behavior-hold-tap.yaml +++ b/app/dts/bindings/behaviors/zmk,behavior-hold-tap.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2020, Cody McGinnis; Okke Formsma +# Copyright (c) 2020 The ZMK Contributors # SPDX-License-Identifier: MIT description: Hold or Tap behavior @@ -12,12 +12,12 @@ properties: type: phandles required: true tapping_term_ms: - type: int + type: int flavor: type: string required: false default: "hold-preferred" enum: - - "hold-preferred" - - "balanced" - - "tap-preferred" \ No newline at end of file + - "hold-preferred" + - "balanced" + - "tap-preferred" diff --git a/app/dts/bindings/behaviors/zmk,behavior-rgb-underglow.yaml b/app/dts/bindings/behaviors/zmk,behavior-rgb-underglow.yaml index 6b6d5b0..2cb74b9 100644 --- a/app/dts/bindings/behaviors/zmk,behavior-rgb-underglow.yaml +++ b/app/dts/bindings/behaviors/zmk,behavior-rgb-underglow.yaml @@ -1,8 +1,8 @@ -# Copyright (c) 2020, Nick Winans +# Copyright (c) 2020 The ZMK Contributors # SPDX-License-Identifier: MIT description: RGB Underglow Action compatible: "zmk,behavior-rgb-underglow" -include: one_param.yaml \ No newline at end of file +include: one_param.yaml diff --git a/app/dts/bindings/behaviors/zmk,behavior-toggle-layer.yaml b/app/dts/bindings/behaviors/zmk,behavior-toggle-layer.yaml index 065949f..0a9723f 100644 --- a/app/dts/bindings/behaviors/zmk,behavior-toggle-layer.yaml +++ b/app/dts/bindings/behaviors/zmk,behavior-toggle-layer.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2020, Cody McGinnis +# Copyright (c) 2020 The ZMK Contributors # SPDX-License-Identifier: MIT description: Toggle Layer diff --git a/app/include/drivers/behavior.h b/app/include/drivers/behavior.h index c24d11b..617b5ab 100644 --- a/app/include/drivers/behavior.h +++ b/app/include/drivers/behavior.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Peter Johanson + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/include/dt-bindings/zmk/reset.h b/app/include/dt-bindings/zmk/reset.h index b513649..683f965 100644 --- a/app/include/dt-bindings/zmk/reset.h +++ b/app/include/dt-bindings/zmk/reset.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Peter Johanson + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/include/linker/zmk-events.ld b/app/include/linker/zmk-events.ld index 44063be..78d00bb 100644 --- a/app/include/linker/zmk-events.ld +++ b/app/include/linker/zmk-events.ld @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Peter Johanson + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/include/zmk/behavior.h b/app/include/zmk/behavior.h index 63edcc9..6f5815f 100644 --- a/app/include/zmk/behavior.h +++ b/app/include/zmk/behavior.h @@ -1,3 +1,8 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ #pragma once diff --git a/app/include/zmk/ble.h b/app/include/zmk/ble.h index e760ed7..d0aaa96 100644 --- a/app/include/zmk/ble.h +++ b/app/include/zmk/ble.h @@ -1,3 +1,8 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ #pragma once diff --git a/app/include/zmk/display.h b/app/include/zmk/display.h index 93ac3ff..def4392 100644 --- a/app/include/zmk/display.h +++ b/app/include/zmk/display.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Peter Johanson + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/include/zmk/endpoints.h b/app/include/zmk/endpoints.h index 4c0f442..aad6265 100644 --- a/app/include/zmk/endpoints.h +++ b/app/include/zmk/endpoints.h @@ -1,3 +1,9 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + #pragma once #include diff --git a/app/include/zmk/event-manager.h b/app/include/zmk/event-manager.h index d9a56a4..9da6602 100644 --- a/app/include/zmk/event-manager.h +++ b/app/include/zmk/event-manager.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Peter Johanson + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/include/zmk/events/keycode-state-changed.h b/app/include/zmk/events/keycode-state-changed.h index e12813c..fc37946 100644 --- a/app/include/zmk/events/keycode-state-changed.h +++ b/app/include/zmk/events/keycode-state-changed.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Peter Johanson + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/include/zmk/events/modifiers-state-changed.h b/app/include/zmk/events/modifiers-state-changed.h index a17a093..b39e11e 100644 --- a/app/include/zmk/events/modifiers-state-changed.h +++ b/app/include/zmk/events/modifiers-state-changed.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Peter Johanson + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/include/zmk/events/position-state-changed.h b/app/include/zmk/events/position-state-changed.h index c91688e..f88080d 100644 --- a/app/include/zmk/events/position-state-changed.h +++ b/app/include/zmk/events/position-state-changed.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Peter Johanson + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/include/zmk/events/sensor-event.h b/app/include/zmk/events/sensor-event.h index f881ac5..a9302a5 100644 --- a/app/include/zmk/events/sensor-event.h +++ b/app/include/zmk/events/sensor-event.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Peter Johanson + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/include/zmk/handlers.h b/app/include/zmk/handlers.h index a10851f..7ce1d27 100644 --- a/app/include/zmk/handlers.h +++ b/app/include/zmk/handlers.h @@ -1,3 +1,9 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + #pragma once #include diff --git a/app/include/zmk/hid.h b/app/include/zmk/hid.h index 138606a..a945e72 100644 --- a/app/include/zmk/hid.h +++ b/app/include/zmk/hid.h @@ -1,3 +1,9 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + #pragma once #include diff --git a/app/include/zmk/hog.h b/app/include/zmk/hog.h index e2f976a..a7dda51 100644 --- a/app/include/zmk/hog.h +++ b/app/include/zmk/hog.h @@ -1,3 +1,8 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ #pragma once diff --git a/app/include/zmk/keymap.h b/app/include/zmk/keymap.h index c1f6393..6192587 100644 --- a/app/include/zmk/keymap.h +++ b/app/include/zmk/keymap.h @@ -1,3 +1,9 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + #pragma once bool zmk_keymap_layer_active(u8_t layer); diff --git a/app/include/zmk/keys.h b/app/include/zmk/keys.h index 6966bba..ee9c3d9 100644 --- a/app/include/zmk/keys.h +++ b/app/include/zmk/keys.h @@ -1,3 +1,9 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + #pragma once #include diff --git a/app/include/zmk/kscan.h b/app/include/zmk/kscan.h index ebffccd..3352600 100644 --- a/app/include/zmk/kscan.h +++ b/app/include/zmk/kscan.h @@ -1,3 +1,9 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + #pragma once int zmk_kscan_init(char *name); diff --git a/app/include/zmk/matrix.h b/app/include/zmk/matrix.h index 3088263..1614317 100644 --- a/app/include/zmk/matrix.h +++ b/app/include/zmk/matrix.h @@ -1,3 +1,9 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + #pragma once #include diff --git a/app/include/zmk/matrix_transform.h b/app/include/zmk/matrix_transform.h index e9e969a..29c2afc 100644 --- a/app/include/zmk/matrix_transform.h +++ b/app/include/zmk/matrix_transform.h @@ -1,3 +1,9 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + #pragma once u32_t zmk_matrix_transform_row_column_to_position(u32_t row, u32_t column); \ No newline at end of file diff --git a/app/include/zmk/rgb_underglow.h b/app/include/zmk/rgb_underglow.h index 69e9a9b..94cc32c 100644 --- a/app/include/zmk/rgb_underglow.h +++ b/app/include/zmk/rgb_underglow.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Nick Winans + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/include/zmk/sensors.h b/app/include/zmk/sensors.h index c60cd4b..63dcade 100644 --- a/app/include/zmk/sensors.h +++ b/app/include/zmk/sensors.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Peter Johanson + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/include/zmk/usb_hid.h b/app/include/zmk/usb_hid.h index 5d7c744..7ee2629 100644 --- a/app/include/zmk/usb_hid.h +++ b/app/include/zmk/usb_hid.h @@ -1,5 +1,10 @@ -#ifndef ZMK_USB_HID -#define ZMK_USB_HID +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#pragma once #include #include @@ -10,5 +15,3 @@ int zmk_usb_hid_init(); int zmk_usb_hid_send_report(u8_t *report, size_t len); - -#endif diff --git a/app/run-test.sh b/app/run-test.sh index be335c6..3b7cd58 100755 --- a/app/run-test.sh +++ b/app/run-test.sh @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright (c) 2020 Peter Johanson; Cody McGinnis +# Copyright (c) 2020 The ZMK Contributors # # SPDX-License-Identifier: MIT # diff --git a/app/src/behaviors/behavior_hold_tap.c b/app/src/behaviors/behavior_hold_tap.c index 2c6d996..dce724d 100644 --- a/app/src/behaviors/behavior_hold_tap.c +++ b/app/src/behaviors/behavior_hold_tap.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Cody McGinnis, Okke Formsma + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/src/behaviors/behavior_key_press.c b/app/src/behaviors/behavior_key_press.c index 7404c79..42becf5 100644 --- a/app/src/behaviors/behavior_key_press.c +++ b/app/src/behaviors/behavior_key_press.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Peter Johanson + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/src/behaviors/behavior_momentary_layer.c b/app/src/behaviors/behavior_momentary_layer.c index 8a8584a..7d65135 100644 --- a/app/src/behaviors/behavior_momentary_layer.c +++ b/app/src/behaviors/behavior_momentary_layer.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Peter Johanson + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/src/behaviors/behavior_none.c b/app/src/behaviors/behavior_none.c index e822d5e..c464988 100644 --- a/app/src/behaviors/behavior_none.c +++ b/app/src/behaviors/behavior_none.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Peter Johanson + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/src/behaviors/behavior_reset.c b/app/src/behaviors/behavior_reset.c index 30a96ea..b5692b5 100644 --- a/app/src/behaviors/behavior_reset.c +++ b/app/src/behaviors/behavior_reset.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Peter Johanson + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/src/behaviors/behavior_rgb_underglow.c b/app/src/behaviors/behavior_rgb_underglow.c index 7a48e07..f0a35ef 100644 --- a/app/src/behaviors/behavior_rgb_underglow.c +++ b/app/src/behaviors/behavior_rgb_underglow.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Nick Winans + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/src/behaviors/behavior_sensor_rotate_key_press.c b/app/src/behaviors/behavior_sensor_rotate_key_press.c index fb0fb85..fa55575 100644 --- a/app/src/behaviors/behavior_sensor_rotate_key_press.c +++ b/app/src/behaviors/behavior_sensor_rotate_key_press.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Peter Johanson + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/src/behaviors/behavior_toggle_layer.c b/app/src/behaviors/behavior_toggle_layer.c index 02a76d2..c6d5225 100644 --- a/app/src/behaviors/behavior_toggle_layer.c +++ b/app/src/behaviors/behavior_toggle_layer.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Cody McGinnis + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/src/behaviors/behavior_transparent.c b/app/src/behaviors/behavior_transparent.c index 5109264..51f682b 100644 --- a/app/src/behaviors/behavior_transparent.c +++ b/app/src/behaviors/behavior_transparent.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Peter Johanson + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/src/ble.c b/app/src/ble.c index 0e96d16..c4d3efd 100644 --- a/app/src/ble.c +++ b/app/src/ble.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Peter Johanson + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/src/ble_unpair_combo.c b/app/src/ble_unpair_combo.c index 82fa834..3633a5b 100644 --- a/app/src/ble_unpair_combo.c +++ b/app/src/ble_unpair_combo.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Peter Johanson + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/src/display.c b/app/src/display.c index 9021914..dca462e 100644 --- a/app/src/display.c +++ b/app/src/display.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Peter Johanson + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/src/endpoints.c b/app/src/endpoints.c index c9ba716..61e86ce 100644 --- a/app/src/endpoints.c +++ b/app/src/endpoints.c @@ -1,3 +1,8 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ #include #include diff --git a/app/src/event_manager.c b/app/src/event_manager.c index 47ad6b7..6d37e4e 100644 --- a/app/src/event_manager.c +++ b/app/src/event_manager.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Peter Johanson + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/src/events/keycode_state_changed.c b/app/src/events/keycode_state_changed.c index 73508e1..9a1984a 100644 --- a/app/src/events/keycode_state_changed.c +++ b/app/src/events/keycode_state_changed.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Peter Johanson + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/src/events/modifiers_state_changed.c b/app/src/events/modifiers_state_changed.c index 71ec015..8becd02 100644 --- a/app/src/events/modifiers_state_changed.c +++ b/app/src/events/modifiers_state_changed.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Peter Johanson + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/src/events/position_state_changed.c b/app/src/events/position_state_changed.c index 69cba03..f8f1a26 100644 --- a/app/src/events/position_state_changed.c +++ b/app/src/events/position_state_changed.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Peter Johanson + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/src/events/sensor_event.c b/app/src/events/sensor_event.c index 1b0302d..c6b80cd 100644 --- a/app/src/events/sensor_event.c +++ b/app/src/events/sensor_event.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Peter Johanson + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/src/hid.c b/app/src/hid.c index ca04056..07fc3a0 100644 --- a/app/src/hid.c +++ b/app/src/hid.c @@ -1,3 +1,9 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + #include LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); diff --git a/app/src/hid_listener.c b/app/src/hid_listener.c index 69aa23e..9f68ca2 100644 --- a/app/src/hid_listener.c +++ b/app/src/hid_listener.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Peter Johanson + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/src/hog.c b/app/src/hog.c index 589c28f..92858d5 100644 --- a/app/src/hog.c +++ b/app/src/hog.c @@ -1,3 +1,9 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + #include #include diff --git a/app/src/keymap.c b/app/src/keymap.c index 57cdad6..b1c68f1 100644 --- a/app/src/keymap.c +++ b/app/src/keymap.c @@ -1,3 +1,8 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ #include #include diff --git a/app/src/kscan.c b/app/src/kscan.c index 63713f1..7a4d3a4 100644 --- a/app/src/kscan.c +++ b/app/src/kscan.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Peter Johanson + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/src/kscan_composite.c b/app/src/kscan_composite.c index d46484b..15527eb 100644 --- a/app/src/kscan_composite.c +++ b/app/src/kscan_composite.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Peter Johanson + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/src/kscan_mock.c b/app/src/kscan_mock.c index d626c71..741f6c1 100644 --- a/app/src/kscan_mock.c +++ b/app/src/kscan_mock.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Peter Johanson + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/src/main.c b/app/src/main.c index 5a678ee..5da272e 100644 --- a/app/src/main.c +++ b/app/src/main.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Peter Johanson + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/src/matrix_transform.c b/app/src/matrix_transform.c index 7ecf1ae..8a037b3 100644 --- a/app/src/matrix_transform.c +++ b/app/src/matrix_transform.c @@ -1,3 +1,8 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ #include #include diff --git a/app/src/rgb_underglow.c b/app/src/rgb_underglow.c index 95adcec..97c2ac0 100644 --- a/app/src/rgb_underglow.c +++ b/app/src/rgb_underglow.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Nick Winans + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/src/sensors.c b/app/src/sensors.c index 501ce15..7a7c0c5 100644 --- a/app/src/sensors.c +++ b/app/src/sensors.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Peter Johanson + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/src/split/bluetooth/central.c b/app/src/split/bluetooth/central.c index 237096f..9e67228 100644 --- a/app/src/split/bluetooth/central.c +++ b/app/src/split/bluetooth/central.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Peter Johanson + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/src/split/bluetooth/service.c b/app/src/split/bluetooth/service.c index e1d232a..0a5ddb7 100644 --- a/app/src/split/bluetooth/service.c +++ b/app/src/split/bluetooth/service.c @@ -1,3 +1,8 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ #include #include diff --git a/app/src/split_listener.c b/app/src/split_listener.c index 65f835a..46a95e1 100644 --- a/app/src/split_listener.c +++ b/app/src/split_listener.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Peter Johanson + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/src/usb_hid.c b/app/src/usb_hid.c index 784fc25..e2fe0f3 100644 --- a/app/src/usb_hid.c +++ b/app/src/usb_hid.c @@ -1,3 +1,8 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ #include #include -- cgit v1.2.3 From 073f5c8b98c5111d954fe5bfe98951b24983449d Mon Sep 17 00:00:00 2001 From: kurtis-lew Date: Thu, 10 Sep 2020 18:40:07 -0700 Subject: Added File Transfer Error/CMake Warning Docs --- .../assets/troubleshooting/filetransfer/linux.png | Bin 0 -> 40111 bytes .../troubleshooting/filetransfer/windows.png | Bin 0 -> 12077 bytes docs/docs/troubleshooting.md | 31 ++++++++++++++++++++- 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 docs/docs/assets/troubleshooting/filetransfer/linux.png create mode 100644 docs/docs/assets/troubleshooting/filetransfer/windows.png diff --git a/docs/docs/assets/troubleshooting/filetransfer/linux.png b/docs/docs/assets/troubleshooting/filetransfer/linux.png new file mode 100644 index 0000000..c192dfa Binary files /dev/null and b/docs/docs/assets/troubleshooting/filetransfer/linux.png differ diff --git a/docs/docs/assets/troubleshooting/filetransfer/windows.png b/docs/docs/assets/troubleshooting/filetransfer/windows.png new file mode 100644 index 0000000..91cb8a6 Binary files /dev/null and b/docs/docs/assets/troubleshooting/filetransfer/windows.png differ diff --git a/docs/docs/troubleshooting.md b/docs/docs/troubleshooting.md index cd8bfd6..4820e11 100644 --- a/docs/docs/troubleshooting.md +++ b/docs/docs/troubleshooting.md @@ -7,11 +7,40 @@ sidebar_title: Troubleshooting The following page provides suggestions for common errors that may occur during firmware compilation. If the information provided is insufficient to resolve the issue, feel free to seek out help from the [ZMK Discord](https://zmkfirmware.dev/community/discord/invite). +### File Transfer Error + +Variations of the warnings shown below occur when flashing the `.uf2` onto the microcontroller. This is because the microcontroller resets itself before the OS receives confirmation that the file transfer is complete. Errors like this are normal and can generally be ignored. Verification of a functional board can be done by attempting to pair your computer to your newly flashed keyboard via Bluetooth or plugging in a USB cable if `ZMK_USB` is enabled in your Kconfig.defconfig. + +| ![Example Error Screen](../docs/assets/troubleshooting/filetransfer/windows.png) | +| :-------------------------------------------------------------------------------: | +| An example of the file transfer error on Windows 10 | + +| ![Example Error Screen](../docs/assets/troubleshooting/filetransfer/linux.png) | +| :-------------------------------------------------------------------------------: | +| An example of the file transfer error on Linux | + + ### CMake Error -An error along the lines of `CMake Error at (zmk directory)/zephyr/cmake/generic_toolchain.cmake:64 (include): include could not find load file:` during firmware compilation indicates that the Zephyr Environment Variables are not properly defined. +``` +CMake Warning at C:/zmk/zephyr/subsys/usb/CMakeLists.txt:28 (message): + CONFIG_USB_DEVICE_VID has default value 0x2FE3. + + This value is only for testing and MUST be configured for USB products. + + +CMake Warning at C:/zmk/zephyr/subsys/usb/CMakeLists.txt:34 (message): + CONFIG_USB_DEVICE_PID has default value 0x100. + + This value is only for testing and MUST be configured for USB products. +``` + +CMake Warnings shown above during `west build` are normal occurrences. They should not negatively affect the firmware's ability to function as normal. + +On the other hand, an error along the lines of `CMake Error at (zmk directory)/zephyr/cmake/generic_toolchain.cmake:64 (include): include could not find load file:` during firmware compilation indicates that the Zephyr Environment Variables are not properly defined. For more information, click [here](../docs/dev-setup#environment-variables). + ### dtlib.DTError An error along the lines of `dtlib.DTError: .dts.pre.tmp:` during firmware compilation indicates an issue within the `.keymap` file. -- cgit v1.2.3 From 5b38fcff71a0e22407dbd418fb1900614ecbfb6f Mon Sep 17 00:00:00 2001 From: Kurtis Lew Date: Thu, 10 Sep 2020 18:44:39 -0700 Subject: Reversed pairing instructions --- docs/docs/troubleshooting.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/troubleshooting.md b/docs/docs/troubleshooting.md index 4820e11..deb89b6 100644 --- a/docs/docs/troubleshooting.md +++ b/docs/docs/troubleshooting.md @@ -9,7 +9,7 @@ The following page provides suggestions for common errors that may occur during ### File Transfer Error -Variations of the warnings shown below occur when flashing the `.uf2` onto the microcontroller. This is because the microcontroller resets itself before the OS receives confirmation that the file transfer is complete. Errors like this are normal and can generally be ignored. Verification of a functional board can be done by attempting to pair your computer to your newly flashed keyboard via Bluetooth or plugging in a USB cable if `ZMK_USB` is enabled in your Kconfig.defconfig. +Variations of the warnings shown below occur when flashing the `.uf2` onto the microcontroller. This is because the microcontroller resets itself before the OS receives confirmation that the file transfer is complete. Errors like this are normal and can generally be ignored. Verification of a functional board can be done by attempting to pair your newly flashed keyboard to your computer via Bluetooth or plugging in a USB cable if `ZMK_USB` is enabled in your Kconfig.defconfig. | ![Example Error Screen](../docs/assets/troubleshooting/filetransfer/windows.png) | | :-------------------------------------------------------------------------------: | -- cgit v1.2.3 From 89ba824b2b28d4fdbd174ba20b1183d6547c19f8 Mon Sep 17 00:00:00 2001 From: Mamoor Jaan Khan <56243233+LowNightSnack@users.noreply.github.com> Date: Fri, 11 Sep 2020 11:04:58 +0530 Subject: typo --- docs/docs/user-setup.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/user-setup.md b/docs/docs/user-setup.md index 2aade82..c207136 100644 --- a/docs/docs/user-setup.md +++ b/docs/docs/user-setup.md @@ -179,7 +179,7 @@ storage device. Once the flash is complete, the controller should automatically ## Wirelessly Connecting Your Keyboard -Connecting your keyboard wirelessly is the same as adding other Bluetooth devides: press the reset button and scan for devices. However, pairing and bonding is still currently being worked on to increase relability and ease of use. In addition, users have in general reported that Bluetooth pairing with computers tends to be quite finnicky. Try out the connection with your tablet or phone first, as those devices seem to work much more consistently. See [BLE Reset](./bond-reset.md) for help on resetting your MCUs if you're experiencing connection issues. +Connecting your keyboard wirelessly is the same as adding other Bluetooth devices: press the reset button and scan for devices. However, pairing and bonding is still currently being worked on to increase relability and ease of use. In addition, users have in general reported that Bluetooth pairing with computers tends to be quite finnicky. Try out the connection with your tablet or phone first, as those devices seem to work much more consistently. See [BLE Reset](./bond-reset.md) for help on resetting your MCUs if you're experiencing connection issues. ### Connecting Split Keyboard Halves -- cgit v1.2.3 From cd00c0aad41e4aad369bbc12f68b888ab2d9ddd4 Mon Sep 17 00:00:00 2001 From: Cody McGinnis Date: Fri, 11 Sep 2020 02:28:55 -0400 Subject: fix(docs): Fix the example mod tap configuration --- docs/docs/behavior/mod-tap.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/docs/behavior/mod-tap.md b/docs/docs/behavior/mod-tap.md index dcac492..068928a 100644 --- a/docs/docs/behavior/mod-tap.md +++ b/docs/docs/behavior/mod-tap.md @@ -31,8 +31,8 @@ You can configure a different tapping term in your keymap: ``` &mt { - tapping_term_ms: <400>; -} + tapping_term_ms = <400>; +}; / { keymap { -- cgit v1.2.3 From ce862d148db09ed318c9d592bef4e29f59949b5e Mon Sep 17 00:00:00 2001 From: Mamoor Jaan Khan <56243233+LowNightSnack@users.noreply.github.com> Date: Fri, 11 Sep 2020 19:47:20 +0530 Subject: Delete pro-micro-labelled-image.jpg --- docs/docs/pro-micro-labelled-image.jpg | Bin 115573 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 docs/docs/pro-micro-labelled-image.jpg diff --git a/docs/docs/pro-micro-labelled-image.jpg b/docs/docs/pro-micro-labelled-image.jpg deleted file mode 100644 index f72d407..0000000 Binary files a/docs/docs/pro-micro-labelled-image.jpg and /dev/null differ -- cgit v1.2.3 From 69e6a99180b51c0d9bdca44741e71e54a162bf14 Mon Sep 17 00:00:00 2001 From: Mamoor Jaan Khan <56243233+LowNightSnack@users.noreply.github.com> Date: Fri, 11 Sep 2020 19:49:46 +0530 Subject: Add files via upload --- docs/docs/assets/pro-micro/pro-micro-pins-labelled.jpg | Bin 0 -> 115573 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 docs/docs/assets/pro-micro/pro-micro-pins-labelled.jpg diff --git a/docs/docs/assets/pro-micro/pro-micro-pins-labelled.jpg b/docs/docs/assets/pro-micro/pro-micro-pins-labelled.jpg new file mode 100644 index 0000000..f72d407 Binary files /dev/null and b/docs/docs/assets/pro-micro/pro-micro-pins-labelled.jpg differ -- cgit v1.2.3 From e660e56dfb428d58d6c6548ac804c8933495c22d Mon Sep 17 00:00:00 2001 From: Mamoor Jaan Khan <56243233+LowNightSnack@users.noreply.github.com> Date: Fri, 11 Sep 2020 19:52:32 +0530 Subject: Update dev-boards-shields-keymaps.md --- docs/docs/dev-boards-shields-keymaps.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/dev-boards-shields-keymaps.md b/docs/docs/dev-boards-shields-keymaps.md index 17a3847..9ed5a32 100644 --- a/docs/docs/dev-boards-shields-keymaps.md +++ b/docs/docs/dev-boards-shields-keymaps.md @@ -35,7 +35,7 @@ in the `app/boards/${arch}/${board_name}` directory, e.g. `app/boards/arm/planck ## Pro Micro Compatible Keyboard -![Labelled Pro Micro pins](pro-micro-labelled-image.jpg) +![Labelled Pro Micro pins](assets/pro-micro/pro-micro-pins-labelled.jpg) For keyboards that require a (usually Pro Micro compatible) add-on board to operate, the ZMK integration pieces are places in the _shield_ definition for that keyboard, allowing users to -- cgit v1.2.3 From 4ce70831dddfbe1c8fda8d23086388ad36a421a5 Mon Sep 17 00:00:00 2001 From: Mamoor Jaan Khan <56243233+LowNightSnack@users.noreply.github.com> Date: Fri, 11 Sep 2020 19:54:03 +0530 Subject: Update dev-guide-new-shield.md --- docs/docs/dev-guide-new-shield.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/dev-guide-new-shield.md b/docs/docs/dev-guide-new-shield.md index 23d2387..832519d 100644 --- a/docs/docs/dev-guide-new-shield.md +++ b/docs/docs/dev-guide-new-shield.md @@ -64,7 +64,7 @@ endif ## Shield Overlay -![Labelled Pro Micro pins](pro-micro-labelled-image.jpg) +![Labelled Pro Micro pins](assets/pro-micro/pro-micro-pins-labelled.jpg) The `.overlay` is the devicetree description of the keyboard shield that is merged with the primary board devicetree description before the build. For ZMK, this file at a minimum should include the [chosen]() node named `zmk,kscan` that references a KSCAN driver instance. For a simple 3x3 macropad matrix, this might look something like: -- cgit v1.2.3 From c20eb9abac1797ff94012863d2bec582b68e6ded Mon Sep 17 00:00:00 2001 From: Mamoor Jaan Khan <56243233+LowNightSnack@users.noreply.github.com> Date: Fri, 11 Sep 2020 20:01:46 +0530 Subject: Update hold-tap.md --- docs/docs/behavior/hold-tap.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/docs/behavior/hold-tap.md b/docs/docs/behavior/hold-tap.md index fa68538..6790e88 100644 --- a/docs/docs/behavior/hold-tap.md +++ b/docs/docs/behavior/hold-tap.md @@ -56,7 +56,7 @@ A code example which configures a mod-tap setting that works with homerow mods: If this config does not work for you, try the flavor "tap-preferred" and a short tapping_term_ms such as 120ms. -If you want to use a tap-hold with a keycode from a different code page, you have to define another behavior with another "bindings" parameter.For example, if you want to use SHIFT and volume up, define the bindings like `bindings = <&kp>, <&cp>;`. Only single-argument behaviors are supported at the moment. +If you want to use a tap-hold with a keycode from a different code page, you have to define another behavior with another "bindings" parameter. For example, if you want to use SHIFT and volume up, define the bindings like `bindings = <&kp>, <&cp>;`. Only single-argument behaviors are supported at the moment. #### Note -Astute readers may notice similarities between the possible behaviors in ZMK and other firmware, such as QMK. The hold-preferred flavor works similar to the `HOLD_ON_OTHER_KEY_PRESS` setting. The 'balanced' flavor is similar to the `PERMISSIVE_HOLD` setting, and the `tap-preferred` flavor is similar to `IGNORE_MOD_TAP_INTERRUPT`. \ No newline at end of file +Astute readers may notice similarities between the possible behaviors in ZMK and other firmware, such as QMK. The hold-preferred flavor works similar to the `HOLD_ON_OTHER_KEY_PRESS` setting. The 'balanced' flavor is similar to the `PERMISSIVE_HOLD` setting, and the `tap-preferred` flavor is similar to `IGNORE_MOD_TAP_INTERRUPT`. -- cgit v1.2.3 From 6d7fb6c48dcd62c9d436c08f545f065bb41f810f Mon Sep 17 00:00:00 2001 From: Mamoor Jaan Khan <56243233+LowNightSnack@users.noreply.github.com> Date: Fri, 11 Sep 2020 20:10:23 +0530 Subject: Update dev-clean-room.md --- docs/docs/dev-clean-room.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/dev-clean-room.md b/docs/docs/dev-clean-room.md index c11171c..89e9826 100644 --- a/docs/docs/dev-clean-room.md +++ b/docs/docs/dev-clean-room.md @@ -11,7 +11,7 @@ Anyone wanting to contribute code to ZMK _must_ read this, and adhere to the ste ::: ZMK Firmware is a [clean room design](https://en.wikipedia.org/wiki/Clean_room_design) keyboard firmware, that -borrows/implements a lot of the features found in popular keyboard firmwares projects like [QMK](https://qmk.fm) +borrows/implements a lot of the features found in popular keyboard firmware projects like [QMK](https://qmk.fm) and [TMK](https://github.com/tmk/tmk_keyboard). However, in order for ZMK to use the MIT, it _must_ not incorporate any of the GPL licensed code from those projects. -- cgit v1.2.3 From 178e5e5afbf5d9b4dabb1a247f36714f5234ad29 Mon Sep 17 00:00:00 2001 From: Mamoor Jaan Khan <56243233+LowNightSnack@users.noreply.github.com> Date: Fri, 11 Sep 2020 20:37:05 +0530 Subject: Reverting provious commit --- docs/docs/behavior/hold-tap.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/behavior/hold-tap.md b/docs/docs/behavior/hold-tap.md index 6790e88..ab51022 100644 --- a/docs/docs/behavior/hold-tap.md +++ b/docs/docs/behavior/hold-tap.md @@ -56,7 +56,7 @@ A code example which configures a mod-tap setting that works with homerow mods: If this config does not work for you, try the flavor "tap-preferred" and a short tapping_term_ms such as 120ms. -If you want to use a tap-hold with a keycode from a different code page, you have to define another behavior with another "bindings" parameter. For example, if you want to use SHIFT and volume up, define the bindings like `bindings = <&kp>, <&cp>;`. Only single-argument behaviors are supported at the moment. +If you want to use a tap-hold with a keycode from a different code page, you have to define another behavior with another "bindings" parameter.For example, if you want to use SHIFT and volume up, define the bindings like `bindings = <&kp>, <&cp>;`. Only single-argument behaviors are supported at the moment. #### Note Astute readers may notice similarities between the possible behaviors in ZMK and other firmware, such as QMK. The hold-preferred flavor works similar to the `HOLD_ON_OTHER_KEY_PRESS` setting. The 'balanced' flavor is similar to the `PERMISSIVE_HOLD` setting, and the `tap-preferred` flavor is similar to `IGNORE_MOD_TAP_INTERRUPT`. -- cgit v1.2.3 From 7f5235904a5c49cc79875541d313317c9c6856c0 Mon Sep 17 00:00:00 2001 From: Mamoor Jaan Khan <56243233+LowNightSnack@users.noreply.github.com> Date: Fri, 11 Sep 2020 20:37:57 +0530 Subject: Reverting previous commit --- docs/docs/dev-clean-room.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/dev-clean-room.md b/docs/docs/dev-clean-room.md index 89e9826..c11171c 100644 --- a/docs/docs/dev-clean-room.md +++ b/docs/docs/dev-clean-room.md @@ -11,7 +11,7 @@ Anyone wanting to contribute code to ZMK _must_ read this, and adhere to the ste ::: ZMK Firmware is a [clean room design](https://en.wikipedia.org/wiki/Clean_room_design) keyboard firmware, that -borrows/implements a lot of the features found in popular keyboard firmware projects like [QMK](https://qmk.fm) +borrows/implements a lot of the features found in popular keyboard firmwares projects like [QMK](https://qmk.fm) and [TMK](https://github.com/tmk/tmk_keyboard). However, in order for ZMK to use the MIT, it _must_ not incorporate any of the GPL licensed code from those projects. -- cgit v1.2.3 From 98bd4796cfa3888e0f91d295599e42524e8e07db Mon Sep 17 00:00:00 2001 From: Mamoor Jaan Khan <56243233+LowNightSnack@users.noreply.github.com> Date: Fri, 11 Sep 2020 20:40:19 +0530 Subject: Reverting previous commit --- docs/docs/user-setup.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/user-setup.md b/docs/docs/user-setup.md index c207136..2aade82 100644 --- a/docs/docs/user-setup.md +++ b/docs/docs/user-setup.md @@ -179,7 +179,7 @@ storage device. Once the flash is complete, the controller should automatically ## Wirelessly Connecting Your Keyboard -Connecting your keyboard wirelessly is the same as adding other Bluetooth devices: press the reset button and scan for devices. However, pairing and bonding is still currently being worked on to increase relability and ease of use. In addition, users have in general reported that Bluetooth pairing with computers tends to be quite finnicky. Try out the connection with your tablet or phone first, as those devices seem to work much more consistently. See [BLE Reset](./bond-reset.md) for help on resetting your MCUs if you're experiencing connection issues. +Connecting your keyboard wirelessly is the same as adding other Bluetooth devides: press the reset button and scan for devices. However, pairing and bonding is still currently being worked on to increase relability and ease of use. In addition, users have in general reported that Bluetooth pairing with computers tends to be quite finnicky. Try out the connection with your tablet or phone first, as those devices seem to work much more consistently. See [BLE Reset](./bond-reset.md) for help on resetting your MCUs if you're experiencing connection issues. ### Connecting Split Keyboard Halves -- cgit v1.2.3 From 54437db0ba2809de5ef0b987f59cfe47c486c669 Mon Sep 17 00:00:00 2001 From: Mamoor Jaan Khan <56243233+LowNightSnack@users.noreply.github.com> Date: Fri, 11 Sep 2020 20:42:33 +0530 Subject: Update with the examples --- docs/docs/dev-guide-new-shield.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/docs/dev-guide-new-shield.md b/docs/docs/dev-guide-new-shield.md index 832519d..6140b07 100644 --- a/docs/docs/dev-guide-new-shield.md +++ b/docs/docs/dev-guide-new-shield.md @@ -66,6 +66,8 @@ endif ![Labelled Pro Micro pins](assets/pro-micro/pro-micro-pins-labelled.jpg) +ZMK uses the green color coded pin names to generate devicetree node references. For example, to refer to the node `D0` in the devicetree files, use `&pro_micro_d 0` or to refer to `A1`, use `&pro_micro_a 1`. + The `.overlay` is the devicetree description of the keyboard shield that is merged with the primary board devicetree description before the build. For ZMK, this file at a minimum should include the [chosen]() node named `zmk,kscan` that references a KSCAN driver instance. For a simple 3x3 macropad matrix, this might look something like: -- cgit v1.2.3 -- cgit v1.2.3 -- cgit v1.2.3 -- cgit v1.2.3 -- cgit v1.2.3 From ce8ade4afaa4cc9fc2b94050e98680301e539e56 Mon Sep 17 00:00:00 2001 From: Mamoor Jaan Khan <56243233+LowNightSnack@users.noreply.github.com> Date: Fri, 11 Sep 2020 23:48:53 +0530 Subject: A bad commit --- docs/docs/behavior/hold-tap.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/behavior/hold-tap.md b/docs/docs/behavior/hold-tap.md index ab51022..d51edd3 100644 --- a/docs/docs/behavior/hold-tap.md +++ b/docs/docs/behavior/hold-tap.md @@ -59,4 +59,4 @@ If this config does not work for you, try the flavor "tap-preferred" and a short If you want to use a tap-hold with a keycode from a different code page, you have to define another behavior with another "bindings" parameter.For example, if you want to use SHIFT and volume up, define the bindings like `bindings = <&kp>, <&cp>;`. Only single-argument behaviors are supported at the moment. #### Note -Astute readers may notice similarities between the possible behaviors in ZMK and other firmware, such as QMK. The hold-preferred flavor works similar to the `HOLD_ON_OTHER_KEY_PRESS` setting. The 'balanced' flavor is similar to the `PERMISSIVE_HOLD` setting, and the `tap-preferred` flavor is similar to `IGNORE_MOD_TAP_INTERRUPT`. +Astute readers may notice similarities between the possible behaviors in ZMK and other firmware, such as QMK. The hold-preferred flavor works similar to the `HOLD_ON_OTHER_KEY_PRESS` setting. The 'balanced' flavor is similar to the `PERMISSIVE_HOLD` setting, and the `tap-preferred` flavor is similar to `IGNORE_MOD_TAP_INTERRUPT` -- cgit v1.2.3 From e11cad9fde0e90a47c9b09f66c612ee946f597cf Mon Sep 17 00:00:00 2001 From: Mamoor Jaan Khan <56243233+LowNightSnack@users.noreply.github.com> Date: Fri, 11 Sep 2020 23:49:12 +0530 Subject: Update hold-tap.md --- docs/docs/behavior/hold-tap.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/behavior/hold-tap.md b/docs/docs/behavior/hold-tap.md index d51edd3..ab51022 100644 --- a/docs/docs/behavior/hold-tap.md +++ b/docs/docs/behavior/hold-tap.md @@ -59,4 +59,4 @@ If this config does not work for you, try the flavor "tap-preferred" and a short If you want to use a tap-hold with a keycode from a different code page, you have to define another behavior with another "bindings" parameter.For example, if you want to use SHIFT and volume up, define the bindings like `bindings = <&kp>, <&cp>;`. Only single-argument behaviors are supported at the moment. #### Note -Astute readers may notice similarities between the possible behaviors in ZMK and other firmware, such as QMK. The hold-preferred flavor works similar to the `HOLD_ON_OTHER_KEY_PRESS` setting. The 'balanced' flavor is similar to the `PERMISSIVE_HOLD` setting, and the `tap-preferred` flavor is similar to `IGNORE_MOD_TAP_INTERRUPT` +Astute readers may notice similarities between the possible behaviors in ZMK and other firmware, such as QMK. The hold-preferred flavor works similar to the `HOLD_ON_OTHER_KEY_PRESS` setting. The 'balanced' flavor is similar to the `PERMISSIVE_HOLD` setting, and the `tap-preferred` flavor is similar to `IGNORE_MOD_TAP_INTERRUPT`. -- cgit v1.2.3 From 763d62f6f292bec20bd183f9ba4d0da65fb3f7b5 Mon Sep 17 00:00:00 2001 From: Okke Formsma Date: Fri, 4 Sep 2020 20:57:11 +0200 Subject: update intro page, add layer-tap docs and update hold-tap docs. --- docs/docs/behavior/hold-tap.md | 10 +++++++--- docs/docs/behavior/layers.md | 20 ++++++++++++++++++-- docs/docs/intro.md | 33 +++++++++++++++++++-------------- 3 files changed, 44 insertions(+), 19 deletions(-) diff --git a/docs/docs/behavior/hold-tap.md b/docs/docs/behavior/hold-tap.md index ab51022..9f8f5fa 100644 --- a/docs/docs/behavior/hold-tap.md +++ b/docs/docs/behavior/hold-tap.md @@ -22,7 +22,11 @@ We call this the 'hold-preferred' flavor of hold-taps. While this flavor may wor ![Hold-tap comparison](../assets/hold-tap/comparison.png) -### Configuration +### Basic usage +For basic usage, please see [mod-tap](./mod-tap.md) and [layer-tap](./layers.md) pages. + + +### Advanced Configuration A code example which configures a mod-tap setting that works with homerow mods: ``` @@ -58,5 +62,5 @@ If this config does not work for you, try the flavor "tap-preferred" and a short If you want to use a tap-hold with a keycode from a different code page, you have to define another behavior with another "bindings" parameter.For example, if you want to use SHIFT and volume up, define the bindings like `bindings = <&kp>, <&cp>;`. Only single-argument behaviors are supported at the moment. -#### Note -Astute readers may notice similarities between the possible behaviors in ZMK and other firmware, such as QMK. The hold-preferred flavor works similar to the `HOLD_ON_OTHER_KEY_PRESS` setting. The 'balanced' flavor is similar to the `PERMISSIVE_HOLD` setting, and the `tap-preferred` flavor is similar to `IGNORE_MOD_TAP_INTERRUPT`. +#### Comparison to QMK +The hold-preferred flavor works similar to the `HOLD_ON_OTHER_KEY_PRESS` setting in QMK. The 'balanced' flavor is similar to the `PERMISSIVE_HOLD` setting, and the `tap-preferred` flavor is similar to `IGNORE_MOD_TAP_INTERRUPT`. \ No newline at end of file diff --git a/docs/docs/behavior/layers.md b/docs/docs/behavior/layers.md index da7f07f..c769388 100644 --- a/docs/docs/behavior/layers.md +++ b/docs/docs/behavior/layers.md @@ -26,7 +26,7 @@ This allows you to use those defines, e.g. `LOWER` later in your keymap. ## Momentary Layer -The "momentary layer" behavior allows you to enable a layer while a certain key is pressed. Immediately upon +The "momentary layer" behavior enables a layer while a certain key is pressed. Immediately upon activation of the key, the layer is enabled, and immediately open release of the key, the layer is disabled again. @@ -41,9 +41,25 @@ Example: &mo LOWER ``` +## Layer-tap + +The "layer-tap" behavior enables a layer when a key is held, and output another key when the key is only tapped for a short time. For more information on the inner workings of layer-tap, see [hold-tap](./hold-tap.md). + +### Behavior Binding +- Reference: `<` +- Parameter: The layer number to enable when held, e.g. `1` +- Parameter: The keycode to send when tapped, e.g. `A` + +Example: + +``` +< LOWER SPC +``` + + ## Toggle Layer -The "toggle layer" behavior allows you to enable a layer until the layer is manually disabled. +The "toggle layer" behavior enables a layer until the layer is manually disabled. ### Behavior Binding diff --git a/docs/docs/intro.md b/docs/docs/intro.md index 50a747c..8c1c043 100644 --- a/docs/docs/intro.md +++ b/docs/docs/intro.md @@ -7,31 +7,36 @@ sidebar_label: Introduction ZMK Firmware is an open source (MIT) keyboard firmware built on the [Zephyr™ Project](https://zephyrproject.org/) Real Time Operating System (RTOS). -The goal is to provider a powerful, featureful keyboard firmware that is free +The goal is to provide a powerful, featureful keyboard firmware that is free of licensing issues that prevent upstream BLE support as a first-class feature. ## Features -At this point, ZMK is _missing_ more features than it has. Currently, the mostly working bits +At this point, ZMK is still missing many features. Currently, the working bits include: -- HID Over GATT (HOG) - This is the official term for BLE HID devices -- Keymaps and layers with basic keycodes -- Some initial work on one "behavior", Mod-Tap -- Basic HID over USB -- Basic consumer (media) keycodes. -- Basic OLED display logic -- Basic Split support -- Encoders +- Wireless connectivity via BLE HID Over GATT (HOG) +- USB connectivity +- Low active power usage +- Split keyboard support +- [Keymaps and layers](behavior/layers) +- [Hold-tap](behavior/hold-tap) (which includes [mod-tap](behavior/mod-tap), [layer-tap](behavior/layers)) +- [Basic HID over USB](behavior/key-press) +- [Basic consumer (media) keycodes](behavior/key-press#consumer-key-press) +- [Encoders](feature/encoders) +- Basic [OLED display support](feature/displays) +- [RGB Underglow](feature/underglow) ## Missing Features -- One Shot -- Layer Tap -- Complete split support +- One Shot Keys +- Combo keys +- Macros +- Complete split support (encoders and RGB are not supported on the 'peripheral' side) - Battery reporting -- Low power mode +- Low power sleep states +- Low power mode (to toggle LEDs and screen off) - Shell over BLE ## Code Of Conduct -- cgit v1.2.3 From cf970efb98c5af97955bfffbcebb3b065b16edc4 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Fri, 28 Aug 2020 14:15:16 -0400 Subject: feat(bluetooth): Proper bond management, identity support for non-splits * Add `bt` behavior that can be used to perform certain actions, such as next/prev identity, reset identity, etc. NOTE: Multiple identities is only supported for non-split shields, due to missing Zephyr identity functionality for dual central/peripheral devices. * Proper bond reset tied to action, that honors peripheral bonds, so folks can reset and pair to other hosts, without breaking bonds between splt halves. --- app/CMakeLists.txt | 7 +- app/Kconfig | 29 +- app/dts/behaviors.dtsi | 3 +- app/dts/behaviors/bluetooth.dtsi | 9 + .../bindings/behaviors/zmk,behavior-bluetooth.yaml | 8 + app/include/dt-bindings/zmk/bt.h | 17 ++ app/include/zmk/ble.h | 13 + app/src/behaviors/behavior_bt.c | 62 ++++ app/src/ble.c | 335 +++++++++++++++++++-- app/src/split/bluetooth/central.c | 49 ++- docs/docs/behavior/bluetooth.md | 82 +++++ docs/sidebars.js | 1 + 12 files changed, 563 insertions(+), 52 deletions(-) create mode 100644 app/dts/behaviors/bluetooth.dtsi create mode 100644 app/dts/bindings/behaviors/zmk,behavior-bluetooth.yaml create mode 100644 app/include/dt-bindings/zmk/bt.h create mode 100644 app/src/behaviors/behavior_bt.c create mode 100644 docs/docs/behavior/bluetooth.md diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 2e24fdc..0f2d2ba 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -41,8 +41,11 @@ target_sources(app PRIVATE src/behaviors/behavior_toggle_layer.c) target_sources(app PRIVATE src/behaviors/behavior_transparent.c) target_sources(app PRIVATE src/behaviors/behavior_none.c) target_sources(app PRIVATE src/behaviors/behavior_sensor_rotate_key_press.c) -target_sources(app PRIVATE src/keymap.c) +if(NOT CONFIG_ZMK_BLE_SPLIT_PERIPHERAL) + target_sources(app PRIVATE src/keymap.c) +endif() target_sources_ifdef(CONFIG_ZMK_RGB_UNDERGLOW app PRIVATE src/behaviors/behavior_rgb_underglow.c) +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/ble_unpair_combo.c) target_sources_ifdef(CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL app PRIVATE src/split_listener.c) @@ -57,4 +60,4 @@ target_sources(app PRIVATE src/endpoints.c) target_sources(app PRIVATE src/hid_listener.c) target_sources(app PRIVATE src/main.c) -zephyr_cc_option(-Wfatal-errors) \ No newline at end of file +zephyr_cc_option(-Wfatal-errors) diff --git a/app/Kconfig b/app/Kconfig index 877fce4..b60db05 100644 --- a/app/Kconfig +++ b/app/Kconfig @@ -40,8 +40,6 @@ menuconfig ZMK_BLE select BT_PERIPHERAL select BT_GATT_DIS select BT_GATT_BAS - select SETTINGS - # select BT_SETTINGS if ZMK_BLE @@ -49,6 +47,12 @@ config ZMK_BLE_INIT_PRIORITY int "Init Priority" default 50 +config SETTINGS + default y + +config BT_SETTINGS + default y + config SYSTEM_WORKQUEUE_STACK_SIZE default 2048 @@ -103,8 +107,11 @@ config ZMK_SPLIT_BLE_ROLE_CENTRAL if ZMK_SPLIT_BLE_ROLE_CENTRAL +config BT_MAX_PAIRED + default 2 + config BT_MAX_CONN - default 5 + default 2 config BT_MAX_PAIRED # Bump this everywhere once we support switching active connections! @@ -120,15 +127,18 @@ if ZMK_SPLIT_BLE_ROLE_PERIPHERAL config ZMK_USB default n +config BT_MAX_PAIRED + default 1 config BT_MAX_CONN - default 5 + default 2 config BT_GAP_AUTO_UPDATE_CONN_PARAMS default n endif + endchoice endif @@ -138,6 +148,17 @@ endif endmenu +if ZMK_BLE && !ZMK_SPLIT_BLE + +config BT_ID_MAX + default 5 + +# Used to update the name to include the identity used +config BT_DEVICE_NAME_DYNAMIC + default y + +endif + config ZMK_KSCAN_MOCK_DRIVER bool "Enable mock kscan driver to simulate key presses" default n diff --git a/app/dts/behaviors.dtsi b/app/dts/behaviors.dtsi index ab70bcc..202202b 100644 --- a/app/dts/behaviors.dtsi +++ b/app/dts/behaviors.dtsi @@ -7,4 +7,5 @@ #include #include #include -#include \ No newline at end of file +#include +#include \ No newline at end of file diff --git a/app/dts/behaviors/bluetooth.dtsi b/app/dts/behaviors/bluetooth.dtsi new file mode 100644 index 0000000..ea09f4a --- /dev/null +++ b/app/dts/behaviors/bluetooth.dtsi @@ -0,0 +1,9 @@ +/ { + behaviors { + bt: behavior_bluetooth { + compatible = "zmk,behavior-bluetooth"; + label = "BLUETOOTH"; + #binding-cells = <2>; + }; + }; +}; diff --git a/app/dts/bindings/behaviors/zmk,behavior-bluetooth.yaml b/app/dts/bindings/behaviors/zmk,behavior-bluetooth.yaml new file mode 100644 index 0000000..127ebe0 --- /dev/null +++ b/app/dts/bindings/behaviors/zmk,behavior-bluetooth.yaml @@ -0,0 +1,8 @@ +# Copyright (c) 2020, Peter Johanson +# SPDX-License-Identifier: MIT + +description: Bluetooth Behavior + +compatible: "zmk,behavior-bluetooth" + +include: two_param.yaml diff --git a/app/include/dt-bindings/zmk/bt.h b/app/include/dt-bindings/zmk/bt.h new file mode 100644 index 0000000..6b05ff0 --- /dev/null +++ b/app/include/dt-bindings/zmk/bt.h @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2020 Peter Johanson + * + * SPDX-License-Identifier: MIT + */ + +#define BT_RST_CMD 0 +#define BT_IDENT_NEXT_CMD 1 +#define BT_IDENT_PREV_CMD 2 +#define BT_IDENT_SEL_CMD 3 +#define BT_IDENT_CLR_CMD 4 + +#define BT_RST BT_RST_CMD 0 +#define BT_IDENT_NEXT BT_IDENT_NEXT_CMD 0 +#define BT_IDENT_PREV BT_IDENT_PREV_CMD 0 +#define BT_IDENT_SEL BT_IDENT_SEL_CMD +#define BT_IDENT_CLR BT_IDENT_CLR_CMD 0 \ No newline at end of file diff --git a/app/include/zmk/ble.h b/app/include/zmk/ble.h index d0aaa96..b3762cd 100644 --- a/app/include/zmk/ble.h +++ b/app/include/zmk/ble.h @@ -6,7 +6,20 @@ #pragma once +#include #include +int zmk_ble_adv_pause(); +int zmk_ble_adv_resume(); + +int zmk_ble_identity_clear(); +int zmk_ble_identity_next(); +int zmk_ble_identity_prev(); +int zmk_ble_identity_select(u8_t index); + int zmk_ble_unpair_all(); bool zmk_ble_handle_key_user(struct zmk_key_event *key_event); + +#if IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL) +void zmk_ble_set_peripheral_addr(bt_addr_le_t *addr); +#endif /* IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL) */ \ No newline at end of file diff --git a/app/src/behaviors/behavior_bt.c b/app/src/behaviors/behavior_bt.c new file mode 100644 index 0000000..724d245 --- /dev/null +++ b/app/src/behaviors/behavior_bt.c @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2020 Peter Johanson + * + * SPDX-License-Identifier: MIT + */ + +#define DT_DRV_COMPAT zmk_behavior_bluetooth + +#include +#include + +#include + +#include + +#include +LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); + +#include + +static int on_keymap_binding_pressed(struct device *dev, u32_t position, u32_t command, u32_t arg) +{ + switch (command) + { + case BT_RST_CMD: + return zmk_ble_unpair_all(); + case BT_IDENT_CLR_CMD: + return zmk_ble_identity_clear(); +#if CONFIG_BT_ID_MAX != 1 + case BT_IDENT_NEXT_CMD: + return zmk_ble_identity_next(); + case BT_IDENT_PREV_CMD: + return zmk_ble_identity_prev(); + case BT_IDENT_SEL_CMD: + return zmk_ble_identity_select(arg); +#endif /* BT_ID_MAX != 1 */ + } + + return -ENOTSUP; +} + +static int behavior_bt_init(struct device *dev) +{ + return 0; +}; + +static int on_keymap_binding_released(struct device *dev, u32_t position, u32_t command, u32_t arg) +{ + return 0; +} + +static const struct behavior_driver_api behavior_bt_driver_api = { + .binding_pressed = on_keymap_binding_pressed, + .binding_released = on_keymap_binding_released, +}; + +DEVICE_AND_API_INIT(behavior_bt, DT_INST_LABEL(0), + behavior_bt_init, + NULL, + NULL, + APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, + &behavior_bt_driver_api); diff --git a/app/src/ble.c b/app/src/ble.c index c4d3efd..97ff461 100644 --- a/app/src/ble.c +++ b/app/src/ble.c @@ -8,6 +8,8 @@ #include #include +#include +#include #include #include @@ -15,6 +17,13 @@ #include #include #include +#include + +#if IS_ENABLED(CONFIG_SETTINGS) + +#include + +#endif #include @@ -28,16 +37,249 @@ static struct bt_conn *auth_passkey_entry_conn; static u8_t passkey_entries[6] = {0, 0, 0, 0, 0, 0}; static u8_t passkey_digit = 0; -#if IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL) -#define ZMK_ADV_PARAMS BT_LE_ADV_PARAM(BT_LE_ADV_OPT_CONNECTABLE | \ - BT_LE_ADV_OPT_USE_NAME | \ - BT_LE_ADV_OPT_ONE_TIME, \ +#define ZMK_BT_LE_ADV_PARAM_INIT(_id, _options, _int_min, _int_max, _peer) \ +{ \ + .id = _id, \ + .sid = 0, \ + .secondary_max_skip = 0, \ + .options = (_options), \ + .interval_min = (_int_min), \ + .interval_max = (_int_max), \ + .peer = (_peer), \ +} + +#define ZMK_BT_LE_ADV_PARAM(_id, _options, _int_min, _int_max, _peer) \ + ((struct bt_le_adv_param[]) { \ + ZMK_BT_LE_ADV_PARAM_INIT(_id, _options, _int_min, _int_max, _peer) \ + }) + +#if IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL) +#define ZMK_ADV_PARAMS(_id) ZMK_BT_LE_ADV_PARAM(_id, \ + BT_LE_ADV_OPT_CONNECTABLE | \ + BT_LE_ADV_OPT_ONE_TIME | \ + BT_LE_ADV_OPT_USE_NAME, \ BT_GAP_ADV_FAST_INT_MIN_2, \ BT_GAP_ADV_FAST_INT_MAX_2, NULL) #else -#define ZMK_ADV_PARAMS BT_LE_ADV_CONN_NAME +#define ZMK_ADV_PARAMS(_id) ZMK_BT_LE_ADV_PARAM(_id, \ + BT_LE_ADV_OPT_CONNECTABLE | \ + BT_LE_ADV_OPT_USE_NAME, \ + BT_GAP_ADV_FAST_INT_MIN_2, \ + BT_GAP_ADV_FAST_INT_MAX_2, NULL) #endif +static const struct bt_data zmk_ble_ad[] = { + 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) + 0x12, 0x18, /* HID Service */ +#endif + 0x0f, 0x18 /* Battery Service */ + ), +#if IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL) + BT_DATA_BYTES(BT_DATA_UUID128_ALL, + ZMK_SPLIT_BT_SERVICE_UUID) +#endif +}; + +#define IDENTITY_COUNT CONFIG_BT_ID_MAX + +#if IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL) + +static bt_addr_le_t peripheral_addr; + +#endif /* IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL) */ + + +static u8_t active_identity = 0; + +int zmk_ble_adv_pause() +{ + int err = bt_le_adv_stop(); + if (err) { + LOG_ERR("Failed to stop advertising (err %d)", err); + return err; + } + + return 0; +}; + +int zmk_ble_adv_resume() +{ + struct bt_le_adv_param *adv_params = ZMK_ADV_PARAMS(active_identity); + + LOG_DBG(""); + int err = bt_le_adv_start(adv_params, zmk_ble_ad, ARRAY_SIZE(zmk_ble_ad), NULL, 0); + if (err) + { + LOG_ERR("Advertising failed to start (err %d)", err); + return err; + } + + return 0; +}; + +static void disconnect_host_connection(struct bt_conn *conn, void *arg) +{ + struct bt_conn_info info; + bt_conn_get_info(conn, &info); + + if (info.role != BT_CONN_ROLE_SLAVE) { + return; + } + + bt_conn_disconnect(conn, BT_HCI_ERR_LOCALHOST_TERM_CONN); +}; + +static int activate_profile(u8_t index) +{ + int err; + + if (index >= IDENTITY_COUNT) { + return -EINVAL; + } + + if (active_identity != index) { + LOG_DBG("Persisting new active identity"); + active_identity = index; + +#if IS_ENABLED(CONFIG_SETTINGS) + err = settings_save_one("ble/active_identity", &active_identity, sizeof(u8_t)); + if (err) { + LOG_WRN("Failed to persist active_identity (err %d)", err); + } +#endif + +#if IS_ENABLED(CONFIG_BT_DEVICE_NAME_DYNAMIC) + char name[CONFIG_BT_DEVICE_NAME_MAX]; + snprintf(name, sizeof(name), "%s (Profile %d)", CONFIG_ZMK_KEYBOARD_NAME, active_identity + 1); + bt_set_name(name); +#endif /* IS_ENABLED(CONFIG_BT_DEVICE_NAME_DYNAMIC) */ + } + + return zmk_ble_adv_resume(); +}; + +static int deactivate_profile(u8_t index) +{ + int err = zmk_ble_adv_pause(); + if (err) { + LOG_WRN("Failed to pause advertising %d", err); + } + + bt_conn_foreach(BT_CONN_TYPE_ALL, disconnect_host_connection, NULL); + + return 0; +}; + +int zmk_ble_identity_select(u8_t index) +{ + LOG_DBG("index %d", index); + if (index >= IDENTITY_COUNT) { + return -EINVAL; + } + + int err = deactivate_profile(active_identity); + if (err) { + LOG_WRN("Failed to deactivate profile"); + return err; + } + + return activate_profile(index); +}; + +static void unpair_non_peripheral_bonds(const struct bt_bond_info *info, void *user_data) { + char addr[BT_ADDR_LE_STR_LEN]; + bt_addr_le_to_str(&info->addr, addr, sizeof(addr)); + +#if IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL) + if (!bt_addr_le_cmp(&info->addr, &peripheral_addr)) { + LOG_DBG("Skipping unpairing peripheral %s", log_strdup(addr)); + return; + } +#endif /* IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL) */ + + LOG_DBG("Unpairing %s", log_strdup(addr)); + bt_unpair(active_identity, &info->addr); +} + +int zmk_ble_identity_clear() +{ + LOG_DBG(""); + int err = deactivate_profile(active_identity); + if (err) { + return err; + } + + bt_foreach_bond(active_identity, unpair_non_peripheral_bonds, NULL); + + return activate_profile(active_identity); +}; + +int zmk_ble_identity_next() +{ + LOG_DBG("active_identity %d IDENTITY_COUNT %d", active_identity, IDENTITY_COUNT); + return zmk_ble_identity_select((active_identity + 1) % IDENTITY_COUNT); +} + +int zmk_ble_identity_prev() +{ + LOG_DBG(""); + return zmk_ble_identity_select((active_identity + IDENTITY_COUNT - 1) % IDENTITY_COUNT); +} + +#if IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL) + +void zmk_ble_set_peripheral_addr(bt_addr_le_t *addr) +{ + memcpy(&peripheral_addr, addr, sizeof(bt_addr_le_t)); + settings_save_one("ble/peripheral_address", addr, sizeof(bt_addr_le_t)); +} + +#endif /* IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL) */ + +#if IS_ENABLED(CONFIG_SETTINGS) + +static int ble_profiles_handle_set(const char *name, size_t len, settings_read_cb read_cb, void *cb_arg) +{ + const char *next; + + LOG_DBG("Setting BLE value %s", log_strdup(name)); + + if (settings_name_steq(name, "active_identity", &next) && !next) { + if (len != sizeof(active_identity)) { + return -EINVAL; + } + + int err = read_cb(cb_arg, &active_identity, sizeof(active_identity)); + if (err <= 0) { + LOG_ERR("Failed to handle profile from settings (err %d)", err); + return err; + } + LOG_DBG("Loaded active identity %d", active_identity); +#if IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL) + } else if (settings_name_steq(name, "peripheral_address", &next) && !next) { + if (len != sizeof(bt_addr_le_t)) { + return -EINVAL; + } + + int err = read_cb(cb_arg, &peripheral_addr, sizeof(bt_addr_le_t)); + if (err <= 0) { + LOG_ERR("Failed to handle peripheral address from settings (err %d)", err); + return err; + } +#endif + } + + return 0; +}; + +struct settings_handler profiles_handler = { + .name = "ble", + .h_set = ble_profiles_handle_set +}; +#endif /* IS_ENABLED(CONFIG_SETTINGS) */ + static void connected(struct bt_conn *conn, u8_t err) { char addr[BT_ADDR_LE_STR_LEN]; @@ -71,6 +313,12 @@ static void disconnected(struct bt_conn *conn, u8_t reason) bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr)); LOG_DBG("Disconnected from %s (reason 0x%02x)", log_strdup(addr), reason); + +#if IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL) + if (bt_addr_le_cmp(&peripheral_addr, BT_ADDR_LE_ANY) && bt_addr_le_cmp(&peripheral_addr, bt_conn_get_dst(conn))) { + zmk_ble_adv_resume(); + } +#endif } static void security_changed(struct bt_conn *conn, bt_security_t level, @@ -146,19 +394,6 @@ static struct bt_conn_auth_cb zmk_ble_auth_cb_display = { .cancel = auth_cancel, }; -static const struct bt_data zmk_ble_ad[] = { - 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) - 0x12, 0x18, /* HID Service */ -#endif - 0x0f, 0x18 /* Battery Service */ - ), -#if IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL) - BT_DATA_BYTES(BT_DATA_UUID128_ALL, - ZMK_SPLIT_BT_SERVICE_UUID) -#endif -}; static void zmk_ble_ready(int err) { @@ -169,17 +404,42 @@ static void zmk_ble_ready(int err) return; } - err = bt_le_adv_start(ZMK_ADV_PARAMS, zmk_ble_ad, ARRAY_SIZE(zmk_ble_ad), NULL, 0); - if (err) - { - LOG_ERR("Advertising failed to start (err %d)", err); - return; - } + zmk_ble_identity_select(active_identity); } +#if CONFIG_BT_ID_MAX != 1 +static int initialize_identities() +{ + bt_addr_le_t addrs[CONFIG_BT_ID_MAX]; + size_t count = CONFIG_BT_ID_MAX; + + LOG_DBG(""); + bt_id_get(addrs, &count); + + for (int i = 0; i < count; i++) { + char addr[BT_ADDR_LE_STR_LEN]; + bt_addr_le_to_str(&addrs[i], addr, sizeof(addr)); + LOG_DBG("Existing identity %s", log_strdup(addr)); + } + + for (int i = count; i < CONFIG_BT_ID_MAX; i++) { + LOG_DBG("Initializing identity %d", i); + int id = bt_id_create(NULL, NULL); + if (id < 0) { + LOG_ERR("Failed to create new identity with id %d", i); + return id; + } + } + + return 0; +}; +#endif /* CONFIG_BT_ID_MAX != 1 */ + static int zmk_ble_init(struct device *_arg) { - int err = bt_enable(NULL); + int err; + + err = bt_enable(NULL); if (err) { @@ -187,11 +447,23 @@ static int zmk_ble_init(struct device *_arg) return err; } - if (IS_ENABLED(CONFIG_BT_SETTINGS)) - { - settings_load(); +#if IS_ENABLED(CONFIG_SETTINGS) + settings_subsys_init(); + + err = settings_register(&profiles_handler); + if (err) { + LOG_ERR("Failed to setup the profile settings handler (err %d)", err); + return err; } + settings_load(); + +#endif + +#if CONFIG_BT_ID_MAX != 1 + initialize_identities(); +#endif /* CONFIG_BT_ID_MAX != 1 */ + bt_conn_cb_register(&conn_callbacks); bt_conn_auth_cb_register(&zmk_ble_auth_cb_display); @@ -203,7 +475,12 @@ static int zmk_ble_init(struct device *_arg) int zmk_ble_unpair_all() { LOG_DBG(""); - return bt_unpair(BT_ID_DEFAULT, NULL); + int err = bt_unpair(BT_ID_DEFAULT, NULL); + if (err) { + LOG_ERR("Failed to unpair devices (err %d)", err); + } + + return err; }; bool zmk_ble_handle_key_user(struct zmk_key_event *key_event) diff --git a/app/src/split/bluetooth/central.c b/app/src/split/bluetooth/central.c index 9e67228..df8f34e 100644 --- a/app/src/split/bluetooth/central.c +++ b/app/src/split/bluetooth/central.c @@ -10,12 +10,14 @@ #include #include #include +#include #include #include LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); +#include #include #include #include @@ -71,6 +73,18 @@ static u8_t split_central_notify_func(struct bt_conn *conn, return BT_GATT_ITER_CONTINUE; } +static int split_central_subscribe(struct bt_conn *conn) +{ + int err = bt_gatt_subscribe(conn, &subscribe_params); + if (err && err != -EALREADY) { + LOG_ERR("Subscribe failed (err %d)", err); + } else { + LOG_DBG("[SUBSCRIBED]"); + } + + return 0; +} + static u8_t split_central_discovery_func(struct bt_conn *conn, const struct bt_gatt_attr *attr, struct bt_gatt_discover_params *params) @@ -112,12 +126,7 @@ static u8_t split_central_discovery_func(struct bt_conn *conn, subscribe_params.value = BT_GATT_CCC_NOTIFY; subscribe_params.ccc_handle = attr->handle; - err = bt_gatt_subscribe(conn, &subscribe_params); - if (err && err != -EALREADY) { - LOG_ERR("Subscribe failed (err %d)", err); - } else { - LOG_DBG("[SUBSCRIBED]"); - } + split_central_subscribe(conn); return BT_GATT_ITER_STOP; } @@ -137,16 +146,20 @@ static void split_central_process_connection(struct bt_conn *conn) { } if (conn == default_conn) { - discover_params.uuid = &uuid.uuid; - discover_params.func = split_central_discovery_func; - discover_params.start_handle = 0x0001; - discover_params.end_handle = 0xffff; - discover_params.type = BT_GATT_DISCOVER_PRIMARY; + if (subscribe_params.value) { + split_central_subscribe(conn); + } else { + discover_params.uuid = &uuid.uuid; + discover_params.func = split_central_discovery_func; + discover_params.start_handle = 0x0001; + discover_params.end_handle = 0xffff; + discover_params.type = BT_GATT_DISCOVER_PRIMARY; - err = bt_gatt_discover(default_conn, &discover_params); - if (err) { - LOG_ERR("Discover failed(err %d)", err); - return; + err = bt_gatt_discover(default_conn, &discover_params); + if (err) { + LOG_ERR("Discover failed(err %d)", err); + return; + } } } @@ -194,6 +207,8 @@ static bool split_central_eir_found(struct bt_data *data, void *user_data) LOG_DBG("Found the split service"); + zmk_ble_set_peripheral_addr(addr); + err = bt_le_scan_stop(); if (err) { LOG_ERR("Stop LE scan failed (err %d)", err); @@ -206,10 +221,11 @@ static bool split_central_eir_found(struct bt_data *data, void *user_data) split_central_process_connection(default_conn); } else { param = BT_LE_CONN_PARAM(0x0006, 0x0006, 30, 400); + err = bt_conn_le_create(addr, BT_CONN_LE_CREATE_CONN, param, &default_conn); if (err) { - LOG_ERR("Create conn failed (err %d)", err); + LOG_ERR("Create conn failed (err %d) (create conn? 0x%04x)", err, BT_HCI_OP_LE_CREATE_CONN); start_scan(); } @@ -263,6 +279,7 @@ static void split_central_connected(struct bt_conn *conn, u8_t conn_err) bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr)); + if (conn_err) { LOG_ERR("Failed to connect to %s (%u)", addr, conn_err); diff --git a/docs/docs/behavior/bluetooth.md b/docs/docs/behavior/bluetooth.md new file mode 100644 index 0000000..df8ec26 --- /dev/null +++ b/docs/docs/behavior/bluetooth.md @@ -0,0 +1,82 @@ +--- +title: Bluetooth Behavior +sidebar_label: Bluetooth +--- + +## Summary + +The bluetooth behavior allows management of various settings and states related to the bluetooth connection(s) +between the keyboard and the host. + +## Bluetooth Command Defines + +Bluetooth command defines are provided through the [`dt-bindings/zmk/bt.h`](https://github.com/zmkfirmware/zmk/blob/main/app/include/dt-bindings/zmk/bt.h) header, +which is added at the top of the keymap file: + +``` +#include +``` + +This will allow you to reference the actions defined in this header such as `BT_IDENT_CLR_CMD`. + +Here is a table describing the command for each define: + +| Define | Action | +| ------------------- | ----------------------------------------------------- | +| `BT_IDENT_CLR_CMD` | Clear paired keyboards (for the current identity)[^1] | +| `BT_IDENT_NEXT_CMD` | Switch to the next identity[^1] | +| `BT_IDENT_PREV_CMD` | Switch to the previous identity | +| `BT_IDENT_SEL_CMD` | Switch to a specific numbered identity | +| `BT_RST_CMD` | Hard reset of all bluetooth bonds | + +Because the `BT_IDENT_SEL_CMD` command takes an additional parameter, the numeric index of the identity to select, _all_ the commands for the bluetooth behavior must take that additional parameter, and ignore the value. To make this easier, +there are alias defines that add those default parameters for you: + +| Define | Action | +| --------------- | --------------------------------------------------------------------------------------- | +| `BT_IDENT_CLR` | Alias for `BT_IDENT_CLR_CMD 0` to clear paired keyboards (for the current identity)[^1] | +| `BT_IDENT_NEXT` | Alias for `BT_IDENT_NEXT_CMD 0` to switch to the next identity[^1] | +| `BT_IDENT_PREV` | Alias for `BT_IDENT_PREV_CMD 0` to switch to the previous identity | +| `BT_IDENT_SEL` | Alias for `BT_IDENT_SEL_CMD` to switch to a specific numbered identity | +| `BT_RST` | Alias for `BT_RST_CMD 0` to reset all bonds[^2] | + +[^1]: Multiple keyboard identities/profiles is only support on non-split keyboards as of this time. +[^2]: This may interrupt pairing between both halves of a split keyboard. For split keyboards, it is preferred to use the [/docs/bond-reset] combo to clear bonds on both devices + +## Bluetooth Behavior + +The bluetooth behavior completes an bluetooth action given on press. + +### Behavior Binding + +- Reference: `&bt` +- Parameter #1: The bluetooth command define, e.g. `BT_IDENT_CLR_CMD` or `BT_RST_CMD` +- Parameter #2: The parameter for the command, when used to identify an identity/profile to select, e.g. `0` + +### Examples + +1. Behavior to clear the paired host: + + ``` + &bt BT_IDENT_CLR + ``` + +1. Behavior to hard reset all bonded devices[^2]: + + ``` + &bt BT_IDENT_CLR + ``` + +Examples for non-split keyboards with multiple identities: + +1. Behavior to switch to the next identity: + + ``` + &bt BT_IDENT_NEXT + ``` + +1. Behavior to switch to the specific numbered identity: + + ``` + &bt BT_IDENT_SEL 1 + ``` diff --git a/docs/sidebars.js b/docs/sidebars.js index 6bd3aa4..ace7fa1 100644 --- a/docs/sidebars.js +++ b/docs/sidebars.js @@ -22,6 +22,7 @@ module.exports = { "behavior/hold-tap", "behavior/mod-tap", "behavior/reset", + "behavior/bluetooth", "behavior/lighting", ], Development: [ -- cgit v1.2.3 From a4d06f69ac9879618e91a9befac6f2e84ef37428 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Mon, 31 Aug 2020 16:56:05 -0400 Subject: fix(bluetooth): Fix max pair settings for non-split. --- app/Kconfig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Kconfig b/app/Kconfig index b60db05..3640dc6 100644 --- a/app/Kconfig +++ b/app/Kconfig @@ -107,9 +107,6 @@ config ZMK_SPLIT_BLE_ROLE_CENTRAL if ZMK_SPLIT_BLE_ROLE_CENTRAL -config BT_MAX_PAIRED - default 2 - config BT_MAX_CONN default 2 @@ -153,6 +150,9 @@ if ZMK_BLE && !ZMK_SPLIT_BLE config BT_ID_MAX default 5 +config BT_MAX_PAIRED + default 5 + # Used to update the name to include the identity used config BT_DEVICE_NAME_DYNAMIC default y -- cgit v1.2.3 From fc0812bd2eb08d66819f38bafd1f5d00b933c87b Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Tue, 1 Sep 2020 23:22:30 -0400 Subject: fix(bluetooth): Remove identity, minimal `bt`. * Simplify the `bt` behavior to one current command `BT_CLEAR_BONDS_CMD`. * Simplify BLE code for split and non-split keyboards. * Remove keymap processing from split peripheral side. --- app/CMakeLists.txt | 4 +- app/Kconfig | 23 +----- app/include/dt-bindings/zmk/bt.h | 17 ++--- app/include/zmk/ble.h | 7 +- app/src/behaviors/behavior_bt.c | 16 +--- app/src/ble.c | 158 ++++++--------------------------------- app/src/split_listener.c | 1 + docs/docs/behavior/bluetooth.md | 58 ++++---------- 8 files changed, 52 insertions(+), 232 deletions(-) diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 0f2d2ba..ca2767f 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -41,9 +41,7 @@ target_sources(app PRIVATE src/behaviors/behavior_toggle_layer.c) target_sources(app PRIVATE src/behaviors/behavior_transparent.c) target_sources(app PRIVATE src/behaviors/behavior_none.c) target_sources(app PRIVATE src/behaviors/behavior_sensor_rotate_key_press.c) -if(NOT CONFIG_ZMK_BLE_SPLIT_PERIPHERAL) - target_sources(app PRIVATE src/keymap.c) -endif() +target_sources(app PRIVATE src/keymap.c) target_sources_ifdef(CONFIG_ZMK_RGB_UNDERGLOW app PRIVATE src/behaviors/behavior_rgb_underglow.c) target_sources_ifdef(CONFIG_ZMK_BLE app PRIVATE src/behaviors/behavior_bt.c) target_sources_ifdef(CONFIG_ZMK_BLE app PRIVATE src/ble.c) diff --git a/app/Kconfig b/app/Kconfig index 3640dc6..11a3cc0 100644 --- a/app/Kconfig +++ b/app/Kconfig @@ -40,18 +40,14 @@ menuconfig ZMK_BLE select BT_PERIPHERAL select BT_GATT_DIS select BT_GATT_BAS + select BT_SETTINGS + select SETTINGS if ZMK_BLE config ZMK_BLE_INIT_PRIORITY int "Init Priority" default 50 - -config SETTINGS - default y - -config BT_SETTINGS - default y config SYSTEM_WORKQUEUE_STACK_SIZE default 2048 @@ -144,21 +140,6 @@ endif endmenu - -if ZMK_BLE && !ZMK_SPLIT_BLE - -config BT_ID_MAX - default 5 - -config BT_MAX_PAIRED - default 5 - -# Used to update the name to include the identity used -config BT_DEVICE_NAME_DYNAMIC - default y - -endif - config ZMK_KSCAN_MOCK_DRIVER bool "Enable mock kscan driver to simulate key presses" default n diff --git a/app/include/dt-bindings/zmk/bt.h b/app/include/dt-bindings/zmk/bt.h index 6b05ff0..24d27ae 100644 --- a/app/include/dt-bindings/zmk/bt.h +++ b/app/include/dt-bindings/zmk/bt.h @@ -4,14 +4,11 @@ * SPDX-License-Identifier: MIT */ -#define BT_RST_CMD 0 -#define BT_IDENT_NEXT_CMD 1 -#define BT_IDENT_PREV_CMD 2 -#define BT_IDENT_SEL_CMD 3 -#define BT_IDENT_CLR_CMD 4 +#define BT_CLEAR_BONDS_CMD 0 -#define BT_RST BT_RST_CMD 0 -#define BT_IDENT_NEXT BT_IDENT_NEXT_CMD 0 -#define BT_IDENT_PREV BT_IDENT_PREV_CMD 0 -#define BT_IDENT_SEL BT_IDENT_SEL_CMD -#define BT_IDENT_CLR BT_IDENT_CLR_CMD 0 \ No newline at end of file +/* +Note: Some future commands will include additional parameters, so we +defines these aliases up front. +*/ + +#define BT_CLEAR_BONDS BT_CLEAR_BONDS_CMD 0 \ No newline at end of file diff --git a/app/include/zmk/ble.h b/app/include/zmk/ble.h index b3762cd..62d476e 100644 --- a/app/include/zmk/ble.h +++ b/app/include/zmk/ble.h @@ -9,13 +9,8 @@ #include #include -int zmk_ble_adv_pause(); -int zmk_ble_adv_resume(); -int zmk_ble_identity_clear(); -int zmk_ble_identity_next(); -int zmk_ble_identity_prev(); -int zmk_ble_identity_select(u8_t index); +int zmk_ble_clear_bonds(); int zmk_ble_unpair_all(); bool zmk_ble_handle_key_user(struct zmk_key_event *key_event); diff --git a/app/src/behaviors/behavior_bt.c b/app/src/behaviors/behavior_bt.c index 724d245..63a1ef1 100644 --- a/app/src/behaviors/behavior_bt.c +++ b/app/src/behaviors/behavior_bt.c @@ -22,18 +22,10 @@ static int on_keymap_binding_pressed(struct device *dev, u32_t position, u32_t c { switch (command) { - case BT_RST_CMD: - return zmk_ble_unpair_all(); - case BT_IDENT_CLR_CMD: - return zmk_ble_identity_clear(); -#if CONFIG_BT_ID_MAX != 1 - case BT_IDENT_NEXT_CMD: - return zmk_ble_identity_next(); - case BT_IDENT_PREV_CMD: - return zmk_ble_identity_prev(); - case BT_IDENT_SEL_CMD: - return zmk_ble_identity_select(arg); -#endif /* BT_ID_MAX != 1 */ + case BT_CLEAR_BONDS_CMD: + return zmk_ble_clear_bonds(); + default: + LOG_ERR("Unknown BT command: %d", command); } return -ENOTSUP; diff --git a/app/src/ble.c b/app/src/ble.c index 97ff461..0aba16c 100644 --- a/app/src/ble.c +++ b/app/src/ble.c @@ -82,8 +82,6 @@ static const struct bt_data zmk_ble_ad[] = { #endif }; -#define IDENTITY_COUNT CONFIG_BT_ID_MAX - #if IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL) static bt_addr_le_t peripheral_addr; @@ -91,8 +89,6 @@ static bt_addr_le_t peripheral_addr; #endif /* IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL) */ -static u8_t active_identity = 0; - int zmk_ble_adv_pause() { int err = bt_le_adv_stop(); @@ -106,7 +102,7 @@ int zmk_ble_adv_pause() int zmk_ble_adv_resume() { - struct bt_le_adv_param *adv_params = ZMK_ADV_PARAMS(active_identity); + struct bt_le_adv_param *adv_params = ZMK_ADV_PARAMS(BT_ID_DEFAULT); LOG_DBG(""); int err = bt_le_adv_start(adv_params, zmk_ble_ad, ARRAY_SIZE(zmk_ble_ad), NULL, 0); @@ -131,62 +127,6 @@ static void disconnect_host_connection(struct bt_conn *conn, void *arg) bt_conn_disconnect(conn, BT_HCI_ERR_LOCALHOST_TERM_CONN); }; -static int activate_profile(u8_t index) -{ - int err; - - if (index >= IDENTITY_COUNT) { - return -EINVAL; - } - - if (active_identity != index) { - LOG_DBG("Persisting new active identity"); - active_identity = index; - -#if IS_ENABLED(CONFIG_SETTINGS) - err = settings_save_one("ble/active_identity", &active_identity, sizeof(u8_t)); - if (err) { - LOG_WRN("Failed to persist active_identity (err %d)", err); - } -#endif - -#if IS_ENABLED(CONFIG_BT_DEVICE_NAME_DYNAMIC) - char name[CONFIG_BT_DEVICE_NAME_MAX]; - snprintf(name, sizeof(name), "%s (Profile %d)", CONFIG_ZMK_KEYBOARD_NAME, active_identity + 1); - bt_set_name(name); -#endif /* IS_ENABLED(CONFIG_BT_DEVICE_NAME_DYNAMIC) */ - } - - return zmk_ble_adv_resume(); -}; - -static int deactivate_profile(u8_t index) -{ - int err = zmk_ble_adv_pause(); - if (err) { - LOG_WRN("Failed to pause advertising %d", err); - } - - bt_conn_foreach(BT_CONN_TYPE_ALL, disconnect_host_connection, NULL); - - return 0; -}; - -int zmk_ble_identity_select(u8_t index) -{ - LOG_DBG("index %d", index); - if (index >= IDENTITY_COUNT) { - return -EINVAL; - } - - int err = deactivate_profile(active_identity); - if (err) { - LOG_WRN("Failed to deactivate profile"); - return err; - } - - return activate_profile(index); -}; static void unpair_non_peripheral_bonds(const struct bt_bond_info *info, void *user_data) { char addr[BT_ADDR_LE_STR_LEN]; @@ -200,34 +140,19 @@ static void unpair_non_peripheral_bonds(const struct bt_bond_info *info, void *u #endif /* IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL) */ LOG_DBG("Unpairing %s", log_strdup(addr)); - bt_unpair(active_identity, &info->addr); + bt_unpair(BT_ID_DEFAULT, &info->addr); } -int zmk_ble_identity_clear() +int zmk_ble_clear_bonds() { LOG_DBG(""); - int err = deactivate_profile(active_identity); - if (err) { - return err; - } - - bt_foreach_bond(active_identity, unpair_non_peripheral_bonds, NULL); + + bt_conn_foreach(BT_ID_DEFAULT, disconnect_host_connection, NULL); + bt_foreach_bond(BT_ID_DEFAULT, unpair_non_peripheral_bonds, NULL); - return activate_profile(active_identity); + return 0; }; -int zmk_ble_identity_next() -{ - LOG_DBG("active_identity %d IDENTITY_COUNT %d", active_identity, IDENTITY_COUNT); - return zmk_ble_identity_select((active_identity + 1) % IDENTITY_COUNT); -} - -int zmk_ble_identity_prev() -{ - LOG_DBG(""); - return zmk_ble_identity_select((active_identity + IDENTITY_COUNT - 1) % IDENTITY_COUNT); -} - #if IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL) void zmk_ble_set_peripheral_addr(bt_addr_le_t *addr) @@ -246,19 +171,8 @@ static int ble_profiles_handle_set(const char *name, size_t len, settings_read_c LOG_DBG("Setting BLE value %s", log_strdup(name)); - if (settings_name_steq(name, "active_identity", &next) && !next) { - if (len != sizeof(active_identity)) { - return -EINVAL; - } - - int err = read_cb(cb_arg, &active_identity, sizeof(active_identity)); - if (err <= 0) { - LOG_ERR("Failed to handle profile from settings (err %d)", err); - return err; - } - LOG_DBG("Loaded active identity %d", active_identity); #if IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL) - } else if (settings_name_steq(name, "peripheral_address", &next) && !next) { + if (settings_name_steq(name, "peripheral_address", &next) && !next) { if (len != sizeof(bt_addr_le_t)) { return -EINVAL; } @@ -268,8 +182,8 @@ static int ble_profiles_handle_set(const char *name, size_t len, settings_read_c LOG_ERR("Failed to handle peripheral address from settings (err %d)", err); return err; } -#endif } +#endif return 0; }; @@ -318,6 +232,8 @@ static void disconnected(struct bt_conn *conn, u8_t reason) if (bt_addr_le_cmp(&peripheral_addr, BT_ADDR_LE_ANY) && bt_addr_le_cmp(&peripheral_addr, bt_conn_get_dst(conn))) { zmk_ble_adv_resume(); } +#else + zmk_ble_adv_resume(); #endif } @@ -404,42 +320,12 @@ static void zmk_ble_ready(int err) return; } - zmk_ble_identity_select(active_identity); + zmk_ble_adv_resume(); } -#if CONFIG_BT_ID_MAX != 1 -static int initialize_identities() -{ - bt_addr_le_t addrs[CONFIG_BT_ID_MAX]; - size_t count = CONFIG_BT_ID_MAX; - - LOG_DBG(""); - bt_id_get(addrs, &count); - - for (int i = 0; i < count; i++) { - char addr[BT_ADDR_LE_STR_LEN]; - bt_addr_le_to_str(&addrs[i], addr, sizeof(addr)); - LOG_DBG("Existing identity %s", log_strdup(addr)); - } - - for (int i = count; i < CONFIG_BT_ID_MAX; i++) { - LOG_DBG("Initializing identity %d", i); - int id = bt_id_create(NULL, NULL); - if (id < 0) { - LOG_ERR("Failed to create new identity with id %d", i); - return id; - } - } - - return 0; -}; -#endif /* CONFIG_BT_ID_MAX != 1 */ - static int zmk_ble_init(struct device *_arg) { - int err; - - err = bt_enable(NULL); + int err = bt_enable(NULL); if (err) { @@ -460,10 +346,6 @@ static int zmk_ble_init(struct device *_arg) #endif -#if CONFIG_BT_ID_MAX != 1 - initialize_identities(); -#endif /* CONFIG_BT_ID_MAX != 1 */ - bt_conn_cb_register(&conn_callbacks); bt_conn_auth_cb_register(&zmk_ble_auth_cb_display); @@ -474,13 +356,17 @@ static int zmk_ble_init(struct device *_arg) int zmk_ble_unpair_all() { - LOG_DBG(""); - int err = bt_unpair(BT_ID_DEFAULT, NULL); - if (err) { - LOG_ERR("Failed to unpair devices (err %d)", err); + int resp = 0; + for (int i = BT_ID_DEFAULT; i < CONFIG_BT_ID_MAX; i++) { + + int err = bt_unpair(BT_ID_DEFAULT, NULL); + if (err) { + resp = err; + LOG_ERR("Failed to unpair devices (err %d)", err); + } } - return err; + return resp; }; bool zmk_ble_handle_key_user(struct zmk_key_event *key_event) diff --git a/app/src/split_listener.c b/app/src/split_listener.c index 46a95e1..ee59c48 100644 --- a/app/src/split_listener.c +++ b/app/src/split_listener.c @@ -21,6 +21,7 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); int split_listener(const struct zmk_event_header *eh) { + LOG_DBG(""); if (is_position_state_changed(eh)) { const struct position_state_changed *ev = cast_position_state_changed(eh); if (ev->state) { diff --git a/docs/docs/behavior/bluetooth.md b/docs/docs/behavior/bluetooth.md index df8ec26..f605c96 100644 --- a/docs/docs/behavior/bluetooth.md +++ b/docs/docs/behavior/bluetooth.md @@ -6,7 +6,8 @@ sidebar_label: Bluetooth ## Summary The bluetooth behavior allows management of various settings and states related to the bluetooth connection(s) -between the keyboard and the host. +between the keyboard and the host. As of right now, there is only one such action support, but in the future +more will be added. ## Bluetooth Command Defines @@ -17,31 +18,20 @@ which is added at the top of the keymap file: #include ``` -This will allow you to reference the actions defined in this header such as `BT_IDENT_CLR_CMD`. +This will allow you to reference the actions defined in this header such as `BT_CLEAR_BONDS_CMD`. Here is a table describing the command for each define: -| Define | Action | -| ------------------- | ----------------------------------------------------- | -| `BT_IDENT_CLR_CMD` | Clear paired keyboards (for the current identity)[^1] | -| `BT_IDENT_NEXT_CMD` | Switch to the next identity[^1] | -| `BT_IDENT_PREV_CMD` | Switch to the previous identity | -| `BT_IDENT_SEL_CMD` | Switch to a specific numbered identity | -| `BT_RST_CMD` | Hard reset of all bluetooth bonds | +| Define | Action | +| -------------------- | --------------------------------------------------------- | +| `BT_CLEAR_BONDS_CMD` | Clear bond information between the keyboard and host [^1] | -Because the `BT_IDENT_SEL_CMD` command takes an additional parameter, the numeric index of the identity to select, _all_ the commands for the bluetooth behavior must take that additional parameter, and ignore the value. To make this easier, -there are alias defines that add those default parameters for you: +Because future bluetooth commands will take an additional parameter, it is recommended to use +the following alias in your keymap to avoid having to change it later. -| Define | Action | -| --------------- | --------------------------------------------------------------------------------------- | -| `BT_IDENT_CLR` | Alias for `BT_IDENT_CLR_CMD 0` to clear paired keyboards (for the current identity)[^1] | -| `BT_IDENT_NEXT` | Alias for `BT_IDENT_NEXT_CMD 0` to switch to the next identity[^1] | -| `BT_IDENT_PREV` | Alias for `BT_IDENT_PREV_CMD 0` to switch to the previous identity | -| `BT_IDENT_SEL` | Alias for `BT_IDENT_SEL_CMD` to switch to a specific numbered identity | -| `BT_RST` | Alias for `BT_RST_CMD 0` to reset all bonds[^2] | - -[^1]: Multiple keyboard identities/profiles is only support on non-split keyboards as of this time. -[^2]: This may interrupt pairing between both halves of a split keyboard. For split keyboards, it is preferred to use the [/docs/bond-reset] combo to clear bonds on both devices +| Define | Action | +| ---------------- | ---------------------------------------------------------------------- | +| `BT_CLEAR_BONDS` | Alias for `BT_CLEAR_BONDS_CMD 0` to clear the bond to the current host | ## Bluetooth Behavior @@ -50,33 +40,13 @@ The bluetooth behavior completes an bluetooth action given on press. ### Behavior Binding - Reference: `&bt` -- Parameter #1: The bluetooth command define, e.g. `BT_IDENT_CLR_CMD` or `BT_RST_CMD` -- Parameter #2: The parameter for the command, when used to identify an identity/profile to select, e.g. `0` +- Parameter #1: The bluetooth command define, e.g. `BT_CLEAR_BONDS_CMD` +- Parameter #2: (Reserved for future bluetooth command types) ### Examples 1. Behavior to clear the paired host: ``` - &bt BT_IDENT_CLR - ``` - -1. Behavior to hard reset all bonded devices[^2]: - - ``` - &bt BT_IDENT_CLR - ``` - -Examples for non-split keyboards with multiple identities: - -1. Behavior to switch to the next identity: - - ``` - &bt BT_IDENT_NEXT - ``` - -1. Behavior to switch to the specific numbered identity: - - ``` - &bt BT_IDENT_SEL 1 + &bt BT_CLEAR_BONDS ``` -- cgit v1.2.3 From 13842a8a1e45b399864ba1ae5a759c614313b4db Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Thu, 3 Sep 2020 13:21:01 -0400 Subject: fix(bluetooth): Kconfig to clear bonds on start --- app/Kconfig | 4 ++++ app/src/ble.c | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/app/Kconfig b/app/Kconfig index 11a3cc0..b9d05a9 100644 --- a/app/Kconfig +++ b/app/Kconfig @@ -52,6 +52,10 @@ config ZMK_BLE_INIT_PRIORITY config SYSTEM_WORKQUEUE_STACK_SIZE default 2048 +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. config BT_GATT_NOTIFY_MULTIPLE default n diff --git a/app/src/ble.c b/app/src/ble.c index 0aba16c..1e748ed 100644 --- a/app/src/ble.c +++ b/app/src/ble.c @@ -346,6 +346,12 @@ static int zmk_ble_init(struct device *_arg) #endif +#if IS_ENABLED(CONFIG_ZMK_BLE_CLEAR_BONDS_ON_START) + for (int i = 0; i < 10; i++) { + bt_unpair(i, NULL); + } +#endif + bt_conn_cb_register(&conn_callbacks); bt_conn_auth_cb_register(&zmk_ble_auth_cb_display); -- cgit v1.2.3 From b103eb4b059b60ebff81eb45db8405ed3a381257 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Thu, 3 Sep 2020 14:55:15 -0400 Subject: fix(bluetooth): Delete any previously stored name. --- app/src/ble.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/ble.c b/app/src/ble.c index 1e748ed..f723762 100644 --- a/app/src/ble.c +++ b/app/src/ble.c @@ -347,6 +347,8 @@ static int zmk_ble_init(struct device *_arg) #endif #if IS_ENABLED(CONFIG_ZMK_BLE_CLEAR_BONDS_ON_START) + settings_delete("bt/name"); + for (int i = 0; i < 10; i++) { bt_unpair(i, NULL); } -- cgit v1.2.3 From e88d0833c5f8ddd2b8a9b93ab7b6d03c141f8463 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Thu, 3 Sep 2020 21:11:21 -0400 Subject: fix(bluetooth): Log when clearing on start. --- app/src/ble.c | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/ble.c b/app/src/ble.c index f723762..7ef95ca 100644 --- a/app/src/ble.c +++ b/app/src/ble.c @@ -347,6 +347,7 @@ static int zmk_ble_init(struct device *_arg) #endif #if IS_ENABLED(CONFIG_ZMK_BLE_CLEAR_BONDS_ON_START) + LOG_WRN("Clearing all existing BLE bond information from the keyboard"); settings_delete("bt/name"); for (int i = 0; i < 10; i++) { -- cgit v1.2.3 From 39f980a06dac1769e4f09abaf19d3ccbb4b34e67 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Tue, 8 Sep 2020 23:26:00 -0400 Subject: feat(bluetooth): Add back profiles, split fixes. * Add back in profiles, not using Zephyr BT identity infrastructure. * Restore additional `&bt` commands for profile operations. * Fix for split pairing and subscriptions, since Zephyr persists subscriptions across connects. * Remove keymap from peripheral builds, reduces firmware size, and avoids unneeded attempts to send HID data. --- app/CMakeLists.txt | 23 +- app/Kconfig | 26 +-- app/include/dt-bindings/zmk/bt.h | 11 +- app/include/zmk/ble.h | 9 +- app/include/zmk/ble/profile.h | 16 ++ .../zmk/events/ble-active-profile-changed.h | 22 ++ app/src/behaviors/behavior_bt.c | 6 + app/src/ble.c | 238 +++++++++++++++------ app/src/events/ble_active_profile_changed.c | 10 + app/src/hog.c | 36 +++- app/src/split/bluetooth/central.c | 43 ++-- app/src/split/bluetooth/service.c | 6 + app/src/split_listener.c | 4 +- docs/docs/behavior/bluetooth.md | 46 +++- 14 files changed, 372 insertions(+), 124 deletions(-) create mode 100644 app/include/zmk/ble/profile.h create mode 100644 app/include/zmk/events/ble-active-profile-changed.h create mode 100644 app/src/events/ble_active_profile_changed.c diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index ca2767f..3e0560b 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -29,23 +29,26 @@ target_sources(app PRIVATE src/hid.c) target_sources(app PRIVATE src/sensors.c) target_sources_ifdef(CONFIG_ZMK_DISPLAY app PRIVATE src/display.c) target_sources(app PRIVATE src/event_manager.c) +target_sources_ifdef(CONFIG_ZMK_BLE app PRIVATE src/ble_unpair_combo.c) target_sources(app PRIVATE src/events/position_state_changed.c) target_sources(app PRIVATE src/events/keycode_state_changed.c) target_sources(app PRIVATE src/events/modifiers_state_changed.c) target_sources(app PRIVATE src/events/sensor_event.c) -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) -target_sources(app PRIVATE src/behaviors/behavior_momentary_layer.c) -target_sources(app PRIVATE src/behaviors/behavior_toggle_layer.c) -target_sources(app PRIVATE src/behaviors/behavior_transparent.c) -target_sources(app PRIVATE src/behaviors/behavior_none.c) -target_sources(app PRIVATE src/behaviors/behavior_sensor_rotate_key_press.c) -target_sources(app PRIVATE src/keymap.c) +target_sources_ifdef(CONFIG_ZMK_BLE app PRIVATE src/events/ble_active_profile_changed.c) +if (NOT CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL) + 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) + target_sources(app PRIVATE src/behaviors/behavior_momentary_layer.c) + target_sources(app PRIVATE src/behaviors/behavior_toggle_layer.c) + target_sources(app PRIVATE src/behaviors/behavior_transparent.c) + target_sources(app PRIVATE src/behaviors/behavior_none.c) + target_sources(app PRIVATE src/behaviors/behavior_sensor_rotate_key_press.c) + target_sources(app PRIVATE src/keymap.c) +endif() target_sources_ifdef(CONFIG_ZMK_RGB_UNDERGLOW app PRIVATE src/behaviors/behavior_rgb_underglow.c) 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/ble_unpair_combo.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) diff --git a/app/Kconfig b/app/Kconfig index b9d05a9..917674d 100644 --- a/app/Kconfig +++ b/app/Kconfig @@ -37,6 +37,7 @@ menuconfig ZMK_BLE select BT select BT_SMP select BT_SMP_SC_PAIR_ONLY + select BT_SMP_APP_PAIRING_ACCEPT select BT_PERIPHERAL select BT_GATT_DIS select BT_GATT_BAS @@ -105,19 +106,9 @@ config ZMK_SPLIT_BLE_ROLE_CENTRAL select BT_CENTRAL select BT_GATT_CLIENT -if ZMK_SPLIT_BLE_ROLE_CENTRAL - -config BT_MAX_CONN - default 2 - -config BT_MAX_PAIRED - # Bump this everywhere once we support switching active connections! - default 2 - -endif - config ZMK_SPLIT_BLE_ROLE_PERIPHERAL bool "Peripheral" + select BT_KEYS_OVERWRITE_OLDEST if ZMK_SPLIT_BLE_ROLE_PERIPHERAL @@ -128,16 +119,25 @@ config BT_MAX_PAIRED default 1 config BT_MAX_CONN - default 2 + default 1 config BT_GAP_AUTO_UPDATE_CONN_PARAMS default n endif - endchoice +if ZMK_BLE && (!ZMK_SPLIT_BLE || ZMK_SPLIT_BLE_ROLE_CENTRAL) + +config BT_MAX_CONN + default 6 + +config BT_MAX_PAIRED + default 5 + +endif + endif endif diff --git a/app/include/dt-bindings/zmk/bt.h b/app/include/dt-bindings/zmk/bt.h index 24d27ae..b2899ab 100644 --- a/app/include/dt-bindings/zmk/bt.h +++ b/app/include/dt-bindings/zmk/bt.h @@ -4,11 +4,18 @@ * SPDX-License-Identifier: MIT */ -#define BT_CLEAR_BONDS_CMD 0 +#define BT_CLEAR_BONDS_CMD 0 +#define BT_PROF_NEXT_CMD 1 +#define BT_PROF_PREV_CMD 2 +#define BT_PROF_SEL_CMD 3 +// #define BT_FULL_RESET_CMD 4 /* Note: Some future commands will include additional parameters, so we defines these aliases up front. */ -#define BT_CLEAR_BONDS BT_CLEAR_BONDS_CMD 0 \ No newline at end of file +#define BT_CLEAR_BONDS BT_CLEAR_BONDS_CMD 0 +#define BT_PROF_NEXT BT_PROF_NEXT_CMD 0 +#define BT_PROF_PREV BT_PROF_PREV_CMD 0 +#define BT_PROF_SEL BT_PROF_SEL_CMD \ No newline at end of file diff --git a/app/include/zmk/ble.h b/app/include/zmk/ble.h index 62d476e..1cf71a7 100644 --- a/app/include/zmk/ble.h +++ b/app/include/zmk/ble.h @@ -6,11 +6,16 @@ #pragma once -#include #include - +#include int zmk_ble_clear_bonds(); +int zmk_ble_prof_next(); +int zmk_ble_prof_prev(); +int zmk_ble_prof_select(u8_t index); + +bt_addr_le_t *zmk_ble_active_profile_addr(); +char *zmk_ble_active_profile_name(); int zmk_ble_unpair_all(); bool zmk_ble_handle_key_user(struct zmk_key_event *key_event); diff --git a/app/include/zmk/ble/profile.h b/app/include/zmk/ble/profile.h new file mode 100644 index 0000000..9a79c6d --- /dev/null +++ b/app/include/zmk/ble/profile.h @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2020 Peter Johanson + * + * SPDX-License-Identifier: MIT + */ + +#pragma once + +#include + +#define ZMK_BLE_PROFILE_NAME_MAX 15 + +struct zmk_ble_profile { + char name[ZMK_BLE_PROFILE_NAME_MAX]; + bt_addr_le_t peer; +}; diff --git a/app/include/zmk/events/ble-active-profile-changed.h b/app/include/zmk/events/ble-active-profile-changed.h new file mode 100644 index 0000000..c464236 --- /dev/null +++ b/app/include/zmk/events/ble-active-profile-changed.h @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2020 Peter Johanson + * + * SPDX-License-Identifier: MIT + */ + +#pragma once + +#include +#include +#include + +#include + + +struct ble_active_profile_changed { + struct zmk_event_header header; + u8_t index; + struct zmk_ble_profile *profile; +}; + +ZMK_EVENT_DECLARE(ble_active_profile_changed); diff --git a/app/src/behaviors/behavior_bt.c b/app/src/behaviors/behavior_bt.c index 63a1ef1..bf15683 100644 --- a/app/src/behaviors/behavior_bt.c +++ b/app/src/behaviors/behavior_bt.c @@ -24,6 +24,12 @@ static int on_keymap_binding_pressed(struct device *dev, u32_t position, u32_t c { case BT_CLEAR_BONDS_CMD: return zmk_ble_clear_bonds(); + case BT_PROF_NEXT_CMD: + return zmk_ble_prof_next(); + case BT_PROF_PREV_CMD: + return zmk_ble_prof_prev(); + case BT_PROF_SEL_CMD: + return zmk_ble_prof_select(arg); default: LOG_ERR("Unknown BT command: %d", command); } diff --git a/app/src/ble.c b/app/src/ble.c index 7ef95ca..40e05a3 100644 --- a/app/src/ble.c +++ b/app/src/ble.c @@ -25,49 +25,30 @@ #endif - #include LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); +#include #include #include +#include +#include static struct bt_conn *auth_passkey_entry_conn; static u8_t passkey_entries[6] = {0, 0, 0, 0, 0, 0}; static u8_t passkey_digit = 0; -#define ZMK_BT_LE_ADV_PARAM_INIT(_id, _options, _int_min, _int_max, _peer) \ -{ \ - .id = _id, \ - .sid = 0, \ - .secondary_max_skip = 0, \ - .options = (_options), \ - .interval_min = (_int_min), \ - .interval_max = (_int_max), \ - .peer = (_peer), \ -} - -#define ZMK_BT_LE_ADV_PARAM(_id, _options, _int_min, _int_max, _peer) \ - ((struct bt_le_adv_param[]) { \ - ZMK_BT_LE_ADV_PARAM_INIT(_id, _options, _int_min, _int_max, _peer) \ - }) - #if IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL) -#define ZMK_ADV_PARAMS(_id) ZMK_BT_LE_ADV_PARAM(_id, \ - BT_LE_ADV_OPT_CONNECTABLE | \ - BT_LE_ADV_OPT_ONE_TIME | \ - BT_LE_ADV_OPT_USE_NAME, \ - BT_GAP_ADV_FAST_INT_MIN_2, \ - BT_GAP_ADV_FAST_INT_MAX_2, NULL) +#define PROFILE_COUNT (CONFIG_BT_MAX_PAIRED - 1) #else -#define ZMK_ADV_PARAMS(_id) ZMK_BT_LE_ADV_PARAM(_id, \ - BT_LE_ADV_OPT_CONNECTABLE | \ - BT_LE_ADV_OPT_USE_NAME, \ - BT_GAP_ADV_FAST_INT_MIN_2, \ - BT_GAP_ADV_FAST_INT_MAX_2, NULL) +#define PROFILE_COUNT CONFIG_BT_MAX_PAIRED #endif + +static struct zmk_ble_profile profiles[PROFILE_COUNT]; +static u8_t active_profile; + static const struct bt_data zmk_ble_ad[] = { BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)), BT_DATA_BYTES(BT_DATA_UUID16_SOME, @@ -88,6 +69,33 @@ static bt_addr_le_t peripheral_addr; #endif /* IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL) */ +static void raise_profile_changed_event() +{ + struct ble_active_profile_changed *ev = new_ble_active_profile_changed(); + ev->index = active_profile; + ev->profile = &profiles[active_profile]; + + ZMK_EVENT_RAISE(ev); +} + +static bool active_profile_is_open() +{ + return !bt_addr_le_cmp(&profiles[active_profile].peer, BT_ADDR_LE_ANY); +} + +void set_profile_address(u8_t index, const bt_addr_le_t *addr) +{ + char setting_name[15]; + char addr_str[BT_ADDR_LE_STR_LEN]; + + bt_addr_le_to_str(addr, addr_str, sizeof(addr_str)); + + memcpy(&profiles[index].peer, addr, sizeof(bt_addr_le_t)); + sprintf(setting_name, "ble/profiles/%d", index); + LOG_DBG("Setting profile addr for %s to %s", log_strdup(setting_name), log_strdup(addr_str)); + settings_save_one(setting_name, &profiles[index], sizeof(struct zmk_ble_profile)); + raise_profile_changed_event(); +} int zmk_ble_adv_pause() { @@ -102,10 +110,12 @@ int zmk_ble_adv_pause() int zmk_ble_adv_resume() { - struct bt_le_adv_param *adv_params = ZMK_ADV_PARAMS(BT_ID_DEFAULT); + LOG_DBG("active_profile %d, directed? %s", active_profile, active_profile_is_open() ? "no" : "yes"); - LOG_DBG(""); - int err = bt_le_adv_start(adv_params, zmk_ble_ad, ARRAY_SIZE(zmk_ble_ad), NULL, 0); + int err = bt_le_adv_start( + BT_LE_ADV_CONN_NAME, + zmk_ble_ad, ARRAY_SIZE(zmk_ble_ad), + NULL, 0); if (err) { LOG_ERR("Advertising failed to start (err %d)", err); @@ -115,44 +125,54 @@ int zmk_ble_adv_resume() return 0; }; -static void disconnect_host_connection(struct bt_conn *conn, void *arg) +int zmk_ble_clear_bonds() { - struct bt_conn_info info; - bt_conn_get_info(conn, &info); - - if (info.role != BT_CONN_ROLE_SLAVE) { - return; + LOG_DBG(""); + + if (bt_addr_le_cmp(&profiles[active_profile].peer, BT_ADDR_LE_ANY)) { + LOG_DBG("Unpairing!"); + bt_unpair(BT_ID_DEFAULT, &profiles[active_profile].peer); + set_profile_address(active_profile, BT_ADDR_LE_ANY); } - bt_conn_disconnect(conn, BT_HCI_ERR_LOCALHOST_TERM_CONN); + return 0; }; - -static void unpair_non_peripheral_bonds(const struct bt_bond_info *info, void *user_data) { - char addr[BT_ADDR_LE_STR_LEN]; - bt_addr_le_to_str(&info->addr, addr, sizeof(addr)); - -#if IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL) - if (!bt_addr_le_cmp(&info->addr, &peripheral_addr)) { - LOG_DBG("Skipping unpairing peripheral %s", log_strdup(addr)); - return; +int zmk_ble_prof_select(u8_t index) +{ + LOG_DBG("profile %d", index); + if (active_profile == index) { + return 0; } -#endif /* IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL) */ - LOG_DBG("Unpairing %s", log_strdup(addr)); - bt_unpair(BT_ID_DEFAULT, &info->addr); -} + active_profile = index; + return settings_save_one("ble/active_profile", &active_profile, sizeof(active_profile)); -int zmk_ble_clear_bonds() + raise_profile_changed_event(); +}; + +int zmk_ble_prof_next() { LOG_DBG(""); - - bt_conn_foreach(BT_ID_DEFAULT, disconnect_host_connection, NULL); - bt_foreach_bond(BT_ID_DEFAULT, unpair_non_peripheral_bonds, NULL); + return zmk_ble_prof_select((active_profile + 1) % PROFILE_COUNT); +}; - return 0; +int zmk_ble_prof_prev() +{ + LOG_DBG(""); + return zmk_ble_prof_select((active_profile + PROFILE_COUNT - 1) % PROFILE_COUNT); }; +bt_addr_le_t *zmk_ble_active_profile_addr() +{ + return &profiles[active_profile].peer; +} + +char *zmk_ble_active_profile_name() +{ + return profiles[active_profile].name; +} + #if IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL) void zmk_ble_set_peripheral_addr(bt_addr_le_t *addr) @@ -171,8 +191,47 @@ static int ble_profiles_handle_set(const char *name, size_t len, settings_read_c LOG_DBG("Setting BLE value %s", log_strdup(name)); + if (settings_name_steq(name, "profiles", &next) && next) { + char *endptr; + u8_t idx = strtoul(next, &endptr, 10); + if (*endptr != '\0') { + LOG_WRN("Invalid profile index: %s", log_strdup(next)); + return -EINVAL; + } + + if (len != sizeof(struct zmk_ble_profile)) { + LOG_ERR("Invalid profile size (got %d expected %d)", len, sizeof(struct zmk_ble_profile)); + return -EINVAL; + } + + if (idx >= PROFILE_COUNT) { + LOG_WRN("Profile address for index %d is larger than max of %d", idx, PROFILE_COUNT); + return -EINVAL; + } + + int err = read_cb(cb_arg, &profiles[idx], sizeof(struct zmk_ble_profile)); + if (err <= 0) { + LOG_ERR("Failed to handle profile address from settings (err %d)", err); + return err; + } + + char addr_str[BT_ADDR_LE_STR_LEN]; + bt_addr_le_to_str(&profiles[idx].peer, addr_str, sizeof(addr_str)); + + LOG_DBG("Loaded %s address for profile %d", log_strdup(addr_str), idx); + } else if (settings_name_steq(name, "active_profile", &next) && !next) { + if (len != sizeof(active_profile)) { + return -EINVAL; + } + + int err = read_cb(cb_arg, &active_profile, sizeof(active_profile)); + if (err <= 0) { + LOG_ERR("Failed to handle active profile from settings (err %d)", err); + return err; + } + } #if IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL) - if (settings_name_steq(name, "peripheral_address", &next) && !next) { + else if (settings_name_steq(name, "peripheral_address", &next) && !next) { if (len != sizeof(bt_addr_le_t)) { return -EINVAL; } @@ -197,7 +256,6 @@ struct settings_handler profiles_handler = { static void connected(struct bt_conn *conn, u8_t err) { char addr[BT_ADDR_LE_STR_LEN]; - bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr)); if (err) @@ -229,11 +287,11 @@ static void disconnected(struct bt_conn *conn, u8_t reason) LOG_DBG("Disconnected from %s (reason 0x%02x)", log_strdup(addr), reason); #if IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL) - if (bt_addr_le_cmp(&peripheral_addr, BT_ADDR_LE_ANY) && bt_addr_le_cmp(&peripheral_addr, bt_conn_get_dst(conn))) { - zmk_ble_adv_resume(); - } + // if (bt_addr_le_cmp(&peripheral_addr, BT_ADDR_LE_ANY) && bt_addr_le_cmp(&peripheral_addr, bt_conn_get_dst(conn))) { + // zmk_ble_adv_resume(); + // } #else - zmk_ble_adv_resume(); + // zmk_ble_adv_resume(); #endif } @@ -301,7 +359,52 @@ 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) +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; + bt_conn_get_info(conn, &info); + + LOG_DBG("role %d, open? %s", info.role, active_profile_is_open() ? "yes" : "no"); + if (info.role != BT_CONN_ROLE_SLAVE && !active_profile_is_open()) { + LOG_WRN("Rejecting pairing request to taken profile %d", active_profile); + return BT_SECURITY_ERR_PAIR_NOT_ALLOWED; + } + + return BT_SECURITY_ERR_SUCCESS; +}; +#endif /* !IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL) */ + +static void auth_pairing_complete(struct bt_conn *conn, bool bonded) +{ + struct bt_conn_info info; + char addr[BT_ADDR_LE_STR_LEN]; + const bt_addr_le_t *dst = bt_conn_get_dst(conn); + + bt_addr_le_to_str(dst, addr, sizeof(addr)); + bt_conn_get_info(conn, &info); + + if (info.role != BT_CONN_ROLE_SLAVE) { + LOG_DBG("SKIPPING FOR ROLE %d", info.role); + return; + } + +#if !IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL) + if (!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) */ + + set_profile_address(active_profile, dst); +}; + static struct bt_conn_auth_cb zmk_ble_auth_cb_display = { +#if !IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL) + .pairing_accept = auth_pairing_accept, +#endif /* !IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL) */ + .pairing_complete = auth_pairing_complete, // .passkey_display = auth_passkey_display, #ifdef CONFIG_ZMK_BLE_PASSKEY_ENTRY @@ -348,11 +451,20 @@ static int zmk_ble_init(struct device *_arg) #if IS_ENABLED(CONFIG_ZMK_BLE_CLEAR_BONDS_ON_START) LOG_WRN("Clearing all existing BLE bond information from the keyboard"); - settings_delete("bt/name"); for (int i = 0; i < 10; i++) { bt_unpair(i, NULL); } + + for (int i = 0; i < PROFILE_COUNT; i++) { + char setting_name[15]; + sprintf(setting_name, "ble/profiles/%d", i); + + err = settings_delete(setting_name); + if (err) { + LOG_ERR("Failed to delete setting: %d", err); + } + } #endif bt_conn_cb_register(&conn_callbacks); diff --git a/app/src/events/ble_active_profile_changed.c b/app/src/events/ble_active_profile_changed.c new file mode 100644 index 0000000..a270a14 --- /dev/null +++ b/app/src/events/ble_active_profile_changed.c @@ -0,0 +1,10 @@ +/* + * Copyright (c) 2020 Peter Johanson + * + * SPDX-License-Identifier: MIT + */ + +#include +#include + +ZMK_EVENT_IMPL(ble_active_profile_changed); \ No newline at end of file diff --git a/app/src/hog.c b/app/src/hog.c index 92858d5..93e6d9b 100644 --- a/app/src/hog.c +++ b/app/src/hog.c @@ -6,6 +6,10 @@ #include +#include + +LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); + #include #include @@ -148,12 +152,40 @@ BT_GATT_SERVICE_DEFINE(hog_svc, BT_GATT_PERM_WRITE, NULL, write_ctrl_point, &ctrl_point)); +struct bt_conn *destination_connection() { + struct bt_conn *conn; + bt_addr_le_t *addr = zmk_ble_active_profile_addr(); + LOG_DBG("Address pointer %p", addr); + if (!bt_addr_le_cmp(addr, BT_ADDR_LE_ANY)) { + LOG_WRN("Not sending, no active address for current profile"); + return NULL; + } else if ((conn = bt_conn_lookup_addr_le(BT_ID_DEFAULT, addr)) == NULL) { + LOG_WRN("Not sending, not connected to active profile"); + return NULL; + } + + return conn; + +} + int zmk_hog_send_keypad_report(struct zmk_hid_keypad_report_body *report) { - return bt_gatt_notify(NULL, &hog_svc.attrs[5], report, sizeof(struct zmk_hid_keypad_report_body)); + struct bt_conn *conn = destination_connection(); + if (conn == NULL) { + return -ENOTCONN; + } + + LOG_DBG("Sending to NULL? %s", conn == NULL ? "yes" : "no"); + + return bt_gatt_notify(conn, &hog_svc.attrs[5], report, sizeof(struct zmk_hid_keypad_report_body)); }; int zmk_hog_send_consumer_report(struct zmk_hid_consumer_report_body *report) { - return bt_gatt_notify(NULL, &hog_svc.attrs[10], report, sizeof(struct zmk_hid_consumer_report_body)); + struct bt_conn *conn = destination_connection(); + if (conn == NULL) { + return -ENOTCONN; + } + + return bt_gatt_notify(conn, &hog_svc.attrs[10], report, sizeof(struct zmk_hid_consumer_report_body)); }; diff --git a/app/src/split/bluetooth/central.c b/app/src/split/bluetooth/central.c index df8f34e..6d8b435 100644 --- a/app/src/split/bluetooth/central.c +++ b/app/src/split/bluetooth/central.c @@ -76,10 +76,19 @@ static u8_t split_central_notify_func(struct bt_conn *conn, static int split_central_subscribe(struct bt_conn *conn) { int err = bt_gatt_subscribe(conn, &subscribe_params); - if (err && err != -EALREADY) { - LOG_ERR("Subscribe failed (err %d)", err); - } else { + switch (err) { + case -EALREADY: + LOG_DBG("[ALREADY SUBSCRIBED]"); + break; + // break; + // bt_gatt_unsubscribe(conn, &subscribe_params); + // return split_central_subscribe(conn); + case 0: LOG_DBG("[SUBSCRIBED]"); + break; + default: + LOG_ERR("Subscribe failed (err %d)", err); + break; } return 0; @@ -145,21 +154,17 @@ static void split_central_process_connection(struct bt_conn *conn) { return; } - if (conn == default_conn) { - if (subscribe_params.value) { - split_central_subscribe(conn); - } else { - discover_params.uuid = &uuid.uuid; - discover_params.func = split_central_discovery_func; - discover_params.start_handle = 0x0001; - discover_params.end_handle = 0xffff; - discover_params.type = BT_GATT_DISCOVER_PRIMARY; - - err = bt_gatt_discover(default_conn, &discover_params); - if (err) { - LOG_ERR("Discover failed(err %d)", err); - return; - } + if (conn == default_conn && !subscribe_params.value) { + discover_params.uuid = &uuid.uuid; + discover_params.func = split_central_discovery_func; + discover_params.start_handle = 0x0001; + discover_params.end_handle = 0xffff; + discover_params.type = BT_GATT_DISCOVER_PRIMARY; + + err = bt_gatt_discover(default_conn, &discover_params); + if (err) { + LOG_ERR("Discover failed(err %d)", err); + return; } } @@ -281,7 +286,7 @@ static void split_central_connected(struct bt_conn *conn, u8_t conn_err) if (conn_err) { - LOG_ERR("Failed to connect to %s (%u)", addr, conn_err); + LOG_ERR("Failed to connect to %s (%u)", log_strdup(addr), conn_err); bt_conn_unref(default_conn); default_conn = NULL; diff --git a/app/src/split/bluetooth/service.c b/app/src/split/bluetooth/service.c index 0a5ddb7..c2f65d2 100644 --- a/app/src/split/bluetooth/service.c +++ b/app/src/split/bluetooth/service.c @@ -6,6 +6,11 @@ #include #include + +#include + +LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); + #include #include @@ -28,6 +33,7 @@ static ssize_t split_svc_num_of_positions(struct bt_conn *conn, const struct bt_ static void split_svc_pos_state_ccc(const struct bt_gatt_attr *attr, u16_t value) { + LOG_DBG("value %d", value); } diff --git a/app/src/split_listener.c b/app/src/split_listener.c index ee59c48..1263807 100644 --- a/app/src/split_listener.c +++ b/app/src/split_listener.c @@ -25,9 +25,9 @@ int split_listener(const struct zmk_event_header *eh) if (is_position_state_changed(eh)) { const struct position_state_changed *ev = cast_position_state_changed(eh); if (ev->state) { - zmk_split_bt_position_pressed(ev->position); + return zmk_split_bt_position_pressed(ev->position); } else { - zmk_split_bt_position_released(ev->position); + return zmk_split_bt_position_released(ev->position); } } return 0; diff --git a/docs/docs/behavior/bluetooth.md b/docs/docs/behavior/bluetooth.md index f605c96..4a121a3 100644 --- a/docs/docs/behavior/bluetooth.md +++ b/docs/docs/behavior/bluetooth.md @@ -6,8 +6,8 @@ sidebar_label: Bluetooth ## Summary The bluetooth behavior allows management of various settings and states related to the bluetooth connection(s) -between the keyboard and the host. As of right now, there is only one such action support, but in the future -more will be added. +between the keyboard and the host. By default, ZMK supports five "profiles" for selecting which bonded host +computer/laptop/keyboard should receive the keyboard input; many of the commands here operation on those profiles. ## Bluetooth Command Defines @@ -22,16 +22,22 @@ This will allow you to reference the actions defined in this header such as `BT_ Here is a table describing the command for each define: -| Define | Action | -| -------------------- | --------------------------------------------------------- | -| `BT_CLEAR_BONDS_CMD` | Clear bond information between the keyboard and host [^1] | +| Define | Action | +| -------------------- | ---------------------------------------------------------------------------------------------- | +| `BT_CLEAR_BONDS_CMD` | Clear bond information between the keyboard and host for the selected profile [^1] | +| `BT_PROF_NEXT_CMD` | Switch to the next profile, cycling through to the first one when the end is reached. | +| `BT_PROF_PREV_CMD` | Switch to the previous profile, cycling through to the last one when the beginning is reached. | +| `BT_PROF_SEL_CMD` | Select the 0-indexed profile by number. | -Because future bluetooth commands will take an additional parameter, it is recommended to use -the following alias in your keymap to avoid having to change it later. +Because at least one bluetooth commands takes an additional parameter, it is recommended to use +the following aliases in your keymap to avoid having to specify an ignored second parameter: -| Define | Action | -| ---------------- | ---------------------------------------------------------------------- | -| `BT_CLEAR_BONDS` | Alias for `BT_CLEAR_BONDS_CMD 0` to clear the bond to the current host | +| Define | Action | +| ---------------- | ---------------------------------------------------------------------------------------- | +| `BT_CLEAR_BONDS` | Alias for `BT_CLEAR_BONDS_CMD 0` to clear the current profile's bond to the current host | +| `BT_PROF_NEXT` | Alias for `BT_PROF_NEXT_CMD 0` to select the next profile | +| `BT_PROF_PREV` | Alias for `BT_PROF_PREV_CMD 0` to select the previous profile | +| `BT_PROF_SEL` | Alias for `BT_PROF_SEL_CMD` to select the given profile, e.g. `&bt BT_PROF_SEL 1` | ## Bluetooth Behavior @@ -45,8 +51,26 @@ The bluetooth behavior completes an bluetooth action given on press. ### Examples -1. Behavior to clear the paired host: +1. Behavior binding to clear the paired host for the selected profile: ``` &bt BT_CLEAR_BONDS ``` + +1. Behavior binding to select the next profile: + + ``` + &bt BT_PROF_NEXT + ``` + +1. Behavior binding to select the previous profile: + + ``` + &bt BT_PROF_NEXT + ``` + +1. Behavior binding to select the 2nd profile (passed parameters are [zero based](https://en.wikipedia.org/wiki/Zero-based_numbering)): + + ``` + &bt BT_PROF_SEL 1 + ``` -- cgit v1.2.3 From fb91be5164a5b6ba78b19c7a2597c13ddd992f81 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Wed, 9 Sep 2020 14:33:09 -0400 Subject: fix(bluetooth): Configs for non-splits. --- app/Kconfig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Kconfig b/app/Kconfig index 917674d..6180565 100644 --- a/app/Kconfig +++ b/app/Kconfig @@ -128,6 +128,10 @@ endif endchoice +endif + +endif + if ZMK_BLE && (!ZMK_SPLIT_BLE || ZMK_SPLIT_BLE_ROLE_CENTRAL) config BT_MAX_CONN @@ -138,10 +142,6 @@ config BT_MAX_PAIRED endif -endif - -endif - endmenu config ZMK_KSCAN_MOCK_DRIVER -- cgit v1.2.3 From 652bb6ce05254f8168f279396a50b92d7a2182c3 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Sat, 12 Sep 2020 23:48:44 -0400 Subject: feat(bluetooth): Add new settings_reset shield. * Easy to build board/image that will clear saved profile/bond information for a fresh start for keyboards. --- .github/workflows/build.yml | 1 + .../shields/settings_reset/Kconfig.defconfig | 10 +++++++++ app/boards/shields/settings_reset/Kconfig.shield | 5 +++++ .../shields/settings_reset/settings_reset.conf | 1 + .../shields/settings_reset/settings_reset.keymap | 22 ++++++++++++++++++++ .../shields/settings_reset/settings_reset.overlay | 24 ++++++++++++++++++++++ 6 files changed, 63 insertions(+) create mode 100644 app/boards/shields/settings_reset/Kconfig.defconfig create mode 100644 app/boards/shields/settings_reset/Kconfig.shield create mode 100644 app/boards/shields/settings_reset/settings_reset.conf create mode 100644 app/boards/shields/settings_reset/settings_reset.keymap create mode 100644 app/boards/shields/settings_reset/settings_reset.overlay diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c8a711c..02657c0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,6 +17,7 @@ jobs: - lily58_left - lily58_right - romac + - settings_reset include: - board: proton_c shield: clueboard_california diff --git a/app/boards/shields/settings_reset/Kconfig.defconfig b/app/boards/shields/settings_reset/Kconfig.defconfig new file mode 100644 index 0000000..6d050cb --- /dev/null +++ b/app/boards/shields/settings_reset/Kconfig.defconfig @@ -0,0 +1,10 @@ +# Copyright (c) 2020 The ZMK Contributors +# SPDX-License-Identifier: MIT + +if SHIELD_SETTINGS_RESET + +config ZMK_KEYBOARD_NAME + default "SETTINGS RESET" + +endif + diff --git a/app/boards/shields/settings_reset/Kconfig.shield b/app/boards/shields/settings_reset/Kconfig.shield new file mode 100644 index 0000000..b5ce97f --- /dev/null +++ b/app/boards/shields/settings_reset/Kconfig.shield @@ -0,0 +1,5 @@ +# Copyright (c) 2020 The ZMK Contributors +# SPDX-License-Identifier: MIT + +config SHIELD_SETTINGS_RESET + def_bool $(shields_list_contains,settings_reset) diff --git a/app/boards/shields/settings_reset/settings_reset.conf b/app/boards/shields/settings_reset/settings_reset.conf new file mode 100644 index 0000000..8052a6c --- /dev/null +++ b/app/boards/shields/settings_reset/settings_reset.conf @@ -0,0 +1 @@ +CONFIG_ZMK_BLE_CLEAR_BONDS_ON_START=y diff --git a/app/boards/shields/settings_reset/settings_reset.keymap b/app/boards/shields/settings_reset/settings_reset.keymap new file mode 100644 index 0000000..0523644 --- /dev/null +++ b/app/boards/shields/settings_reset/settings_reset.keymap @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#include +#include + +/ { + keymap { + compatible = "zmk,keymap"; + + default_layer { + bindings = < + &reset + >; + }; + }; +}; + + diff --git a/app/boards/shields/settings_reset/settings_reset.overlay b/app/boards/shields/settings_reset/settings_reset.overlay new file mode 100644 index 0000000..a2b5799 --- /dev/null +++ b/app/boards/shields/settings_reset/settings_reset.overlay @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#include + +/ { + chosen { + zmk,kscan = &kscan0; + }; + + kscan0: kscan { + compatible = "zmk,kscan-gpio-direct"; + label = "KSCAN"; + + input-gpios + = <&pro_micro_d 4 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + ; + }; + +}; + -- cgit v1.2.3 From 6c8b0b53f0dbec695ab967ee947916875ed49352 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Sun, 13 Sep 2020 22:20:25 -0400 Subject: refactor(bluetooth): More concise names. --- app/include/dt-bindings/zmk/bt.h | 16 ++++++++-------- app/src/behaviors/behavior_bt.c | 8 ++++---- docs/docs/behavior/bluetooth.md | 36 ++++++++++++++++++------------------ 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/app/include/dt-bindings/zmk/bt.h b/app/include/dt-bindings/zmk/bt.h index b2899ab..bf8b4f5 100644 --- a/app/include/dt-bindings/zmk/bt.h +++ b/app/include/dt-bindings/zmk/bt.h @@ -4,10 +4,10 @@ * SPDX-License-Identifier: MIT */ -#define BT_CLEAR_BONDS_CMD 0 -#define BT_PROF_NEXT_CMD 1 -#define BT_PROF_PREV_CMD 2 -#define BT_PROF_SEL_CMD 3 +#define BT_CLR_CMD 0 +#define BT_NXT_CMD 1 +#define BT_PRV_CMD 2 +#define BT_SEL_CMD 3 // #define BT_FULL_RESET_CMD 4 /* @@ -15,7 +15,7 @@ Note: Some future commands will include additional parameters, so we defines these aliases up front. */ -#define BT_CLEAR_BONDS BT_CLEAR_BONDS_CMD 0 -#define BT_PROF_NEXT BT_PROF_NEXT_CMD 0 -#define BT_PROF_PREV BT_PROF_PREV_CMD 0 -#define BT_PROF_SEL BT_PROF_SEL_CMD \ No newline at end of file +#define BT_CLR BT_CLR_CMD 0 +#define BT_NXT BT_NXT_CMD 0 +#define BT_PRV BT_PRV_CMD 0 +#define BT_SEL BT_SEL_CMD \ No newline at end of file diff --git a/app/src/behaviors/behavior_bt.c b/app/src/behaviors/behavior_bt.c index bf15683..3a5fbfb 100644 --- a/app/src/behaviors/behavior_bt.c +++ b/app/src/behaviors/behavior_bt.c @@ -22,13 +22,13 @@ static int on_keymap_binding_pressed(struct device *dev, u32_t position, u32_t c { switch (command) { - case BT_CLEAR_BONDS_CMD: + case BT_CLR_CMD: return zmk_ble_clear_bonds(); - case BT_PROF_NEXT_CMD: + case BT_NXT_CMD: return zmk_ble_prof_next(); - case BT_PROF_PREV_CMD: + case BT_PRV_CMD: return zmk_ble_prof_prev(); - case BT_PROF_SEL_CMD: + case BT_SEL_CMD: return zmk_ble_prof_select(arg); default: LOG_ERR("Unknown BT command: %d", command); diff --git a/docs/docs/behavior/bluetooth.md b/docs/docs/behavior/bluetooth.md index 4a121a3..f802a9a 100644 --- a/docs/docs/behavior/bluetooth.md +++ b/docs/docs/behavior/bluetooth.md @@ -18,26 +18,26 @@ which is added at the top of the keymap file: #include ``` -This will allow you to reference the actions defined in this header such as `BT_CLEAR_BONDS_CMD`. +This will allow you to reference the actions defined in this header such as `BT_CLR_CMD`. Here is a table describing the command for each define: -| Define | Action | -| -------------------- | ---------------------------------------------------------------------------------------------- | -| `BT_CLEAR_BONDS_CMD` | Clear bond information between the keyboard and host for the selected profile [^1] | -| `BT_PROF_NEXT_CMD` | Switch to the next profile, cycling through to the first one when the end is reached. | -| `BT_PROF_PREV_CMD` | Switch to the previous profile, cycling through to the last one when the beginning is reached. | -| `BT_PROF_SEL_CMD` | Select the 0-indexed profile by number. | +| Define | Action | +| ------------ | ---------------------------------------------------------------------------------------------- | +| `BT_CLR_CMD` | Clear bond information between the keyboard and host for the selected profile [^1] | +| `BT_NXT_CMD` | Switch to the next profile, cycling through to the first one when the end is reached. | +| `BT_PRV_CMD` | Switch to the previous profile, cycling through to the last one when the beginning is reached. | +| `BT_SEL_CMD` | Select the 0-indexed profile by number. | Because at least one bluetooth commands takes an additional parameter, it is recommended to use the following aliases in your keymap to avoid having to specify an ignored second parameter: -| Define | Action | -| ---------------- | ---------------------------------------------------------------------------------------- | -| `BT_CLEAR_BONDS` | Alias for `BT_CLEAR_BONDS_CMD 0` to clear the current profile's bond to the current host | -| `BT_PROF_NEXT` | Alias for `BT_PROF_NEXT_CMD 0` to select the next profile | -| `BT_PROF_PREV` | Alias for `BT_PROF_PREV_CMD 0` to select the previous profile | -| `BT_PROF_SEL` | Alias for `BT_PROF_SEL_CMD` to select the given profile, e.g. `&bt BT_PROF_SEL 1` | +| Define | Action | +| -------- | -------------------------------------------------------------------------------- | +| `BT_CLR` | Alias for `BT_CLR_CMD 0` to clear the current profile's bond to the current host | +| `BT_NXT` | Alias for `BT_NXT_CMD 0` to select the next profile | +| `BT_PRV` | Alias for `BT_PRV_CMD 0` to select the previous profile | +| `BT_SEL` | Alias for `BT_SEL_CMD` to select the given profile, e.g. `&bt BT_SEL 1` | ## Bluetooth Behavior @@ -46,7 +46,7 @@ The bluetooth behavior completes an bluetooth action given on press. ### Behavior Binding - Reference: `&bt` -- Parameter #1: The bluetooth command define, e.g. `BT_CLEAR_BONDS_CMD` +- Parameter #1: The bluetooth command define, e.g. `BT_CLR_CMD` - Parameter #2: (Reserved for future bluetooth command types) ### Examples @@ -54,23 +54,23 @@ The bluetooth behavior completes an bluetooth action given on press. 1. Behavior binding to clear the paired host for the selected profile: ``` - &bt BT_CLEAR_BONDS + &bt BT_CLR ``` 1. Behavior binding to select the next profile: ``` - &bt BT_PROF_NEXT + &bt BT_NXT ``` 1. Behavior binding to select the previous profile: ``` - &bt BT_PROF_NEXT + &bt BT_NXT ``` 1. Behavior binding to select the 2nd profile (passed parameters are [zero based](https://en.wikipedia.org/wiki/Zero-based_numbering)): ``` - &bt BT_PROF_SEL 1 + &bt BT_SEL 1 ``` -- cgit v1.2.3 From 4658999e31865e54d02955c500c716385e6c69d8 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Sun, 13 Sep 2020 22:22:12 -0400 Subject: fix(bluetooth): Reject pairing to taken profiles. --- app/src/ble.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/ble.c b/app/src/ble.c index 40e05a3..a2a8207 100644 --- a/app/src/ble.c +++ b/app/src/ble.c @@ -366,7 +366,7 @@ static enum bt_security_err auth_pairing_accept(struct bt_conn *conn, const stru bt_conn_get_info(conn, &info); LOG_DBG("role %d, open? %s", info.role, active_profile_is_open() ? "yes" : "no"); - if (info.role != BT_CONN_ROLE_SLAVE && !active_profile_is_open()) { + if (info.role == BT_CONN_ROLE_SLAVE && !active_profile_is_open()) { LOG_WRN("Rejecting pairing request to taken profile %d", active_profile); return BT_SECURITY_ERR_PAIR_NOT_ALLOWED; } -- cgit v1.2.3 From 296a89ce6364fd97099d694dddcbb30e8b0925c0 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Thu, 10 Sep 2020 15:02:37 -0400 Subject: feat(ci): Run clang-format to check files. --- .clang-format | 4 ++++ .github/workflows/clang-format-lint.yml | 25 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 .clang-format create mode 100644 .github/workflows/clang-format-lint.yml diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..3c29522 --- /dev/null +++ b/.clang-format @@ -0,0 +1,4 @@ +BasedOnStyle: LLVM +IndentWidth: 4 +ColumnLimit: 100 +SortIncludes: false diff --git a/.github/workflows/clang-format-lint.yml b/.github/workflows/clang-format-lint.yml new file mode 100644 index 0000000..061bc3d --- /dev/null +++ b/.github/workflows/clang-format-lint.yml @@ -0,0 +1,25 @@ +name: clang-format-lint + +on: + push: + paths: + - "app/boards/**/*.c" + - "app/include/**/*.h" + - "app/src/**" + pull_request: + paths: + - "app/boards/**/*.c" + - "app/include/**/*.h" + - "app/src/**" + +jobs: + build: + runs-on: ubuntu-latest + name: clang-format lint + + steps: + - uses: actions/checkout@v2 + - uses: DoozyX/clang-format-lint-action@v0.9 + with: + source: "./app" + extensions: "h,c" -- cgit v1.2.3 From 191a2d755ad4761bd04a30a113e05119ad7aa61e Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Sun, 13 Sep 2020 22:53:24 -0400 Subject: chore: clang-format the codebase. * Use the LLVM style * Override indent width (8) and column limit (100) * Fixes #142. --- app/boards/arm/dz60rgb/pinmux.c | 54 +- app/boards/arm/nrfmicro/pinmux.c | 27 +- app/boards/arm/planck/pinmux.c | 52 +- app/boards/arm/proton_c/pinmux.c | 54 +- app/drivers/zephyr/ec11.c | 209 +++--- app/drivers/zephyr/ec11.h | 49 +- app/drivers/zephyr/ec11_trigger.c | 176 ++--- app/drivers/zephyr/kscan_gpio_direct.c | 357 +++++----- app/drivers/zephyr/kscan_gpio_matrix.c | 476 +++++++------ app/include/drivers/behavior.h | 69 +- app/include/dt-bindings/zmk/bt.h | 16 +- app/include/dt-bindings/zmk/keys.h | 6 +- app/include/dt-bindings/zmk/reset.h | 9 +- app/include/zmk/event-manager.h | 77 +-- .../zmk/events/ble-active-profile-changed.h | 1 - app/include/zmk/events/keycode-state-changed.h | 6 +- app/include/zmk/events/modifiers-state-changed.h | 8 +- app/include/zmk/hid.h | 12 +- app/include/zmk/keys.h | 3 +- app/include/zmk/matrix.h | 18 +- app/include/zmk/split/bluetooth/uuid.h | 5 +- app/src/behaviors/behavior_bt.c | 23 +- app/src/behaviors/behavior_hold_tap.c | 754 ++++++++++----------- app/src/behaviors/behavior_key_press.c | 50 +- app/src/behaviors/behavior_momentary_layer.c | 35 +- app/src/behaviors/behavior_none.c | 32 +- app/src/behaviors/behavior_reset.c | 40 +- app/src/behaviors/behavior_rgb_underglow.c | 45 +- .../behaviors/behavior_sensor_rotate_key_press.c | 102 ++- app/src/behaviors/behavior_toggle_layer.c | 33 +- app/src/behaviors/behavior_transparent.c | 32 +- app/src/ble.c | 160 ++--- app/src/ble_unpair_combo.c | 17 +- app/src/display.c | 6 +- app/src/endpoints.c | 21 +- app/src/event_manager.c | 44 +- app/src/hid.c | 91 +-- app/src/hid_listener.c | 136 ++-- app/src/hog.c | 126 ++-- app/src/keymap.c | 271 ++++---- app/src/kscan.c | 78 +-- app/src/kscan_composite.c | 63 +- app/src/kscan_mock.c | 119 ++-- app/src/main.c | 20 +- app/src/matrix_transform.c | 11 +- app/src/rgb_underglow.c | 211 +++--- app/src/sensors.c | 32 +- app/src/split/bluetooth/central.c | 489 +++++++------ app/src/split/bluetooth/service.c | 39 +- app/src/split_listener.c | 21 +- app/src/usb_hid.c | 93 ++- 51 files changed, 2251 insertions(+), 2627 deletions(-) diff --git a/app/boards/arm/dz60rgb/pinmux.c b/app/boards/arm/dz60rgb/pinmux.c index 60e231b..f59a31b 100644 --- a/app/boards/arm/dz60rgb/pinmux.c +++ b/app/boards/arm/dz60rgb/pinmux.c @@ -15,55 +15,53 @@ /* pin assignments for STM32F3DISCOVERY board */ static const struct pin_config pinconf[] = { #if DT_NODE_HAS_STATUS(DT_NODELABEL(usart1), okay) && CONFIG_SERIAL - {STM32_PIN_PC4, STM32F3_PINMUX_FUNC_PC4_USART1_TX}, - {STM32_PIN_PC5, STM32F3_PINMUX_FUNC_PC5_USART1_RX}, + {STM32_PIN_PC4, STM32F3_PINMUX_FUNC_PC4_USART1_TX}, + {STM32_PIN_PC5, STM32F3_PINMUX_FUNC_PC5_USART1_RX}, #endif #if DT_NODE_HAS_STATUS(DT_NODELABEL(usart2), okay) && CONFIG_SERIAL - {STM32_PIN_PA2, STM32F3_PINMUX_FUNC_PA2_USART2_TX}, - {STM32_PIN_PA3, STM32F3_PINMUX_FUNC_PA3_USART2_RX}, + {STM32_PIN_PA2, STM32F3_PINMUX_FUNC_PA2_USART2_TX}, + {STM32_PIN_PA3, STM32F3_PINMUX_FUNC_PA3_USART2_RX}, #endif #if DT_NODE_HAS_STATUS(DT_NODELABEL(i2c1), okay) && CONFIG_I2C - {STM32_PIN_PB6, STM32F3_PINMUX_FUNC_PB6_I2C1_SCL}, - {STM32_PIN_PB7, STM32F3_PINMUX_FUNC_PB7_I2C1_SDA}, + {STM32_PIN_PB6, STM32F3_PINMUX_FUNC_PB6_I2C1_SCL}, + {STM32_PIN_PB7, STM32F3_PINMUX_FUNC_PB7_I2C1_SDA}, #endif #if DT_NODE_HAS_STATUS(DT_NODELABEL(i2c2), okay) && CONFIG_I2C - {STM32_PIN_PA9, STM32F3_PINMUX_FUNC_PA9_I2C2_SCL}, - {STM32_PIN_PA10, STM32F3_PINMUX_FUNC_PA10_I2C2_SDA}, + {STM32_PIN_PA9, STM32F3_PINMUX_FUNC_PA9_I2C2_SCL}, + {STM32_PIN_PA10, STM32F3_PINMUX_FUNC_PA10_I2C2_SDA}, #endif #if DT_NODE_HAS_STATUS(DT_NODELABEL(spi1), okay) && CONFIG_SPI #ifdef CONFIG_SPI_STM32_USE_HW_SS - {STM32_PIN_PA4, STM32F3_PINMUX_FUNC_PA4_SPI1_NSS}, + {STM32_PIN_PA4, STM32F3_PINMUX_FUNC_PA4_SPI1_NSS}, #endif /* CONFIG_SPI_STM32_USE_HW_SS */ - {STM32_PIN_PA5, STM32F3_PINMUX_FUNC_PA5_SPI1_SCK}, - {STM32_PIN_PA6, STM32F3_PINMUX_FUNC_PA6_SPI1_MISO}, - {STM32_PIN_PA7, STM32F3_PINMUX_FUNC_PA7_SPI1_MOSI}, + {STM32_PIN_PA5, STM32F3_PINMUX_FUNC_PA5_SPI1_SCK}, + {STM32_PIN_PA6, STM32F3_PINMUX_FUNC_PA6_SPI1_MISO}, + {STM32_PIN_PA7, STM32F3_PINMUX_FUNC_PA7_SPI1_MOSI}, #endif #if DT_NODE_HAS_STATUS(DT_NODELABEL(spi2), okay) && CONFIG_SPI #ifdef CONFIG_SPI_STM32_USE_HW_SS - {STM32_PIN_PB12, STM32F3_PINMUX_FUNC_PB12_SPI2_NSS}, + {STM32_PIN_PB12, STM32F3_PINMUX_FUNC_PB12_SPI2_NSS}, #endif /* CONFIG_SPI_STM32_USE_HW_SS */ - {STM32_PIN_PB13, STM32F3_PINMUX_FUNC_PB13_SPI2_SCK}, - {STM32_PIN_PB14, STM32F3_PINMUX_FUNC_PB14_SPI2_MISO}, - {STM32_PIN_PB15, STM32F3_PINMUX_FUNC_PB15_SPI2_MOSI}, + {STM32_PIN_PB13, STM32F3_PINMUX_FUNC_PB13_SPI2_SCK}, + {STM32_PIN_PB14, STM32F3_PINMUX_FUNC_PB14_SPI2_MISO}, + {STM32_PIN_PB15, STM32F3_PINMUX_FUNC_PB15_SPI2_MOSI}, #endif #ifdef CONFIG_USB_DC_STM32 - {STM32_PIN_PA11, STM32F3_PINMUX_FUNC_PA11_USB_DM}, - {STM32_PIN_PA12, STM32F3_PINMUX_FUNC_PA12_USB_DP}, -#endif /* CONFIG_USB_DC_STM32 */ + {STM32_PIN_PA11, STM32F3_PINMUX_FUNC_PA11_USB_DM}, + {STM32_PIN_PA12, STM32F3_PINMUX_FUNC_PA12_USB_DP}, +#endif /* CONFIG_USB_DC_STM32 */ #if DT_NODE_HAS_STATUS(DT_NODELABEL(can1), okay) && CONFIG_CAN - {STM32_PIN_PD0, STM32F3_PINMUX_FUNC_PD0_CAN1_RX}, - {STM32_PIN_PD1, STM32F3_PINMUX_FUNC_PD1_CAN1_TX}, + {STM32_PIN_PD0, STM32F3_PINMUX_FUNC_PD0_CAN1_RX}, + {STM32_PIN_PD1, STM32F3_PINMUX_FUNC_PD1_CAN1_TX}, #endif }; -static int pinmux_stm32_init(struct device *port) -{ - ARG_UNUSED(port); +static int pinmux_stm32_init(struct device *port) { + ARG_UNUSED(port); - stm32_setup_pins(pinconf, ARRAY_SIZE(pinconf)); + stm32_setup_pins(pinconf, ARRAY_SIZE(pinconf)); - return 0; + return 0; } -SYS_INIT(pinmux_stm32_init, PRE_KERNEL_1, - CONFIG_PINMUX_STM32_DEVICE_INITIALIZATION_PRIORITY); \ No newline at end of file +SYS_INIT(pinmux_stm32_init, PRE_KERNEL_1, CONFIG_PINMUX_STM32_DEVICE_INITIALIZATION_PRIORITY); \ No newline at end of file diff --git a/app/boards/arm/nrfmicro/pinmux.c b/app/boards/arm/nrfmicro/pinmux.c index 0536fe0..4e330b6 100644 --- a/app/boards/arm/nrfmicro/pinmux.c +++ b/app/boards/arm/nrfmicro/pinmux.c @@ -11,31 +11,30 @@ #include #include -static int pinmux_nrfmicro_init(struct device *port) -{ - ARG_UNUSED(port); +static int pinmux_nrfmicro_init(struct device *port) { + ARG_UNUSED(port); - struct device *p1 = device_get_binding("GPIO_1"); + struct device *p1 = device_get_binding("GPIO_1"); #if CONFIG_BOARD_NRFMICRO_13 - struct device *p0 = device_get_binding("GPIO_0"); - // enable EXT_VCC (use 0 for nRFMicro 1.3, use 1 for nRFMicro 1.1) - gpio_pin_configure(p1, 9, GPIO_OUTPUT); - gpio_pin_set(p1, 9, 0); + struct device *p0 = device_get_binding("GPIO_0"); + // enable EXT_VCC (use 0 for nRFMicro 1.3, use 1 for nRFMicro 1.1) + gpio_pin_configure(p1, 9, GPIO_OUTPUT); + gpio_pin_set(p1, 9, 0); #if CONFIG_BOARD_NRFMICRO_CHARGER - gpio_pin_configure(p0, 5, GPIO_OUTPUT); - gpio_pin_set(p0, 5, 0); + gpio_pin_configure(p0, 5, GPIO_OUTPUT); + gpio_pin_set(p0, 5, 0); #else - gpio_pin_configure(p0, 5, GPIO_INPUT); + gpio_pin_configure(p0, 5, GPIO_INPUT); #endif #else // enable EXT_VCC (use 0 for nRFMicro 1.3, use 1 for nRFMicro 1.1) - gpio_pin_configure(p1, 9, GPIO_OUTPUT); - gpio_pin_set(p1, 9, 1); + gpio_pin_configure(p1, 9, GPIO_OUTPUT); + gpio_pin_set(p1, 9, 1); #endif - return 0; + return 0; } SYS_INIT(pinmux_nrfmicro_init, APPLICATION, CONFIG_APPLICATION_INIT_PRIORITY); diff --git a/app/boards/arm/planck/pinmux.c b/app/boards/arm/planck/pinmux.c index 5df5c90..61cc16a 100644 --- a/app/boards/arm/planck/pinmux.c +++ b/app/boards/arm/planck/pinmux.c @@ -15,55 +15,53 @@ /* pin assignments for STM32F3DISCOVERY board */ static const struct pin_config pinconf[] = { #ifdef CONFIG_UART_1 - {STM32_PIN_PC4, STM32F3_PINMUX_FUNC_PC4_USART1_TX}, - {STM32_PIN_PC5, STM32F3_PINMUX_FUNC_PC5_USART1_RX}, + {STM32_PIN_PC4, STM32F3_PINMUX_FUNC_PC4_USART1_TX}, + {STM32_PIN_PC5, STM32F3_PINMUX_FUNC_PC5_USART1_RX}, #endif /* CONFIG_UART_1 */ #ifdef CONFIG_UART_2 - {STM32_PIN_PA2, STM32F3_PINMUX_FUNC_PA2_USART2_TX}, - {STM32_PIN_PA3, STM32F3_PINMUX_FUNC_PA3_USART2_RX}, + {STM32_PIN_PA2, STM32F3_PINMUX_FUNC_PA2_USART2_TX}, + {STM32_PIN_PA3, STM32F3_PINMUX_FUNC_PA3_USART2_RX}, #endif /* CONFIG_UART_2 */ #ifdef CONFIG_I2C_1 - {STM32_PIN_PB6, STM32F3_PINMUX_FUNC_PB6_I2C1_SCL}, - {STM32_PIN_PB7, STM32F3_PINMUX_FUNC_PB7_I2C1_SDA}, + {STM32_PIN_PB6, STM32F3_PINMUX_FUNC_PB6_I2C1_SCL}, + {STM32_PIN_PB7, STM32F3_PINMUX_FUNC_PB7_I2C1_SDA}, #endif /* CONFIG_I2C_1 */ #ifdef CONFIG_I2C_2 - {STM32_PIN_PA9, STM32F3_PINMUX_FUNC_PA9_I2C2_SCL}, - {STM32_PIN_PA10, STM32F3_PINMUX_FUNC_PA10_I2C2_SDA}, + {STM32_PIN_PA9, STM32F3_PINMUX_FUNC_PA9_I2C2_SCL}, + {STM32_PIN_PA10, STM32F3_PINMUX_FUNC_PA10_I2C2_SDA}, #endif /* CONFIG_I2C_2 */ #ifdef CONFIG_SPI_1 #ifdef CONFIG_SPI_STM32_USE_HW_SS - {STM32_PIN_PA4, STM32F3_PINMUX_FUNC_PA4_SPI1_NSS}, + {STM32_PIN_PA4, STM32F3_PINMUX_FUNC_PA4_SPI1_NSS}, #endif /* CONFIG_SPI_STM32_USE_HW_SS */ - {STM32_PIN_PA5, STM32F3_PINMUX_FUNC_PA5_SPI1_SCK}, - {STM32_PIN_PA6, STM32F3_PINMUX_FUNC_PA6_SPI1_MISO}, - {STM32_PIN_PA7, STM32F3_PINMUX_FUNC_PA7_SPI1_MOSI}, + {STM32_PIN_PA5, STM32F3_PINMUX_FUNC_PA5_SPI1_SCK}, + {STM32_PIN_PA6, STM32F3_PINMUX_FUNC_PA6_SPI1_MISO}, + {STM32_PIN_PA7, STM32F3_PINMUX_FUNC_PA7_SPI1_MOSI}, #endif /* CONFIG_SPI_1 */ #ifdef CONFIG_SPI_2 #ifdef CONFIG_SPI_STM32_USE_HW_SS - {STM32_PIN_PB12, STM32F3_PINMUX_FUNC_PB12_SPI2_NSS}, + {STM32_PIN_PB12, STM32F3_PINMUX_FUNC_PB12_SPI2_NSS}, #endif /* CONFIG_SPI_STM32_USE_HW_SS */ - {STM32_PIN_PB13, STM32F3_PINMUX_FUNC_PB13_SPI2_SCK}, - {STM32_PIN_PB14, STM32F3_PINMUX_FUNC_PB14_SPI2_MISO}, - {STM32_PIN_PB15, STM32F3_PINMUX_FUNC_PB15_SPI2_MOSI}, + {STM32_PIN_PB13, STM32F3_PINMUX_FUNC_PB13_SPI2_SCK}, + {STM32_PIN_PB14, STM32F3_PINMUX_FUNC_PB14_SPI2_MISO}, + {STM32_PIN_PB15, STM32F3_PINMUX_FUNC_PB15_SPI2_MOSI}, #endif /* CONFIG_SPI_2 */ #ifdef CONFIG_USB_DC_STM32 - {STM32_PIN_PA11, STM32F3_PINMUX_FUNC_PA11_USB_DM}, - {STM32_PIN_PA12, STM32F3_PINMUX_FUNC_PA12_USB_DP}, + {STM32_PIN_PA11, STM32F3_PINMUX_FUNC_PA11_USB_DM}, + {STM32_PIN_PA12, STM32F3_PINMUX_FUNC_PA12_USB_DP}, #endif /* CONFIG_USB_DC_STM32 */ #ifdef CONFIG_CAN_1 - {STM32_PIN_PD0, STM32F3_PINMUX_FUNC_PD0_CAN1_RX}, - {STM32_PIN_PD1, STM32F3_PINMUX_FUNC_PD1_CAN1_TX}, + {STM32_PIN_PD0, STM32F3_PINMUX_FUNC_PD0_CAN1_RX}, + {STM32_PIN_PD1, STM32F3_PINMUX_FUNC_PD1_CAN1_TX}, #endif /* CONFIG_CAN_1 */ }; -static int pinmux_stm32_init(struct device *port) -{ - ARG_UNUSED(port); +static int pinmux_stm32_init(struct device *port) { + ARG_UNUSED(port); - stm32_setup_pins(pinconf, ARRAY_SIZE(pinconf)); + stm32_setup_pins(pinconf, ARRAY_SIZE(pinconf)); - return 0; + return 0; } -SYS_INIT(pinmux_stm32_init, PRE_KERNEL_1, - CONFIG_PINMUX_STM32_DEVICE_INITIALIZATION_PRIORITY); +SYS_INIT(pinmux_stm32_init, PRE_KERNEL_1, CONFIG_PINMUX_STM32_DEVICE_INITIALIZATION_PRIORITY); diff --git a/app/boards/arm/proton_c/pinmux.c b/app/boards/arm/proton_c/pinmux.c index a6aaae0..9ffabd7 100644 --- a/app/boards/arm/proton_c/pinmux.c +++ b/app/boards/arm/proton_c/pinmux.c @@ -15,55 +15,53 @@ /* pin assignments for STM32F3DISCOVERY board */ static const struct pin_config pinconf[] = { #if DT_NODE_HAS_STATUS(DT_NODELABEL(usart1), okay) && CONFIG_SERIAL - {STM32_PIN_PC4, STM32F3_PINMUX_FUNC_PC4_USART1_TX}, - {STM32_PIN_PC5, STM32F3_PINMUX_FUNC_PC5_USART1_RX}, + {STM32_PIN_PC4, STM32F3_PINMUX_FUNC_PC4_USART1_TX}, + {STM32_PIN_PC5, STM32F3_PINMUX_FUNC_PC5_USART1_RX}, #endif #if DT_NODE_HAS_STATUS(DT_NODELABEL(usart2), okay) && CONFIG_SERIAL - {STM32_PIN_PA2, STM32F3_PINMUX_FUNC_PA2_USART2_TX}, - {STM32_PIN_PA3, STM32F3_PINMUX_FUNC_PA3_USART2_RX}, + {STM32_PIN_PA2, STM32F3_PINMUX_FUNC_PA2_USART2_TX}, + {STM32_PIN_PA3, STM32F3_PINMUX_FUNC_PA3_USART2_RX}, #endif #if DT_NODE_HAS_STATUS(DT_NODELABEL(i2c1), okay) && CONFIG_I2C - {STM32_PIN_PB6, STM32F3_PINMUX_FUNC_PB6_I2C1_SCL}, - {STM32_PIN_PB7, STM32F3_PINMUX_FUNC_PB7_I2C1_SDA}, + {STM32_PIN_PB6, STM32F3_PINMUX_FUNC_PB6_I2C1_SCL}, + {STM32_PIN_PB7, STM32F3_PINMUX_FUNC_PB7_I2C1_SDA}, #endif #if DT_NODE_HAS_STATUS(DT_NODELABEL(i2c2), okay) && CONFIG_I2C - {STM32_PIN_PA9, STM32F3_PINMUX_FUNC_PA9_I2C2_SCL}, - {STM32_PIN_PA10, STM32F3_PINMUX_FUNC_PA10_I2C2_SDA}, + {STM32_PIN_PA9, STM32F3_PINMUX_FUNC_PA9_I2C2_SCL}, + {STM32_PIN_PA10, STM32F3_PINMUX_FUNC_PA10_I2C2_SDA}, #endif #if DT_NODE_HAS_STATUS(DT_NODELABEL(spi1), okay) && CONFIG_SPI #ifdef CONFIG_SPI_STM32_USE_HW_SS - {STM32_PIN_PA4, STM32F3_PINMUX_FUNC_PA4_SPI1_NSS}, + {STM32_PIN_PA4, STM32F3_PINMUX_FUNC_PA4_SPI1_NSS}, #endif /* CONFIG_SPI_STM32_USE_HW_SS */ - {STM32_PIN_PA5, STM32F3_PINMUX_FUNC_PA5_SPI1_SCK}, - {STM32_PIN_PA6, STM32F3_PINMUX_FUNC_PA6_SPI1_MISO}, - {STM32_PIN_PA7, STM32F3_PINMUX_FUNC_PA7_SPI1_MOSI}, + {STM32_PIN_PA5, STM32F3_PINMUX_FUNC_PA5_SPI1_SCK}, + {STM32_PIN_PA6, STM32F3_PINMUX_FUNC_PA6_SPI1_MISO}, + {STM32_PIN_PA7, STM32F3_PINMUX_FUNC_PA7_SPI1_MOSI}, #endif #if DT_NODE_HAS_STATUS(DT_NODELABEL(spi2), okay) && CONFIG_SPI #ifdef CONFIG_SPI_STM32_USE_HW_SS - {STM32_PIN_PB12, STM32F3_PINMUX_FUNC_PB12_SPI2_NSS}, + {STM32_PIN_PB12, STM32F3_PINMUX_FUNC_PB12_SPI2_NSS}, #endif /* CONFIG_SPI_STM32_USE_HW_SS */ - {STM32_PIN_PB13, STM32F3_PINMUX_FUNC_PB13_SPI2_SCK}, - {STM32_PIN_PB14, STM32F3_PINMUX_FUNC_PB14_SPI2_MISO}, - {STM32_PIN_PB15, STM32F3_PINMUX_FUNC_PB15_SPI2_MOSI}, + {STM32_PIN_PB13, STM32F3_PINMUX_FUNC_PB13_SPI2_SCK}, + {STM32_PIN_PB14, STM32F3_PINMUX_FUNC_PB14_SPI2_MISO}, + {STM32_PIN_PB15, STM32F3_PINMUX_FUNC_PB15_SPI2_MOSI}, #endif #ifdef CONFIG_USB_DC_STM32 - {STM32_PIN_PA11, STM32F3_PINMUX_FUNC_PA11_USB_DM}, - {STM32_PIN_PA12, STM32F3_PINMUX_FUNC_PA12_USB_DP}, -#endif /* CONFIG_USB_DC_STM32 */ + {STM32_PIN_PA11, STM32F3_PINMUX_FUNC_PA11_USB_DM}, + {STM32_PIN_PA12, STM32F3_PINMUX_FUNC_PA12_USB_DP}, +#endif /* CONFIG_USB_DC_STM32 */ #if DT_NODE_HAS_STATUS(DT_NODELABEL(can1), okay) && CONFIG_CAN - {STM32_PIN_PD0, STM32F3_PINMUX_FUNC_PD0_CAN1_RX}, - {STM32_PIN_PD1, STM32F3_PINMUX_FUNC_PD1_CAN1_TX}, + {STM32_PIN_PD0, STM32F3_PINMUX_FUNC_PD0_CAN1_RX}, + {STM32_PIN_PD1, STM32F3_PINMUX_FUNC_PD1_CAN1_TX}, #endif }; -static int pinmux_stm32_init(struct device *port) -{ - ARG_UNUSED(port); +static int pinmux_stm32_init(struct device *port) { + ARG_UNUSED(port); - stm32_setup_pins(pinconf, ARRAY_SIZE(pinconf)); + stm32_setup_pins(pinconf, ARRAY_SIZE(pinconf)); - return 0; + return 0; } -SYS_INIT(pinmux_stm32_init, PRE_KERNEL_1, - CONFIG_PINMUX_STM32_DEVICE_INITIALIZATION_PRIORITY); +SYS_INIT(pinmux_stm32_init, PRE_KERNEL_1, CONFIG_PINMUX_STM32_DEVICE_INITIALIZATION_PRIORITY); diff --git a/app/drivers/zephyr/ec11.c b/app/drivers/zephyr/ec11.c index dfa86ef..a4e96c2 100644 --- a/app/drivers/zephyr/ec11.c +++ b/app/drivers/zephyr/ec11.c @@ -18,136 +18,131 @@ LOG_MODULE_REGISTER(EC11, CONFIG_SENSOR_LOG_LEVEL); -static int ec11_get_ab_state(struct device *dev) -{ - struct ec11_data *drv_data = dev->driver_data; - const struct ec11_config *drv_cfg = dev->config_info; +static int ec11_get_ab_state(struct device *dev) { + struct ec11_data *drv_data = dev->driver_data; + const struct ec11_config *drv_cfg = dev->config_info; - return (gpio_pin_get(drv_data->a, drv_cfg->a_pin) << 1) | gpio_pin_get(drv_data->b, drv_cfg->b_pin); + return (gpio_pin_get(drv_data->a, drv_cfg->a_pin) << 1) | + gpio_pin_get(drv_data->b, drv_cfg->b_pin); } -static int ec11_sample_fetch(struct device *dev, enum sensor_channel chan) -{ - struct ec11_data *drv_data = dev->driver_data; - const struct ec11_config *drv_cfg = dev->config_info; - u8_t val; - s8_t delta; - - __ASSERT_NO_MSG(chan == SENSOR_CHAN_ALL || chan == SENSOR_CHAN_ROTATION); - - val = ec11_get_ab_state(dev); - - LOG_DBG("prev: %d, new: %d", drv_data->ab_state, val); - - switch(val | (drv_data->ab_state << 2)) { - case 0b0010: case 0b0100: case 0b1101: case 0b1011: - delta = -1; - break; - case 0b0001: case 0b0111: case 0b1110: case 0b1000: - delta = 1; - break; - default: - delta = 0; - break; - } - - LOG_DBG("Delta: %d", delta); - - drv_data->pulses += delta; - drv_data->ab_state = val; - - drv_data->ticks = drv_data->pulses / drv_cfg->resolution; - drv_data->delta = delta; - drv_data->pulses %= drv_cfg->resolution; - - return 0; +static int ec11_sample_fetch(struct device *dev, enum sensor_channel chan) { + struct ec11_data *drv_data = dev->driver_data; + const struct ec11_config *drv_cfg = dev->config_info; + u8_t val; + s8_t delta; + + __ASSERT_NO_MSG(chan == SENSOR_CHAN_ALL || chan == SENSOR_CHAN_ROTATION); + + val = ec11_get_ab_state(dev); + + LOG_DBG("prev: %d, new: %d", drv_data->ab_state, val); + + switch (val | (drv_data->ab_state << 2)) { + case 0b0010: + case 0b0100: + case 0b1101: + case 0b1011: + delta = -1; + break; + case 0b0001: + case 0b0111: + case 0b1110: + case 0b1000: + delta = 1; + break; + default: + delta = 0; + break; + } + + LOG_DBG("Delta: %d", delta); + + drv_data->pulses += delta; + drv_data->ab_state = val; + + drv_data->ticks = drv_data->pulses / drv_cfg->resolution; + drv_data->delta = delta; + drv_data->pulses %= drv_cfg->resolution; + + return 0; } -static int ec11_channel_get(struct device *dev, - enum sensor_channel chan, - struct sensor_value *val) -{ - struct ec11_data *drv_data = dev->driver_data; - - if (chan != SENSOR_CHAN_ROTATION) { - return -ENOTSUP; - } - - val->val1 = drv_data->ticks; - val->val2 = drv_data->delta; - - return 0; +static int ec11_channel_get(struct device *dev, enum sensor_channel chan, + struct sensor_value *val) { + struct ec11_data *drv_data = dev->driver_data; + + if (chan != SENSOR_CHAN_ROTATION) { + return -ENOTSUP; + } + + val->val1 = drv_data->ticks; + val->val2 = drv_data->delta; + + return 0; } static const struct sensor_driver_api ec11_driver_api = { #ifdef CONFIG_EC11_TRIGGER - .trigger_set = ec11_trigger_set, + .trigger_set = ec11_trigger_set, #endif - .sample_fetch = ec11_sample_fetch, - .channel_get = ec11_channel_get, + .sample_fetch = ec11_sample_fetch, + .channel_get = ec11_channel_get, }; -int ec11_init(struct device *dev) -{ - struct ec11_data *drv_data = dev->driver_data; - const struct ec11_config *drv_cfg = dev->config_info; - - LOG_DBG("A: %s %d B: %s %d resolution %d", drv_cfg->a_label, drv_cfg->a_pin, drv_cfg->b_label, drv_cfg->b_pin, drv_cfg->resolution); - - drv_data->a = device_get_binding(drv_cfg->a_label); - if (drv_data->a == NULL) { - LOG_ERR("Failed to get pointer to A GPIO device"); - return -EINVAL; - } +int ec11_init(struct device *dev) { + struct ec11_data *drv_data = dev->driver_data; + const struct ec11_config *drv_cfg = dev->config_info; - drv_data->b = device_get_binding(drv_cfg->b_label); - if (drv_data->b == NULL) { - LOG_ERR("Failed to get pointer to B GPIO device"); - return -EINVAL; - } + LOG_DBG("A: %s %d B: %s %d resolution %d", drv_cfg->a_label, drv_cfg->a_pin, drv_cfg->b_label, + drv_cfg->b_pin, drv_cfg->resolution); - if (gpio_pin_configure(drv_data->a, drv_cfg->a_pin, - drv_cfg->a_flags - | GPIO_INPUT)) { - LOG_DBG("Failed to configure A pin"); - return -EIO; - } + drv_data->a = device_get_binding(drv_cfg->a_label); + if (drv_data->a == NULL) { + LOG_ERR("Failed to get pointer to A GPIO device"); + return -EINVAL; + } - if (gpio_pin_configure(drv_data->b, drv_cfg->b_pin, - drv_cfg->b_flags - | GPIO_INPUT)) { - LOG_DBG("Failed to configure B pin"); - return -EIO; - } + drv_data->b = device_get_binding(drv_cfg->b_label); + if (drv_data->b == NULL) { + LOG_ERR("Failed to get pointer to B GPIO device"); + return -EINVAL; + } + if (gpio_pin_configure(drv_data->a, drv_cfg->a_pin, drv_cfg->a_flags | GPIO_INPUT)) { + LOG_DBG("Failed to configure A pin"); + return -EIO; + } + if (gpio_pin_configure(drv_data->b, drv_cfg->b_pin, drv_cfg->b_flags | GPIO_INPUT)) { + LOG_DBG("Failed to configure B pin"); + return -EIO; + } #ifdef CONFIG_EC11_TRIGGER - if (ec11_init_interrupt(dev) < 0) { - LOG_DBG("Failed to initialize interrupt!"); - return -EIO; - } + if (ec11_init_interrupt(dev) < 0) { + LOG_DBG("Failed to initialize interrupt!"); + return -EIO; + } #endif - drv_data->ab_state = ec11_get_ab_state(dev); + drv_data->ab_state = ec11_get_ab_state(dev); - return 0; + return 0; } -#define EC11_INST(n) \ - struct ec11_data ec11_data_##n; \ - const struct ec11_config ec11_cfg_##n = { \ - .a_label = DT_INST_GPIO_LABEL(n, a_gpios), \ - .a_pin = DT_INST_GPIO_PIN(n, a_gpios), \ - .a_flags = DT_INST_GPIO_FLAGS(n, a_gpios), \ - .b_label = DT_INST_GPIO_LABEL(n, b_gpios), \ - .b_pin = DT_INST_GPIO_PIN(n, b_gpios), \ - .b_flags = DT_INST_GPIO_FLAGS(n, b_gpios), \ - COND_CODE_0(DT_INST_NODE_HAS_PROP(n, resolution), (1), (DT_INST_PROP(n, resolution))), \ - }; \ - DEVICE_AND_API_INIT(ec11, DT_INST_LABEL(n), ec11_init, \ - &ec11_data_##n, \ - &ec11_cfg_##n, POST_KERNEL, CONFIG_SENSOR_INIT_PRIORITY, \ - &ec11_driver_api); +#define EC11_INST(n) \ + struct ec11_data ec11_data_##n; \ + const struct ec11_config ec11_cfg_##n = { \ + .a_label = DT_INST_GPIO_LABEL(n, a_gpios), \ + .a_pin = DT_INST_GPIO_PIN(n, a_gpios), \ + .a_flags = DT_INST_GPIO_FLAGS(n, a_gpios), \ + .b_label = DT_INST_GPIO_LABEL(n, b_gpios), \ + .b_pin = DT_INST_GPIO_PIN(n, b_gpios), \ + .b_flags = DT_INST_GPIO_FLAGS(n, b_gpios), \ + COND_CODE_0(DT_INST_NODE_HAS_PROP(n, resolution), (1), (DT_INST_PROP(n, resolution))), \ + }; \ + DEVICE_AND_API_INIT(ec11, DT_INST_LABEL(n), ec11_init, &ec11_data_##n, &ec11_cfg_##n, \ + POST_KERNEL, CONFIG_SENSOR_INIT_PRIORITY, &ec11_driver_api); DT_INST_FOREACH_STATUS_OKAY(EC11_INST) \ No newline at end of file diff --git a/app/drivers/zephyr/ec11.h b/app/drivers/zephyr/ec11.h index 27fed9b..e62e733 100644 --- a/app/drivers/zephyr/ec11.h +++ b/app/drivers/zephyr/ec11.h @@ -11,39 +11,39 @@ #include struct ec11_config { - const char *a_label; - const u8_t a_pin; - const u8_t a_flags; + const char *a_label; + const u8_t a_pin; + const u8_t a_flags; - const char *b_label; - const u8_t b_pin; - const u8_t b_flags; + const char *b_label; + const u8_t b_pin; + const u8_t b_flags; - const u8_t resolution; + const u8_t resolution; }; struct ec11_data { - struct device *a; - struct device *b; - u8_t ab_state; - s8_t pulses; - s8_t ticks; - s8_t delta; + struct device *a; + struct device *b; + u8_t ab_state; + s8_t pulses; + s8_t ticks; + s8_t delta; #ifdef CONFIG_EC11_TRIGGER - struct gpio_callback a_gpio_cb; - struct gpio_callback b_gpio_cb; - struct device *dev; + struct gpio_callback a_gpio_cb; + struct gpio_callback b_gpio_cb; + struct device *dev; - sensor_trigger_handler_t handler; - const struct sensor_trigger *trigger; + sensor_trigger_handler_t handler; + const struct sensor_trigger *trigger; #if defined(CONFIG_EC11_TRIGGER_OWN_THREAD) - K_THREAD_STACK_MEMBER(thread_stack, CONFIG_EC11_THREAD_STACK_SIZE); - struct k_sem gpio_sem; - struct k_thread thread; + K_THREAD_STACK_MEMBER(thread_stack, CONFIG_EC11_THREAD_STACK_SIZE); + struct k_sem gpio_sem; + struct k_thread thread; #elif defined(CONFIG_EC11_TRIGGER_GLOBAL_THREAD) - struct k_work work; + struct k_work work; #endif #endif /* CONFIG_EC11_TRIGGER */ @@ -51,9 +51,8 @@ struct ec11_data { #ifdef CONFIG_EC11_TRIGGER -int ec11_trigger_set(struct device *dev, - const struct sensor_trigger *trig, - sensor_trigger_handler_t handler); +int ec11_trigger_set(struct device *dev, const struct sensor_trigger *trig, + sensor_trigger_handler_t handler); int ec11_init_interrupt(struct device *dev); #endif diff --git a/app/drivers/zephyr/ec11_trigger.c b/app/drivers/zephyr/ec11_trigger.c index a04a561..248ac32 100644 --- a/app/drivers/zephyr/ec11_trigger.c +++ b/app/drivers/zephyr/ec11_trigger.c @@ -19,158 +19,130 @@ extern struct ec11_data ec11_driver; #include LOG_MODULE_DECLARE(EC11, CONFIG_SENSOR_LOG_LEVEL); -static inline void setup_int(struct device *dev, - bool enable) -{ - struct ec11_data *data = dev->driver_data; - const struct ec11_config *cfg = dev->config_info; - - LOG_DBG("enabled %s", (enable ? "true" : "false")); - - if (gpio_pin_interrupt_configure(data->a, - cfg->a_pin, - enable - ? GPIO_INT_EDGE_BOTH - : GPIO_INT_DISABLE)) { - LOG_WRN("Unable to set A pin GPIO interrupt"); - } - - if (gpio_pin_interrupt_configure(data->b, - cfg->b_pin, - enable - ? GPIO_INT_EDGE_BOTH - : GPIO_INT_DISABLE)) { - LOG_WRN("Unable to set A pin GPIO interrupt"); - } +static inline void setup_int(struct device *dev, bool enable) { + struct ec11_data *data = dev->driver_data; + const struct ec11_config *cfg = dev->config_info; + + LOG_DBG("enabled %s", (enable ? "true" : "false")); + + if (gpio_pin_interrupt_configure(data->a, cfg->a_pin, + enable ? GPIO_INT_EDGE_BOTH : GPIO_INT_DISABLE)) { + LOG_WRN("Unable to set A pin GPIO interrupt"); + } + + if (gpio_pin_interrupt_configure(data->b, cfg->b_pin, + enable ? GPIO_INT_EDGE_BOTH : GPIO_INT_DISABLE)) { + LOG_WRN("Unable to set A pin GPIO interrupt"); + } } -static void ec11_a_gpio_callback(struct device *dev, - struct gpio_callback *cb, u32_t pins) -{ - struct ec11_data *drv_data = - CONTAINER_OF(cb, struct ec11_data, a_gpio_cb); +static void ec11_a_gpio_callback(struct device *dev, struct gpio_callback *cb, u32_t pins) { + struct ec11_data *drv_data = CONTAINER_OF(cb, struct ec11_data, a_gpio_cb); - LOG_DBG(""); + LOG_DBG(""); - setup_int(drv_data->dev, false); + setup_int(drv_data->dev, false); #if defined(CONFIG_EC11_TRIGGER_OWN_THREAD) - k_sem_give(&drv_data->gpio_sem); + k_sem_give(&drv_data->gpio_sem); #elif defined(CONFIG_EC11_TRIGGER_GLOBAL_THREAD) - k_work_submit(&drv_data->work); + k_work_submit(&drv_data->work); #endif } -static void ec11_b_gpio_callback(struct device *dev, - struct gpio_callback *cb, u32_t pins) -{ - struct ec11_data *drv_data = - CONTAINER_OF(cb, struct ec11_data, b_gpio_cb); +static void ec11_b_gpio_callback(struct device *dev, struct gpio_callback *cb, u32_t pins) { + struct ec11_data *drv_data = CONTAINER_OF(cb, struct ec11_data, b_gpio_cb); - LOG_DBG(""); + LOG_DBG(""); - setup_int(drv_data->dev, false); + setup_int(drv_data->dev, false); #if defined(CONFIG_EC11_TRIGGER_OWN_THREAD) - k_sem_give(&drv_data->gpio_sem); + k_sem_give(&drv_data->gpio_sem); #elif defined(CONFIG_EC11_TRIGGER_GLOBAL_THREAD) - k_work_submit(&drv_data->work); + k_work_submit(&drv_data->work); #endif } -static void ec11_thread_cb(void *arg) -{ - struct device *dev = arg; - struct ec11_data *drv_data = dev->driver_data; +static void ec11_thread_cb(void *arg) { + struct device *dev = arg; + struct ec11_data *drv_data = dev->driver_data; - drv_data->handler(dev, drv_data->trigger); + drv_data->handler(dev, drv_data->trigger); - setup_int(dev, true); + setup_int(dev, true); } #ifdef CONFIG_EC11_TRIGGER_OWN_THREAD -static void ec11_thread(int dev_ptr, int unused) -{ - struct device *dev = INT_TO_POINTER(dev_ptr); - struct ec11_data *drv_data = dev->driver_data; +static void ec11_thread(int dev_ptr, int unused) { + struct device *dev = INT_TO_POINTER(dev_ptr); + struct ec11_data *drv_data = dev->driver_data; - ARG_UNUSED(unused); + ARG_UNUSED(unused); - while (1) { - k_sem_take(&drv_data->gpio_sem, K_FOREVER); - ec11_thread_cb(dev); - } + while (1) { + k_sem_take(&drv_data->gpio_sem, K_FOREVER); + ec11_thread_cb(dev); + } } #endif #ifdef CONFIG_EC11_TRIGGER_GLOBAL_THREAD -static void ec11_work_cb(struct k_work *work) -{ - struct ec11_data *drv_data = - CONTAINER_OF(work, struct ec11_data, work); +static void ec11_work_cb(struct k_work *work) { + struct ec11_data *drv_data = CONTAINER_OF(work, struct ec11_data, work); - LOG_DBG(""); + LOG_DBG(""); - ec11_thread_cb(drv_data->dev); + ec11_thread_cb(drv_data->dev); } #endif -int ec11_trigger_set(struct device *dev, - const struct sensor_trigger *trig, - sensor_trigger_handler_t handler) -{ - struct ec11_data *drv_data = dev->driver_data; +int ec11_trigger_set(struct device *dev, const struct sensor_trigger *trig, + sensor_trigger_handler_t handler) { + struct ec11_data *drv_data = dev->driver_data; - setup_int(dev, false); + setup_int(dev, false); - k_msleep(5); + k_msleep(5); - drv_data->trigger = trig; - drv_data->handler = handler; + drv_data->trigger = trig; + drv_data->handler = handler; - setup_int(dev, true); + setup_int(dev, true); - return 0; + return 0; } -int ec11_init_interrupt(struct device *dev) -{ - struct ec11_data *drv_data = dev->driver_data; - const struct ec11_config *drv_cfg = dev->config_info; - - drv_data->dev = dev; - /* setup gpio interrupt */ +int ec11_init_interrupt(struct device *dev) { + struct ec11_data *drv_data = dev->driver_data; + const struct ec11_config *drv_cfg = dev->config_info; + drv_data->dev = dev; + /* setup gpio interrupt */ - gpio_init_callback(&drv_data->a_gpio_cb, - ec11_a_gpio_callback, - BIT(drv_cfg->a_pin)); + gpio_init_callback(&drv_data->a_gpio_cb, ec11_a_gpio_callback, BIT(drv_cfg->a_pin)); - if (gpio_add_callback(drv_data->a, &drv_data->a_gpio_cb) < 0) { - LOG_DBG("Failed to set A callback!"); - return -EIO; - } + if (gpio_add_callback(drv_data->a, &drv_data->a_gpio_cb) < 0) { + LOG_DBG("Failed to set A callback!"); + return -EIO; + } - gpio_init_callback(&drv_data->b_gpio_cb, - ec11_b_gpio_callback, - BIT(drv_cfg->b_pin)); + gpio_init_callback(&drv_data->b_gpio_cb, ec11_b_gpio_callback, BIT(drv_cfg->b_pin)); - if (gpio_add_callback(drv_data->b, &drv_data->b_gpio_cb) < 0) { - LOG_DBG("Failed to set B callback!"); - return -EIO; - } + if (gpio_add_callback(drv_data->b, &drv_data->b_gpio_cb) < 0) { + LOG_DBG("Failed to set B callback!"); + return -EIO; + } #if defined(CONFIG_EC11_TRIGGER_OWN_THREAD) - k_sem_init(&drv_data->gpio_sem, 0, UINT_MAX); + k_sem_init(&drv_data->gpio_sem, 0, UINT_MAX); - k_thread_create(&drv_data->thread, drv_data->thread_stack, - CONFIG_EC11_THREAD_STACK_SIZE, - (k_thread_entry_t)ec11_thread, dev, - 0, NULL, K_PRIO_COOP(CONFIG_EC11_THREAD_PRIORITY), - 0, K_NO_WAIT); + k_thread_create(&drv_data->thread, drv_data->thread_stack, CONFIG_EC11_THREAD_STACK_SIZE, + (k_thread_entry_t)ec11_thread, dev, 0, NULL, + K_PRIO_COOP(CONFIG_EC11_THREAD_PRIORITY), 0, K_NO_WAIT); #elif defined(CONFIG_EC11_TRIGGER_GLOBAL_THREAD) - k_work_init(&drv_data->work, ec11_work_cb); + k_work_init(&drv_data->work, ec11_work_cb); #endif - return 0; + return 0; } diff --git a/app/drivers/zephyr/kscan_gpio_direct.c b/app/drivers/zephyr/kscan_gpio_direct.c index 6e6a01f..1e5ab59 100644 --- a/app/drivers/zephyr/kscan_gpio_direct.c +++ b/app/drivers/zephyr/kscan_gpio_direct.c @@ -15,248 +15,215 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); #if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) -struct kscan_gpio_item_config -{ - char *label; - gpio_pin_t pin; - gpio_flags_t flags; +struct kscan_gpio_item_config { + char *label; + gpio_pin_t pin; + gpio_flags_t flags; }; union work_reference { - struct k_delayed_work delayed; - struct k_work direct; + struct k_delayed_work delayed; + struct k_work direct; }; -struct kscan_gpio_config -{ - u8_t num_of_inputs; - u8_t debounce_period; - struct kscan_gpio_item_config inputs[]; +struct kscan_gpio_config { + u8_t num_of_inputs; + u8_t debounce_period; + struct kscan_gpio_item_config inputs[]; }; -struct kscan_gpio_data -{ +struct kscan_gpio_data { #if defined(CONFIG_ZMK_KSCAN_GPIO_POLLING) - struct k_timer poll_timer; + struct k_timer poll_timer; #endif /* defined(CONFIG_ZMK_KSCAN_GPIO_POLLING) */ - kscan_callback_t callback; - union work_reference work; - struct device *dev; - u32_t pin_state; - struct device *inputs[]; + kscan_callback_t callback; + union work_reference work; + struct device *dev; + u32_t pin_state; + struct device *inputs[]; }; -static struct device **kscan_gpio_input_devices(struct device *dev) -{ - struct kscan_gpio_data *data = dev->driver_data; - return data->inputs; +static struct device **kscan_gpio_input_devices(struct device *dev) { + struct kscan_gpio_data *data = dev->driver_data; + return data->inputs; } -static const struct kscan_gpio_item_config *kscan_gpio_input_configs(struct device *dev) -{ - const struct kscan_gpio_config *cfg = dev->config_info; - return cfg->inputs; +static const struct kscan_gpio_item_config *kscan_gpio_input_configs(struct device *dev) { + const struct kscan_gpio_config *cfg = dev->config_info; + return cfg->inputs; } #if !defined(CONFIG_ZMK_KSCAN_GPIO_POLLING) -struct kscan_gpio_irq_callback -{ - union work_reference *work; - u8_t debounce_period; - struct gpio_callback callback; +struct kscan_gpio_irq_callback { + union work_reference *work; + u8_t debounce_period; + struct gpio_callback callback; }; -static int kscan_gpio_config_interrupts(struct device *dev, gpio_flags_t flags) -{ - const struct kscan_gpio_config *cfg = dev->config_info; - struct device **devices = kscan_gpio_input_devices(dev); - const struct kscan_gpio_item_config *configs = kscan_gpio_input_configs(dev); - - for (int i = 0; i < cfg->num_of_inputs; i++) - { - struct device *dev = devices[i]; - const struct kscan_gpio_item_config *cfg = &configs[i]; - - int err = gpio_pin_interrupt_configure(dev, cfg->pin, flags); - - if (err) - { - LOG_ERR("Unable to enable matrix GPIO interrupt"); - return err; - } - } - - return 0; +static int kscan_gpio_config_interrupts(struct device *dev, gpio_flags_t flags) { + const struct kscan_gpio_config *cfg = dev->config_info; + struct device **devices = kscan_gpio_input_devices(dev); + const struct kscan_gpio_item_config *configs = kscan_gpio_input_configs(dev); + + for (int i = 0; i < cfg->num_of_inputs; i++) { + struct device *dev = devices[i]; + const struct kscan_gpio_item_config *cfg = &configs[i]; + + int err = gpio_pin_interrupt_configure(dev, cfg->pin, flags); + + if (err) { + LOG_ERR("Unable to enable matrix GPIO interrupt"); + return err; + } + } + + return 0; } -static int kscan_gpio_direct_enable(struct device *dev) -{ - return kscan_gpio_config_interrupts(dev, - GPIO_INT_DEBOUNCE | GPIO_INT_EDGE_BOTH); +static int kscan_gpio_direct_enable(struct device *dev) { + return kscan_gpio_config_interrupts(dev, GPIO_INT_DEBOUNCE | GPIO_INT_EDGE_BOTH); } -static int kscan_gpio_direct_disable(struct device *dev) -{ - return kscan_gpio_config_interrupts(dev, - GPIO_INT_DISABLE); +static int kscan_gpio_direct_disable(struct device *dev) { + return kscan_gpio_config_interrupts(dev, GPIO_INT_DISABLE); } -static void kscan_gpio_irq_callback_handler(struct device *dev, - struct gpio_callback *cb, gpio_port_pins_t pin) -{ - struct kscan_gpio_irq_callback *data = - CONTAINER_OF(cb, struct kscan_gpio_irq_callback, callback); - - if (data->debounce_period > 0) { - k_delayed_work_cancel(&data->work->delayed); - k_delayed_work_submit(&data->work->delayed, K_MSEC(data->debounce_period)); - } else { - k_work_submit(&data->work->direct); - } +static void kscan_gpio_irq_callback_handler(struct device *dev, struct gpio_callback *cb, + gpio_port_pins_t pin) { + struct kscan_gpio_irq_callback *data = + CONTAINER_OF(cb, struct kscan_gpio_irq_callback, callback); + + if (data->debounce_period > 0) { + k_delayed_work_cancel(&data->work->delayed); + k_delayed_work_submit(&data->work->delayed, K_MSEC(data->debounce_period)); + } else { + k_work_submit(&data->work->direct); + } } -#else /* !defined(CONFIG_ZMK_KSCAN_GPIO_POLLING) */ +#else /* !defined(CONFIG_ZMK_KSCAN_GPIO_POLLING) */ -static void kscan_gpio_timer_handler(struct k_timer *timer) -{ - struct kscan_gpio_data *data = - CONTAINER_OF(timer, struct kscan_gpio_data, poll_timer); +static void kscan_gpio_timer_handler(struct k_timer *timer) { + struct kscan_gpio_data *data = CONTAINER_OF(timer, struct kscan_gpio_data, poll_timer); - k_work_submit(&data->work.direct); + k_work_submit(&data->work.direct); } -static int kscan_gpio_direct_enable(struct device *dev) -{ - struct kscan_gpio_data *data = dev->driver_data; - k_timer_start(&data->poll_timer, K_MSEC(10), K_MSEC(10)); - return 0; +static int kscan_gpio_direct_enable(struct device *dev) { + struct kscan_gpio_data *data = dev->driver_data; + k_timer_start(&data->poll_timer, K_MSEC(10), K_MSEC(10)); + return 0; } -static int kscan_gpio_direct_disable(struct device *dev) -{ - struct kscan_gpio_data *data = dev->driver_data; - k_timer_stop(&data->poll_timer); - return 0; +static int kscan_gpio_direct_disable(struct device *dev) { + struct kscan_gpio_data *data = dev->driver_data; + k_timer_stop(&data->poll_timer); + return 0; } #endif /* defined(CONFIG_ZMK_KSCAN_GPIO_POLLING) */ -static int kscan_gpio_direct_configure(struct device *dev, kscan_callback_t callback) -{ - struct kscan_gpio_data *data = dev->driver_data; - if (!callback) - { - return -EINVAL; - } - data->callback = callback; - return 0; +static int kscan_gpio_direct_configure(struct device *dev, kscan_callback_t callback) { + struct kscan_gpio_data *data = dev->driver_data; + if (!callback) { + return -EINVAL; + } + data->callback = callback; + return 0; } -static int kscan_gpio_read(struct device *dev) -{ - struct kscan_gpio_data *data = dev->driver_data; - const struct kscan_gpio_config *cfg = dev->config_info; - u32_t read_state = data->pin_state; - for (int i = 0; i < cfg->num_of_inputs; i++) - { - struct device *in_dev = kscan_gpio_input_devices(dev)[i]; - const struct kscan_gpio_item_config *in_cfg = &kscan_gpio_input_configs(dev)[i]; - WRITE_BIT(read_state, i, gpio_pin_get(in_dev, in_cfg->pin) > 0); - } - for (int i = 0; i < cfg->num_of_inputs; i++) - { - bool prev_pressed = BIT(i) & data->pin_state; - bool pressed = BIT(i) & read_state; - if (pressed != prev_pressed) - { - LOG_DBG("Sending event at %d,%d state %s", - 0, i, (pressed ? "on" : "off")); - WRITE_BIT(data->pin_state, i, pressed); - data->callback(dev, 0, i, pressed); - } - } - return 0; +static int kscan_gpio_read(struct device *dev) { + struct kscan_gpio_data *data = dev->driver_data; + const struct kscan_gpio_config *cfg = dev->config_info; + u32_t read_state = data->pin_state; + for (int i = 0; i < cfg->num_of_inputs; i++) { + struct device *in_dev = kscan_gpio_input_devices(dev)[i]; + const struct kscan_gpio_item_config *in_cfg = &kscan_gpio_input_configs(dev)[i]; + WRITE_BIT(read_state, i, gpio_pin_get(in_dev, in_cfg->pin) > 0); + } + for (int i = 0; i < cfg->num_of_inputs; i++) { + bool prev_pressed = BIT(i) & data->pin_state; + bool pressed = BIT(i) & read_state; + if (pressed != prev_pressed) { + LOG_DBG("Sending event at %d,%d state %s", 0, i, (pressed ? "on" : "off")); + WRITE_BIT(data->pin_state, i, pressed); + data->callback(dev, 0, i, pressed); + } + } + return 0; } -static void kscan_gpio_work_handler(struct k_work *work) -{ - struct kscan_gpio_data *data = - CONTAINER_OF(work, struct kscan_gpio_data, work); - kscan_gpio_read(data->dev); +static void kscan_gpio_work_handler(struct k_work *work) { + struct kscan_gpio_data *data = CONTAINER_OF(work, struct kscan_gpio_data, work); + kscan_gpio_read(data->dev); } static const struct kscan_driver_api gpio_driver_api = { - .config = kscan_gpio_direct_configure, - .enable_callback = kscan_gpio_direct_enable, - .disable_callback = kscan_gpio_direct_disable, + .config = kscan_gpio_direct_configure, + .enable_callback = kscan_gpio_direct_enable, + .disable_callback = kscan_gpio_direct_disable, }; -#define KSCAN_DIRECT_INPUT_ITEM(i,n) \ - { \ - .label = DT_INST_GPIO_LABEL_BY_IDX(n, input_gpios, i), \ - .pin = DT_INST_GPIO_PIN_BY_IDX(n, input_gpios, i), \ - .flags = DT_INST_GPIO_FLAGS_BY_IDX(n, input_gpios, i), \ - }, +#define KSCAN_DIRECT_INPUT_ITEM(i, n) \ + { \ + .label = DT_INST_GPIO_LABEL_BY_IDX(n, input_gpios, i), \ + .pin = DT_INST_GPIO_PIN_BY_IDX(n, input_gpios, i), \ + .flags = DT_INST_GPIO_FLAGS_BY_IDX(n, input_gpios, i), \ + }, #define INST_INPUT_LEN(n) DT_INST_PROP_LEN(n, input_gpios) -#define GPIO_INST_INIT(n) \ - COND_CODE_0(CONFIG_ZMK_KSCAN_GPIO_POLLING, (static struct kscan_gpio_irq_callback \ - irq_callbacks_##n[INST_INPUT_LEN(n)];), ()) \ - static struct kscan_gpio_data kscan_gpio_data_##n = { \ - .inputs = { [INST_INPUT_LEN(n)-1] = NULL } \ - }; \ - static int kscan_gpio_init_##n(struct device *dev) \ - { \ - struct kscan_gpio_data *data = dev->driver_data; \ - const struct kscan_gpio_config *cfg = dev->config_info; \ - int err; \ - struct device **input_devices = kscan_gpio_input_devices(dev); \ - for (int i = 0; i < cfg->num_of_inputs; i++) \ - { \ - const struct kscan_gpio_item_config *in_cfg = &kscan_gpio_input_configs(dev)[i]; \ - input_devices[i] = device_get_binding(in_cfg->label); \ - if (!input_devices[i]) \ - { \ - LOG_ERR("Unable to find input GPIO device"); \ - return -EINVAL; \ - } \ - err = gpio_pin_configure(input_devices[i], in_cfg->pin, GPIO_INPUT | in_cfg->flags); \ - if (err) \ - { \ - LOG_ERR("Unable to configure pin %d on %s for input", in_cfg->pin, in_cfg->label); \ - return err; \ - } \ - COND_CODE_0(CONFIG_ZMK_KSCAN_GPIO_POLLING, \ - ( \ - irq_callbacks_##n[i].work = &data->work; \ - irq_callbacks_##n[i].debounce_period = cfg->debounce_period; \ - gpio_init_callback(&irq_callbacks_##n[i].callback, kscan_gpio_irq_callback_handler, BIT(in_cfg->pin)); \ - err = gpio_add_callback(input_devices[i], &irq_callbacks_##n[i].callback); \ - if (err) \ - { \ - LOG_ERR("Error adding the callback to the column device"); \ - return err; \ - } \ - ), ()) \ - } \ - data->dev = dev; \ - COND_CODE_1(CONFIG_ZMK_KSCAN_GPIO_POLLING, (k_timer_init(&data->poll_timer, kscan_gpio_timer_handler, NULL);), ( )) \ - if (cfg->debounce_period > 0) { \ - k_delayed_work_init(&data->work.delayed, kscan_gpio_work_handler); \ - } else { \ - k_work_init(&data->work.direct, kscan_gpio_work_handler); \ - } \ - return 0; \ - } \ - static const struct kscan_gpio_config kscan_gpio_config_##n = { \ - .inputs = { UTIL_LISTIFY(INST_INPUT_LEN(n), KSCAN_DIRECT_INPUT_ITEM, n) }, \ - .num_of_inputs = INST_INPUT_LEN(n), \ - .debounce_period = DT_INST_PROP(n, debounce_period) \ - }; \ - DEVICE_AND_API_INIT(kscan_gpio_##n, DT_INST_LABEL(n), kscan_gpio_init_##n, \ - &kscan_gpio_data_##n, &kscan_gpio_config_##n, \ - POST_KERNEL, CONFIG_ZMK_KSCAN_INIT_PRIORITY, \ - &gpio_driver_api); +#define GPIO_INST_INIT(n) \ + COND_CODE_0(CONFIG_ZMK_KSCAN_GPIO_POLLING, \ + (static struct kscan_gpio_irq_callback irq_callbacks_##n[INST_INPUT_LEN(n)];), ()) \ + static struct kscan_gpio_data kscan_gpio_data_##n = { \ + .inputs = {[INST_INPUT_LEN(n) - 1] = NULL}}; \ + static int kscan_gpio_init_##n(struct device *dev) { \ + struct kscan_gpio_data *data = dev->driver_data; \ + const struct kscan_gpio_config *cfg = dev->config_info; \ + int err; \ + struct device **input_devices = kscan_gpio_input_devices(dev); \ + for (int i = 0; i < cfg->num_of_inputs; i++) { \ + const struct kscan_gpio_item_config *in_cfg = &kscan_gpio_input_configs(dev)[i]; \ + input_devices[i] = device_get_binding(in_cfg->label); \ + if (!input_devices[i]) { \ + LOG_ERR("Unable to find input GPIO device"); \ + return -EINVAL; \ + } \ + err = gpio_pin_configure(input_devices[i], in_cfg->pin, GPIO_INPUT | in_cfg->flags); \ + if (err) { \ + LOG_ERR("Unable to configure pin %d on %s for input", in_cfg->pin, in_cfg->label); \ + return err; \ + } \ + COND_CODE_0( \ + CONFIG_ZMK_KSCAN_GPIO_POLLING, \ + (irq_callbacks_##n[i].work = &data->work; \ + irq_callbacks_##n[i].debounce_period = cfg->debounce_period; \ + gpio_init_callback(&irq_callbacks_##n[i].callback, \ + kscan_gpio_irq_callback_handler, BIT(in_cfg->pin)); \ + err = gpio_add_callback(input_devices[i], &irq_callbacks_##n[i].callback); \ + if (err) { \ + LOG_ERR("Error adding the callback to the column device"); \ + return err; \ + }), \ + ()) \ + } \ + data->dev = dev; \ + COND_CODE_1(CONFIG_ZMK_KSCAN_GPIO_POLLING, \ + (k_timer_init(&data->poll_timer, kscan_gpio_timer_handler, NULL);), ()) \ + if (cfg->debounce_period > 0) { \ + k_delayed_work_init(&data->work.delayed, kscan_gpio_work_handler); \ + } else { \ + k_work_init(&data->work.direct, kscan_gpio_work_handler); \ + } \ + return 0; \ + } \ + static const struct kscan_gpio_config kscan_gpio_config_##n = { \ + .inputs = {UTIL_LISTIFY(INST_INPUT_LEN(n), KSCAN_DIRECT_INPUT_ITEM, n)}, \ + .num_of_inputs = INST_INPUT_LEN(n), \ + .debounce_period = DT_INST_PROP(n, debounce_period)}; \ + DEVICE_AND_API_INIT(kscan_gpio_##n, DT_INST_LABEL(n), kscan_gpio_init_##n, \ + &kscan_gpio_data_##n, &kscan_gpio_config_##n, POST_KERNEL, \ + CONFIG_ZMK_KSCAN_INIT_PRIORITY, &gpio_driver_api); DT_INST_FOREACH_STATUS_OKAY(GPIO_INST_INIT) diff --git a/app/drivers/zephyr/kscan_gpio_matrix.c b/app/drivers/zephyr/kscan_gpio_matrix.c index 079a830..634f694 100644 --- a/app/drivers/zephyr/kscan_gpio_matrix.c +++ b/app/drivers/zephyr/kscan_gpio_matrix.c @@ -15,266 +15,248 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); #if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) -struct kscan_gpio_item_config -{ - char *label; - gpio_pin_t pin; - gpio_flags_t flags; +struct kscan_gpio_item_config { + char *label; + gpio_pin_t pin; + gpio_flags_t flags; }; - -#define _KSCAN_GPIO_ITEM_CFG_INIT(n, prop, idx) \ - { \ - .label = DT_INST_GPIO_LABEL_BY_IDX(n, prop, idx), \ - .pin = DT_INST_GPIO_PIN_BY_IDX(n, prop, idx), \ - .flags = DT_INST_GPIO_FLAGS_BY_IDX(n, prop, idx), \ - }, +#define _KSCAN_GPIO_ITEM_CFG_INIT(n, prop, idx) \ + { \ + .label = DT_INST_GPIO_LABEL_BY_IDX(n, prop, idx), \ + .pin = DT_INST_GPIO_PIN_BY_IDX(n, prop, idx), \ + .flags = DT_INST_GPIO_FLAGS_BY_IDX(n, prop, idx), \ + }, #define _KSCAN_GPIO_ROW_CFG_INIT(idx, n) _KSCAN_GPIO_ITEM_CFG_INIT(n, row_gpios, idx) #define _KSCAN_GPIO_COL_CFG_INIT(idx, n) _KSCAN_GPIO_ITEM_CFG_INIT(n, col_gpios, idx) - + static int kscan_gpio_config_interrupts(struct device **devices, - const struct kscan_gpio_item_config *configs, - size_t len, gpio_flags_t flags) -{ - for (int i = 0; i < len; i++) - { - struct device *dev = devices[i]; - const struct kscan_gpio_item_config *cfg = &configs[i]; + const struct kscan_gpio_item_config *configs, size_t len, + gpio_flags_t flags) { + for (int i = 0; i < len; i++) { + struct device *dev = devices[i]; + const struct kscan_gpio_item_config *cfg = &configs[i]; - int err = gpio_pin_interrupt_configure(dev, cfg->pin, flags); + int err = gpio_pin_interrupt_configure(dev, cfg->pin, flags); - if (err) - { - LOG_ERR("Unable to enable matrix GPIO interrupt"); - return err; - } - } + if (err) { + LOG_ERR("Unable to enable matrix GPIO interrupt"); + return err; + } + } - return 0; + return 0; } #define INST_MATRIX_ROWS(n) DT_INST_PROP_LEN(n, row_gpios) #define INST_MATRIX_COLS(n) DT_INST_PROP_LEN(n, col_gpios) -#define INST_OUTPUT_LEN(n) COND_CODE_0(DT_ENUM_IDX(DT_DRV_INST(n), diode_direction), (INST_MATRIX_ROWS(n)), (INST_MATRIX_COLS(n))) -#define INST_INPUT_LEN(n) COND_CODE_0(DT_ENUM_IDX(DT_DRV_INST(n), diode_direction), (INST_MATRIX_COLS(n)), (INST_MATRIX_ROWS(n))) +#define INST_OUTPUT_LEN(n) \ + COND_CODE_0(DT_ENUM_IDX(DT_DRV_INST(n), diode_direction), (INST_MATRIX_ROWS(n)), \ + (INST_MATRIX_COLS(n))) +#define INST_INPUT_LEN(n) \ + COND_CODE_0(DT_ENUM_IDX(DT_DRV_INST(n), diode_direction), (INST_MATRIX_COLS(n)), \ + (INST_MATRIX_ROWS(n))) -#define GPIO_INST_INIT(n) \ - struct kscan_gpio_irq_callback_##n \ - { \ - struct COND_CODE_0(DT_INST_PROP(n, debounce_period), (k_work), (k_delayed_work)) * work; \ - struct gpio_callback callback; \ - }; \ - static struct kscan_gpio_irq_callback_##n \ - irq_callbacks_##n[INST_INPUT_LEN(n)]; \ - struct kscan_gpio_config_##n \ - { \ - struct kscan_gpio_item_config rows[INST_MATRIX_ROWS(n)]; \ - struct kscan_gpio_item_config cols[INST_MATRIX_COLS(n)]; \ - }; \ - struct kscan_gpio_data_##n \ - { \ - kscan_callback_t callback; \ - struct COND_CODE_0(DT_INST_PROP(n, debounce_period), (k_work), (k_delayed_work)) work; \ - bool matrix_state[INST_MATRIX_ROWS(n)][INST_MATRIX_COLS(n)]; \ - struct device *rows[INST_MATRIX_ROWS(n)]; \ - struct device *cols[INST_MATRIX_COLS(n)]; \ - struct device *dev; \ - }; \ - static struct device **kscan_gpio_input_devices_##n(struct device *dev) \ - { \ - struct kscan_gpio_data_##n *data = dev->driver_data; \ - return (COND_CODE_0(DT_ENUM_IDX(DT_DRV_INST(n), diode_direction), (data->cols), (data->rows))); \ - } \ - static const struct kscan_gpio_item_config *kscan_gpio_input_configs_##n(struct device *dev) \ - { \ - const struct kscan_gpio_config_##n *cfg = dev->config_info; \ - return ((COND_CODE_0(DT_ENUM_IDX(DT_DRV_INST(n), diode_direction), (cfg->cols), (cfg->rows)))); \ - } \ - static struct device **kscan_gpio_output_devices_##n(struct device *dev) \ - { \ - struct kscan_gpio_data_##n *data = dev->driver_data; \ - return (COND_CODE_0(DT_ENUM_IDX(DT_DRV_INST(n), diode_direction), (data->rows), (data->cols))); \ - } \ - static const struct kscan_gpio_item_config *kscan_gpio_output_configs_##n(struct device *dev) \ - { \ - const struct kscan_gpio_config_##n *cfg = dev->config_info; \ - return (COND_CODE_0(DT_ENUM_IDX(DT_DRV_INST(n), diode_direction), (cfg->rows), (cfg->cols))); \ - } \ - static int kscan_gpio_enable_interrupts_##n(struct device *dev) \ - { \ - return kscan_gpio_config_interrupts(kscan_gpio_input_devices_##n(dev), kscan_gpio_input_configs_##n(dev), INST_INPUT_LEN(n), \ - GPIO_INT_DEBOUNCE | GPIO_INT_EDGE_BOTH); \ - } \ - static int kscan_gpio_disable_interrupts_##n(struct device *dev) \ - { \ - return kscan_gpio_config_interrupts(kscan_gpio_input_devices_##n(dev), kscan_gpio_input_configs_##n(dev), INST_INPUT_LEN(n), \ - GPIO_INT_DISABLE); \ - } \ - static void kscan_gpio_set_output_state_##n(struct device *dev, int value) \ - { \ - for (int i = 0; i < INST_OUTPUT_LEN(n); i++) \ - { \ - struct device *in_dev = kscan_gpio_output_devices_##n(dev)[i]; \ - const struct kscan_gpio_item_config *cfg = &kscan_gpio_output_configs_##n(dev)[i]; \ - gpio_pin_set(in_dev, cfg->pin, value); \ - } \ - } \ - static void kscan_gpio_set_matrix_state_##n(bool state[INST_MATRIX_ROWS(n)][INST_MATRIX_COLS(n)], u32_t input_index, u32_t output_index, bool value) \ - { \ - state[COND_CODE_0(DT_ENUM_IDX(DT_DRV_INST(n), diode_direction), (output_index), (input_index))][COND_CODE_0(DT_ENUM_IDX(DT_DRV_INST(n), diode_direction), (input_index), (output_index))] = value; \ - } \ - static int kscan_gpio_read_##n(struct device *dev) \ - { \ - bool submit_follow_up_read = false; \ - struct kscan_gpio_data_##n *data = dev->driver_data; \ - static bool read_state[INST_MATRIX_ROWS(n)][INST_MATRIX_COLS(n)]; \ - /* Disable our interrupts temporarily while we scan, to avoid */ \ - /* re-entry while we iterate columns and set them active one by one */ \ - /* to get pressed state for each matrix cell. */ \ - kscan_gpio_disable_interrupts_##n(dev); \ - kscan_gpio_set_output_state_##n(dev, 0); \ - for (int o = 0; o < INST_OUTPUT_LEN(n); o++) \ - { \ - struct device *out_dev = kscan_gpio_output_devices_##n(dev)[o]; \ - const struct kscan_gpio_item_config *out_cfg = &kscan_gpio_output_configs_##n(dev)[o]; \ - gpio_pin_set(out_dev, out_cfg->pin, 1); \ - for (int i = 0; i < INST_INPUT_LEN(n); i++) \ - { \ - struct device *in_dev = kscan_gpio_input_devices_##n(dev)[i]; \ - const struct kscan_gpio_item_config *in_cfg = &kscan_gpio_input_configs_##n(dev)[i]; \ - kscan_gpio_set_matrix_state_##n(read_state, i, o, gpio_pin_get(in_dev, in_cfg->pin) > 0); \ - } \ - gpio_pin_set(out_dev, out_cfg->pin, 0); \ - } \ - /* Set all our outputs as active again, then re-enable interrupts, */ \ - /* so we can trigger interrupts again for future press/release */ \ - kscan_gpio_set_output_state_##n(dev, 1); \ - kscan_gpio_enable_interrupts_##n(dev); \ - for (int r = 0; r < INST_MATRIX_ROWS(n); r++) \ - { \ - for (int c = 0; c < INST_MATRIX_COLS(n); c++) \ - { \ - bool pressed = read_state[r][c]; \ - /* Follow up reads needed because further interrupts won't fire on already tripped input GPIO pins */ \ - submit_follow_up_read = (submit_follow_up_read || pressed); \ - if (pressed != data->matrix_state[r][c]) \ - { \ - LOG_DBG("Sending event at %d,%d state %s", \ - r, c, (pressed ? "on" : "off")); \ - data->matrix_state[r][c] = pressed; \ - data->callback(dev, r, c, pressed); \ - } \ - } \ - } \ - if (submit_follow_up_read) { \ - COND_CODE_0(DT_INST_PROP(n, debounce_period), \ - ({ k_work_submit(&data->work); }), \ - ({ \ - k_delayed_work_cancel(&data->work); \ - k_delayed_work_submit(&data->work, K_MSEC(5)); })) \ - } \ - return 0; \ - } \ - static void kscan_gpio_work_handler_##n(struct k_work *work) \ - { \ - struct kscan_gpio_data_##n *data = \ - CONTAINER_OF(work, struct kscan_gpio_data_##n, work); \ - kscan_gpio_read_##n(data->dev); \ - } \ - static void kscan_gpio_irq_callback_handler_##n(struct device *dev, \ - struct gpio_callback *cb, gpio_port_pins_t pin) \ - { \ - struct kscan_gpio_irq_callback_##n *data = \ - CONTAINER_OF(cb, struct kscan_gpio_irq_callback_##n, callback); \ - COND_CODE_0(DT_INST_PROP(n, debounce_period), \ - ({ k_work_submit(data->work); }), \ - ({ \ - k_delayed_work_cancel(data->work); \ - k_delayed_work_submit(data->work, K_MSEC(DT_INST_PROP(n, debounce_period))); })) \ - } \ - static struct kscan_gpio_data_##n kscan_gpio_data_##n = { \ - .rows = { [INST_MATRIX_ROWS(n)-1] = NULL}, \ - .cols = { [INST_MATRIX_COLS(n)-1] = NULL }\ - }; \ - static int kscan_gpio_configure_##n(struct device *dev, kscan_callback_t callback) \ - { \ - struct kscan_gpio_data_##n *data = dev->driver_data; \ - if (!callback) \ - { \ - return -EINVAL; \ - } \ - data->callback = callback; \ - return 0; \ - }; \ - static int kscan_gpio_enable_##n(struct device *dev) \ - { \ - int err = kscan_gpio_enable_interrupts_##n(dev); \ - if (err) { return err; } \ - return kscan_gpio_read_##n(dev); \ - }; \ - static int kscan_gpio_init_##n(struct device *dev) \ - { \ - struct kscan_gpio_data_##n *data = dev->driver_data; \ - int err; \ - struct device **input_devices = kscan_gpio_input_devices_##n(dev); \ - for (int i = 0; i < INST_INPUT_LEN(n); i++) \ - { \ - const struct kscan_gpio_item_config *in_cfg = &kscan_gpio_input_configs_##n(dev)[i]; \ - input_devices[i] = device_get_binding(in_cfg->label); \ - if (!input_devices[i]) \ - { \ - LOG_ERR("Unable to find input GPIO device"); \ - return -EINVAL; \ - } \ - err = gpio_pin_configure(input_devices[i], in_cfg->pin, GPIO_INPUT | in_cfg->flags); \ - if (err) \ - { \ - LOG_ERR("Unable to configure pin %d on %s for input", in_cfg->pin, in_cfg->label); \ - return err; \ - } \ - irq_callbacks_##n[i].work = &data->work; \ - gpio_init_callback(&irq_callbacks_##n[i].callback, kscan_gpio_irq_callback_handler_##n, BIT(in_cfg->pin)); \ - err = gpio_add_callback(input_devices[i], &irq_callbacks_##n[i].callback); \ - if (err) \ - { \ - LOG_ERR("Error adding the callback to the column device"); \ - return err; \ - } \ - } \ - struct device **output_devices = kscan_gpio_output_devices_##n(dev); \ - for (int o = 0; o < INST_OUTPUT_LEN(n); o++) \ - { \ - const struct kscan_gpio_item_config *out_cfg = &kscan_gpio_output_configs_##n(dev)[o]; \ - output_devices[o] = device_get_binding(out_cfg->label); \ - if (!output_devices[o]) \ - { \ - LOG_ERR("Unable to find output GPIO device"); \ - return -EINVAL; \ - } \ - err = gpio_pin_configure(output_devices[o], out_cfg->pin, GPIO_OUTPUT_ACTIVE | out_cfg->flags); \ - if (err) \ - { \ - LOG_ERR("Unable to configure pin %d on %s for output", out_cfg->pin, out_cfg->label); \ - return err; \ - } \ - } \ - data->dev = dev; \ - (COND_CODE_0(DT_INST_PROP(n, debounce_period), (k_work_init), (k_delayed_work_init)))(&data->work, kscan_gpio_work_handler_##n); \ - return 0; \ - } \ - static const struct kscan_driver_api gpio_driver_api_##n = { \ - .config = kscan_gpio_configure_##n, \ - .enable_callback = kscan_gpio_enable_##n, \ - .disable_callback = kscan_gpio_disable_interrupts_##n, \ - }; \ - static const struct kscan_gpio_config_##n kscan_gpio_config_##n = { \ - .rows = { UTIL_LISTIFY(INST_MATRIX_ROWS(n), _KSCAN_GPIO_ROW_CFG_INIT, n) }, \ - .cols = { UTIL_LISTIFY(INST_MATRIX_COLS(n), _KSCAN_GPIO_COL_CFG_INIT, n) }, \ - }; \ - DEVICE_AND_API_INIT(kscan_gpio_##n, DT_INST_LABEL(n), kscan_gpio_init_##n, \ - &kscan_gpio_data_##n, &kscan_gpio_config_##n, \ - APPLICATION, CONFIG_APPLICATION_INIT_PRIORITY, \ - &gpio_driver_api_##n); +#define GPIO_INST_INIT(n) \ + struct kscan_gpio_irq_callback_##n { \ + struct COND_CODE_0(DT_INST_PROP(n, debounce_period), (k_work), (k_delayed_work)) * work; \ + struct gpio_callback callback; \ + }; \ + static struct kscan_gpio_irq_callback_##n irq_callbacks_##n[INST_INPUT_LEN(n)]; \ + struct kscan_gpio_config_##n { \ + struct kscan_gpio_item_config rows[INST_MATRIX_ROWS(n)]; \ + struct kscan_gpio_item_config cols[INST_MATRIX_COLS(n)]; \ + }; \ + struct kscan_gpio_data_##n { \ + kscan_callback_t callback; \ + struct COND_CODE_0(DT_INST_PROP(n, debounce_period), (k_work), (k_delayed_work)) work; \ + bool matrix_state[INST_MATRIX_ROWS(n)][INST_MATRIX_COLS(n)]; \ + struct device *rows[INST_MATRIX_ROWS(n)]; \ + struct device *cols[INST_MATRIX_COLS(n)]; \ + struct device *dev; \ + }; \ + static struct device **kscan_gpio_input_devices_##n(struct device *dev) { \ + struct kscan_gpio_data_##n *data = dev->driver_data; \ + return (COND_CODE_0(DT_ENUM_IDX(DT_DRV_INST(n), diode_direction), (data->cols), \ + (data->rows))); \ + } \ + static const struct kscan_gpio_item_config *kscan_gpio_input_configs_##n(struct device *dev) { \ + const struct kscan_gpio_config_##n *cfg = dev->config_info; \ + return (( \ + COND_CODE_0(DT_ENUM_IDX(DT_DRV_INST(n), diode_direction), (cfg->cols), (cfg->rows)))); \ + } \ + static struct device **kscan_gpio_output_devices_##n(struct device *dev) { \ + struct kscan_gpio_data_##n *data = dev->driver_data; \ + return (COND_CODE_0(DT_ENUM_IDX(DT_DRV_INST(n), diode_direction), (data->rows), \ + (data->cols))); \ + } \ + static const struct kscan_gpio_item_config *kscan_gpio_output_configs_##n( \ + struct device *dev) { \ + const struct kscan_gpio_config_##n *cfg = dev->config_info; \ + return ( \ + COND_CODE_0(DT_ENUM_IDX(DT_DRV_INST(n), diode_direction), (cfg->rows), (cfg->cols))); \ + } \ + static int kscan_gpio_enable_interrupts_##n(struct device *dev) { \ + return kscan_gpio_config_interrupts(kscan_gpio_input_devices_##n(dev), \ + kscan_gpio_input_configs_##n(dev), INST_INPUT_LEN(n), \ + GPIO_INT_DEBOUNCE | GPIO_INT_EDGE_BOTH); \ + } \ + static int kscan_gpio_disable_interrupts_##n(struct device *dev) { \ + return kscan_gpio_config_interrupts(kscan_gpio_input_devices_##n(dev), \ + kscan_gpio_input_configs_##n(dev), INST_INPUT_LEN(n), \ + GPIO_INT_DISABLE); \ + } \ + static void kscan_gpio_set_output_state_##n(struct device *dev, int value) { \ + for (int i = 0; i < INST_OUTPUT_LEN(n); i++) { \ + struct device *in_dev = kscan_gpio_output_devices_##n(dev)[i]; \ + const struct kscan_gpio_item_config *cfg = &kscan_gpio_output_configs_##n(dev)[i]; \ + gpio_pin_set(in_dev, cfg->pin, value); \ + } \ + } \ + static void kscan_gpio_set_matrix_state_##n( \ + bool state[INST_MATRIX_ROWS(n)][INST_MATRIX_COLS(n)], u32_t input_index, \ + u32_t output_index, bool value) { \ + state[COND_CODE_0(DT_ENUM_IDX(DT_DRV_INST(n), diode_direction), (output_index), \ + (input_index))] \ + [COND_CODE_0(DT_ENUM_IDX(DT_DRV_INST(n), diode_direction), (input_index), \ + (output_index))] = value; \ + } \ + static int kscan_gpio_read_##n(struct device *dev) { \ + bool submit_follow_up_read = false; \ + struct kscan_gpio_data_##n *data = dev->driver_data; \ + static bool read_state[INST_MATRIX_ROWS(n)][INST_MATRIX_COLS(n)]; \ + /* Disable our interrupts temporarily while we scan, to avoid */ \ + /* re-entry while we iterate columns and set them active one by one */ \ + /* to get pressed state for each matrix cell. */ \ + kscan_gpio_disable_interrupts_##n(dev); \ + kscan_gpio_set_output_state_##n(dev, 0); \ + for (int o = 0; o < INST_OUTPUT_LEN(n); o++) { \ + struct device *out_dev = kscan_gpio_output_devices_##n(dev)[o]; \ + const struct kscan_gpio_item_config *out_cfg = &kscan_gpio_output_configs_##n(dev)[o]; \ + gpio_pin_set(out_dev, out_cfg->pin, 1); \ + for (int i = 0; i < INST_INPUT_LEN(n); i++) { \ + struct device *in_dev = kscan_gpio_input_devices_##n(dev)[i]; \ + const struct kscan_gpio_item_config *in_cfg = \ + &kscan_gpio_input_configs_##n(dev)[i]; \ + kscan_gpio_set_matrix_state_##n(read_state, i, o, \ + gpio_pin_get(in_dev, in_cfg->pin) > 0); \ + } \ + gpio_pin_set(out_dev, out_cfg->pin, 0); \ + } \ + /* Set all our outputs as active again, then re-enable interrupts, */ \ + /* so we can trigger interrupts again for future press/release */ \ + kscan_gpio_set_output_state_##n(dev, 1); \ + kscan_gpio_enable_interrupts_##n(dev); \ + for (int r = 0; r < INST_MATRIX_ROWS(n); r++) { \ + for (int c = 0; c < INST_MATRIX_COLS(n); c++) { \ + bool pressed = read_state[r][c]; \ + /* Follow up reads needed because further interrupts won't fire on already tripped \ + * input GPIO pins */ \ + submit_follow_up_read = (submit_follow_up_read || pressed); \ + if (pressed != data->matrix_state[r][c]) { \ + LOG_DBG("Sending event at %d,%d state %s", r, c, (pressed ? "on" : "off")); \ + data->matrix_state[r][c] = pressed; \ + data->callback(dev, r, c, pressed); \ + } \ + } \ + } \ + if (submit_follow_up_read) { \ + COND_CODE_0(DT_INST_PROP(n, debounce_period), ({ k_work_submit(&data->work); }), ({ \ + k_delayed_work_cancel(&data->work); \ + k_delayed_work_submit(&data->work, K_MSEC(5)); \ + })) \ + } \ + return 0; \ + } \ + static void kscan_gpio_work_handler_##n(struct k_work *work) { \ + struct kscan_gpio_data_##n *data = CONTAINER_OF(work, struct kscan_gpio_data_##n, work); \ + kscan_gpio_read_##n(data->dev); \ + } \ + static void kscan_gpio_irq_callback_handler_##n(struct device *dev, struct gpio_callback *cb, \ + gpio_port_pins_t pin) { \ + struct kscan_gpio_irq_callback_##n *data = \ + CONTAINER_OF(cb, struct kscan_gpio_irq_callback_##n, callback); \ + COND_CODE_0(DT_INST_PROP(n, debounce_period), ({ k_work_submit(data->work); }), ({ \ + k_delayed_work_cancel(data->work); \ + k_delayed_work_submit(data->work, \ + K_MSEC(DT_INST_PROP(n, debounce_period))); \ + })) \ + } \ + static struct kscan_gpio_data_##n kscan_gpio_data_##n = { \ + .rows = {[INST_MATRIX_ROWS(n) - 1] = NULL}, .cols = {[INST_MATRIX_COLS(n) - 1] = NULL}}; \ + static int kscan_gpio_configure_##n(struct device *dev, kscan_callback_t callback) { \ + struct kscan_gpio_data_##n *data = dev->driver_data; \ + if (!callback) { \ + return -EINVAL; \ + } \ + data->callback = callback; \ + return 0; \ + }; \ + static int kscan_gpio_enable_##n(struct device *dev) { \ + int err = kscan_gpio_enable_interrupts_##n(dev); \ + if (err) { \ + return err; \ + } \ + return kscan_gpio_read_##n(dev); \ + }; \ + static int kscan_gpio_init_##n(struct device *dev) { \ + struct kscan_gpio_data_##n *data = dev->driver_data; \ + int err; \ + struct device **input_devices = kscan_gpio_input_devices_##n(dev); \ + for (int i = 0; i < INST_INPUT_LEN(n); i++) { \ + const struct kscan_gpio_item_config *in_cfg = &kscan_gpio_input_configs_##n(dev)[i]; \ + input_devices[i] = device_get_binding(in_cfg->label); \ + if (!input_devices[i]) { \ + LOG_ERR("Unable to find input GPIO device"); \ + return -EINVAL; \ + } \ + err = gpio_pin_configure(input_devices[i], in_cfg->pin, GPIO_INPUT | in_cfg->flags); \ + if (err) { \ + LOG_ERR("Unable to configure pin %d on %s for input", in_cfg->pin, in_cfg->label); \ + return err; \ + } \ + irq_callbacks_##n[i].work = &data->work; \ + gpio_init_callback(&irq_callbacks_##n[i].callback, \ + kscan_gpio_irq_callback_handler_##n, BIT(in_cfg->pin)); \ + err = gpio_add_callback(input_devices[i], &irq_callbacks_##n[i].callback); \ + if (err) { \ + LOG_ERR("Error adding the callback to the column device"); \ + return err; \ + } \ + } \ + struct device **output_devices = kscan_gpio_output_devices_##n(dev); \ + for (int o = 0; o < INST_OUTPUT_LEN(n); o++) { \ + const struct kscan_gpio_item_config *out_cfg = &kscan_gpio_output_configs_##n(dev)[o]; \ + output_devices[o] = device_get_binding(out_cfg->label); \ + if (!output_devices[o]) { \ + LOG_ERR("Unable to find output GPIO device"); \ + return -EINVAL; \ + } \ + err = gpio_pin_configure(output_devices[o], out_cfg->pin, \ + GPIO_OUTPUT_ACTIVE | out_cfg->flags); \ + if (err) { \ + LOG_ERR("Unable to configure pin %d on %s for output", out_cfg->pin, \ + out_cfg->label); \ + return err; \ + } \ + } \ + data->dev = dev; \ + (COND_CODE_0(DT_INST_PROP(n, debounce_period), (k_work_init), (k_delayed_work_init)))( \ + &data->work, kscan_gpio_work_handler_##n); \ + return 0; \ + } \ + static const struct kscan_driver_api gpio_driver_api_##n = { \ + .config = kscan_gpio_configure_##n, \ + .enable_callback = kscan_gpio_enable_##n, \ + .disable_callback = kscan_gpio_disable_interrupts_##n, \ + }; \ + static const struct kscan_gpio_config_##n kscan_gpio_config_##n = { \ + .rows = {UTIL_LISTIFY(INST_MATRIX_ROWS(n), _KSCAN_GPIO_ROW_CFG_INIT, n)}, \ + .cols = {UTIL_LISTIFY(INST_MATRIX_COLS(n), _KSCAN_GPIO_COL_CFG_INIT, n)}, \ + }; \ + DEVICE_AND_API_INIT(kscan_gpio_##n, DT_INST_LABEL(n), kscan_gpio_init_##n, \ + &kscan_gpio_data_##n, &kscan_gpio_config_##n, APPLICATION, \ + CONFIG_APPLICATION_INIT_PRIORITY, &gpio_driver_api_##n); DT_INST_FOREACH_STATUS_OKAY(GPIO_INST_INIT) diff --git a/app/include/drivers/behavior.h b/app/include/drivers/behavior.h index 617b5ab..45b8bea 100644 --- a/app/include/drivers/behavior.h +++ b/app/include/drivers/behavior.h @@ -19,19 +19,20 @@ * (Internal use only.) */ -typedef int (*behavior_keymap_binding_callback_t)(struct device *dev, u32_t position, u32_t param1, u32_t param2); -typedef int (*behavior_sensor_keymap_binding_callback_t)(struct device *dev, struct device *sensor, u32_t param1, u32_t param2); +typedef int (*behavior_keymap_binding_callback_t)(struct device *dev, u32_t position, u32_t param1, + u32_t param2); +typedef int (*behavior_sensor_keymap_binding_callback_t)(struct device *dev, struct device *sensor, + u32_t param1, u32_t param2); __subsystem struct behavior_driver_api { - behavior_keymap_binding_callback_t binding_pressed; - behavior_keymap_binding_callback_t binding_released; - behavior_sensor_keymap_binding_callback_t sensor_binding_triggered; + behavior_keymap_binding_callback_t binding_pressed; + behavior_keymap_binding_callback_t binding_released; + behavior_sensor_keymap_binding_callback_t sensor_binding_triggered; }; /** * @endcond */ - /** * @brief Handle the keymap binding being pressed * @param dev Pointer to the device structure for the driver instance. @@ -41,18 +42,18 @@ __subsystem struct behavior_driver_api { * @retval 0 If successful. * @retval Negative errno code if failure. */ -__syscall int behavior_keymap_binding_pressed(struct device *dev, u32_t position, u32_t param1, u32_t param2); +__syscall int behavior_keymap_binding_pressed(struct device *dev, u32_t position, u32_t param1, + u32_t param2); -static inline int z_impl_behavior_keymap_binding_pressed(struct device *dev, u32_t position, u32_t param1, u32_t param2) -{ - const struct behavior_driver_api *api = - (const struct behavior_driver_api *)dev->driver_api; +static inline int z_impl_behavior_keymap_binding_pressed(struct device *dev, u32_t position, + u32_t param1, u32_t param2) { + const struct behavior_driver_api *api = (const struct behavior_driver_api *)dev->driver_api; - if (api->binding_pressed == NULL) { - return -ENOTSUP; - } + if (api->binding_pressed == NULL) { + return -ENOTSUP; + } - return api->binding_pressed(dev, position, param1, param2); + return api->binding_pressed(dev, position, param1, param2); } /** @@ -63,18 +64,18 @@ static inline int z_impl_behavior_keymap_binding_pressed(struct device *dev, u32 * @retval 0 If successful. * @retval Negative errno code if failure. */ -__syscall int behavior_keymap_binding_released(struct device *dev, u32_t position, u32_t param1, u32_t param2); +__syscall int behavior_keymap_binding_released(struct device *dev, u32_t position, u32_t param1, + u32_t param2); -static inline int z_impl_behavior_keymap_binding_released(struct device *dev, u32_t position, u32_t param1, u32_t param2) -{ - const struct behavior_driver_api *api = - (const struct behavior_driver_api *)dev->driver_api; +static inline int z_impl_behavior_keymap_binding_released(struct device *dev, u32_t position, + u32_t param1, u32_t param2) { + const struct behavior_driver_api *api = (const struct behavior_driver_api *)dev->driver_api; - if (api->binding_released == NULL) { - return -ENOTSUP; - } + if (api->binding_released == NULL) { + return -ENOTSUP; + } - return api->binding_released(dev, position, param1, param2); + return api->binding_released(dev, position, param1, param2); } /** @@ -87,21 +88,21 @@ static inline int z_impl_behavior_keymap_binding_released(struct device *dev, u3 * @retval 0 If successful. * @retval Negative errno code if failure. */ -__syscall int behavior_sensor_keymap_binding_triggered(struct device *dev, struct device *sensor, u32_t param1, u32_t param2); +__syscall int behavior_sensor_keymap_binding_triggered(struct device *dev, struct device *sensor, + u32_t param1, u32_t param2); -static inline int z_impl_behavior_sensor_keymap_binding_triggered(struct device *dev, struct device *sensor, u32_t param1, u32_t param2) -{ - const struct behavior_driver_api *api = - (const struct behavior_driver_api *)dev->driver_api; +static inline int z_impl_behavior_sensor_keymap_binding_triggered(struct device *dev, + struct device *sensor, + u32_t param1, u32_t param2) { + const struct behavior_driver_api *api = (const struct behavior_driver_api *)dev->driver_api; - if (api->sensor_binding_triggered == NULL) { - return -ENOTSUP; - } + if (api->sensor_binding_triggered == NULL) { + return -ENOTSUP; + } - return api->sensor_binding_triggered(dev, sensor, param1, param2); + return api->sensor_binding_triggered(dev, sensor, param1, param2); } - /** * @} */ diff --git a/app/include/dt-bindings/zmk/bt.h b/app/include/dt-bindings/zmk/bt.h index bf8b4f5..05fd65c 100644 --- a/app/include/dt-bindings/zmk/bt.h +++ b/app/include/dt-bindings/zmk/bt.h @@ -4,10 +4,10 @@ * SPDX-License-Identifier: MIT */ -#define BT_CLR_CMD 0 -#define BT_NXT_CMD 1 -#define BT_PRV_CMD 2 -#define BT_SEL_CMD 3 +#define BT_CLR_CMD 0 +#define BT_NXT_CMD 1 +#define BT_PRV_CMD 2 +#define BT_SEL_CMD 3 // #define BT_FULL_RESET_CMD 4 /* @@ -15,7 +15,7 @@ Note: Some future commands will include additional parameters, so we defines these aliases up front. */ -#define BT_CLR BT_CLR_CMD 0 -#define BT_NXT BT_NXT_CMD 0 -#define BT_PRV BT_PRV_CMD 0 -#define BT_SEL BT_SEL_CMD \ No newline at end of file +#define BT_CLR BT_CLR_CMD 0 +#define BT_NXT BT_NXT_CMD 0 +#define BT_PRV BT_PRV_CMD 0 +#define BT_SEL BT_SEL_CMD \ No newline at end of file diff --git a/app/include/dt-bindings/zmk/keys.h b/app/include/dt-bindings/zmk/keys.h index cd9261d..d3dd634 100644 --- a/app/include/dt-bindings/zmk/keys.h +++ b/app/include/dt-bindings/zmk/keys.h @@ -55,7 +55,7 @@ #define QUOT 0x34 #define GRAV 0x35 #define CMMA 0x36 -#define DOT 0x37 +#define DOT 0x37 #define FSLH 0x38 #define CLCK 0x39 #define F1 0x3A @@ -77,8 +77,8 @@ #define INS 0x49 #define HOME 0x4A #define PGUP 0x4B -#define DEL 0x4C -#define END 0x4D +#define DEL 0x4C +#define END 0x4D #define PGDN 0x4E #define RARW 0x4F #define LARW 0x50 diff --git a/app/include/dt-bindings/zmk/reset.h b/app/include/dt-bindings/zmk/reset.h index 683f965..2b3d876 100644 --- a/app/include/dt-bindings/zmk/reset.h +++ b/app/include/dt-bindings/zmk/reset.h @@ -4,9 +4,10 @@ * SPDX-License-Identifier: MIT */ -#define RST_WARM 0x00 -#define RST_COLD 0x01 +#define RST_WARM 0x00 +#define RST_COLD 0x01 -// AdaFruit nrf52 Bootloader Specific. See https://github.com/adafruit/Adafruit_nRF52_Bootloader/blob/d6b28e66053eea467166f44875e3c7ec741cb471/src/main.c#L107 +// AdaFruit nrf52 Bootloader Specific. See +// https://github.com/adafruit/Adafruit_nRF52_Bootloader/blob/d6b28e66053eea467166f44875e3c7ec741cb471/src/main.c#L107 -#define RST_UF2 0x57 \ No newline at end of file +#define RST_UF2 0x57 \ No newline at end of file diff --git a/app/include/zmk/event-manager.h b/app/include/zmk/event-manager.h index 9da6602..4b8f72c 100644 --- a/app/include/zmk/event-manager.h +++ b/app/include/zmk/event-manager.h @@ -3,20 +3,19 @@ * * SPDX-License-Identifier: MIT */ - + #pragma once #include #include #include -struct zmk_event_type -{ +struct zmk_event_type { const char *name; }; struct zmk_event_header { - const struct zmk_event_type* event; + const struct zmk_event_type *event; u8_t last_listener_index; }; @@ -24,8 +23,7 @@ struct zmk_event_header { #define ZMK_EV_EVENT_CAPTURED 2 typedef int (*zmk_listener_callback_t)(const struct zmk_event_header *eh); -struct zmk_listener -{ +struct zmk_listener { zmk_listener_callback_t callback; }; @@ -34,55 +32,50 @@ struct zmk_event_subscription { const struct zmk_listener *listener; }; -#define ZMK_EVENT_DECLARE(event_type) \ - struct event_type* new_##event_type(); \ - bool is_##event_type(const struct zmk_event_header *eh); \ - struct event_type* cast_##event_type(const struct zmk_event_header *eh); \ +#define ZMK_EVENT_DECLARE(event_type) \ + struct event_type *new_##event_type(); \ + bool is_##event_type(const struct zmk_event_header *eh); \ + struct event_type *cast_##event_type(const struct zmk_event_header *eh); \ extern const struct zmk_event_type zmk_event_##event_type; -#define ZMK_EVENT_IMPL(event_type) \ - const struct zmk_event_type zmk_event_##event_type = { \ - .name = STRINGIFY(event_type) \ - }; \ - const struct zmk_event_type* zmk_event_ref_##event_type __used __attribute__((__section__(".event_type"))) = &zmk_event_##event_type; \ - struct event_type* new_##event_type() { \ - struct event_type* ev = (struct event_type *) k_malloc(sizeof(struct event_type)); \ - ev->header.event = &zmk_event_##event_type; \ - return ev; \ - }; \ - bool is_##event_type(const struct zmk_event_header *eh) { \ - return eh->event == &zmk_event_##event_type; \ - }; \ - struct event_type* cast_##event_type(const struct zmk_event_header *eh) {\ - return (struct event_type*)eh; \ +#define ZMK_EVENT_IMPL(event_type) \ + const struct zmk_event_type zmk_event_##event_type = {.name = STRINGIFY(event_type)}; \ + const struct zmk_event_type *zmk_event_ref_##event_type __used \ + __attribute__((__section__(".event_type"))) = &zmk_event_##event_type; \ + struct event_type *new_##event_type() { \ + struct event_type *ev = (struct event_type *)k_malloc(sizeof(struct event_type)); \ + ev->header.event = &zmk_event_##event_type; \ + return ev; \ + }; \ + bool is_##event_type(const struct zmk_event_header *eh) { \ + return eh->event == &zmk_event_##event_type; \ + }; \ + struct event_type *cast_##event_type(const struct zmk_event_header *eh) { \ + return (struct event_type *)eh; \ }; - -#define ZMK_LISTENER(mod, cb) \ - const struct zmk_listener zmk_listener_##mod = { \ - .callback = cb \ - }; +#define ZMK_LISTENER(mod, cb) const struct zmk_listener zmk_listener_##mod = {.callback = cb}; -#define ZMK_SUBSCRIPTION(mod, ev_type) \ - const Z_DECL_ALIGN(struct zmk_event_subscription) _CONCAT(_CONCAT(zmk_event_sub_,mod),ev_type) __used __attribute__((__section__(".event_subscription"))) = { \ - .event_type = &zmk_event_##ev_type, \ - .listener = &zmk_listener_##mod, \ +#define ZMK_SUBSCRIPTION(mod, ev_type) \ + const Z_DECL_ALIGN(struct zmk_event_subscription) \ + _CONCAT(_CONCAT(zmk_event_sub_, mod), ev_type) __used \ + __attribute__((__section__(".event_subscription"))) = { \ + .event_type = &zmk_event_##ev_type, \ + .listener = &zmk_listener_##mod, \ }; -#define ZMK_EVENT_RAISE(ev) \ - zmk_event_manager_raise((struct zmk_event_header *)ev); +#define ZMK_EVENT_RAISE(ev) zmk_event_manager_raise((struct zmk_event_header *)ev); -#define ZMK_EVENT_RAISE_AFTER(ev, mod) \ +#define ZMK_EVENT_RAISE_AFTER(ev, mod) \ zmk_event_manager_raise_after((struct zmk_event_header *)ev, &zmk_listener_##mod); - -#define ZMK_EVENT_RAISE_AT(ev, mod) \ +#define ZMK_EVENT_RAISE_AT(ev, mod) \ zmk_event_manager_raise_at((struct zmk_event_header *)ev, &zmk_listener_##mod); -#define ZMK_EVENT_RELEASE(ev) \ - zmk_event_manager_release((struct zmk_event_header *)ev); +#define ZMK_EVENT_RELEASE(ev) zmk_event_manager_release((struct zmk_event_header *)ev); int zmk_event_manager_raise(struct zmk_event_header *event); -int zmk_event_manager_raise_after(struct zmk_event_header *event, const struct zmk_listener *listener); +int zmk_event_manager_raise_after(struct zmk_event_header *event, + const struct zmk_listener *listener); int zmk_event_manager_raise_at(struct zmk_event_header *event, const struct zmk_listener *listener); int zmk_event_manager_release(struct zmk_event_header *event); diff --git a/app/include/zmk/events/ble-active-profile-changed.h b/app/include/zmk/events/ble-active-profile-changed.h index c464236..66f40c7 100644 --- a/app/include/zmk/events/ble-active-profile-changed.h +++ b/app/include/zmk/events/ble-active-profile-changed.h @@ -12,7 +12,6 @@ #include - struct ble_active_profile_changed { struct zmk_event_header header; u8_t index; diff --git a/app/include/zmk/events/keycode-state-changed.h b/app/include/zmk/events/keycode-state-changed.h index fc37946..4c00654 100644 --- a/app/include/zmk/events/keycode-state-changed.h +++ b/app/include/zmk/events/keycode-state-changed.h @@ -18,9 +18,9 @@ struct keycode_state_changed { ZMK_EVENT_DECLARE(keycode_state_changed); -inline struct keycode_state_changed* create_keycode_state_changed(u8_t usage_page, u32_t keycode, bool state) -{ - struct keycode_state_changed* ev = new_keycode_state_changed(); +inline struct keycode_state_changed *create_keycode_state_changed(u8_t usage_page, u32_t keycode, + bool state) { + struct keycode_state_changed *ev = new_keycode_state_changed(); ev->usage_page = usage_page; ev->keycode = keycode; ev->state = state; diff --git a/app/include/zmk/events/modifiers-state-changed.h b/app/include/zmk/events/modifiers-state-changed.h index b39e11e..d2e02f8 100644 --- a/app/include/zmk/events/modifiers-state-changed.h +++ b/app/include/zmk/events/modifiers-state-changed.h @@ -3,7 +3,7 @@ * * SPDX-License-Identifier: MIT */ - + #pragma once #include @@ -18,9 +18,9 @@ struct modifiers_state_changed { ZMK_EVENT_DECLARE(modifiers_state_changed); -inline struct modifiers_state_changed* create_modifiers_state_changed(zmk_mod_flags modifiers, bool state) -{ - struct modifiers_state_changed* ev = new_modifiers_state_changed(); +inline struct modifiers_state_changed *create_modifiers_state_changed(zmk_mod_flags modifiers, + bool state) { + struct modifiers_state_changed *ev = new_modifiers_state_changed(); ev->modifiers = modifiers; ev->state = state; diff --git a/app/include/zmk/hid.h b/app/include/zmk/hid.h index a945e72..744de98 100644 --- a/app/include/zmk/hid.h +++ b/app/include/zmk/hid.h @@ -140,25 +140,21 @@ static const u8_t zmk_hid_report_desc[] = { // u8_t keys[6]; // } __packed; -struct zmk_hid_keypad_report_body -{ +struct zmk_hid_keypad_report_body { zmk_mod_flags modifiers; u8_t keys[13]; } __packed; -struct zmk_hid_keypad_report -{ +struct zmk_hid_keypad_report { u8_t report_id; struct zmk_hid_keypad_report_body body; } __packed; -struct zmk_hid_consumer_report_body -{ +struct zmk_hid_consumer_report_body { u8_t keys[6]; } __packed; -struct zmk_hid_consumer_report -{ +struct zmk_hid_consumer_report { u8_t report_id; struct zmk_hid_consumer_report_body body; } __packed; diff --git a/app/include/zmk/keys.h b/app/include/zmk/keys.h index ee9c3d9..af474b1 100644 --- a/app/include/zmk/keys.h +++ b/app/include/zmk/keys.h @@ -14,8 +14,7 @@ typedef u8_t zmk_action; typedef u8_t zmk_mod; typedef u8_t zmk_mod_flags; -struct zmk_key_event -{ +struct zmk_key_event { u32_t column; u32_t row; zmk_key key; diff --git a/app/include/zmk/matrix.h b/app/include/zmk/matrix.h index 1614317..b3e2323 100644 --- a/app/include/zmk/matrix.h +++ b/app/include/zmk/matrix.h @@ -15,20 +15,20 @@ #define ZMK_KEYMAP_TRANSFORM_NODE DT_CHOSEN(zmk_matrix_transform) #define ZMK_KEYMAP_LEN DT_PROP_LEN(ZMK_KEYMAP_TRANSFORM_NODE, map) -#define ZMK_MATRIX_ROWS DT_PROP(ZMK_KEYMAP_TRANSFORM_NODE,rows) -#define ZMK_MATRIX_COLS DT_PROP(ZMK_KEYMAP_TRANSFORM_NODE,columns) +#define ZMK_MATRIX_ROWS DT_PROP(ZMK_KEYMAP_TRANSFORM_NODE, rows) +#define ZMK_MATRIX_COLS DT_PROP(ZMK_KEYMAP_TRANSFORM_NODE, columns) #else /* DT_HAS_CHOSEN(zmk_matrix_transform) */ -#if DT_NODE_HAS_PROP(ZMK_MATRIX_NODE_ID,row_gpios) -#define ZMK_MATRIX_ROWS DT_PROP_LEN(ZMK_MATRIX_NODE_ID,row_gpios) -#define ZMK_MATRIX_COLS DT_PROP_LEN(ZMK_MATRIX_NODE_ID,col_gpios) -#elif DT_NODE_HAS_PROP(ZMK_MATRIX_NODE_ID,input_gpios) +#if DT_NODE_HAS_PROP(ZMK_MATRIX_NODE_ID, row_gpios) +#define ZMK_MATRIX_ROWS DT_PROP_LEN(ZMK_MATRIX_NODE_ID, row_gpios) +#define ZMK_MATRIX_COLS DT_PROP_LEN(ZMK_MATRIX_NODE_ID, col_gpios) +#elif DT_NODE_HAS_PROP(ZMK_MATRIX_NODE_ID, input_gpios) #define ZMK_MATRIX_ROWS 1 -#define ZMK_MATRIX_COLS DT_PROP_LEN(ZMK_MATRIX_NODE_ID,input_gpios) +#define ZMK_MATRIX_COLS DT_PROP_LEN(ZMK_MATRIX_NODE_ID, input_gpios) #else -#define ZMK_MATRIX_ROWS DT_PROP(ZMK_MATRIX_NODE_ID,rows) -#define ZMK_MATRIX_COLS DT_PROP(ZMK_MATRIX_NODE_ID,columns) +#define ZMK_MATRIX_ROWS DT_PROP(ZMK_MATRIX_NODE_ID, rows) +#define ZMK_MATRIX_COLS DT_PROP(ZMK_MATRIX_NODE_ID, columns) #endif #define ZMK_KEYMAP_LEN (ZMK_MATRIX_COLS * ZMK_MATRIX_ROWS) diff --git a/app/include/zmk/split/bluetooth/uuid.h b/app/include/zmk/split/bluetooth/uuid.h index 59f2f71..a8dfbf6 100644 --- a/app/include/zmk/split/bluetooth/uuid.h +++ b/app/include/zmk/split/bluetooth/uuid.h @@ -3,10 +3,9 @@ #include #ifndef BT_UUID_NUM_OF_DIGITALS -#define BT_UUID_NUM_OF_DIGITALS BT_UUID_DECLARE_16(0x2909) +#define BT_UUID_NUM_OF_DIGITALS BT_UUID_DECLARE_16(0x2909) #endif -#define ZMK_BT_SPLIT_UUID(num) BT_UUID_128_ENCODE(num, 0x0096, 0x7107, 0xc967, 0xc5cfb1c2482a) +#define ZMK_BT_SPLIT_UUID(num) BT_UUID_128_ENCODE(num, 0x0096, 0x7107, 0xc967, 0xc5cfb1c2482a) #define ZMK_SPLIT_BT_SERVICE_UUID ZMK_BT_SPLIT_UUID(0x00000000) #define ZMK_SPLIT_BT_CHAR_POSITION_STATE_UUID ZMK_BT_SPLIT_UUID(0x00000001) - diff --git a/app/src/behaviors/behavior_bt.c b/app/src/behaviors/behavior_bt.c index 3a5fbfb..09fadba 100644 --- a/app/src/behaviors/behavior_bt.c +++ b/app/src/behaviors/behavior_bt.c @@ -18,10 +18,8 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); #include -static int on_keymap_binding_pressed(struct device *dev, u32_t position, u32_t command, u32_t arg) -{ - switch (command) - { +static int on_keymap_binding_pressed(struct device *dev, u32_t position, u32_t command, u32_t arg) { + switch (command) { case BT_CLR_CMD: return zmk_ble_clear_bonds(); case BT_NXT_CMD: @@ -37,13 +35,10 @@ static int on_keymap_binding_pressed(struct device *dev, u32_t position, u32_t c return -ENOTSUP; } -static int behavior_bt_init(struct device *dev) -{ - return 0; -}; +static int behavior_bt_init(struct device *dev) { return 0; }; -static int on_keymap_binding_released(struct device *dev, u32_t position, u32_t command, u32_t arg) -{ +static int on_keymap_binding_released(struct device *dev, u32_t position, u32_t command, + u32_t arg) { return 0; } @@ -52,9 +47,5 @@ static const struct behavior_driver_api behavior_bt_driver_api = { .binding_released = on_keymap_binding_released, }; -DEVICE_AND_API_INIT(behavior_bt, DT_INST_LABEL(0), - behavior_bt_init, - NULL, - NULL, - APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, - &behavior_bt_driver_api); +DEVICE_AND_API_INIT(behavior_bt, DT_INST_LABEL(0), behavior_bt_init, NULL, NULL, APPLICATION, + CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &behavior_bt_driver_api); diff --git a/app/src/behaviors/behavior_hold_tap.c b/app/src/behaviors/behavior_hold_tap.c index dce724d..8f307a6 100644 --- a/app/src/behaviors/behavior_hold_tap.c +++ b/app/src/behaviors/behavior_hold_tap.c @@ -29,36 +29,35 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); // increase if you have keyboard with more keys. #define ZMK_BHV_HOLD_TAP_POSITION_NOT_USED 9999 - enum flavor { - ZMK_BHV_HOLD_TAP_FLAVOR_HOLD_PREFERRED = 0, - ZMK_BHV_HOLD_TAP_FLAVOR_BALANCED = 1, - ZMK_BHV_HOLD_TAP_FLAVOR_TAP_PREFERRED = 2, + ZMK_BHV_HOLD_TAP_FLAVOR_HOLD_PREFERRED = 0, + ZMK_BHV_HOLD_TAP_FLAVOR_BALANCED = 1, + ZMK_BHV_HOLD_TAP_FLAVOR_TAP_PREFERRED = 2, }; struct behavior_hold_tap_behaviors { - struct zmk_behavior_binding tap; - struct zmk_behavior_binding hold; + struct zmk_behavior_binding tap; + struct zmk_behavior_binding hold; }; typedef k_timeout_t (*timer_func)(); struct behavior_hold_tap_config { - timer_func tapping_term_ms; - struct behavior_hold_tap_behaviors *behaviors; - enum flavor flavor; + timer_func tapping_term_ms; + struct behavior_hold_tap_behaviors *behaviors; + enum flavor flavor; }; // this data is specific for each hold-tap struct active_hold_tap { - s32_t position; - u32_t param_hold; - u32_t param_tap; - bool is_decided; - bool is_hold; - const struct behavior_hold_tap_config *config; - struct k_delayed_work work; - bool work_is_cancelled; + s32_t position; + u32_t param_hold; + u32_t param_tap; + bool is_decided; + bool is_hold; + const struct behavior_hold_tap_config *config; + struct k_delayed_work work; + bool work_is_cancelled; }; // The undecided hold tap is the hold tap that needs to be decided before @@ -71,371 +70,366 @@ struct active_hold_tap active_hold_taps[ZMK_BHV_HOLD_TAP_MAX_HELD] = {}; // We capture most position_state_changed events and some modifiers_state_changed events. const struct zmk_event_header *captured_events[ZMK_BHV_HOLD_TAP_MAX_CAPTURED_EVENTS] = {}; -static int capture_event(const struct zmk_event_header *event) -{ - for (int i = 0; i < ZMK_BHV_HOLD_TAP_MAX_CAPTURED_EVENTS; i++) { - if (captured_events[i] == NULL) { - captured_events[i] = event; - return 0; - } - } - return -ENOMEM; +static int capture_event(const struct zmk_event_header *event) { + for (int i = 0; i < ZMK_BHV_HOLD_TAP_MAX_CAPTURED_EVENTS; i++) { + if (captured_events[i] == NULL) { + captured_events[i] = event; + return 0; + } + } + return -ENOMEM; } -static struct position_state_changed *find_captured_keydown_event(u32_t position) -{ - struct position_state_changed *last_match = NULL; - for (int i = 0; i < ZMK_BHV_HOLD_TAP_MAX_CAPTURED_EVENTS; i++) { - const struct zmk_event_header *eh = captured_events[i]; - if (eh == NULL) { - return last_match; - } - if (!is_position_state_changed(eh)) { - continue; - } - struct position_state_changed *position_event = cast_position_state_changed(eh); - if (position_event->position == position && position_event->state) { - last_match = position_event; - } - } - return last_match; +static struct position_state_changed *find_captured_keydown_event(u32_t position) { + struct position_state_changed *last_match = NULL; + for (int i = 0; i < ZMK_BHV_HOLD_TAP_MAX_CAPTURED_EVENTS; i++) { + const struct zmk_event_header *eh = captured_events[i]; + if (eh == NULL) { + return last_match; + } + if (!is_position_state_changed(eh)) { + continue; + } + struct position_state_changed *position_event = cast_position_state_changed(eh); + if (position_event->position == position && position_event->state) { + last_match = position_event; + } + } + return last_match; } const struct zmk_listener zmk_listener_behavior_hold_tap; -static void release_captured_events() -{ - if (undecided_hold_tap != NULL) { - return; - } - - // We use a trick to prevent copying the captured_events array. - // - // Events for different mod-tap instances are separated by a NULL pointer. - // - // The first event popped will never be catched by the next active hold-tap - // because to start capturing a mod-tap-key-down event must first completely - // go through the events queue. - // - // Example of this release process; - // [mt2_down, k1_down, k1_up, mt2_up, null, ...] - // ^ - // mt2_down position event isn't captured because no hold-tap is active. - // mt2_down behavior event is handled, now we have an undecided hold-tap - // [null, k1_down, k1_up, mt2_up, null, ...] - // ^ - // k1_down is captured by the mt2 mod-tap - // !note that searches for find_captured_keydown_event by the mt2 behavior will stop at the first null encountered - // [mt1_down, null, k1_up, mt2_up, null, ...] - // ^ - // k1_up event is captured by the new hold-tap: - // [k1_down, k1_up, null, mt2_up, null, ...] - // ^ - // mt2_up event is not captured but causes release of mt2 behavior - // [k1_down, k1_up, null, null, null, ...] - // now mt2 will start releasing it's own captured positions. - for (int i = 0; i < ZMK_BHV_HOLD_TAP_MAX_CAPTURED_EVENTS; i++) { - const struct zmk_event_header *captured_event = captured_events[i]; - if (captured_event == NULL) { - return; - } - captured_events[i] = NULL; - if (undecided_hold_tap != NULL) { - k_msleep(10); - } - if (is_position_state_changed(captured_event)) { - struct position_state_changed *position_event = cast_position_state_changed(captured_event); - LOG_DBG("Releasing key position event for position %d %s", position_event->position, (position_event->state ? "pressed" : "released")); - } else { - struct keycode_state_changed *modifier_event = cast_keycode_state_changed(captured_event); - LOG_DBG("Releasing mods changed event 0x%02X %s", modifier_event->keycode, (modifier_event->state ? "pressed" : "released")); - } - ZMK_EVENT_RAISE_AT(captured_event, behavior_hold_tap); - } +static void release_captured_events() { + if (undecided_hold_tap != NULL) { + return; + } + + // We use a trick to prevent copying the captured_events array. + // + // Events for different mod-tap instances are separated by a NULL pointer. + // + // The first event popped will never be catched by the next active hold-tap + // because to start capturing a mod-tap-key-down event must first completely + // go through the events queue. + // + // Example of this release process; + // [mt2_down, k1_down, k1_up, mt2_up, null, ...] + // ^ + // mt2_down position event isn't captured because no hold-tap is active. + // mt2_down behavior event is handled, now we have an undecided hold-tap + // [null, k1_down, k1_up, mt2_up, null, ...] + // ^ + // k1_down is captured by the mt2 mod-tap + // !note that searches for find_captured_keydown_event by the mt2 behavior will stop at the + // first null encountered [mt1_down, null, k1_up, mt2_up, null, ...] + // ^ + // k1_up event is captured by the new hold-tap: + // [k1_down, k1_up, null, mt2_up, null, ...] + // ^ + // mt2_up event is not captured but causes release of mt2 behavior + // [k1_down, k1_up, null, null, null, ...] + // now mt2 will start releasing it's own captured positions. + for (int i = 0; i < ZMK_BHV_HOLD_TAP_MAX_CAPTURED_EVENTS; i++) { + const struct zmk_event_header *captured_event = captured_events[i]; + if (captured_event == NULL) { + return; + } + captured_events[i] = NULL; + if (undecided_hold_tap != NULL) { + k_msleep(10); + } + if (is_position_state_changed(captured_event)) { + struct position_state_changed *position_event = + cast_position_state_changed(captured_event); + LOG_DBG("Releasing key position event for position %d %s", position_event->position, + (position_event->state ? "pressed" : "released")); + } else { + struct keycode_state_changed *modifier_event = + cast_keycode_state_changed(captured_event); + LOG_DBG("Releasing mods changed event 0x%02X %s", modifier_event->keycode, + (modifier_event->state ? "pressed" : "released")); + } + ZMK_EVENT_RAISE_AT(captured_event, behavior_hold_tap); + } } -static struct active_hold_tap *find_hold_tap(u32_t position) -{ - for (int i = 0; i < ZMK_BHV_HOLD_TAP_MAX_HELD; i++) { - if (active_hold_taps[i].position == position) { - return &active_hold_taps[i]; - } - } - return NULL; +static struct active_hold_tap *find_hold_tap(u32_t position) { + for (int i = 0; i < ZMK_BHV_HOLD_TAP_MAX_HELD; i++) { + if (active_hold_taps[i].position == position) { + return &active_hold_taps[i]; + } + } + return NULL; } -static struct active_hold_tap *store_hold_tap(u32_t position, u32_t param_hold, u32_t param_tap, const struct behavior_hold_tap_config *config) -{ - for (int i = 0; i < ZMK_BHV_HOLD_TAP_MAX_HELD; i++) { - if (active_hold_taps[i].position != ZMK_BHV_HOLD_TAP_POSITION_NOT_USED) { - continue; - } - active_hold_taps[i].position = position; - active_hold_taps[i].is_decided = false; - active_hold_taps[i].is_hold = false; - active_hold_taps[i].config = config; - active_hold_taps[i].param_hold = param_hold; - active_hold_taps[i].param_tap = param_tap; - return &active_hold_taps[i]; - } - return NULL; +static struct active_hold_tap *store_hold_tap(u32_t position, u32_t param_hold, u32_t param_tap, + const struct behavior_hold_tap_config *config) { + for (int i = 0; i < ZMK_BHV_HOLD_TAP_MAX_HELD; i++) { + if (active_hold_taps[i].position != ZMK_BHV_HOLD_TAP_POSITION_NOT_USED) { + continue; + } + active_hold_taps[i].position = position; + active_hold_taps[i].is_decided = false; + active_hold_taps[i].is_hold = false; + active_hold_taps[i].config = config; + active_hold_taps[i].param_hold = param_hold; + active_hold_taps[i].param_tap = param_tap; + return &active_hold_taps[i]; + } + return NULL; } -static void clear_hold_tap(struct active_hold_tap *hold_tap) -{ - hold_tap->position = ZMK_BHV_HOLD_TAP_POSITION_NOT_USED; - hold_tap->is_decided = false; - hold_tap->is_hold = false; - hold_tap->work_is_cancelled = false; +static void clear_hold_tap(struct active_hold_tap *hold_tap) { + hold_tap->position = ZMK_BHV_HOLD_TAP_POSITION_NOT_USED; + hold_tap->is_decided = false; + hold_tap->is_hold = false; + hold_tap->work_is_cancelled = false; } enum decision_moment { - HT_KEY_UP = 0, - HT_OTHER_KEY_DOWN = 1, - HT_OTHER_KEY_UP = 2, - HT_TIMER_EVENT = 3, + HT_KEY_UP = 0, + HT_OTHER_KEY_DOWN = 1, + HT_OTHER_KEY_UP = 2, + HT_TIMER_EVENT = 3, }; -static void decide_balanced(struct active_hold_tap *hold_tap, enum decision_moment event) -{ - switch (event) { - case HT_KEY_UP: - hold_tap->is_hold = 0; - hold_tap->is_decided = true; - break; - case HT_OTHER_KEY_UP: - case HT_TIMER_EVENT: - hold_tap->is_hold = 1; - hold_tap->is_decided = true; - break; - default: return; - } +static void decide_balanced(struct active_hold_tap *hold_tap, enum decision_moment event) { + switch (event) { + case HT_KEY_UP: + hold_tap->is_hold = 0; + hold_tap->is_decided = true; + break; + case HT_OTHER_KEY_UP: + case HT_TIMER_EVENT: + hold_tap->is_hold = 1; + hold_tap->is_decided = true; + break; + default: + return; + } } -static void decide_tap_preferred(struct active_hold_tap *hold_tap, enum decision_moment event) -{ - switch (event) { - case HT_KEY_UP: - hold_tap->is_hold = 0; - hold_tap->is_decided = true; - break; - case HT_TIMER_EVENT: - hold_tap->is_hold = 1; - hold_tap->is_decided = true; - break; - default: return; - } +static void decide_tap_preferred(struct active_hold_tap *hold_tap, enum decision_moment event) { + switch (event) { + case HT_KEY_UP: + hold_tap->is_hold = 0; + hold_tap->is_decided = true; + break; + case HT_TIMER_EVENT: + hold_tap->is_hold = 1; + hold_tap->is_decided = true; + break; + default: + return; + } } -static void decide_hold_preferred(struct active_hold_tap *hold_tap, enum decision_moment event) -{ - switch (event) { - case HT_KEY_UP: - hold_tap->is_hold = 0; - hold_tap->is_decided = true; - break; - case HT_OTHER_KEY_DOWN: - case HT_TIMER_EVENT: - hold_tap->is_hold = 1; - hold_tap->is_decided = true; - break; - default: return; - } +static void decide_hold_preferred(struct active_hold_tap *hold_tap, enum decision_moment event) { + switch (event) { + case HT_KEY_UP: + hold_tap->is_hold = 0; + hold_tap->is_decided = true; + break; + case HT_OTHER_KEY_DOWN: + case HT_TIMER_EVENT: + hold_tap->is_hold = 1; + hold_tap->is_decided = true; + break; + default: + return; + } } -static inline char* flavor_str(enum flavor flavor) { - switch(flavor) { - case ZMK_BHV_HOLD_TAP_FLAVOR_HOLD_PREFERRED: - return "hold-preferred"; - case ZMK_BHV_HOLD_TAP_FLAVOR_BALANCED: - return "balanced"; - case ZMK_BHV_HOLD_TAP_FLAVOR_TAP_PREFERRED: - return "tap-preferred"; - } - return "UNKNOWN FLAVOR"; +static inline char *flavor_str(enum flavor flavor) { + switch (flavor) { + case ZMK_BHV_HOLD_TAP_FLAVOR_HOLD_PREFERRED: + return "hold-preferred"; + case ZMK_BHV_HOLD_TAP_FLAVOR_BALANCED: + return "balanced"; + case ZMK_BHV_HOLD_TAP_FLAVOR_TAP_PREFERRED: + return "tap-preferred"; + } + return "UNKNOWN FLAVOR"; } -static void decide_hold_tap(struct active_hold_tap *hold_tap, enum decision_moment event) -{ - if (hold_tap->is_decided) { - return; - } - - if (hold_tap != undecided_hold_tap) { - LOG_DBG("ERROR found undecided tap hold that is not the active tap hold"); - return; - } - - switch(hold_tap->config->flavor) { - case ZMK_BHV_HOLD_TAP_FLAVOR_HOLD_PREFERRED: - decide_hold_preferred(hold_tap, event); - case ZMK_BHV_HOLD_TAP_FLAVOR_BALANCED: - decide_balanced(hold_tap, event); - case ZMK_BHV_HOLD_TAP_FLAVOR_TAP_PREFERRED: - decide_tap_preferred(hold_tap, event); - } - - if (!hold_tap->is_decided) { - return; - } - - LOG_DBG("%d decided %s (%s event %d)", - hold_tap->position, - hold_tap->is_hold ? "hold" : "tap", - flavor_str(hold_tap->config->flavor), - event); - undecided_hold_tap = NULL; - - struct zmk_behavior_binding *behavior; - if (hold_tap->is_hold) { - behavior = &hold_tap->config->behaviors->hold; - struct device *behavior_device = device_get_binding(behavior->behavior_dev); - behavior_keymap_binding_pressed(behavior_device, hold_tap->position, hold_tap->param_hold, 0); - } else { - behavior = &hold_tap->config->behaviors->tap; - struct device *behavior_device = device_get_binding(behavior->behavior_dev); - behavior_keymap_binding_pressed(behavior_device, hold_tap->position, hold_tap->param_tap, 0); - } - release_captured_events(); +static void decide_hold_tap(struct active_hold_tap *hold_tap, enum decision_moment event) { + if (hold_tap->is_decided) { + return; + } + + if (hold_tap != undecided_hold_tap) { + LOG_DBG("ERROR found undecided tap hold that is not the active tap hold"); + return; + } + + switch (hold_tap->config->flavor) { + case ZMK_BHV_HOLD_TAP_FLAVOR_HOLD_PREFERRED: + decide_hold_preferred(hold_tap, event); + case ZMK_BHV_HOLD_TAP_FLAVOR_BALANCED: + decide_balanced(hold_tap, event); + case ZMK_BHV_HOLD_TAP_FLAVOR_TAP_PREFERRED: + decide_tap_preferred(hold_tap, event); + } + + if (!hold_tap->is_decided) { + return; + } + + LOG_DBG("%d decided %s (%s event %d)", hold_tap->position, hold_tap->is_hold ? "hold" : "tap", + flavor_str(hold_tap->config->flavor), event); + undecided_hold_tap = NULL; + + struct zmk_behavior_binding *behavior; + if (hold_tap->is_hold) { + behavior = &hold_tap->config->behaviors->hold; + struct device *behavior_device = device_get_binding(behavior->behavior_dev); + behavior_keymap_binding_pressed(behavior_device, hold_tap->position, hold_tap->param_hold, + 0); + } else { + behavior = &hold_tap->config->behaviors->tap; + struct device *behavior_device = device_get_binding(behavior->behavior_dev); + behavior_keymap_binding_pressed(behavior_device, hold_tap->position, hold_tap->param_tap, + 0); + } + release_captured_events(); } -static int on_hold_tap_binding_pressed(struct device *dev, u32_t position, u32_t param_hold, u32_t param_tap) -{ - const struct behavior_hold_tap_config *cfg = dev->config_info; +static int on_hold_tap_binding_pressed(struct device *dev, u32_t position, u32_t param_hold, + u32_t param_tap) { + const struct behavior_hold_tap_config *cfg = dev->config_info; - if (undecided_hold_tap != NULL) { - LOG_DBG("ERROR another hold-tap behavior is undecided."); - // if this happens, make sure the behavior events occur AFTER other position events. - return 0; - } + if (undecided_hold_tap != NULL) { + LOG_DBG("ERROR another hold-tap behavior is undecided."); + // if this happens, make sure the behavior events occur AFTER other position events. + return 0; + } - struct active_hold_tap *hold_tap = store_hold_tap(position, param_hold, param_tap, cfg); - if (hold_tap == NULL) { - LOG_ERR("unable to store hold-tap info, did you press more than %d hold-taps?", ZMK_BHV_HOLD_TAP_MAX_HELD); - return 0; - } + struct active_hold_tap *hold_tap = store_hold_tap(position, param_hold, param_tap, cfg); + if (hold_tap == NULL) { + LOG_ERR("unable to store hold-tap info, did you press more than %d hold-taps?", + ZMK_BHV_HOLD_TAP_MAX_HELD); + return 0; + } - LOG_DBG("%d new undecided hold_tap", position); - undecided_hold_tap = hold_tap; - k_delayed_work_submit(&hold_tap->work, cfg->tapping_term_ms()); + LOG_DBG("%d new undecided hold_tap", position); + undecided_hold_tap = hold_tap; + k_delayed_work_submit(&hold_tap->work, cfg->tapping_term_ms()); - // todo: once we get timing info for keypresses, start the timer relative to the original keypress - // don't forget to simulate a timer-event before the event after that time was handled. + // todo: once we get timing info for keypresses, start the timer relative to the original + // keypress don't forget to simulate a timer-event before the event after that time was handled. - return 0; + return 0; } -static int on_hold_tap_binding_released(struct device *dev, u32_t position, u32_t _, u32_t __) -{ - struct active_hold_tap *hold_tap = find_hold_tap(position); - - if (hold_tap == NULL) { - LOG_ERR("ACTIVE_HOLD_TAP_CLEANED_UP_TOO_EARLY"); - return 0; - } - - int work_cancel_result = k_delayed_work_cancel(&hold_tap->work); - decide_hold_tap(hold_tap, HT_KEY_UP); - - struct zmk_behavior_binding *behavior; - if (hold_tap->is_hold) { - behavior = &hold_tap->config->behaviors->hold; - struct device *behavior_device = device_get_binding(behavior->behavior_dev); - behavior_keymap_binding_released(behavior_device, hold_tap->position, hold_tap->param_hold, 0); - } else { - behavior = &hold_tap->config->behaviors->tap; - struct device *behavior_device = device_get_binding(behavior->behavior_dev); - behavior_keymap_binding_released(behavior_device, hold_tap->position, hold_tap->param_tap, 0); - } - - - if (work_cancel_result == -EINPROGRESS) { - // let the timer handler clean up - // if we'd clear now, the timer may call back for an uninitialized active_hold_tap. - LOG_DBG("%d hold-tap timer work in event queue", position); - hold_tap->work_is_cancelled = true; - } else { - LOG_DBG("%d cleaning up hold-tap", position); - clear_hold_tap(hold_tap); - } - - return 0; +static int on_hold_tap_binding_released(struct device *dev, u32_t position, u32_t _, u32_t __) { + struct active_hold_tap *hold_tap = find_hold_tap(position); + + if (hold_tap == NULL) { + LOG_ERR("ACTIVE_HOLD_TAP_CLEANED_UP_TOO_EARLY"); + return 0; + } + + int work_cancel_result = k_delayed_work_cancel(&hold_tap->work); + decide_hold_tap(hold_tap, HT_KEY_UP); + + struct zmk_behavior_binding *behavior; + if (hold_tap->is_hold) { + behavior = &hold_tap->config->behaviors->hold; + struct device *behavior_device = device_get_binding(behavior->behavior_dev); + behavior_keymap_binding_released(behavior_device, hold_tap->position, hold_tap->param_hold, + 0); + } else { + behavior = &hold_tap->config->behaviors->tap; + struct device *behavior_device = device_get_binding(behavior->behavior_dev); + behavior_keymap_binding_released(behavior_device, hold_tap->position, hold_tap->param_tap, + 0); + } + + if (work_cancel_result == -EINPROGRESS) { + // let the timer handler clean up + // if we'd clear now, the timer may call back for an uninitialized active_hold_tap. + LOG_DBG("%d hold-tap timer work in event queue", position); + hold_tap->work_is_cancelled = true; + } else { + LOG_DBG("%d cleaning up hold-tap", position); + clear_hold_tap(hold_tap); + } + + return 0; } static const struct behavior_driver_api behavior_hold_tap_driver_api = { - .binding_pressed = on_hold_tap_binding_pressed, - .binding_released = on_hold_tap_binding_released, + .binding_pressed = on_hold_tap_binding_pressed, + .binding_released = on_hold_tap_binding_released, }; - -static int position_state_changed_listener(const struct zmk_event_header *eh) -{ - struct position_state_changed *ev = cast_position_state_changed(eh); - - if (undecided_hold_tap == NULL) { - LOG_DBG("%d bubble (no undecided hold_tap active)", ev->position); - return 0; - } - - if (undecided_hold_tap->position == ev->position) { - if (ev->state) { // keydown - LOG_ERR("hold-tap listener should be called before before most other listeners!"); - return 0; - } else { // keyup - LOG_DBG("%d bubble undecided hold-tap keyrelease event", undecided_hold_tap->position); - return 0; - } - } - - if (!ev->state && find_captured_keydown_event(ev->position) == NULL) { - // no keydown event has been captured, let it bubble. - // we'll catch modifiers later in modifier_state_changed_listener - LOG_DBG("%d bubbling %d %s event", undecided_hold_tap->position, ev->position, ev->state ? "down" : "up"); - return 0; - } - - LOG_DBG("%d capturing %d %s event", undecided_hold_tap->position, ev->position, ev->state ? "down" : "up"); - capture_event(eh); - decide_hold_tap(undecided_hold_tap, ev->state ? HT_OTHER_KEY_DOWN : HT_OTHER_KEY_UP); - return ZMK_EV_EVENT_CAPTURED; +static int position_state_changed_listener(const struct zmk_event_header *eh) { + struct position_state_changed *ev = cast_position_state_changed(eh); + + if (undecided_hold_tap == NULL) { + LOG_DBG("%d bubble (no undecided hold_tap active)", ev->position); + return 0; + } + + if (undecided_hold_tap->position == ev->position) { + if (ev->state) { // keydown + LOG_ERR("hold-tap listener should be called before before most other listeners!"); + return 0; + } else { // keyup + LOG_DBG("%d bubble undecided hold-tap keyrelease event", undecided_hold_tap->position); + return 0; + } + } + + if (!ev->state && find_captured_keydown_event(ev->position) == NULL) { + // no keydown event has been captured, let it bubble. + // we'll catch modifiers later in modifier_state_changed_listener + LOG_DBG("%d bubbling %d %s event", undecided_hold_tap->position, ev->position, + ev->state ? "down" : "up"); + return 0; + } + + LOG_DBG("%d capturing %d %s event", undecided_hold_tap->position, ev->position, + ev->state ? "down" : "up"); + capture_event(eh); + decide_hold_tap(undecided_hold_tap, ev->state ? HT_OTHER_KEY_DOWN : HT_OTHER_KEY_UP); + return ZMK_EV_EVENT_CAPTURED; } -static bool is_mod(struct keycode_state_changed *ev) -{ - return ev->usage_page == USAGE_KEYPAD && ev->keycode >= LCTL && ev->keycode <= RGUI; +static bool is_mod(struct keycode_state_changed *ev) { + return ev->usage_page == USAGE_KEYPAD && ev->keycode >= LCTL && ev->keycode <= RGUI; } -static int keycode_state_changed_listener(const struct zmk_event_header *eh) -{ - // we want to catch layer-up events too... how? - struct keycode_state_changed *ev = cast_keycode_state_changed(eh); - - if (undecided_hold_tap == NULL) { - // LOG_DBG("0x%02X bubble (no undecided hold_tap active)", ev->keycode); - return 0; - } - - if (!is_mod(ev)) { - // LOG_DBG("0x%02X bubble (not a mod)", ev->keycode); - return 0; - } - - // only key-up events will bubble through position_state_changed_listener - // if a undecided_hold_tap is active. - LOG_DBG("%d capturing 0x%02X %s event", undecided_hold_tap->position, ev->keycode, ev->state ? "down" : "up"); - capture_event(eh); - return ZMK_EV_EVENT_CAPTURED; +static int keycode_state_changed_listener(const struct zmk_event_header *eh) { + // we want to catch layer-up events too... how? + struct keycode_state_changed *ev = cast_keycode_state_changed(eh); + + if (undecided_hold_tap == NULL) { + // LOG_DBG("0x%02X bubble (no undecided hold_tap active)", ev->keycode); + return 0; + } + + if (!is_mod(ev)) { + // LOG_DBG("0x%02X bubble (not a mod)", ev->keycode); + return 0; + } + + // only key-up events will bubble through position_state_changed_listener + // if a undecided_hold_tap is active. + LOG_DBG("%d capturing 0x%02X %s event", undecided_hold_tap->position, ev->keycode, + ev->state ? "down" : "up"); + capture_event(eh); + return ZMK_EV_EVENT_CAPTURED; } - -int behavior_hold_tap_listener(const struct zmk_event_header *eh) -{ - if (is_position_state_changed(eh)) { - return position_state_changed_listener(eh); - } else if (is_keycode_state_changed(eh)) { - return keycode_state_changed_listener(eh); - } - return 0; +int behavior_hold_tap_listener(const struct zmk_event_header *eh) { + if (is_position_state_changed(eh)) { + return position_state_changed_listener(eh); + } else if (is_keycode_state_changed(eh)) { + return keycode_state_changed_listener(eh); + } + return 0; } ZMK_LISTENER(behavior_hold_tap, behavior_hold_tap_listener); @@ -443,60 +437,56 @@ ZMK_SUBSCRIPTION(behavior_hold_tap, position_state_changed); // this should be modifiers_state_changed, but unfrotunately that's not implemented yet. ZMK_SUBSCRIPTION(behavior_hold_tap, keycode_state_changed); -void behavior_hold_tap_timer_work_handler(struct k_work *item) -{ - struct active_hold_tap *hold_tap = CONTAINER_OF(item, struct active_hold_tap, work); +void behavior_hold_tap_timer_work_handler(struct k_work *item) { + struct active_hold_tap *hold_tap = CONTAINER_OF(item, struct active_hold_tap, work); - if (hold_tap->work_is_cancelled) { - clear_hold_tap(hold_tap); - } else { - decide_hold_tap(hold_tap, HT_TIMER_EVENT); - } + if (hold_tap->work_is_cancelled) { + clear_hold_tap(hold_tap); + } else { + decide_hold_tap(hold_tap, HT_TIMER_EVENT); + } } -static int behavior_hold_tap_init(struct device *dev) -{ - static bool init_first_run = true; - - if (init_first_run) { - for (int i = 0; i < ZMK_BHV_HOLD_TAP_MAX_HELD; i++) { - k_delayed_work_init(&active_hold_taps[i].work, behavior_hold_tap_timer_work_handler); - active_hold_taps[i].position = ZMK_BHV_HOLD_TAP_POSITION_NOT_USED; - } - } - init_first_run = false; - return 0; +static int behavior_hold_tap_init(struct device *dev) { + static bool init_first_run = true; + + if (init_first_run) { + for (int i = 0; i < ZMK_BHV_HOLD_TAP_MAX_HELD; i++) { + k_delayed_work_init(&active_hold_taps[i].work, behavior_hold_tap_timer_work_handler); + active_hold_taps[i].position = ZMK_BHV_HOLD_TAP_POSITION_NOT_USED; + } + } + init_first_run = false; + return 0; } struct behavior_hold_tap_data {}; static struct behavior_hold_tap_data behavior_hold_tap_data; -#define _TRANSFORM_ENTRY(idx, node) \ - { \ - .behavior_dev = DT_LABEL(DT_INST_PHANDLE_BY_IDX(node, bindings, idx)), \ - .param1 = COND_CODE_0(DT_INST_PHA_HAS_CELL_AT_IDX(node, bindings, idx, param1), (0), (DT_INST_PHA_BY_IDX(node, bindings, idx, param1))), \ - .param2 = COND_CODE_0(DT_INST_PHA_HAS_CELL_AT_IDX(node, bindings, idx, param2), (0), (DT_INST_PHA_BY_IDX(node, bindings, idx, param2))), \ - }, - -#define KP_INST(n) \ - static k_timeout_t behavior_hold_tap_config_##n##_gettime() { return K_MSEC(DT_INST_PROP(n, tapping_term_ms)); } \ - static struct behavior_hold_tap_behaviors behavior_hold_tap_behaviors_##n = { \ - .hold = _TRANSFORM_ENTRY(0, n) \ - .tap = _TRANSFORM_ENTRY(1, n) \ - }; \ - static struct behavior_hold_tap_config behavior_hold_tap_config_##n = { \ - .behaviors = &behavior_hold_tap_behaviors_##n, \ - .tapping_term_ms = &behavior_hold_tap_config_##n##_gettime, \ - .flavor = DT_ENUM_IDX(DT_DRV_INST(n), flavor), \ - }; \ - DEVICE_AND_API_INIT( \ - behavior_hold_tap_##n, DT_INST_LABEL(n), behavior_hold_tap_init, \ - &behavior_hold_tap_data, \ - &behavior_hold_tap_config_##n, \ - APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, \ - &behavior_hold_tap_driver_api); +#define _TRANSFORM_ENTRY(idx, node) \ + { \ + .behavior_dev = DT_LABEL(DT_INST_PHANDLE_BY_IDX(node, bindings, idx)), \ + .param1 = COND_CODE_0(DT_INST_PHA_HAS_CELL_AT_IDX(node, bindings, idx, param1), (0), \ + (DT_INST_PHA_BY_IDX(node, bindings, idx, param1))), \ + .param2 = COND_CODE_0(DT_INST_PHA_HAS_CELL_AT_IDX(node, bindings, idx, param2), (0), \ + (DT_INST_PHA_BY_IDX(node, bindings, idx, param2))), \ + }, + +#define KP_INST(n) \ + static k_timeout_t behavior_hold_tap_config_##n##_gettime() { \ + return K_MSEC(DT_INST_PROP(n, tapping_term_ms)); \ + } \ + static struct behavior_hold_tap_behaviors behavior_hold_tap_behaviors_##n = { \ + .hold = _TRANSFORM_ENTRY(0, n).tap = _TRANSFORM_ENTRY(1, n)}; \ + static struct behavior_hold_tap_config behavior_hold_tap_config_##n = { \ + .behaviors = &behavior_hold_tap_behaviors_##n, \ + .tapping_term_ms = &behavior_hold_tap_config_##n##_gettime, \ + .flavor = DT_ENUM_IDX(DT_DRV_INST(n), flavor), \ + }; \ + DEVICE_AND_API_INIT(behavior_hold_tap_##n, DT_INST_LABEL(n), behavior_hold_tap_init, \ + &behavior_hold_tap_data, &behavior_hold_tap_config_##n, APPLICATION, \ + CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &behavior_hold_tap_driver_api); DT_INST_FOREACH_STATUS_OKAY(KP_INST) - #endif \ No newline at end of file diff --git a/app/src/behaviors/behavior_key_press.c b/app/src/behaviors/behavior_key_press.c index 42becf5..bbfbe36 100644 --- a/app/src/behaviors/behavior_key_press.c +++ b/app/src/behaviors/behavior_key_press.c @@ -16,45 +16,35 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); struct behavior_key_press_config { - u8_t usage_page; + u8_t usage_page; }; -struct behavior_key_press_data { }; +struct behavior_key_press_data {}; -static int behavior_key_press_init(struct device *dev) -{ - return 0; -}; +static int behavior_key_press_init(struct device *dev) { return 0; }; -static int on_keymap_binding_pressed(struct device *dev, u32_t position, u32_t keycode, u32_t _) -{ - const struct behavior_key_press_config *cfg = dev->config_info; - LOG_DBG("position %d usage_page 0x%02X keycode 0x%02X", position, cfg->usage_page, keycode); +static int on_keymap_binding_pressed(struct device *dev, u32_t position, u32_t keycode, u32_t _) { + const struct behavior_key_press_config *cfg = dev->config_info; + LOG_DBG("position %d usage_page 0x%02X keycode 0x%02X", position, cfg->usage_page, keycode); - return ZMK_EVENT_RAISE(create_keycode_state_changed(cfg->usage_page, keycode, true)); + return ZMK_EVENT_RAISE(create_keycode_state_changed(cfg->usage_page, keycode, true)); } -static int on_keymap_binding_released(struct device *dev, u32_t position, u32_t keycode, u32_t _) -{ - const struct behavior_key_press_config *cfg = dev->config_info; - LOG_DBG("position %d usage_page 0x%02X keycode 0x%02X", position, cfg->usage_page, keycode); +static int on_keymap_binding_released(struct device *dev, u32_t position, u32_t keycode, u32_t _) { + const struct behavior_key_press_config *cfg = dev->config_info; + LOG_DBG("position %d usage_page 0x%02X keycode 0x%02X", position, cfg->usage_page, keycode); - return ZMK_EVENT_RAISE(create_keycode_state_changed(cfg->usage_page, keycode, false)); + return ZMK_EVENT_RAISE(create_keycode_state_changed(cfg->usage_page, keycode, false)); } static const struct behavior_driver_api behavior_key_press_driver_api = { - .binding_pressed = on_keymap_binding_pressed, - .binding_released = on_keymap_binding_released -}; - -#define KP_INST(n) \ - static const struct behavior_key_press_config behavior_key_press_config_##n = { \ - .usage_page = DT_INST_PROP(n, usage_page) \ - }; \ - static struct behavior_key_press_data behavior_key_press_data_##n; \ - DEVICE_AND_API_INIT(behavior_key_press_##n, DT_INST_LABEL(n), behavior_key_press_init, \ - &behavior_key_press_data_##n, \ - &behavior_key_press_config_##n, \ - APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, \ - &behavior_key_press_driver_api); + .binding_pressed = on_keymap_binding_pressed, .binding_released = on_keymap_binding_released}; + +#define KP_INST(n) \ + static const struct behavior_key_press_config behavior_key_press_config_##n = { \ + .usage_page = DT_INST_PROP(n, usage_page)}; \ + static struct behavior_key_press_data behavior_key_press_data_##n; \ + DEVICE_AND_API_INIT(behavior_key_press_##n, DT_INST_LABEL(n), behavior_key_press_init, \ + &behavior_key_press_data_##n, &behavior_key_press_config_##n, APPLICATION, \ + CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &behavior_key_press_driver_api); DT_INST_FOREACH_STATUS_OKAY(KP_INST) \ No newline at end of file diff --git a/app/src/behaviors/behavior_momentary_layer.c b/app/src/behaviors/behavior_momentary_layer.c index 7d65135..80b7165 100644 --- a/app/src/behaviors/behavior_momentary_layer.c +++ b/app/src/behaviors/behavior_momentary_layer.c @@ -14,41 +14,30 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); -struct behavior_mo_config { }; -struct behavior_mo_data { }; +struct behavior_mo_config {}; +struct behavior_mo_data {}; -static int behavior_mo_init(struct device *dev) -{ - return 0; -}; +static int behavior_mo_init(struct device *dev) { return 0; }; +static int mo_keymap_binding_pressed(struct device *dev, u32_t position, u32_t layer, u32_t _) { + LOG_DBG("position %d layer %d", position, layer); -static int mo_keymap_binding_pressed(struct device *dev, u32_t position, u32_t layer, u32_t _) -{ - LOG_DBG("position %d layer %d", position, layer); - - return zmk_keymap_layer_activate(layer); + return zmk_keymap_layer_activate(layer); } -static int mo_keymap_binding_released(struct device *dev, u32_t position, u32_t layer, u32_t _) -{ - LOG_DBG("position %d layer %d", position, layer); +static int mo_keymap_binding_released(struct device *dev, u32_t position, u32_t layer, u32_t _) { + LOG_DBG("position %d layer %d", position, layer); - return zmk_keymap_layer_deactivate(layer); + return zmk_keymap_layer_deactivate(layer); } static const struct behavior_driver_api behavior_mo_driver_api = { - .binding_pressed = mo_keymap_binding_pressed, - .binding_released = mo_keymap_binding_released -}; - + .binding_pressed = mo_keymap_binding_pressed, .binding_released = mo_keymap_binding_released}; static const struct behavior_mo_config behavior_mo_config = {}; static struct behavior_mo_data behavior_mo_data; -DEVICE_AND_API_INIT(behavior_mo, DT_INST_LABEL(0), behavior_mo_init, - &behavior_mo_data, - &behavior_mo_config, - APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, +DEVICE_AND_API_INIT(behavior_mo, DT_INST_LABEL(0), behavior_mo_init, &behavior_mo_data, + &behavior_mo_config, APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &behavior_mo_driver_api); diff --git a/app/src/behaviors/behavior_none.c b/app/src/behaviors/behavior_none.c index c464988..b548e6f 100644 --- a/app/src/behaviors/behavior_none.c +++ b/app/src/behaviors/behavior_none.c @@ -13,36 +13,30 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); -struct behavior_none_config { }; -struct behavior_none_data { }; +struct behavior_none_config {}; +struct behavior_none_data {}; -static int behavior_none_init(struct device *dev) -{ - return 0; -}; +static int behavior_none_init(struct device *dev) { return 0; }; -static int on_keymap_binding_pressed(struct device *dev, u32_t position, u32_t _param1, u32_t _param2) -{ - return 0; +static int on_keymap_binding_pressed(struct device *dev, u32_t position, u32_t _param1, + u32_t _param2) { + return 0; } -static int on_keymap_binding_released(struct device *dev, u32_t position, u32_t _param1, u32_t _param2) -{ - return 0; +static int on_keymap_binding_released(struct device *dev, u32_t position, u32_t _param1, + u32_t _param2) { + return 0; } static const struct behavior_driver_api behavior_none_driver_api = { - .binding_pressed = on_keymap_binding_pressed, - .binding_released = on_keymap_binding_released, + .binding_pressed = on_keymap_binding_pressed, + .binding_released = on_keymap_binding_released, }; - static const struct behavior_none_config behavior_none_config = {}; static struct behavior_none_data behavior_none_data; -DEVICE_AND_API_INIT(behavior_none, DT_INST_LABEL(0), behavior_none_init, - &behavior_none_data, - &behavior_none_config, - APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, +DEVICE_AND_API_INIT(behavior_none, DT_INST_LABEL(0), behavior_none_init, &behavior_none_data, + &behavior_none_config, APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &behavior_none_driver_api); \ No newline at end of file diff --git a/app/src/behaviors/behavior_reset.c b/app/src/behaviors/behavior_reset.c index b5692b5..90de20b 100644 --- a/app/src/behaviors/behavior_reset.c +++ b/app/src/behaviors/behavior_reset.c @@ -14,37 +14,31 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); struct behavior_reset_config { - int type; + int type; }; -static int behavior_reset_init(struct device *dev) -{ - return 0; -}; +static int behavior_reset_init(struct device *dev) { return 0; }; -static int on_keymap_binding_pressed(struct device *dev, u32_t position, u32_t _param1, u32_t _param2) -{ - const struct behavior_reset_config *cfg = dev->config_info; +static int on_keymap_binding_pressed(struct device *dev, u32_t position, u32_t _param1, + u32_t _param2) { + const struct behavior_reset_config *cfg = dev->config_info; - // TODO: Correct magic code for going into DFU? - // See https://github.com/adafruit/Adafruit_nRF52_Bootloader/blob/d6b28e66053eea467166f44875e3c7ec741cb471/src/main.c#L107 - sys_reboot(cfg->type); - return 0; + // TODO: Correct magic code for going into DFU? + // See + // https://github.com/adafruit/Adafruit_nRF52_Bootloader/blob/d6b28e66053eea467166f44875e3c7ec741cb471/src/main.c#L107 + sys_reboot(cfg->type); + return 0; } static const struct behavior_driver_api behavior_reset_driver_api = { - .binding_pressed = on_keymap_binding_pressed, + .binding_pressed = on_keymap_binding_pressed, }; +#define RST_INST(n) \ + static const struct behavior_reset_config behavior_reset_config_##n = { \ + .type = DT_INST_PROP(n, type)}; \ + DEVICE_AND_API_INIT(behavior_reset_##n, DT_INST_LABEL(n), behavior_reset_init, NULL, \ + &behavior_reset_config_##n, APPLICATION, \ + CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &behavior_reset_driver_api); -#define RST_INST(n) \ - static const struct behavior_reset_config behavior_reset_config_##n = { \ - .type = DT_INST_PROP(n, type) \ - }; \ - DEVICE_AND_API_INIT(behavior_reset_##n, DT_INST_LABEL(n), behavior_reset_init, \ - NULL, \ - &behavior_reset_config_##n, \ - APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, \ - &behavior_reset_driver_api); - DT_INST_FOREACH_STATUS_OKAY(RST_INST) \ No newline at end of file diff --git a/app/src/behaviors/behavior_rgb_underglow.c b/app/src/behaviors/behavior_rgb_underglow.c index f0a35ef..621eab5 100644 --- a/app/src/behaviors/behavior_rgb_underglow.c +++ b/app/src/behaviors/behavior_rgb_underglow.c @@ -15,48 +15,41 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); -static int behavior_rgb_underglow_init(struct device *dev) -{ - return 0; -} +static int behavior_rgb_underglow_init(struct device *dev) { return 0; } -static int on_keymap_binding_pressed(struct device *dev, u32_t position, u32_t action, u32_t _) -{ - switch (action) - { +static int on_keymap_binding_pressed(struct device *dev, u32_t position, u32_t action, u32_t _) { + switch (action) { case RGB_TOG: - return zmk_rgb_underglow_toggle(); + return zmk_rgb_underglow_toggle(); case RGB_HUI: - return zmk_rgb_underglow_change_hue(1); + return zmk_rgb_underglow_change_hue(1); case RGB_HUD: - return zmk_rgb_underglow_change_hue(-1); + return zmk_rgb_underglow_change_hue(-1); case RGB_SAI: - return zmk_rgb_underglow_change_sat(1); + return zmk_rgb_underglow_change_sat(1); case RGB_SAD: - return zmk_rgb_underglow_change_sat(-1); + return zmk_rgb_underglow_change_sat(-1); case RGB_BRI: - return zmk_rgb_underglow_change_brt(1); + return zmk_rgb_underglow_change_brt(1); case RGB_BRD: - return zmk_rgb_underglow_change_brt(-1); + return zmk_rgb_underglow_change_brt(-1); case RGB_SPI: - return zmk_rgb_underglow_change_spd(1); + return zmk_rgb_underglow_change_spd(1); case RGB_SPD: - return zmk_rgb_underglow_change_spd(-1); + return zmk_rgb_underglow_change_spd(-1); case RGB_EFF: - return zmk_rgb_underglow_cycle_effect(1); + return zmk_rgb_underglow_cycle_effect(1); case RGB_EFR: - return zmk_rgb_underglow_cycle_effect(-1); - } + return zmk_rgb_underglow_cycle_effect(-1); + } - return -ENOTSUP; + return -ENOTSUP; } static const struct behavior_driver_api behavior_rgb_underglow_driver_api = { - .binding_pressed = on_keymap_binding_pressed, + .binding_pressed = on_keymap_binding_pressed, }; -DEVICE_AND_API_INIT(behavior_rgb_underglow, DT_INST_LABEL(0), behavior_rgb_underglow_init, - NULL, - NULL, - APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, +DEVICE_AND_API_INIT(behavior_rgb_underglow, DT_INST_LABEL(0), behavior_rgb_underglow_init, NULL, + NULL, APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &behavior_rgb_underglow_driver_api); \ No newline at end of file diff --git a/app/src/behaviors/behavior_sensor_rotate_key_press.c b/app/src/behaviors/behavior_sensor_rotate_key_press.c index fa55575..1a0bf03 100644 --- a/app/src/behaviors/behavior_sensor_rotate_key_press.c +++ b/app/src/behaviors/behavior_sensor_rotate_key_press.c @@ -17,75 +17,69 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); struct behavior_sensor_rotate_key_press_config { - u8_t usage_page; -}; -struct behavior_sensor_rotate_key_press_data { }; - -static int behavior_sensor_rotate_key_press_init(struct device *dev) -{ - return 0; + u8_t usage_page; }; +struct behavior_sensor_rotate_key_press_data {}; +static int behavior_sensor_rotate_key_press_init(struct device *dev) { return 0; }; -static int on_sensor_binding_triggered(struct device *dev, struct device *sensor, u32_t increment_keycode, u32_t decrement_keycode) -{ - const struct behavior_sensor_rotate_key_press_config *cfg = dev->config_info; - struct sensor_value value; - int err; - u32_t keycode; - struct keycode_state_changed *ev; - LOG_DBG("usage_page 0x%02X inc keycode 0x%02X dec keycode 0x%02X", cfg->usage_page, increment_keycode, decrement_keycode); +static int on_sensor_binding_triggered(struct device *dev, struct device *sensor, + u32_t increment_keycode, u32_t decrement_keycode) { + const struct behavior_sensor_rotate_key_press_config *cfg = dev->config_info; + struct sensor_value value; + int err; + u32_t keycode; + struct keycode_state_changed *ev; + LOG_DBG("usage_page 0x%02X inc keycode 0x%02X dec keycode 0x%02X", cfg->usage_page, + increment_keycode, decrement_keycode); - err = sensor_channel_get(sensor, SENSOR_CHAN_ROTATION, &value); + err = sensor_channel_get(sensor, SENSOR_CHAN_ROTATION, &value); - if (err) { - LOG_WRN("Failed to ge sensor rotation value: %d", err); - return err; - } + if (err) { + LOG_WRN("Failed to ge sensor rotation value: %d", err); + return err; + } - switch (value.val1) { + switch (value.val1) { case 1: - keycode = increment_keycode; - break; + keycode = increment_keycode; + break; case -1: - keycode = decrement_keycode; - break; + keycode = decrement_keycode; + break; default: - return -ENOTSUP; - } - - LOG_DBG("SEND %d", keycode); + return -ENOTSUP; + } + LOG_DBG("SEND %d", keycode); - ev = new_keycode_state_changed(); - ev->usage_page = cfg->usage_page; - ev->keycode = keycode; - ev->state = true; - ZMK_EVENT_RAISE(ev); + ev = new_keycode_state_changed(); + ev->usage_page = cfg->usage_page; + ev->keycode = keycode; + ev->state = true; + ZMK_EVENT_RAISE(ev); - // TODO: Better way to do this? - k_msleep(5); + // TODO: Better way to do this? + k_msleep(5); - ev = new_keycode_state_changed(); - ev->usage_page = cfg->usage_page; - ev->keycode = keycode; - ev->state = false; - return ZMK_EVENT_RAISE(ev); + ev = new_keycode_state_changed(); + ev->usage_page = cfg->usage_page; + ev->keycode = keycode; + ev->state = false; + return ZMK_EVENT_RAISE(ev); } static const struct behavior_driver_api behavior_sensor_rotate_key_press_driver_api = { - .sensor_binding_triggered = on_sensor_binding_triggered -}; - -#define KP_INST(n) \ - static const struct behavior_sensor_rotate_key_press_config behavior_sensor_rotate_key_press_config_##n = { \ - .usage_page = DT_INST_PROP(n, usage_page) \ - }; \ - static struct behavior_sensor_rotate_key_press_data behavior_sensor_rotate_key_press_data_##n; \ - DEVICE_AND_API_INIT(behavior_sensor_rotate_key_press_##n, DT_INST_LABEL(n), behavior_sensor_rotate_key_press_init, \ - &behavior_sensor_rotate_key_press_data_##n, \ - &behavior_sensor_rotate_key_press_config_##n, \ - APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, \ - &behavior_sensor_rotate_key_press_driver_api); + .sensor_binding_triggered = on_sensor_binding_triggered}; + +#define KP_INST(n) \ + static const struct behavior_sensor_rotate_key_press_config \ + behavior_sensor_rotate_key_press_config_##n = {.usage_page = DT_INST_PROP(n, usage_page)}; \ + static struct behavior_sensor_rotate_key_press_data behavior_sensor_rotate_key_press_data_##n; \ + DEVICE_AND_API_INIT( \ + behavior_sensor_rotate_key_press_##n, DT_INST_LABEL(n), \ + behavior_sensor_rotate_key_press_init, &behavior_sensor_rotate_key_press_data_##n, \ + &behavior_sensor_rotate_key_press_config_##n, APPLICATION, \ + CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &behavior_sensor_rotate_key_press_driver_api); DT_INST_FOREACH_STATUS_OKAY(KP_INST) \ No newline at end of file diff --git a/app/src/behaviors/behavior_toggle_layer.c b/app/src/behaviors/behavior_toggle_layer.c index c6d5225..2819451 100644 --- a/app/src/behaviors/behavior_toggle_layer.c +++ b/app/src/behaviors/behavior_toggle_layer.c @@ -14,30 +14,21 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); -struct behavior_tog_config -{ -}; -struct behavior_tog_data -{ -}; +struct behavior_tog_config {}; +struct behavior_tog_data {}; -static int behavior_tog_init(struct device *dev) -{ - return 0; -}; +static int behavior_tog_init(struct device *dev) { return 0; }; -static int tog_keymap_binding_pressed(struct device *dev, u32_t position, u32_t layer, u32_t _) -{ - LOG_DBG("position %d layer %d", position, layer); +static int tog_keymap_binding_pressed(struct device *dev, u32_t position, u32_t layer, u32_t _) { + LOG_DBG("position %d layer %d", position, layer); - return zmk_keymap_layer_toggle(layer); + return zmk_keymap_layer_toggle(layer); } -static int tog_keymap_binding_released(struct device *dev, u32_t position, u32_t layer, u32_t _) -{ - LOG_DBG("position %d layer %d", position, layer); +static int tog_keymap_binding_released(struct device *dev, u32_t position, u32_t layer, u32_t _) { + LOG_DBG("position %d layer %d", position, layer); - return 0; + return 0; } static const struct behavior_driver_api behavior_tog_driver_api = { @@ -49,8 +40,6 @@ static const struct behavior_tog_config behavior_tog_config = {}; static struct behavior_tog_data behavior_tog_data; -DEVICE_AND_API_INIT(behavior_tog, DT_INST_LABEL(0), behavior_tog_init, - &behavior_tog_data, - &behavior_tog_config, - APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, +DEVICE_AND_API_INIT(behavior_tog, DT_INST_LABEL(0), behavior_tog_init, &behavior_tog_data, + &behavior_tog_config, APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &behavior_tog_driver_api); diff --git a/app/src/behaviors/behavior_transparent.c b/app/src/behaviors/behavior_transparent.c index 51f682b..f7852f3 100644 --- a/app/src/behaviors/behavior_transparent.c +++ b/app/src/behaviors/behavior_transparent.c @@ -13,36 +13,30 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); -struct behavior_transparent_config { }; -struct behavior_transparent_data { }; +struct behavior_transparent_config {}; +struct behavior_transparent_data {}; -static int behavior_transparent_init(struct device *dev) -{ - return 0; -}; +static int behavior_transparent_init(struct device *dev) { return 0; }; -static int on_keymap_binding_pressed(struct device *dev, u32_t position, u32_t _param1, u32_t _param2) -{ - return 1; +static int on_keymap_binding_pressed(struct device *dev, u32_t position, u32_t _param1, + u32_t _param2) { + return 1; } -static int on_keymap_binding_released(struct device *dev, u32_t position, u32_t _param1, u32_t _param2) -{ - return 1; +static int on_keymap_binding_released(struct device *dev, u32_t position, u32_t _param1, + u32_t _param2) { + return 1; } static const struct behavior_driver_api behavior_transparent_driver_api = { - .binding_pressed = on_keymap_binding_pressed, - .binding_released = on_keymap_binding_released, + .binding_pressed = on_keymap_binding_pressed, + .binding_released = on_keymap_binding_released, }; - static const struct behavior_transparent_config behavior_transparent_config = {}; static struct behavior_transparent_data behavior_transparent_data; DEVICE_AND_API_INIT(behavior_transparent, DT_INST_LABEL(0), behavior_transparent_init, - &behavior_transparent_data, - &behavior_transparent_config, - APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, - &behavior_transparent_driver_api); \ No newline at end of file + &behavior_transparent_data, &behavior_transparent_config, APPLICATION, + CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &behavior_transparent_driver_api); \ No newline at end of file diff --git a/app/src/ble.c b/app/src/ble.c index a2a8207..49e2b3b 100644 --- a/app/src/ble.c +++ b/app/src/ble.c @@ -45,7 +45,6 @@ static u8_t passkey_digit = 0; #define PROFILE_COUNT CONFIG_BT_MAX_PAIRED #endif - static struct zmk_ble_profile profiles[PROFILE_COUNT]; static u8_t active_profile; @@ -53,13 +52,12 @@ static const struct bt_data zmk_ble_ad[] = { 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) - 0x12, 0x18, /* HID Service */ + 0x12, 0x18, /* HID Service */ #endif 0x0f, 0x18 /* Battery Service */ - ), + ), #if IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL) - BT_DATA_BYTES(BT_DATA_UUID128_ALL, - ZMK_SPLIT_BT_SERVICE_UUID) + BT_DATA_BYTES(BT_DATA_UUID128_ALL, ZMK_SPLIT_BT_SERVICE_UUID) #endif }; @@ -69,8 +67,7 @@ static bt_addr_le_t peripheral_addr; #endif /* IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL) */ -static void raise_profile_changed_event() -{ +static void raise_profile_changed_event() { struct ble_active_profile_changed *ev = new_ble_active_profile_changed(); ev->index = active_profile; ev->profile = &profiles[active_profile]; @@ -78,13 +75,11 @@ static void raise_profile_changed_event() ZMK_EVENT_RAISE(ev); } -static bool active_profile_is_open() -{ +static bool active_profile_is_open() { return !bt_addr_le_cmp(&profiles[active_profile].peer, BT_ADDR_LE_ANY); } -void set_profile_address(u8_t index, const bt_addr_le_t *addr) -{ +void set_profile_address(u8_t index, const bt_addr_le_t *addr) { char setting_name[15]; char addr_str[BT_ADDR_LE_STR_LEN]; @@ -97,8 +92,7 @@ void set_profile_address(u8_t index, const bt_addr_le_t *addr) raise_profile_changed_event(); } -int zmk_ble_adv_pause() -{ +int zmk_ble_adv_pause() { int err = bt_le_adv_stop(); if (err) { LOG_ERR("Failed to stop advertising (err %d)", err); @@ -108,16 +102,12 @@ int zmk_ble_adv_pause() return 0; }; -int zmk_ble_adv_resume() -{ - LOG_DBG("active_profile %d, directed? %s", active_profile, active_profile_is_open() ? "no" : "yes"); +int zmk_ble_adv_resume() { + LOG_DBG("active_profile %d, directed? %s", active_profile, + active_profile_is_open() ? "no" : "yes"); - int err = bt_le_adv_start( - BT_LE_ADV_CONN_NAME, - zmk_ble_ad, ARRAY_SIZE(zmk_ble_ad), - NULL, 0); - if (err) - { + int err = bt_le_adv_start(BT_LE_ADV_CONN_NAME, zmk_ble_ad, ARRAY_SIZE(zmk_ble_ad), NULL, 0); + if (err) { LOG_ERR("Advertising failed to start (err %d)", err); return err; } @@ -125,10 +115,9 @@ int zmk_ble_adv_resume() return 0; }; -int zmk_ble_clear_bonds() -{ +int zmk_ble_clear_bonds() { LOG_DBG(""); - + if (bt_addr_le_cmp(&profiles[active_profile].peer, BT_ADDR_LE_ANY)) { LOG_DBG("Unpairing!"); bt_unpair(BT_ID_DEFAULT, &profiles[active_profile].peer); @@ -138,8 +127,7 @@ int zmk_ble_clear_bonds() return 0; }; -int zmk_ble_prof_select(u8_t index) -{ +int zmk_ble_prof_select(u8_t index) { LOG_DBG("profile %d", index); if (active_profile == index) { return 0; @@ -148,35 +136,26 @@ int zmk_ble_prof_select(u8_t index) active_profile = index; return settings_save_one("ble/active_profile", &active_profile, sizeof(active_profile)); - raise_profile_changed_event(); + raise_profile_changed_event(); }; -int zmk_ble_prof_next() -{ +int zmk_ble_prof_next() { LOG_DBG(""); return zmk_ble_prof_select((active_profile + 1) % PROFILE_COUNT); }; -int zmk_ble_prof_prev() -{ +int zmk_ble_prof_prev() { LOG_DBG(""); return zmk_ble_prof_select((active_profile + PROFILE_COUNT - 1) % PROFILE_COUNT); }; -bt_addr_le_t *zmk_ble_active_profile_addr() -{ - return &profiles[active_profile].peer; -} +bt_addr_le_t *zmk_ble_active_profile_addr() { return &profiles[active_profile].peer; } -char *zmk_ble_active_profile_name() -{ - return profiles[active_profile].name; -} +char *zmk_ble_active_profile_name() { return profiles[active_profile].name; } #if IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL) -void zmk_ble_set_peripheral_addr(bt_addr_le_t *addr) -{ +void zmk_ble_set_peripheral_addr(bt_addr_le_t *addr) { memcpy(&peripheral_addr, addr, sizeof(bt_addr_le_t)); settings_save_one("ble/peripheral_address", addr, sizeof(bt_addr_le_t)); } @@ -185,8 +164,8 @@ void zmk_ble_set_peripheral_addr(bt_addr_le_t *addr) #if IS_ENABLED(CONFIG_SETTINGS) -static int ble_profiles_handle_set(const char *name, size_t len, settings_read_cb read_cb, void *cb_arg) -{ +static int ble_profiles_handle_set(const char *name, size_t len, settings_read_cb read_cb, + void *cb_arg) { const char *next; LOG_DBG("Setting BLE value %s", log_strdup(name)); @@ -200,7 +179,8 @@ static int ble_profiles_handle_set(const char *name, size_t len, settings_read_c } if (len != sizeof(struct zmk_ble_profile)) { - LOG_ERR("Invalid profile size (got %d expected %d)", len, sizeof(struct zmk_ble_profile)); + LOG_ERR("Invalid profile size (got %d expected %d)", len, + sizeof(struct zmk_ble_profile)); return -EINVAL; } @@ -247,19 +227,14 @@ static int ble_profiles_handle_set(const char *name, size_t len, settings_read_c return 0; }; -struct settings_handler profiles_handler = { - .name = "ble", - .h_set = ble_profiles_handle_set -}; +struct settings_handler profiles_handler = {.name = "ble", .h_set = ble_profiles_handle_set}; #endif /* IS_ENABLED(CONFIG_SETTINGS) */ -static void connected(struct bt_conn *conn, u8_t err) -{ +static void connected(struct bt_conn *conn, u8_t err) { char addr[BT_ADDR_LE_STR_LEN]; bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr)); - if (err) - { + if (err) { LOG_WRN("Failed to connect to %s (%u)", log_strdup(addr), err); return; } @@ -272,14 +247,12 @@ static void connected(struct bt_conn *conn, u8_t err) bt_conn_le_phy_update(conn, BT_CONN_LE_PHY_PARAM_2M); #endif - if (bt_conn_set_security(conn, BT_SECURITY_L2)) - { + if (bt_conn_set_security(conn, BT_SECURITY_L2)) { LOG_ERR("Failed to set security"); } } -static void disconnected(struct bt_conn *conn, u8_t reason) -{ +static void disconnected(struct bt_conn *conn, u8_t reason) { char addr[BT_ADDR_LE_STR_LEN]; bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr)); @@ -287,29 +260,24 @@ static void disconnected(struct bt_conn *conn, u8_t reason) LOG_DBG("Disconnected from %s (reason 0x%02x)", log_strdup(addr), reason); #if IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL) - // if (bt_addr_le_cmp(&peripheral_addr, BT_ADDR_LE_ANY) && bt_addr_le_cmp(&peripheral_addr, bt_conn_get_dst(conn))) { + // if (bt_addr_le_cmp(&peripheral_addr, BT_ADDR_LE_ANY) && bt_addr_le_cmp(&peripheral_addr, + // bt_conn_get_dst(conn))) { // zmk_ble_adv_resume(); // } -#else +#else // zmk_ble_adv_resume(); #endif } -static void security_changed(struct bt_conn *conn, bt_security_t level, - enum bt_security_err err) -{ +static void security_changed(struct bt_conn *conn, bt_security_t level, enum bt_security_err err) { char addr[BT_ADDR_LE_STR_LEN]; bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr)); - if (!err) - { + if (!err) { LOG_DBG("Security changed: %s level %u", log_strdup(addr), level); - } - else - { - LOG_ERR("Security failed: %s level %u err %d", log_strdup(addr), level, - err); + } else { + LOG_ERR("Security failed: %s level %u err %d", log_strdup(addr), level, err); } } @@ -319,8 +287,7 @@ static struct bt_conn_cb conn_callbacks = { .security_changed = security_changed, }; -static void auth_passkey_display(struct bt_conn *conn, unsigned int passkey) -{ +static void auth_passkey_display(struct bt_conn *conn, unsigned int passkey) { char addr[BT_ADDR_LE_STR_LEN]; bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr)); @@ -330,8 +297,7 @@ static void auth_passkey_display(struct bt_conn *conn, unsigned int passkey) #ifdef CONFIG_ZMK_BLE_PASSKEY_ENTRY -static void auth_passkey_entry(struct bt_conn *conn) -{ +static void auth_passkey_entry(struct bt_conn *conn) { char addr[BT_ADDR_LE_STR_LEN]; bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr)); @@ -342,14 +308,12 @@ static void auth_passkey_entry(struct bt_conn *conn) #endif -static void auth_cancel(struct bt_conn *conn) -{ +static void auth_cancel(struct bt_conn *conn) { char addr[BT_ADDR_LE_STR_LEN]; bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr)); - if (auth_passkey_entry_conn) - { + if (auth_passkey_entry_conn) { bt_conn_unref(auth_passkey_entry_conn); auth_passkey_entry_conn = NULL; } @@ -360,8 +324,8 @@ static void auth_cancel(struct bt_conn *conn) } #if !IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL) -static enum bt_security_err auth_pairing_accept(struct bt_conn *conn, const struct bt_conn_pairing_feat *const feat) -{ +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; bt_conn_get_info(conn, &info); @@ -375,8 +339,7 @@ static enum bt_security_err auth_pairing_accept(struct bt_conn *conn, const stru }; #endif /* !IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL) */ -static void auth_pairing_complete(struct bt_conn *conn, bool bonded) -{ +static void auth_pairing_complete(struct bt_conn *conn, bool bonded) { struct bt_conn_info info; char addr[BT_ADDR_LE_STR_LEN]; const bt_addr_le_t *dst = bt_conn_get_dst(conn); @@ -413,12 +376,9 @@ static struct bt_conn_auth_cb zmk_ble_auth_cb_display = { .cancel = auth_cancel, }; - -static void zmk_ble_ready(int err) -{ +static void zmk_ble_ready(int err) { LOG_DBG("ready? %d", err); - if (err) - { + if (err) { LOG_ERR("Bluetooth init failed (err %d)", err); return; } @@ -426,12 +386,10 @@ static void zmk_ble_ready(int err) zmk_ble_adv_resume(); } -static int zmk_ble_init(struct device *_arg) -{ +static int zmk_ble_init(struct device *_arg) { int err = bt_enable(NULL); - if (err) - { + if (err) { LOG_ERR("BLUETOOTH FAILED (%d)", err); return err; } @@ -475,8 +433,7 @@ static int zmk_ble_init(struct device *_arg) return 0; } -int zmk_ble_unpair_all() -{ +int zmk_ble_unpair_all() { int resp = 0; for (int i = BT_ID_DEFAULT; i < CONFIG_BT_ID_MAX; i++) { @@ -490,17 +447,14 @@ int zmk_ble_unpair_all() return resp; }; -bool zmk_ble_handle_key_user(struct zmk_key_event *key_event) -{ +bool zmk_ble_handle_key_user(struct zmk_key_event *key_event) { zmk_key key = key_event->key; - if (!auth_passkey_entry_conn) - { + if (!auth_passkey_entry_conn) { return true; } - if (key < NUM_1 || key > NUM_0) - { + if (key < NUM_1 || key > NUM_0) { return true; } @@ -508,11 +462,9 @@ bool zmk_ble_handle_key_user(struct zmk_key_event *key_event) passkey_entries[passkey_digit++] = val; - if (passkey_digit == 6) - { + if (passkey_digit == 6) { u32_t passkey = 0; - for (int i = 5; i >= 0; i--) - { + for (int i = 5; i >= 0; i--) { passkey = (passkey * 10) + val; } bt_conn_auth_passkey_entry(auth_passkey_entry_conn, passkey); @@ -523,6 +475,4 @@ bool zmk_ble_handle_key_user(struct zmk_key_event *key_event) return false; } -SYS_INIT(zmk_ble_init, - APPLICATION, - CONFIG_ZMK_BLE_INIT_PRIORITY); +SYS_INIT(zmk_ble_init, APPLICATION, CONFIG_ZMK_BLE_INIT_PRIORITY); diff --git a/app/src/ble_unpair_combo.c b/app/src/ble_unpair_combo.c index 3633a5b..b6e542d 100644 --- a/app/src/ble_unpair_combo.c +++ b/app/src/ble_unpair_combo.c @@ -18,14 +18,12 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); #include #include - static u8_t combo_state; const u32_t key_positions[] = DT_INST_PROP(0, key_positions); #define KP_LEN DT_INST_PROP_LEN(0, key_positions) -int index_for_key_position(u32_t kp) -{ +int index_for_key_position(u32_t kp) { for (int i = 0; i < KP_LEN; i++) { if (key_positions[i] == kp) { return i; @@ -35,8 +33,7 @@ int index_for_key_position(u32_t kp) return -1; } -int unpair_combo_listener(const struct zmk_event_header *eh) -{ +int unpair_combo_listener(const struct zmk_event_header *eh) { if (is_position_state_changed(eh)) { const struct position_state_changed *psc = cast_position_state_changed(eh); @@ -51,8 +48,7 @@ int unpair_combo_listener(const struct zmk_event_header *eh) return 0; }; -void unpair_combo_work_handler(struct k_work *work) -{ +void unpair_combo_work_handler(struct k_work *work) { for (int i = 0; i < KP_LEN; i++) { if (!(combo_state & BIT(i))) { LOG_DBG("Key position %d not held, skipping unpair combo", key_positions[i]); @@ -65,8 +61,7 @@ void unpair_combo_work_handler(struct k_work *work) struct k_delayed_work unpair_combo_work; -int zmk_ble_unpair_combo_init(struct device *_unused) -{ +int zmk_ble_unpair_combo_init(struct device *_unused) { k_delayed_work_init(&unpair_combo_work, unpair_combo_work_handler); k_delayed_work_submit(&unpair_combo_work, K_SECONDS(2)); @@ -76,8 +71,6 @@ int zmk_ble_unpair_combo_init(struct device *_unused) ZMK_LISTENER(zmk_ble_unpair_combo, unpair_combo_listener); ZMK_SUBSCRIPTION(zmk_ble_unpair_combo, position_state_changed); -SYS_INIT(zmk_ble_unpair_combo_init, - APPLICATION, - CONFIG_APPLICATION_INIT_PRIORITY); +SYS_INIT(zmk_ble_unpair_combo_init, APPLICATION, CONFIG_APPLICATION_INIT_PRIORITY); #endif /* DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) */ diff --git a/app/src/display.c b/app/src/display.c index dca462e..ecd1908 100644 --- a/app/src/display.c +++ b/app/src/display.c @@ -20,8 +20,7 @@ static struct device *display; static lv_obj_t *screen; -int zmk_display_init() -{ +int zmk_display_init() { lv_obj_t *hello_world_label; lv_obj_t *count_label; @@ -48,8 +47,7 @@ int zmk_display_init() return 0; } -void zmk_display_task_handler() -{ +void zmk_display_task_handler() { lv_tick_inc(10); lv_task_handler(); k_sleep(K_MSEC(10)); diff --git a/app/src/endpoints.c b/app/src/endpoints.c index 61e86ce..ae78587 100644 --- a/app/src/endpoints.c +++ b/app/src/endpoints.c @@ -12,27 +12,24 @@ #include LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); -int zmk_endpoints_send_report(u8_t usage_page) -{ +int zmk_endpoints_send_report(u8_t usage_page) { int err; struct zmk_hid_keypad_report *keypad_report; struct zmk_hid_consumer_report *consumer_report; LOG_DBG("usage page 0x%02X", usage_page); - switch (usage_page) - { + switch (usage_page) { case USAGE_KEYPAD: keypad_report = zmk_hid_get_keypad_report(); #ifdef CONFIG_ZMK_USB - if (zmk_usb_hid_send_report((u8_t *)keypad_report, sizeof(struct zmk_hid_keypad_report)) != 0) - { + if (zmk_usb_hid_send_report((u8_t *)keypad_report, sizeof(struct zmk_hid_keypad_report)) != + 0) { LOG_DBG("USB Send Failed"); } #endif /* CONFIG_ZMK_USB */ #ifdef CONFIG_ZMK_BLE err = zmk_hog_send_keypad_report(&keypad_report->body); - if (err) - { + if (err) { LOG_ERR("FAILED TO SEND OVER HOG: %d", err); } #endif /* CONFIG_ZMK_BLE */ @@ -41,16 +38,15 @@ int zmk_endpoints_send_report(u8_t usage_page) case USAGE_CONSUMER: consumer_report = zmk_hid_get_consumer_report(); #ifdef CONFIG_ZMK_USB - if (zmk_usb_hid_send_report((u8_t *)consumer_report, sizeof(struct zmk_hid_consumer_report)) != 0) - { + if (zmk_usb_hid_send_report((u8_t *)consumer_report, + sizeof(struct zmk_hid_consumer_report)) != 0) { LOG_DBG("USB Send Failed"); } #endif /* CONFIG_ZMK_USB */ #ifdef CONFIG_ZMK_BLE err = zmk_hog_send_consumer_report(&consumer_report->body); - if (err) - { + if (err) { LOG_ERR("FAILED TO SEND OVER HOG: %d", err); } #endif /* CONFIG_ZMK_BLE */ @@ -63,4 +59,3 @@ int zmk_endpoints_send_report(u8_t usage_page) return 0; } - diff --git a/app/src/event_manager.c b/app/src/event_manager.c index 6d37e4e..226f3ce 100644 --- a/app/src/event_manager.c +++ b/app/src/event_manager.c @@ -3,7 +3,7 @@ * * SPDX-License-Identifier: MIT */ - + #include #include @@ -11,15 +11,13 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); #include -extern struct zmk_event_type* __event_type_start[]; -extern struct zmk_event_type* __event_type_end[]; +extern struct zmk_event_type *__event_type_start[]; +extern struct zmk_event_type *__event_type_end[]; extern struct zmk_event_subscription __event_subscriptions_start[]; extern struct zmk_event_subscription __event_subscriptions_end[]; - -int zmk_event_manager_handle_from(struct zmk_event_header *event, u8_t start_index) -{ +int zmk_event_manager_handle_from(struct zmk_event_header *event, u8_t start_index) { int ret = 0; u8_t len = __event_subscriptions_end - __event_subscriptions_start; for (int i = start_index; i < len; i++) { @@ -31,15 +29,15 @@ int zmk_event_manager_handle_from(struct zmk_event_header *event, u8_t start_ind goto release; } else if (ret > 0) { switch (ret) { - case ZMK_EV_EVENT_HANDLED: - LOG_DBG("Listener handled the event"); - ret = 0; - goto release; - case ZMK_EV_EVENT_CAPTURED: - LOG_DBG("Listener captured the event"); - event->last_listener_index = i; - // Listeners are expected to free events they capture - return 0; + case ZMK_EV_EVENT_HANDLED: + LOG_DBG("Listener handled the event"); + ret = 0; + goto release; + case ZMK_EV_EVENT_CAPTURED: + LOG_DBG("Listener captured the event"); + event->last_listener_index = i; + // Listeners are expected to free events they capture + return 0; } } } @@ -50,19 +48,18 @@ release: return ret; } -int zmk_event_manager_raise(struct zmk_event_header *event) -{ +int zmk_event_manager_raise(struct zmk_event_header *event) { return zmk_event_manager_handle_from(event, 0); } -int zmk_event_manager_raise_after(struct zmk_event_header *event, const struct zmk_listener *listener) -{ +int zmk_event_manager_raise_after(struct zmk_event_header *event, + const struct zmk_listener *listener) { u8_t len = __event_subscriptions_end - __event_subscriptions_start; for (int i = 0; i < len; i++) { struct zmk_event_subscription *ev_sub = __event_subscriptions_start + i; if (ev_sub->event_type == event->event && ev_sub->listener == listener) { - return zmk_event_manager_handle_from(event, i+1); + return zmk_event_manager_handle_from(event, i + 1); } } @@ -71,8 +68,8 @@ int zmk_event_manager_raise_after(struct zmk_event_header *event, const struct z return -EINVAL; } -int zmk_event_manager_raise_at(struct zmk_event_header *event, const struct zmk_listener *listener) -{ +int zmk_event_manager_raise_at(struct zmk_event_header *event, + const struct zmk_listener *listener) { u8_t len = __event_subscriptions_end - __event_subscriptions_start; for (int i = 0; i < len; i++) { struct zmk_event_subscription *ev_sub = __event_subscriptions_start + i; @@ -87,7 +84,6 @@ int zmk_event_manager_raise_at(struct zmk_event_header *event, const struct zmk_ return -EINVAL; } -int zmk_event_manager_release(struct zmk_event_header *event) -{ +int zmk_event_manager_release(struct zmk_event_header *event) { return zmk_event_manager_handle_from(event, event->last_listener_index + 1); } diff --git a/app/src/hid.c b/app/src/hid.c index 07fc3a0..f80906c 100644 --- a/app/src/hid.c +++ b/app/src/hid.c @@ -10,41 +10,27 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); #include static struct zmk_hid_keypad_report kp_report = { - .report_id = 1, - .body = { - .modifiers = 0, - .keys = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}}; - -static struct zmk_hid_consumer_report consumer_report = { - .report_id = 2, - .body = { - .keys = {0,0,0,0,0,0}}}; - -#define _TOGGLE_MOD(mod, state) \ - if (modifier > MOD_RGUI) \ - { \ - return -EINVAL; \ - } \ - WRITE_BIT(kp_report.body.modifiers, mod, state); \ + .report_id = 1, .body = {.modifiers = 0, .keys = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}}; + +static struct zmk_hid_consumer_report consumer_report = {.report_id = 2, + .body = {.keys = {0, 0, 0, 0, 0, 0}}}; + +#define _TOGGLE_MOD(mod, state) \ + if (modifier > MOD_RGUI) { \ + return -EINVAL; \ + } \ + WRITE_BIT(kp_report.body.modifiers, mod, state); \ return 0; -int zmk_hid_register_mod(zmk_mod modifier) -{ - _TOGGLE_MOD(modifier, true); -} -int zmk_hid_unregister_mod(zmk_mod modifier) -{ - _TOGGLE_MOD(modifier, false); -} +int zmk_hid_register_mod(zmk_mod modifier) { _TOGGLE_MOD(modifier, true); } +int zmk_hid_unregister_mod(zmk_mod modifier) { _TOGGLE_MOD(modifier, false); } -int zmk_hid_register_mods(zmk_mod_flags modifiers) -{ +int zmk_hid_register_mods(zmk_mod_flags modifiers) { kp_report.body.modifiers |= modifiers; return 0; } -int zmk_hid_unregister_mods(zmk_mod_flags modifiers) -{ +int zmk_hid_unregister_mods(zmk_mod_flags modifiers) { kp_report.body.modifiers &= ~modifiers; return 0; } @@ -67,28 +53,21 @@ int zmk_hid_unregister_mods(zmk_mod_flags modifiers) #define TOGGLE_KEY(code, val) WRITE_BIT(kp_report.body.keys[code / 8], code % 8, val) -#define TOGGLE_CONSUMER(match, val) \ - for (int idx = 0; idx < MAX_KEYS; idx++) \ - { \ - if (consumer_report.body.keys[idx] != match) \ - { \ - continue; \ - } \ - consumer_report.body.keys[idx] = val; \ - break; \ +#define TOGGLE_CONSUMER(match, val) \ + for (int idx = 0; idx < MAX_KEYS; idx++) { \ + if (consumer_report.body.keys[idx] != match) { \ + continue; \ + } \ + consumer_report.body.keys[idx] = val; \ + break; \ } - -int zmk_hid_keypad_press(zmk_key code) -{ - if (code >= LCTL && code <= RGUI) - { +int zmk_hid_keypad_press(zmk_key code) { + if (code >= LCTL && code <= RGUI) { return zmk_hid_register_mod(code - LCTL); } - - if (code > ZMK_HID_MAX_KEYCODE) - { + if (code > ZMK_HID_MAX_KEYCODE) { return -EINVAL; } @@ -99,15 +78,12 @@ int zmk_hid_keypad_press(zmk_key code) return 0; }; -int zmk_hid_keypad_release(zmk_key code) -{ - if (code >= LCTL && code <= RGUI) - { +int zmk_hid_keypad_release(zmk_key code) { + if (code >= LCTL && code <= RGUI) { return zmk_hid_unregister_mod(code - LCTL); } - if (code > ZMK_HID_MAX_KEYCODE) - { + if (code > ZMK_HID_MAX_KEYCODE) { return -EINVAL; } @@ -118,25 +94,20 @@ int zmk_hid_keypad_release(zmk_key code) return 0; }; -int zmk_hid_consumer_press(zmk_key code) -{ +int zmk_hid_consumer_press(zmk_key code) { TOGGLE_CONSUMER(0U, code); return 0; }; - -int zmk_hid_consumer_release(zmk_key code) -{ +int zmk_hid_consumer_release(zmk_key code) { TOGGLE_CONSUMER(code, 0U); return 0; }; -struct zmk_hid_keypad_report *zmk_hid_get_keypad_report() -{ +struct zmk_hid_keypad_report *zmk_hid_get_keypad_report() { return &kp_report; } -struct zmk_hid_consumer_report *zmk_hid_get_consumer_report() -{ +struct zmk_hid_consumer_report *zmk_hid_get_consumer_report() { return &consumer_report; } diff --git a/app/src/hid_listener.c b/app/src/hid_listener.c index 9f68ca2..4467e6d 100644 --- a/app/src/hid_listener.c +++ b/app/src/hid_listener.c @@ -15,90 +15,84 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); #include #include +static int hid_listener_keycode_pressed(u8_t usage_page, u32_t keycode) { + int err; + LOG_DBG("usage_page 0x%02X keycode 0x%02X", usage_page, keycode); -static int hid_listener_keycode_pressed(u8_t usage_page, u32_t keycode) -{ - int err; - LOG_DBG("usage_page 0x%02X keycode 0x%02X", usage_page, keycode); - - switch (usage_page) { - case USAGE_KEYPAD: - err = zmk_hid_keypad_press(keycode); - if (err) { - LOG_ERR("Unable to press keycode"); - return err; + switch (usage_page) { + case USAGE_KEYPAD: + err = zmk_hid_keypad_press(keycode); + if (err) { + LOG_ERR("Unable to press keycode"); + return err; + } + break; + case USAGE_CONSUMER: + err = zmk_hid_consumer_press(keycode); + if (err) { + LOG_ERR("Unable to press keycode"); + return err; + } + break; } - break; - case USAGE_CONSUMER: - err = zmk_hid_consumer_press(keycode); - if (err) { - LOG_ERR("Unable to press keycode"); - return err; - } - break; - } - return zmk_endpoints_send_report(usage_page); + return zmk_endpoints_send_report(usage_page); } -static int hid_listener_keycode_released(u8_t usage_page, u32_t keycode) -{ - int err; - LOG_DBG("usage_page 0x%02X keycode 0x%02X", usage_page, keycode); - - switch (usage_page) { - case USAGE_KEYPAD: - err = zmk_hid_keypad_release(keycode); - if (err) { - LOG_ERR("Unable to release keycode"); - return err; - } - break; - case USAGE_CONSUMER: - err = zmk_hid_consumer_release(keycode); - if (err) { - LOG_ERR("Unable to release keycode"); - return err; +static int hid_listener_keycode_released(u8_t usage_page, u32_t keycode) { + int err; + LOG_DBG("usage_page 0x%02X keycode 0x%02X", usage_page, keycode); + + switch (usage_page) { + case USAGE_KEYPAD: + err = zmk_hid_keypad_release(keycode); + if (err) { + LOG_ERR("Unable to release keycode"); + return err; + } + break; + case USAGE_CONSUMER: + err = zmk_hid_consumer_release(keycode); + if (err) { + LOG_ERR("Unable to release keycode"); + return err; + } + break; } - break; - } - return zmk_endpoints_send_report(usage_page); + return zmk_endpoints_send_report(usage_page); } -static int hid_listener_modifiers_pressed(zmk_mod_flags modifiers) -{ - LOG_DBG("modifiers %d", modifiers); - - zmk_hid_register_mods(modifiers); - return zmk_endpoints_send_report(USAGE_KEYPAD); +static int hid_listener_modifiers_pressed(zmk_mod_flags modifiers) { + LOG_DBG("modifiers %d", modifiers); + + zmk_hid_register_mods(modifiers); + return zmk_endpoints_send_report(USAGE_KEYPAD); } -static int hid_listener_modifiers_released(zmk_mod_flags modifiers) -{ - LOG_DBG("modifiers %d", modifiers); - - zmk_hid_unregister_mods(modifiers); - return zmk_endpoints_send_report(USAGE_KEYPAD); +static int hid_listener_modifiers_released(zmk_mod_flags modifiers) { + LOG_DBG("modifiers %d", modifiers); + + zmk_hid_unregister_mods(modifiers); + return zmk_endpoints_send_report(USAGE_KEYPAD); } -int hid_listener(const struct zmk_event_header *eh) -{ - if (is_keycode_state_changed(eh)) { - const struct keycode_state_changed *ev = cast_keycode_state_changed(eh); - if (ev->state) { - hid_listener_keycode_pressed(ev->usage_page, ev->keycode); - } else { - hid_listener_keycode_released(ev->usage_page, ev->keycode); - } - } else if (is_modifiers_state_changed(eh)) { - const struct modifiers_state_changed *ev = cast_modifiers_state_changed(eh); - if (ev->state) { - hid_listener_modifiers_pressed(ev->modifiers); - } else { - hid_listener_modifiers_released(ev->modifiers); +int hid_listener(const struct zmk_event_header *eh) { + if (is_keycode_state_changed(eh)) { + const struct keycode_state_changed *ev = cast_keycode_state_changed(eh); + if (ev->state) { + hid_listener_keycode_pressed(ev->usage_page, ev->keycode); + } else { + hid_listener_keycode_released(ev->usage_page, ev->keycode); + } + } else if (is_modifiers_state_changed(eh)) { + const struct modifiers_state_changed *ev = cast_modifiers_state_changed(eh); + if (ev->state) { + hid_listener_modifiers_pressed(ev->modifiers); + } else { + hid_listener_modifiers_released(ev->modifiers); + } } - } - return 0; + return 0; } ZMK_LISTENER(hid_listener, hid_listener); diff --git a/app/src/hog.c b/app/src/hog.c index 93e6d9b..11349ac 100644 --- a/app/src/hog.c +++ b/app/src/hog.c @@ -17,21 +17,18 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); #include #include -enum -{ +enum { HIDS_REMOTE_WAKE = BIT(0), HIDS_NORMALLY_CONNECTABLE = BIT(1), }; -struct hids_info -{ +struct hids_info { u16_t version; /* version number of base USB HID Specification */ u8_t code; /* country HID Device hardware is localized for. */ u8_t flags; } __packed; -struct hids_report -{ +struct hids_report { u8_t id; /* report id */ u8_t type; /* report type */ } __packed; @@ -42,8 +39,7 @@ static struct hids_info info = { .flags = HIDS_NORMALLY_CONNECTABLE & HIDS_REMOTE_WAKE, }; -enum -{ +enum { HIDS_INPUT = 0x01, HIDS_OUTPUT = 0x02, HIDS_FEATURE = 0x03, @@ -63,31 +59,37 @@ static bool host_requests_notification = false; static u8_t ctrl_point; // static u8_t proto_mode; -static ssize_t read_hids_info(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, u16_t len, u16_t offset) -{ - return bt_gatt_attr_read(conn, attr, buf, len, offset, attr->user_data, sizeof(struct hids_info)); +static ssize_t read_hids_info(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, + u16_t len, u16_t offset) { + return bt_gatt_attr_read(conn, attr, buf, len, offset, attr->user_data, + sizeof(struct hids_info)); } -static ssize_t read_hids_report_ref(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, u16_t len, u16_t offset) -{ - return bt_gatt_attr_read(conn, attr, buf, len, offset, attr->user_data, sizeof(struct hids_report)); +static ssize_t read_hids_report_ref(struct bt_conn *conn, const struct bt_gatt_attr *attr, + void *buf, u16_t len, u16_t offset) { + return bt_gatt_attr_read(conn, attr, buf, len, offset, attr->user_data, + sizeof(struct hids_report)); } -static ssize_t read_hids_report_map(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, u16_t len, u16_t offset) -{ - return bt_gatt_attr_read(conn, attr, buf, len, offset, zmk_hid_report_desc, sizeof(zmk_hid_report_desc)); +static ssize_t read_hids_report_map(struct bt_conn *conn, const struct bt_gatt_attr *attr, + void *buf, u16_t len, u16_t offset) { + return bt_gatt_attr_read(conn, attr, buf, len, offset, zmk_hid_report_desc, + sizeof(zmk_hid_report_desc)); } -static ssize_t read_hids_input_report(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, u16_t len, u16_t offset) -{ +static ssize_t read_hids_input_report(struct bt_conn *conn, const struct bt_gatt_attr *attr, + void *buf, u16_t len, u16_t offset) { struct zmk_hid_keypad_report_body *report_body = &zmk_hid_get_keypad_report()->body; - return bt_gatt_attr_read(conn, attr, buf, len, offset, report_body, sizeof(struct zmk_hid_keypad_report_body)); + return bt_gatt_attr_read(conn, attr, buf, len, offset, report_body, + sizeof(struct zmk_hid_keypad_report_body)); } -static ssize_t read_hids_consumer_input_report(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, u16_t len, u16_t offset) -{ +static ssize_t read_hids_consumer_input_report(struct bt_conn *conn, + const struct bt_gatt_attr *attr, void *buf, + u16_t len, u16_t offset) { struct zmk_hid_consumer_report_body *report_body = &zmk_hid_get_consumer_report()->body; - return bt_gatt_attr_read(conn, attr, buf, len, offset, report_body, sizeof(struct zmk_hid_consumer_report_body)); + return bt_gatt_attr_read(conn, attr, buf, len, offset, report_body, + sizeof(struct zmk_hid_consumer_report_body)); } // static ssize_t write_proto_mode(struct bt_conn *conn, @@ -99,20 +101,15 @@ static ssize_t read_hids_consumer_input_report(struct bt_conn *conn, const struc // return 0; // } -static void input_ccc_changed(const struct bt_gatt_attr *attr, u16_t value) -{ +static void input_ccc_changed(const struct bt_gatt_attr *attr, u16_t value) { host_requests_notification = (value == BT_GATT_CCC_NOTIFY) ? 1 : 0; } -static ssize_t write_ctrl_point(struct bt_conn *conn, - const struct bt_gatt_attr *attr, - const void *buf, u16_t len, u16_t offset, - u8_t flags) -{ +static ssize_t write_ctrl_point(struct bt_conn *conn, const struct bt_gatt_attr *attr, + const void *buf, u16_t len, u16_t offset, u8_t flags) { u8_t *value = attr->user_data; - if (offset + len > sizeof(ctrl_point)) - { + if (offset + len > sizeof(ctrl_point)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); } @@ -122,35 +119,27 @@ static ssize_t write_ctrl_point(struct bt_conn *conn, } /* HID Service Declaration */ -BT_GATT_SERVICE_DEFINE(hog_svc, - BT_GATT_PRIMARY_SERVICE(BT_UUID_HIDS), - // BT_GATT_CHARACTERISTIC(BT_UUID_HIDS_PROTOCOL_MODE, BT_GATT_CHRC_WRITE_WITHOUT_RESP, - // BT_GATT_PERM_WRITE, NULL, write_proto_mode, &proto_mode), - BT_GATT_CHARACTERISTIC(BT_UUID_HIDS_INFO, BT_GATT_CHRC_READ, - BT_GATT_PERM_READ, read_hids_info, NULL, &info), - BT_GATT_CHARACTERISTIC(BT_UUID_HIDS_REPORT_MAP, BT_GATT_CHRC_READ, - BT_GATT_PERM_READ, read_hids_report_map, NULL, NULL), - - BT_GATT_CHARACTERISTIC(BT_UUID_HIDS_REPORT, - BT_GATT_CHRC_READ | BT_GATT_CHRC_NOTIFY, - BT_GATT_PERM_READ_ENCRYPT, - read_hids_input_report, NULL, NULL), - BT_GATT_CCC(input_ccc_changed, - BT_GATT_PERM_READ_ENCRYPT | BT_GATT_PERM_WRITE_ENCRYPT), - BT_GATT_DESCRIPTOR(BT_UUID_HIDS_REPORT_REF, BT_GATT_PERM_READ, - read_hids_report_ref, NULL, &input), - BT_GATT_CHARACTERISTIC(BT_UUID_HIDS_REPORT, - BT_GATT_CHRC_READ | BT_GATT_CHRC_NOTIFY, - BT_GATT_PERM_READ_ENCRYPT, - read_hids_consumer_input_report, NULL, NULL), - BT_GATT_CCC(input_ccc_changed, - BT_GATT_PERM_READ_ENCRYPT | BT_GATT_PERM_WRITE_ENCRYPT), - BT_GATT_DESCRIPTOR(BT_UUID_HIDS_REPORT_REF, BT_GATT_PERM_READ, - read_hids_report_ref, NULL, &consumer_input), - BT_GATT_CHARACTERISTIC(BT_UUID_HIDS_CTRL_POINT, - BT_GATT_CHRC_WRITE_WITHOUT_RESP, - BT_GATT_PERM_WRITE, - NULL, write_ctrl_point, &ctrl_point)); +BT_GATT_SERVICE_DEFINE( + hog_svc, BT_GATT_PRIMARY_SERVICE(BT_UUID_HIDS), + // BT_GATT_CHARACTERISTIC(BT_UUID_HIDS_PROTOCOL_MODE, BT_GATT_CHRC_WRITE_WITHOUT_RESP, + // BT_GATT_PERM_WRITE, NULL, write_proto_mode, &proto_mode), + BT_GATT_CHARACTERISTIC(BT_UUID_HIDS_INFO, BT_GATT_CHRC_READ, BT_GATT_PERM_READ, read_hids_info, + NULL, &info), + BT_GATT_CHARACTERISTIC(BT_UUID_HIDS_REPORT_MAP, BT_GATT_CHRC_READ, BT_GATT_PERM_READ, + read_hids_report_map, NULL, NULL), + + BT_GATT_CHARACTERISTIC(BT_UUID_HIDS_REPORT, BT_GATT_CHRC_READ | BT_GATT_CHRC_NOTIFY, + BT_GATT_PERM_READ_ENCRYPT, read_hids_input_report, NULL, NULL), + BT_GATT_CCC(input_ccc_changed, BT_GATT_PERM_READ_ENCRYPT | BT_GATT_PERM_WRITE_ENCRYPT), + BT_GATT_DESCRIPTOR(BT_UUID_HIDS_REPORT_REF, BT_GATT_PERM_READ, read_hids_report_ref, NULL, + &input), + BT_GATT_CHARACTERISTIC(BT_UUID_HIDS_REPORT, BT_GATT_CHRC_READ | BT_GATT_CHRC_NOTIFY, + BT_GATT_PERM_READ_ENCRYPT, read_hids_consumer_input_report, NULL, NULL), + BT_GATT_CCC(input_ccc_changed, BT_GATT_PERM_READ_ENCRYPT | BT_GATT_PERM_WRITE_ENCRYPT), + BT_GATT_DESCRIPTOR(BT_UUID_HIDS_REPORT_REF, BT_GATT_PERM_READ, read_hids_report_ref, NULL, + &consumer_input), + BT_GATT_CHARACTERISTIC(BT_UUID_HIDS_CTRL_POINT, BT_GATT_CHRC_WRITE_WITHOUT_RESP, + BT_GATT_PERM_WRITE, NULL, write_ctrl_point, &ctrl_point)); struct bt_conn *destination_connection() { struct bt_conn *conn; @@ -165,11 +154,9 @@ struct bt_conn *destination_connection() { } return conn; - } -int zmk_hog_send_keypad_report(struct zmk_hid_keypad_report_body *report) -{ +int zmk_hog_send_keypad_report(struct zmk_hid_keypad_report_body *report) { struct bt_conn *conn = destination_connection(); if (conn == NULL) { return -ENOTCONN; @@ -177,15 +164,16 @@ int zmk_hog_send_keypad_report(struct zmk_hid_keypad_report_body *report) LOG_DBG("Sending to NULL? %s", conn == NULL ? "yes" : "no"); - return bt_gatt_notify(conn, &hog_svc.attrs[5], report, sizeof(struct zmk_hid_keypad_report_body)); + return bt_gatt_notify(conn, &hog_svc.attrs[5], report, + sizeof(struct zmk_hid_keypad_report_body)); }; -int zmk_hog_send_consumer_report(struct zmk_hid_consumer_report_body *report) -{ +int zmk_hog_send_consumer_report(struct zmk_hid_consumer_report_body *report) { struct bt_conn *conn = destination_connection(); if (conn == NULL) { return -ENOTCONN; } - - return bt_gatt_notify(conn, &hog_svc.attrs[10], report, sizeof(struct zmk_hid_consumer_report_body)); + + return bt_gatt_notify(conn, &hog_svc.attrs[10], report, + sizeof(struct zmk_hid_consumer_report_body)); }; diff --git a/app/src/keymap.c b/app/src/keymap.c index b1c68f1..a87ce04 100644 --- a/app/src/keymap.c +++ b/app/src/keymap.c @@ -24,33 +24,38 @@ static u8_t zmk_keymap_layer_default = 0; #define DT_DRV_COMPAT zmk_keymap -#define LAYER_CHILD_LEN(node) 1+ +#define LAYER_CHILD_LEN(node) 1 + #define ZMK_KEYMAP_NODE DT_DRV_INST(0) -#define ZMK_KEYMAP_LAYERS_LEN (DT_INST_FOREACH_CHILD(0, LAYER_CHILD_LEN) 0) +#define ZMK_KEYMAP_LAYERS_LEN (DT_INST_FOREACH_CHILD(0, LAYER_CHILD_LEN) 0) #define LAYER_NODE(l) DT_PHANDLE_BY_IDX(ZMK_KEYMAP_NODE, layers, l) -#define _TRANSFORM_ENTRY(idx, layer) \ - { .behavior_dev = DT_LABEL(DT_PHANDLE_BY_IDX(layer, bindings, idx)), \ - .param1 = COND_CODE_0(DT_PHA_HAS_CELL_AT_IDX(layer, bindings, idx, param1), (0), (DT_PHA_BY_IDX(layer, bindings, idx, param1))), \ - .param2 = COND_CODE_0(DT_PHA_HAS_CELL_AT_IDX(layer, bindings, idx, param2), (0), (DT_PHA_BY_IDX(layer, bindings, idx, param2))), \ - }, - -#define TRANSFORMED_LAYER(node) \ - { UTIL_LISTIFY(DT_PROP_LEN(node, bindings), _TRANSFORM_ENTRY, node) }, +#define _TRANSFORM_ENTRY(idx, layer) \ + { \ + .behavior_dev = DT_LABEL(DT_PHANDLE_BY_IDX(layer, bindings, idx)), \ + .param1 = COND_CODE_0(DT_PHA_HAS_CELL_AT_IDX(layer, bindings, idx, param1), (0), \ + (DT_PHA_BY_IDX(layer, bindings, idx, param1))), \ + .param2 = COND_CODE_0(DT_PHA_HAS_CELL_AT_IDX(layer, bindings, idx, param2), (0), \ + (DT_PHA_BY_IDX(layer, bindings, idx, param2))), \ + }, +#define TRANSFORMED_LAYER(node) {UTIL_LISTIFY(DT_PROP_LEN(node, bindings), _TRANSFORM_ENTRY, node)}, #if ZMK_KEYMAP_HAS_SENSORS -#define _TRANSFORM_SENSOR_ENTRY(idx, layer) \ - { .behavior_dev = DT_LABEL(DT_PHANDLE_BY_IDX(layer, sensor_bindings, idx)), \ - .param1 = COND_CODE_0(DT_PHA_HAS_CELL_AT_IDX(layer, sensor_bindings, idx, param1), (0), (DT_PHA_BY_IDX(layer, sensor_bindings, idx, param1))), \ - .param2 = COND_CODE_0(DT_PHA_HAS_CELL_AT_IDX(layer, sensor_bindings, idx, param2), (0), (DT_PHA_BY_IDX(layer, sensor_bindings, idx, param2))), \ - }, - -#define SENSOR_LAYER(node) \ - COND_CODE_1(DT_NODE_HAS_PROP(node, sensor_bindings), \ - ({ UTIL_LISTIFY(DT_PROP_LEN(node, sensor_bindings), _TRANSFORM_SENSOR_ENTRY, node) }), \ - ({})), +#define _TRANSFORM_SENSOR_ENTRY(idx, layer) \ + { \ + .behavior_dev = DT_LABEL(DT_PHANDLE_BY_IDX(layer, sensor_bindings, idx)), \ + .param1 = COND_CODE_0(DT_PHA_HAS_CELL_AT_IDX(layer, sensor_bindings, idx, param1), (0), \ + (DT_PHA_BY_IDX(layer, sensor_bindings, idx, param1))), \ + .param2 = COND_CODE_0(DT_PHA_HAS_CELL_AT_IDX(layer, sensor_bindings, idx, param2), (0), \ + (DT_PHA_BY_IDX(layer, sensor_bindings, idx, param2))), \ + }, + +#define SENSOR_LAYER(node) \ + COND_CODE_1( \ + DT_NODE_HAS_PROP(node, sensor_bindings), \ + ({UTIL_LISTIFY(DT_PROP_LEN(node, sensor_bindings), _TRANSFORM_SENSOR_ENTRY, node)}), \ + ({})), #endif /* ZMK_KEYMAP_HAS_SENSORS */ @@ -62,155 +67,142 @@ static u8_t zmk_keymap_layer_default = 0; static u32_t zmk_keymap_active_behavior_layer[ZMK_KEYMAP_LEN]; static struct zmk_behavior_binding zmk_keymap[ZMK_KEYMAP_LAYERS_LEN][ZMK_KEYMAP_LEN] = { - DT_INST_FOREACH_CHILD(0, TRANSFORMED_LAYER) -}; + DT_INST_FOREACH_CHILD(0, TRANSFORMED_LAYER)}; #if ZMK_KEYMAP_HAS_SENSORS -static struct zmk_behavior_binding zmk_sensor_keymap[ZMK_KEYMAP_LAYERS_LEN][ZMK_KEYMAP_SENSORS_LEN] = { - DT_INST_FOREACH_CHILD(0, SENSOR_LAYER) -}; +static struct zmk_behavior_binding zmk_sensor_keymap[ZMK_KEYMAP_LAYERS_LEN] + [ZMK_KEYMAP_SENSORS_LEN] = { + DT_INST_FOREACH_CHILD(0, SENSOR_LAYER)}; #endif /* ZMK_KEYMAP_HAS_SENSORS */ -#define SET_LAYER_STATE(layer, state) \ - if (layer >= 32) \ - { \ - return -EINVAL; \ - } \ - WRITE_BIT(zmk_keymap_layer_state, layer, state); \ - return 0; - -bool zmk_keymap_layer_active(u8_t layer) -{ - return (zmk_keymap_layer_state & (BIT(layer))) == (BIT(layer)); -}; +#define SET_LAYER_STATE(layer, state) \ + if (layer >= 32) { \ + return -EINVAL; \ + } \ + WRITE_BIT(zmk_keymap_layer_state, layer, state); \ + return 0; -int zmk_keymap_layer_activate(u8_t layer) -{ - SET_LAYER_STATE(layer, true); +bool zmk_keymap_layer_active(u8_t layer) { + return (zmk_keymap_layer_state & (BIT(layer))) == (BIT(layer)); }; -int zmk_keymap_layer_deactivate(u8_t layer) -{ - SET_LAYER_STATE(layer, false); -}; +int zmk_keymap_layer_activate(u8_t layer) { SET_LAYER_STATE(layer, true); }; + +int zmk_keymap_layer_deactivate(u8_t layer) { SET_LAYER_STATE(layer, false); }; -int zmk_keymap_layer_toggle(u8_t layer) -{ - if (zmk_keymap_layer_active(layer)) - { - return zmk_keymap_layer_deactivate(layer); - } +int zmk_keymap_layer_toggle(u8_t layer) { + if (zmk_keymap_layer_active(layer)) { + return zmk_keymap_layer_deactivate(layer); + } - return zmk_keymap_layer_activate(layer); + return zmk_keymap_layer_activate(layer); }; -bool is_active_layer(u8_t layer, u32_t layer_state) -{ - return (layer_state & BIT(layer)) == BIT(layer) - || layer == zmk_keymap_layer_default; +bool is_active_layer(u8_t layer, u32_t layer_state) { + return (layer_state & BIT(layer)) == BIT(layer) || layer == zmk_keymap_layer_default; } -int zmk_keymap_apply_position_state(int layer, u32_t position, bool pressed) -{ - struct zmk_behavior_binding *binding = &zmk_keymap[layer][position]; - struct device *behavior; +int zmk_keymap_apply_position_state(int layer, u32_t position, bool pressed) { + struct zmk_behavior_binding *binding = &zmk_keymap[layer][position]; + struct device *behavior; - LOG_DBG("layer: %d position: %d, binding name: %s", layer, position, log_strdup(binding->behavior_dev)); + LOG_DBG("layer: %d position: %d, binding name: %s", layer, position, + log_strdup(binding->behavior_dev)); - behavior = device_get_binding(binding->behavior_dev); + behavior = device_get_binding(binding->behavior_dev); - if (!behavior) { - LOG_DBG("No behavior assigned to %d on layer %d", position, layer); - return 1; - } + if (!behavior) { + LOG_DBG("No behavior assigned to %d on layer %d", position, layer); + return 1; + } - if (pressed) { - return behavior_keymap_binding_pressed(behavior, position, binding->param1, binding->param2); - } else { - return behavior_keymap_binding_released(behavior, position, binding->param1, binding->param2); - } + if (pressed) { + return behavior_keymap_binding_pressed(behavior, position, binding->param1, + binding->param2); + } else { + return behavior_keymap_binding_released(behavior, position, binding->param1, + binding->param2); + } } - -int zmk_keymap_position_state_changed(u32_t position, bool pressed) -{ - for (int layer = ZMK_KEYMAP_LAYERS_LEN - 1; layer >= zmk_keymap_layer_default; layer--) - { - u32_t layer_state = pressed ? zmk_keymap_layer_state : zmk_keymap_active_behavior_layer[position]; - if (is_active_layer(layer, layer_state)) - { - int ret = zmk_keymap_apply_position_state(layer, position, pressed); - - zmk_keymap_active_behavior_layer[position] = zmk_keymap_layer_state; - - if (ret > 0) { - LOG_DBG("behavior processing to continue to next layer"); - continue; - } else if (ret < 0) { - LOG_DBG("Behavior returned error: %d", ret); - return ret; - } else { - return ret; - } - } - } - - return -ENOTSUP; + +int zmk_keymap_position_state_changed(u32_t position, bool pressed) { + for (int layer = ZMK_KEYMAP_LAYERS_LEN - 1; layer >= zmk_keymap_layer_default; layer--) { + u32_t layer_state = + pressed ? zmk_keymap_layer_state : zmk_keymap_active_behavior_layer[position]; + if (is_active_layer(layer, layer_state)) { + int ret = zmk_keymap_apply_position_state(layer, position, pressed); + + zmk_keymap_active_behavior_layer[position] = zmk_keymap_layer_state; + + if (ret > 0) { + LOG_DBG("behavior processing to continue to next layer"); + continue; + } else if (ret < 0) { + LOG_DBG("Behavior returned error: %d", ret); + return ret; + } else { + return ret; + } + } + } + + return -ENOTSUP; } #if ZMK_KEYMAP_HAS_SENSORS -int zmk_keymap_sensor_triggered(u8_t sensor_number, struct device *sensor) -{ - for (int layer = ZMK_KEYMAP_LAYERS_LEN - 1; layer >= zmk_keymap_layer_default; layer--) - { - if (((zmk_keymap_layer_state & BIT(layer)) == BIT(layer) || layer == zmk_keymap_layer_default) && zmk_sensor_keymap[layer] != NULL) - { - struct zmk_behavior_binding *binding = &zmk_sensor_keymap[layer][sensor_number]; - struct device *behavior; - int ret; - - LOG_DBG("layer: %d sensor_number: %d, binding name: %s", layer, sensor_number, log_strdup(binding->behavior_dev)); - - behavior = device_get_binding(binding->behavior_dev); - - if (!behavior) { - LOG_DBG("No behavior assigned to %d on layer %d", sensor_number, layer); - continue; - } - - ret = behavior_sensor_keymap_binding_triggered(behavior, sensor, binding->param1, binding->param2); - - if (ret > 0) { - LOG_DBG("behavior processing to continue to next layer"); - continue; - } else if (ret < 0) { - LOG_DBG("Behavior returned error: %d", ret); - return ret; - } else { - return ret; - } - } - } - - return -ENOTSUP; +int zmk_keymap_sensor_triggered(u8_t sensor_number, struct device *sensor) { + for (int layer = ZMK_KEYMAP_LAYERS_LEN - 1; layer >= zmk_keymap_layer_default; layer--) { + if (((zmk_keymap_layer_state & BIT(layer)) == BIT(layer) || + layer == zmk_keymap_layer_default) && + zmk_sensor_keymap[layer] != NULL) { + struct zmk_behavior_binding *binding = &zmk_sensor_keymap[layer][sensor_number]; + struct device *behavior; + int ret; + + LOG_DBG("layer: %d sensor_number: %d, binding name: %s", layer, sensor_number, + log_strdup(binding->behavior_dev)); + + behavior = device_get_binding(binding->behavior_dev); + + if (!behavior) { + LOG_DBG("No behavior assigned to %d on layer %d", sensor_number, layer); + continue; + } + + ret = behavior_sensor_keymap_binding_triggered(behavior, sensor, binding->param1, + binding->param2); + + if (ret > 0) { + LOG_DBG("behavior processing to continue to next layer"); + continue; + } else if (ret < 0) { + LOG_DBG("Behavior returned error: %d", ret); + return ret; + } else { + return ret; + } + } + } + + return -ENOTSUP; } #endif /* ZMK_KEYMAP_HAS_SENSORS */ -int keymap_listener(const struct zmk_event_header *eh) -{ - if (is_position_state_changed(eh)) { - const struct position_state_changed *ev = cast_position_state_changed(eh); - return zmk_keymap_position_state_changed(ev->position, ev->state); +int keymap_listener(const struct zmk_event_header *eh) { + if (is_position_state_changed(eh)) { + const struct position_state_changed *ev = cast_position_state_changed(eh); + return zmk_keymap_position_state_changed(ev->position, ev->state); #if ZMK_KEYMAP_HAS_SENSORS - } else if (is_sensor_event(eh)) { - const struct sensor_event *ev = cast_sensor_event(eh); - return zmk_keymap_sensor_triggered(ev->sensor_number, ev->sensor); + } else if (is_sensor_event(eh)) { + const struct sensor_event *ev = cast_sensor_event(eh); + return zmk_keymap_sensor_triggered(ev->sensor_number, ev->sensor); #endif /* ZMK_KEYMAP_HAS_SENSORS */ - } + } - return -ENOTSUP; + return -ENOTSUP; } ZMK_LISTENER(keymap, keymap_listener); @@ -219,4 +211,3 @@ ZMK_SUBSCRIPTION(keymap, position_state_changed); #if ZMK_KEYMAP_HAS_SENSORS ZMK_SUBSCRIPTION(keymap, sensor_event); #endif /* ZMK_KEYMAP_HAS_SENSORS */ - diff --git a/app/src/kscan.c b/app/src/kscan.c index 7a4d3a4..0046f5c 100644 --- a/app/src/kscan.c +++ b/app/src/kscan.c @@ -18,61 +18,55 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); #define ZMK_KSCAN_EVENT_STATE_PRESSED 0 #define ZMK_KSCAN_EVENT_STATE_RELEASED 1 -struct zmk_kscan_event -{ - u32_t row; - u32_t column; - u32_t state; +struct zmk_kscan_event { + u32_t row; + u32_t column; + u32_t state; }; -struct zmk_kscan_msg_processor -{ - struct k_work work; +struct zmk_kscan_msg_processor { + struct k_work work; } msg_processor; K_MSGQ_DEFINE(zmk_kscan_msgq, sizeof(struct zmk_kscan_event), CONFIG_ZMK_KSCAN_EVENT_QUEUE_SIZE, 4); -static void zmk_kscan_callback(struct device *dev, u32_t row, u32_t column, bool pressed) -{ - struct zmk_kscan_event ev = { - .row = row, - .column = column, - .state = (pressed ? ZMK_KSCAN_EVENT_STATE_PRESSED : ZMK_KSCAN_EVENT_STATE_RELEASED)}; +static void zmk_kscan_callback(struct device *dev, u32_t row, u32_t column, bool pressed) { + struct zmk_kscan_event ev = { + .row = row, + .column = column, + .state = (pressed ? ZMK_KSCAN_EVENT_STATE_PRESSED : ZMK_KSCAN_EVENT_STATE_RELEASED)}; - k_msgq_put(&zmk_kscan_msgq, &ev, K_NO_WAIT); - k_work_submit(&msg_processor.work); + k_msgq_put(&zmk_kscan_msgq, &ev, K_NO_WAIT); + k_work_submit(&msg_processor.work); } -void zmk_kscan_process_msgq(struct k_work *item) -{ - struct zmk_kscan_event ev; +void zmk_kscan_process_msgq(struct k_work *item) { + struct zmk_kscan_event ev; - while (k_msgq_get(&zmk_kscan_msgq, &ev, K_NO_WAIT) == 0) - { - bool pressed = (ev.state == ZMK_KSCAN_EVENT_STATE_PRESSED); - u32_t position = zmk_matrix_transform_row_column_to_position(ev.row, ev.column); - struct position_state_changed *pos_ev; - LOG_DBG("Row: %d, col: %d, position: %d, pressed: %s\n", ev.row, ev.column, position, (pressed ? "true" : "false")); - pos_ev = new_position_state_changed(); - pos_ev->state = pressed; - pos_ev->position = position; - ZMK_EVENT_RAISE(pos_ev); - } + while (k_msgq_get(&zmk_kscan_msgq, &ev, K_NO_WAIT) == 0) { + bool pressed = (ev.state == ZMK_KSCAN_EVENT_STATE_PRESSED); + u32_t position = zmk_matrix_transform_row_column_to_position(ev.row, ev.column); + struct position_state_changed *pos_ev; + LOG_DBG("Row: %d, col: %d, position: %d, pressed: %s\n", ev.row, ev.column, position, + (pressed ? "true" : "false")); + pos_ev = new_position_state_changed(); + pos_ev->state = pressed; + pos_ev->position = position; + ZMK_EVENT_RAISE(pos_ev); + } } -int zmk_kscan_init(char *name) -{ - struct device *dev = device_get_binding(name); - if (dev == NULL) - { - LOG_ERR("Failed to get the KSCAN device"); - return -EINVAL; - } +int zmk_kscan_init(char *name) { + struct device *dev = device_get_binding(name); + if (dev == NULL) { + LOG_ERR("Failed to get the KSCAN device"); + return -EINVAL; + } - k_work_init(&msg_processor.work, zmk_kscan_process_msgq); + k_work_init(&msg_processor.work, zmk_kscan_process_msgq); - kscan_config(dev, zmk_kscan_callback); - kscan_enable_callback(dev); + kscan_config(dev, zmk_kscan_callback); + kscan_enable_callback(dev); - return 0; + return 0; } diff --git a/app/src/kscan_composite.c b/app/src/kscan_composite.c index 15527eb..0249140 100644 --- a/app/src/kscan_composite.c +++ b/app/src/kscan_composite.c @@ -15,37 +15,31 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); #define MATRIX_ROWS DT_PROP(MATRIX_NODE_ID, rows) #define MATRIX_COLS DT_PROP(MATRIX_NODE_ID, columns) -struct kscan_composite_child_config -{ +struct kscan_composite_child_config { char *label; u8_t row_offset; u8_t column_offset; }; -#define CHILD_CONFIG(inst) \ - { \ - .label = DT_LABEL(DT_PHANDLE(inst, kscan)), \ - .row_offset = DT_PROP(inst, row_offset), \ - .column_offset = DT_PROP(inst, column_offset)}, +#define CHILD_CONFIG(inst) \ + {.label = DT_LABEL(DT_PHANDLE(inst, kscan)), \ + .row_offset = DT_PROP(inst, row_offset), \ + .column_offset = DT_PROP(inst, column_offset)}, const struct kscan_composite_child_config kscan_composite_children[] = { DT_FOREACH_CHILD(MATRIX_NODE_ID, CHILD_CONFIG)}; -struct kscan_composite_config -{ -}; +struct kscan_composite_config {}; -struct kscan_composite_data -{ +struct kscan_composite_data { kscan_callback_t callback; struct device *dev; }; -static int kscan_composite_enable_callback(struct device *dev) -{ - for (int i = 0; i < sizeof(kscan_composite_children) / sizeof(kscan_composite_children[0]); i++) - { +static int kscan_composite_enable_callback(struct device *dev) { + for (int i = 0; i < sizeof(kscan_composite_children) / sizeof(kscan_composite_children[0]); + i++) { const struct kscan_composite_child_config *cfg = &kscan_composite_children[i]; kscan_enable_callback(device_get_binding(cfg->label)); @@ -53,10 +47,9 @@ static int kscan_composite_enable_callback(struct device *dev) return 0; } -static int kscan_composite_disable_callback(struct device *dev) -{ - for (int i = 0; i < sizeof(kscan_composite_children) / sizeof(kscan_composite_children[0]); i++) - { +static int kscan_composite_disable_callback(struct device *dev) { + for (int i = 0; i < sizeof(kscan_composite_children) / sizeof(kscan_composite_children[0]); + i++) { const struct kscan_composite_child_config *cfg = &kscan_composite_children[i]; kscan_disable_callback(device_get_binding(cfg->label)); @@ -64,18 +57,17 @@ static int kscan_composite_disable_callback(struct device *dev) return 0; } -static void kscan_composite_child_callback(struct device *child_dev, u32_t row, u32_t column, bool pressed) -{ +static void kscan_composite_child_callback(struct device *child_dev, u32_t row, u32_t column, + bool pressed) { // TODO: Ideally we can get this passed into our callback! struct device *dev = device_get_binding(DT_INST_LABEL(0)); struct kscan_composite_data *data = dev->driver_data; - for (int i = 0; i < sizeof(kscan_composite_children) / sizeof(kscan_composite_children[0]); i++) - { + for (int i = 0; i < sizeof(kscan_composite_children) / sizeof(kscan_composite_children[0]); + i++) { const struct kscan_composite_child_config *cfg = &kscan_composite_children[i]; - if (device_get_binding(cfg->label) != child_dev) - { + if (device_get_binding(cfg->label) != child_dev) { continue; } @@ -83,17 +75,15 @@ static void kscan_composite_child_callback(struct device *child_dev, u32_t row, } } -static int kscan_composite_configure(struct device *dev, kscan_callback_t callback) -{ +static int kscan_composite_configure(struct device *dev, kscan_callback_t callback) { struct kscan_composite_data *data = dev->driver_data; - if (!callback) - { + if (!callback) { return -EINVAL; } - for (int i = 0; i < sizeof(kscan_composite_children) / sizeof(kscan_composite_children[0]); i++) - { + for (int i = 0; i < sizeof(kscan_composite_children) / sizeof(kscan_composite_children[0]); + i++) { const struct kscan_composite_child_config *cfg = &kscan_composite_children[i]; kscan_config(device_get_binding(cfg->label), &kscan_composite_child_callback); @@ -104,8 +94,7 @@ static int kscan_composite_configure(struct device *dev, kscan_callback_t callba return 0; } -static int kscan_composite_init(struct device *dev) -{ +static int kscan_composite_init(struct device *dev) { struct kscan_composite_data *data = dev->driver_data; data->dev = dev; @@ -123,8 +112,6 @@ static const struct kscan_composite_config kscan_composite_config = {}; static struct kscan_composite_data kscan_composite_data; -DEVICE_AND_API_INIT(kscan_composite, DT_INST_LABEL(0), kscan_composite_init, - &kscan_composite_data, - &kscan_composite_config, - APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, +DEVICE_AND_API_INIT(kscan_composite, DT_INST_LABEL(0), kscan_composite_init, &kscan_composite_data, + &kscan_composite_config, APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &mock_driver_api); diff --git a/app/src/kscan_mock.c b/app/src/kscan_mock.c index 741f6c1..e9c15a0 100644 --- a/app/src/kscan_mock.c +++ b/app/src/kscan_mock.c @@ -15,8 +15,7 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); #include -struct kscan_mock_data -{ +struct kscan_mock_data { kscan_callback_t callback; u8_t event_index; @@ -24,20 +23,17 @@ struct kscan_mock_data struct device *dev; }; -static int kscan_mock_disable_callback(struct device *dev) -{ +static int kscan_mock_disable_callback(struct device *dev) { struct kscan_mock_data *data = dev->driver_data; k_delayed_work_cancel(&data->work); return 0; } -static int kscan_mock_configure(struct device *dev, kscan_callback_t callback) -{ +static int kscan_mock_configure(struct device *dev, kscan_callback_t callback) { struct kscan_mock_data *data = dev->driver_data; - if (!callback) - { + if (!callback) { return -EINVAL; } @@ -47,64 +43,53 @@ static int kscan_mock_configure(struct device *dev, kscan_callback_t callback) return 0; } -#define MOCK_INST_INIT(n) \ - struct kscan_mock_config_##n \ - { \ - u32_t events[DT_INST_PROP_LEN(n, events)]; \ - bool exit_after; \ - }; \ - static void kscan_mock_schedule_next_event_##n(struct device *dev) \ - { \ - struct kscan_mock_data *data = dev->driver_data; \ - const struct kscan_mock_config_##n *cfg = dev->config_info; \ - if (data->event_index < DT_INST_PROP_LEN(n, events)) \ - { \ - u32_t ev = cfg->events[data->event_index]; \ - LOG_DBG("delaying next keypress: %d", ZMK_MOCK_MSEC(ev)); \ - k_delayed_work_submit(&data->work, K_MSEC(ZMK_MOCK_MSEC(ev))); \ - } else if (cfg->exit_after) { \ - LOG_DBG("Exiting"); \ - exit(0); \ - } \ - } \ - static void kscan_mock_work_handler_##n(struct k_work *work) \ - { \ - struct kscan_mock_data *data = \ - CONTAINER_OF(work, struct kscan_mock_data, work); \ - const struct kscan_mock_config_##n *cfg = data->dev->config_info; \ - u32_t ev = cfg->events[data->event_index]; \ - LOG_DBG("ev %u row %d column %d state %d\n", ev, \ - ZMK_MOCK_ROW(ev), ZMK_MOCK_COL(ev), ZMK_MOCK_IS_PRESS(ev)); \ - data->callback(data->dev, \ - ZMK_MOCK_ROW(ev), ZMK_MOCK_COL(ev), ZMK_MOCK_IS_PRESS(ev)); \ - kscan_mock_schedule_next_event_##n(data->dev); \ - data->event_index++; \ - } \ - static int kscan_mock_init_##n(struct device *dev) \ - { \ - struct kscan_mock_data *data = dev->driver_data; \ - data->dev = dev; \ - k_delayed_work_init(&data->work, kscan_mock_work_handler_##n); \ - return 0; \ - } \ - static int kscan_mock_enable_callback_##n(struct device *dev) \ - { \ - kscan_mock_schedule_next_event_##n(dev); \ - return 0; \ - } \ - static const struct kscan_driver_api mock_driver_api_##n = { \ - .config = kscan_mock_configure, \ - .enable_callback = kscan_mock_enable_callback_##n, \ - .disable_callback = kscan_mock_disable_callback, \ - }; \ - static struct kscan_mock_data kscan_mock_data_##n; \ - static const struct kscan_mock_config_##n kscan_mock_config_##n = { \ - .events = DT_INST_PROP(n, events), \ - .exit_after = DT_INST_PROP(n, exit_after) }; \ - DEVICE_AND_API_INIT(kscan_mock_##n, DT_INST_LABEL(n), kscan_mock_init_##n, \ - &kscan_mock_data_##n, \ - &kscan_mock_config_##n, \ - APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, \ - &mock_driver_api_##n); +#define MOCK_INST_INIT(n) \ + struct kscan_mock_config_##n { \ + u32_t events[DT_INST_PROP_LEN(n, events)]; \ + bool exit_after; \ + }; \ + static void kscan_mock_schedule_next_event_##n(struct device *dev) { \ + struct kscan_mock_data *data = dev->driver_data; \ + const struct kscan_mock_config_##n *cfg = dev->config_info; \ + if (data->event_index < DT_INST_PROP_LEN(n, events)) { \ + u32_t ev = cfg->events[data->event_index]; \ + LOG_DBG("delaying next keypress: %d", ZMK_MOCK_MSEC(ev)); \ + k_delayed_work_submit(&data->work, K_MSEC(ZMK_MOCK_MSEC(ev))); \ + } else if (cfg->exit_after) { \ + LOG_DBG("Exiting"); \ + exit(0); \ + } \ + } \ + static void kscan_mock_work_handler_##n(struct k_work *work) { \ + struct kscan_mock_data *data = CONTAINER_OF(work, struct kscan_mock_data, work); \ + const struct kscan_mock_config_##n *cfg = data->dev->config_info; \ + u32_t ev = cfg->events[data->event_index]; \ + LOG_DBG("ev %u row %d column %d state %d\n", ev, ZMK_MOCK_ROW(ev), ZMK_MOCK_COL(ev), \ + ZMK_MOCK_IS_PRESS(ev)); \ + data->callback(data->dev, ZMK_MOCK_ROW(ev), ZMK_MOCK_COL(ev), ZMK_MOCK_IS_PRESS(ev)); \ + kscan_mock_schedule_next_event_##n(data->dev); \ + data->event_index++; \ + } \ + static int kscan_mock_init_##n(struct device *dev) { \ + struct kscan_mock_data *data = dev->driver_data; \ + data->dev = dev; \ + k_delayed_work_init(&data->work, kscan_mock_work_handler_##n); \ + return 0; \ + } \ + static int kscan_mock_enable_callback_##n(struct device *dev) { \ + kscan_mock_schedule_next_event_##n(dev); \ + return 0; \ + } \ + static const struct kscan_driver_api mock_driver_api_##n = { \ + .config = kscan_mock_configure, \ + .enable_callback = kscan_mock_enable_callback_##n, \ + .disable_callback = kscan_mock_disable_callback, \ + }; \ + static struct kscan_mock_data kscan_mock_data_##n; \ + static const struct kscan_mock_config_##n kscan_mock_config_##n = { \ + .events = DT_INST_PROP(n, events), .exit_after = DT_INST_PROP(n, exit_after)}; \ + DEVICE_AND_API_INIT(kscan_mock_##n, DT_INST_LABEL(n), kscan_mock_init_##n, \ + &kscan_mock_data_##n, &kscan_mock_config_##n, APPLICATION, \ + CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &mock_driver_api_##n); DT_INST_FOREACH_STATUS_OKAY(MOCK_INST_INIT) diff --git a/app/src/main.c b/app/src/main.c index 5da272e..dca923e 100644 --- a/app/src/main.c +++ b/app/src/main.c @@ -18,20 +18,18 @@ LOG_MODULE_REGISTER(zmk, CONFIG_ZMK_LOG_LEVEL); #define ZMK_KSCAN_DEV DT_LABEL(ZMK_MATRIX_NODE_ID) -void main(void) -{ - LOG_INF("Welcome to ZMK!\n"); +void main(void) { + LOG_INF("Welcome to ZMK!\n"); - if (zmk_kscan_init(ZMK_KSCAN_DEV) != 0) - { - return; - } + if (zmk_kscan_init(ZMK_KSCAN_DEV) != 0) { + return; + } #ifdef CONFIG_ZMK_DISPLAY - zmk_display_init(); + zmk_display_init(); - while (1) { - zmk_display_task_handler(); - } + while (1) { + zmk_display_task_handler(); + } #endif /* CONFIG_ZMK_DISPLAY */ } diff --git a/app/src/matrix_transform.c b/app/src/matrix_transform.c index 8a037b3..4e68a56 100644 --- a/app/src/matrix_transform.c +++ b/app/src/matrix_transform.c @@ -11,16 +11,15 @@ #ifdef ZMK_KEYMAP_TRANSFORM_NODE -#define _TRANSFORM_ENTRY(i, _) \ - [(KT_ROW(DT_PROP_BY_IDX(ZMK_KEYMAP_TRANSFORM_NODE, map, i)) * ZMK_MATRIX_COLS) + KT_COL(DT_PROP_BY_IDX(ZMK_KEYMAP_TRANSFORM_NODE, map, i))] = i, +#define _TRANSFORM_ENTRY(i, _) \ + [(KT_ROW(DT_PROP_BY_IDX(ZMK_KEYMAP_TRANSFORM_NODE, map, i)) * ZMK_MATRIX_COLS) + \ + KT_COL(DT_PROP_BY_IDX(ZMK_KEYMAP_TRANSFORM_NODE, map, i))] = i, -static u32_t transform[] = - { UTIL_LISTIFY(ZMK_KEYMAP_LEN, _TRANSFORM_ENTRY, 0) }; +static u32_t transform[] = {UTIL_LISTIFY(ZMK_KEYMAP_LEN, _TRANSFORM_ENTRY, 0)}; #endif -u32_t zmk_matrix_transform_row_column_to_position(u32_t row, u32_t column) -{ +u32_t zmk_matrix_transform_row_column_to_position(u32_t row, u32_t column) { u32_t matrix_index; #if DT_NODE_HAS_PROP(ZMK_KEYMAP_TRANSFORM_NODE, col_offset) diff --git a/app/src/rgb_underglow.c b/app/src/rgb_underglow.c index 97c2ac0..13912e3 100644 --- a/app/src/rgb_underglow.c +++ b/app/src/rgb_underglow.c @@ -18,8 +18,8 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); -#define STRIP_LABEL DT_LABEL(DT_CHOSEN(zmk_underglow)) -#define STRIP_NUM_PIXELS DT_PROP(DT_CHOSEN(zmk_underglow), chain_length) +#define STRIP_LABEL DT_LABEL(DT_CHOSEN(zmk_underglow)) +#define STRIP_NUM_PIXELS DT_PROP(DT_CHOSEN(zmk_underglow), chain_length) enum rgb_underglow_effect { UNDERGLOW_EFFECT_SOLID, @@ -30,19 +30,19 @@ enum rgb_underglow_effect { }; struct led_hsb { - u16_t h; - u8_t s; - u8_t b; + u16_t h; + u8_t s; + u8_t b; }; struct rgb_underglow_state { u16_t hue; - u8_t saturation; - u8_t brightness; - u8_t animation_speed; - u8_t current_effect; + u8_t saturation; + u8_t brightness; + u8_t animation_speed; + u8_t current_effect; u16_t animation_step; - bool on; + bool on; }; struct rgb_underglow_state state; @@ -51,8 +51,7 @@ struct device *led_strip; struct led_rgb pixels[STRIP_NUM_PIXELS]; -static struct led_rgb hsb_to_rgb(struct led_hsb hsb) -{ +static struct led_rgb hsb_to_rgb(struct led_hsb hsb) { double r, g, b; u8_t i = hsb.h / 60; @@ -63,64 +62,81 @@ static struct led_rgb hsb_to_rgb(struct led_hsb hsb) double q = v * (1 - f * s); double t = v * (1 - (1 - f) * s); - switch (i % 6) - { - case 0: r = v; g = t; b = p; break; - case 1: r = q; g = v; b = p; break; - case 2: r = p; g = v; b = t; break; - case 3: r = p; g = q; b = v; break; - case 4: r = t; g = p; b = v; break; - case 5: r = v; g = p; b = q; break; + switch (i % 6) { + case 0: + r = v; + g = t; + b = p; + break; + case 1: + r = q; + g = v; + b = p; + break; + case 2: + r = p; + g = v; + b = t; + break; + case 3: + r = p; + g = q; + b = v; + break; + case 4: + r = t; + g = p; + b = v; + break; + case 5: + r = v; + g = p; + b = q; + break; } - struct led_rgb rgb = { r: r*255, g: g*255, b: b*255 }; + struct led_rgb rgb = {r : r * 255, g : g * 255, b : b * 255}; return rgb; } -static void zmk_rgb_underglow_effect_solid() -{ - for (int i=0; i 2400) { state.animation_step = 0; } } -static void zmk_rgb_underglow_effect_spectrum() -{ - for (int i=0; i= UNDERGLOW_EFFECT_NUMBER) { state.current_effect = 0; } - + state.animation_step = 0; return 0; } -int zmk_rgb_underglow_toggle() -{ - if (!led_strip) return -ENODEV; +int zmk_rgb_underglow_toggle() { + if (!led_strip) + return -ENODEV; state.on = !state.on; @@ -232,9 +242,8 @@ int zmk_rgb_underglow_toggle() k_timer_start(&underglow_tick, K_NO_WAIT, K_MSEC(50)); } else { - for (int i=0; i 350) { @@ -263,9 +272,9 @@ int zmk_rgb_underglow_change_hue(int direction) return 0; } -int zmk_rgb_underglow_change_sat(int direction) -{ - if (!led_strip) return -ENODEV; +int zmk_rgb_underglow_change_sat(int direction) { + if (!led_strip) + return -ENODEV; if (state.saturation == 0 && direction < 0) { return 0; @@ -280,9 +289,9 @@ int zmk_rgb_underglow_change_sat(int direction) return 0; } -int zmk_rgb_underglow_change_brt(int direction) -{ - if (!led_strip) return -ENODEV; +int zmk_rgb_underglow_change_brt(int direction) { + if (!led_strip) + return -ENODEV; if (state.brightness == 0 && direction < 0) { return 0; @@ -297,9 +306,9 @@ int zmk_rgb_underglow_change_brt(int direction) return 0; } -int zmk_rgb_underglow_change_spd(int direction) -{ - if (!led_strip) return -ENODEV; +int zmk_rgb_underglow_change_spd(int direction) { + if (!led_strip) + return -ENODEV; if (state.animation_speed == 1 && direction < 0) { return 0; @@ -314,6 +323,4 @@ int zmk_rgb_underglow_change_spd(int direction) return 0; } -SYS_INIT(zmk_rgb_underglow_init, - APPLICATION, - CONFIG_APPLICATION_INIT_PRIORITY); +SYS_INIT(zmk_rgb_underglow_init, APPLICATION, CONFIG_APPLICATION_INIT_PRIORITY); diff --git a/app/src/sensors.c b/app/src/sensors.c index 7a7c0c5..15f374b 100644 --- a/app/src/sensors.c +++ b/app/src/sensors.c @@ -24,19 +24,19 @@ struct sensors_data_item { struct sensor_trigger trigger; }; -#define _SENSOR_ITEM(node) {.dev = NULL, .trigger = { .type = SENSOR_TRIG_DELTA, .chan = SENSOR_CHAN_ROTATION } }, -#define SENSOR_ITEM(idx, _) COND_CODE_1(DT_NODE_HAS_STATUS(ZMK_KEYMAP_SENSORS_BY_IDX(idx),okay), (_SENSOR_ITEM(ZMK_KEYMAP_SENSORS_BY_IDX(idx))),()) +#define _SENSOR_ITEM(node) \ + {.dev = NULL, .trigger = {.type = SENSOR_TRIG_DELTA, .chan = SENSOR_CHAN_ROTATION}}, +#define SENSOR_ITEM(idx, _) \ + COND_CODE_1(DT_NODE_HAS_STATUS(ZMK_KEYMAP_SENSORS_BY_IDX(idx), okay), \ + (_SENSOR_ITEM(ZMK_KEYMAP_SENSORS_BY_IDX(idx))), ()) -static struct sensors_data_item sensors[] = { - UTIL_LISTIFY(ZMK_KEYMAP_SENSORS_LEN, SENSOR_ITEM, 0) -}; +static struct sensors_data_item sensors[] = {UTIL_LISTIFY(ZMK_KEYMAP_SENSORS_LEN, SENSOR_ITEM, 0)}; -static void zmk_sensors_trigger_handler(struct device *dev, struct sensor_trigger *trigger) -{ +static void zmk_sensors_trigger_handler(struct device *dev, struct sensor_trigger *trigger) { int err; - struct sensors_data_item * item = CONTAINER_OF(trigger, struct sensors_data_item, trigger); + struct sensors_data_item *item = CONTAINER_OF(trigger, struct sensors_data_item, trigger); struct sensor_event *event; - + LOG_DBG("sensor %d", item->sensor_number); err = sensor_sample_fetch(dev); @@ -52,8 +52,7 @@ static void zmk_sensors_trigger_handler(struct device *dev, struct sensor_trigge ZMK_EVENT_RAISE(event); } -static void zmk_sensors_init_item(const char *node, u8_t i, u8_t abs_i) -{ +static void zmk_sensors_init_item(const char *node, u8_t i, u8_t abs_i) { LOG_DBG("Init %s at index %d with sensor_number %d", node, i, abs_i); sensors[i].dev = device_get_binding(node); @@ -68,10 +67,11 @@ static void zmk_sensors_init_item(const char *node, u8_t i, u8_t abs_i) } #define _SENSOR_INIT(node) zmk_sensors_init_item(DT_LABEL(node), local_index++, absolute_index++); -#define SENSOR_INIT(idx, _i) COND_CODE_1(DT_NODE_HAS_STATUS(ZMK_KEYMAP_SENSORS_BY_IDX(idx),okay), (_SENSOR_INIT(ZMK_KEYMAP_SENSORS_BY_IDX(idx))),(absolute_index++;)) +#define SENSOR_INIT(idx, _i) \ + COND_CODE_1(DT_NODE_HAS_STATUS(ZMK_KEYMAP_SENSORS_BY_IDX(idx), okay), \ + (_SENSOR_INIT(ZMK_KEYMAP_SENSORS_BY_IDX(idx))), (absolute_index++;)) -static int zmk_sensors_init(struct device *_arg) -{ +static int zmk_sensors_init(struct device *_arg) { int local_index = 0; int absolute_index = 0; @@ -79,8 +79,6 @@ static int zmk_sensors_init(struct device *_arg) return 0; } -SYS_INIT(zmk_sensors_init, - APPLICATION, - CONFIG_APPLICATION_INIT_PRIORITY); +SYS_INIT(zmk_sensors_init, APPLICATION, CONFIG_APPLICATION_INIT_PRIORITY); #endif /* ZMK_KEYMAP_HAS_SENSORS */ \ No newline at end of file diff --git a/app/src/split/bluetooth/central.c b/app/src/split/bluetooth/central.c index 6d8b435..cb1b68b 100644 --- a/app/src/split/bluetooth/central.c +++ b/app/src/split/bluetooth/central.c @@ -33,303 +33,290 @@ static struct bt_uuid_128 uuid = BT_UUID_INIT_128(ZMK_SPLIT_BT_SERVICE_UUID); static struct bt_gatt_discover_params discover_params; static struct bt_gatt_subscribe_params subscribe_params; -static u8_t split_central_notify_func(struct bt_conn *conn, - struct bt_gatt_subscribe_params *params, - const void *data, u16_t length) -{ - static u8_t position_state[POSITION_STATE_DATA_LEN]; - - u8_t changed_positions[POSITION_STATE_DATA_LEN]; - - if (!data) { - LOG_DBG("[UNSUBSCRIBED]"); - params->value_handle = 0U; - return BT_GATT_ITER_STOP; - } - - LOG_DBG("[NOTIFICATION] data %p length %u", data, length); - - for (int i = 0; i < POSITION_STATE_DATA_LEN; i++) { - changed_positions[i] = ((u8_t *)data)[i] ^ position_state[i]; - position_state[i] = ((u8_t *)data)[i]; - } - - for (int i = 0; i < POSITION_STATE_DATA_LEN; i++) { - for (int j = 0; j < 8; j++) { - if (changed_positions[i] & BIT(j)) { - u32_t position = (i * 8) + j; - bool pressed = position_state[i] & BIT(j); - struct position_state_changed *pos_ev = new_position_state_changed(); - pos_ev->position = position; - pos_ev->state = pressed; - - LOG_DBG("Trigger key position state change for %d", position); - ZMK_EVENT_RAISE(pos_ev); - } - } - } - - - return BT_GATT_ITER_CONTINUE; +static u8_t split_central_notify_func(struct bt_conn *conn, struct bt_gatt_subscribe_params *params, + const void *data, u16_t length) { + static u8_t position_state[POSITION_STATE_DATA_LEN]; + + u8_t changed_positions[POSITION_STATE_DATA_LEN]; + + if (!data) { + LOG_DBG("[UNSUBSCRIBED]"); + params->value_handle = 0U; + return BT_GATT_ITER_STOP; + } + + LOG_DBG("[NOTIFICATION] data %p length %u", data, length); + + for (int i = 0; i < POSITION_STATE_DATA_LEN; i++) { + changed_positions[i] = ((u8_t *)data)[i] ^ position_state[i]; + position_state[i] = ((u8_t *)data)[i]; + } + + for (int i = 0; i < POSITION_STATE_DATA_LEN; i++) { + for (int j = 0; j < 8; j++) { + if (changed_positions[i] & BIT(j)) { + u32_t position = (i * 8) + j; + bool pressed = position_state[i] & BIT(j); + struct position_state_changed *pos_ev = new_position_state_changed(); + pos_ev->position = position; + pos_ev->state = pressed; + + LOG_DBG("Trigger key position state change for %d", position); + ZMK_EVENT_RAISE(pos_ev); + } + } + } + + return BT_GATT_ITER_CONTINUE; } -static int split_central_subscribe(struct bt_conn *conn) -{ - int err = bt_gatt_subscribe(conn, &subscribe_params); - switch (err) { - case -EALREADY: - LOG_DBG("[ALREADY SUBSCRIBED]"); - break; - // break; - // bt_gatt_unsubscribe(conn, &subscribe_params); - // return split_central_subscribe(conn); - case 0: - LOG_DBG("[SUBSCRIBED]"); - break; - default: - LOG_ERR("Subscribe failed (err %d)", err); - break; - } - - return 0; +static int split_central_subscribe(struct bt_conn *conn) { + int err = bt_gatt_subscribe(conn, &subscribe_params); + switch (err) { + case -EALREADY: + LOG_DBG("[ALREADY SUBSCRIBED]"); + break; + // break; + // bt_gatt_unsubscribe(conn, &subscribe_params); + // return split_central_subscribe(conn); + case 0: + LOG_DBG("[SUBSCRIBED]"); + break; + default: + LOG_ERR("Subscribe failed (err %d)", err); + break; + } + + return 0; } -static u8_t split_central_discovery_func(struct bt_conn *conn, - const struct bt_gatt_attr *attr, - struct bt_gatt_discover_params *params) -{ - int err; - - if (!attr) { - LOG_DBG("Discover complete"); - (void)memset(params, 0, sizeof(*params)); - return BT_GATT_ITER_STOP; - } - - LOG_DBG("[ATTRIBUTE] handle %u", attr->handle); - - if (!bt_uuid_cmp(discover_params.uuid, BT_UUID_DECLARE_128(ZMK_SPLIT_BT_SERVICE_UUID))) { - memcpy(&uuid, BT_UUID_DECLARE_128(ZMK_SPLIT_BT_CHAR_POSITION_STATE_UUID), sizeof(uuid)); - discover_params.uuid = &uuid.uuid; - discover_params.start_handle = attr->handle + 1; - discover_params.type = BT_GATT_DISCOVER_CHARACTERISTIC; - - err = bt_gatt_discover(conn, &discover_params); - if (err) { - LOG_ERR("Discover failed (err %d)", err); - } - } else if (!bt_uuid_cmp(discover_params.uuid, - BT_UUID_DECLARE_128(ZMK_SPLIT_BT_CHAR_POSITION_STATE_UUID))) { - memcpy(&uuid, BT_UUID_GATT_CCC, sizeof(uuid)); - discover_params.uuid = &uuid.uuid; - discover_params.start_handle = attr->handle + 2; - discover_params.type = BT_GATT_DISCOVER_DESCRIPTOR; - subscribe_params.value_handle = bt_gatt_attr_value_handle(attr); - - err = bt_gatt_discover(conn, &discover_params); - if (err) { - LOG_ERR("Discover failed (err %d)", err); - } - } else { - subscribe_params.notify = split_central_notify_func; - subscribe_params.value = BT_GATT_CCC_NOTIFY; - subscribe_params.ccc_handle = attr->handle; - - split_central_subscribe(conn); - - return BT_GATT_ITER_STOP; - } - - return BT_GATT_ITER_STOP; +static u8_t split_central_discovery_func(struct bt_conn *conn, const struct bt_gatt_attr *attr, + struct bt_gatt_discover_params *params) { + int err; + + if (!attr) { + LOG_DBG("Discover complete"); + (void)memset(params, 0, sizeof(*params)); + return BT_GATT_ITER_STOP; + } + + LOG_DBG("[ATTRIBUTE] handle %u", attr->handle); + + if (!bt_uuid_cmp(discover_params.uuid, BT_UUID_DECLARE_128(ZMK_SPLIT_BT_SERVICE_UUID))) { + memcpy(&uuid, BT_UUID_DECLARE_128(ZMK_SPLIT_BT_CHAR_POSITION_STATE_UUID), sizeof(uuid)); + discover_params.uuid = &uuid.uuid; + discover_params.start_handle = attr->handle + 1; + discover_params.type = BT_GATT_DISCOVER_CHARACTERISTIC; + + err = bt_gatt_discover(conn, &discover_params); + if (err) { + LOG_ERR("Discover failed (err %d)", err); + } + } else if (!bt_uuid_cmp(discover_params.uuid, + BT_UUID_DECLARE_128(ZMK_SPLIT_BT_CHAR_POSITION_STATE_UUID))) { + memcpy(&uuid, BT_UUID_GATT_CCC, sizeof(uuid)); + discover_params.uuid = &uuid.uuid; + discover_params.start_handle = attr->handle + 2; + discover_params.type = BT_GATT_DISCOVER_DESCRIPTOR; + subscribe_params.value_handle = bt_gatt_attr_value_handle(attr); + + err = bt_gatt_discover(conn, &discover_params); + if (err) { + LOG_ERR("Discover failed (err %d)", err); + } + } else { + subscribe_params.notify = split_central_notify_func; + subscribe_params.value = BT_GATT_CCC_NOTIFY; + subscribe_params.ccc_handle = attr->handle; + + split_central_subscribe(conn); + + return BT_GATT_ITER_STOP; + } + + return BT_GATT_ITER_STOP; } static void split_central_process_connection(struct bt_conn *conn) { - int err; - - LOG_DBG("Current security for connection: %d", bt_conn_get_security(conn)); - - err = bt_conn_set_security(conn, BT_SECURITY_L2); - if (err) { - LOG_ERR("Failed to set security (reason %d)", err); - return; - } - - if (conn == default_conn && !subscribe_params.value) { - discover_params.uuid = &uuid.uuid; - discover_params.func = split_central_discovery_func; - discover_params.start_handle = 0x0001; - discover_params.end_handle = 0xffff; - discover_params.type = BT_GATT_DISCOVER_PRIMARY; - - err = bt_gatt_discover(default_conn, &discover_params); - if (err) { - LOG_ERR("Discover failed(err %d)", err); - return; - } - } - - struct bt_conn_info info; - - bt_conn_get_info(conn, &info); - - LOG_DBG("New connection params: Interval: %d, Latency: %d, PHY: %d", info.le.interval, info.le.latency, info.le.phy->rx_phy); + int err; + + LOG_DBG("Current security for connection: %d", bt_conn_get_security(conn)); + + err = bt_conn_set_security(conn, BT_SECURITY_L2); + if (err) { + LOG_ERR("Failed to set security (reason %d)", err); + return; + } + + if (conn == default_conn && !subscribe_params.value) { + discover_params.uuid = &uuid.uuid; + discover_params.func = split_central_discovery_func; + discover_params.start_handle = 0x0001; + discover_params.end_handle = 0xffff; + discover_params.type = BT_GATT_DISCOVER_PRIMARY; + + err = bt_gatt_discover(default_conn, &discover_params); + if (err) { + LOG_ERR("Discover failed(err %d)", err); + return; + } + } + + struct bt_conn_info info; + + bt_conn_get_info(conn, &info); + + LOG_DBG("New connection params: Interval: %d, Latency: %d, PHY: %d", info.le.interval, + info.le.latency, info.le.phy->rx_phy); } -static bool split_central_eir_found(struct bt_data *data, void *user_data) -{ - bt_addr_le_t *addr = user_data; - int i; +static bool split_central_eir_found(struct bt_data *data, void *user_data) { + bt_addr_le_t *addr = user_data; + int i; - LOG_DBG("[AD]: %u data_len %u", data->type, data->data_len); + LOG_DBG("[AD]: %u data_len %u", data->type, data->data_len); - switch (data->type) { - case BT_DATA_UUID128_SOME: - case BT_DATA_UUID128_ALL: - if (data->data_len % 16 != 0U) { - LOG_ERR("AD malformed"); - return true; - } + switch (data->type) { + case BT_DATA_UUID128_SOME: + case BT_DATA_UUID128_ALL: + if (data->data_len % 16 != 0U) { + LOG_ERR("AD malformed"); + return true; + } - for (i = 0; i < data->data_len; i += 16) { - struct bt_le_conn_param *param; - struct bt_uuid uuid; - int err; + for (i = 0; i < data->data_len; i += 16) { + struct bt_le_conn_param *param; + struct bt_uuid uuid; + int err; if (!bt_uuid_create(&uuid, &data->data[i], 16)) { LOG_ERR("Unable to load UUID"); continue; } - if (!bt_uuid_cmp(&uuid, BT_UUID_DECLARE_128(ZMK_SPLIT_BT_SERVICE_UUID))) { - char uuid_str[BT_UUID_STR_LEN]; - char service_uuid_str[BT_UUID_STR_LEN]; - - bt_uuid_to_str(&uuid, uuid_str, sizeof(uuid_str)); - bt_uuid_to_str(BT_UUID_DECLARE_128(ZMK_SPLIT_BT_SERVICE_UUID), service_uuid_str, sizeof(service_uuid_str)); - LOG_DBG("UUID %s does not match split UUID: %s", log_strdup(uuid_str), log_strdup(service_uuid_str)); - continue; - } - - LOG_DBG("Found the split service"); - - zmk_ble_set_peripheral_addr(addr); - - err = bt_le_scan_stop(); - if (err) { - LOG_ERR("Stop LE scan failed (err %d)", err); - continue; - } - - default_conn = bt_conn_lookup_addr_le(BT_ID_DEFAULT, addr); - if (default_conn) { - LOG_DBG("Found existing connection"); - split_central_process_connection(default_conn); - } else { - param = BT_LE_CONN_PARAM(0x0006, 0x0006, 30, 400); - - err = bt_conn_le_create(addr, BT_CONN_LE_CREATE_CONN, - param, &default_conn); - if (err) { - LOG_ERR("Create conn failed (err %d) (create conn? 0x%04x)", err, BT_HCI_OP_LE_CREATE_CONN); - start_scan(); - } - - err = bt_conn_le_phy_update(default_conn, BT_CONN_LE_PHY_PARAM_2M); - if (err) { - LOG_ERR("Update phy conn failed (err %d)", err); - start_scan(); - } - } - - return false; - } - } - - return true; + if (!bt_uuid_cmp(&uuid, BT_UUID_DECLARE_128(ZMK_SPLIT_BT_SERVICE_UUID))) { + char uuid_str[BT_UUID_STR_LEN]; + char service_uuid_str[BT_UUID_STR_LEN]; + + bt_uuid_to_str(&uuid, uuid_str, sizeof(uuid_str)); + bt_uuid_to_str(BT_UUID_DECLARE_128(ZMK_SPLIT_BT_SERVICE_UUID), service_uuid_str, + sizeof(service_uuid_str)); + LOG_DBG("UUID %s does not match split UUID: %s", log_strdup(uuid_str), + log_strdup(service_uuid_str)); + continue; + } + + LOG_DBG("Found the split service"); + + zmk_ble_set_peripheral_addr(addr); + + err = bt_le_scan_stop(); + if (err) { + LOG_ERR("Stop LE scan failed (err %d)", err); + continue; + } + + default_conn = bt_conn_lookup_addr_le(BT_ID_DEFAULT, addr); + if (default_conn) { + LOG_DBG("Found existing connection"); + split_central_process_connection(default_conn); + } else { + param = BT_LE_CONN_PARAM(0x0006, 0x0006, 30, 400); + + err = bt_conn_le_create(addr, BT_CONN_LE_CREATE_CONN, param, &default_conn); + if (err) { + LOG_ERR("Create conn failed (err %d) (create conn? 0x%04x)", err, + BT_HCI_OP_LE_CREATE_CONN); + start_scan(); + } + + err = bt_conn_le_phy_update(default_conn, BT_CONN_LE_PHY_PARAM_2M); + if (err) { + LOG_ERR("Update phy conn failed (err %d)", err); + start_scan(); + } + } + + return false; + } + } + + return true; } static void split_central_device_found(const bt_addr_le_t *addr, s8_t rssi, u8_t type, - struct net_buf_simple *ad) -{ - char dev[BT_ADDR_LE_STR_LEN]; - - bt_addr_le_to_str(addr, dev, sizeof(dev)); - LOG_DBG("[DEVICE]: %s, AD evt type %u, AD data len %u, RSSI %i", - log_strdup(dev), type, ad->len, rssi); - - /* We're only interested in connectable events */ - if (type == BT_GAP_ADV_TYPE_ADV_IND || - type == BT_GAP_ADV_TYPE_ADV_DIRECT_IND) { - bt_data_parse(ad, split_central_eir_found, (void *)addr); - } + struct net_buf_simple *ad) { + char dev[BT_ADDR_LE_STR_LEN]; + + bt_addr_le_to_str(addr, dev, sizeof(dev)); + LOG_DBG("[DEVICE]: %s, AD evt type %u, AD data len %u, RSSI %i", log_strdup(dev), type, ad->len, + rssi); + + /* We're only interested in connectable events */ + if (type == BT_GAP_ADV_TYPE_ADV_IND || type == BT_GAP_ADV_TYPE_ADV_DIRECT_IND) { + bt_data_parse(ad, split_central_eir_found, (void *)addr); + } } -static int start_scan(void) -{ - int err; +static int start_scan(void) { + int err; - err = bt_le_scan_start(BT_LE_SCAN_PASSIVE, split_central_device_found); - if (err) { - LOG_ERR("Scanning failed to start (err %d)", err); - return err; - } + err = bt_le_scan_start(BT_LE_SCAN_PASSIVE, split_central_device_found); + if (err) { + LOG_ERR("Scanning failed to start (err %d)", err); + return err; + } - LOG_DBG("Scanning successfully started"); + LOG_DBG("Scanning successfully started"); return 0; } -static void split_central_connected(struct bt_conn *conn, u8_t conn_err) -{ - char addr[BT_ADDR_LE_STR_LEN]; - - bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr)); +static void split_central_connected(struct bt_conn *conn, u8_t conn_err) { + char addr[BT_ADDR_LE_STR_LEN]; + bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr)); - if (conn_err) { - LOG_ERR("Failed to connect to %s (%u)", log_strdup(addr), conn_err); + if (conn_err) { + LOG_ERR("Failed to connect to %s (%u)", log_strdup(addr), conn_err); - bt_conn_unref(default_conn); - default_conn = NULL; + bt_conn_unref(default_conn); + default_conn = NULL; - start_scan(); - return; - } + start_scan(); + return; + } - LOG_DBG("Connected: %s", log_strdup(addr)); + LOG_DBG("Connected: %s", log_strdup(addr)); - split_central_process_connection(conn); + split_central_process_connection(conn); } -static void split_central_disconnected(struct bt_conn *conn, u8_t reason) -{ - char addr[BT_ADDR_LE_STR_LEN]; +static void split_central_disconnected(struct bt_conn *conn, u8_t reason) { + char addr[BT_ADDR_LE_STR_LEN]; - bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr)); + bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr)); - LOG_DBG("Disconnected: %s (reason %d)", log_strdup(addr), reason); + LOG_DBG("Disconnected: %s (reason %d)", log_strdup(addr), reason); - if (default_conn != conn) { - return; - } + if (default_conn != conn) { + return; + } - bt_conn_unref(default_conn); - default_conn = NULL; + bt_conn_unref(default_conn); + default_conn = NULL; - start_scan(); + start_scan(); } static struct bt_conn_cb conn_callbacks = { - .connected = split_central_connected, - .disconnected = split_central_disconnected, + .connected = split_central_connected, + .disconnected = split_central_disconnected, }; -int zmk_split_bt_central_init(struct device *_arg) -{ - bt_conn_cb_register(&conn_callbacks); +int zmk_split_bt_central_init(struct device *_arg) { + bt_conn_cb_register(&conn_callbacks); - return start_scan(); + return start_scan(); } -SYS_INIT(zmk_split_bt_central_init, - APPLICATION, - CONFIG_ZMK_BLE_INIT_PRIORITY); \ No newline at end of file +SYS_INIT(zmk_split_bt_central_init, APPLICATION, CONFIG_ZMK_BLE_INIT_PRIORITY); \ No newline at end of file diff --git a/app/src/split/bluetooth/service.c b/app/src/split/bluetooth/service.c index c2f65d2..86af685 100644 --- a/app/src/split/bluetooth/service.c +++ b/app/src/split/bluetooth/service.c @@ -21,41 +21,36 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); static u8_t num_of_positions = ZMK_KEYMAP_LEN; static u8_t position_state[16]; -static ssize_t split_svc_pos_state(struct bt_conn *conn, const struct bt_gatt_attr *attrs, void *buf, u16_t len, u16_t offset) -{ - return bt_gatt_attr_read(conn, attrs, buf, len, offset, &position_state, sizeof(position_state)); +static ssize_t split_svc_pos_state(struct bt_conn *conn, const struct bt_gatt_attr *attrs, + void *buf, u16_t len, u16_t offset) { + return bt_gatt_attr_read(conn, attrs, buf, len, offset, &position_state, + sizeof(position_state)); } -static ssize_t split_svc_num_of_positions(struct bt_conn *conn, const struct bt_gatt_attr *attrs, void *buf, u16_t len, u16_t offset) -{ +static ssize_t split_svc_num_of_positions(struct bt_conn *conn, const struct bt_gatt_attr *attrs, + void *buf, u16_t len, u16_t offset) { return bt_gatt_attr_read(conn, attrs, buf, len, offset, attrs->user_data, sizeof(u8_t)); } -static void split_svc_pos_state_ccc(const struct bt_gatt_attr *attr, u16_t value) -{ +static void split_svc_pos_state_ccc(const struct bt_gatt_attr *attr, u16_t value) { LOG_DBG("value %d", value); } +BT_GATT_SERVICE_DEFINE( + split_svc, BT_GATT_PRIMARY_SERVICE(BT_UUID_DECLARE_128(ZMK_SPLIT_BT_SERVICE_UUID)), + BT_GATT_CHARACTERISTIC(BT_UUID_DECLARE_128(ZMK_SPLIT_BT_CHAR_POSITION_STATE_UUID), + BT_GATT_CHRC_READ | BT_GATT_CHRC_NOTIFY, BT_GATT_PERM_READ_ENCRYPT, + split_svc_pos_state, NULL, &position_state), + BT_GATT_CCC(split_svc_pos_state_ccc, BT_GATT_PERM_READ_ENCRYPT | BT_GATT_PERM_WRITE_ENCRYPT), + BT_GATT_DESCRIPTOR(BT_UUID_NUM_OF_DIGITALS, BT_GATT_PERM_READ, split_svc_num_of_positions, NULL, + &num_of_positions), ); -BT_GATT_SERVICE_DEFINE(split_svc, - BT_GATT_PRIMARY_SERVICE(BT_UUID_DECLARE_128(ZMK_SPLIT_BT_SERVICE_UUID)), - BT_GATT_CHARACTERISTIC(BT_UUID_DECLARE_128(ZMK_SPLIT_BT_CHAR_POSITION_STATE_UUID), BT_GATT_CHRC_READ | BT_GATT_CHRC_NOTIFY, - BT_GATT_PERM_READ_ENCRYPT, - split_svc_pos_state, NULL, &position_state), - BT_GATT_CCC(split_svc_pos_state_ccc, - BT_GATT_PERM_READ_ENCRYPT | BT_GATT_PERM_WRITE_ENCRYPT), - BT_GATT_DESCRIPTOR(BT_UUID_NUM_OF_DIGITALS, BT_GATT_PERM_READ, - split_svc_num_of_positions, NULL, &num_of_positions), -); - -int zmk_split_bt_position_pressed(u8_t position) -{ +int zmk_split_bt_position_pressed(u8_t position) { WRITE_BIT(position_state[position / 8], position % 8, true); return bt_gatt_notify(NULL, &split_svc.attrs[1], &position_state, sizeof(position_state)); } -int zmk_split_bt_position_released(u8_t position) -{ +int zmk_split_bt_position_released(u8_t position) { WRITE_BIT(position_state[position / 8], position % 8, false); return bt_gatt_notify(NULL, &split_svc.attrs[1], &position_state, sizeof(position_state)); } \ No newline at end of file diff --git a/app/src/split_listener.c b/app/src/split_listener.c index 1263807..b2adfb2 100644 --- a/app/src/split_listener.c +++ b/app/src/split_listener.c @@ -19,18 +19,17 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); #include #include -int split_listener(const struct zmk_event_header *eh) -{ - LOG_DBG(""); - if (is_position_state_changed(eh)) { - const struct position_state_changed *ev = cast_position_state_changed(eh); - if (ev->state) { - return zmk_split_bt_position_pressed(ev->position); - } else { - return zmk_split_bt_position_released(ev->position); +int split_listener(const struct zmk_event_header *eh) { + LOG_DBG(""); + if (is_position_state_changed(eh)) { + const struct position_state_changed *ev = cast_position_state_changed(eh); + if (ev->state) { + return zmk_split_bt_position_pressed(ev->position); + } else { + return zmk_split_bt_position_released(ev->position); + } } - } - return 0; + return 0; } ZMK_LISTENER(split_listener, split_listener); diff --git a/app/src/usb_hid.c b/app/src/usb_hid.c index e2fe0f3..530ffea 100644 --- a/app/src/usb_hid.c +++ b/app/src/usb_hid.c @@ -22,71 +22,56 @@ static struct device *hid_dev; static K_SEM_DEFINE(hid_sem, 1, 1); -static void in_ready_cb(void) -{ - k_sem_give(&hid_sem); -} +static void in_ready_cb(void) { k_sem_give(&hid_sem); } -static const struct hid_ops ops = -{ - .int_in_ready = in_ready_cb, +static const struct hid_ops ops = { + .int_in_ready = in_ready_cb, }; -int zmk_usb_hid_send_report(const u8_t *report, size_t len) -{ - switch(usb_status) { - case USB_DC_SUSPEND: - return usb_wakeup_request(); - case USB_DC_ERROR: - case USB_DC_RESET: - case USB_DC_DISCONNECTED: - case USB_DC_UNKNOWN: - return -ENODEV; - default: - k_sem_take(&hid_sem, K_MSEC(30)); - int err = hid_int_ep_write(hid_dev, report, len, NULL); - - if (err) { - k_sem_give(&hid_sem); - } - - return err; - } +int zmk_usb_hid_send_report(const u8_t *report, size_t len) { + switch (usb_status) { + case USB_DC_SUSPEND: + return usb_wakeup_request(); + case USB_DC_ERROR: + case USB_DC_RESET: + case USB_DC_DISCONNECTED: + case USB_DC_UNKNOWN: + return -ENODEV; + default: + k_sem_take(&hid_sem, K_MSEC(30)); + int err = hid_int_ep_write(hid_dev, report, len, NULL); + + if (err) { + k_sem_give(&hid_sem); + } + + return err; + } } -void usb_hid_status_cb(enum usb_dc_status_code status, const u8_t *params) -{ - usb_status = status; -}; +void usb_hid_status_cb(enum usb_dc_status_code status, const u8_t *params) { usb_status = status; }; -static int zmk_usb_hid_init(struct device *_arg) -{ - int usb_enable_ret; +static int zmk_usb_hid_init(struct device *_arg) { + int usb_enable_ret; - hid_dev = device_get_binding("HID_0"); - if (hid_dev == NULL) - { - LOG_ERR("Unable to locate HID device"); - return -EINVAL; - } + hid_dev = device_get_binding("HID_0"); + if (hid_dev == NULL) { + LOG_ERR("Unable to locate HID device"); + return -EINVAL; + } - usb_hid_register_device(hid_dev, - zmk_hid_report_desc, sizeof(zmk_hid_report_desc), - &ops); + usb_hid_register_device(hid_dev, zmk_hid_report_desc, sizeof(zmk_hid_report_desc), &ops); - usb_hid_init(hid_dev); + usb_hid_init(hid_dev); - usb_enable_ret = usb_enable(usb_hid_status_cb); + usb_enable_ret = usb_enable(usb_hid_status_cb); - if (usb_enable_ret != 0) - { - LOG_ERR("Unable to enable USB"); - return -EINVAL; - } + if (usb_enable_ret != 0) { + LOG_ERR("Unable to enable USB"); + return -EINVAL; + } - return 0; + return 0; } -SYS_INIT(zmk_usb_hid_init, - APPLICATION, - CONFIG_ZMK_USB_INIT_PRIORITY); +SYS_INIT(zmk_usb_hid_init, APPLICATION, CONFIG_ZMK_USB_INIT_PRIORITY); -- cgit v1.2.3 From 7b12dc6caf7517aa95d66fadb529c260be752ff5 Mon Sep 17 00:00:00 2001 From: Nick Date: Sun, 13 Sep 2020 23:29:31 -0500 Subject: feature(board): add BT prof management to defaults --- app/boards/shields/corne/corne.keymap | 11 ++++++----- app/boards/shields/iris/iris.keymap | 13 +++++++------ app/boards/shields/lily58/lily58.keymap | 13 +++++++------ app/boards/shields/qaz/qaz.keymap | 3 ++- app/boards/shields/romac/romac.keymap | 17 +++++++++-------- app/boards/shields/sofle/sofle.keymap | 13 +++++++------ 6 files changed, 38 insertions(+), 32 deletions(-) diff --git a/app/boards/shields/corne/corne.keymap b/app/boards/shields/corne/corne.keymap index c0bbb4a..5f0f15f 100644 --- a/app/boards/shields/corne/corne.keymap +++ b/app/boards/shields/corne/corne.keymap @@ -1,5 +1,6 @@ #include #include +#include / { keymap { @@ -21,14 +22,14 @@ lower_layer { // ----------------------------------------------------------------------------------------- // | ESC | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | BKSP | -// | CTRL | | | | | | | LFT | DWN | UP | RGT | | | +// | BTCLR| BT1 | BT2 | BT3 | BT4 | BT5 | | LFT | DWN | UP | RGT | | | // | SHFT | | | | | | | | | | | | | // | GUI | | SPC | | ENT | | ALT | bindings = < - &kp ESC &kp NUM_1 &kp NUM_2 &kp NUM_3 &kp NUM_4 &kp NUM_5 &kp NUM_6 &kp NUM_7 &kp NUM_8 &kp NUM_9 &kp NUM_0 &kp BKSP - &kp LCTL &trans &trans &trans &trans &trans &kp LARW &kp DARW &kp UARW &kp RARW &trans &trans - &kp LSFT &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans - &kp LGUI &trans &kp SPC &kp RET &trans &kp RALT + &kp ESC &kp NUM_1 &kp NUM_2 &kp NUM_3 &kp NUM_4 &kp NUM_5 &kp NUM_6 &kp NUM_7 &kp NUM_8 &kp NUM_9 &kp NUM_0 &kp BKSP + &bt BT_CLR &bt BT_SEL 0 &bt BT_SEL 1 &bt BT_SEL 2 &bt BT_SEL 3 &bt BT_SEL 4 &kp LARW &kp DARW &kp UARW &kp RARW &trans &trans + &kp LSFT &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans + &kp LGUI &trans &kp SPC &kp RET &trans &kp RALT >; }; diff --git a/app/boards/shields/iris/iris.keymap b/app/boards/shields/iris/iris.keymap index 46b0817..3bd74ed 100644 --- a/app/boards/shields/iris/iris.keymap +++ b/app/boards/shields/iris/iris.keymap @@ -3,6 +3,7 @@ #include #include +#include / { keymap { @@ -26,17 +27,17 @@ lower_layer { // ------------------------------------------------------------------------------------------------------------ -// | | | | | | | | | | | | | | +// | BTCLR | BT1 | BT2 | BT3 | BT4 | BT5 | | | | | | | | // | F1 | F2 | F3 | F4 | F5 | F6 | | F7 | F8 | F9 | F10 | F11 | F12 | // | ` | ! | @ | # | $ | % | | ^ | & | * | ( | ) | ~ | // | | | | | | | | | | | _ | + | { | } | "|" | // | | | | | | | | bindings = < -&trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans -&kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &kp F6 &kp F7 &kp F8 &kp F9 &kp F10 &kp F11 &kp F12 -&kp GRAV &kp BANG &kp ATSN &kp HASH &kp CURU &kp PRCT &kp CRRT &kp AMPS &kp KMLT &kp LPRN &kp RPRN &kp TILD -&trans &trans &trans &trans &trans &trans &trans &trans &trans &kp MINUS &kp KPLS &kp LCUR &kp RCUR &kp PIPE - &trans &trans &trans &trans &trans &trans +&bt BT_CLR &bt BT_SEL 0 &bt BT_SEL 1 &bt BT_SEL 2 &bt BT_SEL 3 &bt BT_SEL 4 &trans &trans &trans &trans &trans &trans +&kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &kp F6 &kp F7 &kp F8 &kp F9 &kp F10 &kp F11 &kp F12 +&kp GRAV &kp BANG &kp ATSN &kp HASH &kp CURU &kp PRCT &kp CRRT &kp AMPS &kp KMLT &kp LPRN &kp RPRN &kp TILD +&trans &trans &trans &trans &trans &trans &trans &trans &trans &kp MINUS &kp KPLS &kp LCUR &kp RCUR &kp PIPE + &trans &trans &trans &trans &trans &trans >; }; diff --git a/app/boards/shields/lily58/lily58.keymap b/app/boards/shields/lily58/lily58.keymap index afd2694..61c19f8 100644 --- a/app/boards/shields/lily58/lily58.keymap +++ b/app/boards/shields/lily58/lily58.keymap @@ -1,5 +1,6 @@ #include #include +#include / { keymap { @@ -25,17 +26,17 @@ lower_layer { // ------------------------------------------------------------------------------------------------------------ -// | | | | | | | | | | | | | | +// | BTCLR | BT1 | BT2 | BT3 | BT4 | BT5 | | | | | | | | // | F1 | F2 | F3 | F4 | F5 | F6 | | F7 | F8 | F9 | F10 | F11 | F12 | // | ` | ! | @ | # | $ | % | | ^ | & | * | ( | ) | ~ | // | | | | | | | | | | | _ | + | { | } | "|" | // | | | | | | | | | | bindings = < -&trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans -&kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &kp F6 &kp F7 &kp F8 &kp F9 &kp F10 &kp F11 &kp F12 -&kp GRAV &kp BANG &kp ATSN &kp HASH &kp CURU &kp PRCT &kp CRRT &kp AMPS &kp KMLT &kp LPRN &kp RPRN &kp TILD -&trans &trans &trans &trans &trans &trans &trans &trans &trans &kp MINUS &kp KPLS &kp LCUR &kp RCUR &kp PIPE - &trans &trans &trans &trans &trans &trans &trans &trans +&bt BT_CLR &bt BT_SEL 0 &bt BT_SEL 1 &bt BT_SEL 2 &bt BT_SEL 3 &bt BT_SEL 4 &trans &trans &trans &trans &trans &trans +&kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &kp F6 &kp F7 &kp F8 &kp F9 &kp F10 &kp F11 &kp F12 +&kp GRAV &kp BANG &kp ATSN &kp HASH &kp CURU &kp PRCT &kp CRRT &kp AMPS &kp KMLT &kp LPRN &kp RPRN &kp TILD +&trans &trans &trans &trans &trans &trans &trans &trans &trans &kp MINUS &kp KPLS &kp LCUR &kp RCUR &kp PIPE + &trans &trans &trans &trans &trans &trans &trans &trans >; sensor-bindings = <&inc_dec_cp M_VOLU M_VOLD>; diff --git a/app/boards/shields/qaz/qaz.keymap b/app/boards/shields/qaz/qaz.keymap index ffa2f6c..07cd90e 100644 --- a/app/boards/shields/qaz/qaz.keymap +++ b/app/boards/shields/qaz/qaz.keymap @@ -6,6 +6,7 @@ #include #include +#include #define DEFAULT 0 #define NUM_SYM 1 @@ -34,7 +35,7 @@ nav { bindings = < - &none &none &none &none &none &none &none &kp UARW &none &kp BKSP + &bt BT_CLR &bt BT_NXT &bt BT_PRV &none &none &none &none &kp UARW &none &kp BKSP &trans &trans &trans &trans &none &none &kp LARW &kp DARW &kp RARW &none &none &none &none &none &none &none &none &none &none &none &none &none &none &none &trans &trans &kp RET &trans &kp FSLH diff --git a/app/boards/shields/romac/romac.keymap b/app/boards/shields/romac/romac.keymap index f94a829..97ea9c5 100644 --- a/app/boards/shields/romac/romac.keymap +++ b/app/boards/shields/romac/romac.keymap @@ -6,6 +6,7 @@ #include #include +#include / { keymap { @@ -28,16 +29,16 @@ nav_layer { // ----------------------- -// | _ | HOME | PGUP | -// | _ | END | PGDN | -// | _ | _ | _ | -// | _ | _ | RET | +// | BTNXT | HOME | PGUP | +// | BTPRV | END | PGDN | +// | BTCLR | _ | _ | +// | _ | _ | RET | // ----------------------- bindings = < - &trans &kp HOME &kp PGUP - &trans &kp END &kp PGDN - &trans &trans &trans - &trans &trans &kp RET + &bt BT_NXT &kp HOME &kp PGUP + &bt BT_PRV &kp END &kp PGDN + &bt BT_CLR &trans &trans + &trans &trans &kp RET >; }; }; diff --git a/app/boards/shields/sofle/sofle.keymap b/app/boards/shields/sofle/sofle.keymap index aadffa1..1cbe742 100644 --- a/app/boards/shields/sofle/sofle.keymap +++ b/app/boards/shields/sofle/sofle.keymap @@ -1,5 +1,6 @@ #include #include +#include / { keymap { @@ -44,17 +45,17 @@ raise_layer { // ------------------------------------------------------------------------------------------------------------ -// | | | | | | | | | | | | | | +// |BTCLR| BT1 | BT2 | BT3 | BT4 | BT5 | | | | | | | | // | | INS | PSCR | GUI | | | | PGUP | | ^ | | | | // | | ALT | CTRL | SHIFT | | CAPS | | PGDN | <- | v | -> | DEL | BKSPC | // | | UNDO | CUT | COPY | PASTE | | | | | | | | | | | // | | | | | | | | | | | | bindings = < -&trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans -&trans &kp INS &kp PRSC &kp GUI &trans &trans &kp PGUP &trans &kp UARW &trans &kp NUM_0 &trans -&trans &kp LALT &kp LCTL &kp LSFT &trans &kp CLCK &kp PGDN &kp LARW &kp DARW &kp RARW &kp DEL &kp BKSP -&trans &kp UNDO &kp CUT &kp COPY &kp PSTE &trans &trans &trans &trans &trans &trans &trans &trans &trans - &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans +&bt BT_CLR &bt BT_SEL 0 &bt BT_SEL 1 &bt BT_SEL 2 &bt BT_SEL 3 &bt BT_SEL 4 &trans &trans &trans &trans &trans &trans +&trans &kp INS &kp PRSC &kp GUI &trans &trans &kp PGUP &trans &kp UARW &trans &kp NUM_0 &trans +&trans &kp LALT &kp LCTL &kp LSFT &trans &kp CLCK &kp PGDN &kp LARW &kp DARW &kp RARW &kp DEL &kp BKSP +&trans &kp UNDO &kp CUT &kp COPY &kp PSTE &trans &trans &trans &trans &trans &trans &trans &trans &trans + &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans >; sensor-bindings = <&inc_dec_cp M_VOLU M_VOLD &inc_dec_kp PGUP PGDN>; -- cgit v1.2.3 From 1183f96cbc4e9a9d01b49278a43ea722486d5e67 Mon Sep 17 00:00:00 2001 From: tominabox1 Date: Mon, 14 Sep 2020 07:39:42 -0500 Subject: Update QAZ keymap for bluetooth config options and homerow hold-taps --- app/boards/shields/qaz/qaz.keymap | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/app/boards/shields/qaz/qaz.keymap b/app/boards/shields/qaz/qaz.keymap index ffa2f6c..ac10772 100644 --- a/app/boards/shields/qaz/qaz.keymap +++ b/app/boards/shields/qaz/qaz.keymap @@ -4,13 +4,27 @@ * SPDX-License-Identifier: MIT */ +#include #include #include #define DEFAULT 0 #define NUM_SYM 1 #define NAV 2 - + +/ { + behaviors { + hm: homerow_mods { + compatible = "zmk,behavior-hold-tap"; + label = "homerow mods"; + #binding-cells = <2>; + tapping_term_ms = <225>; + flavor = "tap-preferred"; + bindings = <&kp>, <&kp>; + }; + }; +}; + / { keymap { compatible = "zmk,keymap"; @@ -18,9 +32,9 @@ default_layer { bindings = < &kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P - &kp A &kp S &kp D &kp F &kp G &kp H &kp J &kp K &kp L &kp RET + &hm LGUI A &hm LALT S &hm LCTL D &hm LSFT F &kp G &kp H &hm RSFT J &hm RCTL K &hm RALT L &hm RGUI RET &kp Z &kp X &kp C &kp V &kp B &kp N &kp M &kp CMMA &kp DOT - &kp LSFT &kp LGUI &kp LALT &mo NAV &kp SPC &mo NUM_SYM &kp QUOT &kp FSLH + &kp LSFT &kp LGUI &kp LALT < NAV RET < NUM_SYM SPC &kp COLN &kp QUOT &kp FSLH >; }; num_sym { @@ -37,7 +51,7 @@ &none &none &none &none &none &none &none &kp UARW &none &kp BKSP &trans &trans &trans &trans &none &none &kp LARW &kp DARW &kp RARW &none &none &none &none &none &none &none &none &none &none - &none &none &none &none &none &trans &trans &kp RET &trans &kp FSLH + &bt BT_CLR &bt BT_NXT &none &trans &trans &kp RET &trans &kp FSLH >; }; }; -- cgit v1.2.3 From fc167f5f5ede2049f5d7649353b456e36c9f0be3 Mon Sep 17 00:00:00 2001 From: tominabox1 Date: Mon, 14 Sep 2020 07:39:42 -0500 Subject: Update QAZ keymap for bluetooth config options and homerow hold-taps --- app/boards/shields/qaz/qaz.keymap | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/app/boards/shields/qaz/qaz.keymap b/app/boards/shields/qaz/qaz.keymap index 07cd90e..1bcaba6 100644 --- a/app/boards/shields/qaz/qaz.keymap +++ b/app/boards/shields/qaz/qaz.keymap @@ -4,6 +4,7 @@ * SPDX-License-Identifier: MIT */ +#include #include #include #include @@ -11,7 +12,20 @@ #define DEFAULT 0 #define NUM_SYM 1 #define NAV 2 - + +/ { + behaviors { + hm: homerow_mods { + compatible = "zmk,behavior-hold-tap"; + label = "homerow mods"; + #binding-cells = <2>; + tapping_term_ms = <225>; + flavor = "tap-preferred"; + bindings = <&kp>, <&kp>; + }; + }; +}; + / { keymap { compatible = "zmk,keymap"; @@ -19,9 +33,9 @@ default_layer { bindings = < &kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P - &kp A &kp S &kp D &kp F &kp G &kp H &kp J &kp K &kp L &kp RET + &hm LGUI A &hm LALT S &hm LCTL D &hm LSFT F &kp G &kp H &hm RSFT J &hm RCTL K &hm RALT L &hm RGUI RET &kp Z &kp X &kp C &kp V &kp B &kp N &kp M &kp CMMA &kp DOT - &kp LSFT &kp LGUI &kp LALT &mo NAV &kp SPC &mo NUM_SYM &kp QUOT &kp FSLH + &kp LSFT &kp LGUI &kp LALT < NAV RET < NUM_SYM SPC &kp COLN &kp QUOT &kp FSLH >; }; num_sym { @@ -38,7 +52,7 @@ &bt BT_CLR &bt BT_NXT &bt BT_PRV &none &none &none &none &kp UARW &none &kp BKSP &trans &trans &trans &trans &none &none &kp LARW &kp DARW &kp RARW &none &none &none &none &none &none &none &none &none &none - &none &none &none &none &none &trans &trans &kp RET &trans &kp FSLH + &bt BT_CLR &bt BT_NXT &none &trans &trans &kp RET &trans &kp FSLH >; }; }; -- cgit v1.2.3 From 6a02a2968aaae4ce803147fc4ab1f9e2ca6b4379 Mon Sep 17 00:00:00 2001 From: tominabox1 Date: Mon, 14 Sep 2020 08:43:28 -0500 Subject: add dstore to git ignore list --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index e02cca0..40e0536 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ /tools /zephyr /build +*.DS_Store -- cgit v1.2.3 From 63e105db908dbae529c44a76c7f29622574f188c Mon Sep 17 00:00:00 2001 From: tominabox1 Date: Mon, 14 Sep 2020 08:45:31 -0500 Subject: Revising keymap to jive with upstream changes --- app/boards/shields/qaz/qaz.keymap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/boards/shields/qaz/qaz.keymap b/app/boards/shields/qaz/qaz.keymap index 1bcaba6..8781428 100644 --- a/app/boards/shields/qaz/qaz.keymap +++ b/app/boards/shields/qaz/qaz.keymap @@ -52,7 +52,7 @@ &bt BT_CLR &bt BT_NXT &bt BT_PRV &none &none &none &none &kp UARW &none &kp BKSP &trans &trans &trans &trans &none &none &kp LARW &kp DARW &kp RARW &none &none &none &none &none &none &none &none &none &none - &bt BT_CLR &bt BT_NXT &none &trans &trans &kp RET &trans &kp FSLH + &none &none &none &trans &trans &kp RET &trans &kp FSLH >; }; }; -- cgit v1.2.3 From 62c47b1981f27bdcbdecb7aa3b704d665785ed2b Mon Sep 17 00:00:00 2001 From: tominabox1 Date: Mon, 14 Sep 2020 08:46:07 -0500 Subject: Remove duplicate include --- app/boards/shields/qaz/qaz.keymap | 1 - 1 file changed, 1 deletion(-) diff --git a/app/boards/shields/qaz/qaz.keymap b/app/boards/shields/qaz/qaz.keymap index 8781428..5ad9628 100644 --- a/app/boards/shields/qaz/qaz.keymap +++ b/app/boards/shields/qaz/qaz.keymap @@ -4,7 +4,6 @@ * SPDX-License-Identifier: MIT */ -#include #include #include #include -- cgit v1.2.3 From 42c42ccbbd114641c596d795a196307cf36aea5d Mon Sep 17 00:00:00 2001 From: tominabox1 Date: Mon, 14 Sep 2020 09:25:31 -0500 Subject: Fixed some space/tab issues as well as updated copyright statements --- app/boards/shields/qaz/Kconfig.defconfig | 4 ++-- app/boards/shields/qaz/Kconfig.shield | 8 ++++---- app/boards/shields/qaz/qaz.keymap | 16 ++++++++-------- app/boards/shields/qaz/qaz.overlay | 4 ++-- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/app/boards/shields/qaz/Kconfig.defconfig b/app/boards/shields/qaz/Kconfig.defconfig index f82f458..c84180b 100644 --- a/app/boards/shields/qaz/Kconfig.defconfig +++ b/app/boards/shields/qaz/Kconfig.defconfig @@ -1,5 +1,5 @@ - # Copyright (c) 2020 TJ Campie - # SPDX-License-Identifier: MIT +# Copyright (c) 2020 The ZMK Contributors +# SPDX-License-Identifier: MIT if SHIELD_QAZ diff --git a/app/boards/shields/qaz/Kconfig.shield b/app/boards/shields/qaz/Kconfig.shield index 9da6077..32c443c 100644 --- a/app/boards/shields/qaz/Kconfig.shield +++ b/app/boards/shields/qaz/Kconfig.shield @@ -1,5 +1,5 @@ -# Copyright (c) 2020 TJ Campie +# Copyright (c) 2020 The ZMK Contributors # SPDX-License-Identifier: MIT - - config SHIELD_MY_BOARD - def_bool $(shields_list_contains,qaz) + +config SHIELD_MY_BOARD + def_bool $(shields_list_contains,qaz) diff --git a/app/boards/shields/qaz/qaz.keymap b/app/boards/shields/qaz/qaz.keymap index 5ad9628..3622972 100644 --- a/app/boards/shields/qaz/qaz.keymap +++ b/app/boards/shields/qaz/qaz.keymap @@ -1,6 +1,6 @@ /* - * Copyright (c) 2020 TJ Campie - * + * Copyright (c) 2020 The ZMK Contributors + * * SPDX-License-Identifier: MIT */ @@ -14,13 +14,13 @@ / { behaviors { - hm: homerow_mods { - compatible = "zmk,behavior-hold-tap"; - label = "homerow mods"; - #binding-cells = <2>; - tapping_term_ms = <225>; + hm: homerow_mods { + compatible = "zmk,behavior-hold-tap"; + label = "homerow mods"; + #binding-cells = <2>; + tapping_term_ms = <225>; flavor = "tap-preferred"; - bindings = <&kp>, <&kp>; + bindings = <&kp>, <&kp>; }; }; }; diff --git a/app/boards/shields/qaz/qaz.overlay b/app/boards/shields/qaz/qaz.overlay index 472005b..4e73370 100644 --- a/app/boards/shields/qaz/qaz.overlay +++ b/app/boards/shields/qaz/qaz.overlay @@ -1,6 +1,6 @@ /* - * Copyright (c) 2020 TJ Campie - * + * Copyright (c) 2020 The ZMK Contributors + * * SPDX-License-Identifier: MIT */ -- cgit v1.2.3 From f6269df5fc7bbdf36ebb5aa5f0de9fc48f76469e Mon Sep 17 00:00:00 2001 From: Cody McGinnis Date: Mon, 14 Sep 2020 10:34:05 -0400 Subject: fix(tests): return error code when build fails --- app/run-test.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/app/run-test.sh b/app/run-test.sh index 3b7cd58..dd8c8ee 100755 --- a/app/run-test.sh +++ b/app/run-test.sh @@ -22,6 +22,7 @@ echo "Running $testcase:" west build -d build/$testcase -b native_posix -- -DZMK_CONFIG=$testcase > /dev/null 2>&1 if [ $? -gt 0 ]; then echo "FAIL: $testcase did not build" >> ./build/tests/pass-fail.log + exit 1 else ./build/$testcase/zephyr/zmk.exe | sed -e "s/.*> //" | tee build/$testcase/keycode_events_full.log | sed -n -f $testcase/events.patterns > build/$testcase/keycode_events.log diff -au $testcase/keycode_events.snapshot build/$testcase/keycode_events.log -- cgit v1.2.3 From 0bf4467729f3bf560a04e51900489d81fe129376 Mon Sep 17 00:00:00 2001 From: tominabox1 Date: Mon, 14 Sep 2020 09:35:57 -0500 Subject: Update Kconfig.shield --- app/boards/shields/qaz/Kconfig.shield | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/boards/shields/qaz/Kconfig.shield b/app/boards/shields/qaz/Kconfig.shield index 32c443c..7cc8f1e 100644 --- a/app/boards/shields/qaz/Kconfig.shield +++ b/app/boards/shields/qaz/Kconfig.shield @@ -1,5 +1,5 @@ # Copyright (c) 2020 The ZMK Contributors # SPDX-License-Identifier: MIT -config SHIELD_MY_BOARD +config SHIELD_QAZ def_bool $(shields_list_contains,qaz) -- cgit v1.2.3