如何解决自定义 HID 游戏手柄适用于 Windows,在 Linux 中有一些倒置的按钮
我使用 STM32 设计了一个自定义游戏手柄。它有四个模拟轴和 22 个按钮。我已经为它编写了固件,包括 USB 描述符(尝试了几次)。
它在 Windows 上完全按预期工作,但在 Linux(特别是 Raspbian)上,最后 5 个按钮是倒置的(默认为“开”,按下时为“关”)
对我的产品来说,它在两个平台上都可以运行至关重要(Mac 也是如此,但我现在没有要测试的平台)
任何想法为什么会这样,以及如何处理它?
这是该设备的 lsusb -v 输出:
Bus 001 Device 003: ID 0483:5750 STMicroelectronics
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 0
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
idvendor 0x0483 STMicroelectronics
idProduct 0x5750
bcdDevice 2.00
iManufacturer 1 STMicroelectronics
iProduct 2 STM32 Custom Human interface
iSerial 3 74E79C303734
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 0x0029
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0xc0
Self Powered
MaxPower 100mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 3 Human Interface Device
bInterfaceSubClass 0
bInterfaceProtocol 0
iInterface 0
HID Device Descriptor:
bLength 9
bDescriptorType 33
bcdHID 1.11
bCountryCode 0 Not supported
bNumDescriptors 1
bDescriptorType 34 Report
wDescriptorLength 53
Report Descriptor: (length is 53)
Item(Global): Usage Page,data= [ 0x01 ] 1
Generic Desktop Controls
Item(Local ): Usage,data= [ 0x05 ] 5
Gamepad
Item(Main ): Collection,data= [ 0x01 ] 1
Application
Item(Local ): Usage,data= [ 0x01 ] 1
Pointer
Item(Main ): Collection,data= [ 0x00 ] 0
Physical
Item(Local ): Usage,data= [ 0x30 ] 48
Direction-X
Item(Local ): Usage,data= [ 0x31 ] 49
Direction-Y
Item(Local ): Usage,data= [ 0x32 ] 50
Direction-Z
Item(Local ): Usage,data= [ 0x33 ] 51
Rotate-X
Item(Global): Logical Minimum,data= [ 0x00 ] 0
Item(Global): Logical Maximum,data= [ 0xff 0x0f ] 4095
Item(Global): Report Size,data= [ 0x10 ] 16
Item(Global): Report Count,data= [ 0x04 ] 4
Item(Main ): Input,data= [ 0x02 ] 2
Data Variable Absolute No_Wrap Linear
Preferred_State No_Null_Position Non_Volatile Bitfield
Item(Main ): End Collection,data=none
Item(Global): Usage Page,data= [ 0x09 ] 9
Buttons
Item(Local ): Usage Minimum,data= [ 0x01 ] 1
Button 1 (Primary)
Item(Local ): Usage Maximum,data= [ 0x16 ] 22
(null)
Item(Global): Logical Minimum,data= [ 0x01 ] 1
Item(Global): Report Size,data= [ 0x01 ] 1
Item(Global): Report Count,data= [ 0x16 ] 22
Item(Main ): Input,data= [ 0x02 ] 2
Data Variable Absolute No_Wrap Linear
Preferred_State No_Null_Position Non_Volatile Bitfield
Item(Global): Report Size,data= [ 0x02 ] 2
Item(Main ): Input,data= [ 0x03 ] 3
Constant Variable Absolute No_Wrap Linear
Preferred_State No_Null_Position Non_Volatile Bitfield
Item(Main ): End Collection,data=none
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0002 1x 2 bytes
bInterval 10
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x01 EP 1 OUT
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0002 1x 2 bytes
bInterval 10
Device Status: 0x0001
Self Powered
我还注意到摇杆的位置不同(同样,在 Windows 上是正确的,在 Linux 上是错误的。)
我确实读过一些关于 Linux 的内核驱动程序可以对这些值执行某些操作的内容? jstest-gtk 可以让我控制轴的某些方面(缩放、死区、反转),也许这是一个线索?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。