realnc / dosbox-core

A DOSBox core for use in RetroArch and other libretro frontends.
GNU General Public License v2.0
42 stars 16 forks source link

Changing between 2axis & 4axis gamepad + gamepads on port 3 and beyond #14

Closed Gagert closed 3 years ago

Gagert commented 4 years ago

Today I've been trying to configure the decades old game Super Off-Road for MS-DOS in this libretro core to work with 3 controllers (Wireless Xbox One gamepads). As of now I have not yet succeeded.

This old game can either use the combination of Keyboard Player 1 & 3 while Joystick Player 2, or Keyboard Player 1 while Joystick Player 2 & 3 as far as I can tell.

If we use the first scenario, I can manage to get Player 1 & 3 Keyboard controls working on my gamepads, but having Player 2 as Joystick makes all action buttons work but only the right directional button working on a gamepad. If I change Player 2 from Joystick to Gamepad in the Port 2 controls, none of the directional buttons seem to work at all. As I recall, this new core defaults the first Gamepad/Joypad activated in the Port menu to a 4axis one (I don't think this game likes that).

In the second scenario with only Player 1 using Keyboard controls on my gamepad, I can only use Port 2 for Joystick/Gamepad because it seems like it's not possible to choose Joystick/Gamepad for Port 3 and beyond in this libretro core. If Port 1 is Mouse/Keyboard, then it would be nice if Port 2 & Port 3 could be selected as 2axis Joysticks/Gamepads.

In all of the examples above I've fully configured all the control mappings for all of the 3 Controller Ports in this libretro core.

It could also be beneficial to have an option for changing between auto/4axis/2axis for Joystick type in the core Options menu for at least this game (I remember doing that with the dosbox.conf files in the "old days" of MS-DOS-emulation). It seems like this game might not be to happy with 4axis Joystick types because of its age.

Edit: I surely could just make the first 2 Ports Joypads and make the 3rd Port Keyboard as a workaround, but for "authenticity" I'll like the first Player to actually be the red car aka the Player 1 car.

realnc commented 4 years ago

If we use the first scenario, I can manage to get Player 1 & 3 Keyboard controls working on my gamepads, but having Player 2 as Joystick makes all action buttons work but only the right directional button working on a gamepad. If I change Player 2 from Joystick to Gamepad in the Port 2 controls, none of the directional buttons seem to work at all.

Could you check if you get the same behavior with stand-alone dosbox?

As I recall, this new core defaults the first Gamepad/Joypad activated in the Port menu to a 4axis one (I don't think this game likes that).

If only one pad/stick is used, it's always configured as 4axis, regardless of whether it's port 1 or 2.

It could also be beneficial to have an option for changing between auto/4axis/2axis for Joystick type in the core Options menu

Sounds reasonable.

Gagert commented 4 years ago

Could you check if you get the same behavior with stand-alone dosbox?

I've checked now (with a build of DOSBox ECE), and this is what I got by choosing various configurations by connecting only one gamepad:

joysticktype=auto

The gamepad responds, but the right directional key is internally stuck causing the letter selection-screen at Player 2 moving constantly to the right without stopping.

joysticktype=4axis

Pressing an action button at the start simultaneous selects both Player 2 & Player 3, and all the actions I do with the controller happens with both player 2 & 3.

joysticktype=2axis

Everything works just fine, Player 1 & 3 uses various keyboard keys, and Player 2 is controlled by my gamepad.

realnc commented 4 years ago

OK, so it sounds like adding an option to restrict joystick type to 2axis even when only one controller is used would solve the problem.

realnc commented 4 years ago

I added "Input: Force 2-axis/2-button" as a core option. Can you download the build from:

https://github.com/realnc/dosbox-core/actions/runs/111902353

and see if that fixes the issue? I tried Super Off Road myself and it fixed it on my end.

Gagert commented 4 years ago

Well, I can use all 3 of my Xbox One controllers now, but only if i choose Port 1 in the Controls section to Gamepad, making the first powered on Xbox One controller choosing the Player 2 car aka the Yellow one. It seems like this game is programmed the way that the Gamepad/Joystick player has to be Player 2, while the Player 1 car aka the red one is locked to the Keyboard player. Choosing Gamepad/Joystick in Port 2 makes the game registering the 3rd blue player, but having two 2axis Gamepads in this game bugs this game out by not having all the buttons working on the Gamepads (both in this dosbox core and on stand-alone dosbox).

The ideal situation would be if Port 1 is selected as Keyboard/Mouse, the first initialized Joystick/Gamepad would be moved from Port 1 to Port 2, making Joystick/Gamepad selection available on Port 2 and Port 3. As of now it seems like the first two ports are the only one that you can use with Joystick/Gamepads.

realnc commented 4 years ago

The ideal situation would be if Port 1 is selected as Keyboard/Mouse, the first initialized Joystick/Gamepad would be moved from Port 1 to Port 2, making Joystick/Gamepad selection available on Port 2 and Port 3.

The core supports up to 6 ports. However, RetroArch has the nasty behavior of automatically assigning RETRO_DEVICE_JOYPAD to all ports. For ports 1 and 2, we rename that to "Gamepad". For the remaining ports we don't rename it, and RA uses "RetroPad" and you still see that as a choice in ports higher than 2, since there's no way to prevent RA from adding it.

When you configure RA's "Maximum Users" count to 3, then the invisible ports higher than 3 are still assigned RETRO_DEVICE_JOYPAD. So when we check how many ports are set to RETRO_DEVICE_JOYPAD (in order to decide whether to use 2axis or 4axis), we get more gamepads more then there actually are. There is no way to query RA about the "Max Users" setting. We just can't know how many of these gamepads are real or not.

This is why gamepad/joystick is only allowed on ports 1 and 2. It's not possible to use 4axis gamepads otherwise, since we can't tell if the invisible higher ports are actually used or not.

andres-asm commented 4 years ago

this is bad behavior on retroarch, there is no real way to remove retropad on ports

On Fri, May 22, 2020 at 12:30 PM Nikos Chantziaras notifications@github.com wrote:

The ideal situation would be if Port 1 is selected as Keyboard/Mouse, the first initialized Joystick/Gamepad would be moved from Port 1 to Port 2, making Joystick/Gamepad selection available on Port 2 and Port 3.

The core supports up to 6 ports. However, RetroArch has the nasty behavior of automatically assigning RETRO_DEVICE_JOYPAD to all ports. For ports 1 and 2, we rename that to "Gamepad". For the remaining ports we don't rename it, and RA uses "RetroPad" and you still see that as a choice in ports higher than 2, since there's no way to prevent RA from adding it.

When you configure RA's "Maximum Users" count to 3, then the invisible ports higher than 3 are still assigned "RetroPad". So when we check how many gamepads there are (in order to decide whether to use 2axis or 4axis), we get 3 gamepads more then there actually are. There is no way to query RA about the "Max Users" setting. We just can't know how many of these gamepads are real or not.

This is why gamepad/joystick is only allowed on ports 1 and 2. It's not possible to use 4axis gamepads otherwise, since we can't tell if the invisible higher ports are actually used or not.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/realnc/dosbox-core/issues/14#issuecomment-632820101, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANEFUBFWMZNDF62LE4ZD3LRS2ZDXANCNFSM4NDOQR3Q .

realnc commented 4 years ago

this is bad behavior on retroarch, there is no real way to remove retropad on ports

I'm currently looking for what the best way is to fix this in RA.

realnc commented 4 years ago

I merged the option to force 2axis and it should be now in the updater. Allowing controllers past port 2 is not not something I can do unless retroarch merges this PR:

https://github.com/libretro/RetroArch/pull/10687

I don't know if they will, however. If they don't, then dosbox can never offer gamepad support on any other ports in RetroArch.

Gagert commented 3 years ago

Looks like something is happening now regarding the pull request to RetroArch; I've been following the discussion over there for some time now. Fingers crossed that everything goes well regarding this pull request, and that it doesn't break compatibility with other cores.

Gagert commented 3 years ago

I've done some testing now with both RetroArch 1.9.1 & the newly released version 1.9.2 with Super Off-Road for MS-DOS in 3 Player Mode.

Since the input related PR now is merged with RetroArch, I thought that this issue would be a thing of the past with my current control config for this game. Somehow I'm not successful as of yet. Player 1 & 3 is using Keyboard + Mouse, and Player 2 is using Joystick in the Controls settings in the newest release of this libretro core. Forcing 2axis mode somehow disables Player 2 when Player 2 uses Joystick, not forcing 2axis makes only the buttons and the right directional key respond.

realnc commented 3 years ago

Right. Didn't keep track of this. Sorry.

The RA issue is fixed now, so I pushed 9e9bb0ac3f43a6641d67a5bcc724cc9c7a83097d that finally unlocks all 6 ports (that's how many this core supports right now) to be set to gamepad or joystick.

Note that it doesn't matter anymore to which ports you connect controllers. Only the amount of controllers count. If for example port 5 has a controller, but none of the others do, you get 1 4axis/4button DOS joystick/gamepad. If you connect a second controller to any of the other ports, you get two 2axis/2button joysticks/gamepads. If you connect more than 2 controllers, then only the first two will be used, since DOS itself doesn't support more than 2.

Let's wait until the update becomes available in the core downloader so you can test this on your end. I tested using JOYTEST.EXE from here:

https://www.vogons.org/viewtopic.php?p=187168#p187168

realnc commented 3 years ago

Or you can download the build artifact from github if you don't want to wait for libretro's buildbot:

https://github.com/realnc/dosbox-core/actions/runs/823008113

Gagert commented 3 years ago

Now I've finally got this working. I've updated to the latest core in the RA Online Updater (9e9bb0a), but still no changes. I then had to enable a setting named "Enable joystick timed intervals" while having "Force 2-axis/2-button" disabled to get all the other directional buttons on my secondary gamepad working.

Now it all works seamlessly with 3 wireless Xbox One gamepads with Super Off-Road using this libretro core in RetroArch. Thanks for fixing this minor issue, I can now close this issue.