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:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user