You can find the joystick mapping file here:
/opt/retropie/configs/c64/sdl-joymap-C64.vjm
You’ll need to use the c64 keyboard mapping found here:
http://sta.c64.org/cbm64kbdlay.html
Here’s what you’ll find by default in the joymap file.
# Buttons
0 1 0 0
0 1 1 1 0 16 # this is the “fire” button and is the only one of the A, B, X, Y gamepad buttons assigned.
0 1 2 2
0 1 3 2
To assign one of my unused buttons to trigger the spacebar which is used in so many games, I did this:
{Joystick # 0 1} { Axis 0/Button 1/Hat 2/Ball 3} {Index on joypad 1-9} {Action} (Action Commands) 0 1 1 2 7 4
In this case, joystick 0, axis 1 (button), index 1 (button 1), the spacebar command is Keyboard, row 7, column 4 on the keyboard (look at the keyboard map image)
# Buttons
0 1 0 0 #this button does nothing, I might assign it to F1 key (0 1 0 0 0 4)
0 1 1 1 0 16 # this is the “fire” button
0 1 2 2 7 7 # I have this button mapped to the c64 run/stop key
0 1 3 2 7 4 # I have this button mapped to the space bar
I hope that makes sense.