diff --git a/AerofoilAndroid/app/jni/AerofoilPortable b/AerofoilAndroid/app/jni/AerofoilPortable new file mode 120000 index 0000000..52ef543 --- /dev/null +++ b/AerofoilAndroid/app/jni/AerofoilPortable @@ -0,0 +1 @@ +../../../AerofoilPortable \ No newline at end of file diff --git a/AerofoilAndroid/app/jni/main/Android.mk b/AerofoilAndroid/app/jni/main/Android.mk index 9cd7b6c..8b9a19a 100644 --- a/AerofoilAndroid/app/jni/main/Android.mk +++ b/AerofoilAndroid/app/jni/main/Android.mk @@ -9,6 +9,7 @@ SDL_PATH := ../SDL LOCAL_C_INCLUDES := $(LOCAL_PATH)/$(SDL_PATH)/include \ $(LOCAL_PATH)/../GpShell \ $(LOCAL_PATH)/../GpCommon \ + $(LOCAL_PATH)/../AerofoilPortable \ $(LOCAL_PATH)/../AerofoilSDL \ $(LOCAL_PATH)/../Common \ $(LOCAL_PATH)/../PortabilityLayer @@ -23,7 +24,7 @@ LOCAL_SRC_FILES := \ LOCAL_SHARED_LIBRARIES := SDL2 -LOCAL_STATIC_LIBRARIES := GpShell GpFontHandler_FreeType2 AerofoilSDL GpApp +LOCAL_STATIC_LIBRARIES := GpShell GpFontHandler_FreeType2 AerofoilPortable AerofoilSDL GpApp LOCAL_LDLIBS := -lGLESv1_CM -lGLESv2 -llog diff --git a/AerofoilAndroid/app/jni/main/GpSystemServices_Android.cpp b/AerofoilAndroid/app/jni/main/GpSystemServices_Android.cpp index ba447f4..c70cede 100644 --- a/AerofoilAndroid/app/jni/main/GpSystemServices_Android.cpp +++ b/AerofoilAndroid/app/jni/main/GpSystemServices_Android.cpp @@ -1,7 +1,6 @@ #include "GpSystemServices_Android.h" -#include "GpMutex_Cpp11.h" -#include "GpThreadEvent_Cpp11.h" +#include "IGpThreadEvent.h" #include "SDL.h" #include @@ -32,29 +31,6 @@ GpSystemServices_Android::GpSystemServices_Android() { } -int64_t GpSystemServices_Android::GetTime() const -{ - time_t t = time(nullptr); - return static_cast(t) - 2082844800; -} - -void GpSystemServices_Android::GetLocalDateTime(unsigned int &year, unsigned int &month, unsigned int &day, unsigned int &hour, unsigned int &minute, unsigned int &second) const -{ - time_t t = time(nullptr); - tm *tmObject = localtime(&t); - year = static_cast(tmObject->tm_year); - month = static_cast(tmObject->tm_mon + 1); - hour = static_cast(tmObject->tm_hour); - minute = static_cast(tmObject->tm_min); - second = static_cast(tmObject->tm_sec); -} - -IGpMutex *GpSystemServices_Android::CreateMutex() -{ - return GpMutex_Cpp11_NonRecursive::Create(); -} - - void *GpSystemServices_Android::CreateThread(ThreadFunc_t threadFunc, void *context) { IGpThreadEvent *evt = CreateThreadEvent(true, false); @@ -79,23 +55,6 @@ void *GpSystemServices_Android::CreateThread(ThreadFunc_t threadFunc, void *cont return thread; } -IGpMutex *GpSystemServices_Android::CreateRecursiveMutex() -{ - return GpMutex_Cpp11_Recursive::Create(); -} - -IGpThreadEvent *GpSystemServices_Android::CreateThreadEvent(bool autoReset, bool startSignaled) -{ - return GpThreadEvent_Cpp11::Create(autoReset, startSignaled); -} - -uint64_t GpSystemServices_Android::GetFreeMemoryCosmetic() const -{ - long pages = sysconf(_SC_AVPHYS_PAGES); - long pageSize = sysconf(_SC_PAGE_SIZE); - return pages * pageSize; -} - void GpSystemServices_Android::Beep() const { } diff --git a/AerofoilAndroid/app/jni/main/GpSystemServices_Android.h b/AerofoilAndroid/app/jni/main/GpSystemServices_Android.h index 63b29f5..b1fdf43 100644 --- a/AerofoilAndroid/app/jni/main/GpSystemServices_Android.h +++ b/AerofoilAndroid/app/jni/main/GpSystemServices_Android.h @@ -1,20 +1,14 @@ #pragma once -#include "IGpSystemServices.h" +#include "GpSystemServices_POSIX.h" #include "GpCoreDefs.h" -class GpSystemServices_Android final : public IGpSystemServices +class GpSystemServices_Android final : public GpSystemServices_POSIX { public: GpSystemServices_Android(); - int64_t GetTime() const override; - void GetLocalDateTime(unsigned int &year, unsigned int &month, unsigned int &day, unsigned int &hour, unsigned int &minute, unsigned int &second) const override; - IGpMutex *CreateMutex() override; - IGpMutex *CreateRecursiveMutex() override; void *CreateThread(ThreadFunc_t threadFunc, void *context) override; - IGpThreadEvent *CreateThreadEvent(bool autoReset, bool startSignaled) override; - uint64_t GetFreeMemoryCosmetic() const override; void Beep() const override; bool IsTouchscreen() const override; bool IsUsingMouseAsTouch() const override; diff --git a/AerofoilAndroid/make_symlinks.bat b/AerofoilAndroid/make_symlinks.bat index 3d4db37..d683cfe 100644 --- a/AerofoilAndroid/make_symlinks.bat +++ b/AerofoilAndroid/make_symlinks.bat @@ -5,6 +5,7 @@ call remove_symlinks.bat mklink /D app\jni\AerofoilSDL ..\..\..\AerofoilSDL +mklink /D app\jni\AerofoilPortable ..\..\..\AerofoilPortable mklink /D app\jni\Common ..\..\..\Common mklink /D app\jni\SDL2 ..\..\..\SDL2-2.0.12 mklink /D app\jni\GpApp ..\..\..\GpApp diff --git a/AerofoilAndroid/remove_symlinks.bat b/AerofoilAndroid/remove_symlinks.bat index d5f28a2..d9bdc0b 100644 --- a/AerofoilAndroid/remove_symlinks.bat +++ b/AerofoilAndroid/remove_symlinks.bat @@ -2,6 +2,7 @@ @cd /d "%~dp0" rmdir app\jni\AerofoilSDL +rmdir app\jni\AerofoilPortable rmdir app\jni\Common rmdir app\jni\SDL2 rmdir app\jni\GpShell diff --git a/AerofoilPortable/Android.mk b/AerofoilPortable/Android.mk new file mode 100644 index 0000000..905a937 --- /dev/null +++ b/AerofoilPortable/Android.mk @@ -0,0 +1,20 @@ +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE := AerofoilPortable + +LOCAL_C_INCLUDES := \ + $(LOCAL_PATH)/../GpCommon \ + $(LOCAL_PATH)/../GpShell \ + $(LOCAL_PATH)/../Common \ + $(LOCAL_PATH)/../PortabilityLayer + +LOCAL_CFLAGS := -DGP_DEBUG_CONFIG=0 + +# Add your application source files here... +LOCAL_SRC_FILES := \ + GpThreadEvent_Cpp11.cpp \ + GpSystemServices_POSIX.cpp + +include $(BUILD_STATIC_LIBRARY) diff --git a/AerofoilSDL/GpMutex_Cpp11.h b/AerofoilPortable/GpMutex_Cpp11.h similarity index 100% rename from AerofoilSDL/GpMutex_Cpp11.h rename to AerofoilPortable/GpMutex_Cpp11.h diff --git a/AerofoilPortable/GpSystemServices_POSIX.cpp b/AerofoilPortable/GpSystemServices_POSIX.cpp new file mode 100644 index 0000000..dbfac09 --- /dev/null +++ b/AerofoilPortable/GpSystemServices_POSIX.cpp @@ -0,0 +1,50 @@ +#include "GpSystemServices_POSIX.h" + +#include "GpMutex_Cpp11.h" +#include "GpThreadEvent_Cpp11.h" + +#include +#include + +GpSystemServices_POSIX::GpSystemServices_POSIX() +{ +} + +int64_t GpSystemServices_POSIX::GetTime() const +{ + time_t t = time(nullptr); + return static_cast(t) - 2082844800; +} + +void GpSystemServices_POSIX::GetLocalDateTime(unsigned int &year, unsigned int &month, unsigned int &day, unsigned int &hour, unsigned int &minute, unsigned int &second) const +{ + time_t t = time(nullptr); + tm *tmObject = localtime(&t); + year = static_cast(tmObject->tm_year); + month = static_cast(tmObject->tm_mon + 1); + hour = static_cast(tmObject->tm_hour); + minute = static_cast(tmObject->tm_min); + second = static_cast(tmObject->tm_sec); +} + +IGpMutex *GpSystemServices_POSIX::CreateMutex() +{ + return GpMutex_Cpp11_NonRecursive::Create(); +} + +IGpMutex *GpSystemServices_POSIX::CreateRecursiveMutex() +{ + return GpMutex_Cpp11_Recursive::Create(); +} + +IGpThreadEvent *GpSystemServices_POSIX::CreateThreadEvent(bool autoReset, bool startSignaled) +{ + return GpThreadEvent_Cpp11::Create(autoReset, startSignaled); +} + +uint64_t GpSystemServices_POSIX::GetFreeMemoryCosmetic() const +{ + long pages = sysconf(_SC_AVPHYS_PAGES); + long pageSize = sysconf(_SC_PAGE_SIZE); + return pages * pageSize; +} diff --git a/AerofoilPortable/GpSystemServices_POSIX.h b/AerofoilPortable/GpSystemServices_POSIX.h new file mode 100644 index 0000000..1aadfb1 --- /dev/null +++ b/AerofoilPortable/GpSystemServices_POSIX.h @@ -0,0 +1,17 @@ +#pragma once + +#include "IGpSystemServices.h" +#include "GpCoreDefs.h" + +class GpSystemServices_POSIX : public IGpSystemServices +{ +public: + GpSystemServices_POSIX(); + + int64_t GetTime() const override; + void GetLocalDateTime(unsigned int &year, unsigned int &month, unsigned int &day, unsigned int &hour, unsigned int &minute, unsigned int &second) const override; + IGpMutex *CreateMutex() override; + IGpMutex *CreateRecursiveMutex() override; + IGpThreadEvent *CreateThreadEvent(bool autoReset, bool startSignaled) override; + uint64_t GetFreeMemoryCosmetic() const override; +}; diff --git a/AerofoilSDL/GpThreadEvent_Cpp11.cpp b/AerofoilPortable/GpThreadEvent_Cpp11.cpp similarity index 100% rename from AerofoilSDL/GpThreadEvent_Cpp11.cpp rename to AerofoilPortable/GpThreadEvent_Cpp11.cpp diff --git a/AerofoilSDL/GpThreadEvent_Cpp11.h b/AerofoilPortable/GpThreadEvent_Cpp11.h similarity index 100% rename from AerofoilSDL/GpThreadEvent_Cpp11.h rename to AerofoilPortable/GpThreadEvent_Cpp11.h diff --git a/AerofoilSDL/Android.mk b/AerofoilSDL/Android.mk index 9e490c8..471fc92 100644 --- a/AerofoilSDL/Android.mk +++ b/AerofoilSDL/Android.mk @@ -21,7 +21,6 @@ LOCAL_SRC_FILES := \ GpDisplayDriver_SDL_GL2.cpp \ GpFiber_SDL.cpp \ GpFiberStarter_SDL.cpp \ - GpThreadEvent_Cpp11.cpp \ ShaderCode/CopyQuadP.cpp \ ShaderCode/DrawQuadPaletteP.cpp \ ShaderCode/DrawQuad32P.cpp \