Unfortunately, m64py was not a working solution for me and "trial and error" is too cumbersome. Here is a solution anybody currently running mupen64plus, with or without a gui, should be able to use.
You will need the joystick calibration tool
jscal to determine which button is which. For help with that, see Ubuntu Forums - Gaming & Leisure - HOWTO : Joystick/Gamepads under Ubuntu
Assuming you have that set up and your joystick is already calibrated properly, all you need to do is run
jstest-gtk /dev/input/js0 &, where
js0 is the calibration file for the device you are currently testing.
You will see a gui for numbered axes and buttons. It looks something like this:
Now you can press a button on your controller to see which axis or button it corresponds with.
Applying custom controller config to mupen
locate InputAutoCfg.ini. For me this is in the directory
InputAutoCfg.ini in your preferred text editor.
Find your device and edit the settings.
You can find out which device is being used by mupen by running
mupen64plus and looking at the input information printed to your terminal.
Input: N64 Controller #1: Using auto-config with SDL joystick 0 ('Generic X-Box pad'). So for me, the settings are found under
[Generic X-Box pad].
Save/write the changes to the file and the changes should be implemented when you next run
After some changes, mine looks like this:
[Generic X-Box pad]
plugged = True
plugin = 2
mouse = False
AnalogDeadzone = "4096,4096"
AnalogPeak = "32768,32768"
DPad R = "hat(0 Right)"
DPad L = "hat(0 Left)"
DPad D = "hat(0 Down)"
DPad U = "hat(0 Up)"
Start = "button(7)"
Z Trig = "button(4)"
B Button = "button(2)"
A Button = "button(0)"
C Button R = "axis(3+)"
C Button L = "axis(3-)"
C Button D = "axis(4+)"
C Button U = "axis(4-)"
R Trig = "button(5)"
L Trig = "axis(2+)"
Mempak switch = "axis(5+)"
Rumblepak switch = "button(2)"
X Axis = "axis(0-,0+)"
Y Axis = "axis(1-,1+)"
jstest, you should be able to figure out how you want to configure
InputAutoCfg.ini to customize your input settings using the input event words.
Sometimes it helps to look at the N64 controller layout to help figure out the parameters you intend to map.