mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-27 22:49:25 +02:00
optimized fps draw
This commit is contained in:
@@ -33,6 +33,7 @@
|
||||
#include <SDL_events.h>
|
||||
#include <SDL_timer.h>
|
||||
#include <SDL_clipboard.h>
|
||||
#include <SDL_power.h>
|
||||
|
||||
InputHandler::InputHandler()
|
||||
: enableMouse(settings["input"]["enableMouse"].Bool())
|
||||
@@ -148,6 +149,21 @@ void InputHandler::copyToClipBoard(const std::string & text)
|
||||
SDL_SetClipboardText(text.c_str());
|
||||
}
|
||||
|
||||
PowerState InputHandler::getPowerState()
|
||||
{
|
||||
int seconds;
|
||||
int percent;
|
||||
auto sdlPowerState = SDL_GetPowerInfo(&seconds, &percent);
|
||||
|
||||
PowerStateMode powerState = PowerStateMode::UNKNOWN;
|
||||
if(sdlPowerState == SDL_POWERSTATE_ON_BATTERY)
|
||||
powerState = PowerStateMode::ON_BATTERY;
|
||||
else if(sdlPowerState == SDL_POWERSTATE_CHARGING || sdlPowerState == SDL_POWERSTATE_CHARGED)
|
||||
powerState = PowerStateMode::CHARGING;
|
||||
|
||||
return PowerState{powerState, seconds, percent};
|
||||
}
|
||||
|
||||
std::vector<SDL_Event> InputHandler::acquireEvents()
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(eventsMutex);
|
||||
|
||||
Reference in New Issue
Block a user