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;
|
||||||
|
@@ -60,17 +60,17 @@ PLError_t StartMusic (void)
|
|||||||
{
|
{
|
||||||
PLError_t theErr;
|
PLError_t theErr;
|
||||||
short soundVolume;
|
short soundVolume;
|
||||||
|
|
||||||
theErr = PLErrors::kNone;
|
theErr = PLErrors::kNone;
|
||||||
|
|
||||||
if (dontLoadMusic)
|
if (dontLoadMusic)
|
||||||
return(theErr);
|
return(theErr);
|
||||||
|
|
||||||
if (musicMutex == nullptr)
|
if (musicMutex == nullptr)
|
||||||
return(theErr);
|
return(theErr);
|
||||||
|
|
||||||
UnivGetSoundVolume(&soundVolume, thisMac.hasSM3);
|
UnivGetSoundVolume(&soundVolume, thisMac.hasSM3);
|
||||||
|
|
||||||
if ((soundVolume != 0) && (!failedMusic))
|
if ((soundVolume != 0) && (!failedMusic))
|
||||||
{
|
{
|
||||||
musicChannel->AddBuffer(theMusicData[musicState.musicSoundID], true);
|
musicChannel->AddBuffer(theMusicData[musicState.musicSoundID], true);
|
||||||
@@ -83,10 +83,10 @@ PLError_t StartMusic (void)
|
|||||||
|
|
||||||
musicChannel->AddBuffer(theMusicData[musicState.musicSoundID], true);
|
musicChannel->AddBuffer(theMusicData[musicState.musicSoundID], true);
|
||||||
musicChannel->AddCallback(MusicCallBack, true);
|
musicChannel->AddCallback(MusicCallBack, true);
|
||||||
|
|
||||||
isMusicOn = true;
|
isMusicOn = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (theErr);
|
return (theErr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,16 +95,16 @@ PLError_t StartMusic (void)
|
|||||||
void StopTheMusic (void)
|
void StopTheMusic (void)
|
||||||
{
|
{
|
||||||
PLError_t theErr;
|
PLError_t theErr;
|
||||||
|
|
||||||
if (dontLoadMusic)
|
if (dontLoadMusic)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
theErr = PLErrors::kNone;
|
theErr = PLErrors::kNone;
|
||||||
if ((isMusicOn) && (!failedMusic))
|
if ((isMusicOn) && (!failedMusic))
|
||||||
{
|
{
|
||||||
musicChannel->ClearAllCommands();
|
musicChannel->ClearAllCommands();
|
||||||
musicChannel->Stop();
|
musicChannel->Stop();
|
||||||
|
|
||||||
isMusicOn = false;
|
isMusicOn = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -114,10 +114,10 @@ void StopTheMusic (void)
|
|||||||
void ToggleMusicWhilePlaying (void)
|
void ToggleMusicWhilePlaying (void)
|
||||||
{
|
{
|
||||||
PLError_t theErr;
|
PLError_t theErr;
|
||||||
|
|
||||||
if (dontLoadMusic)
|
if (dontLoadMusic)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (isPlayMusicGame)
|
if (isPlayMusicGame)
|
||||||
{
|
{
|
||||||
if (!isMusicOn)
|
if (!isMusicOn)
|
||||||
@@ -133,7 +133,7 @@ void ToggleMusicWhilePlaying (void)
|
|||||||
//-------------------------------------------------------------- SetMusicalPiece
|
//-------------------------------------------------------------- SetMusicalPiece
|
||||||
|
|
||||||
void SetMusicalMode (short newMode)
|
void SetMusicalMode (short newMode)
|
||||||
{
|
{
|
||||||
if (dontLoadMusic || failedMusic)
|
if (dontLoadMusic || failedMusic)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -143,11 +143,11 @@ void SetMusicalMode (short newMode)
|
|||||||
case kKickGameScoreMode:
|
case kKickGameScoreMode:
|
||||||
musicState.musicCursor = 2;
|
musicState.musicCursor = 2;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kProdGameScoreMode:
|
case kProdGameScoreMode:
|
||||||
musicState.musicCursor = -1;
|
musicState.musicCursor = -1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
musicState.musicMode = newMode;
|
musicState.musicMode = newMode;
|
||||||
musicState.musicCursor = 0;
|
musicState.musicCursor = 0;
|
||||||
@@ -176,14 +176,14 @@ void MusicCallBack (PortabilityLayer::AudioChannel *theChannel)
|
|||||||
musicState.musicSoundID = gameScore[musicState.musicCursor];
|
musicState.musicSoundID = gameScore[musicState.musicCursor];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kPlayWholeScoreMode:
|
case kPlayWholeScoreMode:
|
||||||
musicState.musicCursor++;
|
musicState.musicCursor++;
|
||||||
if (musicState.musicCursor >= kLastMusicPiece - 1)
|
if (musicState.musicCursor >= kLastMusicPiece - 1)
|
||||||
musicState.musicCursor = 0;
|
musicState.musicCursor = 0;
|
||||||
musicState.musicSoundID = musicScore[musicState.musicCursor];
|
musicState.musicSoundID = musicScore[musicState.musicCursor];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
musicState.musicSoundID = musicState.musicMode;
|
musicState.musicSoundID = musicState.musicMode;
|
||||||
break;
|
break;
|
||||||
@@ -204,18 +204,18 @@ PLError_t LoadMusicSounds (void)
|
|||||||
long soundDataSize;
|
long soundDataSize;
|
||||||
PLError_t theErr;
|
PLError_t theErr;
|
||||||
short i;
|
short i;
|
||||||
|
|
||||||
theErr = PLErrors::kNone;
|
theErr = PLErrors::kNone;
|
||||||
|
|
||||||
for (i = 0; i < kMaxMusic; i++)
|
for (i = 0; i < kMaxMusic; i++)
|
||||||
theMusicData[i] = nil;
|
theMusicData[i] = nil;
|
||||||
|
|
||||||
for (i = 0; i < kMaxMusic; i++)
|
for (i = 0; i < kMaxMusic; i++)
|
||||||
{
|
{
|
||||||
theSound = ParseAndConvertSound(PortabilityLayer::ResourceManager::GetInstance()->GetAppResource('snd ', i + kBaseBufferMusicID));
|
theSound = ParseAndConvertSound(PortabilityLayer::ResourceManager::GetInstance()->GetAppResource('snd ', i + kBaseBufferMusicID));
|
||||||
if (theSound == nil)
|
if (theSound == nil)
|
||||||
return PLErrors::kOutOfMemory;
|
return PLErrors::kOutOfMemory;
|
||||||
|
|
||||||
soundDataSize = GetHandleSize(theSound);
|
soundDataSize = GetHandleSize(theSound);
|
||||||
|
|
||||||
theMusicData[i] = PortabilityLayer::MemoryManager::GetInstance()->Alloc(soundDataSize);
|
theMusicData[i] = PortabilityLayer::MemoryManager::GetInstance()->Alloc(soundDataSize);
|
||||||
@@ -234,16 +234,16 @@ PLError_t DumpMusicSounds (void)
|
|||||||
{
|
{
|
||||||
PLError_t theErr;
|
PLError_t theErr;
|
||||||
short i;
|
short i;
|
||||||
|
|
||||||
theErr = PLErrors::kNone;
|
theErr = PLErrors::kNone;
|
||||||
|
|
||||||
for (i = 0; i < kMaxMusic; i++)
|
for (i = 0; i < kMaxMusic; i++)
|
||||||
{
|
{
|
||||||
if (theMusicData[i] != nil)
|
if (theMusicData[i] != nil)
|
||||||
PortabilityLayer::MemoryManager::GetInstance()->Release(theMusicData[i]);
|
PortabilityLayer::MemoryManager::GetInstance()->Release(theMusicData[i]);
|
||||||
theMusicData[i] = nil;
|
theMusicData[i] = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (theErr);
|
return (theErr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -252,12 +252,12 @@ PLError_t DumpMusicSounds (void)
|
|||||||
PLError_t OpenMusicChannel (void)
|
PLError_t OpenMusicChannel (void)
|
||||||
{
|
{
|
||||||
PLError_t theErr;
|
PLError_t theErr;
|
||||||
|
|
||||||
theErr = PLErrors::kNone;
|
theErr = PLErrors::kNone;
|
||||||
|
|
||||||
if (musicChannel != nil)
|
if (musicChannel != nil)
|
||||||
return (theErr);
|
return (theErr);
|
||||||
|
|
||||||
musicChannel = PortabilityLayer::SoundSystem::GetInstance()->CreateChannel();
|
musicChannel = PortabilityLayer::SoundSystem::GetInstance()->CreateChannel();
|
||||||
|
|
||||||
if (musicChannel == nil)
|
if (musicChannel == nil)
|
||||||
@@ -271,13 +271,13 @@ PLError_t OpenMusicChannel (void)
|
|||||||
PLError_t CloseMusicChannel (void)
|
PLError_t CloseMusicChannel (void)
|
||||||
{
|
{
|
||||||
PLError_t theErr;
|
PLError_t theErr;
|
||||||
|
|
||||||
theErr = PLErrors::kNone;
|
theErr = PLErrors::kNone;
|
||||||
|
|
||||||
if (musicChannel != nil)
|
if (musicChannel != nil)
|
||||||
musicChannel->Destroy(false);
|
musicChannel->Destroy(false);
|
||||||
musicChannel = nil;
|
musicChannel = nil;
|
||||||
|
|
||||||
return (theErr);
|
return (theErr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -286,12 +286,12 @@ PLError_t CloseMusicChannel (void)
|
|||||||
void InitMusic (void)
|
void InitMusic (void)
|
||||||
{
|
{
|
||||||
PLError_t theErr;
|
PLError_t theErr;
|
||||||
|
|
||||||
if (dontLoadMusic)
|
if (dontLoadMusic)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
musicChannel = nil;
|
musicChannel = nil;
|
||||||
|
|
||||||
failedMusic = false;
|
failedMusic = false;
|
||||||
isMusicOn = false;
|
isMusicOn = false;
|
||||||
theErr = LoadMusicSounds();
|
theErr = LoadMusicSounds();
|
||||||
@@ -308,7 +308,7 @@ void InitMusic (void)
|
|||||||
failedMusic = true;
|
failedMusic = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
musicScore[0] = 0;
|
musicScore[0] = 0;
|
||||||
musicScore[1] = 1;
|
musicScore[1] = 1;
|
||||||
musicScore[2] = 2;
|
musicScore[2] = 2;
|
||||||
@@ -325,14 +325,14 @@ void InitMusic (void)
|
|||||||
musicScore[13] = kPlayRefrainSparse2;
|
musicScore[13] = kPlayRefrainSparse2;
|
||||||
musicScore[14] = kPlayChorus;
|
musicScore[14] = kPlayChorus;
|
||||||
musicScore[15] = kPlayChorus;
|
musicScore[15] = kPlayChorus;
|
||||||
|
|
||||||
gameScore[0] = kPlayRefrainSparse2;
|
gameScore[0] = kPlayRefrainSparse2;
|
||||||
gameScore[1] = kPlayRefrainSparse1;
|
gameScore[1] = kPlayRefrainSparse1;
|
||||||
gameScore[2] = -1;
|
gameScore[2] = -1;
|
||||||
gameScore[3] = kPlayRefrainSparse2;
|
gameScore[3] = kPlayRefrainSparse2;
|
||||||
gameScore[4] = kPlayChorus;
|
gameScore[4] = kPlayChorus;
|
||||||
gameScore[5] = kPlayChorus;
|
gameScore[5] = kPlayChorus;
|
||||||
|
|
||||||
musicState.musicCursor = 0;
|
musicState.musicCursor = 0;
|
||||||
musicState.musicSoundID = musicScore[musicState.musicCursor];
|
musicState.musicSoundID = musicScore[musicState.musicCursor];
|
||||||
musicState.musicMode = kPlayWholeScoreMode;
|
musicState.musicMode = kPlayWholeScoreMode;
|
||||||
@@ -340,7 +340,7 @@ void InitMusic (void)
|
|||||||
musicMutex = PortabilityLayer::HostSystemServices::GetInstance()->CreateMutex();
|
musicMutex = PortabilityLayer::HostSystemServices::GetInstance()->CreateMutex();
|
||||||
|
|
||||||
PL_NotYetImplemented_TODO("MusicSync");
|
PL_NotYetImplemented_TODO("MusicSync");
|
||||||
|
|
||||||
if (isPlayMusicIdle)
|
if (isPlayMusicIdle)
|
||||||
{
|
{
|
||||||
theErr = StartMusic();
|
theErr = StartMusic();
|
||||||
@@ -357,13 +357,15 @@ void InitMusic (void)
|
|||||||
void KillMusic (void)
|
void KillMusic (void)
|
||||||
{
|
{
|
||||||
PLError_t theErr;
|
PLError_t theErr;
|
||||||
|
|
||||||
if (dontLoadMusic)
|
if (dontLoadMusic)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
theErr = CloseMusicChannel();
|
theErr = CloseMusicChannel();
|
||||||
theErr = DumpMusicSounds();
|
theErr = DumpMusicSounds();
|
||||||
musicMutex->Destroy();
|
|
||||||
|
if (musicMutex)
|
||||||
|
musicMutex->Destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------- MusicBytesNeeded
|
//-------------------------------------------------------------- MusicBytesNeeded
|
||||||
@@ -372,7 +374,7 @@ long MusicBytesNeeded (void)
|
|||||||
{
|
{
|
||||||
size_t totalBytes;
|
size_t totalBytes;
|
||||||
short i;
|
short i;
|
||||||
|
|
||||||
totalBytes = 0L;
|
totalBytes = 0L;
|
||||||
for (i = 0; i < kMaxMusic; i++)
|
for (i = 0; i < kMaxMusic; i++)
|
||||||
{
|
{
|
||||||
@@ -391,7 +393,7 @@ void TellHerNoMusic (void)
|
|||||||
{
|
{
|
||||||
#define kNoMemForMusicAlert 1038
|
#define kNoMemForMusicAlert 1038
|
||||||
short hitWhat;
|
short hitWhat;
|
||||||
|
|
||||||
// CenterAlert(kNoMemForMusicAlert);
|
// CenterAlert(kNoMemForMusicAlert);
|
||||||
hitWhat = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kNoMemForMusicAlert, nullptr);
|
hitWhat = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kNoMemForMusicAlert, nullptr);
|
||||||
}
|
}
|
||||||
|
@@ -66,7 +66,7 @@ Boolean WritePrefs (const prefsInfo *thePrefs, short versionNow, THandle<moduleP
|
|||||||
PortabilityLayer::FileManager *fm = PortabilityLayer::FileManager::GetInstance();
|
PortabilityLayer::FileManager *fm = PortabilityLayer::FileManager::GetInstance();
|
||||||
|
|
||||||
PasStringCopy(kPrefFileName, fileName);
|
PasStringCopy(kPrefFileName, fileName);
|
||||||
|
|
||||||
VFileSpec theSpecs = MakeVFileSpec(PortabilityLayer::VirtualDirectories::kPrefs, fileName);
|
VFileSpec theSpecs = MakeVFileSpec(PortabilityLayer::VirtualDirectories::kPrefs, fileName);
|
||||||
if (!fm->FileExists(PortabilityLayer::VirtualDirectories::kPrefs, fileName))
|
if (!fm->FileExists(PortabilityLayer::VirtualDirectories::kPrefs, fileName))
|
||||||
{
|
{
|
||||||
@@ -148,7 +148,7 @@ Boolean WritePrefs (const prefsInfo *thePrefs, short versionNow, THandle<moduleP
|
|||||||
}
|
}
|
||||||
|
|
||||||
fileStream->Close();
|
fileStream->Close();
|
||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,7 +158,7 @@ Boolean SavePrefs (prefsInfo *thePrefs, THandle<void> *modulePrefs, short versio
|
|||||||
{
|
{
|
||||||
if (!WritePrefs(thePrefs, versionNow, modulePrefs->StaticCast<modulePrefsListEntry>()))
|
if (!WritePrefs(thePrefs, versionNow, modulePrefs->StaticCast<modulePrefsListEntry>()))
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -197,14 +197,14 @@ PLError_t ReadPrefs (prefsInfo *thePrefs, short versionNeed, Boolean *isOldVersi
|
|||||||
*isOldVersion = false;
|
*isOldVersion = false;
|
||||||
|
|
||||||
PortabilityLayer::FileManager *fm = PortabilityLayer::FileManager::GetInstance();
|
PortabilityLayer::FileManager *fm = PortabilityLayer::FileManager::GetInstance();
|
||||||
|
|
||||||
PasStringCopy(kPrefFileName, fileName);
|
PasStringCopy(kPrefFileName, fileName);
|
||||||
|
|
||||||
theSpecs = MakeVFileSpec(PortabilityLayer::VirtualDirectory_t::kPrefs, fileName);
|
theSpecs = MakeVFileSpec(PortabilityLayer::VirtualDirectory_t::kPrefs, fileName);
|
||||||
|
|
||||||
if (!PortabilityLayer::FileManager::GetInstance()->FileExists(theSpecs.m_dir, theSpecs.m_name))
|
if (!PortabilityLayer::FileManager::GetInstance()->FileExists(theSpecs.m_dir, theSpecs.m_name))
|
||||||
return PLErrors::kFileNotFound;
|
return PLErrors::kFileNotFound;
|
||||||
|
|
||||||
theErr = fm->OpenFileData(theSpecs.m_dir, theSpecs.m_name, PortabilityLayer::EFilePermission_Read, fileStream);
|
theErr = fm->OpenFileData(theSpecs.m_dir, theSpecs.m_name, PortabilityLayer::EFilePermission_Read, fileStream);
|
||||||
if (theErr != PLErrors::kNone)
|
if (theErr != PLErrors::kNone)
|
||||||
{
|
{
|
||||||
@@ -226,7 +226,7 @@ PLError_t ReadPrefs (prefsInfo *thePrefs, short versionNeed, Boolean *isOldVersi
|
|||||||
fileStream->Close();
|
fileStream->Close();
|
||||||
return(PLErrors::kNone);
|
return(PLErrors::kNone);
|
||||||
}
|
}
|
||||||
|
|
||||||
byteCount = sizeof(*thePrefs);
|
byteCount = sizeof(*thePrefs);
|
||||||
|
|
||||||
if (fileStream->Read(thePrefs, byteCount) != byteCount)
|
if (fileStream->Read(thePrefs, byteCount) != byteCount)
|
||||||
@@ -309,7 +309,7 @@ PLError_t ReadPrefs (prefsInfo *thePrefs, short versionNeed, Boolean *isOldVersi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fileStream->Close();
|
fileStream->Close();
|
||||||
|
|
||||||
return(theErr);
|
return(theErr);
|
||||||
@@ -324,7 +324,7 @@ Boolean DeletePrefs ()
|
|||||||
PLError_t theErr;
|
PLError_t theErr;
|
||||||
|
|
||||||
PasStringCopy(kPrefFileName, fileName);
|
PasStringCopy(kPrefFileName, fileName);
|
||||||
|
|
||||||
theSpecs = MakeVFileSpec(PortabilityLayer::VirtualDirectories::kPrefs, fileName);
|
theSpecs = MakeVFileSpec(PortabilityLayer::VirtualDirectories::kPrefs, fileName);
|
||||||
|
|
||||||
return PortabilityLayer::FileManager::GetInstance()->DeleteFile(theSpecs.m_dir, theSpecs.m_name);
|
return PortabilityLayer::FileManager::GetInstance()->DeleteFile(theSpecs.m_dir, theSpecs.m_name);
|
||||||
@@ -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();
|
||||||
|
|
||||||
@@ -364,7 +368,7 @@ Boolean LoadPrefs (prefsInfo *thePrefs, THandle<void> *modulePrefs, short versio
|
|||||||
Boolean isOldVersion = 0;
|
Boolean isOldVersion = 0;
|
||||||
|
|
||||||
THandle<modulePrefsListEntry> mPrefs;
|
THandle<modulePrefsListEntry> mPrefs;
|
||||||
|
|
||||||
theErr = ReadPrefs(thePrefs, versionNeed, &isOldVersion, &mPrefs);
|
theErr = ReadPrefs(thePrefs, versionNeed, &isOldVersion, &mPrefs);
|
||||||
|
|
||||||
if (theErr == PLErrors::kFileNotFound)
|
if (theErr == PLErrors::kFileNotFound)
|
||||||
@@ -383,7 +387,7 @@ Boolean LoadPrefs (prefsInfo *thePrefs, THandle<void> *modulePrefs, short versio
|
|||||||
noProblems = DeletePrefs();
|
noProblems = DeletePrefs();
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
*modulePrefs = mPrefs.StaticCast<void>();
|
*modulePrefs = mPrefs.StaticCast<void>();
|
||||||
|
|
||||||
return (true);
|
return (true);
|
||||||
@@ -537,7 +541,7 @@ Boolean ApplyModulePrefs (THandle<void> *modulePrefs)
|
|||||||
void BringUpDeletePrefsAlert (void)
|
void BringUpDeletePrefsAlert (void)
|
||||||
{
|
{
|
||||||
short whoCares;
|
short whoCares;
|
||||||
|
|
||||||
InitCursor();
|
InitCursor();
|
||||||
// CenterAlert(kNewPrefsAlertID);
|
// CenterAlert(kNewPrefsAlertID);
|
||||||
whoCares = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kNewPrefsAlertID, nullptr);
|
whoCares = PortabilityLayer::DialogManager::GetInstance()->DisplayAlert(kNewPrefsAlertID, nullptr);
|
||||||
|
@@ -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();
|
||||||
|