我有一个无线 PS3 控制器适配器,已插入我的 Ubuntu 14.04 盒子。它有两种模式:XInput 和 DInput,据我所知,它只是通过 USB 传递两个不同的供应商/产品 ID(XInput 有一个 Microsoft XBOX id,另一个是通用的)。 XInput 模式工作正常(加载 xpad 驱动程序),但在 DInput 模式下,内核将设备识别为鼠标,而不是操纵杆。
相关问题:
我需要更改什么才能使其识别为操纵杆?
usbhid 驱动程序如何为字符设备分配次要编号?
消息
[ 1692.151837] usb 3-1: new full-speed USB device number 8 using ohci-pci
[ 1692.325523] usb 3-1: New USB device found, idVendor=0079, idProduct=1801
[ 1692.325528] usb 3-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 1692.325530] usb 3-1: Product: Mayflash PS3 Game Controller Adapater
[ 1692.325531] usb 3-1: Manufacturer: HJZ
[ 1692.341586] input: HJZ Mayflash PS3 Game Controller Adapater as /devices/pci0000:00/0000:00:12.0/usb3/3-1/3-1:1.0/input/input14
[ 1692.341854] hid-generic 0003:0079:1801.0006: input,hidraw3: USB HID v1.11 Joystick [HJZ Mayflash PS3 Game Controller Adapater] on usb-0000:00:12.0-1/input0
须藤 udevadm 信息 --path=/devices/pci0000:00/0000:00:12.0/usb3/3-1/3-1:1.0/input/input14
P: /devices/pci0000:00/0000:00:12.0/usb3/3-1/3-1:1.0/input/input14
E: ABS=ffffff
E: DEVPATH=/devices/pci0000:00/0000:00:12.0/usb3/3-1/3-1:1.0/input/input14
...
E: ID_INPUT_TABLET=1
E: ID_MODEL=Mayflash_PS3_Game_Controller_Adapater
...
E: ID_TYPE=hid
E: ID_USB_DRIVER=usbhid
ll /dev/input/by-id/
lrwxrwxrwx 1 root root 9 May 8 16:18 usb-HJZ_Mayflash_PS3_Game_Controller_Adapater-event-mouse -> ../event4
lrwxrwxrwx 1 root root 9 May 8 16:18 usb-HJZ_Mayflash_PS3_Game_Controller_Adapater-mouse -> ../mouse1
sudo udevadm 监视器 --property --kernel --udev
...
KERNEL[1693.830143] add /devices/pci0000:00/0000:00:12.0/usb3/3-1/3-1:1.0/input/input14/mouse1 (input)
ACTION=add
DEVNAME=/dev/input/mouse1
DEVPATH=/devices/pci0000:00/0000:00:12.0/usb3/3-1/3-1:1.0/input/input14/mouse1
MAJOR=13
MINOR=33
SEQNUM=2196
SUBSYSTEM=input
UDEV_LOG=7
...
更新
在我寻求知识的过程中,我发现了一个列出了 usbhid 驱动程序的主要/次要编号的网站。如下所示,我的设备是 13,32,它是由驱动程序为 mouse0 保留的。看来我需要欺骗(?)驱动程序为其分配不同的次要编号? ……还是我走错了路? (不可否认,我对 Windows 驱动程序开发比 Linux 更熟悉)
USB device number mappings
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
13 char Input drivers
0 = /dev/input/js0 First joystick
1 = /dev/input/js1 Second joystick
...
32 = /dev/input/mouse0 First mouse
33 = /dev/input/mouse1 Second mouse
ls -l /dev/输入/
crw-r----- 1 root root 13, 32 May 9 11:48 mouse0
lsusb -v
Bus 003 Device 003: ID 0079:1801 DragonRise Inc.
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
idVendor 0x0079 DragonRise Inc.
idProduct 0x1801
bcdDevice 1.00
iManufacturer 1 HJZ
iProduct 2 Mayflash PS3 Game Controller Adapater
iSerial 0
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 34
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0x80
(Bus Powered)
MaxPower 500mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 3 Human Interface Device
bInterfaceSubClass 0 No Subclass
bInterfaceProtocol 0 None
iInterface 0
HID Device Descriptor:
bLength 9
bDescriptorType 33
bcdHID 1.11
bCountryCode 0 Not supported
bNumDescriptors 1
bDescriptorType 34 Report
wDescriptorLength 428
Report Descriptors:
** UNAVAILABLE **
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0008 1x 8 bytes
bInterval 1
Device Status: 0x0002
(Bus Powered)
Remote Wakeup Enabled
答案1
HID 系统检查是否有与供应商和产品 ID 匹配的专用驱动程序,如果没有,则将其视为通用 HID 设备:设备发送的描述符用于确定它是什么。
在你的情况下有专门的hid驱动程序,但看起来没有加载。您可以尝试modprobe hid-dr
,但您可能没有安装它。在Ubuntu上,它在linux-image-extra
包装中。