add SDL_PushEvent shim for RemoteFortressReader

develop
Myk Taylor 2023-02-26 15:37:54 -08:00
parent 58f0c3ea02
commit 851bb50dc8
No known key found for this signature in database
3 changed files with 10 additions and 1 deletions

@ -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);
}

@ -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);
}

@ -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;
}