diff --git a/qmk_firmware/keyboards/keyball/lib/keyball/keyball.c b/qmk_firmware/keyboards/keyball/lib/keyball/keyball.c index cc57e8d26..a19d8bc73 100644 --- a/qmk_firmware/keyboards/keyball/lib/keyball/keyball.c +++ b/qmk_firmware/keyboards/keyball/lib/keyball/keyball.c @@ -166,7 +166,7 @@ void pointing_device_driver_set_cpi(uint16_t cpi) { keyball_set_cpi(cpi); } -static void motion_to_mouse_move(keyball_motion_t *m, report_mouse_t *r, bool is_left) { +__attribute__((weak)) void keyball_on_apply_motion_to_mouse_move(keyball_motion_t *m, report_mouse_t *r, bool is_left) { #if KEYBALL_MODEL == 61 || KEYBALL_MODEL == 39 || KEYBALL_MODEL == 147 || KEYBALL_MODEL == 44 r->x = clip2int8(m->y); r->y = clip2int8(m->x); @@ -185,7 +185,7 @@ static void motion_to_mouse_move(keyball_motion_t *m, report_mouse_t *r, bool is m->y = 0; } -static void motion_to_mouse_scroll(keyball_motion_t *m, report_mouse_t *r, bool is_left) { +__attribute__((weak)) void keyball_on_apply_motion_to_mouse_scroll(keyball_motion_t *m, report_mouse_t *r, bool is_left) { // consume motion of trackball. int16_t div = 1 << (keyball_get_scroll_div() - 1); int16_t x = divmod16(&m->x, div); @@ -223,9 +223,9 @@ static void motion_to_mouse_scroll(keyball_motion_t *m, report_mouse_t *r, bool static void motion_to_mouse(keyball_motion_t *m, report_mouse_t *r, bool is_left, bool as_scroll) { if (as_scroll) { - motion_to_mouse_scroll(m, r, is_left); + keyball_on_apply_motion_to_mouse_scroll(m, r, is_left); } else { - motion_to_mouse_move(m, r, is_left); + keyball_on_apply_motion_to_mouse_move(m, r, is_left); } } diff --git a/qmk_firmware/keyboards/keyball/lib/keyball/keyball.h b/qmk_firmware/keyboards/keyball/lib/keyball/keyball.h index 28c5cc0b6..7074ed372 100644 --- a/qmk_firmware/keyboards/keyball/lib/keyball/keyball.h +++ b/qmk_firmware/keyboards/keyball/lib/keyball/keyball.h @@ -174,6 +174,22 @@ typedef enum { extern keyball_t keyball; +////////////////////////////////////////////////////////////////////////////// +// Hook points + +/// keyball_on_adjust_layout is called when the keyboard layout adjustted +void keyball_on_adjust_layout(keyball_adjust_t v); + +/// keyball_on_apply_motion_to_mouse_move applies trackball's motion m to r as +/// mouse movement. +/// You can change the default algorithm by override this function. +void keyball_on_apply_motion_to_mouse_move(keyball_motion_t *m, report_mouse_t *r, bool is_left); + +/// keyball_on_apply_motion_to_mouse_scroll applies trackball's motion m to r +/// as mouse scroll. +/// You can change the default algorithm by override this function. +void keyball_on_apply_motion_to_mouse_scroll(keyball_motion_t *m, report_mouse_t *r, bool is_left); + ////////////////////////////////////////////////////////////////////////////// // Public API functions