Manual. How to actually configure bluetooth gamepads using xboxdrv on RetroPie on Raspberry Pi
-
I have:
Raspberry Pi 3 Model B
-- AC Adapter - Output: 5V, 3000mA
-- SD Card - 64GB
RetroPie v4.3 (Pre-made image)
-- EmulationStastion v2.6.3rp
-- RetroArch v1.6.7
-- Xboxdrv v0.8.8
iPega gamepads
-- PG-9062S (it has real analog triggers)
-- PG-9037 (it has buttons instead triggers)If you don't use xboxdrv for that gamepads, then after configuration buttons (in EmulationStastion) everything works fine in EmulationStastion and terminal (RetroPie uses the python scripts joy2key for that), but in RetroArch that gamepads don't work, the buttons are not configured correctly.
If you want to make gamepads work for RetroArch, you need to know the correct numbers of buttons for RetroArch; in RetroArch - Settings -> Input -> Input User # Binds - and to press the buttons (Of course controlling menu RetroArch by another gamepad or keyboard) then make changes to the config -/opt/retropie/configs/all/retroarch-joypads/<gamepad's name>.cfg
.
After that gamepads will start working in EmulationStastion and RetroArch, but they will stop working in terminal.
Because in the scripts:/opt/retropie/supplementary/runcommand/joy2key.py
and/home/pi/RetroPie-Setup/scriptmodules/supplementary/runcommand/joy2key.py
configuration of gamepads used from/opt/retropie/configs/all/retroarch-joypads/
.
All this is quite inconvenient.Therefore it is necessary to install xboxdrv. This will help to get rid of the above problems. And it allows you to emulate the keyboard by the gamepad, that is necessary, for example in ports like quake3 or in non-Libretro emulators.
To set up gamepads using xboxdrv I will use the guide from RetroPie-Setup/wiki and the xboxdrv manpage .
Ok, start the guide "Universal Controller Calibration & Mapping Using xboxdrv".
If you find that your controller is not listed by name, you can substitute the event number when it comes time.
Yes, I'll do this because I don't have the
/dev/input/by-id/
directory.You can alternatively use the controller's event number if it lacks name designation, by changing
--evdev /dev/input/by-id/[•]
to--evdev /dev/input/event[•]
Yeah.
Bluetooth controllers can potentially present a problem when assigned this way, as their event numbers will shift between powering off and back on again. However, we can assign our own named event designation by first typing:
Ok.
udevadm info -a -n /dev/input/event[•]
Make a note of the 'ATTRS{name}' and then type:In my case this command is unnecessary. I can see the name of gamepad in results of the command -
cat /proc/bus/input/devices
.udevadm info -q all -n /dev/input/event[•]
Make make a note of the 'ID_MODEL' and then type:In my case I don't have that. I hope that's not the problem.
sudo nano /etc/udev/rules.d/85-jseventname.rules
In the resulting text field, type:
ATTRS{name}=="[•]", ENV{DEVNAME}=="/dev/input/event*", ENV{ID_MODEL}="[•]", SYMLINK+="/dev/input/mycontroller"
I will use the file -
/etc/udev/rules.d/99-bluetooth.rules
.
I don't have 'ID_MODEL' of my gamepad. So, I will try this:ATTRS{name}=="PG-9062S", ENV{DEVNAME}=="/dev/input/event*", SYMLINK+="/dev/input/PG-9062S"
It's not working. The link was not created in the
/dev/input/
.ACTION=="add", SUBSYSTEM=="input", ATTRS{name}=="PG-9062S", ENV{DEVNAME}=="/dev/input/event*", SYMLINK+="input/PG-9062S"
It works.
All that is really left is to add the command to /etc/rc.local. To do this type:
sudo nano /etc/rc.local
Press 'Enter" and paste the command into the file above "exit 0".And here we are faced with the main problem. It is assumed that the xboxdrv will run at system startup. But bluetooth gamepads can be disconnected at this point. And then the xboxdrv will not run.
Luckily the xboxdrv has a --daemon mode. Xboxdrv will track the connection of controllers and create for them virtual input devices.
But, it doesn't work))) I spent a lot of time, but i was not able to solve this problem. Probably evdev options and daemon mode are incompatible. In xboxdrv manpage this fact is not specified exactly. But, luckily there are people who confirm my findings - https://github.com/xboxdrv/xboxdrv/issues/195 .What should I do? I'll try to run the xboxdrv when connecting controllers.
Create a script which will run the xboxdrv -/home/pi/gamepads.sh
.
And addRUN
parametr to udev rules in/etc/udev/rules.d/99-bluetooth.rules
:ACTION=="add", SUBSYSTEM=="input", ATTRS{name}=="PG-9062S", ENV{DEVNAME}=="/dev/input/event*", SYMLINK+="input/PG-9062S", RUN+="/home/pi/gamepads.sh"
It works. But the gamepad stops working after a few seconds. In parametr
RUN
we can't run a long script; no difference - in background or not.Systemctl service will help us.
About this and full manual - in my project .About parameters
- detach-kernel-driver - I have not noticed any effect of this parameter.
- mimic-xpad - Very strange effect in my case. If you use my project and remove this parametr, gamepads will not work a few minutes. But later they will start to work.
- trigger-as-button - Required if the controller has buttons instead of triggers (to set
lt
andrt
inevdev-keymap parameter
). For gamepads with real analog triggers - turns the triggers into buttons. - device-usbid - This option requires that the controllers have different
deviceGUID
in/opt/retropie/configs/all/emulationstation/es_input.cfg
.
Thank you for your attention. I will expand this post.
P.S.
- To play quake3 using a gamepad is madness))
- If you think my work (this article and my project) is useful. If you speak good English and you have some free time, you can rewrite the text of this article in normal English and send it to me. I will be very grateful!
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.