@@ -23,9 +23,39 @@ bool VoodooI2CGoodixEventDriver::didTerminate(IOService* provider, IOOptionBits
2323 return super::didTerminate (provider, options, defer);
2424}
2525
26- void VoodooI2CGoodixEventDriver::forwardReport (VoodooI2CMultitouchEvent event, AbsoluteTime timestamp) {
27- if (multitouch_interface)
26+ void VoodooI2CGoodixEventDriver::reportTouches (Touch *touches, int touchCount) {
27+ AbsoluteTime timestamp;
28+ clock_get_uptime (×tamp);
29+
30+ for (int i = 0 ; i < touchCount; i++) {
31+ Touch touch = touches[i];
32+
33+ VoodooI2CDigitiserTransducer* transducer = OSDynamicCast (VoodooI2CDigitiserTransducer, transducers->getObject (touch.id ));
34+ transducer->type = kDigitiserTransducerFinger ;
35+
36+ transducer->is_valid = true ;
37+
38+ if (multitouch_interface) {
39+ transducer->logical_max_x = multitouch_interface->logical_max_x ;
40+ transducer->logical_max_y = multitouch_interface->logical_max_y ;
41+ }
42+
43+ transducer->coordinates .x .update (touch.x , timestamp);
44+ transducer->coordinates .y .update (touch.y , timestamp);
45+
46+ // Todo: do something with touch->width to determine if it's a contact?
47+ transducer->tip_switch .update (1 , timestamp);
48+
49+ transducer->id = touch.id ;
50+ transducer->secondary_id = touch.id ;
51+ }
52+
53+ VoodooI2CMultitouchEvent event;
54+ event.contact_count = touchCount;
55+ event.transducers = transducers;
56+ if (multitouch_interface) {
2857 multitouch_interface->handleInterruptReport (event, timestamp);
58+ }
2959}
3060
3161const char * VoodooI2CGoodixEventDriver::getProductName () {
@@ -46,20 +76,15 @@ bool VoodooI2CGoodixEventDriver::handleStart(IOService* provider) {
4676
4777 publishMultitouchInterface ();
4878
49- digitiser.fingers = OSArray::withCapacity (1 );
50-
51- if (!digitiser.fingers )
52- return false ;
53-
54- digitiser.styluses = OSArray::withCapacity (1 );
55-
56- if (!digitiser.styluses )
57- return false ;
58-
59- digitiser.transducers = OSArray::withCapacity (1 );
60-
61- if (!digitiser.transducers )
79+ transducers = OSArray::withCapacity (GOODIX_MAX_CONTACTS);
80+ if (!transducers) {
6281 return false ;
82+ }
83+ DigitiserTransducerType type = kDigitiserTransducerFinger ;
84+ for (int i = 0 ; i < GOODIX_MAX_CONTACTS; i++) {
85+ VoodooI2CDigitiserTransducer* transducer = VoodooI2CDigitiserTransducer::transducer (type, NULL );
86+ transducers->setObject (transducer);
87+ }
6388
6489 setDigitizerProperties ();
6590
@@ -71,19 +96,22 @@ bool VoodooI2CGoodixEventDriver::handleStart(IOService* provider) {
7196}
7297
7398void VoodooI2CGoodixEventDriver::handleStop (IOService* provider) {
74- OSSafeReleaseNULL (digitiser.transducers );
75- OSSafeReleaseNULL (digitiser.wrappers );
76- OSSafeReleaseNULL (digitiser.styluses );
77- OSSafeReleaseNULL (digitiser.fingers );
78-
79- OSSafeReleaseNULL (attached_hid_pointer_devices);
80-
8199 if (multitouch_interface) {
82100 multitouch_interface->stop (this );
83101 multitouch_interface->detach (this );
84102 OSSafeReleaseNULL (multitouch_interface);
85103 }
86104
105+ if (transducers) {
106+ for (int i = 0 ; i < transducers->getCount (); i++) {
107+ OSObject* object = transducers->getObject (i);
108+ if (object) {
109+ object->release ();
110+ }
111+ }
112+ OSSafeReleaseNULL (transducers);
113+ }
114+
87115 PMstop ();
88116 super::handleStop (provider);
89117}
@@ -117,24 +145,14 @@ IOReturn VoodooI2CGoodixEventDriver::publishMultitouchInterface() {
117145}
118146
119147void VoodooI2CGoodixEventDriver::setDigitizerProperties () {
120- OSDictionary* properties = OSDictionary::withCapacity (4 );
148+ OSDictionary* properties = OSDictionary::withCapacity (1 );
121149
122150 if (!properties)
123151 return ;
124152
125- if (!digitiser.transducers )
126- goto exit;
127-
128- properties->setObject (" Contact Count Element" , digitiser.contact_count );
129- properties->setObject (" Input Mode Element" , digitiser.input_mode );
130- properties->setObject (" Contact Count Maximum Element" , digitiser.contact_count_maximum );
131- properties->setObject (" Button Element" , digitiser.button );
132- properties->setObject (" Transducer Count" , OSNumber::withNumber (digitiser.transducers ->getCount (), 32 ));
153+ properties->setObject (" Transducer Count" , OSNumber::withNumber (GOODIX_MAX_CONTACTS, 32 ));
133154
134155 setProperty (" Digitizer" , properties);
135-
136- exit:
137- OSSafeReleaseNULL (properties);
138156}
139157
140158IOReturn VoodooI2CGoodixEventDriver::setPowerState (unsigned long whichState, IOService* whatDevice) {
@@ -145,8 +163,6 @@ bool VoodooI2CGoodixEventDriver::start(IOService* provider) {
145163 if (!super::start (provider))
146164 return false ;
147165
148- attached_hid_pointer_devices = OSSet::withCapacity (1 );
149-
150166 setProperty (" VoodooI2CServices Supported" , kOSBooleanTrue );
151167
152168 return true ;
0 commit comments