1515#define super IOHIDEventService
1616OSDefineMetaClassAndStructors (VoodooI2CGoodixEventDriver, IOHIDEventService);
1717
18- void VoodooI2CGoodixEventDriver::dispatchDigitizerEvent (int logicalX, int logicalY, bool click ) {
18+ void VoodooI2CGoodixEventDriver::dispatchDigitizerEvent (int logicalX, int logicalY, UInt32 clickType ) {
1919 AbsoluteTime timestamp;
2020 clock_get_uptime (×tamp);
2121
@@ -24,36 +24,83 @@ void VoodooI2CGoodixEventDriver::dispatchDigitizerEvent(int logicalX, int logica
2424 IOFixed y = ((logicalY * 1 .0f ) / multitouch_interface->logical_max_y ) * 65535 ;
2525
2626 // Dispatch the actual event
27- dispatchDigitizerEventWithTiltOrientation (timestamp, 0 , kDigitiserTransducerFinger , 0x1 , click ? 0x1 : 0x0 , x, y);
27+ dispatchDigitizerEventWithTiltOrientation (timestamp, 0 , kDigitiserTransducerFinger , 0x1 , clickType , x, y);
2828
29+ // Store the coordinates so we can lift the finger later
2930 last_x = x;
3031 last_y = y;
31- last_id = 0 ;
3232}
3333
3434void VoodooI2CGoodixEventDriver::scheduleLift () {
35+ this ->timer_source ->cancelTimeout ();
3536 this ->timer_source ->setTimeoutMS (FINGER_LIFT_EVENT_DELAY );
3637}
3738
3839void VoodooI2CGoodixEventDriver::fingerLift () {
3940 AbsoluteTime timestamp;
4041 clock_get_uptime (×tamp);
4142
42- dispatchDigitizerEventWithTiltOrientation (timestamp, last_id, kDigitiserTransducerFinger , 0x1 , 0x0 , last_x, last_y);
43+ dispatchDigitizerEventWithTiltOrientation (timestamp, 0 , kDigitiserTransducerFinger , 0x1 , HOVER , last_x, last_y);
44+
45+ click_tick = 0 ;
46+ start_scroll = true ;
47+
48+ // Reset right click status so we're not stuck checking if we're still right clicking
49+ if (right_click) {
50+ right_click = false ;
51+ }
4352}
4453
4554void VoodooI2CGoodixEventDriver::reportTouches (struct Touch touches[], int numTouches) {
4655 if (numTouches == 1 ) {
47- // Initial mouse down event
4856 Touch touch = touches[0 ];
49- dispatchDigitizerEvent (touch.x , touch.y , true );
5057
51- // Lift a bit later
58+ // Check for right clicks
59+ UInt16 temp_x = touch.x ;
60+ UInt16 temp_y = touch.y ;
61+ if (!right_click) {
62+ if (temp_x == compare_input_x && temp_y == compare_input_y) {
63+ compare_input_counter = compare_input_counter + 1 ;
64+ compare_input_x = temp_x;
65+ compare_input_y = temp_y;
66+
67+ if (compare_input_counter >= RIGHT_CLICK_TICKS && !right_click) {
68+ compare_input_x = 0 ;
69+ compare_input_y = 0 ;
70+ compare_input_counter = 0 ;
71+ right_click = true ;
72+ }
73+ }
74+ else {
75+ compare_input_x = temp_x;
76+ compare_input_y = temp_y;
77+ compare_input_counter = 0 ;
78+ }
79+ }
80+
81+ // Determine what click type to send
82+ UInt32 clickType = LEFT_CLICK ;
83+
84+ if (click_tick <= HOVER_TICKS ) {
85+ clickType = HOVER ;
86+ click_tick++;
87+ }
88+
89+ if (right_click) {
90+ clickType = right_click;
91+ }
92+
93+ dispatchDigitizerEvent (touch.x , touch.y , clickType);
94+
95+ // Lift the finger a bit later
5296 scheduleLift ();
5397 }
5498 else {
99+ // Our finger event is multitouch, so we're not clicking
100+ click_tick = 0 ;
101+
55102 // Move the cursor to the location of the first finger, but don't click
56- dispatchDigitizerEvent (touches[0 ].x , touches[0 ].y , false );
103+ dispatchDigitizerEvent (touches[0 ].x , touches[0 ].y , HOVER );
57104
58105 AbsoluteTime timestamp;
59106 clock_get_uptime (×tamp);
0 commit comments