Guide: Advanced Controller Mappings
-
@mediamogul
It give me this backJoystick (Xbox Gamepad (userspace driver)) has 6 axes (X, Y, Rx, Ry, Hat0X, Hat0Y) and 13 buttons (BtnX, BtnY, BtnTL, BtnTR, BtnTR2, BtnSelect, BtnStart, BtnMode, BtnThumbL, BtnThumbR, ?, ?, ?). Testing ... (interrupt to exit) Axes: 0: 0 1: 0 2: 0 3: 0 4: 0 5: 0 Buttons: 0:off 1:off 2:off 3:off 4:off 5:off 6:off 7:off 8:off 9:off 10:off 11:off 12:off
And nothing testing, neither evtest.
What that it means? -
So, while the testing interface was up, you didn't get any response from using the touchpad, or from pressing the buttons?
-
@mediamogul
Exactly, I don't get any reponse. I have tested with all the controllers that enable xboxdrv without success. -
I'm afraid that may mean it's not going to work. Usually, if there's an issue, xboxdrv will simply refuse to create the virtual controller and throw an error. The fact that it is created, but has no response likely means there's nothing to troubleshoot and that the two are just not compatible.
-
@mediamogul
Well, thanks for the answer, I'll try to do some tests even though we can not do anything. The best way to test the changes is as follows?sudo killall xboxdrv sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv ((...changes...)) reboot
Thanks for the help!
-
@javisousa20 said in Guide: Advanced Controller Mappings:
The best way to test the changes is as follows?
On something like this, the best advice I can give is to keep throwing ideas at the problem as you have them. Whenever I find myself in uncharted territory, trial and error is often the mother of resolution.
-
@mediamogul
Hi, I think the problem is when I reboot to initialize xboxdrv. I have tried to use the following codesudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv --evdev /dev/input/event1 --evdev-debug --evdev-keymap BTN_LEFT=LB,BTN_RIGHT=RB
It give me this back when I press the
BTN_LEFT
, also withBTN_RIGHT
EV_KEY BTN_LEFT 1 X1: 0 Y1: 0 X2: 0 Y2: 0 du:0 dd:0 dl:0 dr:0 back:0 guide:0 start:0 TL:0 TR:0 A:0 B:0 X:0 Y:0 LB:1 RB:0 LT: 0 RT: 0 EV_KEY BTN_LEFT 0 X1: 0 Y1: 0 X2: 0 Y2: 0 du:0 dd:0 dl:0 dr:0 back:0 guide:0 start:0 TL:0 TR:0 A:0 B:0 X:0 Y:0 LB:0 RB:0 LT: 0 RT: 0 EV_KEY BTN_LEFT 1 X1: 0 Y1: 0 X2: 0 Y2: 0 du:0 dd:0 dl:0 dr:0 back:0 guide:0 start:0 TL:0 TR:0 A:0 B:0 X:0 Y:0 LB:1 RB:0 LT: 0 RT: 0
It seems that the emulation to the LB button works, but when I restart to initialize xboxdrv, the result is lost:
sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv --evdev /dev/input/event1 --evdev-debug EV_KEY BTN_LEFT 1 X1: 0 Y1: 0 X2: 0 Y2: 0 du:0 dd:0 dl:0 dr:0 back:0 guide:0 start:0 TL:0 TR:0 A:0 B:0 X:0 Y:0 LB:0 RB:0 LT: 0 RT: 0 EV_KEY BTN_LEFT 0 X1: 0 Y1: 0 X2: 0 Y2: 0 du:0 dd:0 dl:0 dr:0 back:0 guide:0 start:0 TL:0 TR:0 A:0 B:0 X:0 Y:0 LB:0 RB:0 LT: 0 RT: 0
There may be something that I am doing wrong, Do I have to write it in rc.local?
-
I believe you're right. xboxdrv is allowing the map to happen without error, but when the virtual controller is produced, those buttons don't seem to be communicating as they should. If I had to guess, it may be because you're mapping a mouse event. I've never done that myself and while it's technically possible and xboxdrv doesn't complain, it's just not communicating for some reason.
-
@mediamogul
Is there any way to start xboxdrv without rebooting? Or what is the way to start the configuration of xboxdrv at start? Is it to write the code in rc.local? Because I'm having troubles in that case -
You can always kill it at any time with
sudo killall xboxdrv
When testing, you can just created a script, say in your home folder and launch it to see if it's working. If not, kill it, alter it and launch it again.
-
@mediamogul said in Guide: Advanced Controller Mappings:
You can always kill it at any time with
sudo killall xboxdrv
When testing, you can just created a script, say in your home folder and launch it to see if it's working. If not, kill it, alter it and launch it again.
It would not work for what I try to get, xboxdrv does not modify the first virtual event (ex: event2, js0) if I have not used
killall
before, either through rc.local or a script or directly from the xboxdrv command, but that creates a new event (and new js) that does not appear in /dev /input because it always exceeds the limit of defined controllers for the driver. The problem was that I could not run xboxdrv after I had used the killall command, only if I rebooted... or I don't know how.
But I think I've got it, I should try a script like you said, but for now I've managed to make it work by making the following change inrc.local
:sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv \ --evdev /dev/input/event1 \ --silent \ --mimic-xpad \ --trigger-as-button \ --evdev-keymap BTN_LEFT=LB,BTN_RIGHT=RB,KEY_CONFIG=LT,KEY_SEARCH=RT,KEY_PLAYPAUSE=A,KEY_PREVIOUSSONG=X,KEY_NEXTSONG=B,KEY_VOLUMEUP=Y,KEY_VOLUMEDOWN=back "/opt/retropie/supplementary/xboxdrv/bin/xboxdrv" --daemon --detach --dbus disabled --detach-kernel-driver --id 0 --led 2 --deadzone 4000 --silent --trigger-as-button --next-controller --id 1 --led 3 --deadzone 4000 --silent --trigger-as-button exit 0
The first call is my design for xboxdrv and the second one is the default one when enabling the driver from retropie config.
The problem with this method now comes from that to include that code in rc.local, when loading backpieces at the beginning, instead of entering emulationstation runs xboxdrv as expected from command line, but remains stopped in its last sentence:Your Xbox/Xbox360 controller should now be available as: /dev/input/js0 /dev/input/event2 Press Ctrl-C to quit
But I can't do nothing to quit, skip or enter in emulationstation directamente. (Or I may not know how)
I can only enter emulationstation using SSH. There I can map all the keys and buttons without problems (although I still have to try the touchpad as a joystick).
It is an advance, I would like to take advantage of your knowledge in programming that I don't have to finish polishing it, there may be more interested people. -
@javisousa20 said in Guide: Advanced Controller Mappings:
But I can't do nothing to quit, skip or enter in emulationstation directly. (Or I may not know how)
Ok sorry, I forgot the &. Now it's working well!
When I want to use lxde desktop I can't use the keyboard or mouse, how can I end the xboxdrv process automatically when I want to access the desktop and restart it when I go back to retropie? -
So the virtual controller is preventing you from using a mouse and keyboard in lxde?
-
@mediamogul
Yes, if I runkillall xboxdrv
, I can control it normally again -
Well, as you know, the guide covers a method for starting and stopping xboxdrv maps using the runcommand-onstart/end scripts, but I don't think they come into play for lxde. I've never enabled lxde on my own setup, but I assume a script is created to launch it, located in the RetroPie menu. Making sure to work from a copy of that, you could try altering it to kill xboxdrv at the beginning of the script and relaunching it at the end.
-
@mediamogul
Thanks, I got what I wanted!
This is forruncommand-onstart.sh
#!/bin/sh ### Set variables for your joypad and emulator ### Basic Configuraions - Standard controller mappings minikbd="sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv \ --evdev /dev/input/by-id/usb-6901_2701-if01-event-mouse \ --silent \ --mimic-xpad \ --trigger-as-button \ --evdev-keymap BTN_LEFT=LB,BTN_RIGHT=RB,KEY_CONFIG=LT,KEY_SEARCH=RT,KEY_PLAYPAUSE=A,KEY_PREVIOUSSONG=X,KEY_NEXTSONG=B,KEY_VOLUMEUP=Y,KEY_VOLUMEDOWN=back \" ### 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 emulationstation) $xboxkill joycommand="$minikbd &" eval $joycommand ;; kodi) $xboxkill ;; lxde) $xboxkill ;; esac
And this one for
runcommand-onend.sh
#!/bin/sh sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv >/dev/null \ --evdev /dev/input/by-id/usb-6901_2701-if01-event-mouse \ --silent \ --mimic-xpad \ --trigger-as-button \ --evdev-keymap BTN_LEFT=LB,BTN_RIGHT=RB,KEY_CONFIG=LT,KEY_SEARCH=RT,KEY_PLAYPAUSE=A,KEY_PREVIOUSSONG=X,KEY_NEXTSONG=B,KEY_VOLUMEUP=Y,KEY_VOLUMEDOWN=back \ &
I would like to start from Kodi or Desktop, but if I delete the xboxdrv configuration in
rc.local
, I can not start xboxdrv when I press exit to enter in emulationstation. It does not work either leaving it inrc.local
because it starts desktop/kodi with xboxdrv and does not allow me to use normal controls. Is there any chance of making a change inautostart.sh
or inruncommand-onstart.sh
to autostart running throughruncommand
?On the other hand, I can't emulate the axes of the joystick, the REL_X / Y events go approximately from -60 to 60 depending on the speed with which I move on the touchpad, but I can not get them to work either by calibration, can it be a problem defining them using
--ui-axismap
?Thank you very much!
-
@javisousa20 said in Guide: Advanced Controller Mappings:
I can not start xboxdrv when I press exit to enter in emulationstation.
I suppose you could create a script that can be selected from within lxde that would kill the desktop environment and launch xboxdrv, as well as Emulation Station if necessary. The same can actually be done from within Kodi but it's not as straightforward. You'll need to do some research on script addons, or even ways to add scripts as menu items.
On the other hand, I can't emulate the axes of the joystick, the REL_X / Y events go approximately from -60 to 60 depending on the speed with which I move on the touchpad, but I can not get them to work either by calibration, can it be a problem defining them using --ui-axismap?
I believe defining the outer deadzones as defined in the guide should take care of that. Have you given that a go?
-
@mediamogul said in Guide: Advanced Controller Mappings:
I believe defining the outer deadzones as defined in the guide should take care of that. Have you given that a go?
Yes, I tried to do it but I do not get anything
This is the code I usesudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv \ --evdev /dev/input/by-id/usb-6901_2701-if01-event-mouse \ --mimic-xpad \ --dpad-as-button \ --trigger-as-button \ --deadzone 3 --evdev-keymap BTN_LEFT=LB,BTN_RIGHT=RB,KEY_CONFIG=LT,KEY_SEARCH=RT,KEY_PLAYPAUSE=A,KEY_PREVIOUSSONG=dl,KEY_NEXTSONG=dr,KEY_VOLUMEUP=du,KEY_VOLUMEDOWN=dd,KEY_MAIL=back,KEY_HOMEPAGE=start,KEY_MIN_INTERESTING=B,KEY_WWW=guide \ --ui-axismap x2=REL_X,y2=REL_Y \ --calibration x2=-150:0:150,y2=-150:0:150 \ --evdev-debug
And here part of the test
EV_REL REL_X 10 EV_REL REL_Y -26 X1: 0 Y1: 0 X2: 0 Y2: 0 du:0 dd:0 dl:0 dr:0 back:0 guide:0 start:0 TL:0 TR:0 A:0 B:0 X:0 Y:0 LB:0 RB:0 LT: 0 RT: 0 EV_REL REL_X 6 EV_REL REL_Y -14 X1: 0 Y1: 0 X2: 0 Y2: 0 du:0 dd:0 dl:0 dr:0 back:0 guide:0 start:0 TL:0 TR:0 A:0 B:0 X:0 Y:0 LB:0 RB:0 LT: 0 RT: 0 EV_REL REL_X 2 EV_REL REL_Y -6 X1: 0 Y1: 0 X2: 0 Y2: 0 du:0 dd:0 dl:0 dr:0 back:0 guide:0 start:0 TL:0 TR:0 A:0 B:0 X:0 Y:0 LB:0 RB:0 LT: 0 RT: 0 EV_REL REL_X 4 EV_REL REL_Y -4 X1: 0 Y1: 0 X2: 0 Y2: 0 du:0 dd:0 dl:0 dr:0 back:0 guide:0 start:0 TL:0 TR:0 A:0 B:0 X:0 Y:0 LB:0 RB:0 LT: 0 RT: 0 EV_REL REL_X 2 EV_REL REL_Y -4 X1: 0 Y1: 0 X2: 0 Y2: 0 du:0 dd:0 dl:0 dr:0 back:0 guide:0 start:0 TL:0 TR:0 A:0 B:0 X:0 Y:0 LB:0 RB:0 LT: 0 RT: 0 EV_REL REL_X 2 EV_REL REL_Y -2 X1: 0 Y1: 0 X2: 0 Y2: 0 du:0 dd:0 dl:0 dr:0 back:0 guide:0 start:0 TL:0 TR:0 A:0 B:0 X:0 Y:0 LB:0 RB:0 LT: 0 RT: 0 EV_REL REL_Y -2 X1: 0 Y1: 0 X2: 0 Y2: 0 du:0 dd:0 dl:0 dr:0 back:0 guide:0 start:0 TL:0 TR:0 A:0 B:0 X:0 Y:0 LB:0 RB:0 LT: 0 RT: 0 EV_REL REL_X -2 X1: 0 Y1: 0 X2: 0 Y2: 0 du:0 dd:0 dl:0 dr:0 back:0 guide:0 start:0 TL:0 TR:0 A:0 B:0 X:0 Y:0 LB:0 RB:0 LT: 0 RT: 0 EV_REL REL_X -2 EV_REL REL_Y 4 X1: 0 Y1: 0 X2: 0 Y2: 0 du:0 dd:0 dl:0 dr:0 back:0 guide:0 start:0 TL:0 TR:0 A:0 B:0 X:0 Y:0 LB:0 RB:0 LT: 0 RT: 0 EV_REL REL_X -4 EV_REL REL_Y 4 X1: 0 Y1: 0 X2: 0 Y2: 0 du:0 dd:0 dl:0 dr:0 back:0 guide:0 start:0 TL:0 TR:0 A:0 B:0 X:0 Y:0 LB:0 RB:0 LT: 0 RT: 0 EV_REL REL_X -4 EV_REL REL_Y 10 X1: 0 Y1: 0 X2: 0 Y2: 0 du:0 dd:0 dl:0 dr:0 back:0 guide:0 start:0 TL:0 TR:0 A:0 B:0 X:0 Y:0 LB:0 RB:0 LT: 0 RT: 0 EV_REL REL_X -8 EV_REL REL_Y 30 X1: 0 Y1: 0 X2: 0 Y2: 0 du:0 dd:0 dl:0 dr:0 back:0 guide:0 start:0 TL:0 TR:0 A:0 B:0 X:0 Y:0 LB:0 RB:0 LT: 0 RT: 0
It can be seen that in this case xboxdrv is not reading the REL axes, but I don't know why
-
@mediamogul Hi. I thought you might be interested in something I've just found out with xboxdrv. Not sure if you've already discovered this. It is possible to use the
$3
case inruncommand-onstart.sh
to make an xboxdrv script that works just for one game. I've been messing around withSimCoupe
trying to see whether it has any standardised controls either for keyboard or joystick. It doesn't seem to have any, so, as I only want to play a couple of Sam Coupe games, I thought that it would be a good idea to try to create xboxdrv scripts for individual games. I've got one to work with the extract from myruncommand-onstart.sh
file as follows:I've included some case
$1
scripts just so you can see it in context and, at the bottom , you will see the case$3
script for Manic Miner. This works for me.#!/bin/sh ### Code begins ### Game/ROM full path rom="${3##*/}" ### SAM COUPE - Player1_SAM="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 \ --ui-axismap X1=KEY_Q:KEY_W,Y1=KEY_UP:KEY_DOWN \ --ui-buttonmap a=KEY_SPACE,b=KEY_X,x=KEY_C,y=KEY_UNKNOWN,lb=KEY_UNKNOWN,rb=KEY_UNKNOWN,back=KEY_UNKNOWN,start=KEY_UNKNOWN,lt=KEY_UNKNOWN,rt=KEY_ENTER,rt+back=KEY_F10,back+rt=KEY_LEFTCTRL+KEY_F12" case $1 in crvision) $xboxkill joycommand="$Player1_CreatiVision &" eval $joycommand ;; crvision2) $xboxkill joycommand="$Player1_CreatiVision2 &" eval $joycommand ;; pop1) $xboxkill joycommand="$Player1_POP1 &" eval $joycommand ;; pop2) $xboxkill joycommand="$Player1_POP2 &" eval $joycommand ;; esac case $3 in "/home/pi/RetroPie/roms/samcoupe/Manic Miner (1992) (Revelation Software).sad") $xboxkill joycommand="$Player1_SAM &" eval $joycommand ;; esac
-
@spud11 said in Guide: Advanced Controller Mappings:
Not sure if you've already discovered this. It is possible to use the $3 case in runcommand-onstart.sh to make an xboxdrv script that works just for one game.
I'm glad you posted this and I really should have put it into the guide by now. Individual game mapping comes in handy so often that it needs to be documented. A great example are all the Atari 2600/5200, Intellivision and Colecovision games that use unique keypad controls. Mapping them to something more sane on a modern controller increases their playability so much. Another good example is the Atari 2600 games that originally made use of two joysticks for extra buttons. I just recently made a map for the 2600 port of 'Stargate', that moves 'smartbombs', 'inviso' and 'hyperspace' alongside the normal 'fire' button on the same controller and it plays great.
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.