From 80bbfadb4c3a4e276f0846f3a58fd0d6b652269a Mon Sep 17 00:00:00 2001 From: stephena Date: Wed, 4 Jun 2014 16:01:45 +0000 Subject: [PATCH] Fixed grabmouse and show cursor to match Stella 3.9.3 functionality. Added 'hidecursor' commandline option, to always disable showing the mouse cursor (useful for fullscreen-only frontends). git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2908 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- Changes.txt | 4 ++++ docs/index.html | 15 +++++++++----- src/common/FrameBufferSDL2.cxx | 17 ++++++++++------ src/emucore/FrameBuffer.cxx | 11 ++++++----- src/emucore/Settings.cxx | 6 ++++-- src/gui/InputDialog.cxx | 36 ++++++++++++++++++++++++---------- src/gui/InputDialog.hxx | 1 + 7 files changed, 62 insertions(+), 28 deletions(-) diff --git a/Changes.txt b/Changes.txt index f434f6f20..6d004f9d4 100644 --- a/Changes.txt +++ b/Changes.txt @@ -20,6 +20,10 @@ context menu item to the debugger TIA output area. This saves the current TIA image to a PNG file. + * Added 'hidecursor' commandline option, which allows to completely + disable showing the mouse cursor (useful on systems that don't have + a mouse). + * Removed 'uipalette' option, as the original palette is no longer supported. diff --git a/docs/index.html b/docs/index.html index 9c8b95104..d6e18bf07 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1953,11 +1953,6 @@ and always allows all 4 directions. - -
FIXSDL-grabmouse <1|0>
- Keeps the mouse in the game window in emulation mode. - -
-usemouse <always|analog|never>
Use mouse as a controller as specified by ROM properties in specific case. @@ -1965,6 +1960,16 @@ (paddles, trackball, etc). + +
-grabmouse <1|0>
+ Locks the mouse cursor in the game window in emulation mode. + + + +
-hidecursor <1|0>
+ Always hide the mouse cursor, or show it when appropriate. + +
-dsense <number>
Sensitivity for emulation of paddles when using a digital device diff --git a/src/common/FrameBufferSDL2.cxx b/src/common/FrameBufferSDL2.cxx index 6d4b2b049..4a31710ac 100644 --- a/src/common/FrameBufferSDL2.cxx +++ b/src/common/FrameBufferSDL2.cxx @@ -108,8 +108,9 @@ bool FrameBufferSDL2::setVideoMode(const string& title, const VideoMode& mode, SDL_DestroyRenderer(myRenderer); myRenderer = NULL; } - // Don't re-create the window if its size hasn't changed, as it is - // wasteful, and causing flashing in fullscreen mode + + // Don't re-create the window if its size hasn't changed, as it's not + // necessary, and causes flashing in fullscreen mode if(myWindow) { int w, h; @@ -120,8 +121,12 @@ bool FrameBufferSDL2::setVideoMode(const string& title, const VideoMode& mode, myWindow = NULL; } } - - if(!myWindow) + if(myWindow) + { + // Even though window size stayed the same, the title may have changed + SDL_SetWindowTitle(myWindow, title.c_str()); + } + else { int pos = myOSystem.settings().getBool("center") ? SDL_WINDOWPOS_CENTERED : SDL_WINDOWPOS_UNDEFINED; @@ -191,13 +196,13 @@ void FrameBufferSDL2::invalidate() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void FrameBufferSDL2::showCursor(bool show) { -//FIXSDL SDL_ShowCursor(show ? SDL_ENABLE : SDL_DISABLE); + SDL_ShowCursor(show ? SDL_ENABLE : SDL_DISABLE); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void FrameBufferSDL2::grabMouse(bool grab) { -//FIXSDL SDL_WM_GrabInput(grab ? SDL_GRAB_ON : SDL_GRAB_OFF); + SDL_SetRelativeMouseMode(grab ? SDL_TRUE : SDL_FALSE); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/FrameBuffer.cxx b/src/emucore/FrameBuffer.cxx index dd020d800..2351f72ae 100644 --- a/src/emucore/FrameBuffer.cxx +++ b/src/emucore/FrameBuffer.cxx @@ -535,12 +535,14 @@ void FrameBuffer::refresh() case EventHandler::S_PAUSE: invalidate(); drawTIA(); +#if 0 // FIXME: eliminate stuttering in TIA mode; do we really need this? if(isDoubleBuffered()) { postFrameUpdate(); invalidate(); drawTIA(); } +#endif break; case EventHandler::S_MENU: @@ -731,13 +733,12 @@ bool FrameBuffer::changeWindowedVidMode(int direction) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void FrameBuffer::setCursorState() { - // Always grab mouse in fullscreen or during emulation (if enabled), - // and don't show the cursor during emulation + // Always grab mouse in emulation (if enabled), + // and don't show the cursor during emulation (if enabled) bool emulation = myOSystem.eventHandler().state() == EventHandler::S_EMULATE; - grabMouse(fullScreen() || - (emulation && myOSystem.settings().getBool("grabmouse"))); - showCursor(!emulation); + grabMouse(emulation && myOSystem.settings().getBool("grabmouse")); + showCursor(!(emulation || myOSystem.settings().getBool("hidecursor"))); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/Settings.cxx b/src/emucore/Settings.cxx index aabf8c84c..4c62d6f91 100644 --- a/src/emucore/Settings.cxx +++ b/src/emucore/Settings.cxx @@ -42,7 +42,6 @@ Settings::Settings(OSystem& osystem) setInternal("vsync", "true"); setInternal("fullscreen", "false"); setInternal("center", "false"); - setInternal("grabmouse", "true"); setInternal("palette", "standard"); setInternal("colorloss", "true"); setInternal("timing", "sleep"); @@ -84,6 +83,8 @@ Settings::Settings(OSystem& osystem) setInternal("joydeadzone", "13"); setInternal("joyallow4", "false"); setInternal("usemouse", "analog"); + setInternal("grabmouse", "true"); + setInternal("hidecursor", "false"); setInternal("dsense", "5"); setInternal("msense", "7"); setInternal("saport", "lr"); @@ -391,10 +392,11 @@ void Settings::usage() << " -logtoconsole <1|0> Log output to console/commandline\n" << " -joydeadzone Sets 'deadzone' area for analog joysticks (0-29)\n" << " -joyallow4 <1|0> Allow all 4 directions on a joystick to be pressed simultaneously\n" - << "FIXSDL -grabmouse <1|0> Keeps the mouse in the game window\n" << " -usemouse Use mouse as a controller as specified by ROM properties in given mode(see manual)\n" + << " -grabmouse <1|0> Locks the mouse cursor in the TIA window\n" + << " -hidecursor <1|0> Always hide the cursor, or show it when appropriate\n" << " -dsense Sensitivity of digital emulated paddle movement (1-10)\n" << " -msense Sensitivity of mouse emulated paddle movement (1-15)\n" << " -saport How to assign virtual ports to multiple Stelladaptor/2600-daptors\n" diff --git a/src/gui/InputDialog.cxx b/src/gui/InputDialog.cxx index 506e01df6..842743948 100644 --- a/src/gui/InputDialog.cxx +++ b/src/gui/InputDialog.cxx @@ -198,6 +198,15 @@ void InputDialog::addDevicePortTab(const GUI::Font& font) myGrabMouse->clearFlags(WIDGET_ENABLED); #endif + // Hide mouse cursor + ypos += lineHeight + 4; + myHideCursor = new CheckboxWidget(myTab, font, xpos, ypos, + "Always hide mouse cursor"); + wid.push_back(myHideCursor); +#ifndef WINDOWED_SUPPORT + myHideCursor->clearFlags(WIDGET_ENABLED); +#endif + // Add items for virtual device ports addToFocusList(wid, myTab, tabID); } @@ -216,9 +225,6 @@ void InputDialog::loadConfig() myDeadzone->setValue(instance().settings().getInt("joydeadzone")); myDeadzoneLabel->setValue(Joystick::deadzone()); - // Grab mouse - myGrabMouse->setState(instance().settings().getBool("grabmouse")); - // Paddle speed (digital and mouse) myDPaddleSpeed->setValue(instance().settings().getInt("dsense")); myDPaddleLabel->setLabel(instance().settings().getString("dsense")); @@ -231,6 +237,12 @@ void InputDialog::loadConfig() // Allow all 4 joystick directions myAllowAll4->setState(instance().settings().getBool("joyallow4")); + // Grab mouse + myGrabMouse->setState(instance().settings().getBool("grabmouse")); + + // Hide cursor + myHideCursor->setState(instance().settings().getBool("hidecursor")); + myTab->loadConfig(); } @@ -250,10 +262,6 @@ void InputDialog::saveConfig() instance().settings().setValue("joydeadzone", deadzone); Joystick::setDeadZone(deadzone); - // Grab mouse - instance().settings().setValue("grabmouse", myGrabMouse->getState()); - instance().frameBuffer().setCursorState(); - // Paddle speed (digital and mouse) int sensitivity = myDPaddleSpeed->getValue(); instance().settings().setValue("dsense", sensitivity); @@ -269,6 +277,11 @@ void InputDialog::saveConfig() bool allowall4 = myAllowAll4->getState(); instance().settings().setValue("joyallow4", allowall4); instance().eventHandler().allowAllDirections(allowall4); + + // Grab mouse and hide cursor + instance().settings().setValue("grabmouse", myGrabMouse->getState()); + instance().settings().setValue("hidecursor", myHideCursor->getState()); + instance().frameBuffer().setCursorState(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -296,9 +309,6 @@ void InputDialog::setDefaults() myDeadzone->setValue(0); myDeadzoneLabel->setValue(3200); - // Grab mouse - myGrabMouse->setState(true); - // Paddle speed (digital and mouse) myDPaddleSpeed->setValue(5); myDPaddleLabel->setLabel("5"); @@ -311,6 +321,12 @@ void InputDialog::setDefaults() // Allow all 4 joystick directions myAllowAll4->setState(false); + // Grab mouse + myGrabMouse->setState(true); + + // Hide cursor + myHideCursor->setState(false); + break; } diff --git a/src/gui/InputDialog.hxx b/src/gui/InputDialog.hxx index ae90e8892..2d4ec7dd2 100644 --- a/src/gui/InputDialog.hxx +++ b/src/gui/InputDialog.hxx @@ -79,6 +79,7 @@ class InputDialog : public Dialog StaticTextWidget* myMPaddleLabel; CheckboxWidget* myAllowAll4; CheckboxWidget* myGrabMouse; + CheckboxWidget* myHideCursor; }; #endif