1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-07-02 17:52:54 +03:00

Reinitialize the powersaver timer when a suspend has been detected.

This commit is contained in:
Paul Cercueil 2012-02-02 23:36:26 +01:00
parent 78b607033a
commit 2d81b13459
2 changed files with 13 additions and 2 deletions

View File

@ -9,7 +9,16 @@
PowerSaver *PowerSaver::instance = NULL;
Uint32 screenTimerCallback(Uint32, void *) {
Uint32 screenTimerCallback(Uint32 timeout, void *d) {
unsigned int * old_ticks = (unsigned int *) d;
unsigned int new_ticks = SDL_GetTicks();
if (new_ticks > *old_ticks + timeout + 1000) {
DEBUG("Suspend occured, restarting timer\n");
*old_ticks = new_ticks;
return timeout;
}
DEBUG("Disable Backlight Event\n");
PowerSaver::getInstance()->disableScreen();
return 0;
@ -62,7 +71,8 @@ void PowerSaver::addScreenTimer() {
return;
}
screenTimer = SDL_AddTimer(screenTimeout * 1000, screenTimerCallback, NULL);
timeout_startms = SDL_GetTicks();
screenTimer = SDL_AddTimer(screenTimeout * 1000, screenTimerCallback, &timeout_startms);
if (screenTimer == NULL) {
ERROR("Could not initialize SDLTimer: %s\n", SDL_GetError());
}

View File

@ -23,6 +23,7 @@ private:
static PowerSaver *instance;
bool screenState;
unsigned int screenTimeout;
unsigned int timeout_startms;
SDL_TimerID screenTimer;
};