linux-surface / iptsd

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

(SP4) Mouse randomly jumps around screen when using touchscreen #40

Open obj-obj opened 3 years ago

obj-obj commented 3 years ago

When placing a finger on the touchscreen and moving it, the mouse jumps around the screen instead of following the finger. Sometimes randomly works like normal, sometimes does this instead. Touchscreen works fine in Windows, so hardware isn't a problem

obj-obj commented 3 years ago

It works more often than not, but still is annoying for the touchscreen to randomly die

obj-obj commented 3 years ago

Switched to wayland and it's not happening anymore, the problem might not even be with iptsd

obj-obj commented 3 years ago

Is now happening again, is there a log I can send?

StollD commented 3 years ago

You can reset the touch sensor with sudo iptsd-sensor-reset. This issue can be caused by faulty auto-calibration of the touchscreen. The command will delete that calibration data and restore the default values. Unfortunately we dont know what format this data is, so iptsd cant supply proper data to the sensor.

obj-obj commented 3 years ago

That command doesn't exist

obj-obj commented 3 years ago

Ran iptsd-reset-sensor, doesn't help

obj-obj commented 3 years ago

Tried a full reinstall, this problem now happens 100% of the time

obj-obj commented 3 years ago

Could someone please tell me the location of the log (if there is one) so I can send it here? I'd like to be able to use my touchscreen lol

Also, touchscreen works in windows & in the built-in keyboard the bios has, so it can't be a touchscreen problem.

NuclearDog commented 3 years ago

Hey, just wanted to chime in that I'm having the same problem on a SP4. This also sounds similar to what's reported in this issue: https://github.com/linux-surface/iptsd/issues/26

Just installed Debian today and the latest packages per the linux-surface instructions (says I ended up with iptsd 0.4-1). Started with minimal Debian install, ran through instructions, then installed sway. Had issues, removed that and installed xorg+i3, same problems.

The pen works flawlessly. Tracks perfectly, pressure sensitivity works, etc. Pen and touch work flawlessly under Windows 10.

Touch is worse than useless for me at the moment. If I touch the screen ten times in the same place, I can get the cursor to hit five different locations on the screen (the other five times the touch just doesn't even seem to register). And not "five locations near the cursor", but tapping the middle of the screen can hit far corners and opposing edges, etc. Pressing and dragging my finger across the screen results in the cursor moving once or twice, and usually nowhere near where my finger is. A single tap can end up highlighting half the text on the screen as it seems to register in one place, then suddenly shoot to another place. I've gotten the odd ghost touch related to the touch driver as well (go away when I xinput disable IPTS Touch).

I tried iptsd-reset-sensor. No change. I tried running ipts-dbg and dragging my finger across the screen and saw a steady stream of data flowing, so despite the cursor not going anywhere when iptsd is running, it seems like the hardware is reporting something.

I tried stopping iptsd via systemd (systemctl stop iptsd) and just running it interactively. The only output is Connected to device 1B96:006A. No error output or anything. I tried disabling BlockOnPalm (don't have many things to fiddle with on my end) and no significant change.

If there's anything at all I can do to help, let me know.

EDIT: Did try building from master. Same issue.

EDIT2: Not sure if this is expected behaviour as I don't have a working device to test against, but I just threw some printf()s into the functions in touch.c. Pressing and holding my finger on the screen in one test got me a lot of calls to iptsd_touch_lift_mt, but no emit. In another test, I got several dozen calls to iptsd_touch_lift_mt with a single iptsd_touch_emit_mt in the middle. So the "I'm touching and nothing is registering" doesn't seem to be all in my head. It's clearly triggering some sort of events, but it's never deciding to actually emit a touch. Logging the touch coordinates in iptsd_touch_emit_mt, I'm seeing incorrect coordinates being emitted for some touches, so I'm pretty sure it's not a "userland" (x/sway/etc) issue.

obj-obj commented 3 years ago

Glad to know it isn’t only me! I should also add that I’m using wayland, although that probably doesn’t affect anything (same thing happens when switching back to X11)

obj-obj commented 3 years ago

Hmm I somehow didn’t see #26 while searching if there was a similar issue

obj-obj commented 3 years ago

New PR got merged, it doesn't seem related to this but I might as well try compiling from source

Edit: It doesn't work, as I thought

i3Craig commented 2 years ago

I noticed a similar issue on my Surface Pro 4. Dragging my finger across the screen resulted in many "dropouts". It was as though I took my finger off the screen (for a very short period of time) and then put it back on many times throughout the drag. This made dragging things across the screen impossible as it would drop whatever I was dragging (window title bar, slider, and so on).

I looked into the code in this repo a bit and found that, for me, whenever my touch dropped out most of the entire touch frame "pixels" went to zero. In the code this frame is referred to as a "heatmap". Essentially, it is a bitmap image of all the touch points on the screen. Thus, I hacked the code some more to block these unwanted (corrupted) frames. I save off the computed touch points on every "good" frame. Then, when a corrupted frame comes around, I restore from this backup. Since the bad frames are usually only one frame long and rare, I don't notice any additional choppiness for touch input. I have included a patch file that should apply my changes to your repo (if you apply the patch). Instructions are below. I also included an animation of a sequence of images I saved off demonstrating the issue. The frames are of the heatmap described earlier. The black frames are the ones that are discarded.

  1. Download the patch and unzip the .patch file (use this below in place of /path/to/patch/file.patch. Patch file: patch.zip

  2. Run the following.

    $ git clone https://github.com/linux-surface/iptsd
    $ cd iptsd
    $ git am /path/to/patch/file.patch
    # (if you haven't used git yet, you will have to run 'git config user.name whatever' and 'git config user.email whatever' to apply the patch (or enter a real name and username if you plan to use this repo).
    # This isn't used for anything other than the local commit created by git.
    $ meson build
    $ ninja -C build
    $ sudo ./build/iptsd

    3, If you already have iptsd installed, you may need to stop it with the following.

    $ sudo systemctl stop iptsd
  3. Run the local version of iptsd:

    $ sudo build/iptsd

Note: if you want to install this, uninstall iptsd:

( arch )
$ sudo pacman -R iptsd

(ubuntu - not tested )
$ sudo apt-get remove iptsd

Then, run sudo ninja -C build install to install.

If you want, give it a try. Let me know if this fixes the issue or not. You may need to adjust the threshold on line 145 in src/touch-processing.c. Basically, if the average of all pixels in the heatmap is less than 15, then I throw the frame out. If the patch does not seem to work, the threshold may need to be increased. Valid values range from 0 to 255. The black frames in the animation usually averaged less than 10, for example, so I picked 15.

Animation of heatmap frames:

https://user-images.githubusercontent.com/70919757/141399698-61a7f504-e37b-461c-838c-73bb5b8d5300.mp4