udev: touchscreen pointer never pressed/released correctly (KMS, UDEV_TOUCH_SUPPORT)

オープン
#20,060 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
72/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
c, linux

調査の方向性

Start with the three reported locations in input/drivers/udev_input.c: pointer button state around line 2393, pointer state reporting around lines 3037-3041, and touch event handling around lines 2659-2729. Trace how touch contacts update pointer state and MT slots, then reproduce with the issue’s udev touchscreen setup. Done means taps register, pointer state follows contact press and release, and multi-touch scrolling produces no phantom releases.

索引モデルが issue の本文から書いたものです。

説明

Is there an existing issue for this?
  • This is a bug in RetroArch frontend
  • I have searched the existing issues
Description

With the udev input driver built with -DUDEV_TOUCH_SUPPORT, taps on a touchscreen do nothing in the menu. I found three bugs in input/drivers/udev_input.c. All three are still in master (49582a9, line numbers below are from that commit).

1. The simulated pointer is reported pressed after release (line 2393)

/* Release the pointer only after all contacts are released */
if (touch->pointer_enabled)
   touch->pointer_btn_pp = (touch->staging_active == 0);

staging_active has already been decremented here, so the condition is inverted: the pointer is pressed after the last finger is lifted and released while a finger is still down. The menu acts on release, so taps never register. Fix: (touch->staging_active > 0).

2. udev_input_touch_state() always returns 0 for the pointer (lines 3037-3041)

case RETRO_DEVICE_POINTER:
case RARCH_DEVICE_POINTER_SCREEN:
   screen = (device == RARCH_DEVICE_MOUSE_SCREEN);
   break;
   switch (id)

The stray break leaves before switch (id), so pointer X/Y/pressed are never reported. The comparison also uses RARCH_DEVICE_MOUSE_SCREEN instead of RARCH_DEVICE_POINTER_SCREEN. Fix: remove the break and compare with RARCH_DEVICE_POINTER_SCREEN.

3. Single-touch emulation is mixed into MT slot 0 (ABS_X line 2659, ABS_Y around line 2683, BTN_TOUCH line 2729)

For multi-touch devices the kernel also sends single-touch emulation (ABS_X, ABS_Y, BTN_TOUCH) that follows the oldest active contact. The code writes it into slot 0 (BTN_TOUCH even into the current slot) on top of the MT slot data. When a second contact outlives the first one, the emulation jumps to it: slot 0 gets that position and a second touch up, the log shows Cannot report touch up since there are no active points. and the menu sees phantom releases and taps while scrolling. The MT slots carry the same data, so the fix is to skip these three events when the device has MT slots:

if (touch->info_slots.enabled && touch->info_slots.range > 1)
   break;

Single-touch devices (no ABS_MT_SLOT) are not affected by this change.

Bugs 1 and 2 seem to date back to the touch rewrite in #15282 (2023).

Side note: nothing in the build system defines UDEV_TOUCH_SUPPORT (configure, Makefile.common), so distribution builds have no touchscreen support in udev at all. Maybe it could become a configure option once these bugs are fixed.

I have patches against v1.20.0 tested on hardware and can open a PR against master if that helps:
https://github.com/cyryllo/banana-a20/tree/arkada20-v1.0-trixie-6.18.62/armbian-build/konsola/latki-retroarch (0001, 0002, 0007)

Expected behavior

A tap selects a menu entry, the pointer is pressed while a finger is down and released when the last finger is lifted.

Steps to reproduce the bug
  1. Build RetroArch for Linux with KMS and udev, CFLAGS=-DUDEV_TOUCH_SUPPORT.
  2. Run it on a device with a multi-touch touchscreen (evdev with ABS_MT_SLOT), input_driver = "udev", menu_pointer_enable = "true", input_touch_vmouse_pointer = "true".
  3. Tap a menu entry: nothing happens. With 1 and 2 fixed, taps work, but with two contacts the menu gets phantom releases (bug 3).
Version/Commit

1.20.0 (built from the v1.20.0 tag). The same code is in master 49582a9.

Bisect Results

Probably since #15282 (2023), not bisected.

Present in the nightly version

I don't know

Platform & operating system

Linux armhf, Debian 13 (Armbian), kernel 6.18.62, LeMaker Banana Pro (Allwinner A20)

Affected Cores

None (menu)

Environment information

KMS + EGL + OpenGL ES 2 (Mesa lima, Mali-400), udev input, no X11/Wayland. Touchscreen: FocalTech FT5x06 (edt-ft5x06 driver), 1024x600, multi-touch with slots.

Relevant log output
`[udev] Cannot report touch up since there are no active points.` (bug 3)
主要言語
C
スター
14.6k
フォーク
2.4k
平均マージ
2日 3時間
マージ済み PR(30日)
64

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

libretro/RetroArch のほかの issue

libretro/RetroArch の issue をすべて見る

似ている issue

C の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。