#include #include "../Timer.h" Timer timer; SDL_TimerID timerId; void timerISR() { timer.update(); } Timer::Timer() { _freq = 50; timerId = SDL_AddTimer(1000/_freq, [] (Uint32, void*) -> Uint32 { timerISR(); return 1000 / timer.getFrequency(); }, nullptr); } Timer::~Timer() { SDL_RemoveTimer(timerId); } void Timer::update() { // TODO _ticks++; } uint32_t Timer::getTicks() const { return _ticks; } void Timer::setFrequency(uint16_t freq) { _freq = freq; // TODO } uint16_t Timer::getFrequency() const { return _freq; } void Timer::setDivider(uint16_t div) { // TODO } Timer::Callback Timer::setCallback(Timer::Callback callback) { auto oldCallback = _callback; _callback = callback; return oldCallback; }