blob: 450c58e1cded66c83e50512071a43993c59af14e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
#include "osx_timer.h"
#include <api/timer/timerclient.h>
timer_api *timerApi = NULL;
TimerApi::TimerApi()
{
mainEventLoop = GetMainEventLoop();
}
static void WasabiTimerProc(EventLoopTimerRef inTimer, void * inUserData)
{
TimerClient *client = (TimerClient *)inUserData;
if (client)
client->timerclient_timerCallback(inTimer);
}
TimerToken TimerApi::timer_add(TimerClient *client, int id, int ms)
{
EventLoopTimerRef token;
OSStatus err = InstallEventLoopTimer(mainEventLoop,
(float)ms/1000.0f,
(float)ms/1000.0f,
WasabiTimerProc,
client,
&token);
if (err == noErr)
return token;
else
return 0;
}
void TimerApi::timer_remove(TimerClient *client, TimerToken token)
{
RemoveEventLoopTimer(token);
}
|