LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 09-07-2021, 06:28 AM   #1
chomwitt
Member
 
Registered: Jul 2020
Location: Hellas
Distribution: Devuan+XFCE
Posts: 53

Rep: Reputation: Disabled
Detecting if gamepads works on xinput or directinput.


A gamepad has a button to switch between xinput and directinput. but it doesnt tell which mode is on. so is there a way to tell what is active in linux?
 
Old 09-07-2021, 06:30 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 24,190

Rep: Reputation: 7941Reputation: 7941Reputation: 7941Reputation: 7941Reputation: 7941Reputation: 7941Reputation: 7941Reputation: 7941Reputation: 7941Reputation: 7941Reputation: 7941
I guess directinput is MS specific, so xinput works on linux.
 
Old 09-07-2021, 03:17 PM   #3
enigma9o7
Senior Member
 
Registered: Jul 2018
Location: Silicon Valley
Distribution: Bodhi Linux
Posts: 1,516

Rep: Reputation: 589Reputation: 589Reputation: 589Reputation: 589Reputation: 589Reputation: 589
i'm only guessing here, but run "xinput" which will list everything it sees, if your controller not there, flip the switch and try again. if it only shows it on one setting, thats probably the xinput setting.

The main time you flip that switch is if the game you're trying to play doesn't recognize the controller right away.
 
Old 09-07-2021, 04:47 PM   #4
obobskivich
Member
 
Registered: Jun 2020
Posts: 614

Rep: Reputation: Disabled
Run (in terminal)
Code:
usb-devices
and it will show the associated driver with the gamepad (you will also get a lot of other output - since this lists every USB device). The 'xpad' driver is needed for xinput ('xinput' has nothing to do with X.org by the way - its 'xbox input' or some similar shorthand, and is based on the Xbox 360 (and now Xbox One) controller model), top of my head I forget what dinput mode (if supported) will show (probably usbhid)- not all gamepads support it (many newer generic controllers are based on 'xinput' solely since there is good driver support in many systems (Windows, linux, Xbox consoles, some mobile devces, etc) for it). So short version: if it is using xpad as its driver, it is using xinput mode, else it is not using xinput mode. If the gamepad has no switch, and looks vaguely Xbox-shaped, it is probably an xinput device.

More about xpad:
https://github.com/paroj/xpad (this is included in a number of distros OOB at this point as well - I'd be surprised if Debian does not have it)
 
2 members found this post helpful.
Old 09-07-2021, 06:13 PM   #5
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,352

Rep: Reputation: 5385Reputation: 5385Reputation: 5385Reputation: 5385Reputation: 5385Reputation: 5385Reputation: 5385Reputation: 5385Reputation: 5385Reputation: 5385Reputation: 5385
My guess? Run evtest with each mode. The mode where the results look right would be Xinput.

Explanation:

DirectInput is the old joystick protocol where games are expected to provide a GUI to map controller actions to game actions. Xinput is a gamepad protocol where gamepads just report Xbox controller actions. The evtest program will show you the events the kernel see, so I would expect Xinput mode to give results that look more like what you're actually entering. In games, either mode should work transparently because SDL2 remaps those kernel events in userspace. That's why you can just plug in a DualShock 4 (a DirectInput device) and start playing games with it.

Last edited by dugan; 09-08-2021 at 05:17 PM.
 
2 members found this post helpful.
Old 09-08-2021, 07:49 AM   #6
chomwitt
Member
 
Registered: Jul 2020
Location: Hellas
Distribution: Devuan+XFCE
Posts: 53

Original Poster
Rep: Reputation: Disabled
That are some of the values reported from evtest for my steelseries gamepad:
Event: time 1631105189.744713, type 1 (EV_KEY), code 304 (BTN_SOUTH), value 1

Event: time 1631105190.648714, type 1 (EV_KEY), code 307 (BTN_NORTH), value 1

Event: time 1631105191.312708, type 1 (EV_KEY), code 308 (BTN_WEST), value 1

Event: time 1631105191.808715, type 1 (EV_KEY), code 305 (BTN_EAST), value 1

Event: time 1631105234.976764, type 3 (EV_ABS), code 16 (ABS_HAT0X), value -1

Event: time 1631105292.792803, type 3 (EV_ABS), code 0 (ABS_X), value 0


Turning another gamepad to another mode i get from evtest :

Event: time 1631105622.137207, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90003
Event: time 1631105622.137207, type 1 (EV_KEY), code 290 (BTN_THUMB2), value 1

Event: time 1631105635.273205, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90002
Event: time 1631105635.273205, type 1 (EV_KEY), code 289 (BTN_THUMB), value 1

So i guess the second format is direct input.

Last edited by chomwitt; 09-08-2021 at 07:56 AM.
 
Old 09-08-2021, 08:07 AM   #7
chomwitt
Member
 
Registered: Jul 2020
Location: Hellas
Distribution: Devuan+XFCE
Posts: 53

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by obobskivich View Post
Run (in terminal)
Code:
usb-devices
and it will show the associated driver with the gamepad

So i plug an gamepad which says it has a xinput-dinput button:

$ jstest /dev/input/js0
Driver version is 2.1.0.
Joystick (Microsoft X-Box 360 pad) has 8 axes (X, Y, Z, Rx, Ry, Rz, Hat0X, Hat0Y)
and 11 buttons (BtnA, BtnB, BtnX, BtnY, BtnTL, BtnTR, BtnSelect, BtnStart, BtnMode, BtnThumbL, BtnThumbR).


T: Bus=02 Lev=01 Prnt=01 Port=08 Cnt=03 Dev#= 9 Spd=12 MxCh= 0
D: Ver= 2.00 Cls=ff(vend.) Sub=ff Prot=ff MxPS=64 #Cfgs= 1
P: Vendor=045e ProdID=028e Rev=01.10
S: Manufacturer=Microsoft Inc.
S: Product=XBOX 360 For Windows
S: SerialNumber=200FA00
C: #Ifs= 4 Cfg#= 1 Atr=a0 MxPwr=500mA
I: If#=0x0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=5d Prot=01 Driver=xpad
I: If#=0x1 Alt= 0 #EPs= 4 Cls=ff(vend.) Sub=5d Prot=03 Driver=(none)
I: If#=0x2 Alt= 0 #EPs= 1 Cls=ff(vend.) Sub=5d Prot=02 Driver=(none)
I: If#=0x3 Alt= 0 #EPs= 0 Cls=ff(vend.) Sub=fd Prot=13 Driver=(none)

Now i press the aforementioned button for six seconds and:

$ jstest /dev/input/js0
Driver version is 2.1.0.
Joystick (MY-POWER CO.,LTD. USB Joystick) has 7 axes (X, Y, Z, Rz, Hat0X, Hat0Y, (null))
and 12 buttons (Trigger, ThumbBtn, ThumbBtn2, TopBtn, TopBtn2, PinkieBtn, BaseBtn, BaseBtn2, BaseBtn3, BaseBtn4, BaseBtn5, BaseBtn6).

T: Bus=02 Lev=01 Prnt=01 Port=08 Cnt=03 Dev#= 8 Spd=12 MxCh= 0
D: Ver= 1.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1
P: Vendor=0e8f ProdID=0003 Rev=01.09
S: Manufacturer=MY-POWER CO.,LTD.
S: Product=USB Joystick
C: #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=100mA
I: If#=0x0 Alt= 0 #EPs= 2 Cls=03(HID ) Sub=00 Prot=00 Driver=usbhid


So i think my original question is answered . You can discern by using evtest , usb-devices.

Last edited by chomwitt; 09-08-2021 at 08:08 AM.
 
  


Reply

Tags
gamepad, xinput


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Linux Equavalent to DirectInput???? HelloKitty Linux - Software 9 09-11-2018 11:32 AM
Logitech F510 DirectInput-Mode - port gets disconnected/syslog spammed yogo1212 Linux - Hardware 0 03-03-2013 03:44 PM
Fedora 16: Trying to execute an xinput command at boot up before login. Cmd works in terminal as su Ron Pierce Linux - Newbie 1 04-24-2012 09:41 PM
"DirectInput" for POSIX? Whatsisname Programming 1 03-01-2005 07:47 PM
What is linux equal to DirectInput? HelloKitty Linux - Software 1 08-07-2003 06:08 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 08:03 AM.

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