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

don't waste CPU redrawing the screen when there's no input

Signed-off-by: Ulrich Hecht <ulrich.hecht@gmail.com>
This commit is contained in:
Ulrich Hecht 2010-06-20 13:01:50 +02:00 committed by Maarten ter Huurne
parent c52b239bc0
commit ac2fa73962
3 changed files with 7 additions and 5 deletions

View File

@ -940,7 +940,8 @@ void GMenu2X::main() {
} }
//#ifdef TARGET_GP2X //#ifdef TARGET_GP2X
input.update(); while (!input.update())
usleep(LOOP_DELAY);
if ( input[ACTION_B] && menu->selLink()!=NULL ) menu->selLink()->run(); if ( input[ACTION_B] && menu->selLink()!=NULL ) menu->selLink()->run();
else if ( input[ACTION_START] ) options(); else if ( input[ACTION_START] ) options();
else if ( input[ACTION_SELECT] ) contextMenu(); else if ( input[ACTION_SELECT] ) contextMenu();
@ -993,8 +994,6 @@ void GMenu2X::main() {
offset = menu->sectionLinks()->size()>linksPerPage ? 2 : 6; offset = menu->sectionLinks()->size()>linksPerPage ? 2 : 6;
} }
} }
usleep(LOOP_DELAY);
} }
} }

View File

@ -128,7 +128,8 @@ void InputManager::setActionsCount(int count) {
} }
} }
void InputManager::update() { bool InputManager::update() {
bool anyactions = false;
SDL_JoystickUpdate(); SDL_JoystickUpdate();
events.clear(); events.clear();
@ -145,11 +146,13 @@ void InputManager::update() {
if (tick-actionTick[x]>interval[x]) { if (tick-actionTick[x]>interval[x]) {
actions[x] = true; actions[x] = true;
actionTick[x] = tick; actionTick[x] = tick;
anyactions = true;
} }
} else { } else {
actionTick[x] = 0; actionTick[x] = 0;
} }
} }
return anyactions;
} }
int InputManager::count() { int InputManager::count() {

View File

@ -78,7 +78,7 @@ public:
vector<bool> actions; vector<bool> actions;
vector<MappingList> mappings; vector<MappingList> mappings;
void update(); bool update();
int count(); int count();
void setActionsCount(int count); void setActionsCount(int count);
void setInterval(int ms, int action = -1); void setInterval(int ms, int action = -1);