Skip to content

Commit

Permalink
[patch] Configurable threshold to prevent tiny movements activating a…
Browse files Browse the repository at this point in the history
…uto mouse layer Yowkees#563

Signed-off-by: Takahiro Nakayama <[email protected]>
  • Loading branch information
civitaspo committed Sep 20, 2024
1 parent c5eac57 commit 404fafb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
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 @@ -278,6 +278,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 @@ -287,6 +290,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

0 comments on commit 404fafb

Please sign in to comment.