Hi,
I need a function to be called every x milliseconds. I have used the following functions on Windows : SetTimer() and KillTimer().
I looked into the PSPSDK documentation and the only two functions that I found (that I think could do the job) are the following: sceKernelSetAlarm() and sceKernelCancelAlarm().
However, I am not sure how to use these. The documentation does not provide too much information on these. I want to know if these are the appropriate functions to do a periodic call.
I was wondering if anyone has already used these and could point me in the right direction on what parameters to pass (small example).
Thanks.
Calling a function periodically
uhm..... why not do a thread with low priority which has something like:
Code: Select all
while(!quit){
sceKernelDelayThread(milliseconds);
my_function();
}
I dont know what part of the documentation you say is lacking but in my eyes it makes perfect sense.
i.e. do
i.e. do
Code: Select all
SceUInt alarm_handler(void *common)
{
// Do something, wont run in a thread so will have to set a semaphore or event flag
}
void set_alarm(void)
{
SceUID uid;
// Set an alarm for 1 second in the future
uid = sceKernelSetAlarm(1000000, alarm_handler, NULL);
}