@@ -28,35 +28,51 @@ void VoodooI2CGoodixEventDriver::reportTouches(struct Touch touches[], int numTo
2828 clock_get_uptime (×tamp);
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
0 commit comments