markqvist / Sideband

LXMF client for Android, Linux and macOS allowing you to communicate with people or LXMF-compatible systems over Reticulum networks using LoRa, Packet Radio, WiFi, I2P, or anything else Reticulum supports.
Other
391 stars 27 forks source link

Touchpad inputs are treated as touchscreen inputs on Linux under some unknown conditions #54

Open felurx opened 3 months ago

felurx commented 3 months ago

Describe the Bug Sideband or Kivy seem to partially treat inputs from a touchpad as if they were coming from a touchscreen on my system, which results in the GUI being pretty much unusable via touchpad.

For example, moving a finger up and down on a scrollable view results in its contents moving up and down (instead of just moving the mouse pointer). Also, tapping on the touchpad seems to sometimes click on things corresponding to where the touchpad was tapped, instead of where the mouse pointer is. There is a screencast below.

Using a regular mouse works fine, even without closing and reopening Sideband.

To Reproduce I don't know which pieces of my system cause the bug to surface. A possible starting point might be to live-boot Manjaro with KDE from a USB stick on a laptop and install Sideband on that (via pipx). After that, just opening Sideband and using the touchpad should be enough to see the bug in action.

Expected Behavior Sideband should treat touchpads like other mouse input devices.

Logs & Screenshots

Sideband log file with -v

``` [INFO ] Logger: Record log in /home/felix/.kivy/logs/kivy_24-08-17_4.txt [INFO ] Kivy: v2.3.0 [INFO ] Kivy: Installed at "/home/felix/.local/share/pipx/venvs/sbapp/lib/python3.12/site-packages/kivy/__init__.py" [INFO ] Python: v3.12.4 (main, Jun 7 2024, 06:33:07) [GCC 14.1.1 20240522] [INFO ] Python: Interpreter at "/home/felix/.local/share/pipx/venvs/sbapp/bin/python" [INFO ] Logger: Purge log fired. Processing... [INFO ] Logger: Purge finished! [INFO ] KivyMD: 1.2.0.dev0 (installed at "/home/felix/.local/share/pipx/venvs/sbapp/lib/python3.12/site-packages/sbapp/kivymd/__init__.py") [INFO ] Factory: 195 symbols loaded [DEBUG ] Cache: register with limit=None, timeout=60 [DEBUG ] Cache: register with limit=None, timeout=60 [DEBUG ] Cache: register with limit=None, timeout=None [INFO ] ImageLoaderFFPy: Using ffpyplayer 4.5.1 [INFO ] Image: Providers: img_tex, img_dds, img_sdl2, img_pil, img_ffpyplayer [DEBUG ] Cache: register with limit=1000, timeout=60 [DEBUG ] Cache: register with limit=1000, timeout=3600 [DEBUG ] Cache: register with limit=None, timeout=None [INFO ] Text: Provider: sdl2 [DEBUG ] Cache: register with limit=None, timeout=None [INFO ] Window: Provider: sdl2 [INFO ] GL: Using the "OpenGL" graphics system [INFO ] GL: Backend used [INFO ] GL: OpenGL version [INFO ] GL: OpenGL vendor [INFO ] GL: OpenGL renderer [INFO ] GL: OpenGL parsed version: 4, 6 [INFO ] GL: Shading version [INFO ] GL: Texture max size <16384> [INFO ] GL: Texture max units <32> [DEBUG ] Shader: Fragment compiled successfully [DEBUG ] Shader: Vertex compiled successfully [DEBUG ] ImageSDL2: Load [INFO ] Window: auto add sdl2 input provider [INFO ] Window: virtual keyboard not allowed, single mode, not docked [INFO ] Clipboard: Provider: xclip [INFO ] CutBuffer: cut buffer support enabled [INFO ] SoundFFPy: Using ffpyplayer 4.5.1 [DEBUG ] Audio: register SoundFFPy [DEBUG ] Audio: register SoundSDL2 [DEBUG ] Audio: register MusicSDL2 [INFO ] Audio: Providers: audio_ffpyplayer, audio_sdl2 [DEBUG ] Cache: register with limit=None, timeout=60.0 [DEBUG ] Cache: register with limit=None, timeout=60.0 [DEBUG ] App: Loading kv [DEBUG ] App: kv not found [DEBUG ] Resource: add in path list [DEBUG ] Resource: add in path list [DEBUG ] Resource: add in path list [DEBUG ] Resource: add in path list [DEBUG ] Resource: add in path list [DEBUG ] Resource: add in path list [DEBUG ] Resource: add in path list [DEBUG ] Resource: add in path list [DEBUG ] Resource: add in path list [DEBUG ] Resource: add in path list [DEBUG ] Resource: add in path list [DEBUG ] Resource: add in path list [DEBUG ] Resource: add in path list [DEBUG ] Resource: add in path list [DEBUG ] Resource: add in path list [DEBUG ] Resource: add in path list [DEBUG ] Resource: add in path list [DEBUG ] Shader: Fragment compiled successfully [INFO ] GL: NPOT texture support is available [DEBUG ] Base: Create provider from mouse,disable_multitouch [DEBUG ] Base: Create provider from probesysfs [DEBUG ] ProbeSysfs: using probesysfs! [DEBUG ] ProbeSysfs: found device: Wacom Bamboo 16FG 4x5 Finger at /dev/input/event9 [INFO ] ProbeSysfs: device match: /dev/input/event9 [INFO ] MTD: Read event from [DEBUG ] ProbeSysfs: found device: PIXA3854:00 093A:0274 Touchpad at /dev/input/event18 [INFO ] ProbeSysfs: device match: /dev/input/event18 [INFO ] MTD: Read event from [INFO ] Base: Start application main loop [INFO ] MTD: range position X is 0 - 4096 [INFO ] MTD: range position X is 0 - 1337 [INFO ] MTD: range position Y is 0 - 4096 [INFO ] MTD: range position Y is 0 - 876 [INFO ] MTD: range touch major is 0 - 4096 [INFO ] MTD: range touch major is 0 - 0 [INFO ] MTD: range touch minor is 0 - 4096 [INFO ] MTD: range touch minor is 0 - 0 [INFO ] MTD: range pressure is 0 - 255 [INFO ] MTD: range pressure is 0 - 255 [INFO ] MTD: axes inversion: X is 0, Y is 0 [INFO ] MTD: axes inversion: X is 0, Y is 0 [INFO ] MTD: rotation set to 0 [INFO ] MTD: rotation set to 0 [DEBUG ] Atlas: Load [DEBUG ] Atlas: Need to load 1 images [DEBUG ] Atlas: Load [WARNING] Deprecated property "" of object "" has been set, it will be removed in a future version [INFO ] Base: Leaving application in progress... ```

Screencast_20240817_124228.webm The window on the right is the libinput debug-gui, in which the blue rectangle shows touchpad inputs. The blue circle always shows the last finger position, the number 0 means that a finger is currently on the touchpad.

System Information

Additional context

libinput list-devices

I removed irrelevant devices. ``` Device: Wacom Bamboo 16FG 4x5 Pen Kernel: /dev/input/event6 Group: 5 Seat: seat0, default Size: 147x92mm Capabilities: tablet Tap-to-click: n/a Tap-and-drag: n/a Tap drag lock: n/a Left-handed: disabled Nat.scrolling: n/a Middle emulation: n/a Calibration: n/a Scroll methods: none Click methods: none Disable-w-typing: n/a Disable-w-trackpointing: n/a Accel profiles: none Rotation: n/a Device: Wacom Bamboo 16FG 4x5 Finger Kernel: /dev/input/event9 Group: 5 Seat: seat0, default Size: 146x91mm Capabilities: pointer gesture Tap-to-click: enabled Tap-and-drag: enabled Tap drag lock: disabled Left-handed: disabled Nat.scrolling: disabled Middle emulation: n/a Calibration: n/a Scroll methods: *two-finger edge Click methods: none Disable-w-typing: n/a Disable-w-trackpointing: n/a Accel profiles: flat *adaptive custom Rotation: n/a Device: Wacom Bamboo 16FG 4x5 Pad Kernel: /dev/input/event10 Group: 5 Seat: seat0, default Capabilities: tablet-pad Tap-to-click: n/a Tap-and-drag: n/a Tap drag lock: n/a Left-handed: disabled Nat.scrolling: n/a Middle emulation: n/a Calibration: n/a Scroll methods: none Click methods: none Disable-w-typing: n/a Disable-w-trackpointing: n/a Accel profiles: n/a Rotation: n/a Pad: Rings: 0 Strips: 0 Buttons: 4 Mode groups: 1 (1 modes) Device: PIXA3854:00 093A:0274 Mouse Kernel: /dev/input/event17 Group: 9 Seat: seat0, default Capabilities: pointer Tap-to-click: n/a Tap-and-drag: n/a Tap drag lock: n/a Left-handed: disabled Nat.scrolling: disabled Middle emulation: n/a Calibration: n/a Scroll methods: *button Click methods: none Disable-w-typing: n/a Disable-w-trackpointing: n/a Accel profiles: flat *adaptive custom Rotation: n/a Device: PIXA3854:00 093A:0274 Touchpad Kernel: /dev/input/event18 Group: 9 Seat: seat0, default Size: 111x73mm Capabilities: pointer gesture Tap-to-click: disabled Tap-and-drag: enabled Tap drag lock: disabled Left-handed: disabled Nat.scrolling: disabled Middle emulation: disabled Calibration: n/a Scroll methods: *two-finger edge Click methods: *button-areas clickfinger Disable-w-typing: enabled Disable-w-trackpointing: enabled Accel profiles: flat *adaptive custom Rotation: n/a ```

felurx commented 3 months ago

In Kivy on Linux, multitouch devices (= touchscreens) seem to be handled by kivy.input.providers.mtdev, which in the default config is configured by kivy.input.providers.probesysfs.

This lead me to a workaround: Commenting out line 49 %(name)s = probesysfs under [input] in ~/.kivy/config.ini (which is auto-created by Kivy) disables that behaviour, the touchpads are no longer treated as multitouch devices and everything is fine for me. (This would probably break actual touchscreens, however.)

I'll investigate further, but I suspect that this is a problem with ProbeSysfs' logic for how to detect touchscreens and should be fixed upstream in Kivy. Or does Sideband do anything unusual regarding input devices?


EDIT: This matches with the following lines in the log I posted, which I think are ProbeSysfs recognizing the touchpads as touchscreens and configuring them:

Log snippet

``` [DEBUG ] Base: Create provider from mouse,disable_multitouch [DEBUG ] Base: Create provider from probesysfs [DEBUG ] ProbeSysfs: using probesysfs! [DEBUG ] ProbeSysfs: found device: Wacom Bamboo 16FG 4x5 Finger at /dev/input/event9 [INFO ] ProbeSysfs: device match: /dev/input/event9 [INFO ] MTD: Read event from [DEBUG ] ProbeSysfs: found device: PIXA3854:00 093A:0274 Touchpad at /dev/input/event18 [INFO ] ProbeSysfs: device match: /dev/input/event18 [INFO ] MTD: Read event from [INFO ] Base: Start application main loop [INFO ] MTD: range position X is 0 - 4096 [INFO ] MTD: range position X is 0 - 1337 [INFO ] MTD: range position Y is 0 - 4096 [INFO ] MTD: range position Y is 0 - 876 [INFO ] MTD: range touch major is 0 - 4096 [INFO ] MTD: range touch major is 0 - 0 [INFO ] MTD: range touch minor is 0 - 4096 [INFO ] MTD: range touch minor is 0 - 0 [INFO ] MTD: range pressure is 0 - 255 [INFO ] MTD: range pressure is 0 - 255 [INFO ] MTD: axes inversion: X is 0, Y is 0 [INFO ] MTD: axes inversion: X is 0, Y is 0 [INFO ] MTD: rotation set to 0 [INFO ] MTD: rotation set to 0 ```

felurx commented 3 months ago

To be more precise and correct: The term "multitouch device" seems to apply to all devices that can track multiple touch points, which includes both touchscreens and touchpads. Also, both have the properties that ProbeSysfs checks for.

The problem seems to be that all multitouch devices are treated as touchscreens, where device coordinates map to screen coordinates somehow and a contact moving corresponds to the user dragging UI elements. Touchpads should probably just be ignored, since Kivy already deals with mouse events just fine and the OS does everything to create these from touchpad input.

I don't know where that conflation of touchscreens and touchpads happens and how it should be fixed. Also, the question remains why this didn't cause any trouble for other users.

markqvist commented 3 months ago

Thanks for collecting all the information and posting detailed logs and info. I agree with your observations and initial conclusions here. Unfortunately, Sideband doesn't do anything non-standard in regards to input, so this may be an issue that has it's root in Kivy itself. Regardless, we'll need to find some sort of tenable workaround as well, until it can be identified and potentially fixed in Kivy.

I'll start looking into this, and seeing if I can track down where the issue might occur exactly, but it might be hard for me to debug, since I doubt I have any hardware where I can replicate. Therefore, any additional information and input you can come up with in the meantime is highly appreciated!