2014-02-13 12:13:05 +01:00
|
|
|
#include "stdafx.h"
|
2014-06-02 19:27:24 +02:00
|
|
|
#include "Emu/Memory/Memory.h"
|
2015-04-13 15:32:09 +02:00
|
|
|
#include "Emu/System.h"
|
2014-12-22 01:56:04 +01:00
|
|
|
|
|
|
|
|
#include "Emu/SysCalls/lv2/sys_event.h"
|
2014-07-06 18:05:52 +02:00
|
|
|
#include "Event.h"
|
2014-02-13 12:13:05 +01:00
|
|
|
|
|
|
|
|
void EventManager::Init()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EventManager::Clear()
|
|
|
|
|
{
|
2015-07-01 19:09:26 +02:00
|
|
|
m_map.clear();
|
2014-02-13 12:13:05 +01:00
|
|
|
}
|
|
|
|
|
|
2015-03-04 05:42:04 +01:00
|
|
|
bool EventManager::UnregisterKey(u64 key)
|
2014-02-13 12:13:05 +01:00
|
|
|
{
|
2015-03-04 05:42:04 +01:00
|
|
|
if (!key)
|
2014-02-13 12:13:05 +01:00
|
|
|
{
|
2015-03-04 05:42:04 +01:00
|
|
|
// always ok
|
2014-02-13 12:13:05 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-01 19:09:26 +02:00
|
|
|
std::lock_guard<std::mutex> lock(m_mutex);
|
2014-02-13 12:13:05 +01:00
|
|
|
|
2015-07-01 19:09:26 +02:00
|
|
|
auto f = m_map.find(key);
|
|
|
|
|
if (f != m_map.end())
|
2014-02-13 12:13:05 +01:00
|
|
|
{
|
2015-07-01 19:09:26 +02:00
|
|
|
m_map.erase(f);
|
2014-02-13 12:13:05 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
2015-03-04 05:42:04 +01:00
|
|
|
|
2014-02-13 12:13:05 +01:00
|
|
|
return false;
|
2014-02-20 21:47:22 +01:00
|
|
|
}
|
|
|
|
|
|
2015-05-27 05:11:59 +02:00
|
|
|
std::shared_ptr<lv2_event_queue_t> EventManager::GetEventQueue(u64 key)
|
2014-02-20 21:47:22 +01:00
|
|
|
{
|
2015-03-04 05:42:04 +01:00
|
|
|
if (!key)
|
|
|
|
|
{
|
|
|
|
|
// never exists
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-01 19:09:26 +02:00
|
|
|
std::lock_guard<std::mutex> lock(m_mutex);
|
2014-02-20 21:47:22 +01:00
|
|
|
|
2015-07-01 19:09:26 +02:00
|
|
|
auto f = m_map.find(key);
|
|
|
|
|
if (f != m_map.end())
|
2014-02-20 21:47:22 +01:00
|
|
|
{
|
2015-03-04 05:42:04 +01:00
|
|
|
return f->second;
|
2014-02-20 21:47:22 +01:00
|
|
|
}
|
2015-03-04 05:42:04 +01:00
|
|
|
|
|
|
|
|
return nullptr;
|
2014-02-23 20:05:49 +01:00
|
|
|
}
|