Change EmulationStation gamepad keyboard mapping
-
I'm running the latest supported build of Recalbox with the controls connected to RPI4 through an Ultimarc Mini-PAC. Recalbox interprets joysticks and action buttons as keyboard keys. This is good.
Here's the problem. EmulationStation assigns the virtual gamepad buttons to different keyboard keys than my Mini-Pac. For example, EmulationStation maps virtual gamepad button 'A' to keyboard key 'S', but my Mini-Pac is programmed to send keyboard key '1' instead of sending keyboard key 'S'.
I could reprogram the Mini-PAC to send 'S' instead of '1' when pressing that action button on my controller, but I would like to modify EmulationStation configuration instead. Is there a supported way to change the default keyboard mappings in EmulationStation? For example, can EmulationStation be configured to map virtual gamepad button 'A' to keyboard key '1' instead of keyboard key 'S'? If so, is there a way to make this the default mapping for all games?
-
I resolved this issue on my own. Confirmed with libretro/nestopia and libretro/picodrive.
- Connect a physical USB gamepad such as an Xbox controller for navigating ES menus.
- Launch a core and open the ES menu.
- Go up to Main Menu -> Settings -> Input -> Port 1 Controls.
- Using the physical USB gamepad, select each input and map an encoded keyboard control, e.g., map virtual gamepad "A" to keyboard key '1'.
- Go up to Main Menu -> Configuration File -> Save New Configuration. The file will be saved to /recalbox/share/system/.config/retroarch/config/corename.cfg.
- Copy the new configuration file to /recalbox/share/system/configs/retroarch/system.cfg, e.g., "nes.cfg" for libretro/nestopia. For more information about this step, see the "Manual modification" section of "Create a custom configuration per emulator" on the wiki.
-
To modify the EmulationStation menu mapping, edit the file /recalbox/system/.emulationstation/es_input.cfg. In the 'deviceName="Keyboard"' section, set the 'id' property of each input to the SDL keycode for that keyboard input. To map virtual gamepad button "a" to keyboard key "1", locate the input with 'name="a"' and change the value of 'id' to "49".
<input name="a" type="key" id="49" value="1" code="168" /> <!-- gamepad a ==> keyboard 1 -->
[EDIT] In this example, the SDL keycode for keyboard key "1" is 49. SDL keycodes are listed here - https://wiki.libsdl.org/SDL2/SDLKeycodeLookup.
-
-