mirror of https://github.com/stella-emu/stella.git
Fixed some state problems with (un)grabbing the mouse and showing/hiding
the cursor. It should now work correctly. Thanks to Mark Grebe for the suggestions. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@239 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
cc9a03f512
commit
87277a770f
|
@ -13,7 +13,7 @@
|
||||||
// See the file "license" for information on usage and redistribution of
|
// See the file "license" for information on usage and redistribution of
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
//
|
//
|
||||||
// $Id: FrameBufferGL.cxx,v 1.17 2004-04-20 21:07:50 stephena Exp $
|
// $Id: FrameBufferGL.cxx,v 1.18 2004-04-26 12:49:46 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
@ -233,21 +233,18 @@ bool FrameBufferGL::init()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure that theUseFullScreenFlag sets up fullscreen mode correctly
|
// Make sure that theUseFullScreenFlag sets up fullscreen mode correctly
|
||||||
theGrabMouseIndicator = myConsole->settings().getBool("grabmouse");
|
|
||||||
theHideCursorIndicator = myConsole->settings().getBool("hidecursor");
|
|
||||||
if(myConsole->settings().getBool("fullscreen"))
|
if(myConsole->settings().getBool("fullscreen"))
|
||||||
{
|
{
|
||||||
grabMouse(true);
|
grabMouse(true);
|
||||||
showCursor(false);
|
showCursor(false);
|
||||||
isFullscreen = true;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Keep mouse in game window if grabmouse is selected
|
// Keep mouse in game window if grabmouse is selected
|
||||||
grabMouse(theGrabMouseIndicator);
|
grabMouse(myConsole->settings().getBool("grabmouse"));
|
||||||
|
|
||||||
// Show or hide the cursor depending on the 'hidecursor' argument
|
// Show or hide the cursor depending on the 'hidecursor' argument
|
||||||
showCursor(!theHideCursorIndicator);
|
showCursor(!myConsole->settings().getBool("hidecursor"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
// See the file "license" for information on usage and redistribution of
|
// See the file "license" for information on usage and redistribution of
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
//
|
//
|
||||||
// $Id: FrameBufferSDL.cxx,v 1.13 2004-04-21 16:27:34 stephena Exp $
|
// $Id: FrameBufferSDL.cxx,v 1.14 2004-04-26 12:49:46 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
@ -33,10 +33,7 @@ FrameBufferSDL::FrameBufferSDL()
|
||||||
: x11Available(false),
|
: x11Available(false),
|
||||||
theZoomLevel(1),
|
theZoomLevel(1),
|
||||||
theMaxZoomLevel(1),
|
theMaxZoomLevel(1),
|
||||||
theGrabMouseIndicator(false),
|
|
||||||
theHideCursorIndicator(false),
|
|
||||||
theAspectRatio(1.0),
|
theAspectRatio(1.0),
|
||||||
isFullscreen(false),
|
|
||||||
myPauseStatus(false)
|
myPauseStatus(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -80,7 +77,7 @@ void FrameBufferSDL::setupPalette()
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void FrameBufferSDL::toggleFullscreen()
|
void FrameBufferSDL::toggleFullscreen()
|
||||||
{
|
{
|
||||||
isFullscreen = !isFullscreen;
|
bool isFullscreen = !myConsole->settings().getBool("fullscreen");
|
||||||
|
|
||||||
// Update the settings
|
// Update the settings
|
||||||
myConsole->settings().setBool("fullscreen", isFullscreen);
|
myConsole->settings().setBool("fullscreen", isFullscreen);
|
||||||
|
@ -100,8 +97,8 @@ void FrameBufferSDL::toggleFullscreen()
|
||||||
}
|
}
|
||||||
else // now in windowed mode
|
else // now in windowed mode
|
||||||
{
|
{
|
||||||
grabMouse(theGrabMouseIndicator);
|
grabMouse(myConsole->settings().getBool("grabmouse"));
|
||||||
showCursor(!theHideCursorIndicator);
|
showCursor(!myConsole->settings().getBool("hidecursor"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,7 +114,7 @@ void FrameBufferSDL::resize(int mode)
|
||||||
}
|
}
|
||||||
else if(mode == 1) // increase size
|
else if(mode == 1) // increase size
|
||||||
{
|
{
|
||||||
if(isFullscreen)
|
if(myConsole->settings().getBool("fullscreen"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(theZoomLevel == theMaxZoomLevel)
|
if(theZoomLevel == theMaxZoomLevel)
|
||||||
|
@ -127,7 +124,7 @@ void FrameBufferSDL::resize(int mode)
|
||||||
}
|
}
|
||||||
else if(mode == -1) // decrease size
|
else if(mode == -1) // decrease size
|
||||||
{
|
{
|
||||||
if(isFullscreen)
|
if(myConsole->settings().getBool("fullscreen"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(theZoomLevel == 1)
|
if(theZoomLevel == 1)
|
||||||
|
@ -146,31 +143,25 @@ void FrameBufferSDL::resize(int mode)
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void FrameBufferSDL::showCursor(bool show)
|
void FrameBufferSDL::showCursor(bool show)
|
||||||
{
|
{
|
||||||
if(isFullscreen)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if(show)
|
if(show)
|
||||||
SDL_ShowCursor(SDL_ENABLE);
|
SDL_ShowCursor(SDL_ENABLE);
|
||||||
else
|
else
|
||||||
SDL_ShowCursor(SDL_DISABLE);
|
SDL_ShowCursor(SDL_DISABLE);
|
||||||
|
|
||||||
// Update the settings
|
|
||||||
myConsole->settings().setBool("hidecursor", !show);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void FrameBufferSDL::grabMouse(bool grab)
|
void FrameBufferSDL::grabMouse(bool grab)
|
||||||
{
|
{
|
||||||
if(isFullscreen)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if(grab)
|
if(grab)
|
||||||
SDL_WM_GrabInput(SDL_GRAB_ON);
|
SDL_WM_GrabInput(SDL_GRAB_ON);
|
||||||
else
|
else
|
||||||
SDL_WM_GrabInput(SDL_GRAB_OFF);
|
SDL_WM_GrabInput(SDL_GRAB_OFF);
|
||||||
|
}
|
||||||
|
|
||||||
// Update the settings
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
myConsole->settings().setBool("grabmouse", grab);
|
bool FrameBufferSDL::fullScreen()
|
||||||
|
{
|
||||||
|
return myConsole->settings().getBool("fullscreen");
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
// See the file "license" for information on usage and redistribution of
|
// See the file "license" for information on usage and redistribution of
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
//
|
//
|
||||||
// $Id: FrameBufferSDL.hxx,v 1.10 2004-04-15 22:52:43 stephena Exp $
|
// $Id: FrameBufferSDL.hxx,v 1.11 2004-04-26 12:49:46 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#ifndef FRAMEBUFFER_SDL_HXX
|
#ifndef FRAMEBUFFER_SDL_HXX
|
||||||
|
@ -23,6 +23,7 @@
|
||||||
#include <SDL_syswm.h>
|
#include <SDL_syswm.h>
|
||||||
|
|
||||||
#include "FrameBuffer.hxx"
|
#include "FrameBuffer.hxx"
|
||||||
|
#include "Settings.hxx"
|
||||||
#include "bspf.hxx"
|
#include "bspf.hxx"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -34,7 +35,7 @@
|
||||||
the core FrameBuffer.
|
the core FrameBuffer.
|
||||||
|
|
||||||
@author Stephen Anthony
|
@author Stephen Anthony
|
||||||
@version $Id: FrameBufferSDL.hxx,v 1.10 2004-04-15 22:52:43 stephena Exp $
|
@version $Id: FrameBufferSDL.hxx,v 1.11 2004-04-26 12:49:46 stephena Exp $
|
||||||
*/
|
*/
|
||||||
class FrameBufferSDL : public FrameBuffer
|
class FrameBufferSDL : public FrameBuffer
|
||||||
{
|
{
|
||||||
|
@ -79,7 +80,7 @@ class FrameBufferSDL : public FrameBuffer
|
||||||
/**
|
/**
|
||||||
Answers if the display is currently in fullscreen mode.
|
Answers if the display is currently in fullscreen mode.
|
||||||
*/
|
*/
|
||||||
bool fullScreen() { return isFullscreen; }
|
bool fullScreen();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Answers the current zoom level of the SDL
|
Answers the current zoom level of the SDL
|
||||||
|
@ -152,18 +153,9 @@ class FrameBufferSDL : public FrameBuffer
|
||||||
// Indicates the maximum zoom of the SDL screen
|
// Indicates the maximum zoom of the SDL screen
|
||||||
uInt32 theMaxZoomLevel;
|
uInt32 theMaxZoomLevel;
|
||||||
|
|
||||||
// Indicates if the mouse should be grabbed
|
|
||||||
bool theGrabMouseIndicator;
|
|
||||||
|
|
||||||
// Indicates if the mouse cursor should be hidden
|
|
||||||
bool theHideCursorIndicator;
|
|
||||||
|
|
||||||
// The aspect ratio of the window
|
// The aspect ratio of the window
|
||||||
float theAspectRatio;
|
float theAspectRatio;
|
||||||
|
|
||||||
// Indicates whether the game is currently in fullscreen
|
|
||||||
bool isFullscreen;
|
|
||||||
|
|
||||||
// Indicates whether the emulation has paused
|
// Indicates whether the emulation has paused
|
||||||
bool myPauseStatus;
|
bool myPauseStatus;
|
||||||
};
|
};
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
// See the file "license" for information on usage and redistribution of
|
// See the file "license" for information on usage and redistribution of
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
//
|
//
|
||||||
// $Id: FrameBufferSoft.cxx,v 1.6 2004-04-20 21:08:03 stephena Exp $
|
// $Id: FrameBufferSoft.cxx,v 1.7 2004-04-26 12:49:46 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
@ -106,21 +106,18 @@ bool FrameBufferSoft::init()
|
||||||
setupPalette();
|
setupPalette();
|
||||||
|
|
||||||
// Make sure that theUseFullScreenFlag sets up fullscreen mode correctly
|
// Make sure that theUseFullScreenFlag sets up fullscreen mode correctly
|
||||||
theGrabMouseIndicator = myConsole->settings().getBool("grabmouse");
|
|
||||||
theHideCursorIndicator = myConsole->settings().getBool("hidecursor");
|
|
||||||
if(myConsole->settings().getBool("fullscreen"))
|
if(myConsole->settings().getBool("fullscreen"))
|
||||||
{
|
{
|
||||||
grabMouse(true);
|
grabMouse(true);
|
||||||
showCursor(false);
|
showCursor(false);
|
||||||
isFullscreen = true;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Keep mouse in game window if grabmouse is selected
|
// Keep mouse in game window if grabmouse is selected
|
||||||
grabMouse(theGrabMouseIndicator);
|
grabMouse(myConsole->settings().getBool("grabmouse"));
|
||||||
|
|
||||||
// Show or hide the cursor depending on the 'hidecursor' argument
|
// Show or hide the cursor depending on the 'hidecursor' argument
|
||||||
showCursor(!theHideCursorIndicator);
|
showCursor(!myConsole->settings().getBool("hidecursor"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
// See the file "license" for information on usage and redistribution of
|
// See the file "license" for information on usage and redistribution of
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
//
|
//
|
||||||
// $Id: mainSDL.cxx,v 1.71 2004-04-16 13:10:37 stephena Exp $
|
// $Id: mainSDL.cxx,v 1.72 2004-04-26 12:49:46 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
@ -370,6 +370,7 @@ void handleEvents()
|
||||||
if(!theDisplay->fullScreen())
|
if(!theDisplay->fullScreen())
|
||||||
{
|
{
|
||||||
theGrabMouseIndicator = !theGrabMouseIndicator;
|
theGrabMouseIndicator = !theGrabMouseIndicator;
|
||||||
|
theSettings->setBool("grabmouse", theGrabMouseIndicator);
|
||||||
theDisplay->grabMouse(theGrabMouseIndicator);
|
theDisplay->grabMouse(theGrabMouseIndicator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -379,6 +380,7 @@ void handleEvents()
|
||||||
if(!theDisplay->fullScreen())
|
if(!theDisplay->fullScreen())
|
||||||
{
|
{
|
||||||
theHideCursorIndicator = !theHideCursorIndicator;
|
theHideCursorIndicator = !theHideCursorIndicator;
|
||||||
|
theSettings->setBool("hidecursor", theHideCursorIndicator);
|
||||||
theDisplay->showCursor(!theHideCursorIndicator);
|
theDisplay->showCursor(!theHideCursorIndicator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -682,6 +684,8 @@ int main(int argc, char* argv[])
|
||||||
// Cache some settings so they don't have to be repeatedly searched for
|
// Cache some settings so they don't have to be repeatedly searched for
|
||||||
thePaddleMode = theSettings->getInt("paddle");
|
thePaddleMode = theSettings->getInt("paddle");
|
||||||
theShowInfoFlag = theSettings->getBool("showinfo");
|
theShowInfoFlag = theSettings->getBool("showinfo");
|
||||||
|
theGrabMouseIndicator = theSettings->getBool("grabmouse");
|
||||||
|
theHideCursorIndicator = theSettings->getBool("hidecursor");
|
||||||
|
|
||||||
// Request that the SDL window be centered, if possible
|
// Request that the SDL window be centered, if possible
|
||||||
putenv("SDL_VIDEO_CENTERED=1");
|
putenv("SDL_VIDEO_CENTERED=1");
|
||||||
|
|
Loading…
Reference in New Issue