From bdd1552c00723ce4a39731ad897574699289424f Mon Sep 17 00:00:00 2001 From: Jesse Date: Mon, 22 Apr 2024 20:45:05 +0900 Subject: [PATCH 1/2] Add configurable threshold to prevent tiny movements activating auto mouse layer --- qmk_firmware/keyboards/keyball/lib/keyball/keyball.c | 9 +++++++++ qmk_firmware/keyboards/keyball/lib/keyball/keyball.h | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/qmk_firmware/keyboards/keyball/lib/keyball/keyball.c b/qmk_firmware/keyboards/keyball/lib/keyball/keyball.c index 07efac7a7..d7727ab7d 100644 --- a/qmk_firmware/keyboards/keyball/lib/keyball/keyball.c +++ b/qmk_firmware/keyboards/keyball/lib/keyball/keyball.c @@ -277,6 +277,9 @@ report_mouse_t pointing_device_driver_get_report(report_mouse_t rep) { } // report mouse event, if keyboard is primary. if (is_keyboard_master() && should_report()) { + // Reset total motion tracker. + keyball.total_motion.x = 0; + keyball.total_motion.y = 0; // modify mouse report by PMW3360 motion. motion_to_mouse(&keyball.this_motion, &rep, is_keyboard_left(), keyball.scroll_mode); motion_to_mouse(&keyball.that_motion, &rep, !is_keyboard_left(), keyball.scroll_mode ^ keyball.this_have_ball); @@ -286,6 +289,12 @@ report_mouse_t pointing_device_driver_get_report(report_mouse_t rep) { return rep; } +bool auto_mouse_activation(report_mouse_t mouse_report) { + keyball.total_motion.x += mouse_report.x; + keyball.total_motion.y += mouse_report.y; + return abs(keyball.total_motion.x) > KEYBALL_AUTO_MOUSE_THRESHOLD || abs(keyball.total_motion.y) > KEYBALL_AUTO_MOUSE_THRESHOLD || mouse_report.buttons; +} + ////////////////////////////////////////////////////////////////////////////// // Split RPC diff --git a/qmk_firmware/keyboards/keyball/lib/keyball/keyball.h b/qmk_firmware/keyboards/keyball/lib/keyball/keyball.h index 32003a846..a01b83248 100644 --- a/qmk_firmware/keyboards/keyball/lib/keyball/keyball.h +++ b/qmk_firmware/keyboards/keyball/lib/keyball/keyball.h @@ -49,6 +49,11 @@ along with this program. If not, see . # define KEYBALL_SCROLLSNAP_TENSION_THRESHOLD 12 #endif +/// Threshold of mouse movement before layer change occurs +#ifndef KEYBALL_AUTO_MOUSE_THRESHOLD +# define KEYBALL_AUTO_MOUSE_THRESHOLD 5 +#endif + /// Specify SROM ID to be uploaded PMW3360DW (optical sensor). It will be /// enabled high CPI setting or so. Valid valus are 0x04 or 0x81. Define this /// in your config.h to be enable. Please note that using this option will @@ -158,6 +163,7 @@ typedef struct { keyball_motion_t this_motion; keyball_motion_t that_motion; + keyball_motion_t total_motion; uint8_t cpi_value; bool cpi_changed; From add49111189f18171ce4a2e935b7e21fab4942e9 Mon Sep 17 00:00:00 2001 From: Jesse Jennings Date: Mon, 22 Apr 2024 07:14:21 -0500 Subject: [PATCH 2/2] Smaller starting threshold for automouse --- qmk_firmware/keyboards/keyball/lib/keyball/keyball.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qmk_firmware/keyboards/keyball/lib/keyball/keyball.h b/qmk_firmware/keyboards/keyball/lib/keyball/keyball.h index a01b83248..ba0a00cef 100644 --- a/qmk_firmware/keyboards/keyball/lib/keyball/keyball.h +++ b/qmk_firmware/keyboards/keyball/lib/keyball/keyball.h @@ -51,7 +51,7 @@ along with this program. If not, see . /// Threshold of mouse movement before layer change occurs #ifndef KEYBALL_AUTO_MOUSE_THRESHOLD -# define KEYBALL_AUTO_MOUSE_THRESHOLD 5 +# define KEYBALL_AUTO_MOUSE_THRESHOLD 2 #endif /// Specify SROM ID to be uploaded PMW3360DW (optical sensor). It will be