linux-surface / linux-surface

Linux Kernel for Surface Devices
4.62k stars 201 forks source link

Surface Pro 4 touchscreen not working properly, ghost touches everywhere #1046

Open Gordon3002 opened 1 year ago

Gordon3002 commented 1 year ago

I tried installing linux on my surface pro 4 following the guide here on github but the touchscreen just doesn't work correctly, I get ghost touches everywhere making the system unusable. This issue has been frustrating me for days, I tried everything to solve it, the solution mentioned in the wiki didn't help, I tried installing iptsd from the .deb file provided here on github but nothing, I tried building iptsd from source but couldn't manage it because of the hidrd dependency that I couldn't for the life of me manage to install. There's also to mention that even in Windows the touchscreen of my unit has some issues on the edges of the display not recognizing touches properly, however it is still usable (in Windows). It has been driving me nuts, I just can't find a solution, can any of you guys help ?

dmesg output: dmseg output.txt

1701 commented 1 year ago

An example of a configuration that also works very well:

/etc/ipts.conf

[Config] TouchThreshold = 50 StabilityThreshold = 0.55

[Touch] CheckStability = true DisableOnPalm = false DisableOnStylus = false

[Contacts] Detection = advanced TemporalWindow = 5 SizeMin = 0.3

Gordon3002 commented 1 year ago

In my ipts.conf there's only config, the others aren't there, do I just add them or is it another version of iptsd ? Here's my ipts.conf file: ipts.conf.txt

1701 commented 1 year ago

just add it. After my system was unusable because of the Ghost Touches, it worked great with this config. I tested it with Ubuntu and Fedora.

Gordon3002 commented 1 year ago

I just tried but didn't work, did I mess something up ? Is the spacing correct ? ipts.conf.txt

1701 commented 1 year ago

this looks wrong. the config should look exactly like in my comment above. also the # characters should be removed from the parameters.

1701 commented 1 year ago

and please restart iptsd via systemctl restart iptsd

Gordon3002 commented 1 year ago

Thanks a bunch ! It actually solved it, now touch works perfectly. This config needs to be added to the wiki

Gordon3002 commented 1 year ago

Also I wanted to add that today I ran some updates and the touchscreen went insane again. This was solved by uninstalling iptsd running in terminal ‘sudo apt remove iptsd’ and this made the touch work a little bit better in fact, single touches are more precise making it possible to scroll whereas before it was impossible to draw a straight line. All of this at the cost of losing multitouch though. All things considered I’d say that it’s better like this. Just thought I’d let you know for anyone who might need it, I reopened the issue to make it easier to find.

qzed commented 1 year ago

You might want to try and adapt the old config for the new version. The settings you can change are described here: https://github.com/linux-surface/iptsd/blob/master/etc/iptsd.conf

Gordon3002 commented 1 year ago

That actually worked, I applied the configs on the iptsd.conf file and it works even better now. Though still only single touch, no multitouch.

Gordon3002 commented 1 year ago

I edited the wiki with the updated instructions for anyone who might need it, here's the link: https://github.com/linux-surface/linux-surface/wiki/Surface-Pro-4

tpw2033 commented 1 year ago

@Gordon3002 , I just ran into the same issues you are facing today. Funny timing that I found this! Anyways, the one thing that improved touch on my SP4 immensely is enabling Wayland if you haven't already. Touch works exponentially better and I haven't even edited the conf yet.

SeongGino commented 1 year ago

Updated iptsd, running into the same issue as well. The old Touch Sensitivity option doesn't exist and seems to have no analogue in the new configs. @Gordon3002's suggestions didn't help in my case, the touch cursor is going to a corner every so often.

StollD commented 1 year ago

Quoting from the wiki

Once done the touchscreen should be working correctly minus multitouch

That is weird, because the only way to not have multitouch is if iptsd is not running. Could you make sure it is? ps aux | grep iptsd, or check if the pen works. Or do you mean multitouch in applications? For that you probably need Wayland.

The commands above are already edited but in your case you'll need to change these: change the 'Detection' command to = advanced, the 'TemporalWindow' to = 5 and the 'SizeMin' to = 0.3.

You can put partial configs into /etc/iptsd.d, that way you could provide only the values that are actually needed.

Increasing the temporal window is a good idea against ghost touches, but instead of always increasing SizeMin, you should calibrate iptsd: https://github.com/linux-surface/iptsd/wiki/Calibrating-iptsd

Also, if you are experiencing ghost touches, I would appreciate if you could get me a binary log of the IPTS data. For this you need to stop iptsd first, and then run iptsd-dump.

$ sudo systemctl stop $(iptsd-find-service)
$ sudo iptsd-dump $(iptsd-find-hidraw) ipts-log.bin

When iptsd-dump is running, you need to touch the screen a few times. There won't be any inputs generated, so unfortunately it is hard to see if ghost touches are actually appearing. If you have a reliable way to reproduce them, that would be great. Otherwise just leave it running for like a minute and do stuff on the display. Maybe it helps that my SB2 usually generates a bunch of garbage data if I put all fingers on the display and move them around.

Once you have enough data, stop the iptsd-dump program with Ctrl-C and upload the ipts-log.bin file it generated here. If you want to check if there are actually ghost touches in the data (or if you just want to know what it looks like), you can use iptsd-plot to generate images for every data frame.

$ iptsd-plot ipts-log.bin out

You can either go through the images one by one, or you can play them as a video.

$ ffplay out/%05d.png
1701 commented 1 year ago

Hi, Multitouch works perfectly fine if, if you copy the values from my initial post to the new config. Please note that multitouch is not supported by all applications!

1701 commented 1 year ago

I edited the wiki with the updated instructions for anyone who might need it, here's the link: https://github.com/linux-surface/linux-surface/wiki/Surface-Pro-4

this new config doesn't work. did you just remove all # from the new default config? i think this makes no sense.

This is my config (works in x11 and wayland, single and multitouch and pen):

/etc/iptsd.conf 
[Config]
##
## The following values are device specific and will be loaded from /usr/share/iptsd
## Only set them if you need to provide custom values for new devices that are not yet supported
##
TouchTreshold = 50
StabilityTreshold = 0.55
# InvertX = false
# InvertY = false
# Width = 0
# Height = 0

[Touch]
##
## Mark contacts around the stylus as palms.
##
# CheckCone = true

##
## Skip contacts that are not marked as stable.
## Contacts are unstable if their size or position is changing rapidly.
##
CheckStability = true

##
## Ignore all touch inputs if a palm was registered on the display.
##
DisableOnPalm = false

##
## Ignore all touch inputs if a stylus is in proximity.
##
DisableOnStylus = false

[Contacts]
##
## The blob detection method that will be used.
## Basic should give a good overall experience.
## Advanced might offer better finger detection, but will use vastly more resources.
##
Detection = advanced

##
## The temporal window for determining temporal stability of a contact.
## A contact that has not been active for the specified amount of frames is skipped.
##
TemporalWindow = 5

##
## The minimal diameter a contact must have.
##
SizeMin = 0.3

##
## The maximal diameter a contact can have.
##
# SizeMax = 2.0

##
## The minimal aspect ratio a contact must have.
##
# AspectMin = 1.0

##
## The maximal aspect ratio a contact can have.
##
# AspectMax = 2.5

##
## How many centimeters a contact can increase in size to be considered stable.
##
# SizeThreshold = 0.1

##
## How many centimeters a contact must move before the movement is considered stable.
## Movements below this threshold are ignored.
##
# PositionThresholdMin = 0.2

##
## How many centimeters a contact can move before the movement is considered unstable.
## Movements above this threshold are ignored.
##
# PositionThresholdMax = 2

##
## How many centimeters a contact has to be away from a palm to not get marked as a palm too.
##
# DistanceThreshold = 1

[Cone]
##
## The wideness of the cone in degrees.
##
# Angle = 30

##
## How many centimeters a contact must be away from the stylus to not get blocked.
##
# Distance = 5

[DFT]
# PositionMinAmp = 50
# PositionMinMag = 2000
# PositionExp = -0.7
# ButtonMinMag = 1000
# FreqMinMag = 10000
Gordon3002 commented 1 year ago

Quoting from the wiki

Once done the touchscreen should be working correctly minus multitouch

That is weird, because the only way to not have multitouch is if iptsd is not running. Could you make sure it is? ps aux | grep iptsd, or check if the pen works. Or do you mean multitouch in applications? For that you probably need Wayland.

The commands above are already edited but in your case you'll need to change these: change the 'Detection' command to = advanced, the 'TemporalWindow' to = 5 and the 'SizeMin' to = 0.3.

You can put partial configs into /etc/iptsd.d, that way you could provide only the values that are actually needed.

Increasing the temporal window is a good idea against ghost touches, but instead of always increasing SizeMin, you should calibrate iptsd: https://github.com/linux-surface/iptsd/wiki/Calibrating-iptsd

Also, if you are experiencing ghost touches, I would appreciate if you could get me a binary log of the IPTS data. For this you need to stop iptsd first, and then run iptsd-dump.

$ sudo systemctl stop $(iptsd-find-service)
$ sudo iptsd-dump $(iptsd-find-hidraw) ipts-log.bin

When iptsd-dump is running, you need to touch the screen a few times. There won't be any inputs generated, so unfortunately it is hard to see if ghost touches are actually appearing. If you have a reliable way to reproduce them, that would be great. Otherwise just leave it running for like a minute and do stuff on the display. Maybe it helps that my SB2 usually generates a bunch of garbage data if I put all fingers on the display and move them around.

Once you have enough data, stop the iptsd-dump program with Ctrl-C and upload the ipts-log.bin file it generated here. If you want to check if there are actually ghost touches in the data (or if you just want to know what it looks like), you can use iptsd-plot to generate images for every data frame.

$ iptsd-plot ipts-log.bin out

You can either go through the images one by one, or you can play them as a video.

$ ffplay out/%05d.png

Here's the log: ipts-log.txt Also it turns out that iptsd wasn't enabled and when enabled it starts going insane again.

StollD commented 1 year ago

Sorry but you need to upload the binary file that is created when running the commands I posted, NOT what iptsd-dump outputs to the terminal.

Gordon3002 commented 1 year ago

Sorry, I didn't know where it dumped it and assumed that what it put out in terminal would be the same. With a quick search in the file manager I found it, here's the google drive link since it won't let me upload it directly: https://drive.google.com/file/d/1zEGRlkrXDOOYQmfde3L4uM4ZkrDJrxz6/view?usp=sharing

Gordon3002 commented 1 year ago

I edited the wiki with the updated instructions for anyone who might need it, here's the link: https://github.com/linux-surface/linux-surface/wiki/Surface-Pro-4

this new config doesn't work. did you just remove all # from the new default config? i think this makes no sense.

This is my config (works in x11 and wayland, single and multitouch and pen):

/etc/iptsd.conf 
[Config]
##
## The following values are device specific and will be loaded from /usr/share/iptsd
## Only set them if you need to provide custom values for new devices that are not yet supported
##
TouchTreshold = 50
StabilityTreshold = 0.55
# InvertX = false
# InvertY = false
# Width = 0
# Height = 0

[Touch]
##
## Mark contacts around the stylus as palms.
##
# CheckCone = true

##
## Skip contacts that are not marked as stable.
## Contacts are unstable if their size or position is changing rapidly.
##
CheckStability = true

##
## Ignore all touch inputs if a palm was registered on the display.
##
DisableOnPalm = false

##
## Ignore all touch inputs if a stylus is in proximity.
##
DisableOnStylus = false

[Contacts]
##
## The blob detection method that will be used.
## Basic should give a good overall experience.
## Advanced might offer better finger detection, but will use vastly more resources.
##
Detection = advanced

##
## The temporal window for determining temporal stability of a contact.
## A contact that has not been active for the specified amount of frames is skipped.
##
TemporalWindow = 5

##
## The minimal diameter a contact must have.
##
SizeMin = 0.3

##
## The maximal diameter a contact can have.
##
# SizeMax = 2.0

##
## The minimal aspect ratio a contact must have.
##
# AspectMin = 1.0

##
## The maximal aspect ratio a contact can have.
##
# AspectMax = 2.5

##
## How many centimeters a contact can increase in size to be considered stable.
##
# SizeThreshold = 0.1

##
## How many centimeters a contact must move before the movement is considered stable.
## Movements below this threshold are ignored.
##
# PositionThresholdMin = 0.2

##
## How many centimeters a contact can move before the movement is considered unstable.
## Movements above this threshold are ignored.
##
# PositionThresholdMax = 2

##
## How many centimeters a contact has to be away from a palm to not get marked as a palm too.
##
# DistanceThreshold = 1

[Cone]
##
## The wideness of the cone in degrees.
##
# Angle = 30

##
## How many centimeters a contact must be away from the stylus to not get blocked.
##
# Distance = 5

[DFT]
# PositionMinAmp = 50
# PositionMinMag = 2000
# PositionExp = -0.7
# ButtonMinMag = 1000
# FreqMinMag = 10000

I tried this config, but it doesn’t seem to work, I still get ghost touches. And yeah what I wrote in the wiki is useless because it turns out that iptsd wasn’t working and what was actually making single touches work was the driver integrated in the kernel. When I applied the config you gave me in the beginning of this thread, in the older version of iptsd, multitouch was actually working however the touch input was imprecise and could not detect a straight line, more like a line of dots.

Gordon3002 commented 1 year ago

Quoting from the wiki

Once done the touchscreen should be working correctly minus multitouch

That is weird, because the only way to not have multitouch is if iptsd is not running. Could you make sure it is? ps aux | grep iptsd, or check if the pen works. Or do you mean multitouch in applications? For that you probably need Wayland.

The commands above are already edited but in your case you'll need to change these: change the 'Detection' command to = advanced, the 'TemporalWindow' to = 5 and the 'SizeMin' to = 0.3.

You can put partial configs into /etc/iptsd.d, that way you could provide only the values that are actually needed.

Increasing the temporal window is a good idea against ghost touches, but instead of always increasing SizeMin, you should calibrate iptsd: https://github.com/linux-surface/iptsd/wiki/Calibrating-iptsd

Also, if you are experiencing ghost touches, I would appreciate if you could get me a binary log of the IPTS data. For this you need to stop iptsd first, and then run iptsd-dump.

$ sudo systemctl stop $(iptsd-find-service)
$ sudo iptsd-dump $(iptsd-find-hidraw) ipts-log.bin

When iptsd-dump is running, you need to touch the screen a few times. There won't be any inputs generated, so unfortunately it is hard to see if ghost touches are actually appearing. If you have a reliable way to reproduce them, that would be great. Otherwise just leave it running for like a minute and do stuff on the display. Maybe it helps that my SB2 usually generates a bunch of garbage data if I put all fingers on the display and move them around.

Once you have enough data, stop the iptsd-dump program with Ctrl-C and upload the ipts-log.bin file it generated here. If you want to check if there are actually ghost touches in the data (or if you just want to know what it looks like), you can use iptsd-plot to generate images for every data frame.

$ iptsd-plot ipts-log.bin out

You can either go through the images one by one, or you can play them as a video.

$ ffplay out/%05d.png

I also tried calibrating it, but if anything it made things worse.

StollD commented 1 year ago

So, this is how one frame from your binary log looks like, when nothing seems to be touching the screen:

00890

For comparison, this is one frame from SB2:

00060

Out of curiosity, have you ever opened your SP4? I wonder if this is damage (either accidental or just from age), or if SP4's are just built badly.

Anyways, I played around with the data a bit. This is what iptsd generates if all settings are left as the default. Green means normal input, red means that the contact was detected as a palm, and yellow means the contact is not stable and will be ignored until it is stable.

sp4-basic.webm

There is a magic value in the blob detector that is somewhat related to the old TouchThreshold, so if I increase that a bit, the result improves a lot. But if you look closely, some of the actual touches will now fail to register properly, especially during motion.

sp4-basic-tweaked.webm

If I enable the advanced touch processor from @qzed, the result improves even more. As far as I can tell, there are no ghost inputs, just some slight inaccuracies with the actual ones when they are in areas with lots of noise.

sp4-advanced.webm

So yeah, I dont know why it didnt work for you, but maybe you could try the advanced option again? e.g. restore /etc/iptsd.conf to default values (comment out everything) and put this into /etc/iptsd.d/10-advanced.conf:

[Contacts]
Detection = advanced
StollD commented 1 year ago

I have also noticed, that some contacts are detected with values that result in a NAN value later. I dont know how the linux input system reacts to NAN values, so I dont know if these can be responsible for ghost touches. For the plots above I created a patch that ignores these contacts, so I will try to apply the same change to the entire daemon.

EDIT: NAN values only happen with basic touch processing, not with advanced.

tpw2033 commented 1 year ago

Possibly related to the ghost touches, I am seeing some dead spots on the touchscreen on Fedora that I did not have on Windows. Changing the touch sensitivity value in iptsd.conf did not fix the problem for me.

StollD commented 1 year ago

Changing the touch sensitivity value in iptsd.conf did not fix the problem for me.

Because that option does not exist anymore. Only the values that are commented out in the default config are read by iptsd.

It is possible that dead spots occur because of the noise and these "streaking" artifacts that you can see in the data from @Gordon3002. If iptsd is too sensitive, then it will process the noise, if its less sensitive, it won't process the noise, but it also will ignore light touches or touches that are in noisy areas. There isnt really anything we can do about that.

What blob detection are you using, basic or advanced? The advanced one is more sensitive, and uses some statistical analysis to only process contacts that look like a finger (I think, I dont know that part of the code very well, I guess @qzed could say more). This means its less affected by noise, but it can discard inputs if the touch is too soft, in a noisy area, or your finger doesnt look like what it is tuned for. This also means that the calibration options dont have much effect on it.

The basic one has the opposite problem: It deliberately detects too much, so that it can be filtered later using the calibration options. But that approach is also much more sensitive to noise.

In any case you should try the calibration process and see if that improves something. If it doesnt you can always remove the options again. You can also try iptsd-show to see what iptsd actually sees in those dead zones.

$ sudo systemctl stop $(iptsd-find-service)
$ sudo iptsd-show $(iptsd-find-hidraw)
StollD commented 1 year ago

I readded configuration options that control the touch detection thresholds to iptsd, so if someone feels in the mood to tweak them for the more noisy touchscreen on the SP4, feel free to have a go at it.

There are prebuilt versions with that change available here (scroll down and download -latest): https://github.com/linux-surface/iptsd/actions/runs/4128485749

The new values are explained here: https://github.com/linux-surface/iptsd/blob/master/etc/iptsd.conf#L41-L73

For reference (really, you should not use this), this config would configure the blob detection to work roughly like the old iptsd:

[Contacts]
Neutral = average
ActivationThreshold = 10
DeactivationThreshold = 10
Cyborgscode commented 1 year ago

Working for Pro 4:

[Config]
# BlockOnPalm = false
TouchThreshold = 50
StabilityThreshold = 0.55

[Touch]
CheckStability = true
DisableOnPalm = true
DisableOnStylus = false

[Contacts]
Detection = advanced

TemporalWindow = 5

SizeMin = 0.3

[Cone]

[DFT]
1701 commented 1 year ago

Working for Pro 4:


[Config]
# BlockOnPalm = false
TouchThreshold = 50
StabilityThreshold = 0.55
...

@StollD I thought that these parameters are no longer supported?

StollD commented 1 year ago

That is correct. As far as iptsd is concerned, the config looks like this:

[Touch]
CheckStability = true
DisableOnPalm = true
DisableOnStylus = false

[Contacts]
Detection = advanced
TemporalWindow = 5
SizeMin = 0.3
Cyborgscode commented 1 year ago

let me test this on my pro4 and i report about the result, if it does not work as you expect it to.

Cyborgscode commented 1 year ago

Confirmed: works without those two:


# TouchThreshold = 50
# StabilityThreshold = 0.55
1701 commented 1 year ago

I can confirm that I have no ghost touches with this configuration.

However, my CPU goes up to 100% immediately when I touch the display.

Touch inputs are extremely delayed. With the stylus, on the other hand, it works very well.

I use Fedora 37 with the following config parameters:

[Touch]
CheckStability = true
DisableOnPalm = true
DisableOnStylus = false

[Contacts]
Detection = advanced
TemporalWindow = 5
SizeMin = 0.3

Anyone else with the same problem? Touch has worked fine under Fedora before. I have no idea what could have led to this behaviour.

qzed commented 1 year ago

Touch has worked fine under Fedora before. I have no idea what could have led to this behaviour.

Generally, those touches are caused by the sensor receiving a lot of noise. So there's not really any underlying software issue (other than that we need to improve our processing to deal with that kind of noise). I wouldn't really spend too much time thinking about why this happens (it just happens and it's a thing that we need to deal with).

I can confirm that I have no ghost touches with this configuration.

However, my CPU goes up to 100% immediately when I touch the display.

Touch inputs are extremely delayed.

The problem is that the "advanced" processing is quite heavy on resources. Especially, if there are a lot of "touch candidates" around, which in this case are likely caused by the sensor noise. While it's a bit better at dealing with such noise, performance/resource usage is the big downside of it. I think it's quite plausible that it takes too much time to process, which in turn delays the touch input.

Cyborgscode commented 1 year ago

Confirmed:

923 root 20 0 8216 5604 4544 R 77,4 0,1 10:07.02 /usr/bin/iptsd /dev/hidraw1

It varies between 70 and > 100%

Cyborgscode commented 1 year ago

After a restart it fluctuates around 40%, no matter if a real touch event is done or not.

Cyborgscode commented 1 year ago

now, 10 minutes later and no external changes to the system, it hovers around 70%. % is increasing over time..

I now see ghosttouches happening A LOT.

Cyborgscode commented 1 year ago

If you believe it or not:

After reactivating

TouchThreshold = 50
StabilityThreshold = 0.55

and restarting the daemon, NO CPU usage and NO GhOSTTOUCHES are happening. Of course i restarted it without the two lines above, and it consumed cpu immediatly. Now, with them, it works like a charm again.

After some restarts this came up:

Feb 24 14:36:21 surface.resellerdesktop.de systemd[1]: Started iptsd@dev-hidraw1.service - Intel Precise Touch & Stylus Daemon. Feb 24 14:36:21 surface.resellerdesktop.de systemd[1]: iptsd@dev-hidraw1.service: Main process exited, code=exited, status=1/FAILURE Feb 24 14:36:21 surface.resellerdesktop.de iptsd[59234]: [14:36:21.078] [info] Connected to device 1B96:006A Feb 24 14:36:21 surface.resellerdesktop.de iptsd[59234]: [14:36:21.103] [error] Failed to set feature: Bad address

and no iptsd is startable anymore.

Cyborgscode commented 1 year ago

rebooting to newest surface kernel and the bugs continue... with the two lines aboove inside:

[ +0,113842] ipts 0000:00:16.4-3e8d0870-271a-4208-8eb5-9acb9402ae04: Starting IPTS [ +0,011336] ipts 0000:00:16.4-3e8d0870-271a-4208-8eb5-9acb9402ae04: IPTS EDS Version: 1 [ +0,006634] ipts 0000:00:16.4-3e8d0870-271a-4208-8eb5-9acb9402ae04: IPTS running in doorbell mode

but:

# systemctl status iptsd@dev-hidraw1.service 
○ iptsd@dev-hidraw1.service - Intel Precise Touch & Stylus Daemon
     Loaded: loaded (/usr/lib/systemd/system/iptsd@.service; static)
     Active: inactive (dead)
       Docs: https://github.com/linux-surface/iptsd

Feb 24 14:38:19 surface.resellerdesktop.de systemd[1]: Started iptsd@dev-hidraw1.service - Intel Precise Touch & Stylus Daemon.
Feb 24 14:38:19 surface.resellerdesktop.de systemd[1]: Stopping iptsd@dev-hidraw1.service - Intel Precise Touch & Stylus Daemon...
Feb 24 14:38:19 surface.resellerdesktop.de systemd[1]: iptsd@dev-hidraw1.service: Deactivated successfully.
Feb 24 14:38:19 surface.resellerdesktop.de systemd[1]: Stopped iptsd@dev-hidraw1.service - Intel Precise Touch & Stylus Daemon.
Feb 24 14:38:39 surface.resellerdesktop.de systemd[1]: Started iptsd@dev-hidraw1.service - Intel Precise Touch & Stylus Daemon.
Feb 24 14:38:39 surface.resellerdesktop.de systemd[1]: Stopping iptsd@dev-hidraw1.service - Intel Precise Touch & Stylus Daemon...
Feb 24 14:38:39 surface.resellerdesktop.de systemd[1]: iptsd@dev-hidraw1.service: Deactivated successfully.
Feb 24 14:38:39 surface.resellerdesktop.de systemd[1]: Stopped iptsd@dev-hidraw1.service - Intel Precise Touch & Stylus Daemon.

BUT it's actually running:

# pstree -up | grep ipt
           |-iptsd(965)

Something is not working the way we would expect it too ;)

NOTE: NO increased cpu activity by the daemon in this mode, and fully functional touch support.

1701 commented 1 year ago

hmm... i can confirm some strange new behaviour:

the system works now without advanced detection: --> no ghost touches, no cpu load

StollD commented 1 year ago

Something is not working the way we would expect it too ;)

Always use iptsd-find-service to get the service name, the number of the hidraw device is not stable.

$ sudo systemctl status $(iptsd-find-service)

CPU load will only come when there are inputs. IPTS is smart enough to send no data if there is no finger on the screen, most of the time. But when a finger touches the screen, that data will contain a lot of noise. So if you are not touching the screen, or the hardware is not seeing very strong noise, there will be no CPU usage.

Restarting iptsd will also issue a reset command to the sensor, which has fixed noisy data in the past. So either that influences the behaviour on your devices, or the ghosts have migrated from the touches straight into iptsd and it is reading config values without any code to read them. ;)

Cyborgscode commented 1 year ago

CPU load will only come when there are inputs. IPTS is smart enough to send no data if there is no finger on the screen, most of the time. But when a finger touches the screen, that data will contain a lot of noise. So if you are not touching the screen, or the hardware is not seeing very strong noise, there will be no CPU usage.

As i wrote, there were no user generated touches, but a lot of cpu usage, which increased over time. Now, with the two config options back inside, there is no cpu usage again, as it should be.

StollD commented 1 year ago

I have been working on some major changes to iptsd, and I think that one part of these changes has the potential to improve the behaviour on SP4 massively.

The issue of the basic touch detection algorithm is essentially, that it is very dependent on low thresholds. If you increase the thresholds, the ellipses detected by the algorithm will get smaller and smaller. This then causes some other issues, like contacts being dropped for no reason, or regarded as a palm because they have a weird aspect ratio.

The low thresholds work fine on a device like SB2 where there is no noise, but on noisy devices, that apporach obviously fails.

The advanced algorithm handles this better by using gaussian fitting to extract the contact ellipses. But it suffers from a less than efficient method for finding the areas where the gaussian fitting should be applied.

By combining the simple recursive cluster search from the basic algorithm, and the gaussian fitting from the advanced one, I was able to create a pretty efficient algorithm that allows raising the default thresholds significantly, without decreasing the size of the final contact ellipse - with very acceptable CPU usage.

With the data that was posted above, this then looks like this:

SP4_new_slow.webm


I would really appreciate if you could give this new code a try and report how it works for you. Once the build has finished, you will be able to get compiled packages here: https://github.com/linux-surface/iptsd/actions/runs/4482485134, if you want to build it yourself, the code is in the eigen-and-more branch of iptsd.

If you decide to try it out, please first save your old config and revert it to the default one. You shouldn't have to tweak the thresholds much, but you should definitly calibrate iptsd first after installing the new version, since I did not update these values yet, so palm detection might be inaccurate out of the box: https://github.com/linux-surface/iptsd/wiki/Calibrating-iptsd

SeongGino commented 1 year ago

A little late to respond, but I have been using the Arch package provided in the eigen-and-more branch builds for about a day on my SP4. Out-of-the-box and without old configs, it's perfectly responsive and hasn't been prone to interference/ghost touches over multiple boots or sleep/wake cycles like the current iptsd binaries; both with single touch/drags and multitouch gestures. Without a calibration configuration, palm detection seems to work okay, reasonably well enough for normal use. Seems about the same after calibration, and copying the file to /etc/iptsd.d/90-calibration.conf as the tool suggests.

Just a quick glance at KSysGuard, the touch process seems to only use ~3% CPU while recognizing touches, highest being a blip to 5%, on the i5 model running Plasma.

ttsmit commented 1 year ago

I have tested arch package from the eigen-and-more branch as well, good results. iptsd using about 3.5% CPU, _iptsdoorbel using about 10% CPU. I'm running Manjaro on as SP4 with Intel Core i5.

ipts-log.zip

StollD commented 1 year ago

FYI, this code is now released as iptsd 1.2.0

wb14123 commented 2 weeks ago

I'm stilling getting ghost touches with newest iptsd. The version is iptsd 2-1 on Archlinux. I'm wondering if it's the version that has the fix?

wb14123 commented 2 weeks ago

The wiki https://github.com/linux-surface/linux-surface/wiki/Surface-Pro-4 is last updated at Feb 2023, so I'm not sure if the fix is up to date with the newest version. But I've tried all the workarounds in the wiki and this issue and it doesn't help. @StollD Please let me know if you need more information about my setup.