libretro / RetroArch

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

[Bounty: $300] Multiple gamepads mapped to one RetroPad, and one gamepad to multiple RetroPads #7830

Closed markwkidd closed 3 years ago

markwkidd commented 5 years ago

Bounty contributions make a difference - please donate at this link today to support this feature

As of today there remain a few control mapping use cases which are not addressed by the mapping system. This is a feature request to support those use cases.

"N to 1" / Multiple Gamepads to One RetroPad Arcade games such as Robotron: 2084 feature a "Dual Joystick" control scheme where one joystick is held in each of the player's hands. In order to have a general purpose emulation system (where the two joysticks can usually be assigned to different players) that also fully supports Robotron, it is necessary to be able to map both joysticks to Player 1 on a game-by-game basis.

fa160906

N64 games like Perfect Dark and Goldeneye would also benefit from this option by allowing the user to configure the Player 1 joystick for movement and Player 2 for direction for full analog movement. This is supported by some standalone emulators.

"1 to N" / One Gamepad to Multiple RetroPads Some console games had additional features or cheats that are available for Player 1 if the player uses controls on the Player 2 gamepad of the original system -- for example, Megaman 3 on NES.

Other games, like Smash TV, require two controllers in their original versions because they are ports of "Dual Joystick" arcade games. Users with gamepads that include a joystick and a d-pad may wish to map both of the original NES d-pads to the same physical controller today.

andres-asm commented 5 years ago

this is very difficult

andres-asm commented 5 years ago

at least the 1:N part

markwkidd commented 5 years ago

Would you advise splitting the 1 to N into a separate bounty @fr500?

On Fri, Dec 28, 2018, 4:42 PM Andrés <notifications@github.com wrote:

at least the 1:N part

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/libretro/RetroArch/issues/7830#issuecomment-450432045, or mute the thread https://github.com/notifications/unsubscribe-auth/ASphdjaH70u-XVv3ETVCEs_5qe0xWPW3ks5u9pBhgaJpZM4Zj5jR .

andres-asm commented 5 years ago

Nah let's hope for the best

On Fri, Dec 28, 2018 at 5:00 PM markwkidd notifications@github.com wrote:

Would you advise splitting the 1 to N into a separate bounty @fr500?

On Fri, Dec 28, 2018, 4:42 PM Andrés <notifications@github.com wrote:

at least the 1:N part

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub < https://github.com/libretro/RetroArch/issues/7830#issuecomment-450432045>, or mute the thread < https://github.com/notifications/unsubscribe-auth/ASphdjaH70u-XVv3ETVCEs_5qe0xWPW3ks5u9pBhgaJpZM4Zj5jR

.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/libretro/RetroArch/issues/7830#issuecomment-450434086, or mute the thread https://github.com/notifications/unsubscribe-auth/ABpC0Aib9FhNQudjz95ZCbWjfKTAy2Iuks5u9pR5gaJpZM4Zj5jR .

alercah commented 5 years ago

The N:1 mapping would also be wonderful since it would make Switch joycons be usable paired, I think?

robertvb83 commented 5 years ago

So many possibilities... console games could be played dual joystick on an arcade cabinet or 2player fighting sticks

markwkidd commented 5 years ago

Thanks for the bump to $30 @robertvb83 !

barbudreadmon commented 5 years ago

I guess it sums up to being able to chose "controller+button" instead of just "button" when remapping ? I guess it would help dealing with "limited controller" issues indeed (in fba i always consider i'm dealing with a "full controller" with everything the retropad has to offer, so i won't hesitate to map P2 hardware joystick to P1 retropad right analog if i'm dealing with a twinstick game).

markwkidd commented 5 years ago

@barbudreadmon

I guess it sums up to being able to chose "controller+button" instead of just "button" when remapping ?

That seems like a straightforward and concise way to sum up the "N controllers/gamepads to 1 RetroPad" functionality. Nice.

markwkidd commented 5 years ago

Bounty up to $90 thanks to a $60 contribution from libretro organization bounty funds!

andres-asm commented 5 years ago

I really don't understand the need for this request. At least for one input device controlling multiple retropads.

I just tried SNES9X, Contra 3, started the game in 2 player mode. Then I went to settings and made sure that my gamepad was set the same for both players:

image

image

And now I can control both players with a single pad. Then as a PoC I remapped my right stick to move player two

image

And it all works, that should cover 1 gamepad N players use case just fine (could use some touch ups but it's certainly achievable)

What's the other part of it?

rsn8887 commented 5 years ago

Awesome, give the man the bounty (or half, because 1 to N seems solved, but N to 1 not yet).

barbudreadmon commented 5 years ago

@fr500 the other part is basically for people having bartops/cabinets, they have 2 minimalistic controllers (generally 1 stick + 6 buttons), and i think the general idea is that they want to use this setup to play twin-stick shooters and the likes (2 gamepads => 1 player).

ghost commented 5 years ago

I agree the info you where given is very vague. What is needed is the ability to map more than one physical controller to a player.

rsn8887 commented 5 years ago

The solution of assigning two users to the same controller in settings->input works perfectly (1 to N). I verified it here: https://github.com/fr500/dosbox-svn/issues/5#issuecomment-477719061

ziltama commented 5 years ago

I'm also interested in the "N to 1" feature. This is mainly helpful for emulators outside of MAME, which allows much more freedom for remapping in both 1 to N and N to 1 (although there seems to be a bug not allowing more than 4 controllers being detected for MAME in retroarch, which is not a problem in standalone MAME).

Scenario Example: Let's say I'm using Reicast core. I want to use a fight/arcade stick for fighting / simple action games and then want to use a dual analog pad for games that need analog or anything else. Both are wired and always plugged into the computer. Allowing these controllers set to the same user / player would make configurations much easier to do Instead of trying to make another copy of the reicast core or retroarch folder as a whole.

Edit: Also added a little to the bounty.

andres-asm commented 5 years ago

So I guess the N:1 part could be done after all

image

this is basically how controllers are paired in RetroArch Problem right now is that the top option only selects what's on the Port 1.

Instead it should show SNES Joypad (port #1)|SNES Mouse (port #1)|SNES Joypad (port #2)|SNES Joypad (port #3) I guess

Of course this would involve some work on the input drivers (and the remapper). It's not all that trivial, because as it is right now all input is assigned.

Say you press B, a variable holding that button state then is assigned to true

b=true

But then the second gamepad that has that action assigned is not pressing b, so

b=false

Etc, so the whole thing must become additive instead. Certainly can be done, but I don't know how long or complex it would be.

Remember after the input is polled there is the whole remapping thing (that overwrites input state too).

pgbconfirmit commented 4 years ago

I was going to contribute, but the bounty donation link gives an error. =(

Application error An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details. You can do this from the Heroku CLI with the command heroku logs --tail

hizzlekizzle commented 4 years ago

Bountysource has been having some structural issues lately, but they're apparently working on it. Hopefully, things will be working again soon.

pgbconfirmit commented 4 years ago

Is anyone able to ELI5 this to me, regarding why the 2nd analog stick on most modern gamepads isn't a solution for dual stick games like Robotron and SmashTV?

alercah commented 4 years ago

Because not everyone wants to use one of those.

pgbconfirmit commented 4 years ago

Sorry, maybe I'm not being clear what I mean. My understanding is that it is currently not possible to use the 2nd analog stick as the 2nd stick in a 2 stick game like Robotron. I get that not everyone uses a controller with dual analog sticks, but would it not also be helpful to add that as an option? (or was this added at some point and I'm not aware of it?) It seems that mapping the 1st analog stick on a gamepad to also work as an 8-way non-analog stick has existed for quite a while. I'm wondering why this is not an option for the 2nd analog stick which exists on most gamepads.

barbudreadmon commented 4 years ago

My understanding is that it is currently not possible to use the 2nd analog stick as the 2nd stick in a 2 stick game like Robotron.

@pgbconfirmit Works fine in FBNeo, it's actually the default for twin-stick games. I guess your issue is related to the usage of MAME and its OSD, i can't help you there (i think it's actually possible though), but it doesn't sound related to the current issue.

mediamoshpit commented 3 years ago

I've been using the N:1 solution presented here by @fr500 for some time to play Atari 2600 games that originally required two controllers, such as 'Spy Hunter', 'Defender II' and 'Raiders of the Lost Ark'. It's been working well until recently where it seems as though this behavior is no longer allowed. Specifically, this applies to mapping player two controls to any button on the player one retropad. It still works when mapping anything from player two to the analog sticks or the hat switch of player one, but that's of course not ideal for quick responses during play. Can anyone confirm this?

mediamoshpit commented 3 years ago

Of course I meant mapping to the same device index rather than same retropad.

barbudreadmon commented 3 years ago

@mediamoshpit Using FBNeo and current RetroArch nightly, mapping and controlling 2 players with the same controller still works here, so it doesn't seem to be a change in RetroArch. Probably a change in your core or setup.

mediamoshpit commented 3 years ago

@barbudreadmon Thanks for checking. just to make certain we're on the same page, did you try mapping player two button controls to be used on player one buttons specifically? Again, mapping directional input controls (like you would in 'Robotron') works for me as well.

barbudreadmon commented 3 years ago

did you try mapping player two button controls to be used on player one buttons specifically

@mediamoshpit yes, i mapped them to L1/R1/L2/R2 (B/A/Y/X being already in use), no issue.

mediamoshpit commented 3 years ago

@barbudreadmon Good to know. I guess it's either a core issue, or perhaps even a quirk with the Android port. It's fortunate that the controls can still be mapped to a directional function, so it's not that big of a deal. Thanks again for taking the time to check this. Your contributions have always been phenomenal and they are greatly appreciated. I'm on the road a lot these days and it's thanks to you and your cohorts that I'm able to play '3rd Strike' anywhere I have my phone.

megashub commented 3 years ago

Bounty increased to $300. All I want is for Retroarch to do it the same as MAME standalone does it:

Player 1: A = Device 1 Button 1 B = Device 2 Button 4 X = Device 3 Button 5 Y = Device 3 Button 0 Up = Device 1 Y+ Start = Device 2 Button 12 ...and so on.

And if you commit to also adding in the ability to press more than one button per mapping (e.g. "Device 1 Button 1 Button 2"), I'll up the bounty further.

megashub commented 3 years ago

Oh I should also mention, in case it's helpful for any devs considering this bounty, that standalone MAME also introduced the concept of device mapping in a custom controller config file the user creates. In that mapping config file, you literally define links between the various hardware IDs of your input devices and the standard controller variables used by MAME, thereby avoiding any problems inherent in device auto-detection (especially useful in Windows where devices rarely stay static).

Examples: <mapdevice device="Ultimarc Ultra-Stik Player 1" controller="JOYCODE_3" /> <mapdevice device="13382d5" controller="MOUSECODE_1" />

When you run MAME in verbose mode with auto-detection, it prints to the command window the exact hardware IDs it detects. Between that diagnostic information and disabling/re-enabling each device in, for example, Device Manager (Windows), you can isolate which HIDs are for which controller. Sometimes these devices have unique friendly device names like the Ultimarc example above. Others are just a string of alphanumeric characters. Still others have device names which are identical to one another (which is a pain when you have more than one of those devices), but MAME allows for a partial substring to be used, so in that case you're still not stuck. You can use the Device Instance Path substring like in the second example above, which, in Windows anyway, is unique so long as it isn't moved to a different USB port later.

Then, when you map a control in MAME, it looks like this under the hood: <port tag=":BUTTONS" type="P1_BUTTON1" mask="1" defvalue="1"> <newseq type="standard"> JOYCODE_3_BUTTON2 </newseq> </port>

and

<port type="P1_PADDLE"> <newseq type="standard"> MOUSECODE_1_XAXIS </newseq> </port>

So, essentially, the solution here could be:

  1. Replicate MAME's approach to device mapping to standard device variables Retroarch expects.
  2. Append the device variable to the control mappings e.g. _
  3. Bonus: Introduce multiple, compound button presses for control mapping. :)

That last bonus is useful, especially for reusing buttons for multiple actions, and/or on more minimalist control panels with fewer discrete buttons available for the various emulator commands.

emmak50 commented 3 years ago

Just some clarification from another person who would like to the see the N-to-1 solution implemented... yes you can play Robotron with a dual stick gamepad, that hasn't been a problem for a long time. The problem is more acute with custom control panels and specialty input devices.

On my cabinet I have two Ultistik 360s, which are seen as two distinct single-stick input devices. For Robotron and Black Widow, at least at the time I set it all up, I needed to do some kludgy stuff to get them to work and it also forced me to use a MAME core when I prefer FBNeo (with run ahead lag reduction). Talk about First World problems, yeah I get it, but it would be nice to have a way to map both to a single input device in Retroarch.

Another use case I am dealing with now... I just got a spinner. It acts like a mouse (only X) with left and right buttons.

If I put this in my cabinet, I don't want to add more buttons (there are plenty). It would be nice if Retroarch could map the mouse input from the spinner and buttons from the existing panel to a single Retroarch controller.

jdgleaver commented 3 years ago

Just for info - now that #12534 has been merged, RetroArch has support for both "N to 1" and "1 to N" gamepad mapping.

markwkidd commented 3 years ago

@jdgleaver thank you for your work on this, I will close the issue so that you may begin the bounty claim process.

Also thank you to everyone else who made bounty contributions, tested, and helped in other ways. Woo!!

megashub commented 3 years ago

Ive tested "N to 1" (and "N to 2" coincidentally) and it works well. I can't speak for 1-to-N. It does need a knowledge article to explain it all though, as it's far from intuitive thanks to RA's current codebase. But the feature works as advertised, as far as I'm concerned.

megashub commented 3 years ago

Hmm... I've been trying to log into bountysource all morning. Anyone else having trouble? Googling around it looks like BS is less than reliable these days. Might be time to move on from it to something else...

jdgleaver commented 3 years ago

Indeed - bountysource is a less than perfect organisation... There are a few alternatives listed here: https://en.wikipedia.org/wiki/Open-source_bounty#Examples_of_websites_listing_bounties_for_multiple_projects, but I don't know if any of them are any good... :(

I do try to avoid working on issues with attached bounties, just because of the stickiness of dealing with bountysource. This one was an exception, since I wanted "N to 1" mapping for my own purposes and so many users kept requesting the feature :)

Regardless, I hope the outcome is favourable for all involved!

megashub commented 3 years ago

@jdgleaver That makes sense, given the issues with it, and also totally defeats the purpose of bounties if devs actively avoid the bounty service being used. Ouch. I'd love to do more bounties, but am deterred in this case by the obstacle it presents. It's hard enough to get attention on features you want, adding a deterrent like a PITA bounty service just lowers the odds further when ideally it should raise them considerably (or what's the point?).

So thank you for taking it on, regardless. I'm very grateful!