when resolving filenames also take system and hidden files into account.
[Rockbox.git] / uisimulator / sdl / timer.c
blobf103ab5ebdcc5c3ef012bac9fd7642af1a6a8372
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id: timer.h 13806 2007-07-06 21:36:32Z jethead71 $
10 * Copyright (C) 2005 Kévin Ferrare
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
20 #include "timer.h"
21 #include <SDL_timer.h>
23 static int timer_prio = -1;
24 void (*global_timer_callback)(void);
25 SDL_TimerID timerId;
27 Uint32 SDL_timer_callback(Uint32 interval, void *param){
28 (void)param;
29 global_timer_callback();
30 return(interval);
33 #define cycles_to_miliseconds(cycles) \
34 ((int)((1000*cycles)/TIMER_FREQ))
36 bool timer_register(int reg_prio, void (*unregister_callback)(void),
37 long cycles, int int_prio, void (*timer_callback)(void))
39 (void)int_prio;/* interrupt priority not used */
40 (void)unregister_callback;
41 if (reg_prio <= timer_prio || cycles == 0)
42 return false;
43 timer_prio=reg_prio;
44 global_timer_callback=timer_callback;
45 timerId=SDL_AddTimer(cycles_to_miliseconds(cycles), SDL_timer_callback, 0);
46 return true;
49 bool timer_set_period(long cycles)
51 SDL_RemoveTimer (timerId);
52 timerId=SDL_AddTimer(cycles_to_miliseconds(cycles), SDL_timer_callback, 0);
53 return true;
56 void timer_unregister(void)
58 SDL_RemoveTimer (timerId);
59 timer_prio = -1;