Skip to content

Commit

Permalink
Correct EmuEvent problems
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaacMarovitz committed Dec 31, 2024
1 parent 2d77eb8 commit 710f85f
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 42 deletions.
6 changes: 3 additions & 3 deletions core/debug/gdb_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -863,20 +863,20 @@ class GdbServer
agentInterrupt();
}

static void emuEventCallback(Event event, void *arg)
static void emuEventCallback(EmuEvent event, void *arg)
{
GdbServer *gdbServer = static_cast<GdbServer*>(arg);
switch (event)
{
case Event::Resume:
case EmuEvent::Resume:
try {
if (!gdbServer->isRunning())
gdbServer->run();
} catch (const GdbServer::Error& e) {
ERROR_LOG(COMMON, "%s", e.what());
}
break;
case Event::Terminate:
case EmuEvent::Terminate:
gdbServer->stop();
break;
default:
Expand Down
46 changes: 23 additions & 23 deletions core/lua/lua.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ using namespace luabridge;
static std::recursive_mutex mutex;
using lock_guard = std::lock_guard<std::recursive_mutex>;

static void emuEventCallback(Event event, void *)
static void emuEventCallback(EmuEvent event, void *)
{
if (L == nullptr || settings.raHardcoreMode)
return;
Expand All @@ -54,28 +54,28 @@ static void emuEventCallback(Event event, void *)
const char *key = nullptr;
switch (event)
{
case Event::Start:
case EmuEvent::Start:
key = "start";
break;
case Event::Resume:
case EmuEvent::Resume:
key = "resume";
break;
case Event::Pause:
case EmuEvent::Pause:
key = "pause";
break;
case Event::Terminate:
case EmuEvent::Terminate:
key = "terminate";
break;
case Event::LoadState:
case EmuEvent::LoadState:
key = "loadState";
break;
case Event::VBlank:
case EmuEvent::VBlank:
key = "vblank";
break;
case Event::Network:
case EmuEvent::Network:
key = "network";
break;
case Event::DiskChange:
case EmuEvent::DiskChange:
key = "diskChange";
break;
}
Expand Down Expand Up @@ -626,13 +626,13 @@ void init()
L = luaL_newstate();
luaL_openlibs(L);
luaRegister(L);
EventManager::listen(Event::Start, emuEventCallback);
EventManager::listen(Event::Resume, emuEventCallback);
EventManager::listen(Event::Pause, emuEventCallback);
EventManager::listen(Event::Terminate, emuEventCallback);
EventManager::listen(Event::LoadState, emuEventCallback);
EventManager::listen(Event::VBlank, emuEventCallback);
EventManager::listen(Event::Network, emuEventCallback);
EventManager::listen(EmuEvent::Start, emuEventCallback);
EventManager::listen(EmuEvent::Resume, emuEventCallback);
EventManager::listen(EmuEvent::Pause, emuEventCallback);
EventManager::listen(EmuEvent::Terminate, emuEventCallback);
EventManager::listen(EmuEvent::LoadState, emuEventCallback);
EventManager::listen(EmuEvent::VBlank, emuEventCallback);
EventManager::listen(EmuEvent::Network, emuEventCallback);

doExec(initFile);
}
Expand All @@ -641,13 +641,13 @@ void term()
{
if (L == nullptr)
return;
EventManager::unlisten(Event::Start, emuEventCallback);
EventManager::unlisten(Event::Resume, emuEventCallback);
EventManager::unlisten(Event::Pause, emuEventCallback);
EventManager::unlisten(Event::Terminate, emuEventCallback);
EventManager::unlisten(Event::LoadState, emuEventCallback);
EventManager::unlisten(Event::VBlank, emuEventCallback);
EventManager::unlisten(Event::Network, emuEventCallback);
EventManager::unlisten(EmuEvent::Start, emuEventCallback);
EventManager::unlisten(EmuEvent::Resume, emuEventCallback);
EventManager::unlisten(EmuEvent::Pause, emuEventCallback);
EventManager::unlisten(EmuEvent::Terminate, emuEventCallback);
EventManager::unlisten(EmuEvent::LoadState, emuEventCallback);
EventManager::unlisten(EmuEvent::VBlank, emuEventCallback);
EventManager::unlisten(EmuEvent::Network, emuEventCallback);
lua_close(L);
L = nullptr;
}
Expand Down
26 changes: 13 additions & 13 deletions core/ui/discord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,19 @@ class DiscordPresence
public:
DiscordPresence()
{
EventManager::listen(Event::Start, handleEmuEvent, this);
EventManager::listen(Event::Terminate, handleEmuEvent, this);
EventManager::listen(Event::Resume, handleEmuEvent, this);
EventManager::listen(Event::Network, handleEmuEvent, this);
EventManager::listen(EmuEvent::Start, handleEmuEvent, this);
EventManager::listen(EmuEvent::Terminate, handleEmuEvent, this);
EventManager::listen(EmuEvent::Resume, handleEmuEvent, this);
EventManager::listen(EmuEvent::Network, handleEmuEvent, this);
}

~DiscordPresence()
{
shutdown();
EventManager::unlisten(Event::Start, handleEmuEvent, this);
EventManager::unlisten(Event::Terminate, handleEmuEvent, this);
EventManager::unlisten(Event::Resume, handleEmuEvent, this);
EventManager::unlisten(Event::Network, handleEmuEvent, this);
EventManager::unlisten(EmuEvent::Start, handleEmuEvent, this);
EventManager::unlisten(EmuEvent::Terminate, handleEmuEvent, this);
EventManager::unlisten(EmuEvent::Resume, handleEmuEvent, this);
EventManager::unlisten(EmuEvent::Network, handleEmuEvent, this);
}

private:
Expand Down Expand Up @@ -85,21 +85,21 @@ class DiscordPresence
Discord_UpdatePresence(&discordPresence);
}

static void handleEmuEvent(Event event, void *p)
static void handleEmuEvent(EmuEvent event, void *p)
{
if (settings.naomi.slave || settings.naomi.drivingSimSlave != 0)
return;
DiscordPresence *inst = (DiscordPresence *)p;
switch (event)
{
case Event::Start:
case EmuEvent::Start:
inst->startTimestamp = time(nullptr);
[[fallthrough]];
case Event::Network:
case EmuEvent::Network:
if (config::DiscordPresence)
inst->sendPresence();
break;
case Event::Resume:
case EmuEvent::Resume:
if (config::DiscordPresence && !inst->initialized)
// Discord presence enabled
inst->sendPresence();
Expand All @@ -110,7 +110,7 @@ class DiscordPresence
inst->shutdown();
}
break;
case Event::Terminate:
case EmuEvent::Terminate:
if (inst->initialized)
Discord_ClearPresence();
inst->startTimestamp = 0;
Expand Down
6 changes: 3 additions & 3 deletions shell/android-studio/flycast/src/main/jni/src/Android.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,16 @@ extern jmethodID showScreenKeyboardMid;
static jmethodID onGameStateChangeMid;
extern jmethodID setVGamepadEditModeMid;

static void emuEventCallback(Event event, void *)
static void emuEventCallback(EmuEvent event, void *)
{
switch (event)
{
case Event::Pause:
case EmuEvent::Pause:
game_started = false;
if (g_activity != nullptr)
jni::env()->CallVoidMethod(g_activity, onGameStateChangeMid, false);
break;
case Event::Resume:
case EmuEvent::Resume:
game_started = true;
if (g_activity != nullptr)
jni::env()->CallVoidMethod(g_activity, onGameStateChangeMid, true);
Expand Down

0 comments on commit 710f85f

Please sign in to comment.