@@ -30,13 +30,32 @@ void VoodooI2CGoodixEventDriver::dispatchDigitizerEvent(int logicalX, int logica
3030
3131 // Dispatch the actual event
3232 dispatchDigitizerEventWithTiltOrientation (timestamp, 0 , kDigitiserTransducerFinger , 0x1 , click ? 0x1 : 0x0 , x, y);
33+
34+ last_x = x;
35+ last_y = y;
36+ last_id = 0 ;
37+ }
38+
39+ void VoodooI2CGoodixEventDriver::scheduleLift () {
40+ this ->timer_source ->setTimeoutMS (14 );
41+ }
42+
43+ void VoodooI2CGoodixEventDriver::fingerLift () {
44+ AbsoluteTime timestamp;
45+ clock_get_uptime (×tamp);
46+
47+ dispatchDigitizerEventWithTiltOrientation (timestamp, last_id, kDigitiserTransducerFinger , 0x1 , 0x0 , last_x, last_y);
3348}
3449
50+
3551void VoodooI2CGoodixEventDriver::reportTouches (struct Touch touches[], int numTouches) {
3652 if (numTouches == 1 ) {
3753 // Initial mouse down event
3854 Touch touch = touches[0 ];
3955 dispatchDigitizerEvent (touch.x , touch.y , true );
56+
57+ // Lift a bit later
58+ scheduleLift ();
4059 }
4160 else {
4261 // Move the cursor to the location of the first finger, but don't click
@@ -87,6 +106,15 @@ bool VoodooI2CGoodixEventDriver::handleStart(IOService* provider) {
87106 return false ;
88107 }
89108
109+ this ->work_loop = getWorkLoop ();
110+ if (!this ->work_loop ) {
111+ IOLog (" %s::Unable to get workloop\n " , getName ());
112+ stop (provider);
113+ return false ;
114+ }
115+
116+ work_loop->retain ();
117+
90118 name = getProductName ();
91119
92120 publishMultitouchInterface ();
@@ -105,6 +133,13 @@ bool VoodooI2CGoodixEventDriver::handleStart(IOService* provider) {
105133
106134 multitouch_interface->registerService ();
107135
136+ timer_source = IOTimerEventSource::timerEventSource (this , OSMemberFunctionCast (IOTimerEventSource::Action, this , &VoodooI2CGoodixEventDriver::fingerLift));
137+
138+ if (!timer_source || work_loop->addEventSource (timer_source) != kIOReturnSuccess ) {
139+ IOLog (" %s::Could not add timer source to work loop\n " , getName ());
140+ return false ;
141+ }
142+
108143 return true ;
109144}
110145
@@ -121,6 +156,11 @@ void VoodooI2CGoodixEventDriver::handleStop(IOService* provider) {
121156 OSSafeReleaseNULL (transducers);
122157 }
123158
159+ if (timer_source) {
160+ work_loop->removeEventSource (timer_source);
161+ OSSafeReleaseNULL (timer_source);
162+ }
163+
124164 super::handleStop (provider);
125165}
126166
0 commit comments