### Layer Toggle Configuration Examples Source: https://github.com/badjeff/kb_zmk_ps2_mouse_trackpoint_driver/blob/main/_autodocs/api-reference/input-listener.md These examples demonstrate different configurations for the automatic layer toggling feature. They show how to set the target layer, delay for activation, and timeout for deactivation. ```dts layer-toggle = <2>; layer-toggle-delay-ms = <100>; layer-toggle-timeout-ms = <200>; ``` ```dts layer-toggle = <4>; layer-toggle-delay-ms = <500>; layer-toggle-timeout-ms = <500>; ``` ```dts layer-toggle = <-1>; ``` -------------------------------- ### ZMK Mouse Settings Behavior Keymap Example Source: https://github.com/badjeff/kb_zmk_ps2_mouse_trackpoint_driver/blob/main/_autodocs/api-reference/mouse-ps2-settings.md Example ZMK keymap demonstrating the use of the `behavior_mouse_setting_ms` behavior with mouse setting constants for TrackPoint adjustments. This shows how to bind mouse setting behaviors to keycodes. ```c #include / { behaviors { mms: behavior_mouse_setting_ms { compatible = "zmk,behavior-mouse-setting"; }; }; keymap { mouse_settings_layer { // Sensitivity adjustments bindings = < &mms MS_TP_SENSITIVITY_INCR &mms MS_TP_SENSITIVITY_DECR &mms MS_LOG &mms MS_RESET >; }; }; }; ``` -------------------------------- ### Complete ZMK PS/2 Mouse and TrackPoint Configuration Example Source: https://github.com/badjeff/kb_zmk_ps2_mouse_trackpoint_driver/blob/main/_autodocs/configuration.md This Device Tree Source (DTS) example shows a full configuration for a UART PS/2 driver, mouse input, and input listener, including TrackPoint-specific settings. It also includes a behavior for mouse settings and keymap bindings. ```dts #include #include #include #include / { // UART PS/2 driver configuration ps2_uart: ps2_uart { compatible = "uart-ps2"; status = "okay"; scl-gpios = <&pro_micro 16 GPIO_ACTIVE_HIGH>; sda-gpios = <&pro_micro 10 GPIO_ACTIVE_HIGH>; }; // Mouse input configuration mouse_ps2: mouse_ps2 { compatible = "zmk,input-mouse-ps2"; ps2-device = <&ps2_uart>; rst-gpios = <&pro_micro 9 GPIO_ACTIVE_HIGH>; sampling-rate = <100>; scroll-mode; tp-press-to-select; tp-press-to-select-threshold = <8>; tp-sensitivity = <128>; tp-neg-inertia = <6>; tp-val6-upper-speed = <97>; layer-toggle = <3>; }; // Mouse input listener configuration mouse_ps2_input_listener: mouse_ps2_input_listener { compatible = "zmk,input-listener-ps2"; device = <&mouse_ps2>; xy-swap; scale-multiplier = <1>; scale-divisor = <1>; layer-toggle = <3>; layer-toggle-delay-ms = <250>; layer-toggle-timeout-ms = <250>; }; behaviors { mms: behavior_mouse_setting_ms { compatible = "zmk,behavior-mouse-setting"; }; }; keymap { default_layer { bindings = < /* ... other keys ... */ &mms MS_TP_SENSITIVITY_INCR &mms MS_LOG >; }; }; }; ``` -------------------------------- ### Device Tree Configuration for Input Listener PS/2 Source: https://github.com/badjeff/kb_zmk_ps2_mouse_trackpoint_driver/blob/main/_autodocs/api-reference/input-listener.md This example shows how to configure the Input Listener PS/2 in your device tree. It includes settings for coordinate transformation and automatic layer toggling. ```dts / { mouse_ps2_input_listener: mouse_ps2_input_listener { compatible = "zmk,input-listener-ps2"; device = <&mouse_ps2>; // Coordinate transformation xy-swap; x-invert; // Sensitivity scaling (multiply then divide for precise control) scale-multiplier = <2>; scale-divisor = <1>; // Automatic layer toggling on mouse activity layer-toggle = <3>; layer-toggle-delay-ms = <200>; layer-toggle-timeout-ms = <300>; }; }; ``` -------------------------------- ### UART PS/2 Driver Device Tree Example Source: https://github.com/badjeff/kb_zmk_ps2_mouse_trackpoint_driver/blob/main/_autodocs/api-reference/ps2-drivers.md This example configures the UART PS/2 driver in the device tree, specifying the compatible string and GPIO pins for SCL and SDA. It also includes related UART and pin control configurations. ```dts &uart0 { status = "okay"; current-speed = <14400>; pinctrl-0 = <&uart0_default>; pinctrl-1 = <&uart0_sleep>; pinctrl-names = "default", "sleep"; }; &pinctrl { uart0_default: uart0_default { group1 { psels = ; }; group2 { psels = ; }; }; uart0_sleep: uart0_sleep { group1 { psels = , ; low-power-enable; }; }; }; / { ps2_uart: ps2_uart { compatible = "uart-ps2"; status = "okay"; scl-gpios = <&pro_micro 16 GPIO_ACTIVE_HIGH>; sda-gpios = <&pro_micro 10 GPIO_ACTIVE_HIGH>; }; }; ``` -------------------------------- ### Keymap Usage for Mouse Settings Source: https://github.com/badjeff/kb_zmk_ps2_mouse_trackpoint_driver/blob/main/_autodocs/api-reference/behaviors.md Example keymap configuration demonstrating how to bind mouse setting adjustments to specific keys. This includes layers for normal key usage and a dedicated layer for accessing mouse settings. ```c #include #include #include / { behaviors { mms: behavior_mouse_setting_ms { compatible = "zmk,behavior-mouse-setting"; }; }; keymap { // Standard layer with regular keys default_layer { bindings = < &kp A &kp B &kp C &kp D &kp E &kp F &kp G &kp H &mo 1 // Hold to go to mouse settings layer >; }; // Mouse settings layer - activated by holding the key above mouse_settings_layer { bindings = < &mms MS_TP_SENSITIVITY_INCR &mms MS_TP_SENSITIVITY_DECR &kp RET &mms MS_TP_NEG_INERTIA_INCR &mms MS_TP_NEG_INERTIA_DECR &mms MS_LOG &mms MS_TP_VALUE6_INCR &mms MS_TP_VALUE6_DECR &mms MS_RESET >; }; }; }; ``` -------------------------------- ### Layer Toggling with Mouse Buttons Layer Source: https://github.com/badjeff/kb_zmk_ps2_mouse_trackpoint_driver/blob/main/_autodocs/api-reference/input-listener.md Example showing how to configure the input listener for automatic layer toggling on mouse movement, paired with a keymap for mouse buttons. ```dts // Input listener enables layer 3 on mouse movement mouse_ps2_input_listener { compatible = "zmk,input-listener-ps2"; device = <&mouse_ps2>; layer-toggle = <3>; layer-toggle-delay-ms = <250>; layer-toggle-timeout-ms = <250>; }; // Keymap keymap { default_layer { bindings = < // Regular keys >; }; mouse_buttons_layer { // Layer 3 bindings = < &mkp LCLK // Left click on key &mkp RCLK // Right click on key // etc. >; }; }; ``` -------------------------------- ### Bind Mouse Setting Behavior in Keymap Source: https://github.com/badjeff/kb_zmk_ps2_mouse_trackpoint_driver/blob/main/_autodocs/api-reference/behaviors.md Ensure the correct behavior name is used in your keymap binding. This example shows how to bind the `MS_LOG` setting. ```zmk &mms MS_LOG ``` -------------------------------- ### UART PS/2 Driver Configuration Example Source: https://github.com/badjeff/kb_zmk_ps2_mouse_trackpoint_driver/blob/main/_autodocs/configuration.md Sets up a UART-based PS/2 driver, defining the clock and data GPIO pins. This is the preferred driver for nrf52-based controllers. ```dts / { ps2_uart: ps2_uart { compatible = "uart-ps2"; status = "okay"; scl-gpios = <&pro_micro 16 GPIO_ACTIVE_HIGH>; sda-gpios = <&pro_micro 10 GPIO_ACTIVE_HIGH>; }; }; ``` -------------------------------- ### Complete Mouse Settings Example Source: https://github.com/badjeff/kb_zmk_ps2_mouse_trackpoint_driver/blob/main/_autodocs/api-reference/behaviors.md This C code defines mouse settings behaviors and a keymap for controlling mouse sensitivity, inertia, and other parameters within ZMK. It includes definitions for mouse settings, hold-tap behaviors, and specific layers for mouse configuration and buttons. ```c #include #include #include #include / { behaviors { // Define the mouse settings behavior mms: behavior_mouse_setting_ms { compatible = "zmk,behavior-mouse-setting"; }; // Optional: Create a tap behavior that enters mouse settings layer mm_layer: behavior_hold_tap { compatible = "zmk,behavior-hold-tap"; #binding-cells = <2>; tapping-term-ms = <200>; flavor = "tap-preferred"; bindings = <&mo>, <&none>; }; }; keymap { default_layer { bindings = < &kp A &kp B &kp C &kp D &kp E &kp F &kp G &kp H &kp I &kp J &kp K &kp L &kp M &kp N &mo 1 >; }; mouse_config_layer { label = "Mouse Configuration"; bindings = < &mms MS_LOG _ _ _ _ &mms MS_RESET _ _ _ _ &mms MS_TP_SENSITIVITY_DECR &mms MS_TP_SENSITIVITY_INCR &none &none &none &mms MS_TP_NEG_INERTIA_DECR &mms MS_TP_NEG_INERTIA_INCR &none &none &none &mms MS_TP_VALUE6_DECR &mms MS_TP_VALUE6_INCR &none &none &kp ESC >; }; mouse_buttons_layer { label = "Mouse Buttons"; bindings = < &mmv MOVE_UP &mms MS_TP_PTS_THRESHOLD_DECR &none &mmv MOVE_LEFT &mmv MOVE_DOWN &mmv MOVE_RIGHT _ &mms MS_TP_PTS_THRESHOLD_INCR &kp ESC >; }; }; }; ``` -------------------------------- ### PS/2 Mouse Configuration Example Source: https://github.com/badjeff/kb_zmk_ps2_mouse_trackpoint_driver/blob/main/_autodocs/configuration.md Configures the PS/2 mouse device, specifying the PS/2 controller, reset GPIO, sampling rate, and various TrackPoint-specific settings like sensitivity and inertia. ```dts / { mouse_ps2: mouse_ps2 { compatible = "zmk,input-mouse-ps2"; ps2-device = <&ps2_uart_device>; rst-gpios = <&pro_micro 9 GPIO_ACTIVE_HIGH>; sampling-rate = <100>; scroll-mode; tp-press-to-select; tp-press-to-select-threshold = <8>; tp-sensitivity = <128>; tp-neg-inertia = <6>; tp-val6-upper-speed = <97>; layer-toggle = <3>; }; }; ``` -------------------------------- ### GPIO PS/2 Driver Configuration Example Source: https://github.com/badjeff/kb_zmk_ps2_mouse_trackpoint_driver/blob/main/_autodocs/configuration.md Configures a GPIO-based PS/2 driver using bit-banging. This driver is suitable for any microcontroller but offers lower performance compared to the UART driver. ```dts / { ps2_gpio: ps2_gpio { compatible = "gpio-ps2"; status = "okay"; scl-gpios = <&pro_micro 16 GPIO_ACTIVE_HIGH>; sda-gpios = <&pro_micro 10 GPIO_ACTIVE_HIGH>; }; }; ``` -------------------------------- ### PS/2 GPIO Device Tree Configuration Source: https://github.com/badjeff/kb_zmk_ps2_mouse_trackpoint_driver/blob/main/_autodocs/api-reference/ps2-drivers.md Example of how to configure the PS/2 GPIO driver in the device tree. This specifies the compatible driver and the GPIO pins for the clock and data lines. ```dts / { ps2_gpio: ps2_gpio { compatible = "gpio-ps2"; status = "okay"; scl-gpios = <&pro_micro 16 GPIO_ACTIVE_HIGH>; sda-gpios = <&pro_micro 10 GPIO_ACTIVE_HIGH>; }; }; ``` -------------------------------- ### Configure Additional Post-Processing with ZMK Input Configs Source: https://github.com/badjeff/kb_zmk_ps2_mouse_trackpoint_driver/blob/main/_autodocs/api-reference/input-listener.md Apply additional post-processing to input events using ZMK's 'zmk,input-configs'. This example configures trackpoint speed with a specific trigger key and speed factor. ```dts &zmk_input_configs { trackpoint_speed { compatible = "zmk,input-config"; trigger-key = ; speed-factor = <1>; delay-ms = <0>; }; }; ``` -------------------------------- ### Movement Clamping Example Source: https://github.com/badjeff/kb_zmk_ps2_mouse_trackpoint_driver/blob/main/_autodocs/api-reference/input-listener.md Illustrates how large movement values are clamped to ±127 and reported across multiple HID reports. ```text raw_movement = 500 Reports sent: Report 1: movement = +127 Report 2: movement = +127 Report 3: movement = +127 Report 4: movement = +119 ``` -------------------------------- ### Upgrade ZMK-Config to Module Format Source: https://github.com/badjeff/kb_zmk_ps2_mouse_trackpoint_driver/blob/main/README.md Example commit showing necessary changes to upgrade an older ZMK-config to the new module format, specifically addressing directory structure changes for shield definitions and the addition of the zephyr directory. ```diff diff --git a/config/boards/shields/corne/corne.overlay b/config/boards/shields/corne/corne.overlay index 1234567..890abcd 100644 --- a/config/boards/shields/corne/corne.overlay +++ b/config/boards/shields/corne/corne.overlay @@ -1,3 +1,3 @@ <. -config.overlay +include/config.overlay -protean.overlay +include/protean.overlay diff --git a/zephyr/Kconfig.defconfig b/zephyr/Kconfig.defconfig index abcdef0..1234567 100644 --- a/zephyr/Kconfig.defconfig +++ b/zephyr/Kconfig.defconfig @@ -1,3 +1,3 @@ <. -defconfig +include/defconfig -drivers/kscan.defconfig +include/drivers/kscan.defconfig diff --git a/zmk-config/boards/shields/corne/corne.overlay b/boards/shields/corne/corne.overlay similarity index 80% rename from zmk-config/boards/shields/corne/corne.overlay new file mode 100644 index 1234567..890abcd --- a/zmk-config/boards/shields/corne/corne.overlay +++ b/boards/shields/corne/corne.overlay @@ -1,3 +1,3 @@ <. -config.overlay +include/config.overlay -protean.overlay +include/protean.overlay diff --git a/zmk-config/zephyr/Kconfig.defconfig b/zephyr/Kconfig.defconfig new file mode 100644 index 0000000..abcdef0 --- /dev/null +++ b/zephyr/Kconfig.defconfig @@ -0,0 +1,5 @@ +include/defconfig +include/drivers/kscan.defconfig +include/drivers/led_strip.defconfig +include/drivers/ps2.defconfig +include/drivers/sensor.defconfig \ No newline at end of file ``` -------------------------------- ### Recommended PS/2 Driver Configuration (nice!nano) Source: https://github.com/badjeff/kb_zmk_ps2_mouse_trackpoint_driver/blob/main/_autodocs/api-reference/ps2-drivers.md This configuration is recommended for the best overall performance on nice!nano boards, enabling PS/2 resend callbacks. ```text ps2_uart with error callbacks enabled CONFIG_ZMK_INPUT_MOUSE_PS2_ENABLE_PS2_RESEND_CALLBACK=y ``` -------------------------------- ### Build and Flash ZMK Firmware Source: https://github.com/badjeff/kb_zmk_ps2_mouse_trackpoint_driver/blob/main/_autodocs/quick-start.md Compile your ZMK firmware with the new shield configuration and flash it to your keyboard. ```bash # Build your firmware west build -d build/right -b nice_nano_v2 -- -DSHIELD=corne_right # Flash to keyboard # (Use your usual method for flashing ZMK) ``` -------------------------------- ### PS/2 Transmission Timing: Host to Device Source: https://github.com/badjeff/kb_zmk_ps2_mouse_trackpoint_driver/blob/main/_autodocs/api-reference/ps2-drivers.md Details the timing sequence for data transmission from the host to a PS/2 device, including start conditions and bit transfer. ```text Host to Device: - Start condition: Host pulls clock LOW for ≥100 µs - Host releases clock, waits for device clock response - Device pulls clock LOW to signal it can receive - Host sends each bit (data changes on clock LOW, sampled on clock HIGH) - Device pulls clock LOW after last bit - Host sends ack, device pulls clock/data LOW ``` -------------------------------- ### Recommended PS/2 Driver Configuration (Development/Testing) Source: https://github.com/badjeff/kb_zmk_ps2_mouse_trackpoint_driver/blob/main/_autodocs/api-reference/ps2-drivers.md This configuration is suitable for development and testing, enabling both error mitigation and PS/2 resend callbacks. ```text ps2_gpio with error mitigation CONFIG_ZMK_INPUT_MOUSE_PS2_ENABLE_ERROR_MITIGATION=y CONFIG_ZMK_INPUT_MOUSE_PS2_ENABLE_PS2_RESEND_CALLBACK=y ``` -------------------------------- ### Adjusting TrackPoint Sensitivity for Sluggish Movement Source: https://github.com/badjeff/kb_zmk_ps2_mouse_trackpoint_driver/blob/main/_autodocs/api-reference/input-listener.md Example of adjusting the scale-multiplier for trackpoint input to improve responsiveness when movement feels sluggish. This is one of several solutions for sensitivity issues. ```text Example: Change from <1, 1> to <2, 1> ``` -------------------------------- ### Common ZMK Build and Debug Commands Source: https://github.com/badjeff/kb_zmk_ps2_mouse_trackpoint_driver/blob/main/_autodocs/quick-start.md A collection of essential commands for building, debugging, and managing your ZMK firmware. Includes commands for viewing logs, building for specific boards, cleaning builds, and checking configurations. ```bash # View ZMK logs west debug ``` ```bash # Build for nice!nano v2 with corne shield west build -d build/right -b nice_nano_v2 -- -DSHIELD=corne_right ``` ```bash # Clean build west build -c -d build/right -b nice_nano_v2 -- -DSHIELD=corne_right ``` ```bash # View current configuration west build -t menuconfig ``` ```bash # Check device tree compilation west build -t dts ``` ```bash # Flash firmware (adjust for your setup) # On Linux: west flash -d build/right ``` -------------------------------- ### Log Mouse Settings to Console Source: https://github.com/badjeff/kb_zmk_ps2_mouse_trackpoint_driver/blob/main/_autodocs/DOCUMENTATION-INDEX.md Logs the current mouse settings to the console. Use this to inspect current configurations. ```c zmk_mouse_ps2_settings_log() ``` -------------------------------- ### Mouse Initialization Sequence Log Source: https://github.com/badjeff/kb_zmk_ps2_mouse_trackpoint_driver/blob/main/README.md This snippet shows the expected log messages when the ZMK firmware attempts to initialize a connected mouse device. It includes waiting for connection and the initialization attempts. ```bash [00:00:01.984,466] zmk: Waiting for mouse to connect... [00:00:01.984,497] zmk: Trying to initialize mouse device (attempt 1 / 10) ``` -------------------------------- ### Calculating Wireless Bandwidth Utilization Source: https://github.com/badjeff/kb_zmk_ps2_mouse_trackpoint_driver/blob/main/_autodocs/api-reference/input-listener.md Example calculation for estimating wireless bandwidth usage based on trackpoint report rate and size, including BLE overhead. This helps determine if optimization is needed for high report rates. ```text Movement reports: ~100 reports/sec × 4 bytes = 400 bytes/sec With BLE overhead: ~800-1000 bytes/sec Typical BLE bandwidth: 250 kbps, so < 0.4% utilization ``` -------------------------------- ### Build Firmware with External Modules Source: https://github.com/badjeff/kb_zmk_ps2_mouse_trackpoint_driver/blob/main/README.md Compile your ZMK firmware using `west build`, specifying the paths to your ZMK configuration and custom modules via build arguments. Ensure the paths are correctly formatted with the appropriate separators. ```bash west build -d build/corne_tp/right -p -b nice_nano_v2 -- -DZMK_EXTRA_MODULES="/workspaces/zmk-config/;/workspaces/zmk-modules/kb_zmk_ps2_mouse_trackpoint_driver/" -DZMK_CONFIG="/workspaces/zmk-config/config" -DSHIELD="corne_tp_right" ``` -------------------------------- ### ZMK Driver Performing Power-On-Reset Source: https://github.com/badjeff/kb_zmk_ps2_mouse_trackpoint_driver/blob/main/README.md This log entry confirms that the ZMK driver is initiating a Power-On-Reset sequence for a pointing device, which is crucial for TrackPoints before they start communicating. Ensure this is enabled in your configuration if using a TrackPoint without a hardware reset circuit. ```bash [00:00:01.385,803] zmk: Performing Power-On-Reset on pin P0.09... ``` -------------------------------- ### Minimal Device Tree Configuration (UART PS/2) Source: https://github.com/badjeff/kb_zmk_ps2_mouse_trackpoint_driver/blob/main/_autodocs/README.md This is the minimal device tree configuration required to use the PS/2 mouse driver with a UART connection on a nice!nano board. ```dts / { ps2_uart: ps2_uart { compatible = "uart-ps2"; status = "okay"; scl-gpios = <&pro_micro 16 GPIO_ACTIVE_HIGH>; sda-gpios = <&pro_micro 10 GPIO_ACTIVE_HIGH>; }; mouse_ps2: mouse_ps2 { compatible = "zmk,input-mouse-ps2"; ps2-device = <&ps2_uart>; rst-gpios = <&pro_micro 9 GPIO_ACTIVE_HIGH>; tp-sensitivity = <128>; }; mouse_ps2_input_listener: mouse_ps2_input_listener { compatible = "zmk,input-listener-ps2"; device = <&mouse_ps2>; }; }; ``` -------------------------------- ### PS/2 UART Driver Initialization Log Source: https://github.com/badjeff/kb_zmk_ps2_mouse_trackpoint_driver/blob/main/README.md This log snippet shows the successful initialization of the PS/2 UART driver. Look for the 'Initializing ps2_uart driver' and 'UART device is ready' messages. If these are missing, consider increasing the log delay. ```bash [00:00:00.404,663] ps2_uart: Initializing ps2_uart driver with pins... SCL: P0.06; SDA: P0.08; SDA Pinctrl: P0.08 [00:00:00.404,724] ps2_uart: UART device is ready [00:00:00.404,754] ps2_uart: Disabling callback... [00:00:00.423,828] zmk: Welcome to ZMK! ``` -------------------------------- ### Mouse Setting Behavior Codes in ZMK Keymap Source: https://github.com/badjeff/kb_zmk_ps2_mouse_trackpoint_driver/blob/main/_autodocs/types.md Demonstrates how to use mouse setting behavior codes with the &mms behavior in a ZMK keymap to adjust TrackPoint settings at runtime. Ensure the necessary include is present. ```c #include / { behaviors { mms: behavior_mouse_setting_ms { compatible = "zmk,behavior-mouse-setting"; }; }; keymap { mouse_settings_layer { bindings = < &mms MS_TP_SENSITIVITY_INCR // Key: Increase sensitivity &mms MS_TP_SENSITIVITY_DECR // Key: Decrease sensitivity &mms MS_TP_NEG_INERTIA_INCR // Key: Increase damping &mms MS_TP_NEG_INERTIA_DECR // Key: Decrease damping &mms MS_TP_VALUE6_INCR // Key: Increase max speed &mms MS_TP_VALUE6_DECR // Key: Decrease max speed &mms MS_TP_PTS_THRESHOLD_INCR // Key: Make PTS easier &mms MS_TP_PTS_THRESHOLD_DECR // Key: Make PTS harder &mms MS_LOG // Key: Log settings to console &mms MS_RESET // Key: Reset to defaults >; }; }; }; ``` -------------------------------- ### Too Few Arguments for zmk_keymap_layer_activate Source: https://github.com/badjeff/kb_zmk_ps2_mouse_trackpoint_driver/blob/main/README.md This error occurs if you enabled mouse support but are not using the correct ZMK fork. Adjust the CONFIG_ZMK_INPUT_MOUSE_PS2_ENABLE_UROB_COMPAT option in your keyboard's .conf file based on the fork you are using. ```c config/kb_zmk_ps2_mouse_trackpoint_driver/src/mouse/input_listener_ps2.c /__w/zmk-config/zmk-config/kb_zmk_ps2_mouse_trackpoint_driver/src/mouse/input_listener_ps2.c: In function 'zmk_input_listener_ps2_layer_toggle_activate_layer': /__w/zmk-config/zmk-config/kb_zmk_ps2_mouse_trackpoint_driver/src/mouse/input_listener_ps2.c:284:9: error: too few arguments to function 'zmk_keymap_layer_activate' 284 | zmk_keymap_layer_activate(config->layer_toggle); | ^~~~~~~~~~~~~~~~~~~~~~~~~~ compilation terminated due to -Wfatal-errors. ``` -------------------------------- ### Configure Keymap for Mouse Settings Source: https://github.com/badjeff/kb_zmk_ps2_mouse_trackpoint_driver/blob/main/_autodocs/quick-start.md Define keymap bindings for controlling mouse sensitivity, damping, logging, and resetting using custom behaviors. ```c #include #include / { behaviors { mms: behavior_mouse_setting_ms { compatible = "zmk,behavior-mouse-setting"; }; }; keymap { // In your mouse layer: mouse_settings_layer { bindings = < // Sensitivity adjustment &mms MS_TP_SENSITIVITY_INCR &mms MS_TP_SENSITIVITY_DECR // Damping adjustment &mms MS_TP_NEG_INERTIA_INCR &mms MS_TP_NEG_INERTIA_DECR // Log and reset &mms MS_LOG &mms MS_RESET >; }; }; }; ``` -------------------------------- ### Extend Mouse Setting Behavior with Custom Code Source: https://github.com/badjeff/kb_zmk_ps2_mouse_trackpoint_driver/blob/main/_autodocs/quick-start.md Create custom ZMK behaviors that leverage the public API for mouse settings, such as adjusting TrackPoint sensitivity. ```c #include #include #include static int on_custom_binding_pressed(struct zmk_behavior_binding *binding, struct zmk_behavior_binding_event event) { // Call the public API zmk_mouse_ps2_tp_sensitivity_change(binding->param1); return 0; } static int on_custom_binding_released(struct zmk_behavior_binding *binding, struct zmk_behavior_binding_event event) { return ZMK_BEHAVIOR_OPAQUE; } static const struct behavior_driver_api custom_api = { .binding_pressed = on_custom_binding_pressed, .binding_released = on_custom_binding_released }; BEHAVIOR_DT_INST_DEFINE(0, behavior_custom_init, NULL, NULL, NULL, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &custom_api); ``` -------------------------------- ### Module Architecture Diagram Source: https://github.com/badjeff/kb_zmk_ps2_mouse_trackpoint_driver/blob/main/_autodocs/README.md Illustrates the high-level architecture of the ZMK PS/2 Mouse & TrackPoint Driver, showing the interaction between the application layer, behaviors, input drivers, PS/2 drivers, and the ZMK HID subsystem. ```text ┌─────────────────────────────────────────────────────────────┐ │ Application/Keymap │ │ (User layer) │ └────────────┬────────────────────────────────┬────────────────┘ │ │ │ Uses behaviors │ │ (MS_LOG, MS_RESET, etc.) │ Configures via │ │ device tree ▼ ▼ ┌──────────────────────────┐ ┌──────────────────────────┐ │ Behavior: Mouse Setting │ │ Configuration (DT) │ │ src/behaviors/ │ │ dts/bindings/ │ │ behavior_mouse_setting │ │ │ └──────────────┬───────────┘ └────────┬─────────────────┘ │ │ └─────────────┬───────────┘ │ ▼ ┌────────────────────────────────────────┐ │ Mouse Input Driver (input_mouse_ps2) │ │ src/drivers/input/input_mouse_ps2.c │ │ │ │ - Settings management │ │ - Packet parsing │ │ - TrackPoint commands │ └────────────────────────────────────────┘ │ ┌────────────┴────────────┐ │ │ ▼ ▼ ┌──────────────────┐ ┌──────────────────────┐ │ PS/2 Driver │ │ Input Listener PS/2 │ │ (uart-ps2 or │ │ input_listener_ps2 │ │ gpio-ps2) │ │ │ │ │ │ - Coordinate xform │ │ src/drivers/ps2/ │ │ - Layer toggle │ └──────┬───────────┘ │ - HID report gen │ │ └──────────┬───────────┘ │ │ │ Sends HID reports │ │ ▼ ▼ ┌──────────────────┐ ┌──────────────────────┐ │ PS/2 Hardware │ │ ZMK HID Subsystem │ │ (TrackPoint, │ │ (to USB/BLE host) │ │ Mouse, etc.) │ │ │ └──────────────────┘ └──────────────────────┘ ``` -------------------------------- ### Create Docker Volume for ZMK Configuration Source: https://github.com/badjeff/kb_zmk_ps2_mouse_trackpoint_driver/blob/main/README.md Create a Docker volume to store your ZMK configuration files. This is used when building firmware within a Docker environment. ```bash docker volume create --driver local -o o=bind -o type=none -o device="/full/path/to/your/zmk-config/" zmk-config ``` -------------------------------- ### Configure Mouse PS/2 Input Listener with Layer Toggle Source: https://github.com/badjeff/kb_zmk_ps2_mouse_trackpoint_driver/blob/main/_autodocs/api-reference/input-listener.md Configure the PS/2 input listener for mouse devices, enabling layer toggling on movement with specified delays and timeouts. Ensure the 'zmk,input-listener-ps2' compatible device is correctly defined. ```dts mouse_ps2_input_listener { compatible = "zmk,input-listener-ps2"; device = <&mouse_ps2>; layer-toggle = <4>; // Enable mouse settings layer on movement layer-toggle-delay-ms = <500>; // Wait longer before activating layer-toggle-timeout-ms = <500>; }; ``` -------------------------------- ### Verifying Boolean Properties in Device Tree Source: https://github.com/badjeff/kb_zmk_ps2_mouse_trackpoint_driver/blob/main/_autodocs/api-reference/input-listener.md Demonstrates the correct syntax for boolean properties in ZMK device trees, where properties like 'x-invert' should not have a value assigned. Incorrect syntax can lead to issues like inverted axes not working. ```dts x-invert; ``` -------------------------------- ### Runtime Adjustment Keybindings for PS/2 Mouse Source: https://github.com/badjeff/kb_zmk_ps2_mouse_trackpoint_driver/blob/main/_autodocs/module-overview.md Provides keybindings for runtime adjustments of PS/2 mouse settings like sensitivity and logging. ```c &mms MS_TP_SENSITIVITY_INCR // Adjust on the fly &mms MS_LOG // Check current value &mms MS_RESET // Go back to defaults ``` -------------------------------- ### Complete PS/2 Mouse Input Listener Configuration Source: https://github.com/badjeff/kb_zmk_ps2_mouse_trackpoint_driver/blob/main/_autodocs/api-reference/input-listener.md A comprehensive Device Tree Source (DTS) configuration for a PS/2 mouse input listener, including sensitivity, axis transformations, and auto layer toggling. ```dts / { // Mouse input device mouse_ps2: mouse_ps2 { compatible = "zmk,input-mouse-ps2"; ps2-device = <&ps2_uart>; // ... other config ... }; // Input listener with full configuration mouse_ps2_input_listener: mouse_ps2_input_listener { compatible = "zmk,input-listener-ps2"; device = <&mouse_ps2>; // Sensitivity scaling scale-multiplier = <1>; scale-divisor = <1>; // No axis transformation xy-swap; // Off x-invert; // Off y-invert; // Off // Auto layer toggle layer-toggle = <3>; layer-toggle-delay-ms = <250>; layer-toggle-timeout-ms = <250>; }; }; ``` -------------------------------- ### Add Driver to west.yml Source: https://github.com/badjeff/kb_zmk_ps2_mouse_trackpoint_driver/blob/main/_autodocs/README.md Add the PS/2 mouse and trackpoint driver to your ZMK project's west.yml file to include it in your build. ```yaml west.yml: - name: kb_zmk_ps2_mouse_trackpoint_driver remote: infused-kim revision: main ``` -------------------------------- ### Minimal Kconfig Configuration Source: https://github.com/badjeff/kb_zmk_ps2_mouse_trackpoint_driver/blob/main/_autodocs/README.md This Kconfig setting enables the PS/2 resend callback for the ZMK input mouse driver. ```kconfig CONFIG_ZMK_INPUT_MOUSE_PS2_ENABLE_PS2_RESEND_CALLBACK=y ``` -------------------------------- ### Create Device Tree Configuration for TrackPoint Source: https://github.com/badjeff/kb_zmk_ps2_mouse_trackpoint_driver/blob/main/_autodocs/quick-start.md Define the PS/2 UART driver and mouse input configuration in a device tree overlay file. ```dts #include / { // UART PS/2 driver (recommended for nice!nano) ps2_uart: ps2_uart { compatible = "uart-ps2"; status = "okay"; scl-gpios = <&pro_micro 16 GPIO_ACTIVE_HIGH>; sda-gpios = <&pro_micro 10 GPIO_ACTIVE_HIGH>; }; // Mouse input configuration mouse_ps2: mouse_ps2 { compatible = "zmk,input-mouse-ps2"; ps2-device = <&ps2_uart>; rst-gpios = <&pro_micro 9 GPIO_ACTIVE_HIGH>; sampling-rate = <100>; tp-sensitivity = <128>; tp-neg-inertia = <6>; tp-val6-upper-speed = <97>; tp-press-to-select-threshold = <8>; layer-toggle = <2>; // Optional: auto-switch to layer 2 on mouse movement }; // Mouse input listener mouse_ps2_input_listener: mouse_ps2_input_listener { compatible = "zmk,input-listener-ps2"; device = <&mouse_ps2>; layer-toggle = <2>; layer-toggle-delay-ms = <200>; layer-toggle-timeout-ms = <250>; }; }; ``` -------------------------------- ### Define Mouse Setting Behavior in Device Tree Source: https://github.com/badjeff/kb_zmk_ps2_mouse_trackpoint_driver/blob/main/_autodocs/api-reference/behaviors.md Verify that the mouse setting behavior is defined in your device tree. This is a prerequisite for using mouse setting keys. ```devicetree mms: behavior_mouse_setting_ms { compatible = "zmk,behavior-mouse-setting"; }; ``` -------------------------------- ### Enabling Data Reporting and PS/2 Callback Log Source: https://github.com/badjeff/kb_zmk_ps2_mouse_trackpoint_driver/blob/main/README.md This log confirms that the firmware is enabling data reporting and the PS/2 callback, which should initiate mouse movement reports. Write errors are acceptable if retries are successful. ```bash [00:00:02.065,032] zmk: Enabling data reporting and ps2 callback... [00:00:02.069,244] ps2_uart: Failed to write value 0xf4: scl timeout [00:00:02.069,274] ps2_uart: Blocking write finished with failure for byte 0xf4 status: 3 [00:00:02.069,305] ps2_uart: Attempting write re-try #2 of 5... [00:00:02.072,875] ps2_uart: Successfully wrote 0xf4 on try #2 of 5... ``` -------------------------------- ### Keymap Configuration for Mouse Settings Behavior Source: https://github.com/badjeff/kb_zmk_ps2_mouse_trackpoint_driver/blob/main/_autodocs/README.md This keymap configuration defines a behavior for mouse settings and assigns it to bindings for logging and resetting mouse settings. ```c #include / { behaviors { mms: behavior_mouse_setting_ms { compatible = "zmk,behavior-mouse-setting"; }; }; keymap { mouse_layer { bindings = < &mms MS_LOG &mms MS_RESET >; }; }; }; ``` -------------------------------- ### Increase ZMK Log Startup Delay Source: https://github.com/badjeff/kb_zmk_ps2_mouse_trackpoint_driver/blob/main/README.md If PS/2 UART driver initialization logs are not visible, increase the log process thread startup delay. This ensures logs are available during the early boot process. ```config CONFIG_LOG_PROCESS_THREAD_STARTUP_DELAY_MS=3000 ``` -------------------------------- ### Enable Debug Logging for PS/2 and UART Source: https://github.com/badjeff/kb_zmk_ps2_mouse_trackpoint_driver/blob/main/README.md Enable minimal logging for ZMK and detailed debugging for PS/2 and UART to observe driver behavior and identify issues. ```conf CONFIG_ZMK_LOGGING_MINIMAL=y CONFIG_PS2_LOG_LEVEL_DBG=y CONFIG_UART_LOG_LEVEL_DBG=y ``` -------------------------------- ### Kconfig Build Options for PS/2 Mouse Driver Source: https://github.com/badjeff/kb_zmk_ps2_mouse_trackpoint_driver/blob/main/_autodocs/module-overview.md Enables and configures the PS/2 mouse driver and related features in the ZMK build system. ```kconfig CONFIG_ZMK_INPUT_MOUSE_PS2=y CONFIG_ZMK_INPUT_MOUSE_PS2_ENABLE_UROB_COMPAT=y CONFIG_ZMK_INPUT_MOUSE_PS2_REPORT_INTERVAL_MIN=0 CONFIG_ZMK_INPUT_MOUSE_PS2_POWER_ON_RESET_TIME=600 CONFIG_SETTINGS=y # Enables persistent settings ``` -------------------------------- ### Enable urob's ZMK Fork Compatibility Source: https://github.com/badjeff/kb_zmk_ps2_mouse_trackpoint_driver/blob/main/_autodocs/configuration.md Enables compatibility with urob's ZMK fork, which modifies the layer activation API. Enable this option only if you are using urob's fork to avoid compilation errors. ```kconfig config ZMK_INPUT_MOUSE_PS2_ENABLE_UROB_COMPAT bool "Makes the driver compatible with urob's zmk fork" default n ``` -------------------------------- ### Public API Functions Source: https://github.com/badjeff/kb_zmk_ps2_mouse_trackpoint_driver/blob/main/_autodocs/README.md These functions are available from `include/zmk/input_mouse_ps2.h` and allow direct control over PS/2 mouse settings. All functions operate on configured devices and return 0 on success. ```APIDOC ## Public API Functions All functions operate on all configured PS/2 mouse devices and return 0 on success, non-zero on error. ### `int zmk_mouse_ps2_settings_log()` #### Description Log current settings to console. #### Returns - `0` on success ### `int zmk_mouse_ps2_settings_reset()` #### Description Reset all settings to defaults. #### Returns - `0` on success ### `int zmk_mouse_ps2_tp_sensitivity_change(int amount)` #### Description Adjust sensitivity. Typical change is ±10. #### Parameters - `amount` (int) - The amount to change sensitivity by. #### Returns - `0` on success ### `int zmk_mouse_ps2_tp_neg_inertia_change(int amount)` #### Description Adjust damping. Typical change is ±1. #### Parameters - `amount` (int) - The amount to change damping by. #### Returns - `0` on success ### `int zmk_mouse_ps2_tp_value6_upper_plateau_speed_change(int amount)` #### Description Adjust max speed. Typical change is ±5. #### Parameters - `amount` (int) - The amount to change max speed by. #### Returns - `0` on success ### `int zmk_mouse_ps2_tp_pts_threshold_change(int amount)` #### Description Adjust press-to-select sensitivity. Typical change is ±1. #### Parameters - `amount` (int) - The amount to change PTS sensitivity by. #### Returns - `0` on success ``` -------------------------------- ### Device Tree Binding: zmk,input-mouse-ps2 Source: https://github.com/badjeff/kb_zmk_ps2_mouse_trackpoint_driver/blob/main/_autodocs/README.md Configuration for the main PS/2 mouse device. This binding is required for each mouse instance. ```APIDOC ## Device Tree Binding: zmk,input-mouse-ps2 Main PS/2 mouse device configuration. Required for each mouse. ### Key Properties - **ps2-device** (device) - Required - Reference to the PS/2 driver (e.g., `uart-ps2` or `gpio-ps2`). - **rst-gpios** (gpio) - Optional - GPIO for TrackPoint Power-On-Reset. - **sampling-rate** (int) - Optional - Report frequency in Hz. Valid range: 10-200. Default: 100. - **tp-sensitivity** (int) - Optional - Default setting for TrackPoint sensitivity. Range: 0-255. Default: 128. - **tp-neg-inertia** (int) - Optional - Default setting for TrackPoint damping. Range: 0-255. Default: 6. - **tp-val6-upper-speed** (int) - Optional - Default setting for TrackPoint upper plateau speed. Range: 0-255. Default: 97. - **tp-press-to-select-threshold** (int) - Optional - Default setting for TrackPoint press-to-select threshold. Range: 0-255. Default: 8. - **layer-toggle** (bool) - Optional - Enable auto-layer-toggle on mouse movement. ``` -------------------------------- ### Inverted/Mirrored Controls Configuration Source: https://github.com/badjeff/kb_zmk_ps2_mouse_trackpoint_driver/blob/main/_autodocs/api-reference/input-listener.md Set up the PS/2 input listener for left-handed usage by inverting the X-axis. Y-axis inversion is optional. ```dts mouse_ps2_input_listener { compatible = "zmk,input-listener-ps2"; device = <&mouse_ps2>; x-invert; // Reverse left-right // y-invert is optional for top-down inversion }; ``` -------------------------------- ### Add ZMK Fork to west.yml Source: https://github.com/badjeff/kb_zmk_ps2_mouse_trackpoint_driver/blob/main/README.md Modify your `config/west.yml` file to include the necessary ZMK forks and the PS/2 mouse/trackpoint driver module. This ensures your build system can locate and use the custom driver. ```diff manifest: remotes: - name: zmkfirmware url-base: https://github.com/zmkfirmware - name: infused-kim url-base: https://github.com/infused-kim + - name: petejohanson + url-base: https://github.com/petejohanson + - name: urob + url-base: https://github.com/urob projects: - name: zmk - remote: zmkfirmware - revision: main + remote: infused-kim + revision: pr-testing/mouse_ps2_module_base import: app/west.yml + # zmk module for PS/2 mouse / TP driver + - name: kb_zmk_ps2_mouse_trackpoint_driver + remote: infused-kim + revision: main self: path: config ``` -------------------------------- ### Log Current PS/2 Mouse Settings Source: https://github.com/badjeff/kb_zmk_ps2_mouse_trackpoint_driver/blob/main/_autodocs/api-reference/mouse-ps2-settings.md Logs the current settings of all configured PS/2 mouse devices to the console. The output is formatted for easy copying into device tree configurations. ```c int zmk_mouse_ps2_settings_log(void) ``` ```c // Call from a behavior or initialization function zmk_mouse_ps2_settings_log(); // Console output: // [00:12:34.567] zmk: Current settings... // &mouse_ps2_conf = { // tp-sensitivity = <135>; // tp-neg-inertia = <6>; // tp-val6-upper-speed = <97>; // tp-tp-press-to-select-threshold = <8>; // } ``` -------------------------------- ### Configure PS/2 Mouse Input Listener Source: https://github.com/badjeff/kb_zmk_ps2_mouse_trackpoint_driver/blob/main/_autodocs/configuration.md This device tree snippet configures the zmk,input-listener-ps2 compatible node to process PS/2 mouse input. It allows for swapping/inverting axes, scaling movement, and configuring layer toggling based on mouse activity. ```dts / { mouse_ps2_input_listener: mouse_ps2_input_listener { compatible = "zmk,input-listener-ps2"; device = <&mouse_ps2>; xy-swap; x-invert; scale-multiplier = <2>; scale-divisor = <1>; layer-toggle = <3>; layer-toggle-delay-ms = <200>; layer-toggle-timeout-ms = <300>; }; }; ``` -------------------------------- ### Create Docker Volume for ZMK Modules Source: https://github.com/badjeff/kb_zmk_ps2_mouse_trackpoint_driver/blob/main/README.md Create a Docker volume to store custom ZMK modules. This is necessary for the Docker VSCode toolchain to recognize and use external modules. ```bash docker volume create --driver local -o o=bind -o type=none -o device="/full/path/to/your/zmk-modules/" zmk-modules ```