2023-06-29 04:10:08 -04:00
|
|
|
#include "mxeventmanager.h"
|
2023-10-07 17:30:05 -04:00
|
|
|
#include "mxcriticalsection.h"
|
|
|
|
#include "mxthread.h"
|
|
|
|
#include "mxticklemanager.h"
|
|
|
|
#include "mxomni.h"
|
2023-06-29 04:10:08 -04:00
|
|
|
|
2023-08-03 19:43:36 -04:00
|
|
|
// OFFSET: LEGO1 0x100c0360
|
2023-06-29 04:10:08 -04:00
|
|
|
MxEventManager::MxEventManager()
|
|
|
|
{
|
2023-08-03 19:43:36 -04:00
|
|
|
Init();
|
2023-06-29 04:10:08 -04:00
|
|
|
}
|
|
|
|
|
2023-08-03 19:43:36 -04:00
|
|
|
// OFFSET: LEGO1 0x100c03f0
|
2023-06-29 04:10:08 -04:00
|
|
|
MxEventManager::~MxEventManager()
|
|
|
|
{
|
2023-10-13 12:43:45 -04:00
|
|
|
Destroy(TRUE);
|
2023-06-29 04:10:08 -04:00
|
|
|
}
|
2023-08-03 19:43:36 -04:00
|
|
|
|
|
|
|
// OFFSET: LEGO1 0x100c0450
|
|
|
|
void MxEventManager::Init()
|
|
|
|
{
|
2023-10-07 17:30:05 -04:00
|
|
|
// This is intentionally left blank
|
2023-10-07 14:05:45 -04:00
|
|
|
}
|
|
|
|
|
2023-10-13 12:43:45 -04:00
|
|
|
// OFFSET: LEGO1 0x100c0460
|
|
|
|
void MxEventManager::Destroy(MxBool p_fromDestructor)
|
|
|
|
{
|
|
|
|
if (m_thread != NULL) {
|
|
|
|
m_thread->Terminate();
|
|
|
|
delete m_thread;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
TickleManager()->UnregisterClient(this);
|
|
|
|
|
|
|
|
if (!p_fromDestructor)
|
|
|
|
MxMediaManager::Destroy();
|
|
|
|
}
|
|
|
|
|
2023-10-07 17:30:05 -04:00
|
|
|
// OFFSET: LEGO1 0x100c04a0
|
2023-10-14 20:49:07 -04:00
|
|
|
MxResult MxEventManager::Create(MxU32 p_frequencyMS, MxBool p_createThread)
|
2023-10-07 14:05:45 -04:00
|
|
|
{
|
2023-10-07 17:30:05 -04:00
|
|
|
MxResult status = FAILURE;
|
|
|
|
MxBool locked = FALSE;
|
|
|
|
|
|
|
|
MxResult result = MxMediaManager::InitPresenters();
|
2023-10-13 12:43:45 -04:00
|
|
|
if (result == SUCCESS) {
|
2023-10-14 20:49:07 -04:00
|
|
|
if (p_createThread) {
|
2023-10-07 17:30:05 -04:00
|
|
|
this->m_criticalSection.Enter();
|
|
|
|
locked = TRUE;
|
|
|
|
this->m_thread = new MxTickleThread(this, p_frequencyMS);
|
|
|
|
|
2023-10-14 20:49:07 -04:00
|
|
|
if (!this->m_thread || this->m_thread->Start(0, 0) != SUCCESS)
|
|
|
|
goto done;
|
2023-10-07 17:30:05 -04:00
|
|
|
}
|
2023-10-14 20:49:07 -04:00
|
|
|
else
|
2023-10-07 17:30:05 -04:00
|
|
|
TickleManager()->RegisterClient(this, p_frequencyMS);
|
2023-10-14 20:49:07 -04:00
|
|
|
|
|
|
|
status = SUCCESS;
|
2023-10-07 17:30:05 -04:00
|
|
|
}
|
|
|
|
|
2023-10-14 20:49:07 -04:00
|
|
|
done:
|
2023-10-07 17:30:05 -04:00
|
|
|
if (status != SUCCESS)
|
|
|
|
Destroy();
|
|
|
|
|
|
|
|
if (locked)
|
|
|
|
this->m_criticalSection.Leave();
|
|
|
|
|
|
|
|
return status;
|
2023-10-07 14:05:45 -04:00
|
|
|
}
|
2023-10-13 12:43:45 -04:00
|
|
|
|
|
|
|
// OFFSET: LEGO1 0x100c0590
|
|
|
|
void MxEventManager::Destroy()
|
|
|
|
{
|
|
|
|
Destroy(FALSE);
|
|
|
|
}
|