Skip to content

Commit

Permalink
pointing device gestures: div0 checks
Browse files Browse the repository at this point in the history
  • Loading branch information
dkao committed Jul 4, 2022
1 parent 7158ed6 commit f08d5e7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
10 changes: 8 additions & 2 deletions drivers/sensors/cirque_pinnacle_gestures.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,18 @@ static circular_scroll_t circular_scroll(pinnacle_data_t touchData) {
int8_t x, y, wheel_clicks;
uint8_t center = 256 / 2, mag;
int16_t ang, dot, det, opposite_side, adjacent_side;
uint16_t scale = cirque_pinnacle_get_scale();

if (touchData.zValue) {
// place origin at center of trackpad, treat coordinates as vectors
// scale to fixed int8_t size, angles are independent of resolution
x = (int8_t)((int32_t)touchData.xValue * 256 / cirque_pinnacle_get_scale() - center);
y = (int8_t)((int32_t)touchData.yValue * 256 / cirque_pinnacle_get_scale() - center);
if (scale) {
x = (int8_t)((int32_t)touchData.xValue * 256 / scale - center);
y = (int8_t)((int32_t)touchData.yValue * 256 / scale - center);
} else {
x = 0;
y = 0;
}

// check if first touch
if (!scroll.z) {
Expand Down
10 changes: 10 additions & 0 deletions quantum/pointing_device_gestures.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ static cursor_glide_t cursor_glide(cursor_glide_context_t* glide) {
int32_t p;
int32_t x, y;

if (glide->v0 == 0) {
report.dx = 0;
report.dy = 0;
report.valid = false;
glide->dx0 = 0;
glide->dy0 = 0;
goto exit;
}

glide->counter++;
// calculate current 1D position
p = glide->v0 * glide->counter - (int32_t)glide->coef * glide->counter * glide->counter / 2;
Expand All @@ -44,6 +53,7 @@ static cursor_glide_t cursor_glide(cursor_glide_context_t* glide) {
glide->y = y;
glide->timer = timer_read();

exit:
return report;
}

Expand Down

0 comments on commit f08d5e7

Please sign in to comment.