Skip to content

Commit

Permalink
Switch to native mouse API
Browse files Browse the repository at this point in the history
ZMK now natively supports mouse movement
as well as scroll (zmkfirmware/zmk#2477)

This involves:
- changing the KConfig values
- switching to new behaviours
- including new headers
- renaming `SCROLL_*` to `SCRL_*`
  • Loading branch information
kucera-lukas committed Dec 31, 2024
1 parent 3c059f2 commit f5c8ec0
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 33 deletions.
6 changes: 3 additions & 3 deletions config/adv360pro.conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ CONFIG_ZMK_BACKLIGHT=n
CONFIG_ZMK_SLEEP=y
CONFIG_ZMK_IDLE_SLEEP_TIMEOUT=1800000

# Mouse config, requires PR #778
CONFIG_ZMK_MOUSE=y
CONFIG_ZMK_MOUSE_TICK_DURATION=8
# Mouse config
CONFIG_ZMK_POINTING=y
CONFIG_ZMK_POINTING_SMOOTH_SCROLLING=y
2 changes: 2 additions & 0 deletions miryoku/miryoku.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

#include "miryoku.h"

#include <dt-bindings/zmk/pointing.h>

/ {
keymap {
compatible = "zmk,keymap";
Expand Down
2 changes: 1 addition & 1 deletion miryoku/miryoku_kludge_mousekeyspr.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
delay-ms = <U_MOUSE_MOVE_DELAY>;
};

&mwh {
&msc {
acceleration-exponent = <U_MOUSE_SCROLL_EXPONENT>;
time-to-max-speed-ms = <U_MOUSE_SCROLL_TIME>;
delay-ms = <U_MOUSE_SCROLL_DELAY>;
Expand Down
42 changes: 13 additions & 29 deletions miryoku/miryoku_kludge_mousekeyspr.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,26 @@

#pragma once

#include <dt-bindings/zmk/mouse.h>

#define U_MOUSE_MOVE_MAX 1000
// Mouse move
#define ZMK_POINTING_DEFAULT_MOVE_VAL 700
#define U_MOUSE_MOVE_EXPONENT 1
#define U_MOUSE_MOVE_TIME 1000
#define U_MOUSE_MOVE_TIME 300
#define U_MOUSE_MOVE_DELAY 0
#define U_MOUSE_SCROLL_MAX 10

// Mouse scroll
#define ZMK_POINTING_DEFAULT_SCRL_VAL 100
#define U_MOUSE_SCROLL_EXPONENT 1
#define U_MOUSE_SCROLL_TIME 0
#define U_MOUSE_SCROLL_DELAY 0

#undef MOVE_UP
#undef MOVE_DOWN
#undef MOVE_LEFT
#undef MOVE_RIGHT
#undef SCROLL_UP
#undef SCROLL_DOWN
#undef SCROLL_LEFT
#undef SCROLL_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)
#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)

#define U_BTN1 &mkp MB1
#define U_BTN2 &mkp MB2
#define U_BTN3 &mkp MB3
#define U_BTN1 &mkp LCLK
#define U_BTN2 &mkp RCLK
#define U_BTN3 &mkp MCLK
#define U_MS_D &mmv MOVE_DOWN
#define U_MS_L &mmv MOVE_LEFT
#define U_MS_R &mmv MOVE_RIGHT
#define U_MS_U &mmv MOVE_UP
#define U_WH_D &mwh SCROLL_DOWN
#define U_WH_L &mwh SCROLL_LEFT
#define U_WH_R &mwh SCROLL_RIGHT
#define U_WH_U &mwh SCROLL_UP
#define U_WH_D &msc SCRL_DOWN
#define U_WH_L &msc SCRL_LEFT
#define U_WH_R &msc SCRL_RIGHT
#define U_WH_U &msc SCRL_UP

0 comments on commit f5c8ec0

Please sign in to comment.