Hard Code Controller Mapping
-
Hi there,
I want to switch between SNES and NES controller with controlblock. Since I normaly need to remap the buttons every time I switch, I wanted to hard code the config.
So I checked the following file:
/opt/retropie/configs/all/retroarch/autoconfig/ControlBlock SNES Gamepad.cfgthis is different for NES and SNES.
SNES:
input_device = "ControlBlock SNES Gamepad" input_driver = "udev" input_l_btn = "4" input_load_state_btn = "4" input_start_btn = "7" input_exit_emulator_btn = "7" input_up_axis = "-1" input_a_btn = "0" input_b_btn = "1" input_reset_btn = "1" input_enable_hotkey_btn = "6" input_down_axis = "+1" input_r_btn = "5" input_save_state_btn = "5" input_right_axis = "+0" input_state_slot_increase_axis = "+0" input_x_btn = "2" input_menu_toggle_btn = "2" input_select_btn = "6" input_y_btn = "3" input_left_axis = "-0" input_state_slot_decrease_axis = "-0"
NES:
input_device = "ControlBlock SNES Gamepad" input_driver = "udev" input_start_btn = "7" input_exit_emulator_btn = "7" input_up_axis = "-1" input_a_btn = "1" input_b_btn = "3" input_reset_btn = "3" input_enable_hotkey_btn = "6" input_down_axis = "+1" input_right_axis = "+0" input_state_slot_increase_axis = "+0" input_select_btn = "6" input_left_axis = "-0" input_state_slot_decrease_axis = "-0"
So my plan was to Copy the NES config file into this file
/opt/retropie/configs/all/retroarch/autoconfig/ControlBlock SNES Gamepad.cfg
if NES controller is connected.
The same for SNES controller.I do the same for /opt/retropie/configs/all/retroarch/autoconfig/ControlBlock SNES Gamepad.cfg.bak.
But this does not work right now. I still miss something so it seems.
In Retroarch config it is stated that you need to config /opt/retropie/configs/all/retroarch.cfg but I cannot find any difference after auto config NES or SNES controller in emulationstation.
So anyone any idea what I am missing?
-
@jeddo I am not at my computer right now, but I created a custom script I run on my stand up arcade machine that has joysticks. My use case is for n64 where the controllers are set by the muepen64.cfg. In my use case the script will swap out the muepen64.cfg file so that I can use my wireless PS4 controllers and player 1 and 2, or switch back to use the joysticks as player 1 and 2.
If you are interested I should be able to do the same thing for your SNES config file. The script is run from the retropie menu and it performs an auto restart of ES.
Let me know if you are interested in this solution and I can create a script for your use case.
-
@tmntturtlguy that sounds great. I have als a script for the setup of my controllers. works great so far. Last thing is that SNES / NES swap thingy.
I'm not quite sure since you use n64 and PS4 if there is any difference with Controlblock.
But would be great if you could upload that anywhere so I can have a look at it.
Right now the swapout of the two config files is working but I am still missing some more. Not quite sure where else the autoconfig of emulationstatoion is editing things. -
@jeddo Ok, so i am at my computer now and re-read through your post and input files. It appears that both of your controllers are being recognized as the same input device name. That is unfortunate, if they were recognized as different input names, then you could just have their own autoconfig.cfg and this would not be an issue for you. BUT since they both are recognized as the same controller, here is a possible solution for you. All this will do is swap out the
ControlBlock SNES gamepad.cfg
First please verify that the .cfg file actually has spaces in it. in the path you have typed, you have a space between the
k
of block and theS
of SNES as well as theS
in SNES and theg
in gamepad. It is very important that the spaces and letter casing (upper vs. lowercase match exactly)Based on the information you have provided in your original post, i have created a custom script just for your use case that can be downloaded from mega.
If you open the script in notepad++ you will see some instructions, but here is what you need to do. Be sure not to miss a step, or you may permanently delete your controller config file. (you will just have to reset up your controller, so nothing to be will be lost here). I suggest you make a copy of your controller config file to your computer before you start.
Steps to make this work:
- using putty or winSCP go to
/opt/retropie/configs/all/emulationstation/
- create a new folder (directory) named
controller_swap
- the full path you just created should be
/opt/retropie/configs/all/emulationstation/controller_swap/
- inside this new directory add these two directories:
nes
andsnes
- inside the new
nes
folder:/opt/retropie/configs/all/emulationstation/controller_swap/nes/
place a copy of theControlBlock SNES Gamepad.cfg
that is set up with your NES settings. - inside the new
snes
folder:/opt/retropie/configs/all/emulationstation/controller_swap/snes/
place a copy of theControlBlock SNES Gamepad.cfg
that is set up with your SNES settings. - Now go to
/home/pi/RetroPie/retropiemenu/
- place the script provided in the download link into this folder:
Controller Swap
- restart EmulationStation
- now when you enter the retropie menu from the system selection you should see
Controller Swap
added as an option on the menu. Select this option from the menu. - A dialog box should appear that says "Thes scrpipt lets you change your controller config file for NES and SNES controllers. This will not change or remove any systems or content. ES will automatically restart. Do you want to proceed."
- Select yes
- The next screen will give you 2 options,
Change to NES
andChange to SNES
- Choose whichever you want. Your system will automatically restart.
- Now your system is using the controller config that you just chose. To change again, just go into retropie menu, launch the Controller Swap option and choose the other option.
What this does: all this does is store 2 different settings files under the same configuration file name. It deletes the existing config file from your /autoconfig/ folder and then places a copy of the config file for either NES or SNES back in its place. So it is just switching out your input files for you so you don't have to reset them up every time.
If something does not work correctly, all you need to do is go into the
/autoconfig/
folder and delete theControlBlock SNES gamepad.cfg
and then place your backup copy from your computer back into this directory. Everything will be fixed. There should be no issues however.As always, i suggest backing up your SD card before you try anything new out. I am basing this script on the file names you have provided. If the files names, spelling, spacing, or capitalization are incorrect, the script will not work properly.
Please let me know if you have any questions, and let me know if it works. It should work very smoothly for you.
- using putty or winSCP go to
-
@tmntturtlguy thanks for the detailed reply. I will have a look at your code when I'm back on the PC.
My script already swaps that .cfg and .cfg.bak (not sure if this .cfg.bak swap is needed or not) file and this is working fine.
But what does not yet work is the actual controller.I swap the .cfg file on startup depending which controller is connected but the the controller is still configured as SNES or NES whatever I last configured last with the auto config in emulationstation.
So my idea was that I need to swap another file, not only .cfg and .cfg.bak or restart something. But not sure what or where. Like I said in my starting post, the documentation says that controller hard config is stored in retroarch.cfg but I could not find any difference between the retroarch.cfg while SNES is working and retroarch.cfg when NES is working.
-
@tmntturtlguy so I checked your code now and it basicly does the same as my script.
The problem there is that swapping the ControlBlock SNES gamepad.cfg file works but the system still does not changes the controlls of the controller :/ -
@jeddo sorry I have been traveling for work.
Have you made changes to your retroarch.cfg or other files?
Can you verify that both controllers are being recognized by the same name? You can use evdev or jstest to find this information through putty or the command line.
Also, please explain where the controls are not working. Is the is ES or in the games? If in the games are you using retroarch emulators? The emulators that start with lr? The auto start controls only work with lr emulators, others need to be manually set.
Lastly, you may also need to change out the input.cfg file. That is the file that configured the buttons while in emulationstation menues. The autoconfig is what configures the controls for retroarch emulators.
Based on the info you have shared so far, changing the autocofigs should definetly chane the inputs while in the emulator. This is the only location I change my inputs and it always works. You must restar emulationstation every time you make a change for them to take effect.
Please provide more detailed info on what modifications you have made to other files, and how the controllers respond in both ES and in games. Please also run evdev on both controllers to make sure they are both recognized by the same name, and make sure that name matches the autoconfig file exactly.
I look forward to hearing back from you.
-
@tmntturtlguy thanks for the help. Will try that as soon as I am back from work.
Controller are definitely recognised as the same.
In emulationstation if it is configured as NES, SNES controller behaves as follows:
D-pad start and select working as intended.
B button is configured as A
Y button is configured as B.If SNES configured, NES works as follows:
D-pad start and select working as intended.
B button is configured as Y
A button is configured as B.I did not yet test it in emulator. Was not aware that emulators and emulationstation has different configs.
I tried changing retroarch.cfg (setting auto config to exact file and another try was to set button mapping there) but with same result as described above.
But if emulationstation has separate config I need to change that too.
I will try that -
@jeddo ok, first your problem is definetly that you need to change your input.cfg file when changing controllers so that the buttons are changed in emulationstation as well as in the games.
Next you need to make sure you remove any modifications you made to your retroarch.cfg file so everything works as expected.
Last, you need to make sure you use lr emulators so that the controllers use the controller settings in the config files.
If all this works we can add the swapping of the input.cfg file to the script so it changes out both config files at the same time.
-
@tmntturtlguy wohoo! you are my man! or turtle or whatever! thank you very much! It works now. Just needed to swap the es_input.cfg too for emulationstation config. I tested in the emulator before without es_input.cfg and there the controller worked. Just config in ES was missing.
Finally I can soon finish my project :) Thank you!
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.