Juster
Juster

Reputation: 752

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

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++

Upvotes: 7

Views: 1281

Answers (1)

DJm00n
DJm00n

Reputation: 1411

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

Upvotes: 1

Related Questions