diff options
author | jakobst1n <jakob.stendahl@outlook.com> | 2024-01-27 00:17:50 +0100 |
---|---|---|
committer | jakobst1n <jakob.stendahl@outlook.com> | 2024-01-27 01:08:56 +0100 |
commit | fa935f17408d7373b9419bf19b9cecc48f363765 (patch) | |
tree | 8c8ac112bf0087debd90d844adb6c41e9cf60e31 | |
parent | 20c10e8ed1d3710cb83367ca18202e7f160f2506 (diff) | |
download | zmk-config-fa935f17408d7373b9419bf19b9cecc48f363765.tar.gz zmk-config-fa935f17408d7373b9419bf19b9cecc48f363765.zip |
ps2
-rw-r--r-- | .github/workflows/build.yml | 3 | ||||
-rwxr-xr-x | bin/build.sh | 2 | ||||
-rw-r--r-- | boards/shields/.gitkeep | 0 | ||||
-rw-r--r-- | build.yaml | 6 | ||||
-rw-r--r-- | config/boards/shields/corne/corne.dtsi | 258 | ||||
-rw-r--r-- | config/bt60_v2.keymap | 2 | ||||
-rw-r--r-- | config/corne.conf | 28 | ||||
-rw-r--r-- | config/corne.keymap | 40 | ||||
-rw-r--r-- | config/corne_alt.keymap | 108 | ||||
-rw-r--r-- | config/corne_left.conf | 2 | ||||
-rw-r--r-- | config/corne_right.conf | 2 | ||||
-rw-r--r-- | config/corne_right.overlay | 262 | ||||
-rw-r--r-- | config/includes/combos.dtsi | 183 | ||||
-rw-r--r-- | config/includes/mouse_keys.dtsi | 15 | ||||
-rw-r--r-- | config/includes/mouse_tp.dtsi | 142 | ||||
-rw-r--r-- | config/utils/common.h | 29 | ||||
-rw-r--r-- | config/west.yml | 37 |
17 files changed, 1086 insertions, 33 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d74fb89..acac9b4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,4 +2,5 @@ on: [push, pull_request, workflow_dispatch] jobs: build: - uses: zmkfirmware/zmk/.github/workflows/build-user-config.yml@main + uses: petejohanson/zmk/.github/workflows/build-user-config.yml@core/zephyr-3.5-update + #uses: zmkfirmware/zmk/.github/workflows/build-user-config.yml@main diff --git a/bin/build.sh b/bin/build.sh index 330f0d3..04603be 100755 --- a/bin/build.sh +++ b/bin/build.sh @@ -90,7 +90,7 @@ while [[ $# -gt 0 ]]; do done # Set defaults -[[ -z $ZEPHYR_VERSION ]] && ZEPHYR_VERSION="3.2" +[[ -z $ZEPHYR_VERSION ]] && ZEPHYR_VERSION="3.5-branch" [[ -z $OUTPUT_DIR ]] && OUTPUT_DIR="$HOME/Downloads" [[ -z $LOG_DIR ]] && LOG_DIR="/tmp" diff --git a/boards/shields/.gitkeep b/boards/shields/.gitkeep deleted file mode 100644 index e69de29..0000000 --- a/boards/shields/.gitkeep +++ /dev/null @@ -14,7 +14,7 @@ --- include: - board: nice_nano_v2 - shield: corne_left - - board: nice_nano_v2 shield: corne_right - - board: bt60_v2 + #- board: nice_nano_v2 + # shield: corne_left +# - board: bt60_v2 diff --git a/config/boards/shields/corne/corne.dtsi b/config/boards/shields/corne/corne.dtsi new file mode 100644 index 0000000..acee29c --- /dev/null +++ b/config/boards/shields/corne/corne.dtsi @@ -0,0 +1,258 @@ +/* + * Copyright (c) 2020 Pete Johanson + * + * SPDX-License-Identifier: MIT + */ + +#include <dt-bindings/zmk/matrix_transform.h> + +/ { + chosen { + zephyr,display = &oled; + zmk,kscan = &kscan0; + zmk,matrix-transform = &default_transform; + }; + + default_transform: keymap_transform_0 { + compatible = "zmk,matrix-transform"; + columns = <12>; + rows = <4>; +// | SW1 | SW2 | SW3 | SW4 | SW5 | SW6 | | SW6 | SW5 | SW4 | SW3 | SW2 | SW1 | +// | SW7 | SW8 | SW9 | SW10 | SW11 | SW12 | | SW12 | SW11 | SW10 | SW9 | SW8 | SW7 | +// | SW13 | SW14 | SW15 | SW16 | SW17 | SW18 | | SW18 | SW17 | SW16 | SW15 | SW14 | SW13 | +// | SW19 | SW20 | SW21 | | SW21 | SW20 | SW19 | + 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,3) RC(3,4) RC(3,5) RC(3,6) RC(3,7) RC(3,8) + >; + }; + + five_column_transform: keymap_transform_1 { + compatible = "zmk,matrix-transform"; + columns = <10>; + rows = <4>; +// | SW2 | SW3 | SW4 | SW5 | SW6 | | SW6 | SW5 | SW4 | SW3 | SW2 | +// | SW8 | SW9 | SW10 | SW11 | SW12 | | SW12 | SW11 | SW10 | SW9 | SW8 | +// | SW14 | SW15 | SW16 | SW17 | SW18 | | SW18 | SW17 | SW16 | SW15 | SW14 | +// | SW19 | SW20 | SW21 | | SW21 | SW20 | SW19 | + map = < +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(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(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(3,3) RC(3,4) RC(3,5) RC(3,6) RC(3,7) RC(3,8) + >; + }; + + kscan0: kscan { + compatible = "zmk,kscan-gpio-matrix"; + + diode-direction = "col2row"; + row-gpios + = <&pro_micro 4 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro 5 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro 6 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro 7 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + ; + + }; + + // TODO: per-key RGB node(s)? +}; + +&pro_micro_i2c { + status = "okay"; + + oled: ssd1306@3c { + compatible = "solomon,ssd1306fb"; + reg = <0x3c>; + width = <128>; + height = <32>; + segment-offset = <0>; + page-offset = <0>; + display-offset = <0>; + multiplex-ratio = <31>; + segment-remap; + com-invdir; + com-sequential; + prechargep = <0x22>; + }; +}; + + +/* + * PS/2 Mouse / Trackpoint + */ + +// Configure the SCL and SDA pins of the PS/2 mouse/tp using the `&pro_micro` +// notation. +// +// If possible, try to choose the blue high frequency pins to avoid +// bluetooth interference. +// +// On the nice!nano documentation these are green DX pins: +// https://nicekeyboards.com/docs/nice-nano/pinout-schematic +// +#define MOUSE_PS2_PIN_SCL_PRO_MICRO <&pro_micro 1 GPIO_ACTIVE_HIGH> +#define MOUSE_PS2_PIN_SDA_PRO_MICRO <&pro_micro 0 GPIO_ACTIVE_HIGH> + + +// Uncomment and configure this pin if you have an extra free pin and want the +// controller to perform the Power-On-Reset sequence, which many trackpoints +// require, instead of using a trackpoint reset circuit. +// +// It's ok to use a low-frequency pin for this. +#define MOUSE_PS2_PIN_RST_PRO_MICRO <&pro_micro 9 GPIO_ACTIVE_HIGH> + + +// Now configure the same SDA pin using the pinctrl notation. +// +// For that you have to use the PX.XX notation of the nrf52 chip. +// +// On the nice!nano pinout they are shown in blue and purple next to the green +// DX pin. +// +// Enter it like `X, Y` without leading zeroes. +// Examples: +// D0 - P0.08: 0, 8 +// D15 - P1.13: 1, 13 +// +// We don't define the SCL pin, because UART uses a baud rate instead of +// a clock pin. +#define MOUSE_PS2_PIN_SDA_PINCTRL <NRF_PSEL(UART_RX, 0, 8)> + + +// In UART two different pins are used for receiving and transmitting, but PS/2 +// uses the same pin for both. +// +// The UART config still requires both pins to be configured. So we use one of +// the nrf52 pins that are not exposed on the nice!nano board. +#define MOUSE_PS2_PIN_UNEXPOSED_TX <NRF_PSEL(UART_TX, 0, 27)> +#define MOUSE_PS2_PIN_UNEXPOSED_RX <NRF_PSEL(UART_RX, 0, 28)> + + +// The PS/2 GPIO driver +/ { + gpio_ps2: gpio_ps2 { + status = "disabled"; + compatible = "gpio-ps2"; + scl-gpios = MOUSE_PS2_PIN_SCL_PRO_MICRO; + sda-gpios = MOUSE_PS2_PIN_SDA_PRO_MICRO; + }; +}; + + +&pinctrl { + // This pinctrl state is used for receiving + // For `UART_TX`, set an unused and unexposed pin + // For `UART_RX`, set the PS/2 SDA pin number + uart0_ps2_default: uart0_ps2_default { + group1 { + psels = MOUSE_PS2_PIN_UNEXPOSED_TX, + MOUSE_PS2_PIN_SDA_PINCTRL; + }; + }; + + // Set this to the same pins as uart0_ps2_default + uart0_ps2_sleep: uart0_ps2_sleep { + group1 { + psels = MOUSE_PS2_PIN_UNEXPOSED_TX, + MOUSE_PS2_PIN_SDA_PINCTRL; + low-power-enable; + }; + }; + + // The nrf52 UART controller is not compatible with the PS/2 + // transmission frame. So we don't use UART for transmissions + // and instead use GPIO bitbanging. + // + // When we switch to transmit mode, we free up the SDA pin by switching + // UART to unexposed/unused pins. + // + // Then we can configure the pins to be used with the GPIO controller. + uart0_ps2_off: uart0_ps2_off { + group1 { + psels = MOUSE_PS2_PIN_UNEXPOSED_TX, + MOUSE_PS2_PIN_UNEXPOSED_RX; + }; + }; +}; + + +&uart0 { + status = "disabled"; + compatible = "nordic,nrf-uarte"; + + // PS/2 uses a clock pin to syncronize data transmissions. UART on the + // other hand uses a pre-defined frequency (baud rate). + // + // Fortunately, one of the available baud rates is very close to the + // frequency used in IBM/Lenovo trackpoints. + // + // You can find other configurable baud rates here: + // https://docs.zephyrproject.org/latest/build/dts/api/bindings/serial/nordic,nrf-uarte.html + // + // But most likely you won't need to adjust this. + // + // You can measure the frequency of your mouse/TP using a $5 logic + // analyzer from AliExpress. + // + // Actual frequency of PS/2 trackpoint: 67us + // Correspondent baud rate: 14,925 + // + // Closest available baud rate in zephyr: 14,400 + // Correspondent cycle length: 69.44 microseconds + // + // Calculations: + // + // Convert cycle length in microseconds into baud: + // 1 / PS2_CYCLE_LENGTH * 1000000 = BAUD + // 1 / 67 * 1000000 = 14,925 BAUD + // + // Convert baud into cycle length: + // 1 / BAUD * 1000000 = CYCLE_LEN (in microseconds) + // 1 / 14400 * 1000000 = 69.44 + // + current-speed = <14400>; + pinctrl-0 = <&uart0_ps2_default>; + pinctrl-1 = <&uart0_ps2_off>; + + pinctrl-names = "default", "sleep"; + + uart_ps2: uart_ps2 { + status="disabled"; + compatible = "uart-ps2"; + scl-gpios = MOUSE_PS2_PIN_SCL_PRO_MICRO; + sda-gpios = MOUSE_PS2_PIN_SDA_PRO_MICRO; + }; +}; + + +/ { + mouse_ps2: mouse_ps2 { + status = "disabled"; + compatible = "zmk,input-mouse-ps2"; + + // This will be overriden in your `xxx_right.overlay file`. + // ps2-device = <&gpio_ps2>; + ps2-device = <&uart_ps2>; + +#ifdef MOUSE_PS2_PIN_RST_PRO_MICRO + rst-gpios = MOUSE_PS2_PIN_RST_PRO_MICRO; +#endif + }; + + input_config: input_config { + compatible = "zmk,input-configs"; + status = "disabled"; + + mouse_ps2_config: mouse_ps2_config { + device = <&mouse_ps2>; + + // Some of the available settings depend on the keymap. So they + // are adjusted in... + // ../../../includes/trackpoint.dtsi + }; + }; +}; diff --git a/config/bt60_v2.keymap b/config/bt60_v2.keymap index 5ebceef..d127da2 100644 --- a/config/bt60_v2.keymap +++ b/config/bt60_v2.keymap @@ -86,7 +86,7 @@ COMBO(mwn_ao_comb, 54 25, MAC_U, &mwn_no_ao) &kp GRAVE &kp N1 &kp N2 &kp N3 &kp N4 &kp N5 &kp N6 &kp N7 &kp N8 &kp N9 &kp N0 &kp MINUS &kp EQUAL &kp BSPC &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 - &mt LCTRL ESC &hml LGUI A &hml LALT S &hml LCTRL D &hml LSHIFT F &kp G &kp H &hmr RSHIFT J &hmr RCTRL K &hmr RALT L &hmr RGUI SEMI &kp SQT &kp NON_US_HASH &kp RET + &mt LCTRL ESC &kp A &kp S &kp D &kp F &kp G &kp H &kp J &kp K &kp L &kp SEMI &kp SQT &kp NON_US_HASH &kp RET &kp LSHIFT &kp NON_US_BSLH &kp Z &kp X &kp C &kp V &kp B &kp N &kp M &kp COMMA &kp DOT &kp FSLH &td_rshift_c &td_rfn_u_c &td_lctrl_l &kp LGUI &kp LALT &kp SPACE &kp RALT &td_rfn_l_c &kp C_MENU &kp RCTRL >; diff --git a/config/corne.conf b/config/corne.conf index 1748389..72094c8 100644 --- a/config/corne.conf +++ b/config/corne.conf @@ -1,5 +1,4 @@ -# Uncomment the following line to enable deep sleep -# CONFIG_ZMK_SLEEP=y +CONFIG_ZMK_KEYBOARD_NAME="Jakobs Corne" # Uncomment the following line to increase the keyboard's wireless range CONFIG_BT_CTLR_TX_PWR_PLUS_8=y @@ -14,4 +13,27 @@ CONFIG_BT_CTLR_TX_PWR_PLUS_8=y CONFIG_ZMK_RGB_UNDERGLOW=n CONFIG_ZMK_DISPLAY=n -CONFIG_ZMK_KEYBOARD_NAME="Jakobs Corne" +#CONFIG_ZMK_IDLE_TIMEOUT=30000 + +# Uncomment the following line to enable deep sleep +#CONFIG_ZMK_SLEEP=y +#CONFIG_ZMK_IDLE_SLEEP_TIMEOUT=3600000 + +CONFIG_ZMK_SPLIT_BLE_CENTRAL_BATTERY_LEVEL_FETCHING=y +CONFIG_ZMK_SPLIT_BLE_CENTRAL_BATTERY_LEVEL_PROXY=y + +# +# Configure PS2 Mouse Settings +# + +CONFIG_HEAP_MEM_POOL_SIZE=256 + +# Enable additional error mitigations to prevent cursor jumps +# Disabled by default and only recommended if using the GPIO PS2 driver +# CONFIG_ZMK_INPUT_MOUSE_PS2_ENABLE_ERROR_MITIGATION=n + +CONFIG_ZMK_LOGGING_MINIMAL=y +CONFIG_PS2_LOG_LEVEL_DBG=n +CONFIG_UART_LOG_LEVEL_DBG=n +CONFIG_LOG_MODE_IMMEDIATE=n +CONFIG_LOG_PROCESS_THREAD_STARTUP_DELAY_MS=3000 diff --git a/config/corne.keymap b/config/corne.keymap index 9d3b950..cef11d3 100644 --- a/config/corne.keymap +++ b/config/corne.keymap @@ -20,25 +20,27 @@ #define LOWER 1 #define RAISE 2 #define SUPER 3 +#define MOUSE_TP 4 #include "utils/common.h" +#define HAS_UROB +#define HAS_MOUSE_KEYS +#define HAS_MOUSE_TP +#ifdef HAS_MOUSE_KEYS + #include "includes/mouse_keys.dtsi" +#endif + +#ifdef HAS_MOUSE_TP + #include "includes/mouse_tp.dtsi" +#endif + COMBO(lnx_oe_comb, K_O K_E, DEFAULT, &lnx_no_oe) COMBO(lnx_ae_comb, K_A K_E, DEFAULT, &lnx_no_ae) COMBO(lnx_ao_comb, K_A K_O, DEFAULT, &lnx_no_ao) / { behaviors { - kp_mo: behavior_kp_mo { - compatible = "zmk,behavior-hold-tap"; - label = "kp_mo"; - #binding-cells = <2>; - flavor = "tap-preferred"; - tapping-term-ms = <QUICK_TAP_MS>; - quick-tap-ms = <QUICK_TAP_MS>; - require-prior-idle-ms = <100>; - bindings = <&mo>, <&kp>; - }; td_alt: td_alt { compatible = "zmk,behavior-tap-dance"; label = "td_alt"; @@ -61,7 +63,7 @@ COMBO(lnx_ao_comb, K_A K_O, DEFAULT, &lnx_no_ao) XXX &kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P XXX &td_alt &kp A &kp S &kp D &kp F &kp G &kp H &kp J &kp K &kp L &kp SEMI &kp SQT &kp LGUI &kp Z &kp X &kp C &kp V &kp B &kp N &kp M &kp COMMA &kp DOT &kp FSLH &mo SUPER - &kp TAB &kp_mo RAISE RET &kp LSHIFT &kp BSPC &kp_mo LOWER SPACE &mt LCTRL ESC + &mt LCTRL TAB &kp_mo RAISE RET &kp LSHIFT &kp_mt LSHIFT BSPC &kp_mo LOWER SPACE &mt LCTRL ESC >; }; lower_layer { @@ -97,7 +99,7 @@ COMBO(lnx_ao_comb, K_A K_O, DEFAULT, &lnx_no_ao) // | OUTTG | | | | | | | | | | | | | // | BTCLR | BT1 | BT2 | BT3 | BT4 | BT5 | | | VOLDN | VOLUP | MUTE | | | // | | | | | | | | | | | | | | -// | | | | | | | | +// | | | | | | | | label = "Super"; bindings = < &out OUT_TOG ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ @@ -106,6 +108,20 @@ COMBO(lnx_ao_comb, K_A K_O, DEFAULT, &lnx_no_ao) ___ ___ ___ ___ ___ ___ >; }; + MouseTP_layer { +// ---------------------------------------------------------------------------------------- +// | | | | | | | | | | | | | | +// | | | | | | | | | | | | | | +// | | | | | | | | | | | | | | +// | | | | | | | | + label = "TP"; + bindings = < + ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ + ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ + ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ + ___ ___ ___ ___ ___ ___ + >; + }; }; }; diff --git a/config/corne_alt.keymap b/config/corne_alt.keymap new file mode 100644 index 0000000..bc3b98c --- /dev/null +++ b/config/corne_alt.keymap @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + // https://caksoylar.github.io/keymap-drawer?keymap_yaml=H4sIAAAAAAAC_5WU23aTQBSG7_sU43hWGkNOLbhcS5qQtopGc7DWNCJNpk1WCCCQVbMivo0-g_e-mPPDdGxOrb3Il-GfvX82eza4zsyfxvoWIV8nY3vMZqe-Ew500vdDj9mhHzsxG4hdN4sllnHc6LTtKHBHsV38VrGLW3yLhRFsambd6FhtLAnZJl1v6roKoe8pxxFgAk2gDRwDHeAQaADvOJDXuzShluHG2DGAFlAD6sA-cAC8Al4DFvAceEivuOxPR9A-AR-BKvAB2APeAm8ABcgBz1aKaRsInvNOmF7MQoUMdf5EzihiNFFIazg6i2EYOH0m4lpYZ3GWf8FCxM35lVWNQ94dOLWqCe5gNY7MpmwecukXbhLx_x9pFhRVKHekUhDKS6kUhXJXKiWh3JNKWSj3pVIRymep7AjlgVR2hfJEKppQHkklL5THUBa6l83D9aQWO0uPu-ZfeOl8BOnQjM6HMb0aejvXA3_C0vE6JwNhzJfT1Nv0Buud08fJTjyeBUwnceh4UbLh_NcFiYFY3ZAjsryVXtIhcwdrB2UxAZU2jcOWufTK1TX-U_OAChSu6UwXLejRtU2tlxVC6hVgB9iVWdvIegGcnIBzINngoiK3ABSBknSxkfUU-E5Xi_ufc1hq16aW0xpzN72PK6Y39bzvT0799IO3TeaBTroqf6xiTyFj7vnnFzd0uUjF15DyDYcn-4FCfJ3kczzYCft21HdcbqrmCpXkn5WWOWVWv29nlc9ppWSxKu2yqp83WWlLVeXLyV_cwd0WIAYAAA%3D%3D + +#include <behaviors.dtsi> +#include <dt-bindings/zmk/keys.h> +#include <dt-bindings/zmk/bt.h> + +#include "../utils/keypos_42keys.h" + +#define K_E LT2 +#define K_O RT3 +#define K_A LM4 + +#define DEFAULT 0 +#define LOWER 1 +#define RAISE 2 +#define SUPER 3 + +#include "common.h" + +COMBO(lnx_oe_comb, K_O K_E, DEFAULT, &lnx_no_oe) +COMBO(lnx_ae_comb, K_A K_E, DEFAULT, &lnx_no_ae) +COMBO(lnx_ao_comb, K_A K_O, DEFAULT, &lnx_no_ao) + +/ { + behaviors { + kp_mo: behavior_kp_mo { + compatible = "zmk,behavior-hold-tap"; + label = "kp_mo"; + #binding-cells = <2>; + flavor = "hold-preferred"; + tapping-term-ms = <200>; + bindings = <&mo>, <&kp>; + }; + td_alt: td_alt { + compatible = "zmk,behavior-tap-dance"; + label = "td_alt"; + #binding-cells = <0>; + tapping-term-ms = <200>; + bindings = <&kp LALT>, <&kp RALT>; + }; + }; + keymap { + compatible = "zmk,keymap"; + + default_layer { +// --------------------------------------------------------------------------------------- +// | | Q | W | E | R | T | | Y | U | I | O | P | | +// | ALT | A | S | D | F | G | | H | J | K | L | ; | ' | +// | GUI | Z | X | C | V | B | | N | M | , | . | / | | +// | TAB |SHIFT| ENT/RSE | | SPC/LWR | BKSP | CTRL/ESC | + label = "Base"; + bindings = < + XXX &kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P XXX + &td_alt &kp A &kp S &kp D &kp F &kp G &kp H &kp J &kp K &kp L &kp SEMI &kp SQT + &kp LGUI &kp Z &kp X &kp C &kp V &kp B &kp N &kp M &kp COMMA &kp DOT &kp FSLH XXX + &kp TAB &kp_mo RAISE RET &kp LSHIFT &kp BSPC &kp_mo LOWER SPACE &mt LCTRL ESC + >; + }; + lower_layer { +// ---------------------------------------------------------------------------------------- +// | | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | | +// | | | | | | | | LFT | DWN | UP | RGT | | | +// | | | | | | | | HME | P_D | P_U | END | | | +// | | | | | | | | + label = "Lower"; + bindings = < + &kp GRAVE &kp N1 &kp N2 &kp N3 &kp N4 &kp N5 &kp N6 &kp N7 &kp N8 &kp N9 &kp N0 &kp BSPC + ___ ___ ___ ___ ___ ___ &kp LEFT &kp DOWN &kp UP &kp RIGHT ___ ___ + &kp LGUI ___ ___ ___ ___ ___ &kp HOME &kp PG_DN &kp PG_UP &kp END ___ ___ + ___ ___ ___ ___ ___ ___ + >; + }; + raise_layer { +// --------------------------------------------------------------------------------------- +// | | F9 | F10 | F11 | F12 | | | | | | [ | ] | | +// | | F5 | F6 | F7 | F8 | | | - | = | \ | { | } | | +// | | F1 | F2 | F3 | F4 | | | _ | + | | | | | | +// | | | | | | | | + label = "Raise"; + bindings = < + ___ &kp F9 &kp F10 &kp F11 &kp F12 ___ ___ ___ ___ &kp LBKT &kp RBKT ___ + ___ &kp F5 &kp F6 &kp F7 &kp F8 ___ &kp MINUS &kp EQUAL &kp BSLH &kp LBRC &kp RBRC ___ + ___ &kp F1 &kp F2 &kp F3 &kp F4 ___ &kp UNDER &kp PLUS &kp PIPE ___ ___ ___ + ___ ___ ___ &kp DEL ___ ___ + >; + }; + super { +// ---------------------------------------------------------------------------------------- +// | | | | | | | | | | | | | | +// | BTCLR| BT1 | BT2 | BT3 | BT4 | BT5 | | | | | | | | +// | | | | | | | | | | | | | | +// | | | | | | | | + label = "Super"; + bindings = < + ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ + &bt BT_CLR &bt BT_SEL 0 &bt BT_SEL 1 &bt BT_SEL 2 &bt BT_SEL 3 &bt BT_SEL 4 ___ ___ ___ ___ ___ ___ + ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ + ___ ___ ___ ___ ___ ___ + >; + }; + }; +}; + diff --git a/config/corne_left.conf b/config/corne_left.conf new file mode 100644 index 0000000..6be7c3c --- /dev/null +++ b/config/corne_left.conf @@ -0,0 +1,2 @@ +CONFIG_ZMK_SPLIT_ROLE_CENTRAL=n +CONFIG_ZMK_USB_LOGGING=n diff --git a/config/corne_right.conf b/config/corne_right.conf new file mode 100644 index 0000000..9a282bd --- /dev/null +++ b/config/corne_right.conf @@ -0,0 +1,2 @@ +CONFIG_ZMK_SPLIT_ROLE_CENTRAL=y +CONFIG_ZMK_USB_LOGGING=y diff --git a/config/corne_right.overlay b/config/corne_right.overlay new file mode 100644 index 0000000..d0b2c61 --- /dev/null +++ b/config/corne_right.overlay @@ -0,0 +1,262 @@ +/* + * Copyright (c) 2020 Pete Johanson + * + * SPDX-License-Identifier: MIT + */ + +#include "boards/shields/corne/corne.dtsi" + +/* + * PS/2 Mouse / Trackpoint + */ + +// Enable PS/2 drivers on this side of the keyboard. +// MUST be the central. +// +// Comment out the following define to use the GPIO driver instead of UART +// (this is not recommended unless you can't use the UART driver for whatever +// reason) +#define MOUSE_PS2_DRIVER_UART + +#ifdef MOUSE_PS2_DRIVER_UART + &uart0 { + status = "okay"; + }; + &uart_ps2 { + status = "okay"; + }; +#else + &gpio_ps2 { + status = "okay"; + }; +#endif + +&mouse_ps2 { + status = "okay"; + +#ifdef MOUSE_PS2_DRIVER_UART + ps2-device = <&uart_ps2>; +#else + ps2-device = <&gpio_ps2>; +#endif +}; + +&input_config { + status = "okay"; +}; + +// Adjust GPIO interrupt priority to the highest level. +// +// PS/2 events must be processed within 30-50us, but frequently bluetooth and +// other interrupts take longer to finish. +// +// Therefore we change the default GPIO priority to the highest level (0) and +// demote all BT interrupt priorities by one level using the kconfig settings: +// - CONFIG_BT_CTLR_LLL_PRIO 1 +// - CONFIG_BT_CTLR_ULL_HIGH_PRIO 2 +// - CONFIG_BT_CTLR_ULL_LOW_PRIOCONFIG 2 +// +// These config options are enabled automatically by the PS2 UART and GPIO +// drivers... so you don't have to enable them manually. +// +// Then we lower the interrupt priority of all other devices by 2 levels using +// the devicetree config below. +// +// This allows the PS/2 interrupts to be triggered faster and reduces +// transmission errors. +// +// If you are using the nice_nano_v2 board, you can reuse my config below. +// +// Otherwise, you can generate the interrupt overrides using the following +// script in my zmk fork with the PS/2 mouse driver: +// app/scripts/gen_interrupt_priority_overrides.py +// +// Make sure to do it on a zephyr.dts where the interrupts have not been +// adjusted yet (i.e. a config that doesn't have the the following options +// enabled). +// +// If you are building using a toolchain you can find the zephyr.dts in the +// build directory, which by default is: `app/build/zephyr/zephyr.dts` +// +// If you are building using the github actions, copy the output of the build +// step `xxxx_right - nice_nano_v2 Devicetree file` into a file and run the +// script on it. + +// gpiote should have the highest interrupt priority (0) +&gpiote { + interrupts = < 6 0 >; +}; + +// All other priorities should be two levels lower than their defaults +// (which is usually 1 and should be demoted to 3) +&clock { + interrupts = < 0 3 >; +}; + +&power { + interrupts = < 0 3 >; +}; + +&radio { + interrupts = < 1 3 >; +}; + +&uart0 { + interrupts = < 2 3 >; +}; + +&i2c0 { + interrupts = < 3 3 >; +}; + +&spi0 { + interrupts = < 3 3 >; +}; + +&i2c1 { + interrupts = < 4 3 >; +}; + +&spi1 { + interrupts = < 4 3 >; +}; + +&nfct { + interrupts = < 5 3 >; +}; + +&adc { + interrupts = < 7 3 >; +}; + +&timer0 { + interrupts = < 8 3 >; +}; + +&timer1 { + interrupts = < 9 3 >; +}; + +&timer2 { + interrupts = < 10 3 >; +}; + +&rtc0 { + interrupts = < 11 3 >; +}; + +&temp { + interrupts = < 12 3 >; +}; + +&rng { + interrupts = < 13 3 >; +}; + +&ecb { + interrupts = < 14 3 >; +}; + +&ccm { + interrupts = < 15 3 >; +}; + +&wdt { + interrupts = < 16 3 >; +}; + +&rtc1 { + interrupts = < 17 3 >; +}; + +&qdec { + interrupts = < 18 3 >; +}; + +&comp { + interrupts = < 19 3 >; +}; + +&egu0 { + interrupts = < 20 3 >; +}; + +&egu1 { + interrupts = < 21 3 >; +}; + +&egu2 { + interrupts = < 22 3 >; +}; + +&egu3 { + interrupts = < 23 3 >; +}; + +&egu4 { + interrupts = < 24 3 >; +}; + +&egu5 { + interrupts = < 25 3 >; +}; + +&timer3 { + interrupts = < 26 3 >; +}; + +&timer4 { + interrupts = < 27 3 >; +}; + +&pwm0 { + interrupts = < 28 3 >; +}; + +&pdm0 { + interrupts = < 29 3 >; +}; + +&pwm1 { + interrupts = < 33 3 >; +}; + +&pwm2 { + interrupts = < 34 3 >; +}; + +&spi2 { + interrupts = < 35 3 >; +}; + +&rtc2 { + interrupts = < 36 3 >; +}; + +&i2s0 { + interrupts = < 37 3 >; +}; + +&usbd { + interrupts = < 39 3 >; +}; + +&uart1 { + interrupts = < 40 3 >; +}; + +&qspi { + interrupts = < 41 3 >; +}; + +&pwm3 { + interrupts = < 45 3 >; +}; + +&spi3 { + interrupts = < 47 3 >; +}; + +&cryptocell { + interrupts = < 42 3 >; +}; diff --git a/config/includes/combos.dtsi b/config/includes/combos.dtsi new file mode 100644 index 0000000..f24cffb --- /dev/null +++ b/config/includes/combos.dtsi @@ -0,0 +1,183 @@ +#define COMBO_TERM_FAST 35 +#define COMBO_TERM_SLOW 40 +#define COMBO_PRIOR_IDLE 100 + +/ { + combos { + compatible = "zmk,combos"; + + combo_bracket_v_round_l { + timeout-ms = <COMBO_TERM_FAST>; + require-prior-idle-ms = <COMBO_PRIOR_IDLE>; + key-positions = <LT1 LM1>; + layers = <BASE BASE_QWERTY SYM NUM NUM_WORD>; + bindings = <&kp LPAR>; + }; + + combo_bracket_v_round_r { + timeout-ms = <COMBO_TERM_FAST>; + require-prior-idle-ms = <COMBO_PRIOR_IDLE>; + key-positions = <RT1 RM1>; + layers = <BASE BASE_QWERTY SYM NUM NUM_WORD>; + bindings = <&kp RPAR>; + }; + + combo_bracket_v_square_l { + timeout-ms = <COMBO_TERM_SLOW>; + require-prior-idle-ms = <COMBO_PRIOR_IDLE>; + key-positions = <LT2 LM2>; + layers = <BASE BASE_QWERTY SYM NUM NUM_WORD>; + bindings = <&kp LBKT>; + }; + + combo_bracket_v_square_r { + timeout-ms = <COMBO_TERM_SLOW>; + require-prior-idle-ms = <COMBO_PRIOR_IDLE>; + key-positions = <RT2 RM2>; + layers = <BASE BASE_QWERTY SYM NUM NUM_WORD>; + bindings = <&kp RBKT>; + }; + + combo_bracket_v_curly_l { + timeout-ms = <COMBO_TERM_SLOW>; + require-prior-idle-ms = <COMBO_PRIOR_IDLE>; + key-positions = <LT3 LM3>; + layers = <BASE BASE_QWERTY SYM NUM NUM_WORD>; + bindings = <&kp LBRC>; + }; + + combo_bracket_v_curly_r { + timeout-ms = <COMBO_TERM_SLOW>; + require-prior-idle-ms = <COMBO_PRIOR_IDLE>; + key-positions = <RT3 RM3>; + layers = <BASE BASE_QWERTY SYM NUM NUM_WORD>; + bindings = <&kp RBRC>; + }; + + combo_bracket_v_angled_l { + timeout-ms = <COMBO_TERM_SLOW>; + require-prior-idle-ms = <COMBO_PRIOR_IDLE>; + key-positions = <LM1 LB1>; + layers = <BASE BASE_QWERTY SYM NUM NUM_WORD>; + bindings = <&kp LT>; + }; + + combo_bracket_v_angled_r { + timeout-ms = <COMBO_TERM_SLOW>; + require-prior-idle-ms = <COMBO_PRIOR_IDLE>; + key-positions = <RM1 RB1>; + layers = <BASE BASE_QWERTY SYM NUM NUM_WORD>; + bindings = <&kp GT>; + }; + + combo_capsword { + timeout-ms = <COMBO_TERM_SLOW>; + require-prior-idle-ms = <COMBO_PRIOR_IDLE>; + key-positions = <LM1 RM1>; + layers = <BASE BASE_QWERTY>; + +#ifdef HAS_CAPSLOCK + bindings = <&caps_word_capslock >; +#else + bindings = <&caps_word>; +#endif + }; + + combo_return { + timeout-ms = <COMBO_TERM_FAST>; + require-prior-idle-ms = <COMBO_PRIOR_IDLE>; + key-positions = <LH2 LH1 LH0>; + layers = <BASE BASE_QWERTY NAV NUM SYM>; + bindings = <&kp RET>; + }; + + combo_bspc { + timeout-ms = <COMBO_TERM_FAST>; + require-prior-idle-ms = <COMBO_PRIOR_IDLE>; + key-positions = <LH1 LH0>; + layers = <BASE BASE_QWERTY NAV NUM SYM>; + bindings = <&kp BSPC>; + }; + + // combo_grave { + // timeout-ms = <COMBO_TERM_SLOW>; + // require-prior-idle-ms = <COMBO_PRIOR_IDLE>; + // key-positions = <RM3 RM4>; + // layers = <>; + // bindings = <&kp GRAVE>; + // }; + + // combo_md_code_block { + // timeout-ms = <COMBO_TERM_SLOW>; + // require-prior-idle-ms = <COMBO_PRIOR_IDLE>; + // key-positions = <RM2 RM3 RM4>; + // layers = <>; + // bindings = <&m_type_md_code_block>; + // }; + + combo_tog_nav_word { + timeout-ms = <COMBO_TERM_SLOW>; + require-prior-idle-ms = <COMBO_PRIOR_IDLE>; + key-positions = <LM3 LM2 LM1>; + layers = <BASE BASE_QWERTY NUM NUM_WORD>; + + #ifdef HAS_UROB + bindings = <&nav_word>; + #else + bindings = <&tog NAV_WORD>; + #endif + + }; + + combo_tog_num_word { + timeout-ms = <COMBO_TERM_SLOW>; + require-prior-idle-ms = <COMBO_PRIOR_IDLE>; + key-positions = <LB3 LB2 LB1>; + layers = <BASE BASE_QWERTY NAV NAV_WORD>; + + #ifdef HAS_UROB + bindings = <&num_word>; + #else + bindings = <&tog NUM_WORD>; + #endif + + }; + +#ifdef HAS_MOUSE_TP + combo_tog_mouse_settings_l { + timeout-ms = <COMBO_TERM_SLOW>; + // require-prior-idle-ms = <COMBO_PRIOR_IDLE>; + key-positions = <LT2 LT3 LT4>; + layers = <BASE BASE_QWERTY NAV NAV_WORD MOUSE_KEYS>; + bindings = <&tog MOUSE_SET>; + }; + + combo_tog_mouse_settings_r { + timeout-ms = <COMBO_TERM_SLOW>; + // require-prior-idle-ms = <COMBO_PRIOR_IDLE>; + key-positions = <RT2 RT3 RT4>; + layers = <BASE BASE_QWERTY NAV NAV_WORD MOUSE_KEYS>; + bindings = <&tog MOUSE_SET>; + }; +#endif + +#ifdef HAS_MOUSE_KEYS + combo_tog_mouse_keys_l { + timeout-ms = <COMBO_TERM_SLOW>; + // require-prior-idle-ms = <COMBO_PRIOR_IDLE>; + key-positions = <LM2 LM3 LM4>; + layers = <BASE BASE_QWERTY NAV NAV_WORD MOUSE_KEYS>; + bindings = <&tog MOUSE_KEYS>; + }; + + combo_tog_mouse_keys_r { + timeout-ms = <COMBO_TERM_SLOW>; + // require-prior-idle-ms = <COMBO_PRIOR_IDLE>; + key-positions = <RM2 RM3 RM4>; + layers = <BASE BASE_QWERTY NAV NAV_WORD MOUSE_KEYS>; + bindings = <&tog MOUSE_KEYS>; + }; +#endif + + }; +}; diff --git a/config/includes/mouse_keys.dtsi b/config/includes/mouse_keys.dtsi new file mode 100644 index 0000000..aa98ed4 --- /dev/null +++ b/config/includes/mouse_keys.dtsi @@ -0,0 +1,15 @@ +#ifdef HAS_MOUSE_KEYS + #include <dt-bindings/zmk/mouse.h> +#endif + + +// Below are settings and behavior defines for mouse keys. +&mmv { + acceleration-exponent = <1>; // Default: 1 + time-to-max-speed-ms = <300>; // Default: 300 +}; + +&msc { + acceleration-exponent = <0>; // Default: 0 + time-to-max-speed-ms = <300>; // Default: 300 +}; diff --git a/config/includes/mouse_tp.dtsi b/config/includes/mouse_tp.dtsi new file mode 100644 index 0000000..52856ca --- /dev/null +++ b/config/includes/mouse_tp.dtsi @@ -0,0 +1,142 @@ +#ifdef HAS_MOUSE_TP + #include <dt-bindings/zmk/mouse_settings.h> + + /* + * Key Behaviors to adjust settings + */ + + // They key codes below can be used to adjust the TP settings at runtime + // without needing to recompile the firmware. + // + // The values will be logged and saved in the config on the controller flash + // after 60s (CONFIG_ZMK_SETTINGS_SAVE_DEBOUNCE). + // + // On boot the settings will be restored again. + // + // If you prefer a more explicit way of configuration, you can also hardcode + // these settings in `&mouse_ps2`. + // + // If you set these settings in `&mouse_ps2`, you will still be able to + // adjust the values during runtime with these key codes, but after + // restarting the board the values in `&mouse_ps2` will be restored and not + // the ones stored in the flash using the key codes. + + + // How sensitive the trackpoint is + #define U_MSS_TP_S_I &mms MS_TP_SENSITIVITY_INCR + #define U_MSS_TP_S_D &mms MS_TP_SENSITIVITY_DECR + + + // The maximum speed the trackpoint will accelerate to + #define U_MSS_TP_V6_I &mms MS_TP_VALUE6_INCR + #define U_MSS_TP_V6_D &mms MS_TP_VALUE6_DECR + + + // I am not quite sure tbh... default seems fine. + #define U_MSS_TP_NI_I &mms MS_TP_NEG_INERTIA_INCR + #define U_MSS_TP_NI_D &mms MS_TP_NEG_INERTIA_DECR + + + // How hard you have to press to activate the "Press To Select" feature that + // lets you tap or press on the trackpoint to click. + // + // Not all trackpoints support it and you have to enable + // `tp-press-to-select;` in `&mouse_ps2` first. + #define U_MSS_TP_PT_I &mms MS_TP_PTS_THRESHOLD_INCR + #define U_MSS_TP_PT_D &mms MS_TP_PTS_THRESHOLD_DECR + + + // If you mess up the settings, you can use this key code to clear the + // settings from flash and re-set the default values on the TP. + // + // Make sure to wait at least CONFIG_ZMK_SETTINGS_SAVE_DEBOUNCE seconds (60 + // by default) before restarting the board to ensure the settings are + // written to flash storage. + #define U_MSS_RESET &mms MS_RESET + + + // If you prefer to set the settings in `&mouse_ps2`, you can use the key + // codes above to find the settings you like the most and then press this + // key code to output the settings to the log. + // + // Then you can add those values to `&mouse_ps2` + #define U_MSS_LOG &mms MS_LOG + + + /* + * Driver-specific configuration + */ + + &mouse_ps2 { + // Enables scroll wheel on mouse devices supporting the Intellimouse + // extension. + // scroll-mode; + + + // Disables clicking. Useful when using a PS2 driver that is prone to + // erros in transmissions to reduce accidental clicks. + // disable-clicking; + + // The frequency at which the mouse samples and sends data (in hz). + // The default rate is 100. You can try lowering it if you experience + // connection errors. + // + // Higher values than 100 are no improvement in my experience, but will + // increase battery life and potentially errors in transmissions. + // + // These values are allowed: 10,20,40,60,80,100,200 + // sampling-rate = <60>; + + + // Enable clicking by tapping on the TP. Not all TPs support this. + // tp-press-to-select; + // tp-press-to-select-threshold = <10>; + + + // How sensitive the TP is (Default: 128) + tp-sensitivity = <135>; + + + // The maximum mouse movement speed the TP will accelarate to (Default: 97) + tp-val6-upper-speed = <182>; + + + // Not quite sure what it does tbh :) (Default: 6) + tp-neg-inertia = <6>; + + + // Adjusts axis settings on the TP + // Works only on some trackpoints, but may be properly considered by the + // trackpoint's acceleration features (which may or may not have an + // impact). Alternatively consider achieving the same effect using the + // `zmk,input-configs` feature. + // tp-xy-swap; + // tp-x-invert; + // tp-y-invert; + + }; + + /* + * Input Config + */ + + &mouse_ps2_config { + xy-swap; + x-invert; + y-invert; + + // Set the layer that should automatically activate when the mouse is + // moving. + layer-toggle = <MOUSE_TP>; + + // How long the mouse needs to move for before the layer is activated (to + // avoid accidental activations while typing) (Default: 250) + layer-toggle-delay-ms = <250>; + + // How long to wait, after the last mouse movement, before deactivating + // the layer (Default: 250) + layer-toggle-timeout-ms = <250>; + }; + + +#endif diff --git a/config/utils/common.h b/config/utils/common.h index babff13..57ee0d0 100644 --- a/config/utils/common.h +++ b/config/utils/common.h @@ -2,7 +2,7 @@ #define XXX &none #ifndef QUICK_TAP_MS - #define QUICK_TAP_MS 175 + #define QUICK_TAP_MS 172 #endif #define ZMK_HELPER_STRINGIFY(x) #x @@ -25,6 +25,33 @@ }; +// Some general behaviours that are slightly tweaked from the core +/ { + behaviours { + kp_mo: behavior_kp_mo { + compatible = "zmk,behavior-hold-tap"; + label = "kp_mo"; + #binding-cells = <2>; + flavor = "tap-preferred"; + tapping-term-ms = <200>; + quick-tap-ms = <200>; + require-prior-idle-ms = <140>; + bindings = <&mo>, <&kp>; + }; + kp_mt: behavior_kp_mt { + compatible = "zmk,behavior-hold-tap"; + label = "kp_mt"; + #binding-cells = <2>; + flavor = "tap-preferred"; + tapping-term-ms = <QUICK_TAP_MS>; + quick-tap-ms = <QUICK_TAP_MS>; + //require-prior-idle-ms = <100>; + bindings = <&kp>, <&kp>; + }; + }; +}; + + #include "homerow.h" #include "unicode.h" diff --git a/config/west.yml b/config/west.yml index 379d291..122f468 100644 --- a/config/west.yml +++ b/config/west.yml @@ -1,11 +1,26 @@ -manifest: - remotes: - - name: zmkfirmware - url-base: https://github.com/zmkfirmware - projects: - - name: zmk - remote: zmkfirmware - revision: main - import: app/west.yml - self: - path: config +#manifest: +# remotes: +# - name: zmkfirmware +# url-base: https://github.com/zmkfirmware +# projects: +# - name: zmk +# remote: zmkfirmware +# revision: main +# import: app/west.yml +# self: +# path: config + manifest: + remotes: + - name: zmkfirmware + url-base: https://github.com/zmkfirmware + - name: urob + url-base: https://github.com/urob + - name: infused-kim + url-base: https://github.com/infused-kim + projects: + - name: zmk + remote: infused-kim + revision: pr-testing/mouse_ps2_v2 + import: app/west.yml + self: + path: config |