libretro / RetroArch

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

[Feature request] global raw mice and/or joystick axis mapping support for lightguns (with all supported cores) #12024

Open JayBee-git opened 3 years ago

JayBee-git commented 3 years ago

First and foremost consider this:

Description

RA is missing a global universal lightgun input support that works with 2 players and on all aspect ratio.

Expected behavior

With either raw mice or joystick axes mapping on the gun axes, we should be able to use 2 lightguns at the same time on any core that support it, the same wait we can currently map global controller mapping. The aiming area should also be limited to the game video area for the aiming and offscreen reload to work correctly.

Actual behavior

For lightguns that support mouse and joystick axis inputs (with absolute coordinates positioning), 2 player mode currently isn't supported, and the mouse range onscreen is incorrect for 4:3 games on 16:9 screens, making offscreen reload not working correctly.

Steps to reproduce the bug

  1. Plug 2 lightguns
  2. Start any core that supports lightguns
  3. Activate the lightgun support and assignment in the core options and restart if needed
  4. Test a 2 player and/or a 4:3 game with offscreen reload on 16:9 screen

Bisect Results

It was always like that

Version/Commit

You can find this information under Information/System Information

Environment information

gustavoalara commented 3 years ago

As there are a lot of lightgun projects nowadays (GUN4IR, Sinden Lightgun, Aimtraks, Wiimote/Dolphin Bar, multi mices...) and more people that are using them on several cores, A lot of people are interesting in a full lightgun support in Retroarch as Jaybee says.

All these community will be very grateful if the project can support it.

Thanks in advanced!

sonninnos commented 3 years ago

If the guns are seen as mice to the OS, then having two in RA should be just as possible as two mice already is with certain input drivers. For Windows you need raw driver and correct Mouse Index in Port Controls.

JayBee-git commented 3 years ago

If the guns are seen as mice to the OS, then having two in RA should be just as possible as two mice already is with certain input drivers. For Windows you need raw driver and correct Mouse Index in Port Controls.

Thanks for your answer. Indeed switching it to raw is kind of fixing the issue. But do you mind me asking how exactly is the Mouse Index working? It seems inconsistent in my setup, as changing one player index seems to change the other players as well, and while index 0 for player 1 and index 1 for player 2 works, the opposite doesn't work. Also changing the index of player 3 and 4 seems to change player 1 and 2 as well

sonninnos commented 3 years ago

I don't know too much about the index, but enough that I got dual mouse support added to the PUAE core a while back. No problems then dealing with only 2 mice.

The log will print the device names to tell which index is which mouse (would be great to get the name to the menu like with the controllers). The order is dictated by the OS, and it seems that the last mouse connected will be index 0, and the menu only works with index 0. Reordering the mice can be done for example via disabling/enabling them via Device Manager. And I have no idea why the default is 0 for all ports.

chef-wally commented 3 years ago

@sonninnos in Windows RA does not print the name of the device nor display the index using the RAW driver, we have to use mame64.exe -v to see the details.

RA logging:

unknown

mame64.exe -v

unknown (1)

The issue is a complete shutdown as in removing power from the PC or Laptop, might mess the indexing and so will reconnecting new or existing USB devices. From a user perspective it is not very practical to constantly reach inside the arcade cabinet, PC or Laptop and reconnect the light guns or mice again so that the USB stack is enumerated in the correct order. I have also tried using a powered USB hub to no success.

Easiest way to replicate:

  1. Disconnect all USB mice devices including the guns
  2. Connect both light guns first
  3. Then connect all other USB mice devices
sonninnos commented 3 years ago

Here it does:

[INFO] [WINRAW]: Mouse #0: "ROG SICA".
[INFO] [WINRAW]: Mouse #1: "W-01RN USB_V3.1".
[INFO] [XInput]: Found XInput v1.4.
[INFO] [Joypad]: Found joypad driver: "dinput".
[INFO] [Font]: Using font rendering backend: freetype.
[INFO] [Video]: Found display server: win32
[INFO] [XAudio2]: Requesting 64 ms latency, using 64 ms latency.
[INFO] [Display]: Found display driver: "vulkan".
[INFO] [Font]: Using font rendering backend: freetype.
[INFO] [Font]: Using font rendering backend: freetype.
[INFO] [Font]: Using font rendering backend: freetype.
[INFO] [Display]: Found display driver: "vulkan".
[INFO] [Font]: Using font rendering backend: freetype.
[INFO] [Font]: Using font rendering backend: freetype.
[INFO] [Font]: Using font rendering backend: freetype.
[INFO] [Font]: Using font rendering backend: freetype.
[INFO] [Font]: Using font rendering backend: freetype.
[INFO] [Font]: Using font rendering backend: freetype.
[INFO] [MIDI]: Input disabled.
[INFO] [MIDI]: Output disabled.
[INFO] [MIDI]: Initialized "winmm" driver.

How old version are you using?

And like I said, no physical unplugging is necessary, since the order can be changed via software disable/enable-cycle. Not optimal, of course, but better than nothing.

chef-wally commented 3 years ago

I've tried the latest stable and nightly builds. Possibly RA is not detecting correctly because this Light Gun system has both mouse/keyboard and joypad modes @JayBee-git?

When Driver is RAW and you click Save Controller Profile it saves to the following location, might we be able to set "Static ID" here?: \RetroArch\autoconfig\dinput\JB Gun Pro Micro P1.cfg

input_driver = "dinput" input_device = "JB Gun Pro Micro P1" input_vendor_id = "9025" input_product_id = "32834" input_gun_trigger_mbtn = "1"

\RetroArch\autoconfig\dinput\JB Gun Pro Micro P2.cfg

input_driver = "dinput" input_device = "JB Gun Pro Micro P2" input_vendor_id = "9025" input_product_id = "32835" input_gun_trigger_mbtn = "1"

You'll only know if the mouse index for the Light Gun has changed when you start a game and Player 1 and Player 2 are switched. If we could somehow detect that the ordering has changed before starting and then use AHK to modify the Controller Profile or retroarch cfg that could be a solution or as MAME does it Static IDs?

JayBee-git commented 3 years ago

I've tried the latest stable and nightly builds. Possibly RA is not detecting correctly because this Light Gun system has both mouse/keyboard and joypad modes @JayBee-git?

The mouse/keyboard and joypad modes don't cause any issue, 2 players works fine in raw actually, but just aren't so stable with the mouse index. I will try the cfg solution here to see how it works, but I'm not sure it will help in this situation. We could also make a script to change that, but it's not very elegant nor convenient.

You'll only know if the mouse index for the Light Gun has changed when you start a game and Player 1 and Player 2 are switched. If we could somehow detect that the ordering has changed before starting and then use AHK to modify the Controller Profile or retroarch cfg that could be a solution or as MAME does it Static IDs?

Mame indeed can be set with static IDs, one device is always recognized as a specific gun, no need to change the settings every time the index change like with RA. It's super convenient since it also allows to swap various guns with the same IDs.

markwkidd commented 3 years ago

This seems like a relevant issue to mention: https://github.com/libretro/RetroArch/issues/7638 (Mouse index changes between boots)

thatman84 commented 3 years ago

Def does look like this issue includes the issue Mark posted above.

It would be awesome to see the lightgun support become more automatic in the future. I would chip in to a bounty to resolve at least the changing index issue.

I’m not that technical to understand all the issues and descriptions. But will follow along 😀