From 481c32b352f95b823cdb62761d16152d1b604342 Mon Sep 17 00:00:00 2001 From: cpasjuste Date: Sun, 5 Apr 2020 11:10:48 +0200 Subject: [PATCH] switch: use unix timers --- configure | 21 ++------- src/timer/switch/SDL_systimer.c | 78 --------------------------------- 2 files changed, 3 insertions(+), 96 deletions(-) delete mode 100644 src/timer/switch/SDL_systimer.c diff --git a/configure b/configure index 1dfc33d3b..7b0675931 100755 --- a/configure +++ b/configure @@ -25629,6 +25629,7 @@ $as_echo "#define SDL_TIMER_UNIX 1" >>confdefs.h EXTRA_CFLAGS="$EXTRA_CFLAGS -DSDL_VIDEO_STATIC_ANGLE" EXTRA_LDFLAGS="-march=armv8-a -fPIE -L${DEVKITPRO}/libnx/lib -lEGL -lglapi -ldrm_nouveau -lnx" CheckDeclarationAfterStatement + CheckClockGettime # Set up files for the video library 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 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 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 if test x$enable_threads = xyes; then diff --git a/src/timer/switch/SDL_systimer.c b/src/timer/switch/SDL_systimer.c deleted file mode 100644 index 5c5d209e0..000000000 --- a/src/timer/switch/SDL_systimer.c +++ /dev/null @@ -1,78 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2015 Sam Lantinga - - 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 - -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 */