From a6e3d77504064f0f5392134cd55579d619599e41 Mon Sep 17 00:00:00 2001 From: Gliniak Date: Mon, 23 Dec 2024 15:50:00 +0100 Subject: [PATCH] [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 --- src/xenia/hid/input.h | 10 ++++++++++ src/xenia/hid/winkey/winkey_input_driver.cc | 11 ++++++++--- src/xenia/hid/xinput/xinput_input_driver.cc | 4 +++- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/xenia/hid/input.h b/src/xenia/hid/input.h index ebfeb7eeba..f142b89901 100644 --- a/src/xenia/hid/input.h +++ b/src/xenia/hid/input.h @@ -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, diff --git a/src/xenia/hid/winkey/winkey_input_driver.cc b/src/xenia/hid/winkey/winkey_input_driver.cc index b1d4af1eb3..762a6593e6 100644 --- a/src/xenia/hid/winkey/winkey_input_driver.cc +++ b/src/xenia/hid/winkey/winkey_input_driver.cc @@ -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; diff --git a/src/xenia/hid/xinput/xinput_input_driver.cc b/src/xenia/hid/xinput/xinput_input_driver.cc index 4217345622..c745990f29 100644 --- a/src/xenia/hid/xinput/xinput_input_driver.cc +++ b/src/xenia/hid/xinput/xinput_input_driver.cc @@ -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);