Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 239
Juster Avatar asked Jan 13 '16 10:01

Juster


People also ask

Is Xbox controller HID device?

Xbox One controllers are using proprietary protocol called GIP (Gaming Input Protocol) for USB and Wireless, also HID for Bluetooth (on newer controllers).

What is HID gamepad?

Human Interface Device (HID) is a specification to describe peripheral user input devices connected to computers via USB or Bluetooth. HID is commonly used to implement devices such as gamepads, joysticks, or racing wheels.


Video Answer


1 Answers

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

like image 77
DJm00n Avatar answered Oct 05 '22 20:10

DJm00n