mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2026-01-05 19:19:43 -06:00
button_guide: support for PlayStation controller icons
This commit is contained in:
@@ -15,9 +15,14 @@ public:
|
||||
SDL_JoystickID id{ -1 };
|
||||
XAMINPUT_GAMEPAD state{};
|
||||
XAMINPUT_VIBRATION vibration{ 0, 0 };
|
||||
int index{};
|
||||
|
||||
Controller() = default;
|
||||
explicit Controller(int index) : Controller(SDL_GameControllerOpen(index)) {}
|
||||
|
||||
explicit Controller(int index) : Controller(SDL_GameControllerOpen(index))
|
||||
{
|
||||
this->index = index;
|
||||
}
|
||||
|
||||
Controller(SDL_GameController* controller) : controller(controller)
|
||||
{
|
||||
@@ -28,6 +33,24 @@ public:
|
||||
id = SDL_JoystickInstanceID(joystick);
|
||||
}
|
||||
|
||||
SDL_GameControllerType GetControllerType() const
|
||||
{
|
||||
return SDL_GameControllerTypeForIndex(index);
|
||||
}
|
||||
|
||||
hid::detail::EInputDevice GetInputDevice() const
|
||||
{
|
||||
switch (GetControllerType())
|
||||
{
|
||||
case SDL_CONTROLLER_TYPE_PS3:
|
||||
case SDL_CONTROLLER_TYPE_PS4:
|
||||
case SDL_CONTROLLER_TYPE_PS5:
|
||||
return hid::detail::EInputDevice::PlayStation;
|
||||
}
|
||||
|
||||
return hid::detail::EInputDevice::Xbox;
|
||||
}
|
||||
|
||||
void Close()
|
||||
{
|
||||
if (!controller)
|
||||
@@ -167,7 +190,7 @@ int HID_OnSDLEvent(void*, SDL_Event* event)
|
||||
controller->Poll();
|
||||
}
|
||||
|
||||
hid::detail::g_inputDevice = hid::detail::EInputDevice::Controller;
|
||||
hid::detail::g_inputDevice = controller->GetInputDevice();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,3 +23,9 @@ uint32_t hid::GetCapabilities(uint32_t dwUserIndex, XAMINPUT_CAPABILITIES* pCaps
|
||||
{
|
||||
return detail::GetCapabilities(dwUserIndex, pCaps);
|
||||
}
|
||||
|
||||
bool hid::detail::IsInputDeviceController()
|
||||
{
|
||||
return hid::detail::g_inputDevice != hid::detail::EInputDevice::Keyboard &&
|
||||
hid::detail::g_inputDevice != hid::detail::EInputDevice::Mouse;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,8 @@ namespace hid::detail
|
||||
{
|
||||
Keyboard,
|
||||
Mouse,
|
||||
Controller
|
||||
Xbox,
|
||||
PlayStation
|
||||
};
|
||||
|
||||
extern EInputDevice g_inputDevice;
|
||||
@@ -16,4 +17,6 @@ namespace hid::detail
|
||||
uint32_t GetState(uint32_t dwUserIndex, XAMINPUT_STATE* pState);
|
||||
uint32_t SetState(uint32_t dwUserIndex, XAMINPUT_VIBRATION* pVibration);
|
||||
uint32_t GetCapabilities(uint32_t dwUserIndex, XAMINPUT_CAPABILITIES* pCaps);
|
||||
|
||||
bool IsInputDeviceController();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user