Android fixups
@@ -95,6 +95,11 @@ bool GpSystemServices_Win32::IsUsingMouseAsTouch() const
|
|||||||
return m_isTouchscreenSimulation;
|
return m_isTouchscreenSimulation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GpSystemServices_Win32::IsTextInputObstructive() const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void GpSystemServices_Win32::SetTouchscreenSimulation(bool isTouchscreenSimulation)
|
void GpSystemServices_Win32::SetTouchscreenSimulation(bool isTouchscreenSimulation)
|
||||||
{
|
{
|
||||||
m_isTouchscreenSimulation = isTouchscreenSimulation;
|
m_isTouchscreenSimulation = isTouchscreenSimulation;
|
||||||
|
@@ -24,6 +24,7 @@ public:
|
|||||||
void Beep() const override;
|
void Beep() const override;
|
||||||
bool IsTouchscreen() const override;
|
bool IsTouchscreen() const override;
|
||||||
bool IsUsingMouseAsTouch() const override;
|
bool IsUsingMouseAsTouch() const override;
|
||||||
|
bool IsTextInputObstructive() const override;
|
||||||
|
|
||||||
void SetTouchscreenSimulation(bool isTouchscreenSimulation);
|
void SetTouchscreenSimulation(bool isTouchscreenSimulation);
|
||||||
|
|
||||||
|
@@ -18,6 +18,8 @@
|
|||||||
|
|
||||||
#include "GpAndroid.h"
|
#include "GpAndroid.h"
|
||||||
|
|
||||||
|
#include <exception>
|
||||||
|
|
||||||
GpAndroidGlobals g_gpAndroidGlobals;
|
GpAndroidGlobals g_gpAndroidGlobals;
|
||||||
|
|
||||||
extern "C" IGpFontHandler *GpDriver_CreateFontHandler_FreeType2(const GpFontHandlerProperties &properties);
|
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_displayDriverType = EGpDisplayDriverType_SDL_GL2;
|
||||||
|
|
||||||
g_gpGlobalConfig.m_audioDriverType = EGpAudioDriverType_None;
|
g_gpGlobalConfig.m_audioDriverType = EGpAudioDriverType_SDL2;
|
||||||
|
|
||||||
g_gpGlobalConfig.m_fontHandlerType = EGpFontHandlerType_FreeType2;
|
g_gpGlobalConfig.m_fontHandlerType = EGpFontHandlerType_FreeType2;
|
||||||
|
|
||||||
@@ -55,5 +57,12 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
int returnCode = GpMain::Run();
|
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;
|
return returnCode;
|
||||||
}
|
}
|
||||||
|
@@ -58,7 +58,7 @@ typedef GpMutex_Cpp11<std::recursive_mutex> GpMutex_Cpp11_Recursive;
|
|||||||
class GpThreadEvent_Cpp11 final : public PortabilityLayer::HostThreadEvent
|
class GpThreadEvent_Cpp11 final : public PortabilityLayer::HostThreadEvent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GpThreadEvent_Cpp11();
|
GpThreadEvent_Cpp11(bool autoReset, bool startSignaled);
|
||||||
~GpThreadEvent_Cpp11();
|
~GpThreadEvent_Cpp11();
|
||||||
|
|
||||||
void Wait() override;
|
void Wait() override;
|
||||||
@@ -70,10 +70,12 @@ private:
|
|||||||
std::mutex m_mutex;
|
std::mutex m_mutex;
|
||||||
std::condition_variable m_cvar;
|
std::condition_variable m_cvar;
|
||||||
bool m_flag;
|
bool m_flag;
|
||||||
|
bool m_autoReset;
|
||||||
};
|
};
|
||||||
|
|
||||||
GpThreadEvent_Cpp11::GpThreadEvent_Cpp11()
|
GpThreadEvent_Cpp11::GpThreadEvent_Cpp11(bool autoReset, bool startSignaled)
|
||||||
: m_flag(false)
|
: m_flag(startSignaled)
|
||||||
|
, m_autoReset(autoReset)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,14 +86,43 @@ GpThreadEvent_Cpp11::~GpThreadEvent_Cpp11()
|
|||||||
void GpThreadEvent_Cpp11::Wait()
|
void GpThreadEvent_Cpp11::Wait()
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(m_mutex);
|
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)
|
bool GpThreadEvent_Cpp11::WaitTimed(uint32_t msec)
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(m_mutex);
|
std::unique_lock<std::mutex> lock(m_mutex);
|
||||||
if (!m_cvar.wait_for(lock, std::chrono::milliseconds(msec), [&]()->bool{ return m_flag; }))
|
if (m_autoReset)
|
||||||
return false;
|
{
|
||||||
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,7 +131,10 @@ void GpThreadEvent_Cpp11::Signal()
|
|||||||
m_mutex.lock();
|
m_mutex.lock();
|
||||||
m_flag = true;
|
m_flag = true;
|
||||||
m_mutex.unlock();
|
m_mutex.unlock();
|
||||||
m_cvar.notify_all();
|
if (m_autoReset)
|
||||||
|
m_cvar.notify_one();
|
||||||
|
else
|
||||||
|
m_cvar.notify_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GpThreadEvent_Cpp11::Destroy()
|
void GpThreadEvent_Cpp11::Destroy()
|
||||||
@@ -154,7 +188,7 @@ PortabilityLayer::HostThreadEvent *GpSystemServices_Android::CreateThreadEvent(b
|
|||||||
if (!evt)
|
if (!evt)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
return new (evt) GpThreadEvent_Cpp11();
|
return new (evt) GpThreadEvent_Cpp11(autoReset, startSignaled);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t GpSystemServices_Android::GetFreeMemoryCosmetic() const
|
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()
|
GpSystemServices_Android *GpSystemServices_Android::GetInstance()
|
||||||
{
|
{
|
||||||
return &ms_instance;
|
return &ms_instance;
|
||||||
|
@@ -15,6 +15,9 @@ public:
|
|||||||
PortabilityLayer::HostThreadEvent *CreateThreadEvent(bool autoReset, bool startSignaled) override;
|
PortabilityLayer::HostThreadEvent *CreateThreadEvent(bool autoReset, bool startSignaled) override;
|
||||||
uint64_t GetFreeMemoryCosmetic() const override;
|
uint64_t GetFreeMemoryCosmetic() const override;
|
||||||
void Beep() const override;
|
void Beep() const override;
|
||||||
|
bool IsTouchscreen() const override;
|
||||||
|
bool IsUsingMouseAsTouch() const override;
|
||||||
|
bool IsTextInputObstructive() const override;
|
||||||
|
|
||||||
static GpSystemServices_Android *GetInstance();
|
static GpSystemServices_Android *GetInstance();
|
||||||
|
|
||||||
|
@@ -525,21 +525,27 @@ void GpAudioDriver_SDL2::RefillMixChunk(GpAudioChannel_SDL2 *const*channels, siz
|
|||||||
audioMixBuffer += alignPadding;
|
audioMixBuffer += alignPadding;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool noAudio = true;
|
||||||
|
|
||||||
for (size_t i = 0; i < numChannels; i++)
|
for (size_t i = 0; i < numChannels; i++)
|
||||||
{
|
{
|
||||||
channels[i]->Consume(audioMixBuffer, kMixChunkSize);
|
channels[i]->Consume(audioMixBuffer, kMixChunkSize);
|
||||||
|
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
{
|
{
|
||||||
|
noAudio = false;
|
||||||
for (size_t j = 0; j < kMixChunkSize; j++)
|
for (size_t j = 0; j < kMixChunkSize; j++)
|
||||||
m_mixChunk[j] = audioMixBuffer[j] - 0x80;
|
m_mixChunk[j] = (audioMixBuffer[j] - 0x80) * 25;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (size_t j = 0; j < kMixChunkSize; j++)
|
for (size_t j = 0; j < kMixChunkSize; j++)
|
||||||
m_mixChunk[j] += audioMixBuffer[j] - 0x80;
|
m_mixChunk[j] += (audioMixBuffer[j] - 0x80) * 25;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (noAudio)
|
||||||
|
memset(m_mixChunk, 0, kMixChunkSize * sizeof(m_mixChunk[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -700,7 +700,7 @@ public:
|
|||||||
|
|
||||||
bool Init();
|
bool Init();
|
||||||
|
|
||||||
static void TranslateSDLMessage(const SDL_Event *msg, IGpVOSEventQueue *eventQueue, float pixelScaleX, float pixelScaleY);
|
static void TranslateSDLMessage(const SDL_Event *msg, IGpVOSEventQueue *eventQueue, float pixelScaleX, float pixelScaleY, bool obstructiveTextInput);
|
||||||
|
|
||||||
void Run() override;
|
void Run() override;
|
||||||
void Shutdown() override;
|
void Shutdown() override;
|
||||||
@@ -1540,7 +1540,7 @@ static void PostKeyboardEvent(IGpVOSEventQueue *eventQueue, GpKeyboardInputEvent
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GpDisplayDriver_SDL_GL2::TranslateSDLMessage(const SDL_Event *msg, IGpVOSEventQueue *eventQueue, float pixelScaleX, float pixelScaleY)
|
void GpDisplayDriver_SDL_GL2::TranslateSDLMessage(const SDL_Event *msg, IGpVOSEventQueue *eventQueue, float pixelScaleX, float pixelScaleY, bool obstructiveTextInput)
|
||||||
{
|
{
|
||||||
switch (msg->type)
|
switch (msg->type)
|
||||||
{
|
{
|
||||||
@@ -1642,9 +1642,11 @@ void GpDisplayDriver_SDL_GL2::TranslateSDLMessage(const SDL_Event *msg, IGpVOSEv
|
|||||||
PostKeyboardEvent(eventQueue, keyEventType, subset, key, 1);
|
PostKeyboardEvent(eventQueue, keyEventType, subset, key, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Monster hack. This needs to be redone to support OSK.
|
if (!obstructiveTextInput)
|
||||||
SDL_StopTextInput();
|
{
|
||||||
SDL_StartTextInput();
|
SDL_StopTextInput();
|
||||||
|
SDL_StartTextInput();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_QUIT:
|
case SDL_QUIT:
|
||||||
@@ -1674,7 +1676,10 @@ void GpDisplayDriver_SDL_GL2::Run()
|
|||||||
|
|
||||||
m_window = SDL_CreateWindow(GP_APPLICATION_NAME, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, m_windowWidthPhysical, m_windowHeightPhysical, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE);
|
m_window = SDL_CreateWindow(GP_APPLICATION_NAME, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, m_windowWidthPhysical, m_windowHeightPhysical, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE);
|
||||||
|
|
||||||
SDL_StartTextInput();
|
const bool obstructiveTextInput = m_properties.m_systemServices->IsTextInputObstructive();
|
||||||
|
|
||||||
|
if (!obstructiveTextInput)
|
||||||
|
SDL_StartTextInput();
|
||||||
|
|
||||||
StartOpenGLForWindow(logger);
|
StartOpenGLForWindow(logger);
|
||||||
|
|
||||||
@@ -1696,7 +1701,7 @@ void GpDisplayDriver_SDL_GL2::Run()
|
|||||||
//else if (msg.type == SDL_MOUSELEAVE) // Does SDL support this??
|
//else if (msg.type == SDL_MOUSELEAVE) // Does SDL support this??
|
||||||
// m_mouseIsInClientArea = false;
|
// m_mouseIsInClientArea = false;
|
||||||
|
|
||||||
TranslateSDLMessage(&msg, m_properties.m_eventQueue, m_pixelScaleX, m_pixelScaleY);
|
TranslateSDLMessage(&msg, m_properties.m_eventQueue, m_pixelScaleX, m_pixelScaleY, obstructiveTextInput);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
@@ -422,7 +422,7 @@ namespace touchScreenControlGraphics
|
|||||||
|
|
||||||
typedef touchScreenControlGraphics::touchScreenControlGraphic touchScreenControlGraphic_t;
|
typedef touchScreenControlGraphics::touchScreenControlGraphic touchScreenControlGraphic_t;
|
||||||
|
|
||||||
typedef struct
|
struct touchScreenControlState
|
||||||
{
|
{
|
||||||
static const int kMaxFingers = 4;
|
static const int kMaxFingers = 4;
|
||||||
|
|
||||||
@@ -430,4 +430,6 @@ typedef struct
|
|||||||
touchScreenFingerState fingers[kMaxFingers];
|
touchScreenFingerState fingers[kMaxFingers];
|
||||||
|
|
||||||
DrawSurface *graphics[touchScreenControlGraphics::Count];
|
DrawSurface *graphics[touchScreenControlGraphics::Count];
|
||||||
} touchScreenControlState, *touchScreenControlStatePtr;
|
};
|
||||||
|
|
||||||
|
typedef touchScreenControlState *touchScreenControlStatePtr;
|
||||||
|
@@ -363,7 +363,9 @@ void KillMusic (void)
|
|||||||
|
|
||||||
theErr = CloseMusicChannel();
|
theErr = CloseMusicChannel();
|
||||||
theErr = DumpMusicSounds();
|
theErr = DumpMusicSounds();
|
||||||
musicMutex->Destroy();
|
|
||||||
|
if (musicMutex)
|
||||||
|
musicMutex->Destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------- MusicBytesNeeded
|
//-------------------------------------------------------------- MusicBytesNeeded
|
||||||
|
@@ -337,9 +337,13 @@ bool RunFunctionOnAllPrefsHandlers (void *context, bool (*func) (void *context,
|
|||||||
if (ddHandler && !func(context, ddHandler))
|
if (ddHandler && !func(context, ddHandler))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
IGpPrefsHandler *adHandler = PortabilityLayer::HostAudioDriver::GetInstance()->GetPrefsHandler();
|
|
||||||
if (adHandler && !func(context, adHandler))
|
if (IGpAudioDriver *audioDriver = PortabilityLayer::HostAudioDriver::GetInstance())
|
||||||
return false;
|
{
|
||||||
|
IGpPrefsHandler *adHandler = audioDriver->GetPrefsHandler();
|
||||||
|
if (adHandler && !func(context, adHandler))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
size_t numInputDrivers = PortabilityLayer::HostInputDriver::NumInstances();
|
size_t numInputDrivers = PortabilityLayer::HostInputDriver::NumInstances();
|
||||||
|
|
||||||
|
@@ -25,6 +25,7 @@ namespace PortabilityLayer
|
|||||||
virtual void Beep() const = 0;
|
virtual void Beep() const = 0;
|
||||||
virtual bool IsTouchscreen() const = 0;
|
virtual bool IsTouchscreen() const = 0;
|
||||||
virtual bool IsUsingMouseAsTouch() const = 0;
|
virtual bool IsUsingMouseAsTouch() const = 0;
|
||||||
|
virtual bool IsTextInputObstructive() const = 0;
|
||||||
|
|
||||||
static void SetInstance(HostSystemServices *instance);
|
static void SetInstance(HostSystemServices *instance);
|
||||||
static HostSystemServices *GetInstance();
|
static HostSystemServices *GetInstance();
|
||||||
|