mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-09-23 06:53:43 +00:00
Android fixups
This commit is contained in:
@@ -18,6 +18,8 @@
|
||||
|
||||
#include "GpAndroid.h"
|
||||
|
||||
#include <exception>
|
||||
|
||||
GpAndroidGlobals g_gpAndroidGlobals;
|
||||
|
||||
extern "C" IGpFontHandler *GpDriver_CreateFontHandler_FreeType2(const GpFontHandlerProperties &properties);
|
||||
@@ -38,7 +40,7 @@ int main(int argc, char* argv[])
|
||||
|
||||
g_gpGlobalConfig.m_displayDriverType = EGpDisplayDriverType_SDL_GL2;
|
||||
|
||||
g_gpGlobalConfig.m_audioDriverType = EGpAudioDriverType_None;
|
||||
g_gpGlobalConfig.m_audioDriverType = EGpAudioDriverType_SDL2;
|
||||
|
||||
g_gpGlobalConfig.m_fontHandlerType = EGpFontHandlerType_FreeType2;
|
||||
|
||||
@@ -55,5 +57,12 @@ int main(int argc, char* argv[])
|
||||
|
||||
int returnCode = GpMain::Run();
|
||||
|
||||
SDL_Quit();
|
||||
|
||||
// This doesn't even actually exit, but it does stop this stupid brain-damaged OS from
|
||||
// just calling "main" again with no cleanup...
|
||||
// That'll have to do until proper cleanup code is added to everything.
|
||||
exit(returnCode);
|
||||
|
||||
return returnCode;
|
||||
}
|
||||
|
@@ -58,7 +58,7 @@ typedef GpMutex_Cpp11<std::recursive_mutex> GpMutex_Cpp11_Recursive;
|
||||
class GpThreadEvent_Cpp11 final : public PortabilityLayer::HostThreadEvent
|
||||
{
|
||||
public:
|
||||
GpThreadEvent_Cpp11();
|
||||
GpThreadEvent_Cpp11(bool autoReset, bool startSignaled);
|
||||
~GpThreadEvent_Cpp11();
|
||||
|
||||
void Wait() override;
|
||||
@@ -70,10 +70,12 @@ private:
|
||||
std::mutex m_mutex;
|
||||
std::condition_variable m_cvar;
|
||||
bool m_flag;
|
||||
bool m_autoReset;
|
||||
};
|
||||
|
||||
GpThreadEvent_Cpp11::GpThreadEvent_Cpp11()
|
||||
: m_flag(false)
|
||||
GpThreadEvent_Cpp11::GpThreadEvent_Cpp11(bool autoReset, bool startSignaled)
|
||||
: m_flag(startSignaled)
|
||||
, m_autoReset(autoReset)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -84,14 +86,43 @@ GpThreadEvent_Cpp11::~GpThreadEvent_Cpp11()
|
||||
void GpThreadEvent_Cpp11::Wait()
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
m_cvar.wait(lock,[&]()->bool{ return m_flag; });
|
||||
if (m_autoReset)
|
||||
{
|
||||
m_cvar.wait(lock,[&]()->bool{
|
||||
if (m_flag)
|
||||
{
|
||||
m_flag = false;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
});
|
||||
}
|
||||
else
|
||||
m_cvar.wait(lock,[&]()->bool{ return m_flag; });
|
||||
}
|
||||
|
||||
bool GpThreadEvent_Cpp11::WaitTimed(uint32_t msec)
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
if (!m_cvar.wait_for(lock, std::chrono::milliseconds(msec), [&]()->bool{ return m_flag; }))
|
||||
return false;
|
||||
if (m_autoReset)
|
||||
{
|
||||
if (!m_cvar.wait_for(lock, std::chrono::milliseconds(msec), [&]()->bool{
|
||||
if (m_flag)
|
||||
{
|
||||
m_flag = false;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!m_cvar.wait_for(lock, std::chrono::milliseconds(msec), [&]()->bool{ return m_flag; }))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -100,7 +131,10 @@ void GpThreadEvent_Cpp11::Signal()
|
||||
m_mutex.lock();
|
||||
m_flag = true;
|
||||
m_mutex.unlock();
|
||||
m_cvar.notify_all();
|
||||
if (m_autoReset)
|
||||
m_cvar.notify_one();
|
||||
else
|
||||
m_cvar.notify_all();
|
||||
}
|
||||
|
||||
void GpThreadEvent_Cpp11::Destroy()
|
||||
@@ -154,7 +188,7 @@ PortabilityLayer::HostThreadEvent *GpSystemServices_Android::CreateThreadEvent(b
|
||||
if (!evt)
|
||||
return nullptr;
|
||||
|
||||
return new (evt) GpThreadEvent_Cpp11();
|
||||
return new (evt) GpThreadEvent_Cpp11(autoReset, startSignaled);
|
||||
}
|
||||
|
||||
uint64_t GpSystemServices_Android::GetFreeMemoryCosmetic() const
|
||||
@@ -166,6 +200,21 @@ void GpSystemServices_Android::Beep() const
|
||||
{
|
||||
}
|
||||
|
||||
bool GpSystemServices_Android::IsTouchscreen() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GpSystemServices_Android::IsUsingMouseAsTouch() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GpSystemServices_Android::IsTextInputObstructive() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
GpSystemServices_Android *GpSystemServices_Android::GetInstance()
|
||||
{
|
||||
return &ms_instance;
|
||||
|
@@ -15,6 +15,9 @@ public:
|
||||
PortabilityLayer::HostThreadEvent *CreateThreadEvent(bool autoReset, bool startSignaled) override;
|
||||
uint64_t GetFreeMemoryCosmetic() const override;
|
||||
void Beep() const override;
|
||||
bool IsTouchscreen() const override;
|
||||
bool IsUsingMouseAsTouch() const override;
|
||||
bool IsTextInputObstructive() const override;
|
||||
|
||||
static GpSystemServices_Android *GetInstance();
|
||||
|
||||
|
Reference in New Issue
Block a user