Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(mouse): Add mouse move and scroll support #2477

Merged

Conversation

petejohanson
Copy link
Contributor

@petejohanson petejohanson commented Sep 13, 2024

Summary

  • 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.

This is the planned successor to #2027 that integrates a more flexible input processing system inspired by the work by badjeff. I will leave #2027 alone for now, but this PR is intended to be the version that's targeted to actually merge.

WARNING The work in this PR is subject to ZERO API/code/config stability guarantees. If you want something that won't randomly break on you, keep using #2027. Only use the branch from this PR if you are willing to accept that, follow the PR closely for any changes, and are technical enough to solve any problems that occur from using it.

Input Processors

All the options for scaling, swapping X/Y values, etc are now accomplished with input processors, that can be set on a given listener, and overridden for a set of given layers:

I've implemented input processors with the following compatible values:

  • zmk,input-processor-code-mapper - For translating input codes to other values. Useful for enabling a "scroll layer" that makes a pointer send scroll events instead of X/Y move events.
  • zmk,input-processor-scaler - For scaling values, using a passed in multiplier and divisor. Useful for "precision layer". Example &vip_xy_scaler 1 4 to scale values by 1/4, for fine grained movements.
  • zmk,input-processor-temp-layer - For enabling a layer until a certain time period of no input events from the device. Useful for a "mouse layer" with mouse keys when using an integrated trackpad/ball/whatever.
  • zmk,input-processor-transform - For swapping X/Y values, inverting a given Y or X value. Useful when a given input driver doesn't support these transforms and it may be installed rotated 90deg, etc.

Input processors are tied to input listeners, with layer overrides, e.g.:

&mmv_input_listener {
	input-processors = <&zip_xy_scaler 3 2>, <&zip_temp_layer MOUSE_L 2000>;

	wheelie {
		layers = <WHEEL_L>;
		input-processors = <&mouse_to_wheel_mapper>;
	};

	fine {
		layers = <FINE_L>;
		input-processors = <&zip_xy_scaler 1 3>;
	};
};

Smooth Scrolling

This also adds "smooth scrolling" support, by using HID "resolution multipliers", which appears to be supported in Linux and Windows, but not macOS. On macOS, we should be properly falling back to normal behavior here even with CONFIG_ZMK_MOUSE_SMOOTH_SCROLLING=y. More testing needed here.

Split

This PR includes a second commit to add split input device support. You can see an example PR implementing a split Cirque controller at sadekbaroudi/zmk-fingerpunch-vik#1

The key new driver here is behind the zmk,input-split compatible value. This driver has different modes based on being used on a split peripheral or central. When used on a peripheral, this acts as a listener for the specified input events on the referenced device, and forwards those events to the central (after some optional peripheral side input processing that can be used to clean up rotation, etc. beforehand). On the central, this driver registeres it's own input device, that should have a ZMK input listener added referencing it. The driver will receive the events from the peripheral and fire them locally for processing.

Testing

So far, I've tested with mouse keys/scroll/move, and with a Cirque device. More testing all around! Existing generic Zephyr input devices should still "just work" with this PR.

To Do

  • Add "out of the box" input processors you can use, that are tagged with /omit-if-no-ref/.
  • Document input listener config
  • Document available input processors
  • Testing, more testing.

@petejohanson petejohanson added enhancement New feature or request core Core functionality/behavior of ZMK pointers Pointer related functionality labels Sep 13, 2024
@petejohanson petejohanson self-assigned this Sep 13, 2024
@petejohanson petejohanson force-pushed the feat/pointers-with-input-processors branch from e90e11d to 7e9f046 Compare September 24, 2024 23:47
@caksoylar
Copy link
Contributor

It looks like there is a bug in ticks->ms conversions in mouse keys that break acceleration behavior; these fixes got acceleration working again for me:

diff --git a/app/src/behaviors/behavior_input_two_axis.c b/app/src/behaviors/behavior_input_two_axis.c
index 20f5d52a..dd2f3bf6 100644
--- a/app/src/behaviors/behavior_input_two_axis.c
+++ b/app/src/behaviors/behavior_input_two_axis.c
@@ -112,7 +112,7 @@ static float speed(const struct behavior_input_two_axis_config *config, uint16_t
                    float max_speed, int64_t duration_ticks) {
     uint8_t accel_exp = get_acceleration_exponent(config, code);
 
-    if ((duration_ticks * CONFIG_SYS_CLOCK_TICKS_PER_SEC / 1000) > config->time_to_max_speed_ms ||
+    if ((1000 * duration_ticks / CONFIG_SYS_CLOCK_TICKS_PER_SEC) > config->time_to_max_speed_ms ||
         config->time_to_max_speed_ms == 0 || accel_exp == 0) {
         return max_speed;
     }
@@ -123,8 +123,8 @@ static float speed(const struct behavior_input_two_axis_config *config, uint16_t
         return 0;
     }
 
-    float time_fraction = (float)duration_ticks * CONFIG_SYS_CLOCK_TICKS_PER_SEC /
-                          config->time_to_max_speed_ms / 1000;
+    float time_fraction = (float)(1000 * duration_ticks / CONFIG_SYS_CLOCK_TICKS_PER_SEC) /
+                          config->time_to_max_speed_ms;
     return max_speed * powf(time_fraction, accel_exp);
 }

&mmv MOVE_DOWN
```

The following will send a scroll left event to the host when pressed/held:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"scroll" should be "mouse move" here and in line 90, I think.

@petejohanson petejohanson force-pushed the feat/pointers-with-input-processors branch 3 times, most recently from 2052d19 to 4fc6861 Compare September 30, 2024 23:32
@petejohanson petejohanson force-pushed the feat/pointers-with-input-processors branch 7 times, most recently from 4fed437 to d1a09bb Compare October 26, 2024 20:14
@petejohanson petejohanson force-pushed the feat/pointers-with-input-processors branch from d1a09bb to 447afcb Compare October 27, 2024 00:09
@kaievns
Copy link

kaievns commented Oct 27, 2024

just fyi, I used this in a custom build and it seems to be working just fine, thanks! https://github.com/kaievns/little-wing/blob/6ce99b4b3827adb583cbbd0d54b5616a0b304c66/zmk-config/config/little_wing.keymap#L27C1-L44C7

a built in mouse to wheel mapper would be a good idea I reckon, i stole mine from badjeff's work

@petejohanson
Copy link
Contributor Author

a built in mouse to wheel mapper would be a good idea I reckon, i stole mine from badjeff's work

I added a preconfigured code mapper for this today. After #include <input/processors.dtsi> you can use &zip_xy_to_scroll_mapper.

@kaievns
Copy link

kaievns commented Oct 28, 2024

I've just given it a go and it works perfectly for me. I've also noticed that you've added the two-axis to mouse scroll &msc thing. That's fantastic, thank you!

@petejohanson petejohanson force-pushed the feat/pointers-with-input-processors branch 2 times, most recently from a6cb056 to 032f421 Compare October 28, 2024 21:18
@greg-hellings
Copy link

I was using your previous branch, and I switched to this one. So far it's working great for me with just basic mouse move emulation and scroll on the key bindings. However, the speed of the scroll is wickedly fast compared to the scrolling speed on your previous branch. Almost too quick to keep up with in most cases.

@lexxxel
Copy link

lexxxel commented Oct 29, 2024

@petejohanson
I really like the progress that is made here. I'm in the progress of building my first split keyboard and I want to use joysticks, for more movement and possibly as analog input in games, however the point I want to make is that the current force pushing workflow makes it difficult to keep track of your changes. Of course, I can 'save your old branches' manually, however have you thought about squashing your committs before merge, but develop with normal commits (and rebase FP or merges against main/develop)?

@kaievns
Copy link

kaievns commented Oct 30, 2024

hey @petejohanson i think there is something fishy going on with the split-input

Long story short I'm building a split keyboard with a trackball and I followed your work that someone in discord pointed me to over here https://github.com/sadekbaroudi/zmk-fingerpunch-vik/pull/1/files and i have adopted it over here https://github.com/kaievns/little-wing/blob/6aaabf9901a5721276f37030116f5688fcd68fa0/zmk-config/boards/shields/little_wing/little_wing_right.overlay#L11-L35

If I set the left side as central and the right one (the one with a trackball) as a periferal side, it compiles and works great via USB, but in case of bluetooth connection I think there is lag + interference as data is fed from right to left and then to a PC, and that leads to some very jumpy and unstable cursor movements. And kind of unusable tbh.

But, if i try to set the right side as the central one--so that data would go straight to the PC--, it doesn't compile. The left side says that the @trackball_split device is not defined

FAILED: CMakeFiles/app.dir/src/split/bluetooth/service.c.obj 
ccache /opt/zephyr-sdk-0.16.3/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc -DKERNEL -DNRF52840_XXAA -DPICOLIBC_INTEGER_PRINTF_SCANF -D_FORTIFY_SOURCE=1 -D_POSIX_C_SOURCE=200809 -D__LINUX_ERRNO_EXTENSIONS__ -D__PROGRAM_START -D__ZEPHYR__=1 -I/workspaces/pete-zmk/app/include -I/workspaces/pete-zmk/zephyr/include -I/workspaces/pete-zmk/app/build/left/zephyr/include/generated -I/workspaces/pete-zmk/zephyr/soc/arm/nordic_nrf/nrf52 -I/workspaces/pete-zmk/zephyr/soc/arm/nordic_nrf/common/. -I/workspaces/pete-zmk/zephyr/subsys/usb/device -I/workspaces/pete-zmk/zephyr/subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/nrfx_glue -I/workspaces/pete-zmk/zephyr/subsys/bluetooth -I/workspaces/pete-zmk/zephyr/subsys/settings/include -I/workspaces/pete-zmk/modules/hal/cmsis/CMSIS/Core/Include -I/workspaces/pete-zmk/zephyr/modules/cmsis/. -I/workspaces/pete-zmk/modules/hal/nordic/nrfx -I/workspaces/pete-zmk/modules/hal/nordic/nrfx/drivers/include -I/workspaces/pete-zmk/modules/hal/nordic/nrfx/mdk -I/workspaces/pete-zmk/zephyr/modules/hal_nordic/nrfx/. -I/workspaces/pete-zmk/modules/crypto/tinycrypt/lib/include -I/workspaces/pete-zmk/app/module/include -I/workspaces/pete-zmk/app/module/drivers/sensor/battery/. -fno-strict-aliasing -Os -imacros /workspaces/pete-zmk/app/build/left/zephyr/include/generated/autoconf.h -fno-printf-return-value -fno-common -g -gdwarf-4 -fdiagnostics-color=always -mcpu=cortex-m4 -mthumb -mabi=aapcs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mfp16-format=ieee --sysroot=/opt/zephyr-sdk-0.16.3/arm-zephyr-eabi/arm-zephyr-eabi -imacros /workspaces/pete-zmk/zephyr/include/zephyr/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-pointer-sign -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -Werror=implicit-int -fno-pic -fno-pie -fno-asynchronous-unwind-tables -ftls-model=local-exec -fno-reorder-functions --param=min-pagesize=0 -fno-defer-pop -fmacro-prefix-map=/workspaces/pete-zmk/app=CMAKE_SOURCE_DIR -fmacro-prefix-map=/workspaces/pete-zmk/zephyr=ZEPHYR_BASE -fmacro-prefix-map=/workspaces/pete-zmk=WEST_TOPDIR -ffunction-sections -fdata-sections --specs=picolibc.specs -std=c99 -Wfatal-errors -MD -MT CMakeFiles/app.dir/src/split/bluetooth/service.c.obj -MF CMakeFiles/app.dir/src/split/bluetooth/service.c.obj.d -o CMakeFiles/app.dir/src/split/bluetooth/service.c.obj -c /workspaces/pete-zmk/app/src/split/bluetooth/service.c
In file included from /workspaces/pete-zmk/app/src/split/bluetooth/service.c:17:
/workspaces/pete-zmk/app/src/split/bluetooth/service.c:235:45: warning: implicit declaration of function 'INPUT_SPLIT_CHARS' [-Wimplicit-function-declaration]
  235 |     DT_FOREACH_STATUS_OKAY(zmk_input_split, INPUT_SPLIT_CHARS)
      |                                             ^~~~~~~~~~~~~~~~~
/workspaces/pete-zmk/zephyr/include/zephyr/bluetooth/gatt.h:572:54: note: in definition of macro 'BT_GATT_SERVICE_DEFINE'
  572 |         const struct bt_gatt_attr attr_##_name[] = { __VA_ARGS__ };     \
      |                                                      ^~~~~~~~~~~
/workspaces/pete-zmk/zephyr/include/zephyr/sys/util_internal.h:69:53: note: in expansion of macro '__DEBRACKET'
   69 | #define __GET_ARG2_DEBRACKET(ignore_this, val, ...) __DEBRACKET val
      |                                                     ^~~~~~~~~~~
/workspaces/pete-zmk/zephyr/include/zephyr/sys/util_internal.h:64:9: note: in expansion of macro '__GET_ARG2_DEBRACKET'
   64 |         __GET_ARG2_DEBRACKET(one_or_two_args _if_code, _else_code)
      |         ^~~~~~~~~~~~~~~~~~~~
/workspaces/pete-zmk/zephyr/include/zephyr/sys/util_internal.h:59:9: note: in expansion of macro '__COND_CODE'
   59 |         __COND_CODE(_XXXX##_flag, _if_1_code, _else_code)
      |         ^~~~~~~~~~~
/workspaces/pete-zmk/zephyr/include/zephyr/sys/util_macro.h:180:9: note: in expansion of macro 'Z_COND_CODE_1'
  180 |         Z_COND_CODE_1(_flag, _if_1_code, _else_code)
      |         ^~~~~~~~~~~~~
/workspaces/pete-zmk/zephyr/include/zephyr/devicetree.h:2916:9: note: in expansion of macro 'COND_CODE_1'
 2916 |         COND_CODE_1(DT_HAS_COMPAT_STATUS_OKAY(compat),                  \
      |         ^~~~~~~~~~~
/workspaces/pete-zmk/zephyr/include/zephyr/sys/util_internal.h:105:36: note: in expansion of macro 'DT_FOREACH_OKAY_zmk_input_split'
  105 | #define UTIL_PRIMITIVE_CAT(a, ...) a##__VA_ARGS__
      |                                    ^
/workspaces/pete-zmk/app/src/split/bluetooth/service.c:235:5: note: in expansion of macro 'DT_FOREACH_STATUS_OKAY'
  235 |     DT_FOREACH_STATUS_OKAY(zmk_input_split, INPUT_SPLIT_CHARS)
      |     ^~~~~~~~~~~~~~~~~~~~~~
/workspaces/pete-zmk/app/build/left/zephyr/include/generated/devicetree_generated.h:20185:48: error: 'DT_N_S_split_inputs_S_trackball_split_0' undeclared here (not in a function); did you mean 'DT_N_S_split_inputs_S_trackball_split_0_ORD'?
20185 | #define DT_FOREACH_OKAY_zmk_input_split(fn) fn(DT_N_S_split_inputs_S_trackball_split_0)
      |                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/workspaces/pete-zmk/zephyr/include/zephyr/bluetooth/gatt.h:572:54: note: in definition of macro 'BT_GATT_SERVICE_DEFINE'
  572 |         const struct bt_gatt_attr attr_##_name[] = { __VA_ARGS__ };     \
      |                                                      ^~~~~~~~~~~
/workspaces/pete-zmk/zephyr/include/zephyr/sys/util_internal.h:69:53: note: in expansion of macro '__DEBRACKET'
   69 | #define __GET_ARG2_DEBRACKET(ignore_this, val, ...) __DEBRACKET val
      |                                                     ^~~~~~~~~~~
/workspaces/pete-zmk/zephyr/include/zephyr/sys/util_internal.h:64:9: note: in expansion of macro '__GET_ARG2_DEBRACKET'
   64 |         __GET_ARG2_DEBRACKET(one_or_two_args _if_code, _else_code)
      |         ^~~~~~~~~~~~~~~~~~~~
/workspaces/pete-zmk/zephyr/include/zephyr/sys/util_internal.h:59:9: note: in expansion of macro '__COND_CODE'
   59 |         __COND_CODE(_XXXX##_flag, _if_1_code, _else_code)
      |         ^~~~~~~~~~~
/workspaces/pete-zmk/zephyr/include/zephyr/sys/util_macro.h:180:9: note: in expansion of macro 'Z_COND_CODE_1'
  180 |         Z_COND_CODE_1(_flag, _if_1_code, _else_code)
      |         ^~~~~~~~~~~~~
/workspaces/pete-zmk/zephyr/include/zephyr/devicetree.h:2916:9: note: in expansion of macro 'COND_CODE_1'
 2916 |         COND_CODE_1(DT_HAS_COMPAT_STATUS_OKAY(compat),                  \
      |         ^~~~~~~~~~~
/workspaces/pete-zmk/zephyr/include/zephyr/sys/util_internal.h:105:36: note: in expansion of macro 'DT_FOREACH_OKAY_zmk_input_split'
  105 | #define UTIL_PRIMITIVE_CAT(a, ...) a##__VA_ARGS__
      |                                    ^
/workspaces/pete-zmk/zephyr/include/zephyr/sys/util_internal.h:104:26: note: in expansion of macro 'UTIL_PRIMITIVE_CAT'
  104 | #define UTIL_CAT(a, ...) UTIL_PRIMITIVE_CAT(a, __VA_ARGS__)
      |                          ^~~~~~~~~~~~~~~~~~
/workspaces/pete-zmk/zephyr/include/zephyr/devicetree.h:2917:22: note: in expansion of macro 'UTIL_CAT'
 2917 |                     (UTIL_CAT(DT_FOREACH_OKAY_, compat)(fn)),   \
      |                      ^~~~~~~~
/workspaces/pete-zmk/app/src/split/bluetooth/service.c:235:5: note: in expansion of macro 'DT_FOREACH_STATUS_OKAY'
  235 |     DT_FOREACH_STATUS_OKAY(zmk_input_split, INPUT_SPLIT_CHARS)

and the right side compiles but fails at the linking stage

[341/341] Linking C executable zephyr/zmk.elf
FAILED: zephyr/zmk.elf zephyr/zmk.map zephyr/zmk.hex zephyr/zmk.bin zephyr/zmk.uf2 zephyr/zmk.stat /workspaces/pete-zmk/app/build/right/zephyr/zmk.map /workspaces/pete-zmk/app/build/right/zephyr/zmk.hex /workspaces/pete-zmk/app/build/right/zephyr/zmk.bin /workspaces/pete-zmk/app/build/right/zephyr/zmk.uf2 /workspaces/pete-zmk/app/build/right/zephyr/zmk.stat 
: && ccache /opt/zephyr-sdk-0.16.3/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc  -gdwarf-4 zephyr/CMakeFiles/zephyr_final.dir/misc/empty_file.c.obj zephyr/CMakeFiles/zephyr_final.dir/isr_tables.c.obj -o zephyr/zmk.elf  zephyr/CMakeFiles/offsets.dir/./arch/arm/core/offsets/offsets.c.obj  -fuse-ld=bfd  -T  zephyr/linker.cmd  -Wl,-Map=/workspaces/pete-zmk/app/build/right/zephyr/zephyr_final.map  -Wl,--whole-archive  app/libapp.a  zephyr/libzephyr.a  zephyr/arch/common/libarch__common.a  zephyr/arch/arch/arm/core/libarch__arm__core.a  zephyr/arch/arch/arm/core/cortex_m/libarch__arm__core__cortex_m.a  zephyr/arch/arch/arm/core/mpu/libarch__arm__core__mpu.a  zephyr/lib/libc/picolibc/liblib__libc__picolibc.a  zephyr/lib/libc/common/liblib__libc__common.a  zephyr/soc/soc/arm/common/cortex_m/libsoc__arm__common__cortex_m.a  zephyr/soc/soc/arm/nordic_nrf/nrf52/libsoc__arm__nordic_nrf__nrf52.a  zephyr/subsys/random/libsubsys__random.a  zephyr/subsys/usb/device/class/hid/libsubsys__usb__device__class__hid.a  zephyr/subsys/bluetooth/common/libsubsys__bluetooth__common.a  zephyr/subsys/bluetooth/host/libsubsys__bluetooth__host.a  zephyr/subsys/bluetooth/crypto/libsubsys__bluetooth__crypto.a  zephyr/subsys/bluetooth/controller/libsubsys__bluetooth__controller.a  zephyr/subsys/input/libsubsys__input.a  zephyr/subsys/net/libsubsys__net.a  zephyr/drivers/usb/device/libdrivers__usb__device.a  zephyr/drivers/adc/libdrivers__adc.a  zephyr/drivers/clock_control/libdrivers__clock_control.a  zephyr/drivers/entropy/libdrivers__entropy.a  zephyr/drivers/flash/libdrivers__flash.a  zephyr/drivers/gpio/libdrivers__gpio.a  zephyr/drivers/hwinfo/libdrivers__hwinfo.a  zephyr/drivers/kscan/libdrivers__kscan.a  zephyr/drivers/led_strip/libdrivers__led_strip.a  zephyr/drivers/pinctrl/libdrivers__pinctrl.a  zephyr/drivers/sensor/nrf5/libdrivers__sensor__nrf5.a  zephyr/drivers/spi/libdrivers__spi.a  zephyr/drivers/timer/libdrivers__timer.a  modules/hal_nordic/nrfx/libmodules__hal_nordic__nrfx.a  modules/pmw3610/lib..__..__zmk-config__drivers__pmw3610.a  modules/module/drivers/sensor/battery/lib..__app__module__drivers__sensor__battery.a  modules/module/lib/zmk_debounce/lib..__app__module__lib__zmk_debounce.a  -Wl,--no-whole-archive  zephyr/kernel/libkernel.a  -L"/opt/zephyr-sdk-0.16.3/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/thumb/v7e-m+fp/hard"  -L/workspaces/pete-zmk/app/build/right/zephyr  -lgcc  -Wl,--print-memory-usage  zephyr/arch/common/libisr_tables.a  -mcpu=cortex-m4  -mthumb  -mabi=aapcs  -mfpu=fpv4-sp-d16  -mfloat-abi=hard  -mfp16-format=ieee  -Wl,--gc-sections  -Wl,--build-id=none  -Wl,--sort-common=descending  -Wl,--sort-section=alignment  -Wl,-u,_OffsetAbsSyms  -Wl,-u,_ConfigAbsSyms  -nostdlib  -static  -Wl,-X  -Wl,-N  -Wl,--orphan-handling=warn  -Wl,-no-pie  -DPICOLIBC_INTEGER_PRINTF_SCANF  --specs=picolibc.specs  -lc  -lgcc && cd /workspaces/pete-zmk/app/build/right/zephyr && /usr/local/lib/python3.12/dist-packages/cmake/data/bin/cmake -E copy zephyr_final.map zmk.map && /opt/zephyr-sdk-0.16.3/arm-zephyr-eabi/bin/arm-zephyr-eabi-objcopy --gap-fill 0xff --output-target=ihex --remove-section=.comment --remove-section=COMMON --remove-section=.eh_frame zmk.elf zmk.hex && /opt/zephyr-sdk-0.16.3/arm-zephyr-eabi/bin/arm-zephyr-eabi-objcopy --gap-fill 0xff --output-target=binary --remove-section=.comment --remove-section=COMMON --remove-section=.eh_frame zmk.elf zmk.bin && /usr/bin/python3 /workspaces/pete-zmk/zephyr/scripts/build/uf2conv.py -c -f 0xada52840 -b 0x26000 -o zmk.uf2 zmk.bin && /opt/zephyr-sdk-0.16.3/arm-zephyr-eabi/bin/arm-zephyr-eabi-readelf -e zmk.elf > zmk.stat && /usr/bin/python3 /workspaces/pete-zmk/zephyr/scripts/build/check_init_priorities.py --elf-file=/workspaces/pete-zmk/app/build/right/zephyr/zmk.elf
Memory region         Used Size  Region Size  %age Used
           FLASH:      234812 B       792 KB     28.95%
             RAM:       61862 B       256 KB     23.60%
        IDT_LIST:          0 GB         2 KB      0.00%
/workspaces/pete-zmk/zephyr/scripts/build/uf2conv.py:204: SyntaxWarning: invalid escape sequence '\s'
  words = re.split('\s+', line)
Converting to uf2, output size: 470016, start address: 0x26000
Wrote 470016 bytes to zmk.uf2
ERROR: /split_inputs/trackball_split@0 POST_KERNEL 32 < /soc/spi@40004000/trackball@0 POST_KERNEL 50
ninja: build stopped: subcommand failed.

which looks like some sort of device ordering issue.

thought I'd share it, feel free to ping me on discord if you'd want to dig into it

@miketronic
Copy link

This is a great update; simple to implement, the scrolling is fantastic -- so smooth! Is there a way to specify cursor speed? Also, are there any options for acceleration such as ramping up to full speed after X ms?

Copy link
Contributor

@eteq eteq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... I think this is what was intended?

docs/docs/keymaps/behaviors/mouse-emulation.md Outdated Show resolved Hide resolved
docs/docs/keymaps/behaviors/mouse-emulation.md Outdated Show resolved Hide resolved
docs/docs/keymaps/behaviors/mouse-emulation.md Outdated Show resolved Hide resolved
@petejohanson petejohanson force-pushed the feat/pointers-with-input-processors branch from 4b54648 to e28a83d Compare December 2, 2024 21:18
@petejohanson
Copy link
Contributor Author

FYI: After a massive amount of various small fix commits, I've rebased against latest main and squashed where appropriate. No major behavior/code changes, a few minor bug fixes and lots of documentation additions.

@petejohanson petejohanson force-pushed the feat/pointers-with-input-processors branch from e28a83d to 15c0155 Compare December 3, 2024 02:17
Copy link
Contributor

@Nick-Munnich Nick-Munnich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some initial higher-level thoughts on the documentation. Haven't looked at any of the input processor docs yet, nor any of the code.

docs/docs/config/pointers.md Outdated Show resolved Hide resolved
docs/docs/config/pointers.md Outdated Show resolved Hide resolved
docs/docs/config/pointers.md Outdated Show resolved Hide resolved
docs/docs/config/pointers.md Outdated Show resolved Hide resolved
docs/docs/config/pointers.md Outdated Show resolved Hide resolved
Comment on lines 1 to 4
---
title: Pointing Devices
sidebar_label: Pointers
---
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I would split this page into a pair of tabs, one for "Unibody or Split Central" (with a better name) and one for peripheral. I would extract the "input device" section into a different file, so that you can import it into both tabs for clarity reasons.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took a stab at this. I decided not to create any "shared docs" bit, since the specifics/flow was just subtly different enough it would have led to a more awkward end result in the docs. LMK what you think.

docs/docs/features/pointers.md Outdated Show resolved Hide resolved
docs/docs/features/pointers.md Outdated Show resolved Hide resolved
Comment on lines 35 to 39
## Input Listeners

Listeners are the key piece that integrate the low level input devices to the rest of the ZMK system. In particular, listeners subscribe to input events from the linked device, and when a given event occurs (e.g. X/Y movement), apply any input processors before sending those events to the HID system for notification to the host. The main way to modify the way a pointer behaves is by configuring the input processors for a given listener.

For more details on assigning processors to your listeners, see the [input processor usage](../keymaps/input-processors/usage.md) documentation.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this information is user-end. I think this would be more suitable in hardware integration, with perhaps a short note in the usage page.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since input listeners are the thing that end users will be assigning processors to, I felt it important to briefly describe them here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im not 100% sold, but leave it here for the time being and Ill argue my case on the second pass.

Comment on lines 180 to 198
#### `trigger-period-ms`

How many milliseconds between generated input events based on the current speed/direction.

#### `delay-ms`

How many milliseconds to delay any processing or event generation when first pressed.

#### `time-to-max-speed-ms`

How many milliseconds it takes to accelerate to the curren max speed.

#### `acceleration-exponent`

The acceleration exponent to apply, with three possible values:

- `0` - uniform speed
- `1` - uniform acceleration
- `2` - exponential acceleration
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like these should all be in the code block with examples, and then a table to present this information below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switched this around. LMK what you think.

@petejohanson petejohanson force-pushed the feat/pointers-with-input-processors branch from efa0219 to 6fdf192 Compare December 5, 2024 00:10
@petejohanson
Copy link
Contributor Author

Rebased to fix up merge conflict after the merge of #2537

docs/docs/keymaps/behaviors/index.mdx Outdated Show resolved Hide resolved
docs/docs/config/pointing.md Outdated Show resolved Hide resolved
docs/docs/config/pointing.md Outdated Show resolved Hide resolved
docs/docs/config/pointing.md Outdated Show resolved Hide resolved
docs/docs/config/pointing.md Outdated Show resolved Hide resolved
docs/docs/keymaps/input-processors/temp-layer.md Outdated Show resolved Hide resolved
docs/docs/keymaps/input-processors/temp-layer.md Outdated Show resolved Hide resolved
docs/docs/keymaps/input-processors/temp-layer.md Outdated Show resolved Hide resolved
docs/docs/keymaps/input-processors/temp-layer.md Outdated Show resolved Hide resolved
docs/docs/keymaps/input-processors/temp-layer.md Outdated Show resolved Hide resolved
docs/docs/config/pointing.md Outdated Show resolved Hide resolved
docs/docs/config/pointing.md Outdated Show resolved Hide resolved
docs/docs/development/hardware-integration/pointing.mdx Outdated Show resolved Hide resolved
docs/docs/development/hardware-integration/pointing.mdx Outdated Show resolved Hide resolved

The details will depend on if you are adding a pointing device to a [split peripheral](../../features/split-keyboards.md#central-and-peripheral-roles) or to a non-split or split central:

<Tabs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think my general suggestion on this point would be to get the headers "Input Device", "Listener", and "Input processor" outside of the tabs using the invisible tabs trick. Then change the max header depth on the sidebar so that the subheaders of "listener" under the split section aren't visible.

docs/docs/development/hardware-integration/pointing.mdx Outdated Show resolved Hide resolved
@petejohanson petejohanson force-pushed the feat/pointers-with-input-processors branch 2 times, most recently from 5c6be5e to f402ff0 Compare December 6, 2024 18:16
adamrdavid added a commit to adamrdavid/sofle-hybrid-ergomech-zmk that referenced this pull request Dec 7, 2024
Add new remote for experimental branch zmkfirmware/zmk#2477
@petejohanson petejohanson force-pushed the feat/pointers-with-input-processors branch 2 times, most recently from efd6434 to a072dd7 Compare December 9, 2024 18:22
docs/docs/keymaps/input-processors/usage.md Outdated Show resolved Hide resolved
docs/docs/keymaps/input-processors/usage.md Outdated Show resolved Hide resolved
docs/docs/config/pointing.md Outdated Show resolved Hide resolved
@petejohanson petejohanson force-pushed the feat/pointers-with-input-processors branch from 68692d5 to ecb2005 Compare December 10, 2024 00:16
caksoylar and others added 2 commits December 9, 2024 17:23
* 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.

Co-authored-by: Alexander Krikun <[email protected]>
Co-authored-by: Robert U <[email protected]>
Co-authored-by: Shawn Meier <[email protected]>
Co-authored-by: Chris Andreae <[email protected]>
@petejohanson petejohanson force-pushed the feat/pointers-with-input-processors branch from ecb2005 to 0ddce94 Compare December 10, 2024 00:23
Co-authored-by: Anant Thazhemadam <[email protected]>
Co-authored-by: Erik Tollerud <[email protected]>
Co-authored-by: Cem Aksoylar <[email protected]>
Co-authored-by: Nicolas Munnich <[email protected]>
@petejohanson petejohanson force-pushed the feat/pointers-with-input-processors branch from 0ddce94 to 116e2ea Compare December 10, 2024 00:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Core functionality/behavior of ZMK enhancement New feature or request pointers Pointer related functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.