diff --git a/src/common/EventHandlerSDL.cxx b/src/common/EventHandlerSDL.cxx index 7d377f17a..06fc8befb 100644 --- a/src/common/EventHandlerSDL.cxx +++ b/src/common/EventHandlerSDL.cxx @@ -30,12 +30,8 @@ EventHandlerSDL::EventHandlerSDL(OSystem& osystem) #ifdef GUI_SUPPORT { ostringstream buf; - #if 0 //FIXME: come back to this myQwertz = int{'y'} == static_cast - (SDL_GetKeyFromScancode(static_cast(KBDK_Z))); - #else - myQwertz = false; - #endif + (SDL_GetKeyFromScancode(static_cast(KBDK_Z), static_cast(StellaMod::KBDM_NONE), false)); buf << "Keyboard: " << (myQwertz ? "QWERTZ" : "QWERTY"); Logger::debug(buf.view()); } @@ -64,19 +60,6 @@ EventHandlerSDL::~EventHandlerSDL() SDL_QuitSubSystem(SDL_INIT_JOYSTICK); } -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void EventHandlerSDL::enableTextEvents(bool enable) -{ -#if 0 // FIXME: needs a window ptr; refactor to pass this into the method - ASSERT_MAIN_THREAD; - - if(enable) - SDL_StartTextInput(); - else - SDL_StopTextInput(); -#endif -} - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void EventHandlerSDL::copyText(const string& text) const { diff --git a/src/common/EventHandlerSDL.hxx b/src/common/EventHandlerSDL.hxx index eb3648bef..2dc9c90f4 100644 --- a/src/common/EventHandlerSDL.hxx +++ b/src/common/EventHandlerSDL.hxx @@ -39,11 +39,6 @@ class EventHandlerSDL : public EventHandler ~EventHandlerSDL() override; private: - /** - Enable/disable text events (distinct from single-key events). - */ - void enableTextEvents(bool enable) override; - /** Clipboard methods. */ diff --git a/src/common/FBBackendSDL.cxx b/src/common/FBBackendSDL.cxx index e79896105..fd7f2375d 100644 --- a/src/common/FBBackendSDL.cxx +++ b/src/common/FBBackendSDL.cxx @@ -308,6 +308,7 @@ bool FBBackendSDL::setVideoMode(const VideoModeHandler::Mode& mode, return false; } + enableTextEvents(myTextEventsEnabled); setWindowIcon(); } @@ -522,6 +523,20 @@ void FBBackendSDL::grabMouse(bool grab) SDL_SetWindowMouseGrab(myWindow, grab); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void FBBackendSDL::enableTextEvents(bool enable) +{ + ASSERT_MAIN_THREAD; + + if(enable) + SDL_StartTextInput(myWindow); + else + SDL_StopTextInput(myWindow); + // myWindows can still be null, so we remember the state and set again when + // the window is created + myTextEventsEnabled = enable; +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool FBBackendSDL::fullScreen() const { diff --git a/src/common/FBBackendSDL.hxx b/src/common/FBBackendSDL.hxx index 98fd39ffe..161add714 100644 --- a/src/common/FBBackendSDL.hxx +++ b/src/common/FBBackendSDL.hxx @@ -222,6 +222,11 @@ class FBBackendSDL : public FBBackend */ void grabMouse(bool grab) override; + /** + Enable/disable text events (distinct from single-key events). + */ + void enableTextEvents(bool enable) override; + /** This method is called to provide information about the backend. */ @@ -304,6 +309,8 @@ class FBBackendSDL : public FBBackend // TODO: Is this a bug in SDL? bool myIsFullscreen{false}; + bool myTextEventsEnabled{false}; + // Center setting of current window bool myCenter{false}; diff --git a/src/emucore/EventHandler.cxx b/src/emucore/EventHandler.cxx index 0493a731d..85e93eb75 100644 --- a/src/emucore/EventHandler.cxx +++ b/src/emucore/EventHandler.cxx @@ -305,6 +305,12 @@ void EventHandler::poll(uInt64 time) myEvent.set(Event::MouseAxisYMove, 0); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void EventHandler::enableTextEvents(bool enable) +{ + myOSystem.frameBuffer().enableTextEvents(enable); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void EventHandler::handleTextEvent(char text) { diff --git a/src/emucore/EventHandler.hxx b/src/emucore/EventHandler.hxx index 3daf64597..1bbad6ac1 100644 --- a/src/emucore/EventHandler.hxx +++ b/src/emucore/EventHandler.hxx @@ -361,7 +361,7 @@ class EventHandler /** Enable/disable text events (distinct from single-key events). */ - virtual void enableTextEvents(bool enable) = 0; + void enableTextEvents(bool enable); #ifdef GUI_SUPPORT /** diff --git a/src/emucore/FBBackend.hxx b/src/emucore/FBBackend.hxx index 391a0d731..52ebb091e 100644 --- a/src/emucore/FBBackend.hxx +++ b/src/emucore/FBBackend.hxx @@ -100,6 +100,11 @@ class FBBackend */ virtual void grabMouse(bool grab) = 0; + /** + Enable/disable text events (distinct from single-key events). + */ + virtual void enableTextEvents(bool enable) = 0; + /** This method must be called after all drawing is done, and indicates that the buffers should be pushed to the physical screen. diff --git a/src/emucore/FrameBuffer.cxx b/src/emucore/FrameBuffer.cxx index b9a554876..fbdf2327b 100644 --- a/src/emucore/FrameBuffer.cxx +++ b/src/emucore/FrameBuffer.cxx @@ -1371,6 +1371,7 @@ FBInitStatus FrameBuffer::applyVideoMode() resetSurfaces(); setCursorState(); + myPendingRender = true; } else @@ -1443,6 +1444,12 @@ void FrameBuffer::setCursorState() myBackend->grabMouse(myGrabMouse); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void FrameBuffer::enableTextEvents(bool enable) +{ + myBackend->enableTextEvents(enable); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool FrameBuffer::grabMouseAllowed() { diff --git a/src/emucore/FrameBuffer.hxx b/src/emucore/FrameBuffer.hxx index d6449ff9a..f8483753e 100644 --- a/src/emucore/FrameBuffer.hxx +++ b/src/emucore/FrameBuffer.hxx @@ -268,6 +268,11 @@ class FrameBuffer */ void setCursorState(); + /** + Enable/disable text events (distinct from single-key events). + */ + void enableTextEvents(bool enable); + /** Checks if mouse grabbing is allowed. */ diff --git a/src/os/libretro/FBBackendLIBRETRO.hxx b/src/os/libretro/FBBackendLIBRETRO.hxx index 01269e8f9..64d0730d2 100644 --- a/src/os/libretro/FBBackendLIBRETRO.hxx +++ b/src/os/libretro/FBBackendLIBRETRO.hxx @@ -109,6 +109,7 @@ class FBBackendLIBRETRO : public FBBackend bool setVideoMode(const VideoModeHandler::Mode&, int, const Common::Point&) override { return true; } void grabMouse(bool) override { } + void enableTextEvents(bool enable) override { } void renderToScreen() override { } int refreshRate() const override { return 0; } bool isLightTheme() const override { return false; }