Key mapper

The key mapper lets you rebind any keyboard key, mouse button, or joystick control to any emulated input event. It is the central tool for customising controls in dosbox-automation - whether you need to swap two keys, assign a gamepad button to a keyboard action, or build a complete controller profile for a keyboard-only game.

Open the key mapper by pressing Ctrl+F1 on Windows/Linux or Cmd+F1 on macOS during gameplay.

The key mapper interface

The key mapper displays a visual layout of a virtual keyboard and joystick. Each element on this layout represents an event - the input that DOSBox reports to the running DOS program. Clicking an event shows its current bindings: the physical keys, buttons, or axes that trigger it.

The interface provides the following controls:

  • Add - Bind a new physical key or button to the selected event. After clicking Add, press the key or button you want to assign.
  • Del - Remove the currently displayed binding from the selected event.
  • Next - Cycle through multiple bindings for the same event (an event can have more than one binding).
  • Exit - Return to the game. All changes are saved automatically.

The modifier checkboxes (mod1, mod2, mod3) let you create modified bindings - for example, requiring Ctrl to be held along with a key. This is how DOSBox's own shortcuts work (e.g., Ctrl+F9 for shutdown).

Remapping keys

To swap two keys (for example, Y and Z on a German keyboard layout):

  1. Open the key mapper (Ctrl+F1 / Cmd+F1 ).
  2. Click the Y key on the virtual keyboard.
  3. Click Del to remove its default binding.
  4. Click Add, then press the physical Z key.
  5. Now click the Z key on the virtual keyboard.
  6. Click Del to remove its default binding.
  7. Click Add, then press the physical Y key.
  8. Click Exit to return to the game.

The same process works for any key - click the event on the virtual layout, remove the old binding, add a new one. All changes are saved automatically to the mapper file. To discard all customisations and start fresh, see Resetting the mapper.

Remapping joystick axes

To invert a joystick axis (e.g., reverse the Y-axis):

  1. Click the top of the Y-axis on the virtual joystick layout.
  2. Click Del to remove the default binding.
  3. Click Add, then push your physical joystick in the opposite direction.
  4. Repeat for the other direction of the same axis.
  5. Click Exit to return to the game.

Mapping controller buttons to keys

The key mapper can bind gamepad buttons to keyboard keys, which is how you play keyboard-only DOS games with a controller. The basic approach:

  1. Configure the game for keyboard-only controls (disable joystick in the game's setup if possible).
  2. In the key mapper, click the key you want to trigger (e.g., the Up arrow on the virtual keyboard).
  3. Click Add, then press the corresponding button or direction on your controller.
  4. Repeat for all keys the game uses.
  5. Click Exit to return to the game.

Tip

When using a controller this way, set joysticktype = hidden in the [joystick] section so the game doesn't detect the controller as a joystick. You may also want to set mouse_capture = nomouse in the [mouse] section to prevent analog stick movement from being interpreted as mouse input.

Mapper files

Mappings are saved to a mapper file - a text file that records every binding. By default, the file is named mapper-sdl2-<version>.map and is stored alongside your primary config file.

You can specify a custom mapper file path via the mapperfile setting in the [sdl] section:

[sdl]
mapperfile = my-game.map

dosbox-automation ships with preconfigured mapper files for many games in the resources/mapperfiles directory. These can be loaded by name:

[sdl]
mapperfile = xbox/doom.map

Mapper file format

Each line in a mapper file maps an event name to one or more bindings:

event_name "binding_1" "binding_2"

For example:

key_esc "key 41" "stick_0 button 6"

This binds both the physical Escape key (key 41) and gamepad button 6 (Xbox Select) to the emulated Escape key.

Binding syntax

Keyboard bindings use the format key <scancode>, optionally followed by modifier flags (mod1, mod2, mod3):

key 41          (Escape)
key 66 mod1     (Ctrl+F9, i.e., mod1 = Ctrl)

Joystick bindings use the format stick_N <type> <id>, where:

  • stick_0 is the first controller
  • button <id> is a button press
  • axis <id> <direction> is an axis movement (0 = negative, 1 = positive)
  • hat <id> <direction> is a D-pad direction (1 = up, 2 = right, 4 = down, 8 = left)

Examples:

stick_0 button 0      (A button)
stick_0 axis 1 0      (left stick up)
stick_0 hat 0 1       (D-pad up)

Modifier bindings let you define a button as a modifier key, then use it in combination with other buttons:

mod_3 "stick_0 button 6"
hand_shutdown "key 66 mod1" "stick_0 button 7 mod3"

This defines gamepad button 6 (Select) as mod3, then binds Select+Start (button 7) to Ctrl+F9 (shutdown).

Xbox controller reference

For convenience, here are the common Xbox controller mappings:

ControlBinding
Astick_0 button 0
Bstick_0 button 1
Xstick_0 button 2
Ystick_0 button 3
LBstick_0 button 4
RBstick_0 button 5
Select / Backstick_0 button 6
Startstick_0 button 7
L3stick_0 button 9
R3stick_0 button 10
D-pad upstick_0 hat 0 1
D-pad rightstick_0 hat 0 2
D-pad downstick_0 hat 0 4
D-pad leftstick_0 hat 0 8
Left stick Xstick_0 axis 0 (0=left, 1=right)
Left stick Ystick_0 axis 1 (0=up, 1=down)
Right stick Xstick_0 axis 3 (0=left, 1=right)
Right stick Ystick_0 axis 4 (0=up, 1=down)
LTstick_0 axis 2 2
RTstick_0 axis 5 2

Note

Button numbers may differ between controller brands. On Linux, you can use jstest to identify the correct IDs for your controller.

Resetting the mapper

If your key mappings get into a broken state, use the --erasemapper command line option to delete the default mapper file and reset all bindings to their defaults.

Warning

--erasemapper only deletes the default mapper file. If you're using a custom mapperfile path, you'll need to delete or edit that file manually.

Configuration settings

The setting below is configured in the [sdl] section.

mapperfile

Path to the mapper file (mapper-sdl2-XYZ.map by default, where XYZ is the current version). Pre-configured maps are bundled in resources/mapperfiles. These can be loaded by name, e.g., with mapperfile = xbox/xenon2.map.

Note

The --erasemapper command line option only deletes the default mapper file.

Limitations

  • Only keyboard keys can be remapped to controller buttons and vice versa. Mouse buttons and mouse movement cannot be mapped through the key mapper.
  • The key mapper interface shows a US keyboard layout regardless of your physical keyboard layout. The bindings work correctly - only the visual representation in the mapper UI uses US layout positions.

For the full list of mappable events and their default bindings, see the Keymapper reference below.

Keymapper reference

The table below lists every mappable action in dosbox-automation. Actions with no default binding can be assigned to any key or button combination through the key mapper.

Event nameDescriptionDefault (Win/Linux)Default (macOS)
mapperOpen key mapperCtrl+F1 Cmd+F1
shutdownExit DOSBoxCtrl+F9 Cmd+F9
fullscrToggle fullscreenAlt+Enter Alt+Enter
restartRestart DOSBoxCtrl+Alt+Home Cmd+Ctrl+Home
pausePause emulationAlt+Pause Cmd+P
capmouseToggle mouse captureCtrl+F10 Cmd+F10
muteMute audioCtrl+F8 Cmd+F8
speedlockToggle turbo speedAlt+F12 Alt+F12
cycledownDecrease CPU cyclesCtrl+F11 Cmd+F11
cycleupIncrease CPU cyclesCtrl+F12 Cmd+F12
reloadshaderReload current shaderCtrl+F2 Cmd+F2
stretchaxToggle stretch axis(none)(none)
incstretchIncrease viewport stretch(none)(none)
decstretchDecrease viewport stretch(none)(none)
previmageadjSelect previous image adjustment(none)(none)
nextimageadjSelect next image adjustment(none)(none)
decimageadjDecrease image adjustment(none)(none)
incimageadjIncrease image adjustment(none)(none)
screenshotScreenshot (default format)Ctrl+F5 Cmd+F5
rawshotRaw screenshot(none)(none)
upscshotUpscaled screenshot(none)(none)
rendshotRendered screenshotAlt+F5 Alt+F5
recwaveRecord audioCtrl+F6 Cmd+F6
caprawmidiRecord MIDICtrl+Alt+F6 Cmd+Alt+F6
videoRecord videoCtrl+F7 Cmd+F7
caprawoplRecord OPL output(none)(none)
swapSwap disk imageCtrl+F4 Cmd+F4
hercpalCycle Hercules paletteF11 F11
monocgapalCycle mono CGA paletteF11 F11
comp_selSelect composite knobF10 F10
comp_incIncrease composite controlF11 F11
comp_decDecrease composite controlAlt+F11 Alt+F11
cgacompToggle CGA composite modeF12 F12
debuggerEnable debuggerAlt+Pause Alt+Pause
jxslJoystick X scalar leftCtrl+Left Cmd+Left
jxsrJoystick X scalar rightCtrl+Right Cmd+Right
jxolJoystick X offset leftAlt+Left Alt+Left
jxorJoystick X offset rightAlt+Right Alt+Right
jxrsJoystick X resetCtrl+Delete Cmd+Delete
jysdJoystick Y scalar downCtrl+Down Cmd+Down
jysuJoystick Y scalar upCtrl+Up Cmd+Up
jyodJoystick Y offset downAlt+Down Alt+Down
jyouJoystick Y offset upAlt+Up Alt+Up
jyrsJoystick Y resetCtrl+Home Cmd+Home

Note

Video adapter-specific actions (hercpal, monocgapal, comp_sel, comp_inc, comp_dec, cgacomp) are only active when the corresponding machine type is emulated.

Joystick calibration actions are only active when use_joy_calibration_hotkeys is enabled.