Initial community commit
This commit is contained in:
parent
537bcbc862
commit
fc06254474
16440 changed files with 4239995 additions and 2 deletions
38
Src/Wasabi/api/timer/osx_timer.cpp
Normal file
38
Src/Wasabi/api/timer/osx_timer.cpp
Normal file
|
@ -0,0 +1,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);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue