Skip to content

Commit 1edf328

Browse files
committed
fix(trackpad): two finger tap regression
1 parent f1f7304 commit 1edf328

File tree

2 files changed

+18
-72
lines changed

2 files changed

+18
-72
lines changed

drivers/sensors/navigator_trackpad.c

Lines changed: 18 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ const pointing_device_driver_t navigator_trackpad_pointing_device_driver = {.ini
2121

2222
deferred_token callback_token = 0;
2323
uint16_t current_cpi = DEFAULT_CPI_TICK;
24-
uint32_t gpio_offset_addr;
2524
uint8_t has_motion = 0;
2625
extern bool set_scrolling;
2726
bool trackpad_init;
@@ -234,16 +233,11 @@ uint8_t cirque_gen6_enable_logical_scaling(bool set) {
234233
if (set) {
235234
xy_config &= ~0x08;
236235
} else {
237-
xy_config |= ~0x08;
236+
xy_config |= 0x08;
238237
}
239238
return cirque_gen6_write_reg(CGEN6_XY_CONFIG, xy_config);
240239
}
241240

242-
bool cirque_gen6_get_gpio_state(uint8_t num) {
243-
uint32_t gpio_states = cirque_gen6_read_reg_32(0x43000000 + gpio_offset_addr + 0x0004);
244-
return ((gpio_states >> num) & 0x000000001);
245-
}
246-
247241
void cirque_gen_6_read_report(void) {
248242
uint8_t packet[CGEN6_MAX_PACKET_SIZE];
249243
if (cirque_gen6_read_report(packet, CGEN6_MAX_PACKET_SIZE) != I2C_STATUS_SUCCESS) {
@@ -253,19 +247,13 @@ void cirque_gen_6_read_report(void) {
253247
uint8_t report_id = packet[2];
254248
#if defined(NAVIGATOR_TRACKPAD_PTP_MODE)
255249
if (report_id == CGEN6_PTP_REPORT_ID) {
256-
ptp_report.fingers[0].id = (packet[3] & 0xFC) >> 2;
257-
ptp_report.fingers[0].confidence = packet[3] & 0x01;
258-
ptp_report.fingers[0].tip = (packet[3] & 0x02) >> 1;
259-
ptp_report.fingers[0].x = packet[5] << 8 | packet[4];
260-
ptp_report.fingers[0].y = packet[7] << 8 | packet[6];
261-
ptp_report.fingers[1].id = (packet[8] & 0xFC) >> 2;
262-
ptp_report.fingers[1].confidence = packet[8] & 0x01;
263-
ptp_report.fingers[1].tip = (packet[8] & 0x02) >> 1;
264-
ptp_report.fingers[1].x = packet[10] << 8 | packet[9];
265-
ptp_report.fingers[1].y = packet[12] << 8 | packet[11];
266-
ptp_report.ts = packet[14] << 8 | packet[13];
267-
ptp_report.contact_count = packet[15];
268-
ptp_report.buttons = packet[16];
250+
ptp_report.fingers[0].tip = (packet[3] & 0x02) >> 1;
251+
ptp_report.fingers[0].x = packet[5] << 8 | packet[4];
252+
ptp_report.fingers[0].y = packet[7] << 8 | packet[6];
253+
ptp_report.fingers[1].tip = (packet[8] & 0x02) >> 1;
254+
ptp_report.fingers[1].x = packet[10] << 8 | packet[9];
255+
ptp_report.fingers[1].y = packet[12] << 8 | packet[11];
256+
ptp_report.buttons = packet[16];
269257
}
270258
#endif
271259
#if defined(NAVIGATOR_TRACKPAD_RELATIVE_MODE)
@@ -281,26 +269,6 @@ void cirque_gen_6_read_report(void) {
281269
#endif
282270
}
283271

284-
void dump_ptp_report(void) {
285-
#if defined(NAVIGATOR_TRACKPAD_PTP_MODE)
286-
printf("PTP Report:\n");
287-
printf(" ID finger 1: %d\n", ptp_report.fingers[0].id);
288-
printf(" Confidence finger 1: %d\n", ptp_report.fingers[0].confidence);
289-
printf(" Tip finger 1: %d\n", ptp_report.fingers[0].tip);
290-
printf(" X finger 1: %d\n", ptp_report.fingers[0].x);
291-
printf(" Y finger 1: %d\n", ptp_report.fingers[0].y);
292-
printf(" ID finger 2: %d\n", ptp_report.fingers[1].id);
293-
printf(" Confidence finger 2: %d\n", ptp_report.fingers[1].confidence);
294-
printf(" Tip finger 2: %d\n", ptp_report.fingers[1].tip);
295-
printf(" X finger 2: %d\n", ptp_report.fingers[1].x);
296-
printf(" Y finger 2: %d\n", ptp_report.fingers[1].y);
297-
printf(" Timestamp: %d\n", ptp_report.ts);
298-
printf(" Contact Count: %d\n", ptp_report.contact_count);
299-
printf(" Buttons: %d\n", ptp_report.buttons);
300-
printf(" Fingers: %d\n", finger_count(&ptp_report));
301-
#endif
302-
}
303-
304272
// Check if the DR pin is asserted, if it is there is motion data to sample.
305273
uint8_t cirque_gen6_has_motion(void) {
306274
return cirque_gen6_read_reg(CGEN6_I2C_DR, true);
@@ -327,11 +295,12 @@ void navigator_trackpad_device_init(void) {
327295
}
328296
cirque_gen6_clear();
329297
wait_ms(50);
298+
299+
uint8_t res = CGEN6_SUCCESS;
330300
#if defined(NAVIGATOR_TRACKPAD_PTP_MODE)
331-
uint8_t res = cirque_gen6_set_ptp_mode();
332-
#endif
333-
#if defined(NAVIGATOR_TRACKPAD_RELATIVE_MODE)
334-
uint8_t res = cirque_gen6_set_relative_mode();
301+
res = cirque_gen6_set_ptp_mode();
302+
#elif defined(NAVIGATOR_TRACKPAD_RELATIVE_MODE)
303+
res = cirque_gen6_set_relative_mode();
335304
#endif
336305

337306
if (res != CGEN6_SUCCESS) {
@@ -468,12 +437,12 @@ report_mouse_t navigator_trackpad_get_report(report_mouse_t mouse_report) {
468437
bool is_tap = (duration <= NAVIGATOR_TRACKPAD_TAP_TIMEOUT) &&
469438
(dist_sq <= NAVIGATOR_TRACKPAD_TAP_MOVE_THRESHOLD);
470439

471-
// Don't trigger taps if we were scrolling (two fingers detected)
472-
// Also suppress taps that happen shortly after a scroll ends (within 100ms)
440+
// Don't trigger single-finger taps that happen shortly after a scroll ends (within 100ms)
441+
// But allow two-finger taps (right-click) even after scrolling
473442
# ifdef NAVIGATOR_TRACKPAD_SCROLL_WITH_TWO_FINGERS
474-
if (is_tap && (gesture.max_finger_count >= 2 ||
475-
timer_elapsed(gesture.last_scroll_end) < 100)) {
476-
is_tap = false; // Suppress tap after scrolling
443+
if (is_tap && gesture.max_finger_count == 1 &&
444+
timer_elapsed(gesture.last_scroll_end) < 100) {
445+
is_tap = false; // Suppress single-finger tap after scrolling
477446
}
478447
# endif
479448

drivers/sensors/navigator_trackpad.h

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,6 @@
77
#include "report.h"
88
#include "pointing_device.h"
99

10-
# ifndef CIRQUE_PINNACLE_X_LOWER
11-
# define CIRQUE_PINNACLE_X_LOWER 127 // min "reachable" X value
12-
# endif
13-
# ifndef CIRQUE_PINNACLE_X_UPPER
14-
# define CIRQUE_PINNACLE_X_UPPER 1919 // max "reachable" X value
15-
# endif
16-
# ifndef CIRQUE_PINNACLE_Y_LOWER
17-
# define CIRQUE_PINNACLE_Y_LOWER 63 // min "reachable" Y value
18-
# endif
19-
# ifndef CIRQUE_PINNACLE_Y_UPPER
20-
# define CIRQUE_PINNACLE_Y_UPPER 1471 // max "reachable" Y value
21-
# endif
22-
# ifndef CIRQUE_PINNACLE_X_RANGE
23-
# define CIRQUE_PINNACLE_X_RANGE (CIRQUE_PINNACLE_X_UPPER - CIRQUE_PINNACLE_X_LOWER)
24-
# endif
25-
# ifndef CIRQUE_PINNACLE_Y_RANGE
26-
# define CIRQUE_PINNACLE_Y_RANGE (CIRQUE_PINNACLE_Y_UPPER - CIRQUE_PINNACLE_Y_LOWER)
27-
# endif
28-
2910
#define NAVIGATOR_TRACKPAD_READ 7
3011
#define NAVIGATOR_TRACKPAD_PROBE 1000
3112

@@ -147,17 +128,13 @@ typedef struct {
147128
# define MOUSE_EXTENDED_REPORT
148129
# endif
149130
typedef struct {
150-
uint8_t id;
151-
uint8_t confidence;
152131
uint8_t tip;
153132
uint16_t x;
154133
uint16_t y;
155134
} cgen6_finger_t;
156135

157136
typedef struct {
158137
cgen6_finger_t fingers[2];
159-
uint16_t ts;
160-
uint8_t contact_count;
161138
uint8_t buttons;
162139
} cgen6_report_t;
163140

0 commit comments

Comments
 (0)