-1

I installed DOSBox on my Retroflag GPi and copied some old DOS stuff to roms/pc, and I can run them from the RetroPie/EmulationStation menu, but there's a problem with the controls. By default the arrows seem to work only in some of the games, and the other keys usually don't do anything useful. I'd like to somehow configure the keys for each game separately. I know DOSBox has some way of configuring keyboard, but what are the key codes of the GPi buttons?

1 Answer 1

0

First of all, the buttons are seen by the system as a joystick, so what you want to do is map joystick movements and buttons to keyboard. The actual button codes are:

Up: "stick_0 hat 0 1"
Down: "stick_0 hat 0 4"
Left: "stick_0 hat 0 8"
Right: "stick_0 hat 0 2"
A: "stick_0 button 0"
B: "stick_0 button 1"
X: "stick_0 button 2"
Y: "stick_0 button 3"
Select: "stick_0 button 8"
Start: "stick_0 button 9"
Left Shoulder: "stick_0 button 4"
Right Shoulder: "stick_0 button 5"

If you switch d-pad to axis mode (by long pressing Start+Left), the d-pad gets different codes instead:

Up: "stick_0 axis 1 0"
Down: "stick_0 axis 1 1"
Left: "stick_0 axis 0 0"
Right: "stick_0 axis 0 1"

Note that the exact key codes might vary between Retroflag GPi versions, I've heard of a version where Select/Start is 6/7, not 8/9.

Now you need to create a separate .conf file and a .map file for each game. The .map file contains keyboard mapping, for example for a typical game the file my_game.map might look like this:

key_up "stick_0 hat 0 1"
key_down "stick_0 hat 0 4"
key_left "stick_0 hat 0 8"
key_right "stick_0 hat 0 2"

key_space "stick_0 button 0"
key_esc "stick_0 button 3"
key_p "stick_0 button 9"

key_lctrl "stick_0 button 8"
mod_3 "stick_0 button 8"
key_q "stick_0 button 9 mod3"

First you map the arrows, then other useful keys in the game, and the final section does a tricky thing: it maps Select to both Ctrl and mod_3 (a virtual modifier key in DOSBox), and then sends key Q on mod3+Start. This means that pressing Select+Start will in practice send Ctrl+Q (quit), but Start by itself will not send Q (only P, defined above).

In case of games that cannot be exited nicely, killing DOSBox is possible like this:

mod_3 "stick_0 button 8"
hand_shutdown "stick_0 button 9 mod3"

Then you create a my_game.conf file in roms/pc:

[sdl]
mapperfile=/full/path/to/my_game.map

[autoexec]
@cd /games/my_game
@my_game.exe
@exit

(Not sure, maybe a relative path to mapper would work as well.)

And I assume the mount action is defined in the master DOSBox config (config/dosbox-SVN.conf), something like:

[autoexec]
# Lines in this section will be run at startup.
# You can put your MOUNT lines here.

@mount c /home/pi/RetroPie/roms/pcdata
@c:

Here I keep all the DOS files not in roms/pc, but rather in roms/pcdata, to prevent the exe/bat/com files from appearing directly on the games list. I only want my conf files to appear there.

One final notice: As I said, the whole controller is seen as a joystick, and some games, like for example Prince of Persia, when started with a joystick, go into joystick mode and don't react to arrow keys at all. In that case you can instead map the d-pad and e.g. the A button to joystick, like this:

jaxis_0_1- "stick_0 hat 0 1"
jaxis_0_1+ "stick_0 hat 0 4"
jaxis_0_0- "stick_0 hat 0 8"
jaxis_0_0+ "stick_0 hat 0 2"
jbutton_0_0 "stick_0 button 0"

Not the answer you're looking for? Browse other questions tagged .