[SOLVED] Generic Gamepad using xboxdrv in Ubuntu 18.04 based distro - help needed
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Generic Gamepad using xboxdrv in Ubuntu 18.04 based distro - help needed
I followed the guide on this page -> https://steamcommunity.com/app/22141...8653738497361/ to get my generic usb wired gamepad to work on my notebook. But as mentioned in the guide, the initialisation has to be done on each reboot. Also, as mentioned in the guide the initialisation command has to be included in, and I quote, "/etc/rc.local or whatever your distro calls it". I need the location of this "rc.local" in Ubuntu 18.04 based distro (Peppermint 9).
Also, this is my first time connecting a gamepad, so I have done some mistakes along the way, like not assigning the correct key combination for the gamepad. This has resulted in multiple "js" files, like "js0", "js1", .... "js5" input devices, with the "js5" being the successful gamepad entry. Can these additional input "js" devices be removed?
Also, is there a different way to permanently register my gamepad as an input device?
If it helps, the command I used for the last (and the successful) time was: sudo xboxdrv --evdev /dev/input/event21 --evdev-absmap ABS_Z=x1,ABS_Y=y1,ABS_RX=x2,ABS_RZ=y2,ABS_HAT0X=dpad_x,ABS_HAT0Y=dpad_y --axismap -Y1=Y1,-Y2=Y2 --evdev-keymap BTN_TOP=x,BTN_TRIGGER=y,BTN_THUMB2=a,BTN_THUMB=b,BTN_BASE3=back,BTN_BASE4=start,BTN_TOP2=lb,BTN_PINK IE=rb,BTN_BASE=lt,BTN_BASE2=rt,BTN_BASE5=tl,BTN_BASE6=tr --mimic-xpad --silent &
This command showed me an output:
Your Xbox/Xbox360 controller should now be available as:
/dev/input/js5
/dev/input/event22
(In addition, what has to be entered in this "rc.local" file based on the command and output above?)
You don't need xboxdrv. Any guide that recommends it is outdated.
If the problem you're dealing with is that the gamepad's mappings are wrong, then you probably just need to set your SDL_GAMECONTROLLERCONFIG environment variable. You can use this to find the correct value:
If it's something else, then let us know the name of the specific game, whether it's for Linux or Windows, whether youre' using Steam (for Linux), and what problem, exactly, it's having with your gamepad.
I want to use the gamepad for the 'Teddy Floppy Ear - The Race' game on Steam Linux. My gamepad is a very basic gamepad, it is Zebronics Joypad ZEB-200JP. First I just tried to plug and play. I opened the game and there was no reaction on the player character when using the gamepad. So, I searched for a solution and got to the said guide. After trying for a few times, I got the mapping right and the game was playable only for that session. After rebooting the notebook, the game did not respond to the gamepad.
As mentioned, the first few unsuccessful tries created the additional js input devices and the eventxx thingies.
I tried the SDL2 Gamepad Tool. This tool recognised the gamepad as "DragonRise_Inc. Generic USB Joystick" rather than what previously was displayed as just "Generic USB Joystick". and after clicking the 'Set Mapping As Environment Variable' button in this tool, this new name of the gamepad was the one which was showing for the gamepad even after reboot.
Next, as the name of the tool suggests, this tool would be of more help in cases of games that support/are dependant on SDL2. Also, as stated in my above post, I want to use the gamepad for the 'Teddy Floppy Ear - The Race' game on Steam Linux. Maybe this game does not use SDL2 since after using the tool, the gamepad was not working as expected. It seemed like the mapping was wrong. For example, the right key on the D-Pad would make the player car go forward, and so on. I even used the manual mapping option in the tool, but still got the same output.
This tool helped to at least name the gamepad in the system. Next, I was left with solving the problem I was facing earlier. After some more searching the internet, I got to this page: https://askubuntu.com/questions/8866...n-ubuntu-16-10 That page informed that the newer versions of Ubuntu (i.e. >= 16.10) do not have the /etc/rc.local file, but one kind person has put the instructions of creating one. I followed the instructions and created the rc.local file.
Next, I was not satisfied with the additional js input devices, so I searched some more and got to these pages: https://github.com/RetroPie/RetroPie...-Using-xboxdrv and https://retropie.org.uk/forum/topic/...uidance-needed These pages have very dedicated discussion about the xboxdrv command. From these pages I got the command 'sudo killall xboxdrv'. This command removed all the additional js input devices. And showed that calling the command with the name of the gamepad is a better way than using the event number. I also found that the event number changes if there are more/less usb devices attached to the notebook. Here, the gamepad name registered through the SDL2 Gamepad Tool came handy.
Now, I have a working setup. I have the rc.local file with these contents:
#!/bin/bash
The double "sudo killall xboxdrv" command is required in my setup, I do not know the exact reason, but without this double there is a problem of having an additional js input device listed.
The once catch is that, I have to attach the gamepad to the notebook before booting it. If I attach the gamepad after booting the notebook, the gamepad is not initialised. I could just run the commands manually after attaching the gamepad, but it not possible for everyone using my notebook.
My next step is to find a way to create a script file with the commands, so that I can just double click the script file after attaching the gamepad and this would initialise the gamepad. But I have not yet found a way to incorporate the sudo command in a simple script.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.