mirror of
https://github.com/momo5502/emulator.git
synced 2026-01-18 03:13:55 +00:00
Prepare flatbuffer support
This commit is contained in:
56
src/debugger/event_handler.cpp
Normal file
56
src/debugger/event_handler.cpp
Normal file
@@ -0,0 +1,56 @@
|
||||
#include "event_handler.hpp"
|
||||
#include "events.hpp"
|
||||
|
||||
#include "message_transmitter.hpp"
|
||||
|
||||
namespace debugger
|
||||
{
|
||||
namespace
|
||||
{
|
||||
void handle_event(event_context& c, const event& e, const nlohmann::json& obj)
|
||||
{
|
||||
switch (e.type)
|
||||
{
|
||||
case event_type::pause:
|
||||
c.win_emu.emu().stop();
|
||||
break;
|
||||
|
||||
case event_type::run:
|
||||
c.resume = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void handle_object(event_context& c, const nlohmann::json& obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
const auto e = obj.get<event>();
|
||||
handle_event(c, e, obj);
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
puts(e.what());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void handle_events(event_context& c)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
suspend_execution(0ms);
|
||||
|
||||
const auto obj = receive_object();
|
||||
if (obj.is_null())
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
handle_object(c, obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user