rpcsx/rpcs3/Emu/Event.cpp

55 lines
729 B
C++
Raw Normal View History

#include "stdafx.h"
#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"
void EventManager::Init()
{
}
void EventManager::Clear()
{
2015-07-01 19:09:26 +02:00
m_map.clear();
}
2015-03-04 05:42:04 +01:00
bool EventManager::UnregisterKey(u64 key)
{
2015-03-04 05:42:04 +01:00
if (!key)
{
2015-03-04 05:42:04 +01:00
// always ok
return true;
}
2015-07-01 19:09:26 +02:00
std::lock_guard<std::mutex> lock(m_mutex);
2015-07-01 19:09:26 +02:00
auto f = m_map.find(key);
if (f != m_map.end())
{
2015-07-01 19:09:26 +02:00
m_map.erase(f);
return true;
}
2015-03-04 05:42:04 +01:00
return false;
2014-02-20 21:47:22 +01: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;
}