Edit 2024-02-05:
The instructions below are outdated.
There is an official PR (#2027) for mouse functionality. You should use that rather than what is described below.
When looking to add mouse support, I originally found instructions for how to go about it on Reddit. I was later pointed out to this message on the ZMK Discord (invite).
Repository with mouse support: FTC.
Documentation for for beta testing, including how to make a build off of a different repo such as the one mentioned above. Some documentation about mouse support found here; can be complemented by looking at the source code, here.
EDIT 2022-12-10: Added additional configuration options for scroll wheel speed tweaks.
EDIT 2022-12-09: Added additional configuration options which can be used to tweak mouse movement speed.
Step one, use the custom repository mentioned above in config/west.yml
:
manifest:
remotes:
- name: zmkfirmware
url-base: https://github.com/ftc/ # <--- CHANGE REPO
projects:
- name: zmk
remote: zmkfirmware
revision: mouse-ftc # <--- CHANGE REVISION
import: app/west.yml
self:
path: config
Step 2, add necessary config line in config/YOURBOARD.conf
:
CONFIG_ZMK_SLEEP=y
CONFIG_ZMK_MOUSE=y /* <--- ADD MOUSE SUPPORT */
Step 3, add support in the keyboard layout, config/YOURBOARD.keymap
:
a) Necessary include in the header:
#include <dt-bindings/zmk/mouse.h>
b) Binds, like for instance:
&mkp LCLK &mkp RCLK
&mmv MOVE_UP &mmv MOVE_DOWN
&mmv MOVE_LEFT &mmv MOVE_RIGHT
Step 4, build it; install on the board.
Step 5, unpair and repair the keyboard for it to be recognised as a pointer device as well.
To adjust mouse movement speed, the following can be used in config/YOURBOARD.keymap
, before the keymap {}.
#define U_MOUSE_MOVE_MAX 1400 /* <--- New max speed setting (default: 600) */
#undef MOVE_UP
#undef MOVE_DOWN
#undef MOVE_LEFT
#undef MOVE_RIGHT
#define MOVE_UP MOVE_VERT(-U_MOUSE_MOVE_MAX)
#define MOVE_DOWN MOVE_VERT(U_MOUSE_MOVE_MAX)
#define MOVE_LEFT MOVE_HOR(-U_MOUSE_MOVE_MAX)
#define MOVE_RIGHT MOVE_HOR(U_MOUSE_MOVE_MAX)
&mmv {
time-to-max-speed-ms = <400>; /* <--- How long time until max speed is reached (default: 500) */
};
To adjust scroll wheel, use something like the following:
#define U_MOUSE_SCROLL_MAX 100 /* <--- New max speed setting (default: 10) */
#undef SCROLL_UP
#undef SCROLL_DOWN
#undef SCROLL_LEFT
#undef SCROLL_RIGHT
#define SCROLL_UP SCROLL_VERT(U_MOUSE_SCROLL_MAX)
#define SCROLL_DOWN SCROLL_VERT(-U_MOUSE_SCROLL_MAX)
#define SCROLL_LEFT SCROLL_HOR(-U_MOUSE_SCROLL_MAX)
#define SCROLL_RIGHT SCROLL_HOR(U_MOUSE_SCROLL_MAX)
&mwh {
time-to-max-speed-ms = <500>; /* <--- How long time until max speed is reached */
};
To answer some questions. ftc's fork is very outdated by now. As of today, my mouse repo is otherwise up to date with upstream ZMK. If you want additional experimental features like smart layers or swapper, the main branch of that repo adds mouse emulation support alongside various common features (see the readme in that branch for a list). I try to keep both branches up to date with the latest ZMK updates (but this may change in the future).
Note that if you are coming from ftc's branch, there have been some breaking changes to ZMK in the meantime, which require some edits to the keymap. The most common change needed is to replace
&reset
with&sys_reset
in the keymap. If you are using custom board definitions, you may need additional changes. See this blog post for details.For troubleshooting, updates on the mouse support and ZMK, or any other help in general, I highly recommend checking out the ZMK discord. The community has been most friendly and helpful.