syscl / OS-X-Voodoo-PS2-Controller

Contains updated Voodoo PS/2 Controller, improved Keyboard & Synaptics TouchPad
Other
18 stars 5 forks source link

DynamicEWMode breaks gestures #5

Open al3xtjames opened 6 years ago

al3xtjames commented 6 years ago

As described by RehabMan in the README, enabling DynamicEWMode (via ACPI) significantly improves scrolling performance.

Added DynamicEWMode option (default is false). This is specifically to improve two finger scroll responsiveness with ClickPads. Instead of always forcing the trackpad into EW mode (EW mode enables two finger data), EW mode is only entered upon clicking the pad. Since each finger gets half bandwidth in EW mode and during a scroll we only need one finger (with indication of two), we can avoid entering EW mode resulting in double the bandwidth during the two finger scroll. Of course, EW mode is needed when the pad is clicked (for holding the button with one finger while dragging with the other), so EW mode is now turned on/off dynamically depending on whether the button is clicked.

However, this breaks gesture inputs. They can still be triggered by clicking the trackpad while inputting the gesture, but this is not ideal (nor is it usable).

syscl commented 6 years ago

Hello TheRacerMaster,

How are you?

It's nice to see you provide such a nice information. So we need to add some patches here for enabling EW mode while scrolling then disable it while we do other gestures right?

Regards, syscl

al3xtjames commented 6 years ago

I'm doing OK. Based off RehabMan's description, I think DynamicEWMode should be disabling EW mode when it detects two fingers (or less). Conditionally re-enabling EW mode for 3/4 finger gestures should fix this:

diff --git a/VoodooPS2Trackpad/VoodooPS2SynapticsTouchPad.cpp b/VoodooPS2Trackpad/VoodooPS2SynapticsTouchPad.cpp
index 7e667da..8e5f535 100644
--- a/VoodooPS2Trackpad/VoodooPS2SynapticsTouchPad.cpp
+++ b/VoodooPS2Trackpad/VoodooPS2SynapticsTouchPad.cpp
@@ -1432,6 +1432,23 @@ void ApplePS2SynapticsTouchPad::dispatchEventsWithPacket(UInt8* packet, UInt32 p
         yraw = yraw * xupmm / yupmm;
     int z = packet[2];
     int f = z>z_finger ? w>=4 ? 1 : w+2 : 0;   // number of fingers
+
+    // theracermaster: When DynamicEWMode is set, enable EW mode for 3/4 finger gestures
+    if (_dynamicEW && _extendedwmodeSupported)
+    {
+        if (!_extendedwmode && f > 2)
+        {
+            setModeByte(_touchPadModeByte | (1<<2));
+            _extendedwmode = true;
+        }
+        // Disable EW mode for 1/2 fingers
+        else if (_extendedwmode && f <= 2)
+        {
+            setModeByte(_touchPadModeByte & ~(1<<2));
+            _extendedwmode = false;
+        }
+    }
+
     ////int v = w;  // v is not currently used... but maybe should be using it
     if (_extendedwmode && _reportsv && f > 1)
     {
@@ -3607,4 +3624,3 @@ bool ApplePS2SynapticsTouchPad::setTouchpadLED(UInt8 touchLED)

     return 12 == request.commandsCount;
 }
-

I can use gestures and scrolling performance is the same. However, I am not sure if this is efficient. When using gestures (back/forwards with three fingers), kernel_task's CPU usage spikes to ~20% in Activity Monitor. When using your version of VoodooPS2Controller (with DynamicEWMode disabled), I do not get such CPU usage spikes. Perhaps there is a better approach? Can you replicate this?

syscl commented 6 years ago

Thank you Racer! I will try it today and let you know!

And I will test this on some other laptops as well :)

Have a good day, syscl