Author Topic: USB gamepad - anyone have one, happy to test alternative detection?  (Read 14364 times)

jamo

  • Guru
  • ****
  • Posts: 463
    • View Profile
    • LMCE user Page
http://forum.linuxmce.org/index.php/topic,12645.msg90246.html#msg90246

refers...

The issue is this- the gamepad detection and install scripts use the existence of /dev/js0 as the trigger for adding this device. Unfortunately /dev/js0 is also added for at least one other device (internal notebook accelerometer as per above post).

I would like to modify the detection and install scripts to use another method to find the gamepad. I'm thinking the output of lsusb for example... but I don't have a gamepad to test. If anyone has one, please can they assist with testing and post the output of
Code: [Select]
lsusb -v
(obviously this will be executed after sshing into the media director to which the gamepad is connected) for me.

Ta.

PS, if anyone else with actual skills wants to take this over, feel free ;-)

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5549
  • DOES work for LinuxMCE.
    • View Profile
Re: USB gamepad - anyone have one, happy to test alternative detection?
« Reply #1 on: July 02, 2012, 06:44:10 pm »
I would probably talk to udev to get usb joystick devices.

-Thom

Marie.O

  • Administrator
  • LinuxMCE God
  • *****
  • Posts: 3676
  • Wastes Life On LinuxMCE Since 2007
    • View Profile
    • My Home
Re: USB gamepad - anyone have one, happy to test alternative detection?
« Reply #2 on: July 02, 2012, 06:55:42 pm »
What's wrong with a notebooks accelerometer to be used as a game pad?

jamo

  • Guru
  • ****
  • Posts: 463
    • View Profile
    • LMCE user Page
Re: USB gamepad - anyone have one, happy to test alternative detection?
« Reply #3 on: July 02, 2012, 06:58:07 pm »
What's wrong with a notebooks accelerometer to be used as a game pad?
My daughter asked the same question.

jamo

  • Guru
  • ****
  • Posts: 463
    • View Profile
    • LMCE user Page
Re: USB gamepad - anyone have one, happy to test alternative detection?
« Reply #4 on: July 02, 2012, 07:36:09 pm »
I would probably talk to udev to get usb joystick devices.

-Thom
Alright,

*after much reading*

Someone that has a USB gamepad that they would like to continue using in the next release of the next snapshot of the next update of the wonderful and all-powerful LinuxMCE 10.04, please post their output from
Code: [Select]
udevadm info --query property --name /dev/input/js0

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5549
  • DOES work for LinuxMCE.
    • View Profile
Re: USB gamepad - anyone have one, happy to test alternative detection?
« Reply #5 on: July 02, 2012, 07:55:31 pm »
Non-joystick:

Code: [Select]
UDEV_LOG=3
DEVPATH=/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.5/1-1.5.1/1-1.5.1:1.1/inpu                                                                                        t/input6/js0
MAJOR=13
MINOR=0
DEVNAME=/dev/input/js0
SUBSYSTEM=input
ID_INPUT=1
ID_INPUT_MOUSE=1
ID_VENDOR=American_Megatrends_Inc.
ID_VENDOR_ENC=American\x20Megatrends\x20Inc.
ID_VENDOR_ID=046b
ID_MODEL=Virtual_Keyboard_and_Mouse
ID_MODEL_ENC=Virtual\x20Keyboard\x20and\x20Mouse
ID_MODEL_ID=ff10
ID_REVISION=0100
ID_SERIAL=American_Megatrends_Inc._Virtual_Keyboard_and_Mouse_serial
ID_SERIAL_SHORT=serial
ID_TYPE=hid
ID_BUS=usb
ID_USB_INTERFACES=:030101:030102:
ID_USB_INTERFACE_NUM=01
ID_USB_DRIVER=usbhid
ID_PATH=pci-0000:00:1a.0-usb-0:1.5.1:1.1
DEVLINKS=/dev/char/13:0 /dev/input/by-id/usb-American_Megatrends_Inc._Virtual_Ke                                                                                        yboard_and_Mouse_serial-mouse /dev/input/by-path/pci-0000:00:1a.0-usb-0:1.5.1:1.                                                                                        1-mouse

Joystick:

root@moon36:~# udevadm info --query property --name /dev/input/js0

Code: [Select]
UDEV_LOG=3
DEVPATH=/devices/pci0000:00/0000:00:1d.3/usb5/5-2/5-2:1.0/input/input4/js0
MAJOR=13
MINOR=0
DEVNAME=/dev/input/js0
SUBSYSTEM=input
ID_INPUT=1
ID_INPUT_JOYSTICK=1
ID_VENDOR=Logitech
ID_VENDOR_ENC=Logitech
ID_VENDOR_ID=046d
ID_MODEL=Logitech_Cordless_RumblePad_2
ID_MODEL_ENC=Logitech\x20Cordless\x20RumblePad\x202
ID_MODEL_ID=c219
ID_REVISION=0305
ID_SERIAL=Logitech_Logitech_Cordless_RumblePad_2
ID_TYPE=hid
ID_BUS=usb
ID_USB_INTERFACES=:030000:
ID_USB_INTERFACE_NUM=00
ID_USB_DRIVER=usbhid
ID_PATH=pci-0000:00:1d.3-usb-0:2:1.0
ACL_MANAGE=1
note the ID_INPUT_JOYSTICK=1 property.

-Thom

jamo

  • Guru
  • ****
  • Posts: 463
    • View Profile
    • LMCE user Page
Re: USB gamepad - anyone have one, happy to test alternative detection?
« Reply #6 on: July 02, 2012, 10:30:51 pm »
Thanks. I may be getting somewhere on the AVWizard_Gamepad_Detect part but now for the polling script... Gamepad_Detect....

Thom, would you mind posting the output of
Code: [Select]
udevadm info --attribute-walk --name /dev/input/js0
from your joystick machine?

Ta

Edit: Almost forgot- please also check that the following script returns what you expect from your two machines-
http://pastebin.com/r1bsRXNt
« Last Edit: July 02, 2012, 10:33:56 pm by jamo »

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5549
  • DOES work for LinuxMCE.
    • View Profile
Re: USB gamepad - anyone have one, happy to test alternative detection?
« Reply #7 on: July 02, 2012, 11:50:24 pm »
root@moon36:~# udevadm info --attribute-walk --name /dev/input/js0
Code: [Select]
Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

  looking at device '/devices/pci0000:00/0000:00:1d.3/usb5/5-2/5-2:1.0/input/input4/js0':
    KERNEL=="js0"
    SUBSYSTEM=="input"
    DRIVER==""

  looking at parent device '/devices/pci0000:00/0000:00:1d.3/usb5/5-2/5-2:1.0/input/input4':
    KERNELS=="input4"
    SUBSYSTEMS=="input"
    DRIVERS==""
    ATTRS{name}=="Logitech Logitech Cordless RumblePad 2"
    ATTRS{phys}=="usb-0000:00:1d.3-2/input0"
    ATTRS{uniq}==""
    ATTRS{modalias}=="input:b0003v046DpC219e0111-e0,1,3,4,15,k130,131,132,133,134,135,136,137,138,139,13A,13B,ra0,1,2,5,10,11,m4,lsf50,51,58,59,5A,60,w"

  looking at parent device '/devices/pci0000:00/0000:00:1d.3/usb5/5-2/5-2:1.0':
    KERNELS=="5-2:1.0"
    SUBSYSTEMS=="usb"
    DRIVERS=="usbhid"
    ATTRS{bInterfaceNumber}=="00"
    ATTRS{bAlternateSetting}==" 0"
    ATTRS{bNumEndpoints}=="02"
    ATTRS{bInterfaceClass}=="03"
    ATTRS{bInterfaceSubClass}=="00"
    ATTRS{bInterfaceProtocol}=="00"
    ATTRS{modalias}=="usb:v046DpC219d0305dc00dsc00dp00ic03isc00ip00"
    ATTRS{supports_autosuspend}=="1"

  looking at parent device '/devices/pci0000:00/0000:00:1d.3/usb5/5-2':
    KERNELS=="5-2"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{configuration}=="PACER-X03.05_A"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bmAttributes}=="80"
    ATTRS{bMaxPower}==" 98mA"
    ATTRS{urbnum}=="21"
    ATTRS{idVendor}=="046d"
    ATTRS{idProduct}=="c219"
    ATTRS{bcdDevice}=="0305"
    ATTRS{bDeviceClass}=="00"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{bMaxPacketSize0}=="8"
    ATTRS{speed}=="12"
    ATTRS{busnum}=="5"
    ATTRS{devnum}=="3"
    ATTRS{version}==" 2.00"
    ATTRS{maxchild}=="0"
    ATTRS{quirks}=="0x0"
    ATTRS{authorized}=="1"
    ATTRS{manufacturer}=="Logitech"
    ATTRS{product}=="Logitech Cordless RumblePad 2"

  looking at parent device '/devices/pci0000:00/0000:00:1d.3/usb5':
    KERNELS=="usb5"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{configuration}==""
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bmAttributes}=="e0"
    ATTRS{bMaxPower}=="  0mA"
    ATTRS{urbnum}=="59"
    ATTRS{idVendor}=="1d6b"
    ATTRS{idProduct}=="0001"
    ATTRS{bcdDevice}=="0206"
    ATTRS{bDeviceClass}=="09"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{speed}=="12"
    ATTRS{busnum}=="5"
    ATTRS{devnum}=="1"
    ATTRS{version}==" 1.10"
    ATTRS{maxchild}=="2"
    ATTRS{quirks}=="0x0"
    ATTRS{authorized}=="1"
    ATTRS{manufacturer}=="Linux 2.6.32-41-generic uhci_hcd"
    ATTRS{product}=="UHCI Host Controller"
    ATTRS{serial}=="0000:00:1d.3"
    ATTRS{authorized_default}=="1"

  looking at parent device '/devices/pci0000:00/0000:00:1d.3':
    KERNELS=="0000:00:1d.3"
    SUBSYSTEMS=="pci"
    DRIVERS=="uhci_hcd"
    ATTRS{vendor}=="0x8086"
    ATTRS{device}=="0x27cb"
    ATTRS{subsystem_vendor}=="0x19da"
    ATTRS{subsystem_device}=="0xa140"
    ATTRS{class}=="0x0c0300"
    ATTRS{irq}=="16"
    ATTRS{local_cpus}=="ff"
    ATTRS{local_cpulist}=="0-7"
    ATTRS{modalias}=="pci:v00008086d000027CBsv000019DAsd0000A140bc0Csc03i00"
    ATTRS{enable}=="1"
    ATTRS{broken_parity_status}=="0"
    ATTRS{msi_bus}==""

  looking at parent device '/devices/pci0000:00':
    KERNELS=="pci0000:00"
    SUBSYSTEMS==""
    DRIVERS==""

jamo

  • Guru
  • ****
  • Posts: 463
    • View Profile
    • LMCE user Page
Re: USB gamepad - anyone have one, happy to test alternative detection?
« Reply #8 on: July 03, 2012, 09:50:26 pm »
Thom... I need some help here, buddy. The breadcrumb trail has got me this far only.

Here's the install and detect system as I understand it:

At Boot Time:
==========
AVWizard_Run.sh (which runs every boot if I recall):
calls: AVWizard_Gamepad_Detect.sh, which, in turn:
  1. installs lmce-usb-gamepad (if it thinks it's needed)
  2. returns "/usr/pluto/bin/USB_Game_Pad -l /var/log/pluto/avremote.log -r dcerouter -d -1003 -H localhost -P " or something to that effect.
AVWizard_Run.sh then sets the returned value in 2) to the environment variable GamepadCmd.

OK, so the package is installed if required, but I can't see why the GamepadCmd variable is set because I can't figure out where/if it's ever used?

Every 5 seconds:
=============
Gamepad_Detect.sh
  1. If gamepad not already running but it is detected, send appropriate message to dcerouter.

----------------------------------
So what I'm thinking is that instead of polling every 5 seconds, we just setup a rule in the udev system that detects the gamepad either on boot or on plug in and fires off a script that does the whole shebang- installs the package (if not installed) and sends the message to the router.

The only snag is... that "GamepadCmd" bit... what is that used for and where does it come in. Is it a necessary step I'm missing out?

Esperanto

  • Guru
  • ****
  • Posts: 281
    • View Profile
Re: USB gamepad - anyone have one, happy to test alternative detection?
« Reply #9 on: February 02, 2013, 09:25:43 am »
2 gamepads

XBox Wireless
Code: [Select]
[57094.440019] usb 2-1: new full speed USB device using ohci_hcd and address 7
[57094.657316] input: Generic X-Box pad as /devices/pci0000:00/0000:00:02.0/usb2/2-1/2-1:1.0/input/input11
[57094.657594] input: Generic X-Box pad as /devices/pci0000:00/0000:00:02.0/usb2/2-1/2-1:1.2/input/input12
[57094.657840] input: Generic X-Box pad as /devices/pci0000:00/0000:00:02.0/usb2/2-1/2-1:1.4/input/input13
[57094.658084] input: Generic X-Box pad as /devices/pci0000:00/0000:00:02.0/usb2/2-1/2-1:1.6/input/input14
-----
# udevadm info --query property --name /dev/input/js0
UDEV_LOG=3
DEVPATH=/devices/pci0000:00/0000:00:02.0/usb2/2-1/2-1:1.0/input/input11/js0
MAJOR=13
MINOR=0
DEVNAME=/dev/input/js0
SUBSYSTEM=input
ID_INPUT=1
ID_INPUT_JOYSTICK=1
ID_VENDOR=045e
ID_VENDOR_ENC=045e
ID_VENDOR_ID=045e
ID_MODEL=0291
ID_MODEL_ENC=0291
ID_MODEL_ID=0291
ID_REVISION=0107
ID_SERIAL=045e_0291
ID_TYPE=generic
ID_BUS=usb
ID_USB_INTERFACES=:ff5d81:ff5d82:
ID_USB_INTERFACE_NUM=00
ID_USB_DRIVER=xpad
ID_PATH=pci-0000:00:02.0-usb-0:1:1.0
ACL_MANAGE=1
DEVLINKS=/dev/char/13:0 /dev/input/by-id/usb-045e_0291-joystick /dev/input/by-path/pci-0000:00:02.0-usb-0:1:1.0-joystick

Logitech rumblepad 2

Code: [Select]
[58408.244021] usb 2-1: new low speed USB device using ohci_hcd and address 8
[58408.512541] input: Logitech Logitech RumblePad 2 USB as /devices/pci0000:00/0000:00:02.0/usb2/2-1/2-1:1.0/input/input15
[58408.512782] logitech 0003:046D:C218.0004: input,hidraw3: USB HID v1.10 Joystick [Logitech Logitech RumblePad 2 USB] on usb-0000:00:02.0-1/input0
[58408.512797] logitech 0003:046D:C218.0004: Force feedback for Logitech RumblePad/Rumblepad 2 by Anssi Hannula <anssi.@gmail.com>
-----
# udevadm info --query property --name /dev/input/js0
UDEV_LOG=3
DEVPATH=/devices/pci0000:00/0000:00:02.0/usb2/2-1/2-1:1.0/input/input15/js0
MAJOR=13
MINOR=0
DEVNAME=/dev/input/js0
SUBSYSTEM=input
ID_INPUT=1
ID_INPUT_JOYSTICK=1
ID_VENDOR=Logitech
ID_VENDOR_ENC=Logitech
ID_VENDOR_ID=046d
ID_MODEL=Logitech_RumblePad_2_USB
ID_MODEL_ENC=Logitech\x20RumblePad\x202\x20USB
ID_MODEL_ID=c218
ID_REVISION=0100
ID_SERIAL=Logitech_Logitech_RumblePad_2_USB
ID_TYPE=hid
ID_BUS=usb
ID_USB_INTERFACES=:030000:
ID_USB_INTERFACE_NUM=00
ID_USB_DRIVER=usbhid
ID_PATH=pci-0000:00:02.0-usb-0:1:1.0
ACL_MANAGE=1
DEVLINKS=/dev/char/13:0 /dev/input/by-id/usb-Logitech_Logitech_RumblePad_2_USB-joystick /dev/input/by-path/pci-0000:00:02.0-usb-0:1:1.0-joystick

phenigma

  • LinuxMCE God
  • ****
  • Posts: 1758
    • View Profile
Re: USB gamepad - anyone have one, happy to test alternative detection?
« Reply #10 on: February 02, 2013, 09:15:27 pm »
OK, so the package is installed if required, but I can't see why the GamepadCmd variable is set because I can't figure out where/if it's ever used?
...
 snag is... that "GamepadCmd" bit... what is that used for and where does it come in. Is it a necessary step I'm missing out?

The GamepadCmd environment variable is read by the actual AVWizard (a C++ program) and it's contents are executed by AVWizard to start the GamePad device.  It also takes care of removing the device when the AVWizard completes.

When AVWizard completes, the GamePad Radar (Gamead_Detect.sh) takes over detection..

It seems to me that the easiest way to implement this might be to simply alter the existing detection scripts.  Run 'udevadm info --query property --name /dev/input/js0' on each detected device and grep it for 'ID_INPUT_JOYSTICK=1', if that returns a value then activate the gamepad.  Likewise don't activate the device in the radar (or set GamepadCmd) if the grep returns nothing.  The udev rule would likely be more efficient on cpu resources.

J.
« Last Edit: February 02, 2013, 09:20:34 pm by phenigma »

phenigma

  • LinuxMCE God
  • ****
  • Posts: 1758
    • View Profile
Re: USB gamepad - anyone have one, happy to test alternative detection?
« Reply #11 on: February 02, 2013, 10:02:45 pm »
To illustrate my previous e-mail, and as tschak pointed out earlier, devices will either have or not have ID_INPUT_JOYSTICK=1. 

Here is the udev output from the mouse in my VirtualBox Virtual Machine that is consistently detected as a joystick, notice there is no ID_INPUT_JOYSTICK=1, it has ID_INPUT_MOUSE=1 instead.  Why it is mapped to /dev/input/js0 as well as the normal mouse input I have no idea.

Code: [Select]
# udevadm info --query property --name /dev/input/js0
UDEV_LOG=3
DEVPATH=/devices/pci0000:00/0000:00:06.0/usb2/2-1/2-1:1.0/input/input4/js0
MAJOR=13
MINOR=0
DEVNAME=/dev/input/js0
SUBSYSTEM=input
ID_INPUT=1
ID_INPUT_MOUSE=1
ID_VENDOR=VirtualBox
ID_VENDOR_ENC=VirtualBox
ID_VENDOR_ID=80ee
ID_MODEL=USB_Tablet
ID_MODEL_ENC=USB\x20Tablet
ID_MODEL_ID=0021
ID_REVISION=0100
ID_SERIAL=VirtualBox_USB_Tablet
ID_TYPE=hid
ID_BUS=usb
ID_USB_INTERFACES=:030000:
ID_USB_INTERFACE_NUM=00
ID_USB_DRIVER=usbhid
ID_PATH=pci-0000:00:06.0-usb-0:1:1.0
DEVLINKS=/dev/char/13:0 /dev/input/by-id/usb-VirtualBox_USB_Tablet-mouse /dev/input/by-path/pci-0000:00:06.0-usb-0:1:1.0-mouse

J.

tschak909

  • LinuxMCE God
  • ****
  • Posts: 5549
  • DOES work for LinuxMCE.
    • View Profile
Re: USB gamepad - anyone have one, happy to test alternative detection?
« Reply #12 on: February 02, 2013, 10:20:45 pm »
awesome. patch it :)

-Thom

phenigma

  • LinuxMCE God
  • ****
  • Posts: 1758
    • View Profile
Re: USB gamepad - anyone have one, happy to test alternative detection?
« Reply #13 on: February 02, 2013, 10:24:36 pm »
awesome. patch it :)

-Thom

Working on it.  :)  Here's a Gamepad_Detect.sh and AVWizard_Gamepad_Detect.sh that are no longer detecting my mouse as a game pad.  I'll submit to svn if I can get confirmation that it works for someone else with a gamepad and for someone who has always had the issue of improper detection of non joystick devices.

http://pastebin.com/VYAVp97U <- Gamepad_Detect.sh
http://pastebin.com/nJuvWJFu <- AVWizard_Gamepad_Detect.sh

J.
« Last Edit: February 03, 2013, 06:40:43 pm by phenigma »

phenigma

  • LinuxMCE God
  • ****
  • Posts: 1758
    • View Profile
Re: USB gamepad - anyone have one, happy to test alternative detection?
« Reply #14 on: February 02, 2013, 11:20:30 pm »
Alright, after conversation with tschak on irc I understand the issue a little bit more and it will require a bit more refactoring of the detection scripts and of the USB_Game_Pad device to function the way it needs too.  I'm am first fixing the detection scripts to detect ANY joystick existing on /dev/input/js?.  Then (hopefully) figure out USB_Game_Pad so that it will ignore non-joystick devices that present at /dev/input/js?.

J.