From 851bb50dc8e58f05f2ad4f231a1dbd8755204c61 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Sun, 26 Feb 2023 15:37:54 -0800 Subject: [PATCH] add SDL_PushEvent shim for RemoteFortressReader --- library/include/modules/DFSDL.h | 2 ++ library/modules/DFSDL.cpp | 6 ++++++ plugins/remotefortressreader/remotefortressreader.cpp | 3 ++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/library/include/modules/DFSDL.h b/library/include/modules/DFSDL.h index b5fd119f7..226b9f881 100644 --- a/library/include/modules/DFSDL.h +++ b/library/include/modules/DFSDL.h @@ -8,6 +8,7 @@ namespace DFHack // SDL stand-in type definitions typedef signed short SINT16; typedef void DFSDL_sem; + typedef void DFSDL_Event; typedef struct { @@ -86,6 +87,7 @@ DFHACK_EXPORT DFSDL_Surface * DFSDL_ConvertSurface(DFSDL_Surface *src, const DFS DFHACK_EXPORT void DFSDL_FreeSurface(DFSDL_Surface *surface); DFHACK_EXPORT int DFSDL_SemWait(DFSDL_sem *sem); DFHACK_EXPORT int DFSDL_SemPost(DFSDL_sem *sem); +DFHACK_EXPORT int DFSDL_PushEvent(DFSDL_Event *event); } diff --git a/library/modules/DFSDL.cpp b/library/modules/DFSDL.cpp index a7847fdb5..08e213b94 100644 --- a/library/modules/DFSDL.cpp +++ b/library/modules/DFSDL.cpp @@ -34,6 +34,7 @@ DFSDL_Surface * (*g_SDL_ConvertSurface)(DFSDL_Surface *, const DFSDL_PixelFormat void (*g_SDL_FreeSurface)(DFSDL_Surface *); int (*g_SDL_SemWait)(DFSDL_sem *); int (*g_SDL_SemPost)(DFSDL_sem *); +int (*g_SDL_PushEvent)(DFSDL_Event *); bool DFSDL::init(color_ostream &out) { for (auto &lib_str : SDL_LIBS) { @@ -69,6 +70,7 @@ bool DFSDL::init(color_ostream &out) { bind(g_sdl_handle, SDL_FreeSurface); bind(g_sdl_handle, SDL_SemWait); bind(g_sdl_handle, SDL_SemPost); + bind(g_sdl_handle, SDL_PushEvent); #undef bind DEBUG(dfsdl,out).print("sdl successfully loaded\n"); @@ -118,3 +120,7 @@ int DFSDL::DFSDL_SemWait(DFSDL_sem *sem) { int DFSDL::DFSDL_SemPost(DFSDL_sem *sem) { return g_SDL_SemPost(sem); } + +int DFSDL::DFSDL_PushEvent(DFSDL_Event *event) { + return g_SDL_PushEvent(event); +} diff --git a/plugins/remotefortressreader/remotefortressreader.cpp b/plugins/remotefortressreader/remotefortressreader.cpp index d1a269d52..f33044877 100644 --- a/plugins/remotefortressreader/remotefortressreader.cpp +++ b/plugins/remotefortressreader/remotefortressreader.cpp @@ -27,6 +27,7 @@ #include "modules/MapCache.h" #include "modules/Maps.h" #include "modules/Materials.h" +#include "modules/DFSDL.h" #include "modules/Translation.h" #include "modules/Units.h" #include "modules/World.h" @@ -2897,7 +2898,7 @@ static command_result PassKeyboardEvent(color_ostream &stream, const KeyboardEve e.key.ksym.scancode = in->scancode(); e.key.ksym.sym = (SDL::Key)in->sym(); e.key.ksym.unicode = in->unicode(); - SDL_PushEvent(&e); + DFHack::DFSDL::DFSDL_PushEvent(&e); #endif return CR_OK; }