diff --git a/src/input.cpp b/src/input.cpp index fb862325d09..3de6c327dc6 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -254,7 +254,7 @@ namespace input { << "--begin controller packet--"sv << std::endl << "controllerNumber ["sv << packet->controllerNumber << ']' << std::endl << "activeGamepadMask ["sv << util::hex(packet->activeGamepadMask).to_string_view() << ']' << std::endl - << "buttonFlags ["sv << util::hex(packet->buttonFlags).to_string_view() << ']' << std::endl + << "buttonFlags ["sv << util::hex((uint32_t) packet->buttonFlags | (packet->buttonFlags2 << 16)).to_string_view() << ']' << std::endl << "leftTrigger ["sv << util::hex(packet->leftTrigger).to_string_view() << ']' << std::endl << "rightTrigger ["sv << util::hex(packet->rightTrigger).to_string_view() << ']' << std::endl << "leftStickX ["sv << packet->leftStickX << ']' << std::endl @@ -691,8 +691,9 @@ namespace input { } std::uint16_t bf = packet->buttonFlags; + std::uint32_t bf2 = packet->buttonFlags2; platf::gamepad_state_t gamepad_state { - bf, + bf | (bf2 << 16), packet->leftTrigger, packet->rightTrigger, packet->leftStickX, diff --git a/src/platform/common.h b/src/platform/common.h index cdb5785e076..d9af3b18647 100644 --- a/src/platform/common.h +++ b/src/platform/common.h @@ -47,23 +47,30 @@ namespace video { } // namespace video namespace platf { - constexpr auto MAX_GAMEPADS = 32; - - constexpr std::uint16_t DPAD_UP = 0x0001; - constexpr std::uint16_t DPAD_DOWN = 0x0002; - constexpr std::uint16_t DPAD_LEFT = 0x0004; - constexpr std::uint16_t DPAD_RIGHT = 0x0008; - constexpr std::uint16_t START = 0x0010; - constexpr std::uint16_t BACK = 0x0020; - constexpr std::uint16_t LEFT_STICK = 0x0040; - constexpr std::uint16_t RIGHT_STICK = 0x0080; - constexpr std::uint16_t LEFT_BUTTON = 0x0100; - constexpr std::uint16_t RIGHT_BUTTON = 0x0200; - constexpr std::uint16_t HOME = 0x0400; - constexpr std::uint16_t A = 0x1000; - constexpr std::uint16_t B = 0x2000; - constexpr std::uint16_t X = 0x4000; - constexpr std::uint16_t Y = 0x8000; + // Limited by bits in activeGamepadMask + constexpr auto MAX_GAMEPADS = 16; + + constexpr std::uint32_t DPAD_UP = 0x0001; + constexpr std::uint32_t DPAD_DOWN = 0x0002; + constexpr std::uint32_t DPAD_LEFT = 0x0004; + constexpr std::uint32_t DPAD_RIGHT = 0x0008; + constexpr std::uint32_t START = 0x0010; + constexpr std::uint32_t BACK = 0x0020; + constexpr std::uint32_t LEFT_STICK = 0x0040; + constexpr std::uint32_t RIGHT_STICK = 0x0080; + constexpr std::uint32_t LEFT_BUTTON = 0x0100; + constexpr std::uint32_t RIGHT_BUTTON = 0x0200; + constexpr std::uint32_t HOME = 0x0400; + constexpr std::uint32_t A = 0x1000; + constexpr std::uint32_t B = 0x2000; + constexpr std::uint32_t X = 0x4000; + constexpr std::uint32_t Y = 0x8000; + constexpr std::uint32_t PADDLE1 = 0x010000; + constexpr std::uint32_t PADDLE2 = 0x020000; + constexpr std::uint32_t PADDLE3 = 0x040000; + constexpr std::uint32_t PADDLE4 = 0x080000; + constexpr std::uint32_t TOUCHPAD_BUTTON = 0x100000; + constexpr std::uint32_t MISC_BUTTON = 0x200000; struct rumble_t { KITTY_DEFAULT_CONSTR(rumble_t) @@ -154,7 +161,7 @@ namespace platf { }; struct gamepad_state_t { - std::uint16_t buttonFlags; + std::uint32_t buttonFlags; std::uint8_t lt; std::uint8_t rt; std::int16_t lsX; diff --git a/src/platform/windows/input.cpp b/src/platform/windows/input.cpp index c94904267b3..737fb9e3fbc 100644 --- a/src/platform/windows/input.cpp +++ b/src/platform/windows/input.cpp @@ -520,6 +520,9 @@ namespace platf { if (gamepad_state.buttonFlags & HOME) buttons |= DS4_SPECIAL_BUTTON_PS; + // Allow either PS4/PS5 clickpad button or Xbox Series X share button to activate DS4 clickpad + if (gamepad_state.buttonFlags & (TOUCHPAD_BUTTON | MISC_BUTTON)) buttons |= DS4_SPECIAL_BUTTON_TOUCHPAD; + return (DS4_SPECIAL_BUTTONS) buttons; }