From 3284d256f85c1c6611819e3e84253a979ed09cdb Mon Sep 17 00:00:00 2001 From: Deividas Petraitis Date: Wed, 28 Feb 2024 10:06:03 +0200 Subject: [PATCH] Think Corne init --- .github/workflows/build.yml | 2 +- .gitignore | 12 + .../shields/think_corne/Kconfig.defconfig | 25 ++ .../boards/shields/think_corne/Kconfig.shield | 11 + .../shields/think_corne/think_corne.dtsi | 269 +++++++++++++++++ .../shields/think_corne/think_corne.zmk.yml | 12 + .../shields/think_corne/think_corne_left.conf | 0 .../think_corne/think_corne_left.overlay | 21 ++ .../think_corne/think_corne_right.conf | 0 .../think_corne/think_corne_right.overlay | 280 ++++++++++++++++++ config/corne.conf | 6 - config/corne.keymap | 56 ---- config/includes/mouse_keys.dtsi | 15 + config/includes/mouse_tp.dtsi | 142 +++++++++ config/think_corne.conf | 17 ++ config/think_corne.keymap | 78 +++++ config/think_corne_left.conf | 5 + config/think_corne_right.conf | 5 + config/west.yml | 8 +- 19 files changed, 899 insertions(+), 65 deletions(-) create mode 100644 .gitignore create mode 100644 config/boards/shields/think_corne/Kconfig.defconfig create mode 100644 config/boards/shields/think_corne/Kconfig.shield create mode 100644 config/boards/shields/think_corne/think_corne.dtsi create mode 100644 config/boards/shields/think_corne/think_corne.zmk.yml create mode 100644 config/boards/shields/think_corne/think_corne_left.conf create mode 100644 config/boards/shields/think_corne/think_corne_left.overlay create mode 100644 config/boards/shields/think_corne/think_corne_right.conf create mode 100644 config/boards/shields/think_corne/think_corne_right.overlay delete mode 100644 config/corne.conf delete mode 100644 config/corne.keymap create mode 100644 config/includes/mouse_keys.dtsi create mode 100644 config/includes/mouse_tp.dtsi create mode 100644 config/think_corne.conf create mode 100644 config/think_corne.keymap create mode 100644 config/think_corne_left.conf create mode 100644 config/think_corne_right.conf diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d74fb89..8735e7b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,4 +2,4 @@ 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 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..179c8fd --- /dev/null +++ b/.gitignore @@ -0,0 +1,12 @@ +# This is global git excludes file which is intended point to location configured core.excludesfile option. +# You can check current value of it by running: +# git config --get core.excludesfile +.env + +# Vim backup, undo files +*.orig +*~ + +# Vim swap files +.*.swp +.*.swo diff --git a/config/boards/shields/think_corne/Kconfig.defconfig b/config/boards/shields/think_corne/Kconfig.defconfig new file mode 100644 index 0000000..a0a0c24 --- /dev/null +++ b/config/boards/shields/think_corne/Kconfig.defconfig @@ -0,0 +1,25 @@ +# The Kconfig.defconfig file is where overrides for various configuration settings that make sense +# to have different defaults when this shield is used. +# One main item that usually has a new default value set here is the ZMK_KEYBOARD_NAME value, +# which controls the display name of the device over USB and BLE. +# The updated new default values should always be wrapped inside a conditional on the shield +# config name defined in the Kconfig.shield file. +# +# The side with the PS2 Mouse / TP has to be the central half + +if SHIELD_THINK_CORNE_RIGHT + +config ZMK_KEYBOARD_NAME + default "ThinkCorne" + +config ZMK_SPLIT_ROLE_CENTRAL + default y + +endif + +if SHIELD_THINK_CORNE_LEFT || SHIELD_THINK_CORNE_RIGHT + +config ZMK_SPLIT + default y + +endif diff --git a/config/boards/shields/think_corne/Kconfig.shield b/config/boards/shields/think_corne/Kconfig.shield new file mode 100644 index 0000000..2b87960 --- /dev/null +++ b/config/boards/shields/think_corne/Kconfig.shield @@ -0,0 +1,11 @@ +# Copyright (c) 2020 Pete Johanson +# SPDX-License-Identifier: MIT + +# The Kconfig.shield file defines any additional Kconfig settings that may be relevant when using this keyboard. +# For most keyboards, there is just one additional configuration value for the shield itself. + +config SHIELD_THINK_CORNE_LEFT + def_bool $(shields_list_contains,think_corne_left) + +config SHIELD_THINK_CORNE_RIGHT + def_bool $(shields_list_contains,think_corne_right) diff --git a/config/boards/shields/think_corne/think_corne.dtsi b/config/boards/shields/think_corne/think_corne.dtsi new file mode 100644 index 0000000..121a888 --- /dev/null +++ b/config/boards/shields/think_corne/think_corne.dtsi @@ -0,0 +1,269 @@ +#include + +/* + * Matrix + */ + +/ { + chosen { + 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)? +}; + +/* + * Nice!View + */ + +&pinctrl { + spi0_default: spi0_default { + group1 { + psels = , + , + ; + }; + }; + spi0_sleep: spi0_sleep { + group1 { + psels = , + , + ; + low-power-enable; + }; + }; +}; + +nice_view_spi: &spi0 { + compatible = "nordic,nrf-spim"; + pinctrl-0 = <&spi0_default>; + pinctrl-1 = <&spi0_sleep>; + pinctrl-names = "default", "sleep"; + cs-gpios = <&pro_micro 9 GPIO_ACTIVE_HIGH>; // Not the default 1 +}; + +&pro_micro_i2c { + status = "disabled"; +}; + +/* + * 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 + + +// 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 +#define MOUSE_PS2_PIN_UNEXPOSED_RX + + +// 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/boards/shields/think_corne/think_corne.zmk.yml b/config/boards/shields/think_corne/think_corne.zmk.yml new file mode 100644 index 0000000..16974b7 --- /dev/null +++ b/config/boards/shields/think_corne/think_corne.zmk.yml @@ -0,0 +1,12 @@ +file_format: "1" +id: think_corne +name: ThinkCorne +type: shield +url: https://github.com/infused-kim/kb_think_corney +requires: [pro_micro] +features: + - keys + - display +siblings: + - think_corne_left + - think_corne_right diff --git a/config/boards/shields/think_corne/think_corne_left.conf b/config/boards/shields/think_corne/think_corne_left.conf new file mode 100644 index 0000000..e69de29 diff --git a/config/boards/shields/think_corne/think_corne_left.overlay b/config/boards/shields/think_corne/think_corne_left.overlay new file mode 100644 index 0000000..ce08071 --- /dev/null +++ b/config/boards/shields/think_corne/think_corne_left.overlay @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2020 Pete Johanson + * + * SPDX-License-Identifier: MIT + */ +#include "think_corne.dtsi" + +/* + * Matrix + */ + +&kscan0 { + col-gpios + = <&pro_micro 21 GPIO_ACTIVE_HIGH> + , <&pro_micro 20 GPIO_ACTIVE_HIGH> + , <&pro_micro 19 GPIO_ACTIVE_HIGH> + , <&pro_micro 18 GPIO_ACTIVE_HIGH> + , <&pro_micro 15 GPIO_ACTIVE_HIGH> + , <&pro_micro 14 GPIO_ACTIVE_HIGH> + ; +}; diff --git a/config/boards/shields/think_corne/think_corne_right.conf b/config/boards/shields/think_corne/think_corne_right.conf new file mode 100644 index 0000000..e69de29 diff --git a/config/boards/shields/think_corne/think_corne_right.overlay b/config/boards/shields/think_corne/think_corne_right.overlay new file mode 100644 index 0000000..acf7655 --- /dev/null +++ b/config/boards/shields/think_corne/think_corne_right.overlay @@ -0,0 +1,280 @@ +/* + * Copyright (c) 2020 Pete Johanson + * + * SPDX-License-Identifier: MIT + */ +#include "think_corne.dtsi" + +/* + * Matrix + */ + +&default_transform { + col-offset = <6>; +}; + +&kscan0 { + col-gpios + = <&pro_micro 14 GPIO_ACTIVE_HIGH> + , <&pro_micro 15 GPIO_ACTIVE_HIGH> + , <&pro_micro 18 GPIO_ACTIVE_HIGH> + , <&pro_micro 19 GPIO_ACTIVE_HIGH> + , <&pro_micro 20 GPIO_ACTIVE_HIGH> + , <&pro_micro 21 GPIO_ACTIVE_HIGH> + ; +}; + +/* + * 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/corne.conf b/config/corne.conf deleted file mode 100644 index 974243c..0000000 --- a/config/corne.conf +++ /dev/null @@ -1,6 +0,0 @@ -# Uncomment the following lines to enable the Corne RGB Underglow -# CONFIG_ZMK_RGB_UNDERGLOW=y -# CONFIG_WS2812_STRIP=y - -# Uncomment the following line to enable the Corne OLED Display -# CONFIG_ZMK_DISPLAY=y diff --git a/config/corne.keymap b/config/corne.keymap deleted file mode 100644 index 0555cf4..0000000 --- a/config/corne.keymap +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2020 The ZMK Contributors - * - * SPDX-License-Identifier: MIT - */ - -#include -#include -#include - -/ { - keymap { - compatible = "zmk,keymap"; - - default_layer { -// ----------------------------------------------------------------------------------------- -// | TAB | Q | W | E | R | T | | Y | U | I | O | P | BKSP | -// | CTRL | A | S | D | F | G | | H | J | K | L | ; | ' | -// | SHFT | Z | X | C | V | B | | N | M | , | . | / | ESC | -// | GUI | LWR | SPC | | ENT | RSE | ALT | - bindings = < - &kp TAB &kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P &kp BSPC - &kp LCTRL &kp A &kp S &kp D &kp F &kp G &kp H &kp J &kp K &kp L &kp SEMI &kp SQT - &kp LSHFT &kp Z &kp X &kp C &kp V &kp B &kp N &kp M &kp COMMA &kp DOT &kp FSLH &kp ESC - &kp LGUI &mo 1 &kp SPACE &kp RET &mo 2 &kp RALT - >; - }; - lower_layer { -// ----------------------------------------------------------------------------------------- -// | TAB | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | BKSP | -// | BTCLR| BT1 | BT2 | BT3 | BT4 | BT5 | | LFT | DWN | UP | RGT | | | -// | SHFT | | | | | | | | | | | | | -// | GUI | | SPC | | ENT | | ALT | - bindings = < - &kp TAB &kp N1 &kp N2 &kp N3 &kp N4 &kp N5 &kp N6 &kp N7 &kp N8 &kp N9 &kp N0 &kp BSPC - &bt BT_CLR &bt BT_SEL 0 &bt BT_SEL 1 &bt BT_SEL 2 &bt BT_SEL 3 &bt BT_SEL 4 &kp LEFT &kp DOWN &kp UP &kp RIGHT &trans &trans - &kp LSHFT &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans - &kp LGUI &trans &kp SPACE &kp RET &trans &kp RALT - >; - }; - - raise_layer { -// ----------------------------------------------------------------------------------------- -// | TAB | ! | @ | # | $ | % | | ^ | & | * | ( | ) | BKSP | -// | CTRL | | | | | | | - | = | [ | ] | \ | ` | -// | SHFT | | | | | | | _ | + | { | } | "|" | ~ | -// | GUI | | SPC | | ENT | | ALT | - bindings = < - &kp TAB &kp EXCL &kp AT &kp HASH &kp DLLR &kp PRCNT &kp CARET &kp AMPS &kp KP_MULTIPLY &kp LPAR &kp RPAR &kp BSPC - &kp LCTRL &trans &trans &trans &trans &trans &kp MINUS &kp EQUAL &kp LBKT &kp RBKT &kp BSLH &kp GRAVE - &kp LSHFT &trans &trans &trans &trans &trans &kp UNDER &kp PLUS &kp LBRC &kp RBRC &kp PIPE &kp TILDE - &kp LGUI &trans &kp SPACE &kp RET &trans &kp RALT - >; - }; - }; -}; 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 +#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 + + /* + * 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 = ; + + // 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/think_corne.conf b/config/think_corne.conf new file mode 100644 index 0000000..6f37b0f --- /dev/null +++ b/config/think_corne.conf @@ -0,0 +1,17 @@ +# Uncomment the following lines to enable the Corne RGB Underglow +CONFIG_ZMK_RGB_UNDERGLOW=n +CONFIG_WS2812_STRIP=y + +# Uncomment the following line to enable the Corne OLED Display +# CONFIG_ZMK_DISPLAY=y + +# +# Configure PS2 Mouse Settings +# + +# 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 + +# Fixes: zephyr/drivers/ps2/ps2_uart.c:433: undefined reference to `k_malloc' +CONFIG_HEAP_MEM_POOL_SIZE=256 diff --git a/config/think_corne.keymap b/config/think_corne.keymap new file mode 100644 index 0000000..005d759 --- /dev/null +++ b/config/think_corne.keymap @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#include +#include +#include +#include +#include + +/* Layer active when mouse is active? */ +#define MOUSE_TP 0 + +/* Enable keymap features that require forks */ +#define HAS_UROB +#define HAS_MOUSE_KEYS +#define HAS_MOUSE_TP +// #define HAS_CAPSLOCK + +// Personal includes +#ifdef HAS_MOUSE_KEYS + #include "includes/mouse_keys.dtsi" +#endif + +#ifdef HAS_MOUSE_TP + #include "includes/mouse_tp.dtsi" +#endif + +/ { + keymap { + compatible = "zmk,keymap"; + + default_layer { +// ----------------------------------------------------------------------------------------- +// | GRAVE | SEMI | COMMA | PERIOD | P | Y | | F | G | C | R | L | BKSP | +// | TAB | LGUI A | LALT O | LSHFT E | LCTRL U | I | | D | RCTRL H | RSHFT T | RALT N | RGUI S | BSLH | +// | | SQT | Q | J | K | X | | B | M | W | V | Z | FSLH | +// | LOWER ESC | SPACE | | ENT | RAISE | | + bindings = < + &kp GRAVE &kp SEMI &kp COMMA &kp PERIOD &kp P &kp Y &kp F &kp G &kp C &kp R &kp L &kp BSPC + &kp TAB &mt LGUI A &mt LALT O &mt LSHFT E &mt LCTRL U &kp I &kp D &mt RCTRL H &mt RSHFT T &mt RALT N &mt RGUI S &kp BSLH + &trans &kp SQT &kp Q &kp J &kp K &kp X &kp B &kp M &kp W &kp V &kp Z &kp FSLH + &trans < 1 ESC &kp SPACE &kp RET &mo 2 &trans + >; + }; + lower_layer { +// ----------------------------------------------------------------------------------------- +// | TAB | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | BKSP | +// | BTCLR| BT1 | BT2 | BT3 | BT4 | BT5 | | LFT | DWN | UP | RGT | | | +// | SHFT | | | | | | | | | | | | | +// | GUI | | SPC | | ENT | | ALT | + bindings = < + &kp N7 &kp N5 &kp N3 &kp N1 &kp N9 &kp N0 &kp N2 &kp N4 &kp N6 &kp N8 &kp RIGHT &kp BSPC + &trans &trans &trans &msc LCLK &msc RCLK &trans &trans &kp LEFT &trans &trans &trans &trans + &trans &trans &trans &kp DOWN &kp UP &trans &trans &trans &trans &trans &kp KP_MINUS &trans + &trans < 1 ESC &kp SPACE &kp RET &mo 2 &trans + >; + }; + + raise_layer { +// ----------------------------------------------------------------------------------------- +// | TAB | ! | @ | # | $ | % | | ^ | & | * | ( | ) | BKSP | +// | CTRL | | | | | | | - | = | [ | ] | \ | ` | +// | SHFT | | | | | | | _ | + | { | } | "|" | ~ | +// | GUI | | SPC | | ENT | | ALT | + bindings = < + &kp EXCL &kp AT &kp HASH &kp AMPS &trans &trans &kp EQUAL &kp ASTRK &trans &kp PLUS &kp DLLR &trans + &trans &trans &kp RBKT &kp LBKT &trans &trans &trans &kp CARET &kp RSHFT &trans &trans &trans + &trans &trans &trans &trans &trans &trans &kp UNDER &kp PLUS &kp LBRC &kp RBRC &kp PIPE &kp TILDE + &trans < 1 ESC &kp SPACE &kp RET &mo 2 &trans + >; + }; + }; +}; + +/* vim: set ft=c tw=174: */ diff --git a/config/think_corne_left.conf b/config/think_corne_left.conf new file mode 100644 index 0000000..ae8eb3a --- /dev/null +++ b/config/think_corne_left.conf @@ -0,0 +1,5 @@ +# +# Logging +# + +CONFIG_ZMK_USB_LOGGING=n diff --git a/config/think_corne_right.conf b/config/think_corne_right.conf new file mode 100644 index 0000000..ae8eb3a --- /dev/null +++ b/config/think_corne_right.conf @@ -0,0 +1,5 @@ +# +# Logging +# + +CONFIG_ZMK_USB_LOGGING=n diff --git a/config/west.yml b/config/west.yml index b886cbe..b8ed29e 100644 --- a/config/west.yml +++ b/config/west.yml @@ -4,10 +4,14 @@ manifest: url-base: https://github.com/zmkfirmware # Additional modules containing boards/shields/custom code can be listed here as well # See https://docs.zephyrproject.org/3.2.0/develop/west/manifest.html#projects + - name: urob + url-base: https://github.com/urob + - name: infused-kim + url-base: https://github.com/infused-kim projects: - name: zmk - remote: zmkfirmware - revision: main + remote: infused-kim + revision: pr-testing/mouse_ps2_v2 import: app/west.yml self: path: config