mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2025-04-28 13:27:58 +03:00
Steam Virtual Gamepad support / Steam Input sharing Device Info with SDL (#1086)
Some checks failed
validate-internal / build (push) Failing after 3s
Some checks failed
validate-internal / build (push) Failing after 3s
* Experimenting Button Label Experimenting a way to add a hint for Button Labels. It should attempt to fix the Nintendo Layout issue when using a Nintendo Switch controller * Create c-cpp.yml * Create cmake-multi-platform.yml * Create apply-patch.yml * removing the workflows * added experimental Steam Virtual Gamepad support * restoring notes for Button Labels. * Initial Gamepad Hotplug Logic improvements This changes the way how a Controller will be prioritized. By default: it'll always prioritize based on Player 1. It should play nicely with Steam Deck's internal inputs when Steam Input is active * Lightbar detection when using multiple PlayStation controllers at the same time. An attempt to remedy the Lightbar activation. While Player 2/3/4 will override the in-game lightbar event upon connection: it'll later revert back to the in-game event. * Attempt to reduce Input leaking To avoid "the Controller is leaking" situation, there's now a Gamepad stat management that should reset Controller state based on connected controller. * Lightbar active fix when gamepad plugged first prior to game launch Another attempt to fix the lightbar by redoing the controller state mangement. For some reason: the Lightbar gets disabled when a controller is already plugged prior to game launch. It reverts back to normal until the next game event. * Revert "restoring notes for Button Labels." This reverts commitef4e37cb41
. * Reapply "restoring notes for Button Labels." This reverts commitf3ddd80024
. * Moving all Gamepad Hotplug changes to separate branch To ensure all Hotplug-related changes don't accidentally get leftover: this commit will revert all the back back to the accidental removal of Button Label's note. * added SDL's GameController naming convention as Fallback If EInputDeviceExplicit doesn't recognize a specific Controller Type or Device: it'll fallback to SDL's naming conventions. This helps troubleshooting Controller-related issues when using the debug console. * Official device naming scheme for EInputDeviceExplicit Changes some of EInputDeviceExplicit's names to match the device's official name (such as Nintendo Switch Pro Controller, Xbox Wireless Controller, Amazon Luna Controller, etc.) * spacing formatting fix * remove "SDL_HINT_GAMECONTROLLER_USE_BUTTON_LABELS" hint since #1045 will include it: we're gonna get rid of it on this code section to avoid conflicts. * moved EInputDevice Unknown class to the top priority * 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. * remove hid::GetInputDeviceName() from hid.ccp Now that SDL_GameControllerName handles Controller naming conventions, the hid.ccp portion of GetInputDeviceName is no longer needed. * Fix indentation --------- Co-authored-by: Hyper <34012267+hyperbx@users.noreply.github.com>
This commit is contained in:
parent
6a50f9fc1f
commit
b282cbc4a2
3 changed files with 26 additions and 60 deletions
|
@ -38,7 +38,7 @@ public:
|
||||||
|
|
||||||
SDL_GameControllerType GetControllerType() const
|
SDL_GameControllerType GetControllerType() const
|
||||||
{
|
{
|
||||||
return SDL_GameControllerTypeForIndex(index);
|
return SDL_GameControllerGetType(controller);
|
||||||
}
|
}
|
||||||
|
|
||||||
hid::EInputDevice GetInputDevice() const
|
hid::EInputDevice GetInputDevice() const
|
||||||
|
@ -49,9 +49,22 @@ public:
|
||||||
case SDL_CONTROLLER_TYPE_PS4:
|
case SDL_CONTROLLER_TYPE_PS4:
|
||||||
case SDL_CONTROLLER_TYPE_PS5:
|
case SDL_CONTROLLER_TYPE_PS5:
|
||||||
return hid::EInputDevice::PlayStation;
|
return hid::EInputDevice::PlayStation;
|
||||||
|
case SDL_CONTROLLER_TYPE_XBOX360:
|
||||||
|
case SDL_CONTROLLER_TYPE_XBOXONE:
|
||||||
|
return hid::EInputDevice::Xbox;
|
||||||
|
default:
|
||||||
|
return hid::EInputDevice::Unknown;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return hid::EInputDevice::Xbox;
|
const char* GetControllerName() const
|
||||||
|
{
|
||||||
|
auto result = SDL_GameControllerName(controller);
|
||||||
|
|
||||||
|
if (!result)
|
||||||
|
return "Unknown Device";
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Close()
|
void Close()
|
||||||
|
@ -178,12 +191,21 @@ 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.
|
||||||
if (hid::g_inputDeviceExplicit != controllerType)
|
if (hid::g_inputDeviceExplicit != controllerType)
|
||||||
{
|
{
|
||||||
hid::g_inputDeviceExplicit = controllerType;
|
hid::g_inputDeviceExplicit = controllerType;
|
||||||
|
|
||||||
LOGFN("Detected controller: {}", hid::GetInputDeviceName());
|
if (controllerType == hid::EInputDeviceExplicit::Unknown)
|
||||||
|
{
|
||||||
|
LOGFN("Detected controller: {} (Unknown Controller Type)", controllerName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LOGFN("Detected controller: {}", controllerName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,59 +27,3 @@ bool hid::IsInputDeviceController()
|
||||||
return hid::g_inputDevice != hid::EInputDevice::Keyboard &&
|
return hid::g_inputDevice != hid::EInputDevice::Keyboard &&
|
||||||
hid::g_inputDevice != hid::EInputDevice::Mouse;
|
hid::g_inputDevice != hid::EInputDevice::Mouse;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string hid::GetInputDeviceName()
|
|
||||||
{
|
|
||||||
switch (g_inputDevice)
|
|
||||||
{
|
|
||||||
case EInputDevice::Keyboard:
|
|
||||||
return "Keyboard";
|
|
||||||
|
|
||||||
case EInputDevice::Mouse:
|
|
||||||
return "Mouse";
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (g_inputDeviceExplicit)
|
|
||||||
{
|
|
||||||
case EInputDeviceExplicit::Xbox360:
|
|
||||||
return "Xbox 360";
|
|
||||||
|
|
||||||
case EInputDeviceExplicit::XboxOne:
|
|
||||||
return "Xbox One";
|
|
||||||
|
|
||||||
case EInputDeviceExplicit::DualShock3:
|
|
||||||
return "DualShock 3";
|
|
||||||
|
|
||||||
case EInputDeviceExplicit::DualShock4:
|
|
||||||
return "DualShock 4";
|
|
||||||
|
|
||||||
case EInputDeviceExplicit::SwitchPro:
|
|
||||||
return "Nintendo Switch Pro";
|
|
||||||
|
|
||||||
case EInputDeviceExplicit::Virtual:
|
|
||||||
return "Virtual";
|
|
||||||
|
|
||||||
case EInputDeviceExplicit::DualSense:
|
|
||||||
return "DualSense";
|
|
||||||
|
|
||||||
case EInputDeviceExplicit::Luna:
|
|
||||||
return "Amazon Luna";
|
|
||||||
|
|
||||||
case EInputDeviceExplicit::Stadia:
|
|
||||||
return "Google Stadia";
|
|
||||||
|
|
||||||
case EInputDeviceExplicit::NvShield:
|
|
||||||
return "NVIDIA Shield";
|
|
||||||
|
|
||||||
case EInputDeviceExplicit::SwitchJCLeft:
|
|
||||||
return "Nintendo Switch Joy-Con (Left)";
|
|
||||||
|
|
||||||
case EInputDeviceExplicit::SwitchJCRight:
|
|
||||||
return "Nintendo Switch Joy-Con (Right)";
|
|
||||||
|
|
||||||
case EInputDeviceExplicit::SwitchJCPair:
|
|
||||||
return "Nintendo Switch Joy-Con (Pair)";
|
|
||||||
}
|
|
||||||
|
|
||||||
return "Unknown";
|
|
||||||
}
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ namespace hid
|
||||||
{
|
{
|
||||||
enum class EInputDevice
|
enum class EInputDevice
|
||||||
{
|
{
|
||||||
|
Unknown,
|
||||||
Keyboard,
|
Keyboard,
|
||||||
Mouse,
|
Mouse,
|
||||||
Xbox,
|
Xbox,
|
||||||
|
@ -45,5 +46,4 @@ namespace hid
|
||||||
void SetProhibitedInputs(uint16_t wButtons = 0, bool leftStick = false, bool rightStick = false);
|
void SetProhibitedInputs(uint16_t wButtons = 0, bool leftStick = false, bool rightStick = false);
|
||||||
bool IsInputAllowed();
|
bool IsInputAllowed();
|
||||||
bool IsInputDeviceController();
|
bool IsInputDeviceController();
|
||||||
std::string GetInputDeviceName();
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue