Linux 上的 USB 操纵杆仅在我断开连接并重新连接时才起作用

Linux 上的 USB 操纵杆仅在我断开连接并重新连接时才起作用

你好!

我遇到了一个简单的问题,但我还没有找到解决方案。

当我使用 Debian 或 Ubuntu 打开计算机并尝试使用操纵杆时,操纵杆的命令不会传递给 SO。一旦我断开并重新连接 USB 端口上的操纵杆,它就可以正常工作。

环境:

因此:Debian 5.0 和 Ubuntu 8.04 LTS

lsusb - 在断开并重新连接操纵杆之前执行此命令,结果相同:

Bus 008 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
**Bus 007 Device 004: ID 068e:00af CH Products, Inc.** 
Bus 007 Device 002: ID 04d9:1400 Holtek Semiconductor, Inc. 
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

dmesg-仅相关部分:

...
[    6.213666] usb 7-2: configuration #1 chosen from 1 choice
[    6.264813] usb 7-2: New USB device found, idVendor=068e, idProduct=00af
[    6.264816] usb 7-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[    6.264818] usb 7-2: Product: Megatron OEM 2 Axis 1 Button Joystick
[    6.264819] usb 7-2: Manufacturer: CH PRODUCTS
[    6.269849] usbcore: registered new interface driver hiddev
[    6.286942] input: HID 04d9:1400 as /class/input/input0
[    6.286942] input,hidraw0: USB HID v1.10 Keyboard [HID 04d9:1400] on usb-0000:00:1d.2-1
[    6.315247] input: HID 04d9:1400 as /class/input/input1
[    6.315247] input,hidraw1: USB HID v1.10 Mouse [HID 04d9:1400] on usb-0000:00:1d.2-1
[    6.357061] input: CH PRODUCTS Megatron OEM 2 Axis 1 Button Joystick as /class/input/input2
[    6.357061] input,hidraw2: USB HID v1.00 Joystick [CH PRODUCTS Megatron OEM 2 Axis 1 Button Joystick] on usb-0000:00:1d.2-2
[    6.357061] usbcore: registered new interface driver usbhid
[    6.357061] usbhid: v2.6:USB HID core driver

...

[ 6377.097243] usb 7-2: USB disconnect, address 3
[ 6379.225161] usb 7-2: new low speed USB device using uhci_hcd and address 4
[ 6379.408990] usb 7-2: configuration #1 chosen from 1 choice
[ 6379.615388] input: CH PRODUCTS Megatron OEM 2 Axis 1 Button Joystick as /class/input/input6
[ 6379.694649] input,hidraw2: USB HID v1.00 Joystick [CH PRODUCTS Megatron OEM 2 Axis 1 Button Joystick] on usb-0000:00:1d.2-2
[ 6379.700445] usb 7-2: New USB device found, idVendor=068e, idProduct=00af
[ 6379.700445] usb 7-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 6379.700445] usb 7-2: Product: Megatron OEM 2 Axis 1 Button Joystick
[ 6379.700445] usb 7-2: Manufacturer: CH PRODUCTS**

/proc/bus/usb/设备:

T:  Bus=07 Lev=01 Prnt=01 Port=01 Cnt=02 Dev#=  4 Spd=1.5 MxCh= 0
D:  Ver= 1.01 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs=  1
P:  Vendor=068e ProdID=00af Rev= 0.00
S:  Manufacturer=CH PRODUCTS
S:  Product=Megatron OEM 2 Axis 1 Button Joystick
C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr= 32mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=03(HID  ) Sub=00 Prot=00 Driver=usbhid
E:  Ad=81(I) Atr=03(Int.) MxPS=   5 Ivl=10ms

设备:/dev/input/js0

我用来测试 cat /dev/input/js0 和我的应用程序。

我尝试使用 ssh 进行远程访问,因为我的键盘也使用 USB 端口,并执行以下命令:

# modprobe -r joydev
# modprobe -r usbhid
# modprobe usbhid
# modprobe joydev

执行上述命令后,操纵杆不工作。

怎么了?

帮我!

答案1

我解决了这个问题。

我尝试了很多次,一位同事建议我重新加载模块。我尝试了一些组合,这个组合有效:

rmmod joydev
rmmod uhci_hcd
modprobe uhci_hcd
modprobe joydev

我在 /etc/rc.local 中输入了这几行,操纵杆工作得很好。

我需要更好地理解它是如何工作的。

谢谢。

答案2

我遇到了同样的问题。我测试了几个小时,有三个解决方案。最简单的:只需输入

# lsusb -v -d 068e:00af

在终端

最干净的:使用 quirk 参数加载 usbhid 模块:

# rmmod usbhid && modprobe usbhid quirk=0x068e:0x00af:0x8

或者更好的持久解决方案

# 回显“选项 usbhid quirks=0x068e:0x00af:0x8” > /etc/modprobe.d/usbhid

“困难”的方式:

修补 /usr/src/linux/drivers/hid/usbhid/hid-quirks.c (在其他内核版本中可能看起来有所不同):

--- /usr/src/linux-2.6.27.45-0.1_old/drivers/hid/usbhid/hid-quirks.c 2010-02-23 12:21:38.000000000 +0100 +++ /usr/src/linux-2.6.27.45-0.1_new/drivers/hid/usbhid/hid-quirks.c 2010-11-22 17:59:05.000000000 +0100 @@ -102,6 +102,9 @@ #define USB_VENDOR_ID_BERKSHIRE 0x0c98

#定义 USB_DEVICE_ID_BERKSHIRE_PCWD 0x1140
+#定义 USB_VENDOR_ID_CH 0x068e +#定义 USB_DEVICE_ID_CH_2AXIS_1BUTTON 0x00af +#定义 USB_VENDOR_ID_CHERRY 0x046a#定义 USB_DEVICE_ID_CHERRY_CYMOTION 0x0023
@@ -624,6 +627,7 @@ 静态 const 结构 hid_blacklist { { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_2PORTKVM, HID_QUIRK_NOGET }, { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVM, HID_QUIRK_NOGET }, { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVMC,HID_QUIRK_NOGET },+ {USB_VENDOR_ID_CH,USB_DEVICE_ID_CH_2AXIS_1BUTTON,HID_QUIRK_NOGET},{USB_VENDOR_ID_DMI,USB_DEVICE_ID_DMI_ENC,HID_QUIRK_NOGET },{USB_VENDOR_ID_ELO,USB_DEVICE_ID_ELO_TS2700,HID_QUIRK_NOGET },{USB_VENDOR_ID_LOGITECH,USB_DEVICE_ID_LOGITECH_EXTREME_3D,HID_QUIRK_NOGET },

相关内容