0

So I'm using hidapi to reading input packets from a few xbox controllers I have and one thing frustrating me is that it reports the left and right triggers as a single "rudder" axis with a uint16_t. Is there any sort of packet I can send to change the report structure? I know that there are games that can use both triggers at the same time. I guess that the Microsoft answer would be to use DirectInput but I would really like to be able to roll my own.

#pragma pack(1)
struct xbox_wireless_controller_report {
    static const u8 a = 1;
    static const u8 b = 2;
    static const u8 x = 4;
    static const u8 y = 8;
    static const u8 lb = 16;
    static const u8 rb = 32;
    static const u8 select = 64;
    static const u8 start = 128;

    static const u8 l3 = 1;
    static const u8 r3 = 2;

    u16 left_stick_x;
    u16 left_stick_y;
    u16 right_stick_x;
    u16 right_stick_y;

    u16 rudder;
    
    u8 buttons; // a, b, x, y, lb, rb, select, start
    u8 l3r3;
    u8 dpad;
    u8 unknown[2]; // just here to make 15 bytes
};

static_assert(sizeof(xbox_wireless_controller_report) == 15);
David Carpenter
  • 1,389
  • 2
  • 16
  • 29
  • I found one answer here, if I change the driver from XInput to HID it now reports an entirely different packet structure. I wish there was an easier way though. https://answers.microsoft.com/en-us/xbox/forum/all/xbox-one-controller-wireless-adapter-z-axis-and/04316052-7b19-400c-be30-6b4d30340389 – David Carpenter Jul 20 '22 at 19:48
  • FWIW: the Microsoft answer is to use XINPUT, Windows.Gaming.Input, or GameInput. Not legacy DirectInput. – Chuck Walbourn Jul 29 '22 at 00:05

1 Answers1

0

The reason the HID-driver exposed by the Xbox Common Controller have this behavior is for backcompat reasons with some older DirectInput-based racing titles.

The recommendation is to use XINPUT, Windows.Gaming.Input, or GameInput and not legacy DirectInput for the Xbox gamepads.

There is an undocumented registry key you can use to manipulate this mapping on your system, but keep in mind that this will impact all use of the Xbox Common Controller via DirectInput. How to detect gamepad triggers both pushed with USB HID API?

Chuck Walbourn
  • 38,259
  • 2
  • 58
  • 81