Ikemen-GO icon indicating copy to clipboard operation
Ikemen-GO copied to clipboard

Suggestion: Try to do automatic joystick/gamepad/controller detection/configuration when starting the game for the first time

Open ssvb opened this issue 2 years ago • 8 comments

The quality of life can be greatly improved for new users if the game just could automatically detect the type of their joystick/controller and provide a reasonable configuration for it out of the box.

For example, PS3 controller is supported by modern Linux systems out of the box and requires no special effort for the user to configure it in the system. Basically just plug the USB cable and you are done. But now the user starts Ikemen-GO for the first time and needs to go to the OPTIONS menu to configure joystick buttons, because the default configuration isn't usable for his PS3 controller. I think that the game could provide some reasonable defaults out of the box, based on the automatically detected joystick/gamepad/controller type.

Additional nice feature would be automatic icons remapping in the movelists of the characters. So that a player with a PS3 controller would see "square", "triangle", "cross", "circle", "L1", "L2", "R1", "R2" icons matching the labels of the actual hardware buttons instead of "A", "B", "C", "D", "Z", "Y", "Z", "W" icons there.

Please let me know if you would be interested in a pull request implementing this functionality.

ssvb avatar Aug 07 '22 18:08 ssvb

automatic gamepad mapping is a planned feature and is already implemented locally (although not working at the moment since required glfw functions needed for this are missing in glfw-js library that we've switched to recently. @samhocevar is planning to make a pull request to that library down the road that will add missing stuff)

As for the second suggestion, there is ongoing Lua scripts refactoring effort, so other than bug fixes, pull requests with new features, aimed at the current version of the scripts won't be accepted, until the work on refactoring is finished (may not be ready for next build)

K4thos avatar Aug 08 '22 08:08 K4thos

I would suggest that the configuration section for Windows and Linux joysticks is either kept separate or autodetected if such a thing could be possible as well.

Since I'm dual booting Linux and Windows, I use the same Ikemen folder for both, sometimes I use the windows .exe and sometimes I run Ikemen from Linux, but the joystick config on Windows doesn't match the exact same hardware (same joystick) on Linux, so if I change config in one side, it becomes completely disconfigured for the other side.

Isakku avatar Aug 11 '22 04:08 Isakku

@Isakku, you can already use -config argument to run the engine using different configuration file path. https://github.com/ikemen-engine/Ikemen-GO/wiki/Miscellaneous-info#command-line-arguments

K4thos avatar Aug 11 '22 05:08 K4thos

@Isakku, you can already use -config argument to run the engine using different configuration file path. https://github.com/ikemen-engine/Ikemen-GO/wiki/Miscellaneous-info#command-line-arguments

Thank you. I didn't know there was that command line option. However, again as I said I would like it to work automatically detecting if it's being run on Linux or on Windows and load the corresponding configuration (for the joysticks only) automatically if possible. Having different config files for each OS may seem the way to go, but what if I want other configuration options to remain the same for both?

Isakku avatar Aug 11 '22 05:08 Isakku

I don't think bloating configuration file with additional data just for this purpose is a good idea, especially when the problem is already solved by using -config parameter.

K4thos avatar Aug 11 '22 06:08 K4thos

I would suggest that the configuration section for Windows and Linux joysticks is either kept separate or autodetected if such a thing could be possible as well.

I believe that joysticks can be autoconfigured out of the box and tweaking config files won't be even necessary (unless you don't like the defaults and want to reconfigure something). The game uses glfw library for joysticks handling and here is the glfw's joysticks mapping database: https://github.com/glfw/glfw/blob/master/src/mappings.h

As you can see, each entry in this database contains guid (the first column), gamepad name (the second column) and the operating system type (the last column). So your use case is already covered and glfw developers are aware of the operating system differences and this is taken into account.

But I want to implement an even better joysticks support for additional convenience. The current movelist screen looks like this: movelist_good Which is nice, except that PS3 controller users won't find any 'Y' button on their hardware. I want the game to also automatically remap movelist icons to show something like this: movelist_good_ps3 So that the user will start the game. The joystick type will be automatically detected and ready to use out of the box. Checking the movelist will provide very clear, unambiguous and immediately useful information (matching the actual hardware button labels on the currently used joystick). Though my plans are not exactly aligned with @K4thos's plans, so I will probably have to implement this feature in my own fork of Ikemen-GO and wait for the completion of the Lua scripts refactoring effort.

ssvb avatar Aug 11 '22 12:08 ssvb

I don't think bloating configuration file with additional data just for this purpose is a good idea, especially when the problem is already solved by using -config parameter.

Sadly the -config parameter doesn't seem to be a very practical solution.

Winmugen's Mugen.CFG file was just plain text and had several sections even for each operating system. There was a [Video Win] section for windows video settings and a [Video Linux] section for Linux video settings.

There was a default joystick config [P1 Joystick] ;Default config

[P2 Joystick] ;Default config

and a windows joystick section,

[P1 Joystick Win]

If the engine was run on windows it would load those, otherwise it would load the defaults

The functionality to automatically detect the OS and keep the joystick config for each OS is needed back, it should not require an adittional command that causes confusion (which config.json was which? which one should I use now?)

Copying an entire joystick configuration from one MUGEN to another MUGEN was just a matter of copying a section like this:

[P1 Joystick Win] ;Default config for win Jump = 1 Crouch = 2 Left = 3 Right = 4 A = 7 B = 9 C = 10 X = 12 Y = 8 Z = 11 Start = 14

Now I understand that the json format is better for coding, so going back to plain text may not be the anwer, but at least having settings for each OS stored and automatically detected would be nice.

EDIT: I just noticed that Ikemen won't use inputs from js2 for joystick Player 1 on Linux. The adapter I am using is a twin USB PS2 adapter and on Windows it allows the joystick numbers to be switched in the software drivers (installed via CD) But on Linux I have no way of changing it and it's detecting the only joystick I have right now as a 2nd joystick, as a result I can't get any input!
EDIT 2 OK, configuring the Player 2 joystick worked. But now I have another problem, screensaver shows up on Linux, the keypresses in the joystick don't seem to count as anything for it! That's a problem I have had with some other software on Linux, had to manually disable the screensaver because joystick activity is not detected as doing something.

Isakku avatar Aug 21 '22 05:08 Isakku

The Linux screensaver issue probably needs to be fixed in glfw, see https://github.com/glfw/glfw/issues/854.

samhocevar avatar Aug 21 '22 12:08 samhocevar