Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: INI options for controllers to combine and define PID's/VID's for players #785

Open
thorr2 opened this issue May 26, 2023 · 19 comments

Comments

@thorr2
Copy link

thorr2 commented May 26, 2023

With an arcade cabinet, there are many situations where different USB controllers are needed for a single player, like a USB stick shift and USB pedals and a USB steering wheel, and there are times when you want to combine controls and other times when you want to keep them separate. Each core can be configured independently in the INI file. When creating controls with Arduinos and other devices, you can specify new PID's and VID's to distinguish them from other Arduino controllers.

Please add an INI option to specify the multiple specific PID's and VID's you want to use for Player 1, Player 2, Player 3 and Player 4. It could look like this:

[corename]
P1PIDVIDS=1240x2000,1240x2001,1240x2002
P2PIDVIDS=1240x2003,1240x2004
P3PIDVIDS=1240x2005,1240x2006
P4PIDVIDS=4320x1335

The above settings would supersede any other settings so previous functionality could still work with joystick mapping when these are not defined.

This would allow those with arcade cabinets to use multiple custom controls for a single player with having multiple PIDs and VIDs used for a single player, but still have the option to have more than one player with its own controls.

Also, if the same PID/VID is plugged in more than once, they could be assigned in order of the way they are plugged in like they are now for different players 1-4. These could still be specified in the P#PIDVIDS lines in the INI file and used more than once.

Thanks!

@sorgelig
Copy link
Member

there is already option in INI: player_X_controller where X is player number. It allows to specify only single controller for specific player but should be enough for arcade cabinet with fixed controllers.

@thorr2
Copy link
Author

thorr2 commented May 27, 2023

Thank you. While that is helpful for single USB controllers and multiple players, this request is to allow multiple controllers to be assigned to a single player. A control panel may consist of different third party USB controllers that combine together to make all the controls for the arcade game. If the above is not feasible for multiple players each with multiple controllers, then at least an option to combine all detected controllers to be available for player 1 would be helpful. Thanks again.

@sorgelig
Copy link
Member

Theoretically, assigning several controllers to a single player is possible. I will check it.

@sorgelig
Copy link
Member

In latest commit i've added multiple device mapping.
just use multiple player_1_controller lines to assign all mentioned devices to player 1. And same for other players.
I cannot test all use cases and reactions of such mapping, so it need to be tested. I hope you will help to test it.

@thorr2
Copy link
Author

thorr2 commented May 28, 2023

Thank you very much! This is really great and appreciated. I am happy to help test, but I am slightly embarrassed and sorry to say that I don't know what I need to do to install the latest code onto my MiSTer from the commit. I am very familiar with Linux, but not with getting stuff out of the latest git commits. I am not sure what files I need and where to put them. I see the new code is out there. Can I just run update or update_all, or is it not available as a main release to the public yet?

@sorgelig
Copy link
Member

Do you know how to get nightly/unstable builds?

@sorgelig
Copy link
Member

this is zipped Main with latest changes:
MiSTer.zip

if you don't know how to get unstable builds, then you can unzip it and replace MiSTer binary manually.

@thorr2
Copy link
Author

thorr2 commented May 28, 2023

Thanks! I don't know how to get the builds, but I will try the zip file and let you know how it goes.

Also, when defining the controls, the first thing it asks you to do is press right. This wakes it up so it knows what device you are programming and at the same time programs the right direction. Not every controller has a "Right" to push. Can you fix it so that the User button can bypass all the questions until you get to the first one that applies to the controller. For example, I have a set of USB analog pedals with gas and brake. I can't program these because I have to wake them up with the Right direction.

@sorgelig
Copy link
Member

sorgelig commented May 28, 2023

This problem is hard to solve, actually. Controllers are supposed to be able to control OSD, so directions are essential parts. Waiting for ANY event from controller is not reliable because some analog controllers may have noise and periodically spit the events preventing to map other controllers. Direction-less controllers are usually spinners/paddles which have no traditional mapping, so mapping dialog is useless for them. If spinner uses mouse events, then it should be defined through special options in ini.

As a workaround, you may edit gamecontrollerdb.txt or gamecontrollerdb_mister.txt to add special your controllers and they will get mapping automatically.

@thorr2
Copy link
Author

thorr2 commented May 28, 2023

Thanks! Upon my first testing, this is working great! I tested Super Smash TV on the SNES with two controllers and was able to use one for firing in different directions and the other to move around. This is really great!

One problem I did notice though is that I am getting an INI file error when starting the MiSTer with the line:
controller_unique_mapping=0

If I comment out the line, I don't get the error.

I haven't tried the gamecontrollerdb stuff yet, but that sounds encouraging. I will look into it.

I did try Discs of Tron with a push-pull spinner that uses mouse buttons and it wouldn't let me change the function of the mouse buttons to go up and down in the game (it instead throws the disc). Are you saying there is a way in the INI file to change these functions? I tried using the joystick button mapping but it just ignores the spinner's mouse clicks, same as you have stated above. I have since worked with the manufacturer and they came out with a new version that lets you wire up to the up/down so I can tie it together with the Joystick's Arduino. It would be cool if it would have just worked though and maybe there is a way with the INI file. In any case, maybe the DOT core can be updated to allow changes to the spinner's mouse button functions so up/down will work with them. Scroll Up/Down are also functions of the spinner that could be mapped in the game.

@sorgelig
Copy link
Member

One problem I did notice though is that I am getting an INI file error when starting the MiSTer with the line:
controller_unique_mapping=0

strange.. i can't reproduce it. May be you've typed letter O instead of number 0?

I did try Discs of Tron with a push-pull spinner that uses mouse buttons and it wouldn't let me change the function of the mouse buttons to go up and down in the game (it instead throws the disc). Are you saying there is a way in the INI file to change these functions?

Nope. Spinner is supposed to have only single button. Spinner is considered as an overlay device. So using together with gamepad/joystick you can use spinner with its button as a main action (like fire or jump) and additional buttons from joystick.

@thorr2
Copy link
Author

thorr2 commented May 28, 2023

Strange. I uncommented the line and I don't get the error anymore. Maybe it only shows up with a new unmapped in the main menu device or something if it is defined in the INI file already. I am not sure. I wouldn't worry about it I guess.

My spinner when I hook it up to my PC acts like a mouse going left and right, and it will also left click, right click, scroll up, and scroll down. In order to get it to work with DOT, I had to define the Spinner's vid and pid, and functionally, it provides a single button as you mentioned. Both left click and right click act like the same single button.

I started looking further into the gamecontrollerdb.txt. I didn't find the _mister version. This looks promising, but I wonder about the core mapping. For example, if I wanted to use my USB pedals with Outrun, is there a default mapping for the gas and brake to a particular control in the gamecontrollerdb.txt that I can define? Otherwise, I will run into the same problem when inside the core, I tell it to map the joystick buttons and it wants me to press right and won't let me bypass it. Also, I am trying to figure out how to get the device ID for the gamecontrollerdb.txt. I am doing some searching in the meantime.

Thanks again for all of your help.

Edit: I did a killall MiSTer; /media/fat/MiSTer and plugged in the USB pedals and this is scrolling on the screen...

opened 0( 0): /dev/input/event1 (061c:0301:7a9b6ea3) 0 "usb-ffb40000.usb-1.2/input0" "ACT LABS ACT LABS Performance Pedal System"

061c:0301:00 P0 Input event: type=EV_ABS, Axis=3 [0...255], Offset=246
061c:0301:00 P0 Input event: type=EV_ABS, Axis=3 [0...255], Offset=246
061c:0301:00 P0 Input event: type=EV_ABS, Axis=3 [0...255], Offset=246
061c:0301:00 P0 Input event: type=EV_ABS, Axis=4 [0...255], Offset=247
061c:0301:00 P0 Input event: type=EV_ABS, Axis=3 [0...255], Offset=247
061c:0301:00 P0 Input event: type=EV_ABS, Axis=3 [0...255], Offset=246
061c:0301:00 P0 Input event: type=EV_ABS, Axis=3 [0...255], Offset=246
061c:0301:00 P0 Input event: type=EV_ABS, Axis=3 [0...255], Offset=246
061c:0301:00 P0 Input event: type=EV_ABS, Axis=4 [0...255], Offset=247
061c:0301:00 P0 Input event: type=EV_ABS, Axis=4 [0...255], Offset=247
061c:0301:00 P0 Input event: type=EV_ABS, Axis=4 [0...255], Offset=248

So if the core is expecting the gas and brake on a certain set of controls, I could use the gamecontrollerdb.txt to map the pid/vid/hash and axis to those controls. Gas is Axis 3 an Brake is Axis 4. They both have a high number close to 255 before you press them down and the number goes down to close to zero.

@sorgelig
Copy link
Member

I think it's better to discuss such thing on MiSTer forum.
I didn't develop the module using gamecontrollerdb and i'm not sure about specific details, so better to ask people on forum.
Cores usually expect some more or less standard controllers, so gas/brake are usually controlled by analog sticks. So pedals probably should be mapped to analog sticks.

@thorr2
Copy link
Author

thorr2 commented May 28, 2023

Thanks. I did some more experimenting. I deleted the Outrun.cfg files in the config folder and used my Xbox 360 wired controller clone that already exists in the gamecontrollerdb.txt file with Outrun and didn't configure the joystick button mappings. With the controller_info=6 defined in the MiSTer.ini, it told me what button was assigned to what for that controller. It said that buttons were used for gas and brake. I also noticed that the analog stick worked with up/down for gas/brake, but it still seemed to be digital (full on/full off). I then tried joystick mapping the gas/brake functions to the triggers and it was still full/on full/off, so I guess for Outrun the gas and brake are digital. This experiment was enough for the moment to tell me how to proceed. Delete the config files for the game and see what the default expected behavior is, then assign any new controller in the gamecontrollerdb.txt file and map the controls to the ones the core is expecting. The last thing I need to figure out is how to get the long string that the gamecontrollerdb.txt is expecting like: 030000005e0400008e02000014010000

Thanks again for your help! I really appreciate the new feature, and will put it to good use!

@sorgelig
Copy link
Member

sorgelig commented May 28, 2023

it's here:

sprintf(guid_str, "%04x0000%04x0000%04x0000%04x0000", (uint16_t)(bustype << 8 | bustype >> 8), (uint16_t)( vid << 8 | vid >> 8), (uint16_t)(pid << 8 | pid >> 8), (uint16_t)(version << 8 | version >> 8));

bustype is always 3 and version is always 4

you can use gamecontrollerdb_user.txt to create your own base without touching original gamecontrollerdb.txt

@thorr2
Copy link
Author

thorr2 commented May 29, 2023

Great! Thanks a lot for your help!

@thorr2
Copy link
Author

thorr2 commented Jun 5, 2023

This isn't exactly related to this feature, but I was wondering, do the left and right analog triggers work as analog in the MiSTer? I can see that Linux recognizes them as analog, and I can map them to up and down analog thumbstick functions, but when in the main menu mapping the joystick, the analog triggers are not asked about. I am trying to use them with the arcade core Spy Hunter as analog gas/brake and they don't work unless I change the core menu to set them as digital. I have made a custom driving control panel that uses an Xbox 360 controller as the brains and I mapped the gas and brake to the left and right analog triggers. So far the analog triggers only work as digital in the cores I have tried. There are many many cases where analog triggers would be helpful within the cores, especially for throttle and brake. Am I doing something wrong, or are these not supported, and if not, can you please add them? Spy Hunter is a good example test case. I would be happy to create a new github issue for this if you would like. Thanks!

@sorgelig
Copy link
Member

sorgelig commented Jun 5, 2023

MiSTer doesn't support analog triggers. They are converted to digital buttons if gamepad generates standard events.

@thorr2
Copy link
Author

thorr2 commented Jun 5, 2023

Thank you for letting me know the current status. Is there any chance that you can add this, please? It would be very helpful and add a lot of flexibility to configuring the control options for various cores and games within cores. I assume most people use controllers that have the analog triggers so it could benefit a lot of people as well, not just arcade cabinet users. Thanks for your consideration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants