Skip to content

Commit 65b90e0

Browse files
committed
fix: stop phatnom touches after multitouch interactions, fixes #16
1 parent fe1a1f3 commit 65b90e0

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

VoodooI2CGoodix/VoodooI2CGoodixEventDriver.cpp

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ void VoodooI2CGoodixEventDriver::fingerLift() {
7777
fingerDown = false;
7878
currentInteractionType = HOVER;
7979

80+
// Reset multitouch status so we can get single finger interactions again
81+
isMultitouch = false;
82+
8083
scrollStarted = false;
8184

8285
// Reset all transducers
@@ -147,6 +150,10 @@ void VoodooI2CGoodixEventDriver::handleSingletouchInteraction(Touch touch, bool
147150
IOLog("%s::Still hovering at %d, %d\n", getName(), nextLogicalX, nextLogicalY);
148151
#endif
149152

153+
// Wait a tick to begin the click check
154+
// This helps avoid phantom clicks
155+
scheduleClickCheck();
156+
150157
// Check for a right click
151158
if (currentInteractionType == RIGHT_CLICK) {
152159
// Keep the right mousebutton down in the same place
@@ -211,9 +218,6 @@ void VoodooI2CGoodixEventDriver::handleSingletouchInteraction(Touch touch, bool
211218
nextLogicalY = logicalY;
212219
currentInteractionType = LEFT_CLICK;
213220

214-
// Every interaction could be a click, so check for one in a bit
215-
scheduleClickCheck();
216-
217221
#ifdef GOODIX_EVENT_DRIVER_DEBUG
218222
IOLog("%s::Began hover at %d, %d\n", getName(), nextLogicalX, nextLogicalY);
219223
#endif
@@ -253,8 +257,15 @@ void VoodooI2CGoodixEventDriver::handleMultitouchInteraction(struct Touch touche
253257
dispatchDigitizerEvent((touches[0].x + touches[1].x) / 2, (touches[0].y + touches[1].y) / 2, HOVER);
254258

255259
scrollStarted = true;
260+
#ifdef GOODIX_EVENT_DRIVER_DEBUG
261+
IOLog("%s::Starting scroll\n", getName());
262+
#endif
256263
}
257264

265+
#ifdef GOODIX_EVENT_DRIVER_DEBUG
266+
IOLog("%s::Handling multitouch with %d fingers\n", getName(), numTouches);
267+
#endif
268+
258269
AbsoluteTime timestamp;
259270
clock_get_uptime(&timestamp);
260271

@@ -292,9 +303,21 @@ void VoodooI2CGoodixEventDriver::reportTouches(struct Touch touches[], int numTo
292303
}
293304

294305
if (numTouches == 1) {
295-
handleSingletouchInteraction(touches[0], stylusButton1, stylusButton2);
306+
// Block single touch interactions until fingers have lifted after a multitouch interaction
307+
if (!isMultitouch) {
308+
handleSingletouchInteraction(touches[0], stylusButton1, stylusButton2);
309+
}
310+
else {
311+
#ifdef GOODIX_EVENT_DRIVER_DEBUG
312+
IOLog("%s::Blocking phantom single touch interaction\n", getName());
313+
#endif
314+
}
296315
}
297316
else {
317+
// Cancel our outstanding click, we're multitouching
318+
this->clickTimerSource->cancelTimeout();
319+
320+
isMultitouch = true;
298321
handleMultitouchInteraction(touches, numTouches);
299322
}
300323
}

VoodooI2CGoodix/VoodooI2CGoodixEventDriver.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ class EXPORT VoodooI2CGoodixEventDriver : public IOHIDEventService {
213213
UInt16 nextLogicalY = 0;
214214
UInt8 currentInteractionType = LEFT_CLICK;
215215
bool fingerDown = false;
216+
bool isMultitouch = false;
216217
UInt64 fingerDownStart = 0;
217218

218219
UInt8 stylusTransducerID;

0 commit comments

Comments
 (0)