libretro / RetroArch

Cross-platform, sophisticated frontend for the libretro API. Licensed GPLv3.
http://www.libretro.com
GNU General Public License v3.0
10.28k stars 1.83k forks source link

Linux/Wayland-Native - Multi mouse support #16886

Open SeongGino opened 2 months ago

SeongGino commented 2 months ago

Description

On Linux in a native Wayland session (simply running retroarch) with any input plugin (so udev or wayland), RetroArch does not seem able to support multiple mice - furthermore, trying to use any pointer device (whether it be absolute positioning lightgun or normal relative mouse) will not move the point of aim/aiming reticle in lightgun games.

To work around this, running RetroArch in XWayland is needed - in my case, using WAYLAND_DISPLAY="" retroarch forces RA to run in XWayland, and I can have access to a fully functioning udev input driver with multiple mice support.

Mouse Devices list under native Wayland (either udev or wayland input driver): 2024_08-16 124704

Mouse Devices list under XWayland with udev input driver: 2024_08-16 124815

In both examples, a Logitech G502 mouse and an OpenFIRE Lightgun are plugged into the PC, running under a user in the input group.

Expected behavior

At minimum, the ability to use a mouse device in lightgun games on a native Wayland RetroArch session; ideally, udev or wayland input driver should have feature parity with udev driver under X11 with the ability to address and use individual pointer devices for multiplayer.

Actual behavior

No mouse input is allowed in cores in either udev or wayland input drivers on native Wayland RetroArch.

Steps to reproduce the bug

  1. Input driver should be set to udev
  2. Run RetroArch in native a Wayland session (retroarch)
  3. Go to Settings->Input->RetroPad Binds->Port 1 Controls->Mouse Index
  4. Observe there only being a "Default" index, with all 15 other slots being "N/A"
  5. Launch a game in a core that supports Lightguns, e.g. MAME (Current)
  6. Observe how mouse button inputs are being recognized, and the cursor remains exactly in wherever the default position is regardless of mouse input.
  7. Exit, and relaunch RetroArch under XWayland (WAYLAND_DISPLAY="" retroarch)
  8. Repeat step 2
  9. Observe the Mouse Index being populated by multiple devices (if plugged in) with real names.
  10. Repeat step 4
  11. Observe how the in game aiming reticle is affected by input, depending on the mouse index setting.

Bisect Results

N/A (has this always been an issue?)

Version/Commit

Environment information

SeongGino commented 2 months ago

Small correction: XWayland doesn't solve the issue very well either, as the core cursor is disconnected from the system's in a way that isn't normal for regular X11 functionality.

Using Windowed mode just for sake of demonstration with a visible cursor, this still applies in fullscreen--note how MAME's blue aim reticle is nowhere near the system's black cursor. 2024_08-16 215315c In practical terms, I can't aim beyond the bottom-left quadrant of the game screen area without it snapping to offscreen.

gouchi commented 2 months ago

Similar issue for X11 input driver.

zoltanvb commented 2 months ago

I was under the impression that Wayland only supports 1 system-wide cursor, but failed to find a normative reference, instead I ran into a couple of old issues telling that for graphics tablets, there is actually a second cursor.

When graphics context driver is Wayland, input driver will also be forced to Wayland, it cannot be changed to udev (even though it may appear in the menu like that).

SeongGino commented 2 months ago

I was under the impression that Wayland only supports 1 system-wide cursor, but failed to find a normative reference, instead I ran into a couple of old issues telling that for graphics tablets, there is actually a second cursor.

When graphics context driver is Wayland, input driver will also be forced to Wayland, it cannot be changed to udev (even though it may appear in the menu like that).

I'm not particularly well-versed in the differences of the display servers, but where would you say the root cause of the problem is?

Basically, is this at the fault of Wayland itself; and if so, perhaps where would this kind of issue be posted for more constructive resolution? Wayland itself? The Plasma compositor?

And ideally, I'd at least like the XWayland fallback to still work, but not sure if that's also another Wayland-specific issue rather than the fault of RetroArch. For as good as Wayland mostly is elsewhere, lightguns are the single biggest blocker for me at the moment (which makes things no less easier when you're also developing a lightgun system) and RA has been my goto for virtually everything that isn't a Wii, PS2/3, or Windows-based Arcade title.

Now that I think about it, I've noticed in Wine that the behavior with XWayland is incredibly similar - relative mouse input is okay, but any abs/gun coords are ignored. Honestly, the more I've been thinking about this, the more my head's being done in.

(Just to be clear, any frustrations being vented here aren't with RA itself, but more just exasperated at the general state of Wayland for my inconveniently hyper niche usecase)

zoltanvb commented 1 month ago

I found something that may explain the single mouse device better (not sure if it is up to date): https://wayland-book.com/seat.html The lightgun related part of the wayland input driver is scattered with todo's, so there may be some missing parts also on the RetroArch side of the court. https://github.com/libretro/RetroArch/blob/98c79b3f146938a44205418b83793e85af5202b8/input/drivers/wayland_input.c#L365

zoltanvb commented 1 month ago

I have checked it in a bit more detail, I believe it could be improved a bit on the Wayland input driver side, I'll just need to set up some kind of test tooling so that I can reliably verify different scenarios.