mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2026-04-26 20:31:41 +00:00
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.
This commit is contained in:
parent
bd071015b6
commit
7291987ece
1 changed files with 1 additions and 38 deletions
|
|
@ -74,12 +74,6 @@ public:
|
||||||
return controller;
|
return controller;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClearState()
|
|
||||||
{
|
|
||||||
memset(&state, 0, sizeof(state));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void PollAxis()
|
void PollAxis()
|
||||||
{
|
{
|
||||||
if (!CanPoll())
|
if (!CanPoll())
|
||||||
|
|
@ -179,11 +173,6 @@ inline Controller* FindController(int which)
|
||||||
|
|
||||||
static void SetControllerInputDevice(Controller* controller)
|
static void SetControllerInputDevice(Controller* controller)
|
||||||
{
|
{
|
||||||
if (g_activeController && g_activeController != controller)
|
|
||||||
{
|
|
||||||
g_activeController->ClearState();
|
|
||||||
}
|
|
||||||
|
|
||||||
g_activeController = controller;
|
g_activeController = controller;
|
||||||
|
|
||||||
if (App::s_isLoading)
|
if (App::s_isLoading)
|
||||||
|
|
@ -208,14 +197,9 @@ static void SetControllerTimeOfDayLED(Controller& controller, bool isNight)
|
||||||
auto g = isNight ? 0 : 37;
|
auto g = isNight ? 0 : 37;
|
||||||
auto b = isNight ? 101 : 184;
|
auto b = isNight ? 101 : 184;
|
||||||
|
|
||||||
// Ensure the lightbar is set correctly
|
controller.SetLED(r, g, b);
|
||||||
if (SDL_GameControllerHasLED(controller.controller))
|
|
||||||
{
|
|
||||||
SDL_GameControllerSetLED(controller.controller, r, g, b);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int HID_OnSDLEvent(void*, SDL_Event* event)
|
int HID_OnSDLEvent(void*, SDL_Event* event)
|
||||||
{
|
{
|
||||||
switch (event->type)
|
switch (event->type)
|
||||||
|
|
@ -231,12 +215,6 @@ int HID_OnSDLEvent(void*, SDL_Event* event)
|
||||||
g_controllers[freeIndex] = controller;
|
g_controllers[freeIndex] = controller;
|
||||||
|
|
||||||
SetControllerTimeOfDayLED(controller, App::s_isWerehog);
|
SetControllerTimeOfDayLED(controller, App::s_isWerehog);
|
||||||
|
|
||||||
// Ensure Player 1's controller is always the active controller
|
|
||||||
if (freeIndex == 0)
|
|
||||||
{
|
|
||||||
SetControllerInputDevice(&g_controllers[0]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
@ -249,19 +227,6 @@ int HID_OnSDLEvent(void*, SDL_Event* event)
|
||||||
if (controller)
|
if (controller)
|
||||||
controller->Close();
|
controller->Close();
|
||||||
|
|
||||||
// If Player 1's controller is removed, set the next available controller as active
|
|
||||||
if (controller == &g_controllers[0])
|
|
||||||
{
|
|
||||||
for (auto& ctrl : g_controllers)
|
|
||||||
{
|
|
||||||
if (ctrl.CanPoll())
|
|
||||||
{
|
|
||||||
SetControllerInputDevice(&ctrl);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -337,8 +302,6 @@ int HID_OnSDLEvent(void*, SDL_Event* event)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void hid::Init()
|
void hid::Init()
|
||||||
{
|
{
|
||||||
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1");
|
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1");
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue