mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-22 20:51:31 +00:00
Pause when controller is disconnected
Controller battery warnings added
This commit is contained in:
parent
1a450ef23d
commit
5c560039d8
1 changed files with 18 additions and 0 deletions
|
@ -806,6 +806,7 @@ IN_Update(void)
|
|||
break;
|
||||
}
|
||||
if (event.cdevice.which == SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(controller))) {
|
||||
Cvar_SetValue("paused", 1);
|
||||
IN_Controller_Shutdown(true);
|
||||
IN_Controller_Init(false);
|
||||
}
|
||||
|
@ -820,6 +821,23 @@ IN_Update(void)
|
|||
}
|
||||
break;
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2, 24, 0) // support for battery status changes
|
||||
case SDL_JOYBATTERYUPDATED:
|
||||
if (!controller || event.jbattery.which != SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(controller)))
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (event.jbattery.level == SDL_JOYSTICK_POWER_LOW)
|
||||
{
|
||||
Com_Printf("WARNING: Gamepad battery Low, it is recommended to connect it by cable.\n");
|
||||
}
|
||||
else if (event.jbattery.level == SDL_JOYSTICK_POWER_EMPTY)
|
||||
{
|
||||
SCR_CenterPrint("ALERT: Gamepad battery almost Empty, will disconnect anytime.\n");
|
||||
}
|
||||
break;
|
||||
#endif // SDL_VERSION_ATLEAST(2, 24, 0)
|
||||
|
||||
case SDL_QUIT:
|
||||
Com_Quit();
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue