1

I am trying to read a DirectInput Device under Linux.

lsusb:

Bus 003 Device 006: ID 046d:c219 Logitech, Inc. F710 Gamepad [DirectInput Mode]

sudo dmesg:

[13919.233231] usb 3-2.2: new full-speed USB device number 15 using xhci_hcd
[13919.335587] usb 3-2.2: New USB device found, idVendor=046d, idProduct=c219, bcdDevice= 3.05
[13919.335598] usb 3-2.2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[13919.335603] usb 3-2.2: Product: 游戏手柄
[13919.335607] usb 3-2.2: Manufacturer: game
[13919.421920] input: game 游戏手柄 as /devices/pci0000:00/0000:00:07.1/0000:0a:00.3/usb3/3-2/3-2.2/3-2.2:1.0/0003:046D:C219.000E/input/input32
[13919.422147] logitech 0003:046D:C219.000E: input,hidraw8: USB HID v1.10 Gamepad [game 游戏手柄] on usb-0000:0a:00.3-2.2/input0
[13919.422154] logitech 0003:046D:C219.000E: missing HID_OUTPUT_REPORT 0

ls /dev/ | grep hid:

hidraw0
hidraw1
hidraw2
hidraw3
hidraw4
hidraw5
hidraw6
hidraw7
uhid

Only goes up to 7, not 8 :(

udevadm monitor when plugging in:

monitor will print the received events for:
UDEV - the event which udev sends out after rule processing
KERNEL - the kernel uevent

KERNEL[4618.774609] add      /devices/pci0000:00/0000:00:07.1/0000:0a:00.3/usb3/3-2/3-2.3 (usb)
KERNEL[4618.859136] add      /devices/pci0000:00/0000:00:07.1/0000:0a:00.3/usb3/3-2/3-2.3/3-2.3:1.0 (usb)
KERNEL[4618.860049] add      /devices/pci0000:00/0000:00:07.1/0000:0a:00.3/usb3/3-2/3-2.3/3-2.3:1.0/0003:046D:C219.000C (hid)
KERNEL[4618.860281] add      /devices/pci0000:00/0000:00:07.1/0000:0a:00.3/usb3/3-2/3-2.3/3-2.3:1.0/0003:046D:C219.000C/input/input30 (input)
KERNEL[4618.860397] add      /devices/pci0000:00/0000:00:07.1/0000:0a:00.3/usb3/3-2/3-2.3/3-2.3:1.0/0003:046D:C219.000C/input/input30/event27 (input)
KERNEL[4618.860480] add      /devices/pci0000:00/0000:00:07.1/0000:0a:00.3/usb3/3-2/3-2.3/3-2.3:1.0/0003:046D:C219.000C/input/input30/js0 (input)
KERNEL[4618.860567] add      /devices/pci0000:00/0000:00:07.1/0000:0a:00.3/usb3/3-2/3-2.3/3-2.3:1.0/0003:046D:C219.000C/hidraw/hidraw8 (hidraw)
KERNEL[4618.860674] remove   /devices/pci0000:00/0000:00:07.1/0000:0a:00.3/usb3/3-2/3-2.3/3-2.3:1.0/0003:046D:C219.000C/input/input30/event27 (input)
KERNEL[4618.870216] remove   /devices/pci0000:00/0000:00:07.1/0000:0a:00.3/usb3/3-2/3-2.3/3-2.3:1.0/0003:046D:C219.000C/input/input30/js0 (input)
KERNEL[4618.887225] remove   /devices/pci0000:00/0000:00:07.1/0000:0a:00.3/usb3/3-2/3-2.3/3-2.3:1.0/0003:046D:C219.000C/input/input30 (input)
KERNEL[4618.887338] remove   /devices/pci0000:00/0000:00:07.1/0000:0a:00.3/usb3/3-2/3-2.3/3-2.3:1.0/0003:046D:C219.000C/hidraw/hidraw8 (hidraw)
KERNEL[4618.887408] bind     /devices/pci0000:00/0000:00:07.1/0000:0a:00.3/usb3/3-2/3-2.3/3-2.3:1.0 (usb)
KERNEL[4618.887507] bind     /devices/pci0000:00/0000:00:07.1/0000:0a:00.3/usb3/3-2/3-2.3 (usb)
UDEV  [4618.900197] add      /devices/pci0000:00/0000:00:07.1/0000:0a:00.3/usb3/3-2/3-2.3 (usb)
UDEV  [4618.906487] add      /devices/pci0000:00/0000:00:07.1/0000:0a:00.3/usb3/3-2/3-2.3/3-2.3:1.0 (usb)
UDEV  [4618.910584] add      /devices/pci0000:00/0000:00:07.1/0000:0a:00.3/usb3/3-2/3-2.3/3-2.3:1.0/0003:046D:C219.000C (hid)
UDEV  [4618.917739] add      /devices/pci0000:00/0000:00:07.1/0000:0a:00.3/usb3/3-2/3-2.3/3-2.3:1.0/0003:046D:C219.000C/hidraw/hidraw8 (hidraw)
UDEV  [4618.919709] remove   /devices/pci0000:00/0000:00:07.1/0000:0a:00.3/usb3/3-2/3-2.3/3-2.3:1.0/0003:046D:C219.000C/hidraw/hidraw8 (hidraw)
UDEV  [4619.219420] add      /devices/pci0000:00/0000:00:07.1/0000:0a:00.3/usb3/3-2/3-2.3/3-2.3:1.0/0003:046D:C219.000C/input/input30 (input)
UDEV  [4620.095442] add      /devices/pci0000:00/0000:00:07.1/0000:0a:00.3/usb3/3-2/3-2.3/3-2.3:1.0/0003:046D:C219.000C/input/input30/js0 (input)
UDEV  [4620.109143] remove   /devices/pci0000:00/0000:00:07.1/0000:0a:00.3/usb3/3-2/3-2.3/3-2.3:1.0/0003:046D:C219.000C/input/input30/js0 (input)
UDEV  [4620.129855] add      /devices/pci0000:00/0000:00:07.1/0000:0a:00.3/usb3/3-2/3-2.3/3-2.3:1.0/0003:046D:C219.000C/input/input30/event27 (input)
UDEV  [4620.132286] remove   /devices/pci0000:00/0000:00:07.1/0000:0a:00.3/usb3/3-2/3-2.3/3-2.3:1.0/0003:046D:C219.000C/input/input30/event27 (input)
UDEV  [4620.134369] remove   /devices/pci0000:00/0000:00:07.1/0000:0a:00.3/usb3/3-2/3-2.3/3-2.3:1.0/0003:046D:C219.000C/input/input30 (input)
UDEV  [4620.142158] bind     /devices/pci0000:00/0000:00:07.1/0000:0a:00.3/usb3/3-2/3-2.3/3-2.3:1.0 (usb)
UDEV  [4620.152604] bind     /devices/pci0000:00/0000:00:07.1/0000:0a:00.3/usb3/3-2/3-2.3 (usb)

But sadly no joystick or event is bound :(

How to work around this? Is a custom Windows DirectX Input Driver implementation needed?

6
  • Do you specifically want to use it in DirectInput mode (instead of the XInput mode)? Commented Sep 3 at 17:22
  • "Only goes up to 7, not 8"? But it starts at ZERO! hidraw0. Commented Sep 3 at 23:51
  • @waltinator There's hidraw8 in the udevadm monitor output though. No idea how that is related to the dev nodes though. (Does it mean /dev/hidraw7?) Commented Sep 4 at 5:25
  • Oh hey you two, sorry for the delay, yes dmesg tells me its bound to hidraw8. Which does not exist because its mostlikey removed due to driver binding failure or something like that (my best guess). Of cause it starts at 0 ;). And I always have 7 (well if i unplug stuff i wont, but nothing changes when plugigng in the usb sim racing handbrake) Commented Sep 4 at 16:58
  • linux-hardware.org/?id=usb:046d-c219&page=2#status Oh and someone on stackoverflow (where my question got closed due to being on the wrong exchange lol) sent me this. So the device is actually, or should be supported? How do I get access to it then though? Hmmmmm Commented Sep 4 at 17:07

1 Answer 1

0

I got a workaround reading the raw usb data ->

import usb.core
import usb.util

dev = usb.core.find(idVendor=0x046d, idProduct=0xc219)
if dev is None:
    raise ValueError("Device not found")

if dev.is_kernel_driver_active(0):
    dev.detach_kernel_driver(0)

dev.set_configuration()

cfg = dev.get_active_configuration()
intf = cfg[(0,0)]

ep = usb.util.find_descriptor(
    intf,
    custom_match = lambda e: 
        usb.util.endpoint_direction(e.bEndpointAddress) == usb.util.ENDPOINT_IN
)

assert ep is not None

data = dev.read(ep.bEndpointAddress, ep.wMaxPacketSize, timeout=1000)
print("Data:", data)
1
  • As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center. Commented Sep 6 at 9:44

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.