1
0
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:
Laserlicht
2025-07-14 20:38:03 +02:00
parent 2774502526
commit 3504d1ce38
21 changed files with 99 additions and 49 deletions

View File

@@ -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);