How to use INPUT_HARDWARE on SendInput to simulate an XBox controller input?
Asked Answered
A

1

9

So far I've been capable of using SendInput() function to simulate mouse and keyboard virtual keys and scan keys using MOUSEINPUT and KEYBDINPUT.

I read (on S.O) that INPUT_HARDWARE is for other devices rather than the mouse or keyboard. I'm trying to simulate an Xbox controller (or any controller, if that might help) input using SendInput() and the HARDWAREINPUT structure. Is it possible to do so? How to do it properly?

Annelid answered 30/1, 2017 at 21:55 Comment(1)
It seems there is an answer on SO already, have a lookAda
B
0

According to the leaked WinXP source code INPUT_HARDWARE event type is not supported at all by SendInput on a system level after Win98:

case INPUT_HARDWARE:
            if (fCanDiscontinue) {
                /*
                 * Not supported on NT.
                 */
                RIPERR0(ERROR_CALL_NOT_IMPLEMENTED, RIP_WARNING, "xxxSendInput: INPUT_HARDWARE is for 9x only.");
                goto discontinue;
            }
            break;

According to Wine source code it seems it was used in some old code for HID device support.

I trying to simulate an Xbox controller (or any controller, if that might help) input using SendInput() and the HARDWAREINPUT structure.

Better try to use Virtual Gamepad Emulation Framework (ViGEmBus) for this. It can emulate XInput controllers and is battle tested.

Bunyan answered 23/6, 2023 at 12:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.