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..ba0a00cef 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 2 +#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;