donkey createjs command launches an interactive tool to create a custom button and axis mapping for your game controller or joystick.
Usage
Description
This interactive command helps you map your game controller’s buttons and axes to Donkeycar controls. It’s useful when:- You have a controller that isn’t pre-configured (not PS3, PS4, Xbox, etc.)
- You want to customize the default button mappings
- You’re using a specialty controller or joystick
- Your controller layout differs from the standard mappings
How It Works
The command launches an interactive session that:- Detects your controller - Identifies connected game controllers
- Maps buttons - Prompts you to press buttons for each function
- Maps axes - Prompts you to move sticks/triggers for steering and throttle
- Saves configuration - Writes the mapping to a JSON file
Interactive Mapping Process
When you run the command, you’ll be prompted to:-
Press the button for each control function:
- Throttle increase/decrease
- Steering left/right
- Mode switching (user, autopilot)
- Recording toggle
- Emergency stop
-
Move the axes for analog controls:
- Steering axis (usually left stick horizontal)
- Throttle axis (usually triggers or right stick vertical)
- Identify any gyroscope axes to ignore
Output File
The command generates a JSON configuration file that maps your controller’s physical inputs to Donkeycar functions. This file is saved and can be loaded by the controller part. Example configuration structure:Using Your Custom Configuration
After creating your joystick configuration:- Note the output file path - The command tells you where the config was saved
-
Update myconfig.py - Point to your custom configuration:
-
Test your mapping - Start your car and verify the controls work correctly:
Tips for Mapping
If you make a mistake during mapping, you can run
donkey createjs again to recreate the configuration.Supported Controllers
While Donkeycar has built-in support for common controllers (PS3, PS4, Xbox, Logitech F710),createjs allows you to use:
- Generic USB game controllers
- Flight joysticks
- Racing wheels
- Custom Arduino-based controllers
- Any controller recognized by your operating system
Troubleshooting
Controller not detected
Controller not detected
If your controller isn’t detected:
- Ensure it’s properly connected (USB or Bluetooth paired)
- Check that the controller works in other applications
- On Linux, verify the controller appears in
/dev/input/ - Install required joystick libraries:
sudo apt-get install joystick jstest-gtk - Test with
jstest /dev/input/js0
Axes inverted or wrong direction
Axes inverted or wrong direction
If steering or throttle goes the wrong direction:
- You can manually edit the JSON file to add axis inversion
- Or re-run
createjsand map the axes carefully - Check the
JOYSTICK_STEERING_SCALEandJOYSTICK_THROTTLE_SCALEin myconfig.py
Buttons don't respond
Buttons don't respond
Alternative: Pre-configured Controllers
For common controllers, you don’t needcreatejs. Just set the controller type in myconfig.py:
Related Commands
donkey createcar- Create a car project that uses the controllerdonkey calibrate- Calibrate motors after setting up controls
Source Code
Implemented indonkeycar/management/joystick_creator.py