1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-11-26 07:52:28 +02:00

Enable the SDL timer subsystem only if the backlight timeout is enabled.

This commit is contained in:
Ayla 2011-08-16 02:17:21 +02:00
parent 4fd4b234dc
commit e282f8a55d
2 changed files with 7 additions and 3 deletions

View File

@ -360,7 +360,7 @@ GMenu2X::GMenu2X()
setenv("SDL_FBCON_DONT_CLEAR", "1", 0); setenv("SDL_FBCON_DONT_CLEAR", "1", 0);
//Screen //Screen
if( SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO|SDL_INIT_JOYSTICK|SDL_INIT_TIMER)<0 ) { if( SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO|SDL_INIT_JOYSTICK)<0 ) {
ERROR("Could not initialize SDL: %s\n", SDL_GetError()); ERROR("Could not initialize SDL: %s\n", SDL_GetError());
quit(); quit();
} }

View File

@ -7,7 +7,7 @@
#include "powersaver.h" #include "powersaver.h"
#include "debug.h" #include "debug.h"
PowerSaver* PowerSaver::instance = NULL; PowerSaver* PowerSaver::instance = NULL;
Uint32 screenTimerCallback(Uint32 interval, void *param) Uint32 screenTimerCallback(Uint32, void *)
{ {
DEBUG("Disable Backlight Event\n"); DEBUG("Disable Backlight Event\n");
PowerSaver::getInstance()->disableScreen(); PowerSaver::getInstance()->disableScreen();
@ -22,12 +22,14 @@ PowerSaver* PowerSaver::getInstance() {
} }
PowerSaver::PowerSaver( ) { PowerSaver::PowerSaver( ) {
SDL_InitSubSystem(SDL_INIT_TIMER);
setScreenTimeout(0); setScreenTimeout(0);
screenTimer = NULL; screenTimer = NULL;
} }
PowerSaver::~PowerSaver() { PowerSaver::~PowerSaver() {
SDL_RemoveTimer(screenTimer); SDL_RemoveTimer(screenTimer);
SDL_QuitSubSystem(SDL_INIT_TIMER);
} }
void PowerSaver::setScreenTimeout( unsigned int seconds ) { void PowerSaver::setScreenTimeout( unsigned int seconds ) {
@ -39,6 +41,7 @@ void PowerSaver::resetScreenTimer() {
if ( screenTimer != NULL ) { if ( screenTimer != NULL ) {
SDL_RemoveTimer(screenTimer); SDL_RemoveTimer(screenTimer);
} }
addScreenTimer(); addScreenTimer();
//If display is off, turn on it //If display is off, turn on it
if ( !screenState ) { if ( !screenState ) {
@ -52,6 +55,7 @@ void PowerSaver::addScreenTimer() {
screenTimer = NULL; screenTimer = NULL;
return; return;
} }
screenTimer = SDL_AddTimer(screenTimeout*1000, screenTimerCallback,NULL); screenTimer = SDL_AddTimer(screenTimeout*1000, screenTimerCallback,NULL);
if ( screenTimer == NULL ) { if ( screenTimer == NULL ) {
ERROR("Could not initialize SDLTimer: %s\n", SDL_GetError()); ERROR("Could not initialize SDLTimer: %s\n", SDL_GetError());