mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-11 13:22:33 +00:00
SDL timer support
This patch adds a Genode-specific SDL timer backend. Fixes #211.
This commit is contained in:
parent
ce6fa75f7e
commit
b6896cf22f
libports
@ -18,7 +18,9 @@ SHARED_LIB = yes
|
||||
|
||||
# backends
|
||||
SRC_CC = SDL_genode_fb_video.cc \
|
||||
SDL_genode_fb_events.cc
|
||||
SDL_genode_fb_events.cc \
|
||||
SDL_genodeaudio.cc \
|
||||
SDL_systimer.cc
|
||||
|
||||
INC_DIR += $(REP_DIR)/include/SDL \
|
||||
$(REP_DIR)/src/lib/sdl \
|
||||
@ -53,8 +55,8 @@ INC_DIR += $(SDL_DIR)/src/thread
|
||||
SRC_C += SDL_cpuinfo.c
|
||||
|
||||
# timer subsystem
|
||||
SRC_C += SDL_systimer.c \
|
||||
SDL_timer.c
|
||||
SRC_C += SDL_timer.c
|
||||
INC_DIR += $(SDL_DIR)/src/timer
|
||||
|
||||
# video subsystem
|
||||
SRC_C += SDL_blit_0.c \
|
||||
@ -92,8 +94,8 @@ SRC_C += SDL_audio.c \
|
||||
SDL_mixer_m68k.c \
|
||||
SDL_mixer_MMX.c \
|
||||
SDL_mixer_MMX_VC.c \
|
||||
SDL_wave.c \
|
||||
SDL_genodeaudio.c
|
||||
SDL_wave.c
|
||||
|
||||
INC_DIR += $(SDL_DIR)/src/audio
|
||||
|
||||
# file I/O subsystem
|
||||
@ -116,6 +118,7 @@ CC_OPT_SDL_wave += -Wno-unused-but-set-variable
|
||||
# backend pathes
|
||||
vpath % $(REP_DIR)/src/lib/sdl
|
||||
vpath % $(REP_DIR)/src/lib/sdl/audio
|
||||
vpath % $(REP_DIR)/src/lib/sdl/timer
|
||||
vpath % $(REP_DIR)/src/lib/sdl/video
|
||||
|
||||
# contribution pathes
|
||||
@ -130,7 +133,6 @@ vpath %.c $(SDL_DIR)/src/audio
|
||||
vpath %.c $(SDL_DIR)/src/thread
|
||||
vpath %.c $(SDL_DIR)/src/thread/pthread
|
||||
vpath %.c $(SDL_DIR)/src/timer
|
||||
vpath %.c $(SDL_DIR)/src/timer/dummy
|
||||
vpath %.c $(SDL_DIR)/src/events
|
||||
vpath %.c $(SDL_DIR)/src/cpuinfo
|
||||
vpath %.c $(SDL_DIR)/src/file
|
||||
|
97
libports/src/lib/sdl/timer/SDL_systimer.cc
Normal file
97
libports/src/lib/sdl/timer/SDL_systimer.cc
Normal file
@ -0,0 +1,97 @@
|
||||
/*
|
||||
* \brief Genode-specific timer backend
|
||||
* \author Christian Prochaska
|
||||
* \date 2012-03-13
|
||||
*
|
||||
* based on the dummy SDL timer
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2012 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
extern "C" {
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include "SDL_config.h"
|
||||
|
||||
#include "SDL_timer.h"
|
||||
#include "SDL_timer_c.h"
|
||||
|
||||
|
||||
void SDL_StartTicks(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Uint32 SDL_GetTicks (void)
|
||||
{
|
||||
printf("SDL_GetTicks() called - not implemented yet\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void SDL_Delay (Uint32 ms)
|
||||
{
|
||||
usleep(ms*1000);
|
||||
}
|
||||
|
||||
|
||||
#include "SDL_thread.h"
|
||||
|
||||
|
||||
/* Data to handle a single periodic alarm */
|
||||
static int timer_alive = 0;
|
||||
static SDL_Thread *timer = NULL;
|
||||
|
||||
|
||||
static int RunTimer(void *unused)
|
||||
{
|
||||
while ( timer_alive ) {
|
||||
if ( SDL_timer_running ) {
|
||||
SDL_ThreadedTimerCheck();
|
||||
}
|
||||
SDL_Delay(1);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
/* This is only called if the event thread is not running */
|
||||
int SDL_SYS_TimerInit(void)
|
||||
{
|
||||
timer_alive = 1;
|
||||
timer = SDL_CreateThread(RunTimer, NULL);
|
||||
if ( timer == NULL )
|
||||
return(-1);
|
||||
return(SDL_SetTimerThreaded(1));
|
||||
}
|
||||
|
||||
|
||||
void SDL_SYS_TimerQuit(void)
|
||||
{
|
||||
timer_alive = 0;
|
||||
if ( timer ) {
|
||||
SDL_WaitThread(timer, NULL);
|
||||
timer = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int SDL_SYS_StartTimer(void)
|
||||
{
|
||||
SDL_SetError("Internal logic error: threaded timer in use");
|
||||
return(-1);
|
||||
}
|
||||
|
||||
|
||||
void SDL_SYS_StopTimer(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user