@@ -233,14 +233,17 @@ IOReturn VoodooI2CGoodixTouchDriver::goodix_process_events() {
233233 return kIOReturnSuccess ;
234234 }
235235
236+ AbsoluteTime timestamp;
237+ clock_get_uptime (×tamp);
238+
236239 /*
237240 * Bit 4 of the first byte reports the status of the capacitive
238241 * Windows/Home button.
239242 */
240243// input_report_key(ts->input_dev, KEY_LEFTMETA, point_data[0] & BIT(4));
241244
242245 for (i = 0 ; i < touch_num; i++) {
243- goodix_ts_report_touch (ts, &point_data[1 + GOODIX_CONTACT_SIZE * i]);
246+ goodix_ts_report_touch (ts, &point_data[1 + GOODIX_CONTACT_SIZE * i], timestamp );
244247 }
245248
246249 IOReturn retVal = goodix_write_reg (GOODIX_READ_COOR_ADDR, 0 );
@@ -249,6 +252,16 @@ IOReturn VoodooI2CGoodixTouchDriver::goodix_process_events() {
249252 return retVal;
250253 }
251254
255+ if (touch_num > 0 ) {
256+ VoodooI2CMultitouchEvent event;
257+ event.contact_count = touch_num;
258+ event.transducers = transducers;
259+ // send the event into the multitouch interface
260+ if (mt_interface) {
261+ mt_interface->handleInterruptReport (event, timestamp);
262+ }
263+ }
264+
252265 return kIOReturnSuccess ;
253266}
254267
@@ -309,7 +322,7 @@ int VoodooI2CGoodixTouchDriver::goodix_ts_read_input_report(struct goodix_ts_dat
309322 return 0 ;
310323}
311324
312- void VoodooI2CGoodixTouchDriver::goodix_ts_report_touch (struct goodix_ts_data *ts, UInt8 *coor_data) {
325+ void VoodooI2CGoodixTouchDriver::goodix_ts_report_touch (struct goodix_ts_data *ts, UInt8 *coor_data, AbsoluteTime timestamp ) {
313326 int id = coor_data[0 ] & 0x0F ;
314327 int input_x = get_unaligned_le16 (&coor_data[1 ]);
315328 int input_y = get_unaligned_le16 (&coor_data[3 ]);
@@ -323,14 +336,41 @@ void VoodooI2CGoodixTouchDriver::goodix_ts_report_touch(struct goodix_ts_data *t
323336// if (ts->swapped_x_y)
324337// swap(input_x, input_y);
325338
339+ // Hacky bits
340+ int input_z = input_x;
341+ input_x = input_y;
342+ input_y = input_z;
343+ input_y = 1080 - input_y;
326344// input_mt_slot(ts->input_dev, id);
327345// input_mt_report_slot_state(ts->input_dev, MT_TOOL_FINGER, true);
328346// input_report_abs(ts->input_dev, ABS_MT_POSITION_X, input_x);
329347// input_report_abs(ts->input_dev, ABS_MT_POSITION_Y, input_y);
330348// input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, input_w);
331349// input_report_abs(ts->input_dev, ABS_MT_WIDTH_MAJOR, input_w);
332350
333- IOLog (" %s::Touch %d at %d, %d with width %d\n " , getName (), id, input_x, input_y, input_w);
351+ // IOLog("%s::Touch %d at %d, %d with width %d\n", getName(), id, input_x, input_y, input_w);
352+
353+ if (!transducers) {
354+ IOLog (" %s::No transducers, cannot report" , getName ());
355+ return ;
356+ }
357+
358+ VoodooI2CDigitiserTransducer* transducer = OSDynamicCast (VoodooI2CDigitiserTransducer, transducers->getObject (id));
359+ transducer->type = kDigitiserTransducerFinger ;
360+
361+ transducer->is_valid = true ;
362+
363+ if (mt_interface) {
364+ transducer->logical_max_x = mt_interface->logical_max_x ;
365+ transducer->logical_max_y = mt_interface->logical_max_y ;
366+ }
367+
368+ transducer->coordinates .x .update (input_x, timestamp);
369+ transducer->coordinates .y .update (input_y, timestamp);
370+ transducer->tip_switch .update (1 , timestamp); // wat
371+
372+ transducer->id = id;
373+ transducer->secondary_id = id;
334374}
335375
336376void VoodooI2CGoodixTouchDriver::stop (IOService* provider) {
@@ -546,5 +586,12 @@ bool VoodooI2CGoodixTouchDriver::init_device() {
546586 return false ;
547587 }
548588
589+ if (mt_interface){
590+ mt_interface->physical_max_x = ts->abs_x_max ;
591+ mt_interface->physical_max_y = ts->abs_y_max ;
592+ mt_interface->logical_max_x = ts->abs_x_max ;
593+ mt_interface->logical_max_y = ts->abs_y_max ;
594+ }
595+
549596 return true ;
550597}
0 commit comments