[HID] Report passthrough as keyboard type and subtype device.

- Added enums for: X_INPUT_DEVTYPE and X_INPUT_DEVSUBTYPE
- Fixed issue with xinput failure with keyboard flag received
This commit is contained in:
Gliniak 2024-12-23 15:50:00 +01:00
parent 2e521383c2
commit a6e3d77504
3 changed files with 21 additions and 4 deletions

View File

@ -34,6 +34,16 @@ enum X_INPUT_FLAG {
X_INPUT_FLAG_ANY_USER = 1 << 30
};
enum X_INPUT_DEVTYPE {
XINPUT_DEVTYPE_GAMEPAD = 0x00000001,
XINPUT_DEVTYPE_KEYBOARD = 0x00000002,
};
enum X_INPUT_DEVSUBTYPE {
XINPUT_DEVSUBTYPE_USB_KEYBOARD = 0x00000000,
XINPUT_DEVSUBTYPE_GAMEPAD = 0x00000001,
};
enum X_INPUT_GAMEPAD_BUTTON {
X_INPUT_GAMEPAD_DPAD_UP = 0x0001,
X_INPUT_GAMEPAD_DPAD_DOWN = 0x0002,

View File

@ -132,9 +132,14 @@ X_RESULT WinKeyInputDriver::GetCapabilities(uint32_t user_index, uint32_t flags,
return X_ERROR_DEVICE_NOT_CONNECTED;
}
// TODO(benvanik): confirm with a real XInput controller.
out_caps->type = 0x01; // XINPUT_DEVTYPE_GAMEPAD
out_caps->sub_type = 0x01; // XINPUT_DEVSUBTYPE_GAMEPAD
if (IsPassthroughEnabled()) {
out_caps->type = X_INPUT_DEVTYPE::XINPUT_DEVTYPE_KEYBOARD;
out_caps->sub_type = X_INPUT_DEVSUBTYPE::XINPUT_DEVSUBTYPE_USB_KEYBOARD;
return X_ERROR_SUCCESS;
}
out_caps->type = X_INPUT_DEVTYPE::XINPUT_DEVTYPE_GAMEPAD;
out_caps->sub_type = X_INPUT_DEVSUBTYPE::XINPUT_DEVSUBTYPE_GAMEPAD;
out_caps->flags = 0;
out_caps->gamepad.buttons = 0xFFFF;
out_caps->gamepad.left_trigger = 0xFF;

View File

@ -110,7 +110,9 @@ X_RESULT XInputInputDriver::GetCapabilities(uint32_t user_index, uint32_t flags,
}
XINPUT_CAPABILITIES native_caps;
auto xigc = (decltype(&XInputGetCapabilities))XInputGetCapabilities_;
DWORD result = xigc(user_index, flags, &native_caps);
DWORD result =
xigc(user_index, flags & ~X_INPUT_DEVTYPE::XINPUT_DEVTYPE_KEYBOARD,
&native_caps);
if (result) {
if (result == ERROR_DEVICE_NOT_CONNECTED) {
set_skip(user_index);