Skip to content

Commit 94aea07

Browse files
committed
Working touchscreen cursor tracking (clicks nonstop though)
1 parent cb9e149 commit 94aea07

File tree

3 files changed

+46
-26
lines changed

3 files changed

+46
-26
lines changed

VoodooI2CGoodix.xcodeproj/xcuserdata/lazd.xcuserdatad/xcschemes/xcschememanagement.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<key>VoodooI2CGoodix.xcscheme_^#shared#^_</key>
88
<dict>
99
<key>orderHint</key>
10-
<integer>5</integer>
10+
<integer>4</integer>
1111
</dict>
1212
</dict>
1313
</dict>

VoodooI2CGoodix/VoodooI2CGoodixEventDriver.cpp

Lines changed: 40 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -28,35 +28,51 @@ void VoodooI2CGoodixEventDriver::reportTouches(struct Touch touches[], int numTo
2828
clock_get_uptime(&timestamp);
2929

3030
IOLog("Need to report %d touches", numTouches);
31-
for (int i = 0; i < numTouches; i++) {
32-
Touch touch = touches[i];
3331

34-
IOLog("Touch %d at %d,%d", i, touch.x, touch.y);
35-
VoodooI2CDigitiserTransducer* transducer = OSDynamicCast(VoodooI2CDigitiserTransducer, transducers->getObject(i));
36-
transducer->type = kDigitiserTransducerFinger;
32+
if (numTouches == 1) {
33+
Touch touch = touches[0];
34+
// VoodooI2CDigitiserTransducer* transducer = OSDynamicCast(VoodooI2CDigitiserTransducer, transducers->getObject(0));
35+
// UInt32 buttons = transducer->tip_switch.value();
3736

38-
transducer->is_valid = true;
37+
IOFixed x = ((touch.x * 1.0f) / multitouch_interface->logical_max_x) * 65535;
38+
IOFixed y = ((touch.y * 1.0f) / multitouch_interface->logical_max_y) * 65535;
3939

40-
if (multitouch_interface) {
41-
transducer->logical_max_x = multitouch_interface->logical_max_x;
42-
transducer->logical_max_y = multitouch_interface->logical_max_y;
43-
}
40+
dispatchDigitizerEventWithTiltOrientation(timestamp, 0, kDigitiserTransducerFinger, 0x1, 0x1, x, y);
41+
}
42+
else {
43+
// Todo: move the cursor directly to the location between the fingers?
4444

45-
transducer->coordinates.x.update(touch.x, timestamp);
46-
transducer->coordinates.y.update(touch.y, timestamp);
45+
// Send a multitouch event for scrolls, scales, etc
46+
for (int i = 0; i < numTouches; i++) {
47+
Touch touch = touches[i];
4748

48-
// Todo: do something with touch->width to determine if it's a contact?
49-
transducer->tip_switch.update(1, timestamp);
49+
IOLog("Touch %d at %d,%d with max %d,%d", i, touch.x, touch.y, multitouch_interface->logical_max_x, multitouch_interface->logical_max_y);
50+
VoodooI2CDigitiserTransducer* transducer = OSDynamicCast(VoodooI2CDigitiserTransducer, transducers->getObject(i));
51+
transducer->type = kDigitiserTransducerFinger;
5052

51-
transducer->id = i;
52-
transducer->secondary_id = i;
53-
}
53+
transducer->is_valid = true;
5454

55-
VoodooI2CMultitouchEvent event;
56-
event.contact_count = numTouches;
57-
event.transducers = transducers;
58-
if (multitouch_interface) {
59-
multitouch_interface->handleInterruptReport(event, timestamp);
55+
if (multitouch_interface) {
56+
transducer->logical_max_x = multitouch_interface->logical_max_x;
57+
transducer->logical_max_y = multitouch_interface->logical_max_y;
58+
}
59+
60+
transducer->coordinates.x.update(touch.x, timestamp);
61+
transducer->coordinates.y.update(touch.y, timestamp);
62+
63+
// Todo: do something with touch->width to determine if it's a contact?
64+
transducer->tip_switch.update(1, timestamp);
65+
66+
transducer->id = i;
67+
transducer->secondary_id = i;
68+
}
69+
70+
VoodooI2CMultitouchEvent event;
71+
event.contact_count = numTouches;
72+
event.transducers = transducers;
73+
if (multitouch_interface) {
74+
multitouch_interface->handleInterruptReport(event, timestamp);
75+
}
6076
}
6177
}
6278

@@ -94,6 +110,8 @@ bool VoodooI2CGoodixEventDriver::handleStart(IOService* provider) {
94110
// hid_interface->joinPMtree(this);
95111
// registerPowerDriver(this, VoodooI2CIOPMPowerStates, kVoodooI2CIOPMNumberPowerStates);
96112

113+
multitouch_interface->registerService();
114+
97115
return true;
98116
}
99117

VoodooI2CGoodix/VoodooI2CGoodixTouchDriver.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,6 @@ bool VoodooI2CGoodixTouchDriver::start(IOService* provider) {
183183
ready_for_input = true;
184184
setProperty("VoodooI2CServices Supported", OSBoolean::withBoolean(true));
185185
IOLog("%s::VoodooI2CGoodixTouchDriver has started\n", getName());
186-
registerService();
187186

188187
// Instantiate the event driver
189188
// Todo: how to properly attach to this service?
@@ -205,6 +204,9 @@ bool VoodooI2CGoodixTouchDriver::start(IOService* provider) {
205204
}
206205

207206
event_driver->initializeMultitouchInterface(ts->abs_x_max, ts->abs_y_max);
207+
event_driver->registerService();
208+
209+
registerService();
208210

209211
return true;
210212
start_exit:
@@ -421,9 +423,9 @@ void VoodooI2CGoodixTouchDriver::release_resources() {
421423
}
422424
if (event_driver) {
423425
// Todo: how to properly release event_driver?
424-
event_driver->release(); // required?
425-
event_driver->stop(this);
426+
// event_driver->stop(this); // causes crash
426427
event_driver->detach(this);
428+
// event_driver->release(); // required?
427429
OSSafeReleaseNULL(event_driver);
428430
}
429431
}

0 commit comments

Comments
 (0)