Guide: Advanced Controller Mappings
-
@mediamogul Thanks. I hadn't heard of Texmaster 2009 before, but it looks like a variant of Tetris which is interesting. I'll take a look at that myself.
I'm once again messing around with the
runcommand-onstart
, but this time I'm trying to usecase $3 in
orcase $4 in
. I'd like to try to use autofire for Defender and Stargate. Because these 2 games have a lot of buttons, I'm trying to automate the "fire" button.I've looked at the xboxdrv documentation and there are a couple of different references to autofire.
I've first tried getting autofire to work using the commandline. Xboxdrv works, but autofire doesn't. Would you be able to help please? I'm hoping you might have used autofire before in one of your scripts.
I would like the "X" button (which is third button in my set of first rows of 3 buttons) to autofire. It corresponds to my "space" key.
Here is what I've put into commandline:
sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv \ --silent \ --detach-kernel-driver \ --deadzone=4000 \ --deadzone-trigger 15% \ --force-feedback \ --mimic-xpad \ --trigger-as-button \ --ui-buttonmap tl=void,tr=void,guide=void \ --evdev /dev/input/by-path/platform-3f980000.usb-usb-0:1.3.3:1.0-event-joystick \ --device-name "Player_1" \ --evdev-absmap ABS_X=y1,ABS_Y=x1 \ --evdev-keymap BTN_THUMB2=a,BTN_PINKIE=b,BTN_TRIGGER=x,BTN_THUMB=y,BTN_TOP2=lb,BTN_TOP=rb,BTN_BASE3=back,BTN_BASE6=start,BTN_BASE2=lt,BTN_BASE5=rt \ --ui-axismap X1=KEY_LEFT:KEY_RIGHT,Y1=KEY_UP:KEY_DOWN \ --ui-buttonmap a=KEY_LEFTCTRL,b=KEY_LEFTALT,x=KEY_SPACE,y=KEY_LEFTSHIFT,lb=KEY_C,rb=KEY_V,back=KEY_5+KEY_1,start=KEY_6+KEY_2,lt=KEY_UNKNOWN,rt=KEY_UNKNOWN \ --autofire X=100 \ --ui-buttonmap back+start=macro:/opt/retropie/configs/all/advmame_exit.macro \ &
I've tried a few variations of that autofire command but no luck. Thanks!
-
I'm hoping you might have used autofire before in one of your scripts.
I have in the past, but I don't currently have anything of my own to reference. I seem to remember it working though. Have you tried a higher number? 100ms might be a bit too fast. If you haven't already, try using 250ms to start, as that is the example given in the man page.
-
@mediamogul Thanks. What I did was try
--autofire X=250 \
. I also removed the keyboard commands from the code leaving just the joystick, just in case there was some incompatibility there. Using TAB in AdvMame, I remapped one of the joystick buttons to "X", but still no autofire. The code from commandline is as follows:sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv \ --silent \ --detach-kernel-driver \ --deadzone=4000 \ --deadzone-trigger 15% \ --force-feedback \ --mimic-xpad \ --trigger-as-button \ --ui-buttonmap tl=void,tr=void,guide=void \ --evdev /dev/input/by-path/platform-3f980000.usb-usb-0:1.3.3:1.0-event-joystick \ --device-name "Player_1" \ --evdev-absmap ABS_X=y1,ABS_Y=x1 \ --evdev-keymap BTN_THUMB2=a,BTN_PINKIE=b,BTN_TRIGGER=x,BTN_THUMB=y,BTN_TOP2=lb,BTN_TOP=rb,BTN_BASE3=back,BTN_BASE6=start,BTN_BASE2=lt,BTN_BASE5=rt \ --autofire X=250 \ --ui-buttonmap back+start=macro:/opt/retropie/configs/all/advmame_exit.macro \ &
Xboxdrv definitely works with this code - no errors. Thanks for your help.
-
Glad to see that worked. I might do a little experimentation to see how low the value can be dropped and make a note of it in the guide.
-
@mediamogul Hi mediamogul. Actually, sorry, I didn't explain myself very well. I should have said xboxdrv starts with no errors but the autofire does not work with the code I've supplied.
-
Ah, I see. Well, I'm gonna be gaming a good bit tonight, so I might try to give Stanley a fully automatic upgrade in 'Donkey Kong 3'. I'll let you know how it goes.
-
@mediamogul That would be terrific. Thanks. Hopefully, it's something simple I've missed or misunderstood.
-
OK, I can't speak as to whether or not the method you were using is broken in xboxdrv or not, but I was able to find a better and more flexible way of implementing autofire. Using the 'B' button as an example, the following should work the way you want.
--buttonmap b^autofire:100=b
This method would seem to be better all around, as it even allows you to set one button to act as the autofire equivalent of another. For example:
--buttonmap y^autofire:100=b
would mean that the 'B' button could act normally when pressed, while the 'Y' button would autofire 'B' at 100ms intervals. I haven't used any autofire configs before myself, but I have to admit, this would save a lot of blisters while playing 'Silver Surfer'.
-
@mediamogul said in Guide: Advanced Controller Mappings:
--buttonmap b^autofire:100=b
Thanks so much. That most definitely works. Full code on commandline is:
sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv \ --silent \ --detach-kernel-driver \ --deadzone=4000 \ --deadzone-trigger 15% \ --force-feedback \ --mimic-xpad \ --trigger-as-button \ --ui-buttonmap tl=void,tr=void,guide=void \ --evdev /dev/input/by-path/platform-3f980000.usb-usb-0:1.3.3:1.0-event-joystick \ --device-name "Player_1" \ --evdev-absmap ABS_X=y1,ABS_Y=x1 \ --evdev-keymap BTN_THUMB2=a,BTN_PINKIE=b,BTN_TRIGGER=x,BTN_THUMB=y,BTN_TOP2=lb,BTN_TOP=rb,BTN_BASE3=back,BTN_BASE6=start,BTN_BASE2=lt,BTN_BASE5=rt \ --ui-axismap X1=KEY_LEFT:KEY_RIGHT,Y1=KEY_UP:KEY_DOWN \ --ui-buttonmap a=KEY_LEFTCTRL,b=KEY_LEFTALT,x=KEY_SPACE,y=KEY_LEFTSHIFT,lb=KEY_C,rb=KEY_V,back=KEY_5+KEY_1,start=KEY_6+KEY_2,lt=KEY_UNKNOWN,rt=KEY_UNKNOWN \ --buttonmap x^autofire:100=x \ --ui-buttonmap back+start=macro:/opt/retropie/configs/all/advmame_exit.macro \ &
However, it still requires the kids to hold down the fire button permanently in Defender and I think 2 buttons is all they can really manage - thrust and reverse. I was hoping to try to have it so that the fire button autofires permanently without them having to hold down anything.
There is reference in the manual to the
toggle
function but no explanation as to how to use it. Anyway, I suppose that probably wouldn't work as autofire would probably switch it on and off a zillion times. There's nothing I could see in the manual which would suggest that there is a permanent "on" switch for a button. Thanks for your continuing help. -
I'll experiment with adding a toggle into the mix a little later today. It works as a modifier in much the same that the autofire feature does, so I'm not sure if they'll work together or not.
An alternative in 'Defender' might be to map the fire button to both direction buttons. You'd give up a bit of control, but it would pair it down to two buttons.Edit: After considering how 'Defender' is actually played, that wouldn't really work.
-
@mediamogul - how can I debug the driver ? I am trying to make sure that amiberry is launching and using my config. There seem to be some errors .. but the game launches .. the messages fly by too fast.
Thanks
#!/bin/sh source ~/RetroPie/roms/pc/get_stick_id/stick_id.sh echo $MYCTRL >> /dev/shm/stick.log ## Uncomment one or all of the following if you need to find some information about the emulator or roms ## Name of the emulator echo $1 >> /dev/shm/runcommand.log ## Name of the software used for running the emulation #echo $2 >> /dev/shm/runcommand.log ## Name of the rom #echo $3 >> /dev/shm/runcommand.log ##Executed command line #echo $4 >> /dev/shm/runcommand.log ### The FUN begins #Get ROM name striping full path rom="${3##*/}" ### Set variables for your joypad and emulator ### Basic Configuraions - Standard controller mappings basicPS4="/opt/retropie/supplementary/xboxdrv/bin/xboxdrv \ --evdev=/dev/input/by-id/$MYCTRL \ --silent \ --detach-kernel-driver \ --force-feedback \ --mimic-xpad \ --dpad-as-button \ --deadzone-trigger 15% \ --deadzone 4000 \ --trigger-as-button \ --evdev-absmap ABS_X=x1,ABS_Y=y1,ABS_Z=x2,ABS_RZ=y2,ABS_RX=lt,ABS_RY=rt,ABS_HAT0X=dpad_x,ABS_HAT0Y=dpad_y \ --evdev-keymap BTN_EAST=a,BTN_C=b,BTN_SOUTH=x,BTN_NORTH=y,BTN_WEST=lb,BTN_Z=rb,BTN_START=tl,BTN_SELECT=tr,BTN_THUMBL=guide,BTN_TL2=back,BTN_TR2=start \ --calibration x1=-32767:0:32767,y1=-32767:0:32767,x2=-32767:0:32767,y2=-32767:0:32767" amiga="--axismap -Y1=Y1,-Y2=Y2 \ --ui-axismap x2=REL_X:1,y2=REL_Y:1 \ --ui-axismap x1=KEY_LEFT:KEY_RIGHT,y1=KEY_DOWN:KEY_UP \ --ui-buttonmap lt=BTN_LEFT,rt=BTN_RIGHT,start=KEY_ESC,back=KEY_LEFTCTRL,y=KEY_SPACE,a=KEY_LEFTCTRL,b=KEY_LEFTALT,x=KEY_LEFTSHIFT \ --ui-buttonmap guide=void,tl=void,lt=void,rt=void,back=void \ --ui-axismap x2=void" fourway="--four-way-restrictor" invert="--ui-buttonmap du=KEY_DOWN,dd=KEY_UP" ### Kill Command xboxkill="sudo killall >/dev/null xboxdrv" ### Execute the driver with the configuration you need # $1 is the name of the emulation, not the name of the software used # it is intellivision not jzintv case $1 in amiga) $xboxkill joycommand="$basicPS4 $amiga &" eval $joycommand ;; esac #--ui-buttonmap du=KEY_UP,dd=KEY_DOWN,dl=KEY_LEFT,dr=KEY_RIGHT \
-
how can I debug the driver ?
First, you can try seeing if the command will launch on it's own from the command line. It should bark back any errors that come up. Your particular command should look like:
/opt/retropie/supplementary/xboxdrv/bin/xboxdrv \ --evdev=/dev/input/by-id/$MYCTRL \ --silent \ --detach-kernel-driver \ --force-feedback \ --mimic-xpad \ --dpad-as-button \ --deadzone-trigger 15% \ --deadzone 4000 \ --trigger-as-button \ --evdev-absmap ABS_X=x1,ABS_Y=y1,ABS_Z=x2,ABS_RZ=y2,ABS_RX=lt,ABS_RY=rt,ABS_HAT0X=dpad_x,ABS_HAT0Y=dpad_y \ --evdev-keymap BTN_EAST=a,BTN_C=b,BTN_SOUTH=x,BTN_NORTH=y,BTN_WEST=lb,BTN_Z=rb,BTN_START=tl,BTN_SELECT=tr,BTN_THUMBL=guide,BTN_TL2=back,BTN_TR2=start \ --calibration x1=-32767:0:32767,y1=-32767:0:32767,x2=-32767:0:32767,y2=-32767:0:32767 \ --axismap -Y1=Y1,-Y2=Y2 \ --ui-axismap x2=REL_X:1,y2=REL_Y:1 \ --ui-axismap x1=KEY_LEFT:KEY_RIGHT,y1=KEY_DOWN:KEY_UP \ --ui-buttonmap lt=BTN_LEFT,rt=BTN_RIGHT,start=KEY_ESC,back=KEY_LEFTCTRL,y=KEY_SPACE,a=KEY_LEFTCTRL,b=KEY_LEFTALT,x=KEY_LEFTSHIFT \ --ui-buttonmap guide=void,tl=void,lt=void,rt=void,back=void \ --ui-axismap x2=void
-
@mediamogul thanks ... I am creating two logs to try and nail this down ... one just logs the controller name I am using system wide , the other logs the runcommand $1
The have the following line in them
runcommand.log hasamiga
xboxdrv.log has
usb-Sony_Interactive_Entertainment_Wireless_Controller-if03-event-joystick
Here is my runcommand-onstart.sh
#!/bin/sh source /opt/retropie/configs/all/get_id.sh ## Uncomment one or all of the following if you need to find some information about the emulator or roms ## Name of the emulator echo $MYCTRL >> /opt/retropie/configs/all/xboxdrv_logs/xboxdrv.log echo $1 >> /opt/retropie/configs/all/xboxdrv_logs/runcommand.log ## Name of the software used for running the emulation #echo $2 >> /dev/shm/runcommand.log ## Name of the rom #echo $3 >> /dev/shm/runcommand.log ##Executed command line #echo $4 >> /dev/shm/runcommand.log ### The FUN begins #Get ROM name striping full path rom="${3##*/}" echo $rom >> /opt/retropie/configs/all/xboxdrv_logs/rom.log ### Set variables for your joypad and emulator ### Basic Configuraions - Standard controller mappings basicPS4="/opt/retropie/supplementary/xboxdrv/bin/xboxdrv \ --evdev=/dev/input/by-id/$MYCTRL \ --silent \ --detach-kernel-driver \ --force-feedback \ --mimic-xpad \ --dpad-as-button \ --deadzone-trigger 15% \ --deadzone 4000 \ --trigger-as-button \ --evdev-absmap ABS_X=x1,ABS_Y=y1,ABS_Z=x2,ABS_RZ=y2,ABS_RX=lt,ABS_RY=rt,ABS_HAT0X=dpad_x,ABS_HAT0Y=dpad_y \ --evdev-keymap BTN_EAST=a,BTN_C=b,BTN_SOUTH=x,BTN_NORTH=y,BTN_WEST=lb,BTN_Z=rb,BTN_START=tl,BTN_SELECT=tr,BTN_THUMBL=guide,BTN_TL2=back,BTN_TR2=start \ --calibration x1=-32767:0:32767,y1=-32767:0:32767,x2=-32767:0:32767,y2=-32767:0:32767" amiga="--axismap -Y1=Y1,-Y2=Y2 \ --device-name "Amiga Joy" \ --ui-axismap x2=REL_X:1,y2=REL_Y:1 \ --ui-axismap x1=KEY_LEFT:KEY_RIGHT,y1=KEY_DOWN:KEY_UP \ --ui-buttonmap lt=BTN_LEFT,rt=BTN_RIGHT,start=KEY_ESC,back=KEY_LEFTCTRL,y=KEY_SPACE,a=KEY_LEFTCTRL,b=KEY_LEFTALT,x=KEY_LEFTSHIFT \ fourway="--four-way-restrictor" invert="--ui-buttonmap du=KEY_DOWN,dd=KEY_UP" ### Kill Command xboxkill="sudo killall >/dev/null xboxdrv" ### Execute the driver with the configuration you need # $1 is the name of the emulation, not the name of the software used # it is intellivision not jzintv case $1 in amiga) $xboxkill joycommand="$basicPS4 $amiga &" echo $joycommand >> /opt/retropie/configs/all/xboxdrv_logs/joycommand.log eval $joycommand ;; esac
I was expecting to see a new controller named 'Amiga Joy" when running the cat command via ssh. But is seems like we are never hitting the amiga) section of the case statement because the joycommand.log file never gets generated. It is running the runcommand-onstart though and its also creating a rom.log from the rom variable. Its just not getting into the amiga subroutine at all.
-
Earlier you had poster the error you received from the command itself. When I posted the example command above, I missed the
$MYCTRL
variable. Try it again with the actual controller ID to see if the basic command works on it's own.As far as you runcommand script goes, I believe:
--calibration x1=-32767:0:32767,y1=-32767:0:32767,x2=-32767:0:32767,y2=-32767:0:32767"
Should be:
--calibration x1=-32767:0:32767,y1=-32767:0:32767,x2=-32767:0:32767,y2=-32767:0:32767 \"
-
@mediamogul OK ... I am getting much closer .. my problem earlier was because I was concatenating the device_name incorrectly ... I needed to escape the quotes around the name.
so that line reads like this now
--device-name \"Amiga Joy\" \
I also added sudo in front of the /
basicPS4="sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv \
The output in the shell is :
Your Xbox/Xbox360 controller should now be available as: /dev/input/js1 /dev/input/event3 Press Ctrl-C to quit
running cat reveals :
I: Bus=0003 Vendor=045e Product=028e Version=0110 N: Name="Amiga Joy" P: Phys= S: Sysfs=/devices/virtual/input/input3 U: Uniq= H: Handlers=kbd mouse1 event3 B: PROP=0 B: EV=200007 B: KEY=70c003c0 30000 0 0 0 0 1680 0 3000400 20000002 B: REL=3 B: FF=1 3f870000 0 0
the log i wrote looks like this
usb-Sony_Interactive_Entertainment_Wireless_Controller-if03-event-joystick sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv --evdev=/dev/input/by-id/usb-Sony_Interactive_Entertainment_Wireless_Controller-if03-event-joystick --silent --detach-kernel-driver --force-feedback --mimic-xpad --dpad-as-button --deadzone-trigger 15% --deadzone 4000 --trigger-as-button --evdev-absmap ABS_X=x1,ABS_Y=y1,ABS_Z=x2,ABS_RZ=y2,ABS_RX=lt,ABS_RY=rt,ABS_HAT0X=dpad_x,ABS_HAT0Y=dpad_y --evdev-keymap BTN_EAST=a,BTN_C=b,BTN_SOUTH=x,BTN_NORTH=y,BTN_WEST=lb,BTN_Z=rb,BTN_START=tl,BTN_SELECT=tr,BTN_THUMBL=guide,BTN_TL2=back,BTN_TR2=start --calibration x1=-32767:0:32767,y1=-32767:0:32767,x2=-32767:0:32767,y2=-32767:0:32767 --axismap -Y1=Y1,-Y2=Y2 --device-name "Amiga Joy" --ui-axismap x2=REL_X:1,y2=REL_Y:1 --ui-axismap x1=KEY_LEFT:KEY_RIGHT,y1=KEY_DOWN:KEY_UP --ui-buttonmap lt=BTN_LEFT,rt=BTN_RIGHT,start=KEY_ESC,back=KEY_LEFTCTRL,y=KEY_SPACE,a=KEY_LEFTCTRL,b=KEY_LEFTALT,x=KEY_LEFTSHIFT &
I must be doing something wrong though because running this stops the dpad and joystick from working at all in emulations station. Unless I need to configure input again in emulation station.
-
Unless I need to configure input again in emulation station.
You might have to. I'd definitely try that first.
-
@mediamogul Hi mediamogul. I never really sorted out the autofire for Defender in the way I hoped (ie I was hoping that it would just autofire constantly without holding down the button), but it is good enough for now. Thanks for your help on this.
I've now turned to the Amstrad CPC with lr-caprice32. It's working very well with xboxdrv, but I am having one problem. When I bring up the virtual keyboard with F9, it expects me to use a mouse to navigate. My bluetooth keyboard which has a built in touchpad works perfectly.
I've tried to replicate the mouse/touchpad by using my joystick as a mouse in the virtual keyboard. I've set up the right trigger to act as the modifier. I know the right trigger works because if I am in game and I press the right trigger, the joystick no longer operates; if I press the right trigger again, the joystick works again.
However, in the virtual keyboard GUI, moving joystick does nothing. Could you please have a look at my code? I was wondering whether the "rt" needed to be mapped to a key (for example). Thanks for any help.
sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv > /dev/null 2>&1 \ --silent \ --detach-kernel-driver \ --deadzone=4000 \ --deadzone-trigger 15% \ --force-feedback \ --mimic-xpad \ --trigger-as-button \ --ui-buttonmap tl=void,tr=void,guide=void \ --evdev /dev/input/by-path/platform-3f980000.usb-usb-0:1.3.3:1.0-event-joystick \ --device-name "Player_1" \ --evdev-absmap ABS_X=y1,ABS_Y=x1 \ --evdev-keymap BTN_THUMB2=a,BTN_PINKIE=b,BTN_TRIGGER=x,BTN_THUMB=y,BTN_TOP2=lb,BTN_TOP=rb,BTN_BASE3=back,BTN_BASE6=start,BTN_BASE2=lt,BTN_BASE5=rt \ --buttonmap rt^toggle=rt \ --ui-axismap rt+x1=REL_X:20,rt+y1=REL_Y:20 \ --ui-buttonmap a=KEY_X,b=KEY_Y,x=KEY_SPACE,y=KEY_ENTER,lb=KEY_1,rb=KEY_2,back=KEY_3,start=KEY_4,lt=KEY_5 \ --ui-axismap X1=KEY_LEFT:KEY_RIGHT,Y1=KEY_UP:KEY_DOWN \ --ui-buttonmap back+start=KEY_SPACE+KEY_ESC \ --ui-buttonmap start+back=KEY_F9 \ &
-
Your command appears to be right on the money. Also, from the activity that you've described, it's doing everything as it should. It could be that lr-caprice32 will only make use mouse0. Are any other mice attached while you're attempting all this. If so, try having them disconnected beforehand.
-
@mediamogul That's a good point. There are 2 other mice set up as home made spinners plus a trackball. It would be a bit fiddly to remove them so, unless there's something else I can do, I suppose I'll just have to use my bluetooth keyboard instead for the time being. Thanks for your help.
-
There are 2 other mice set up as home made spinners plus a trackball.
If they're not being used in lr-caprice32, you might be able to temporarily blacklist them from the
runcommand-onstart.sh
and then re-enable them in theruncommand-onend.sh
. Granted, I don't know if this is even possible, but it might be worth exploring.
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.