linux-surface / iptsd

Userspace daemon for Intel Precise Touch & Stylus
GNU General Public License v2.0
94 stars 46 forks source link

SB1 performance #4

Closed tmarkov closed 4 years ago

tmarkov commented 4 years ago

I just tested iptsd on SB1, kernel 5.6.15 on Manjaro.

Pen works great. The lines are very smooth. When I draw lines very fast, the line lags a bit behind, but not by much.

Touch, however, works poorly. When I touch the screen and hold, the mouse starts jumping all over the part of the screen to the left and above where I'm touching. Also apps start zooming in and out.

StollD commented 4 years ago

Thanks for testing!

The issues with the touchscreen are unfortunate, but kinda expected at this stage I guess. The algorithm is very very simple: Just find the first 10 local maximas in the heightmap and calculate the exact screen position using their direct neighbors. There is no noise filtering or palm detection going on.

Your problem sounds like something I have observed on my SB2 a while ago: When you press on the screen, a different area gets suddenly filled with noise (depending on how hard you pressed on the display). I still have a similar issue from time to time with iptsd, but restarting the device usually fixes it for a while. Maybe that will work for you too?

The output of sudo evtest for the IPTS Touch device would be interesting too, although I don't think it will actually help with solving the problem.

tmarkov commented 4 years ago

That makes sense. I was experimenting before with the heatmap on SB1, and usually there is noise where I'm not pressing. It was pretty consistent for me though rather than sporadic.

That simple algorithms seemed to work very well for me, but using a 5x5 square rather than a 3x3 - to the point I'm not sure anything more complex is even necessary. Putting a threshold on the local maximas was sufficient to avoid fake touches. I think I was using 0.5 (0.705 being the no press value). It would also avoid very, very light touches, but more often than not if I touch so lightly it's accidental anyway.

tmarkov commented 4 years ago

Increasing the threshold does fix the pointer jumping around issue. However, now I can see issue: when moving the finger around, the pointer lags a significant amount behind - sometimes by the whole screen width.

StollD commented 4 years ago

How did you increase the threshold? I tried simply replacing the average based threshold with a constant value (0.5 sounded like a good idea so I used that), and it seems to work fine for me.

diff --git a/processing/heatmap/contact.go b/processing/heatmap/contact.go
index 838fb17..8fe453a 100644
--- a/processing/heatmap/contact.go
+++ b/processing/heatmap/contact.go
@@ -1,7 +1,6 @@
 package heatmap

 func (hm Heatmap) Contacts(contacts []Contact) int {
-   threshold := hm.Average() + 1
    c := 0

    if len(contacts) == 0 {
@@ -10,7 +9,7 @@ func (hm Heatmap) Contacts(contacts []Contact) int {

    for x := 0; x < hm.Width; x++ {
        for y := 0; y < hm.Height; y++ {
-           if float32(hm.Value(x, y)) < threshold {
+           if hm.Value(x, y) < 127 {
                continue
            }
tmarkov commented 4 years ago

Ah, yea, I messed up. In addition to increasing the threshold, I had added some debug prints that were actually causing the lags. It works fine now.