mirror of https://github.com/stella-emu/stella.git
fixed text events and QWERTY detection (see #978)
This commit is contained in:
parent
59b236e493
commit
b2b5db7034
|
@ -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<int>
|
||||
(SDL_GetKeyFromScancode(static_cast<SDL_Scancode>(KBDK_Z)));
|
||||
#else
|
||||
myQwertz = false;
|
||||
#endif
|
||||
(SDL_GetKeyFromScancode(static_cast<SDL_Scancode>(KBDK_Z), static_cast<SDL_Keymod>(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
|
||||
{
|
||||
|
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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};
|
||||
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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
|
||||
/**
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
@ -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; }
|
||||
|
|
Loading…
Reference in New Issue