1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2025-04-21 12:27:27 +03:00

Code factorisation (Add function inject_user_event() to utilities)

This commit is contained in:
Paul Cercueil
2013-08-28 13:14:08 -04:00
parent 3ff6dc93f2
commit 5d8fb6520f
5 changed files with 34 additions and 39 deletions

View File

@@ -2,6 +2,7 @@
#include "debug.h"
#include "inputmanager.h"
#include "utilities.h"
#include <SDL.h>
#include <atomic>
@@ -45,20 +46,6 @@ static std::shared_ptr<Clock::Timer> globalTimerInstance()
}
}
static void notify()
{
SDL_UserEvent e = {
.type = SDL_USEREVENT,
.code = REPAINT_MENU,
.data1 = NULL,
.data2 = NULL,
};
/* Inject an user event, that will be handled as a "repaint"
* event by the InputManager */
SDL_PushEvent((SDL_Event *) &e);
}
extern "C" Uint32 callbackFunc(Uint32 /*timeout*/, void */*d*/)
{
std::shared_ptr<Clock::Timer> timer = globalTimer.lock();
@@ -126,7 +113,8 @@ unsigned int Clock::Timer::update()
unsigned int Clock::Timer::callback()
{
unsigned int ms = update();
notify();
inject_user_event();
// TODO: SDL timer forgets adjusted interval if a timer was inserted or
// removed during the callback. So we should either fix that bug
// in SDL or ensure we don't insert/remove timers at runtime.