Commit Graph

591 Commits

Author SHA1 Message Date
Genteure af967667b0
fix(core): Correctly sync BAS battery level (#2977)
Fix BAS battery level showing 100% if controller boots up with 0% battery charge.

Closes zmkfirmware/zmk#2972
2025-07-31 17:51:21 -04:00
Pete Johanson 2ae5185419
fix(split): Compile and run properly in wired polling mode. (#3012)
Fixes for regressions from split refactors that broke polling mode
specifically.

Co-authored-by: honorless <86894501+lesshonor@users.noreply.github.com>
Co-authored-by: Cem Aksoylar <caksoylar@users.noreply.github.com>
2025-07-31 17:09:25 -04:00
Pete Johanson 1530ae36c2
fix(split): Enable wired split by default if DTS is set (#3010)
Remove the previous condition on ZMK_SPLIT_WIRED that only enabled it if
!ZMK_BLE. We'll defer to the `depends on` to ensure the DTS exists to
use wired split to make that decision on enabling the feature.
2025-07-30 13:43:46 -04:00
Cem Aksoylar 1bac680c4f
fix(behaviors): Correct macro release state for parametrized macros (#2942)
test(behaviors): Add parametrized macro test that fails

fix(behaviors): Correct macro release state for parametrized
2025-07-29 18:39:26 -04:00
Tobias Adolph 342d838913
fix(ble,hid): Fix smooth scrolling over BLE (#2998)
- Use correct MIN16 value in hid report. -32768 in 2's compliment is 8000(hex)
- Initialize resolution multiplier array
- Properly implement `read_hids_mouse_feature_report`

Fixes: #2957

Co-authored-by: Tobias Adolph <43353209+adolto@users.noreply.github.comgit>
2025-07-20 09:13:18 -06:00
snoyer fe91cc6625
refactor(ble): add functions to check if profile is open/connected by address (#2993)
Helper functions for BLE profile statuses.
2025-07-19 07:51:53 -06:00
Joel Spadin cef7af4408
fix: Fix build with Studio and USB but not UART (#2996)
Changed CONFIG_ZMK_STUDIO_TRANSPORT_UART to automatically enable itself
whenever a zmk,studio-rpc-uart chosen node is specified. The previous
behavior of enabling if CONFIG_ZMK_USB was enabled broke builds when
CONFIG_ZMK_STUDIO was enabled but the chosen node wasn't specified.
2025-07-11 22:07:38 -06:00
snoyer 9e905d6593
feat(ble): Add function to get profile address by index (#2992) 2025-07-09 20:25:11 -06:00
Pete Johanson 6b44d33db2
feat(split): Runtime selection of split transport (#2886)
feat(split): Runtime selection of split transport

Allow building multiple split transports, and select an active
one based on the transport availability. Wired split availability
depends on additional `detect-gpios` which must be a GPIO pin
that goes active when a wired connection is present.

feat(split): Suspend/resume wired UART devices.

To better support runtime split support, suspend/resume the UART
as necessary to save power when not using the UART.

docs(split): Document adjusting nRF52 UART interrupt priorities

For wired split on nRF52, you may need to adjust the priority for UART
interrupts lower, to ensure the interrupts used for timing sensitive
BT operations can run when needed, so document this in our pinctrl docs.

refactor(split): Restore use of aync UART on nRF52.

With fixes for Zephyr UART driver, re-enable using async API on nRF52.

fix(split): Minor wired split fixes.

Various minor fixes for wired split to avoid spurious TX in half duplex,
etc.

fix: Unconditionally define HID payloads to avoid error.

Don't conditionally define HID indicator payload, to avoid compilation
errors.

docs(split): Expand on details of split transports.

Expand the split keyboard documentation with a more fleshed out section
on the available split trasnports, and what is and isn't supported by
each, including the runtime selection functionality.

---------

Co-authored-by: Nicolas Munnich <98408764+nmunnich@users.noreply.github.com>
2025-06-16 03:45:25 -04:00
badjeff 462d48b78e
feat(pointing): Allow peripheral input processing to stop propagation (#2844)
Allow peripheral input processors to prevent event propagation to centrals.

---------

Co-authored-by: Pete Johanson <peter@peterjohanson.com>
2025-06-16 02:23:25 -04:00
George Norton 239baa4875
feat(metadata): Add metadata to the mouse_key_press behavior (#2950)
Adds metadata to the mouse key press behavior so that mouse buttons can be
configured through studio
2025-06-02 14:32:18 -04:00
Cem Aksoylar 9da5d3ba82
fix(display): Make stock battery widget depend on the right symbol (#2953) 2025-06-02 07:25:08 -06:00
cormoran 461f5c832f
fix(pointing): Avoids mutex leak for default layer toggle event (#2934)
Remove unnecessary special check for toggle of layer 0,
to avoid mutex leak.
2025-05-09 20:01:17 -04:00
Pete Johanson e3030bfcc8
fix(combos): Properly clean up all old candidates. (#2928) 2025-04-22 01:17:12 -04:00
Pete Johanson c4ee8ab86b
refactor(combos): Reduce RAM usage, simplify config (#2849)
* Reference combos by index, not 32-bit pointers, and store bitfields
instead of arrays in several places, to bring down our flash/RAM usage.
* Use bit field to track candidate combos, to avoid needing an explicit
`ZMK_COMBO_MAX_COMBOS_PER_KEY` setting.
* Determine the max keys per combo automatically from the devicetree,
so we remove the ZMK_COMBO_MAX_KEYS_PER_COMBO Kconfig symbol.
2025-04-20 05:01:22 -04:00
Xudong Zheng c6738ce2e5
refactor(split): use LOG_HEXDUMP_DBG() to print position state data (#2854)
The previous code prints one line per byte, making debugging difficult.
2025-04-20 04:36:52 -04:00
Tobias Adolph 2c0e7daced
fix(hid): Fix scroll value truncation (#2865)
Fix 8 bit truncation of 16 bit scroll values when passed into
functions `zmk_hid_mouse_scroll_set` and
`zmk_hid_mouse_scroll_update`.

Fixes: #2864

Co-authored-by: Tobias Adolph <43353209+adolto@users.noreply.github.comgit>
2025-04-20 04:28:51 -04:00
Maximilian Engl 6f85f48b19
fix(split): add source to battery event (#2901) 2025-04-04 10:43:51 -07:00
Pete Johanson 147c340c6e
Feature: Full-Duplex Wired Split (#2766)
refactor(split): Refactor split code for extension

Extract central/peripheral code to allow for plugging in alternate
transports, instead of tying all split logic to BT.

feat(split): Add full-duplex wired split support

* Depends on full-duplex hardware UART for communication.
* Supports all existing central commands/peripheral events, including
  sensors/inputs from peripherals.
* Only one wired split peripheral supported (for now)
* Relies on chosen `zmk,split-uart` referencing the UART device.

docs: Add wired split config docs.

Migrate split to its own dedicated config file, and add details
on wired split config.

Co-authored-by: Nicolas Munnich <98408764+Nick-Munnich@users.noreply.github.com>

fix: Properly override stack size on RP2040

Move the system work queue stack size override on RP2040 ouf of
a `ZMK_BLE` conditional so it is properly applied generally for that
SoC.

---------

Co-authored-by: Nicolas Munnich <98408764+Nick-Munnich@users.noreply.github.com>
2025-03-18 02:48:32 -04:00
Pete Johanson f20e6ea759
fix(behaviors): Proper comma separated device list (#2850)
Properly generate the comma separated list of devs in caps word/
key repeat.
2025-03-02 06:49:07 -07:00
Pete Johanson 1e3e62c13d
fix(pointing): Temp layer threading protection. (#2729)
fix(pointing): Temp layer threading protection.

Ensure all layer operations occur on the system work queue thread.

Fixes: #2719

fix(pointing): Handle layer events to disable events

Make the temp layer input processor propely handle layers getting
deactivated externally before the temp layer timeout.

Co-authored-by: Nicolas Munnich <98408764+Nick-Munnich@users.noreply.github.com>
2025-02-28 20:37:55 -05:00
Pete Johanson 21f54e7238
refactor(behaviors): Remove unneeded init funcs. (#2843)
Initialization functions are optional for Zephyr drivers, so remove
all our superfluous empty init functions.
2025-02-26 17:54:29 -05:00
Cem Aksoylar 7186528f77
fix(behaviors): Make multiple sticky keys work on same key position (#2758)
test(behaviors): Add same position sticky key tests

fix(behaviors): Make multiple sticky keys work on same key position

refactor(behaviors): Remove unused param2 in sticky keys
2025-02-26 17:54:08 -05:00
Pete Johanson 9406d39d14
refactor(behaviors): Small caps word RAM reduction. (#2842)
Don't use lazy initialized in-memory array of devices.
2025-02-26 17:01:04 -05:00
Xudong Zheng ea267b0f35
fix(ble): enforce maximum length for dynamic device name (#2784) 2025-02-26 13:29:30 -05:00
Pete Johanson 2fe55c4c41
refactor(behaviors): Minor RAM usage tweaks (#2839)
Follow up cleanup of some config structs not marked as const.
2025-02-26 13:17:23 -05:00
Pete Johanson 209085da73
refactor(behaviors): Add max-held tap-dance config (#2838)
refactor(behaviors): Add max-held tap-dance config

Add new `CONFIG_ZMK_BEHAVIOR_TAP_DANCE_MAX_HELD` config for reducing RAM
usage on more constrained devices.

refactor(behaviors): Move defaults to Kconfig.defaults
2025-02-25 14:12:27 -05:00
Pete Johanson 18d0d2f476
refactor(combos): Reduce combo RAM usage (#2837)
Properly mark combo configs as `const` so they are place in flash,
not RAM.
2025-02-25 13:38:51 -05:00
Pete Johanson aa3e5dd70f
feat(display): Add config for display update period (#2819)
Add `CONFIG_ZMK_DISPLAY_TICK_PERIOD_MS` Kconfig to allow tweaking
the period between display updates.
2025-02-10 13:32:16 -05:00
Pete Johanson 627e6dbec9
feat(display): Add ability to set display on/off pin. (#2814)
Zephyr is still working on the plan upstream for generically controlling
display "backlight" pins with GPIO/PWM, so in the meantime, add our
own chosen property `zmk,display-led` that is set to an LED device child
to allow blanking/unblanking of devices that use a dedicated backlight
control pin.
2025-02-07 17:49:30 -07:00
Pete Johanson 4b4a8a35f3
fix(display): POSIX lvgl fixes (#2812)
fix(display): Do LVGL task processing in main on POSIX.

An SDL/Zephyr bug prevents proper display when SDL calls are
made from anything but the main thread, so add task handling
in our simple main function when on POSIX.

fix(usb): Compilation fix for 64-bit targets

Properly handle differences in the size of `size_t` on 64-bit
architectures.

fix(display): Imply, but don't force, LVGL mono theme

Some targets may be using color displays, so instead of forcing
on the mono theme, merely imply it to default it
2025-02-07 02:05:21 -05:00
Pete Johanson 425256bc0d
fix(display): Only default mono theme when 1bpp (#2804)
In order to have flexibility for color displays, only imply the mono
theme if we have 1bpp.
2025-01-31 22:53:35 -05:00
Pete Johanson e4f1454e0b
refactor(keymap): Reduce flash usage for studio builds (#2771)
When building for ZMK Studio, we can use the constant stock keymap
for init of the in-memory keymap, to avoid duplicate flash usage
for the keymap from the devicetree.
2025-01-15 16:51:26 -05:00
Pete Johanson c367d8f636
feat(core): Make physical layout key rotation optional (#2770)
To be able to save on flash space, for layouts on space constrained
devices that don't require rotation, make key rotation props
optional behind a new Kconfig flag.
2025-01-15 16:48:18 -05:00
Pete Johanson 8dddb1d9d7
Testing: split input test (#2762)
test(pointing): Add mock input device.

New mock input device to generate input events for tests.

test(split): Add peripheral input test.

Test event propagation from peripheral input devices.

fix(split): Proper scoping for local within switch.

Minor compile fix.

chore: Fix up test snapshots after logging changes.

Adjust the test snapshots after logging changes to the central.

fix(kscan): Don't fire last mock event twice.

Fix a bug where the kscan mock would raise the last mock event
twice before halting processing.
2025-01-13 15:15:16 -05:00
Pete Johanson 36508c27fd
fix(studio): Allow adding layers after a layer move (#2748)
Properly return the available layers in the move layer response.
2025-01-03 19:19:19 -05:00
Pete Johanson 85aba16eec
testing: Add split BLE tests (#2737)
* Enhance the BLE test runner to build additional peripheral builds
  when detecting peripheral*.overlay files in the test.
* Add basic and multiple-peripheral tests to exercise the testing
  support
* Add test for triggering local behaviors on split peripherals.

fix(ble): Fix building split code w/o settings

* Properly exclude storing peripheral addresses to settings when
  settings support isn't turned on.
2025-01-01 18:13:47 -05:00
Pete Johanson cb867f92db
Feature: input processor behavior invocation (#2714)
refactor(pointing): Allow stopping event propagation

    Allow input processors to return a special value if a given input event
    should not be further processed/propagated.

feat(pointing): Add behavior input processor

    Add the ability to intercept certain input events and trigger behaviors
    when they occur.

Co-authored-by: Jorge Villalobos <minusfive@users.noreply.github.com>
Co-authored-by: Cem Aksoylar <caksoylar@users.noreply.github.com>
2024-12-17 20:50:06 -05:00
Nicolas Munnich 4ef231f4bb
feat: Added `toggle-mode`, allowing toggle-on and toggle-off (#2555)
feat: added toggle mode to key and layer toggles

docs: documented toggle mode changes
2024-12-12 19:13:56 -05:00
Joel Spadin 7013158a67
fix: Fix warnings in nanopb encoding code (#2643)
The "arg" field on nanopb structs is a void* because it is shared
between the encode and decode callbacks, even though the encode
callback probably should not modify the data. We are passing const data
using this non-const pointer, which causes warnings about discarding
const. This commit explicitly casts to void* to suppress these warnings.
2024-12-11 15:00:48 -05:00
Pete Johanson 6b40bfda53
feat(mouse): Add mouse move and scroll support (#2477)
* feat(mouse): Add mouse move and scroll support

    * Use Zephyr input subsystem for all pointers.
    * Input processors for modifying events, e.g. scaling, swapping
      codes, temporary (mouse) layers, etc.
    * Mouse move/scroll behaviors.
    * Infrastructure in place for physical pointer input devices.

* feat: Add input split support.

* docs: Add initial pointer docs.

---------

Co-authored-by: Cem Aksoylar <caksoylar@users.noreply.github.com>
Co-authored-by: Alexander Krikun <krikun98@gmail.com>
Co-authored-by: Robert U <urob@users.noreply.github.com>
Co-authored-by: Shawn Meier <ftc@users.noreply.github.com>
Co-authored-by: Chris Andreae <chris@andreae.gen.nz>
Co-authored-by: Anant Thazhemadam <47104651+thazhemadam@users.noreply.github.com>
Co-authored-by: Erik Tollerud <erik.tollerud@gmail.com>
Co-authored-by: Nicolas Munnich <98408764+Nick-Munnich@users.noreply.github.com>
2024-12-09 19:45:41 -05:00
Pete Johanson 0820991901
fix(studio): Properly return complete keymap from RPC (#2696)
Ensure the set active physical layout RPC returns the full keymap
details including the available layers.
2024-12-06 18:10:58 -05:00
Nicolas Munnich 40925d48e6
refactor(Kconfig): Extracted designer defaults out into new files (#2537)
docs: Fix incorrect kconfig default values

fix(Kconfig): Added a name to EC11's trigger mode choice, allowing it to be set in device Kconfig.defconfig

refactor(Kconfig): Moved designer defaults out into new files
2024-12-04 16:19:35 -05:00
Nicolas Munnich fed66a92d0 fix(studio): Improved error message when keyboard is missing a physical layout. 2024-11-13 11:38:41 -07:00
Peter Johanson 19a096ab67 fix(keymap): Set bindings with changed layout
* Fix bug with setting keymap layer bindings when a non-stock layout
  is selected.
2024-11-04 13:30:40 -07:00
Peter Johanson 8ed556df62 chore(studio): Only clear settings for overridden key positions. 2024-10-21 14:53:31 -06:00
Peter Johanson ea1a09bf99 fix: Optimize layout changes by doing runtime mapping
* To avoid tons of migration, extra flash writes, etc, we keep
  the keymaps and settings using a key position index that's tied
  to the stock layout, and at runtime mapping key positions as
  needed.
2024-10-18 15:30:13 -06:00
angweekiat 0adb80c02b
fix(usb): detect USB power mode to fallback to BLE
* Add tracking to see if we ever hit a configured status before
  suspend, so we can properly track "is connected" even when
  connected to a suspended/asleep host.
2024-10-14 19:15:45 -04:00
Pete Johanson dab4b2cdf3
fix(studio): Reduce stack usage. (#2547)
* Imply nanopb setting for reduced stack usage.
2024-10-10 12:49:51 -04:00
Peter Johanson 47a17c64d7 fix: Defer auto enabling of kscan sideband.
* Now that device init of kscan sideband is in POST_KERNEL stage,
  use a separate SYS_INIT for auto enabling the device so processing
  of early/initial presses from referenced toggle mode kscan devices
  occurs at the proper time during init.
2024-10-08 10:20:39 -06:00