Thursday, February 25, 2021

Dosbox keyboard issues - mute and misbehaving keys [RetroPie as an OS]

🕐🕐 Duration: 2 to 3 hours
🔧🔧 Difficulty: Medium
🌟🌟🌟 Interest: Interesting

If you have been building your game library in RetroPie odds that you grew interest in Dosbox could be substantial.

However although Dosbox is fairly easy to use in the late versions, you could be meeting issues with key typing especially if you are using an exotic keyboard (as in "not qwerty").

For instance an azerty keyboard like the one I have will be unable to send most of the special characters and worst of all won't be able to type in digits.

In some cases the handicap you will suffer from it will be light in other cases it will make a game unplayable.

If you check in /home/pi/.dosbox/dosbox-SVN.conf, you will notice that there is a keyboard layout entry in it. At this point it will not solve your case. Keyboard layout entry will only rearrange known keyboard keys. It will not make unknown keys known. For this, you have to use Dosbox keyboard mapper.

Happy path

It is recommended to use a mouse. Plug an USB mouse if you have one. Sometimes the touchpad of your keyboard will work. 
Also this guide assumes that you have already set your keyboard up with raspi-config. If it isn't the case, please do so. Usually choosing "Generic 10x keyboard" will be quite versatile and will not bring too many unbindable unknown keys (see below).

First of all ready your /home/pi/.dosbox/ directory.
Note: /opt/retropie/configs/pc/ is the same directory. RetroPie links the 2 directories together on startup.
 
[sdl]
fullscreen = true
fulldouble = false
...
mapperfile = /home/pi/.dosbox/mapper-SVN.map
usescancodes = false
...
  • Using absolute path for mapper-SVN.map will ensure that it will keep being used if you fork your dosbox-SVN.conf to a local game directory.
  • Start Dosbox from RetroPie
  • If you read carefully, you will notice that Dosbox welcome screen tells you how to summon the mapper (CTRL+F1). Start it. It will look like that:

Dosbox Mapper Raspberry Pi
The dosbox key mapper

  • The safest way to configure your keyboard is to remove all the key bindings and redo them all. Most mapper-SVN.map are made for UK or US keyboards. Depending on how many keys in common your local keyboard has with UK/US keyboard, you will have to do more or less bindings. If you are unsure, remove all and redo all:
    • To remove a key click on that key on the mapper then click on "Del" at the bottom-right of the mapper screen.
    • Reclick on that key then, click on add then, press a key.
    • Do a test with escape key to check if it works.
    • If it works, do the same with F1, F2... until all keys are rebound.
    • When remapping keys you have to remap keys according to the position on your keyboard and not according to what you see written on the key. (Examples: Q on Dosbox mapper will map to A on azerty french keyboard. Y on Dosbox mapper will map to Z on qwertz german keyboard)
  • If you have an azerty keyboard you can follow my map hereafter. You will only need to rebind the keys in red squares:

Dosbox key mapper Raspberry Pi Azerty
Only the keys in red square must be remapped on azerty keyboard
  • Once the keys are mapped click on "Save" and then "Exit"
  • exit dosbox
  • Edit /home/pi/dosbox-SVN.conf
  • replace keyboardlayout = auto according to your country locale
    • keyboardlayout = fr 
    • keyboardlayout = de
    • keyboardlayout = (your country locale)

Troubleshooting - unknown keys

While doing the forementionned mapping you might notice at some point that the mapper has detected an unknown key. This is a bad thing because all unknown keys will stack their mapping. On my keyboard, Caps Lock, ² (the key left to 1), " (the key right to P) and 6 are all unknown keys. 
To solve this issue you have 2 solutions:
  • Try-and-error switch keyboard layouts in raspi-config 
        OR
  • Choose one key over the others. In the above case we will choose the key "6" and unbind Caps Lock, ² and ". 
    • Caps Lock is rarely needed and you can use shift.
    • ² and " can be entered with ascii codes
    • To type in ascii codes you will need digits so you will need 6. This is one of the reasons why it is mandatory to keep digits usable 
    • If you need another key in another game you can save another mapper-SVN.map file and choose for example to bind Caps Lock instead of 6
    • If you have a game that needs all your unknown keys you should maybe consider using rpix86 or Wine for that specific game

After all this, your keyboard should now work much better in Dosbox. The good news is that you only have to do it once! 

The pi gamer

No comments:

Post a Comment

Play ET: Legacy on Raspberry Pi [FPS]

🕐🕐 Duration: A few hours 🔧 Difficulty: Easy 🌟🌟🌟🌟 Interest: Hours of fun