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

Configurable threshold to prevent tiny movements activating auto mouse layer #563

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions qmk_firmware/keyboards/keyball/lib/keyball/keyball.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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

Expand Down
6 changes: 6 additions & 0 deletions qmk_firmware/keyboards/keyball/lib/keyball/keyball.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
# 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
Expand Down Expand Up @@ -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;
Expand Down