Guide: Advanced Controller Mappings
-
Next, we'll take a look at how to map keyboard keys and mouse movements to a controller's analog sticks and buttons for use in emulators that lack native controller support
I'll be looking forward to this as I think it would be quite handy.
Nice guide Media, well written and easy to follow for us layman folks! ;)
-
@Riverstorm said in Advanced Controller Mappings:
Nice guide Media, well written and easy to follow for us layman folks! ;)
Thanks Riverstorm, I'm glad you like it so far. I had some reservations on being overly detailed, but I've been in the position of following guides before where most of the difficulty came from deciphering the missing steps that were taken for granted by the author and that's never fun. The keyboard mapping will be added soon and is very easy to do. The only part of the guide that will take any time to write is how to maintain multiple mappings, as there are a few options there. However, it shouldn't be too far down the road now. I hope it proves useful and thanks again.
-
great job! :)
-
Thank you much. As I see it, the big difference between RetroPie and the other retro-gaming distributions is the thoughtful inclusion of tools like this that can be leveraged to customize our setups in just about any way imaginable. With the recent addition of control over installation and removal of the emulators, RetroPie is quite literally second to none in customization. So... great job back at you and all the folks who make it possible. :)
-
I am trying to map the buttons on my PS3 controller, but I have no names for the buttons X(302), Triangle(300) and Circle(301).
Event: time 1469807542.183632, type 1 (EV_KEY), code 297 (BTN_BASE4), value 0 Event: time 1469807542.183632, -------------- EV_SYN ------------ Event: time 1469807542.930848, type 1 (EV_KEY), code 298 (BTN_BASE5), value 1 Event: time 1469807542.930848, -------------- EV_SYN ------------ Event: time 1469807543.074988, type 1 (EV_KEY), code 298 (BTN_BASE5), value 0 Event: time 1469807543.074988, -------------- EV_SYN ------------ Event: time 1469807543.684320, type 1 (EV_KEY), code 299 (BTN_BASE6), value 1 Event: time 1469807543.684320, -------------- EV_SYN ------------ Event: time 1469807543.805707, type 1 (EV_KEY), code 299 (BTN_BASE6), value 0 Event: time 1469807543.805707, -------------- EV_SYN ------------ Event: time 1469807544.772830, type 1 (EV_KEY), code 303 (BTN_DEAD), value 1 Event: time 1469807544.772830, -------------- EV_SYN ------------ Event: time 1469807544.930849, type 1 (EV_KEY), code 303 (BTN_DEAD), value 0 Event: time 1469807544.930849, -------------- EV_SYN ------------ Event: time 1469807545.909350, type 1 (EV_KEY), code 300 (?), value 1 Event: time 1469807545.909350, -------------- EV_SYN ------------ Event: time 1469807546.058367, type 1 (EV_KEY), code 300 (?), value 0 Event: time 1469807546.058367, -------------- EV_SYN ------------ Event: time 1469807546.599438, type 1 (EV_KEY), code 301 (?), value 1 Event: time 1469807546.599438, -------------- EV_SYN ------------ Event: time 1469807546.711951, type 1 (EV_KEY), code 301 (?), value 0 Event: time 1469807546.711951, -------------- EV_SYN ------------ Event: time 1469807547.283398, type 1 (EV_KEY), code 302 (?), value 1 Event: time 1469807547.283398, -------------- EV_SYN ------------ Event: time 1469807547.407163, type 1 (EV_KEY), code 302 (?), value 0 Event: time 1469807547.407163, -------------- EV_SYN ------------
It is normal?
My other buttons:D-PAD UP - BTN_TOP2 CODE 292 D-PAD DOWN - BTN_BASE CODE 294 D-PAD LEFT - BTN_BASE2 CODE 295 D-PAD RIGHT - BTN_PINKIE CODE 293 SELECT - BTN_TRIGGER CODE 288 START - BTN_TOP CODE 291 L1 - BTN_BASE5 CODE 298 L2 - BTN_BASE3 CODE 296 R1 - BTN_BASE6 CODE 299 R2 - BTN_BASE4 CODE 297 X - (?) CODE 302 SQUARE "ČTVEREC" - BTN_DEAD CODE 303 TRIANGLE "TROJÚHELNÍK" - (?) CODE 300 CIRCLE "KOLEČKO" - (?) CODE 301 L-ANALOG KLIK - BTN_THUMB CODE 289 R-ANALOG KLIK - BTN_THUMB2 CODE 290 L-ANALOG LEFT - ABS_X MÍNUS L-ANALOG RIGHT - ABS_X PLUS L-ANALOG UP - ABS_Y MÍNUS L-ANALOG DOWN - ABS_Y PLUS R-ANALOG LEFT - ABS_Z MÍNUS R-ANALOG RIGHT - ABS_Z PLUS R-ANALOG UP - ABS_RX MÍNUS R-ANALOG DOWN - ABS_RX PLUS
-
@Mayki said in Advanced Controller Mappings:
It is normal?
I believe first party PS3 controllers have native support in xboxdrv. I don't own a PS3 controller myself, so I was unable to test this, but supposedly it will automatically map the controller for you with the button locations in the same places you'd expect to find them. Try the mapping below and see if it works.
sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv \ --silent \ --detach-kernel-driver \ --force-feedback \ --deadzone-trigger 15% \ --deadzone 4000 \ --mimic-xpad \ &
In this situation, most people will be happy with the automatic button mapping, as the buttons and sticks are more or less in the same location between the two types of controllers, but it is still possible to alter the arrangement by using the
--axismap
and--buttonmap
command arguments. Using the example I just gave above, I'll illustrate this technique below by inverting the Y-axis on the left joystick (useful in some games if you don't like helicopter controls) and also switch the 'A' and 'B' buttons.sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv \ --silent \ --detach-kernel-driver \ --force-feedback \ --deadzone-trigger 15% \ --deadzone 4000 \ --mimic-xpad \ --axismap -y1=y1 \ --buttonmap a=b,b=a \ &
Of course this example can be expanded to include any number of mappings. You could even switch the left and right joysticks completely if needed.
-
When I type in the rc.local:
sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv \ --evdev /dev/input/event2 \ --silent \ --detach-kernel-driver \ --force-feedback \ --deadzone-trigger 15% \ --deadzone 4000 \ --calibration x1=-32767:0:32767,y1=-32767:0:32767,x2=-32767:0:32767,y2=-32767:0:32767 \ --mimic-xpad \ &
Have not noticed any change after the restart, gamepad is still reported as a Playstation 3 controller.
How do I know that it works? -
Drop
--evdev /dev/input/event2 \
and see if that does it. If not, I did a little reading on the PS3 controller and it appears as though you can map those four buttons using my original instructions as follows:--evdev-keymap KEY_#302=a,KEY_#301=b,BTN_DEAD=x,KEY_#300=y
In context, that would look like:
sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv \ --evdev /dev/input/by-id/* \ --silent \ --detach-kernel-driver \ --force-feedback \ --deadzone-trigger 15% \ --deadzone 4000 \ --mimic-xpad \ --evdev-absmap ABS_*=x1,ABS_*=y1,ABS_*=x2,ABS_*=y2,ABS_*=lt,ABS_*=rt,ABS_*=dpad_x,ABS_*=dpad_y \ --evdev-keymap BTN_KEY_#302=a,KEY_#301=b,BTN_DEAD=x,KEY_#300=y,BTN_*=lb,BTN_*=rb,BTN_*=tl,BTN_*=tr,BTN_*=guide,BTN_*=back,BTN_*=start \ &
I hate that I don't have a PS3 controller to test, but maybe that will take care of the issue. If so, I'll add it to the instructions up top.
-
Without success.
Write :cat /proc/bus/input/devices
output:
I: Bus=0006 Vendor=054c Product=0268 Version=0100 N: Name="PLAYSTATION(R)3 Controller" P: Phys= S: Sysfs=/devices/virtual/input/input2 U: Uniq= H: Handlers=event2 js0 B: PROP=0 B: EV=20000b B: KEY=1ffff 0 0 0 0 0 0 0 0 0 B: ABS=7f fc00ffff B: FF=7030000 0 0
write:
ls /dev/input/by-id/
output:
usb-Logitech_USB_Receiver-event-kbd usb-Logitech_USB_Receiver-if01-event-mouse usb-Logitech_USB_Receiver-if01-mouse
No PS3 gamepad on the list.
Unable to add to the line.--evdev /dev/input/by-id/* \
When writing this:
sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv \ --evdev /dev/input/event2 \ --silent \ --detach-kernel-driver \ --force-feedback \ --deadzone-trigger 15% \ --deadzone 4000 \ --mimic-xpad \ &
No change.
When writing this:
sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv \ --silent \ --detach-kernel-driver \ --force-feedback \ --deadzone-trigger 15% \ --deadzone 4000 \ --mimic-xpad \ &
No change. Gamepad is still reported as a Playstation 3 controller.
-
Based on all the information you've given so far, you're configuration should look like this:
sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv \ --evdev /dev/input/event2 \ --silent \ --detach-kernel-driver \ --force-feedback \ --deadzone-trigger 15% \ --deadzone 4000 \ --mimic-xpad \ --dpad-as-button \ --evdev-absmap ABS_X=x1,ABS_Y=y1,ABS_Z=x2,ABS_RZ=y2,ABS_#48=lt,ABS_#49=rt \ --evdev-keymap KEY_#302=a,KEY_#301=b,BTN_DEAD=x,KEY_#300=y,BTN_THUMB=tl,BTN_THUMB2=tr,BTN_BASE5=lb,BTN_BASE6=rb,BTN_TRIGGER=back,KEY_#720=guide,BTN_TOP=start,BTN_TOP2=du,BTN_PINKIE=dr,BTN_BASE=dd,BTN_BASE2=dl \ --calibration x1=-32767:0:32767,y1=-32767:0:32767,x2=-32767:0:32767,y2=-32767:0:32767 \ &
If that doesn't work, we'll have to look at the error that is given. The easiest way to do that is to paste the previous command directly into the terminal minus the final backslash and ampersand. After you press 'Enter', the error will print out if something's wrong.
-
Some success...
pi@retropie:~ $ sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv \ > --evdev /dev/input/event2 \ > --silent \ > --detach-kernel-driver \ > --force-feedback \ > --deadzone-trigger 15% \ > --deadzone 4000 \ > --mimic-xpad \ > --dpad-as-button \ > --evdev-absmap ABS_X=x1,ABS_Y=y1,ABS_Z=x2,ABS_RZ=y2,ABS_#48=lt,ABS_#49=rt \ > --evdev-keymap KEY_#302=a,KEY_#301=b,BTN_DEAD=x,KEY_#300=y,BTN_THUMB=tl,BTN_THUMB2=tr,BTN_BASE5=lb,BTN_BASE6=rb,BTN_TRIGGER=back,KEY_#720=guide,BTN_TOP=start,BTN_TOP2=du,BTN_PINKIE=dr,BTN_BASE=dd,BTN_BASE2=dl \ > --calibration x1=-32767:0:32767,y1=-32767:0:32767,x2=-32767:0:32767,y2=-32767:0:32767 xboxdrv 0.8.8 - http://pingus.seul.org/~grumbel/xboxdrv/ Copyright © 2008-2011 Ingo Ruhnke <grumbel@gmail.com> Licensed under GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This program comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions; see the file COPYING for details. Your Xbox/Xbox360 controller should now be available as: /dev/input/js1 /dev/input/event3 Press Ctrl-C to quit
pi@retropie:~ $ cat /proc/bus/input/devices I: Bus=0003 Vendor=046d Product=c52b Version=0111 N: Name="Logitech USB Receiver" P: Phys=usb-3f980000.usb-1.4/input0 S: Sysfs=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.4/1-1.4:1.0/0003:046D:C52B.0001/input/input0 U: Uniq= H: Handlers=sysrq kbd leds event0 B: PROP=0 B: EV=120013 B: KEY=10000 7 ff800000 7ff febeffdf ffefffff ffffffff fffffffe B: MSC=10 B: LED=1f I: Bus=0003 Vendor=046d Product=c52b Version=0111 N: Name="Logitech USB Receiver" P: Phys=usb-3f980000.usb-1.4/input1 S: Sysfs=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.4/1-1.4:1.1/0003:046D:C52B.0002/input/input1 U: Uniq= H: Handlers=kbd mouse0 event1 B: PROP=0 B: EV=1f B: KEY=3007f 0 0 0 0 83ffff 17aff32d bf544446 0 0 ffff0001 130f97 8b17c000 6773fa d941dfed 9ed680 4400 0 10000002 B: REL=1c3 B: ABS=1 0 B: MSC=10 I: Bus=0006 Vendor=054c Product=0268 Version=0100 N: Name="PLAYSTATION(R)3 Controller" P: Phys= S: Sysfs=/devices/virtual/input/input2 U: Uniq= H: Handlers=js0 event2 B: PROP=0 B: EV=20000b B: KEY=1ffff 0 0 0 0 0 0 0 0 0 B: ABS=7f fc00ffff B: FF=7030000 0 0 I: Bus=0003 Vendor=045e Product=028e Version=0110 N: Name="Microsoft X-Box 360 pad" P: Phys= S: Sysfs=/devices/virtual/input/input5 U: Uniq= H: Handlers=js1 event3 B: PROP=0 B: EV=20000b B: KEY=7cdb03c0 0 0 0 0 0 0 0 0 0 B: ABS=3f B: FF=1 3f870000 0 0
-
Very glad to hear it. Everything looks to be in order from here. If anything else comes up, I'll be around.
-
Write to rc.local:
#!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the script will "exit 0" on success or any other # value on error. # # In order to enable or disable this script just change the execution # bits. # # By default this script does nothing. # Print the IP address _IP=$(hostname -I) || true if [ "$_IP" ]; then printf "My IP address is %s\n" "$_IP" fi sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv \ --evdev /dev/input/event2 \ --silent \ --detach-kernel-driver \ --force-feedback \ --deadzone-trigger 15% \ --deadzone 4000 \ --mimic-xpad \ --dpad-as-button \ --evdev-absmap ABS_X=x1,ABS_Y=y1,ABS_Z=x2,ABS_RZ=y2,ABS_#48=lt,ABS_#49=rt \ --evdev-keymap KEY_#302=a,KEY_#301=b,BTN_DEAD=x,KEY_#300=y,BTN_THUMB=tl,BTN_THUMB2=tr,BTN_BASE5=lb,BTN_BASE6=rb,BTN_TRIGGER=back,KEY_#720=guide,BTN_TOP=start,BTN_TOP2=du,BTN_PINKIE=dr,BTN_BASE=dd,BTN_BASE2=dl \ --calibration x1=-32767:0:32767,y1=-32767:0:32767,x2=-32767:0:32767,y2=-32767:0:32767 \ & exit 0
Restart, when writing this:
cat /proc/bus/input/devices
pi@retropie:~ $ cat /proc/bus/input/devices I: Bus=0003 Vendor=046d Product=c52b Version=0111 N: Name="Logitech USB Receiver" P: Phys=usb-3f980000.usb-1.4/input0 S: Sysfs=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.4/1-1.4:1.0/0003:046D:C52B.0001/input/input0 U: Uniq= H: Handlers=sysrq kbd leds event0 B: PROP=0 B: EV=120013 B: KEY=10000 7 ff800000 7ff febeffdf ffefffff ffffffff fffffffe B: MSC=10 B: LED=1f I: Bus=0003 Vendor=046d Product=c52b Version=0111 N: Name="Logitech USB Receiver" P: Phys=usb-3f980000.usb-1.4/input1 S: Sysfs=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.4/1-1.4:1.1/0003:046D:C52B.0002/input/input1 U: Uniq= H: Handlers=kbd mouse0 event1 B: PROP=0 B: EV=1f B: KEY=3007f 0 0 0 0 83ffff 17aff32d bf544446 0 0 ffff0001 130f97 8b17c000 6773fa d941dfed 9ed680 4400 0 10000002 B: REL=1c3 B: ABS=1 0 B: MSC=10 I: Bus=0006 Vendor=054c Product=0268 Version=0100 N: Name="PLAYSTATION(R)3 Controller" P: Phys= S: Sysfs=/devices/virtual/input/input2 U: Uniq= H: Handlers=event2 js0 B: PROP=0 B: EV=20000b B: KEY=1ffff 0 0 0 0 0 0 0 0 0 B: ABS=7f fc00ffff B: FF=7030000 0 0
Not X-Box 360 gamepad, why?
-
So it's working when you enter it into the command line directly, but not from
/etc/rc.local
?Go ahead and post the entire contents of your/etc/rc.local
so we can take a look at it.EDIT: Nevermind, I see it above.
-
/etc/rc.local :
#!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the script will "exit 0" on success or any other # value on error. # # In order to enable or disable this script just change the execution # bits. # # By default this script does nothing. # Print the IP address _IP=$(hostname -I) || true if [ "$_IP" ]; then printf "My IP address is %s\n" "$_IP" fi sudo /opt/retropie/supplementary/xboxdrv/bin/xboxdrv \ --evdev /dev/input/event2 \ --silent \ --detach-kernel-driver \ --force-feedback \ --deadzone-trigger 15% \ --deadzone 4000 \ --mimic-xpad \ --dpad-as-button \ --evdev-absmap ABS_X=x1,ABS_Y=y1,ABS_Z=x2,ABS_RZ=y2,ABS_#48=lt,ABS_#49=rt \ --evdev-keymap KEY_#302=a,KEY_#301=b,BTN_DEAD=x,KEY_#300=y,BTN_THUMB=tl,BTN_THUMB2=tr,BTN_BASE5=lb,BTN_BASE6=rb,BTN_TRIGGER=back,KEY_#720=guide,BTN_TOP=start,BTN_TOP2=du,BTN_PINKIE=dr,BTN_BASE=dd,BTN_BASE2=dl \ --calibration x1=-32767:0:32767,y1=-32767:0:32767,x2=-32767:0:32767,y2=-32767:0:32767 \ & exit 0
-
Try pasting the command above the line
# Print the IP address
. -
No change. No Xbox gamepad.
-
There's a conflict with the other command in the file that's printing the IP address. I'm not sure how to make them coexist, but the xboxdrv command itself should run without the other.
-
Delete the command in the file that's printing the IP address to rc.local, restart.
pi@retropie:~ $ cat /proc/bus/input/devices I: Bus=0003 Vendor=046d Product=c52b Version=0111 N: Name="Logitech USB Receiver" P: Phys=usb-3f980000.usb-1.4/input0 S: Sysfs=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.4/1-1.4:1.0/0003:046D:C52B.0001/input/input0 U: Uniq= H: Handlers=sysrq kbd leds event0 B: PROP=0 B: EV=120013 B: KEY=10000 7 ff800000 7ff febeffdf ffefffff ffffffff fffffffe B: MSC=10 B: LED=1f I: Bus=0003 Vendor=046d Product=c52b Version=0111 N: Name="Logitech USB Receiver" P: Phys=usb-3f980000.usb-1.4/input1 S: Sysfs=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.4/1-1.4:1.1/0003:046D:C52B.0002/input/input1 U: Uniq= H: Handlers=kbd mouse0 event1 B: PROP=0 B: EV=1f B: KEY=3007f 0 0 0 0 83ffff 17aff32d bf544446 0 0 ffff0001 130f97 8b17c000 6773fa d941dfed 9ed680 4400 0 10000002 B: REL=1c3 B: ABS=1 0 B: MSC=10 I: Bus=0006 Vendor=054c Product=0268 Version=0100 N: Name="PLAYSTATION(R)3 Controller" P: Phys= S: Sysfs=/devices/virtual/input/input2 U: Uniq= H: Handlers=js0 event2 B: PROP=0 B: EV=20000b B: KEY=1ffff 0 0 0 0 0 0 0 0 0 B: ABS=7f fc00ffff B: FF=7030000 0 0
Still no Xbox gamepad.
-
Go ahead and past the contents of the newly modified
rc.local
.
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.