How to detect gamepad triggers both pushed with USB HID API?
Asked Answered
C

1

7

I use RawInput + Windows USB HID API to receive WM_INPUT message when a gamepad button is pressed and retrieve gamepad state.

There's a problem: two triggers work on same axis which means you can't figure out if two triggers are pressed at the same time. I observe the same behaviour when launch OS Windows gamepad test application. But I need to distinguish these two buttons pushed.

Note that XInput works as desired, it gives you two axises for two triggers, but I don't want use XInput because it's only for XBox controllers and there are dozens of non-xbox controllers in the world.

I suppose there must be a way to read two axises through USB HID API, but until now I couldn't find it. Have you resolved the issue?

Gamepad: XBox 360 used (but any other should be supported).

OS: Windows 7.

IDE: Visual Studio 2010.

Language: C++

Consubstantiate answered 13/1, 2016 at 10:58 Comment(2)
You say that XInput only works with XBox controllers. But that is incorrect. XInput works with any controller that is XInput compliant. There are many Xinput compliant controllers sold that are not XBox controllers. Dual shock can be made to work with proper drivers, or you can support DirectX input..Secessionist
alright, but still there are XInput incompatible controllersConsubstantiate
H
1

If you really need to read XInput data via HID API and get trigger axis independently...

There is xusb22.sys driver option for that:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\xusb22\Parameters]
"GamepadTriggerUsage"=dword:00003532
"GamepadStickUsage"=dword:31303433

Make it report LT/RT on Rx/Ry (0x33/0x34 usage) and RStick on Z/Rz (0x32/0x35 usage) HID Axis - just like DualShock4:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\xusb22\Parameters]
"GamepadTriggerUsage"=dword:00003334
"GamepadStickUsage"=dword:31303532

But still - there is no any way to send vibration to XInput controller via its HID interface.

PS: There are others options exists. See C:\Windows\INF\xusb22.inf file.

XInput HID Triggers

Hue answered 3/5, 2021 at 10:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.