From 61280cb6cfea880c392c4dc392a256384fde5c56 Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Thu, 14 Sep 2023 16:49:47 +0300 Subject: [PATCH] initial work on sdl events --- src/emulator.cpp | 16 ++++++++++++++++ src/emulator.h | 10 ++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/emulator.cpp b/src/emulator.cpp index 1ae080bf..2c0a0e54 100644 --- a/src/emulator.cpp +++ b/src/emulator.cpp @@ -44,8 +44,24 @@ void emuRun() { g_window_ctx->m_graphic_initialized_cond.SignalCondVar(); } g_window_ctx->m_mutex.UnlockMutex(); + + + auto* pdata = new EmuPrivate; + pdata->m_graphic_ctx = static_cast(&g_window_ctx->m_graphic_ctx); + + pdata->data1 = pdata; + pdata->data2 = new SDL_Event; + + pdata->m_screen_width = pdata->m_graphic_ctx->screen_width; + pdata->m_screen_height = pdata->m_graphic_ctx->screen_height; for (;;) { + SDL_Event* ev = static_cast(pdata->data2); + if (SDL_PollEvent(ev)!= 0) + { + printf("Event: 0x%04\n", ev->type); + printf("]"); + } HLE::Libs::Graphics::VideoOut::videoOutFlip(100000); // flip every 0.1 sec } std::_Exit(0); diff --git a/src/emulator.h b/src/emulator.h index 5afa122a..d86b1ef6 100644 --- a/src/emulator.h +++ b/src/emulator.h @@ -12,6 +12,16 @@ struct WindowCtx { SDL_Window* m_window = nullptr; bool is_window_hidden = true; }; + +struct EmuPrivate { + EmuPrivate() = default; + Lib::Mutex m_mutex; + HLE::Libs::Graphics::GraphicCtx* m_graphic_ctx = nullptr; + void* data1 = nullptr; + void* data2 = nullptr; + u32 m_screen_width = {0}; + u32 m_screen_height = {0}; +}; void emuInit(u32 width, u32 height); void emuRun(); } // namespace Emulator \ No newline at end of file