mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2026-04-26 20:31:41 +00:00
Replacing EInputDeviceExplicit with SDL_GameControllerName
Based on @hyperbx's suggestions: It'll look for SDL's Controller Name as opposed to EInputDevice's naming scheme.
This commit is contained in:
parent
5a57de3ef1
commit
c77ce2b359
1 changed files with 14 additions and 7 deletions
|
|
@ -57,6 +57,16 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* GetControllerName() const
|
||||||
|
{
|
||||||
|
auto result = SDL_GameControllerName(controller);
|
||||||
|
|
||||||
|
if (!result)
|
||||||
|
return "Unknown Device";
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
void Close()
|
void Close()
|
||||||
{
|
{
|
||||||
if (!controller)
|
if (!controller)
|
||||||
|
|
@ -137,7 +147,6 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
std::array<Controller, 4> g_controllers;
|
std::array<Controller, 4> g_controllers;
|
||||||
Controller* g_activeController;
|
Controller* g_activeController;
|
||||||
|
|
||||||
|
|
@ -182,22 +191,20 @@ static void SetControllerInputDevice(Controller* controller)
|
||||||
hid::g_inputDeviceController = hid::g_inputDevice;
|
hid::g_inputDeviceController = hid::g_inputDevice;
|
||||||
|
|
||||||
auto controllerType = (hid::EInputDeviceExplicit)controller->GetControllerType();
|
auto controllerType = (hid::EInputDeviceExplicit)controller->GetControllerType();
|
||||||
|
auto controllerName = controller->GetControllerName();
|
||||||
|
|
||||||
// Only proceed if the controller type changes
|
// Only proceed if the controller type changes.
|
||||||
if (hid::g_inputDeviceExplicit != controllerType)
|
if (hid::g_inputDeviceExplicit != controllerType)
|
||||||
{
|
{
|
||||||
hid::g_inputDeviceExplicit = controllerType;
|
hid::g_inputDeviceExplicit = controllerType;
|
||||||
|
|
||||||
// Handle Unknown Type specifically
|
|
||||||
if (controllerType == hid::EInputDeviceExplicit::Unknown)
|
if (controllerType == hid::EInputDeviceExplicit::Unknown)
|
||||||
{
|
{
|
||||||
const char* controllerName = SDL_GameControllerName(controller->controller);
|
LOGFN("Detected controller: {} (Unknown Controller Type)", controllerName);
|
||||||
LOGFN("Controller connected: {} (Unknown Controller Type)", controllerName ? controllerName : "Unknown Device");
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// For known types, only use the EInputDeviceExplicit name
|
LOGFN("Detected controller: {}", controllerName);
|
||||||
LOGFN("Controller connected: {}", hid::GetInputDeviceName());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue