LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This 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


Reply
  Search this Thread
Old 07-27-2018, 03:03 AM   #1
kamlin
LQ Newbie
 
Registered: Jul 2018
Location: Mumbai
Distribution: Peppermint 9
Posts: 12

Rep: Reputation: Disabled
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?)

Please help.
 
Old 07-27-2018, 06:24 PM   #2
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,219

Rep: Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309
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:

http://generalarcade.com/gamepadtool/

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.

Last edited by dugan; 07-27-2018 at 06:44 PM.
 
Old 07-28-2018, 05:23 AM   #3
kamlin
LQ Newbie
 
Registered: Jul 2018
Location: Mumbai
Distribution: Peppermint 9
Posts: 12

Original Poster
Rep: Reputation: Disabled
Thank you for reply.

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 will try the sdl gamepad tool and respond back.
 
Old 08-05-2018, 02:35 PM   #4
kamlin
LQ Newbie
 
Registered: Jul 2018
Location: Mumbai
Distribution: Peppermint 9
Posts: 12

Original Poster
Rep: Reputation: Disabled
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

sudo killall xboxdrv
sudo killall xboxdrv
sudo xboxdrv --evdev /dev/input/by-id/usb-DragonRise_Inc._Generic_USB_Joystick-event-joystick --silent --mimic-xpad --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_THUMB2=a,BTN_THUMB=b,BTN_TOP=x,BTN_TRIGGER=y,BTN_TOP2=lb,BTN_PINKIE=rb,BTN_BASE=lt,BTN_BASE2=rt, BTN_BASE5=tl,BTN_BASE6=tr,BTN_BASE3=back,BTN_BASE4=start &

exit 0

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.
 
Old 08-14-2018, 06:34 AM   #5
kamlin
LQ Newbie
 
Registered: Jul 2018
Location: Mumbai
Distribution: Peppermint 9
Posts: 12

Original Poster
Rep: Reputation: Disabled
I got a way to make the script (with the sudo) commands from a different forum. The steps are:

1. Create the initialization script, suppose at /home/mark/.my-controller.sh

This script file had these contents:

#!/bin/bash

sudo killall xboxdrv
sudo killall xboxdrv
sudo xboxdrv --evdev /dev/input/by-id/usb-DragonRise_Inc._Generic_USB_Joystick-event-joystick --silent --mimic-xpad --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_THUMB2=a,BTN_THUMB=b,BTN_TOP=x,BTN_TRIGGER=y,BTN_TOP2=lb,BTN_PINKIE=rb,BTN_BASE=lt,BTN_BASE2=rt, BTN_BASE5=tl,BTN_BASE6=tr,BTN_BASE3=back,BTN_BASE4=start &

exit 0

Make this script executable.

2. Edit the sudoers file
In the /etc/sudoers file, enter the following content:

# Added manually
mark ALL = NOPASSWD: /home/mark/.my-controller.sh

Save the sudoers file.

3. Now, you can create a .desktop file to call the above script.

My .desktop file contents:

#!/usr/bin/env xdg-open
[Desktop Entry]
Version=1.0
Name=StartMyGamepad
Comment=To initialize my gamepad
Exec=sakura -e "bash -c 'sudo /home/mark/.my-controller.sh;$SHELL'"
Icon=utilities-terminal
Terminal=false
Type=Application
Categories=Application;

When opening this .desktop file, the terminal is shown that asks for my password, then the script is run.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Ubuntu based distro combos Help needed. GeekTech Linux - Newbie 2 09-21-2012 09:31 PM
How to create an Ubuntu-based distro? KaiZ Linux - Distributions 3 12-17-2011 06:54 PM
Sorce based distro (gentoo) Vs Binary based distro(fedora, debian,..) ashwin_cse Linux - Distributions 7 02-08-2010 01:46 PM
LXer: Ubuntu 9.10 final ships as IBM spins Ubuntu-based cloud distro LXer Syndicated Linux News 0 10-30-2009 08:50 AM
LXer: Is Ubuntu becoming the generic Linux distro? LXer Syndicated Linux News 0 04-03-2008 02:20 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:45 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration