mirror of https://github.com/encounter/SDL.git
switch: use unix timers
This commit is contained in:
parent
93d84618b2
commit
481c32b352
|
@ -25629,6 +25629,7 @@ $as_echo "#define SDL_TIMER_UNIX 1" >>confdefs.h
|
||||||
EXTRA_CFLAGS="$EXTRA_CFLAGS -DSDL_VIDEO_STATIC_ANGLE"
|
EXTRA_CFLAGS="$EXTRA_CFLAGS -DSDL_VIDEO_STATIC_ANGLE"
|
||||||
EXTRA_LDFLAGS="-march=armv8-a -fPIE -L${DEVKITPRO}/libnx/lib -lEGL -lglapi -ldrm_nouveau -lnx"
|
EXTRA_LDFLAGS="-march=armv8-a -fPIE -L${DEVKITPRO}/libnx/lib -lEGL -lglapi -ldrm_nouveau -lnx"
|
||||||
CheckDeclarationAfterStatement
|
CheckDeclarationAfterStatement
|
||||||
|
CheckClockGettime
|
||||||
|
|
||||||
# Set up files for the video library
|
# Set up files for the video library
|
||||||
if test x$enable_video = xyes; then
|
if test x$enable_video = xyes; then
|
||||||
|
@ -25671,27 +25672,11 @@ $as_echo "#define SDL_JOYSTICK_SWITCH 1" >>confdefs.h
|
||||||
# Set up files for the timer library
|
# Set up files for the timer library
|
||||||
if test x$enable_timers = xyes; then
|
if test x$enable_timers = xyes; then
|
||||||
|
|
||||||
$as_echo "#define SDL_TIMER_SWITCH 1" >>confdefs.h
|
$as_echo "#define SDL_TIMER_UNIX 1" >>confdefs.h
|
||||||
|
|
||||||
SOURCES="$SOURCES $srcdir/src/timer/switch/*.c"
|
SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
|
||||||
have_timers=yes
|
have_timers=yes
|
||||||
fi
|
fi
|
||||||
# Set up files for the system power library
|
|
||||||
if test x$enable_power = xyes; then
|
|
||||||
|
|
||||||
$as_echo "#define SDL_POWER_SWITCH 1" >>confdefs.h
|
|
||||||
|
|
||||||
SOURCES="$SOURCES $srcdir/src/power/switch/*.c"
|
|
||||||
have_power=yes
|
|
||||||
fi
|
|
||||||
# Set up files for the system filesystem library
|
|
||||||
if test x$enable_filesystem = xyes; then
|
|
||||||
|
|
||||||
$as_echo "#define SDL_FILESYSTEM_SWITCH 1" >>confdefs.h
|
|
||||||
|
|
||||||
SOURCES="$SOURCES $srcdir/src/filesystem/switch/*.c"
|
|
||||||
have_filesystem=yes
|
|
||||||
fi
|
|
||||||
# Set up files for the thread library
|
# Set up files for the thread library
|
||||||
if test x$enable_threads = xyes; then
|
if test x$enable_threads = xyes; then
|
||||||
|
|
||||||
|
|
|
@ -1,78 +0,0 @@
|
||||||
/*
|
|
||||||
Simple DirectMedia Layer
|
|
||||||
Copyright (C) 1997-2015 Sam Lantinga <slouken@libsdl.org>
|
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied
|
|
||||||
warranty. In no event will the authors be held liable for any damages
|
|
||||||
arising from the use of this software.
|
|
||||||
|
|
||||||
Permission is granted to anyone to use this software for any purpose,
|
|
||||||
including commercial applications, and to alter it and redistribute it
|
|
||||||
freely, subject to the following restrictions:
|
|
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not
|
|
||||||
claim that you wrote the original software. If you use this software
|
|
||||||
in a product, an acknowledgment in the product documentation would be
|
|
||||||
appreciated but is not required.
|
|
||||||
2. Altered source versions must be plainly marked as such, and must not be
|
|
||||||
misrepresented as being the original software.
|
|
||||||
3. This notice may not be removed or altered from any source distribution.
|
|
||||||
*/
|
|
||||||
#include "../../SDL_internal.h"
|
|
||||||
|
|
||||||
#ifdef SDL_TIMER_SWITCH
|
|
||||||
|
|
||||||
#include "SDL_thread.h"
|
|
||||||
#include "SDL_timer.h"
|
|
||||||
#include "../SDL_timer_c.h"
|
|
||||||
#include <switch.h>
|
|
||||||
|
|
||||||
static bool started = false;
|
|
||||||
|
|
||||||
static Uint64 start = 0;
|
|
||||||
|
|
||||||
void
|
|
||||||
SDL_TicksInit(void)
|
|
||||||
{
|
|
||||||
if (started) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
start = SDL_GetPerformanceCounter();
|
|
||||||
started = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
SDL_TicksQuit(void)
|
|
||||||
{
|
|
||||||
started = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Uint32 SDL_GetTicks(void)
|
|
||||||
{
|
|
||||||
if (!started) {
|
|
||||||
SDL_TicksInit();
|
|
||||||
}
|
|
||||||
|
|
||||||
return (Uint32) ((SDL_GetPerformanceCounter() - start) * 1000 / SDL_GetPerformanceFrequency());
|
|
||||||
}
|
|
||||||
|
|
||||||
Uint64
|
|
||||||
SDL_GetPerformanceCounter(void)
|
|
||||||
{
|
|
||||||
return svcGetSystemTick();
|
|
||||||
}
|
|
||||||
|
|
||||||
Uint64
|
|
||||||
SDL_GetPerformanceFrequency(void)
|
|
||||||
{
|
|
||||||
return 19200000;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
SDL_Delay(Uint32 ms)
|
|
||||||
{
|
|
||||||
svcSleepThread((Uint64) ms * 1000000);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* SDL_TIMER_SWITCH */
|
|
Loading…
Reference in New Issue