mirror of https://github.com/stella-emu/stella.git
Cleaned up event gathering loop and moved it from mainSDL into the
EventHandler class. Eventually, *all* event-related stuff will move to this class (which makes sense, considering its name). Removed all references to joystick stuff for now. It will be re-added later. Re-enabled snapshot support. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@389 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
088210251e
commit
cad03a19cb
|
@ -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: makefile,v 1.69 2005-03-28 00:04:49 stephena Exp $
|
## $Id: makefile,v 1.70 2005-04-03 19:37:32 stephena Exp $
|
||||||
##============================================================================
|
##============================================================================
|
||||||
|
|
||||||
##============================================================================
|
##============================================================================
|
||||||
|
@ -32,7 +32,7 @@ OPTIMIZATIONS =
|
||||||
|
|
||||||
### to include support for saving snapshots in png format
|
### to include support for saving snapshots in png format
|
||||||
### (requires PNG library)
|
### (requires PNG library)
|
||||||
# SNAPSHOT_SUPPORT = 1
|
SNAPSHOT_SUPPORT = 1
|
||||||
|
|
||||||
### to include support for game developers
|
### to include support for game developers
|
||||||
### enables some extra commandline options that allow the user
|
### enables some extra commandline options that allow the user
|
||||||
|
|
|
@ -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.15 2005-03-28 00:04:53 stephena Exp $
|
// $Id: FrameBufferGL.cxx,v 1.16 2005-04-03 19:37:32 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
@ -334,7 +334,7 @@ void FrameBufferGL::toggleFilter()
|
||||||
void FrameBufferGL::hLine(uInt32 x, uInt32 y, uInt32 x2, OverlayColor color)
|
void FrameBufferGL::hLine(uInt32 x, uInt32 y, uInt32 x2, OverlayColor color)
|
||||||
{
|
{
|
||||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND);
|
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND);
|
||||||
glLineWidth(1);
|
glLineWidth(2);
|
||||||
glColor4f(myGUIPalette[color][0],
|
glColor4f(myGUIPalette[color][0],
|
||||||
myGUIPalette[color][1],
|
myGUIPalette[color][1],
|
||||||
myGUIPalette[color][2],
|
myGUIPalette[color][2],
|
||||||
|
@ -349,7 +349,7 @@ void FrameBufferGL::hLine(uInt32 x, uInt32 y, uInt32 x2, OverlayColor color)
|
||||||
void FrameBufferGL::vLine(uInt32 x, uInt32 y, uInt32 y2, OverlayColor color)
|
void FrameBufferGL::vLine(uInt32 x, uInt32 y, uInt32 y2, OverlayColor color)
|
||||||
{
|
{
|
||||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND);
|
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND);
|
||||||
glLineWidth(1);
|
glLineWidth(2);
|
||||||
glColor4f(myGUIPalette[color][0],
|
glColor4f(myGUIPalette[color][0],
|
||||||
myGUIPalette[color][1],
|
myGUIPalette[color][1],
|
||||||
myGUIPalette[color][2],
|
myGUIPalette[color][2],
|
||||||
|
|
|
@ -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: Snapshot.cxx,v 1.4 2005-02-13 19:17:02 stephena Exp $
|
// $Id: Snapshot.cxx,v 1.5 2005-04-03 19:37:32 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#include <png.h>
|
#include <png.h>
|
||||||
|
@ -22,7 +22,6 @@
|
||||||
|
|
||||||
#include "bspf.hxx"
|
#include "bspf.hxx"
|
||||||
#include "FrameBuffer.hxx"
|
#include "FrameBuffer.hxx"
|
||||||
#include "FrameBufferSDL.hxx"
|
|
||||||
#include "Snapshot.hxx"
|
#include "Snapshot.hxx"
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
|
@ -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.29 2005-03-26 04:19:53 stephena Exp $
|
// $Id: mainSDL.cxx,v 1.30 2005-04-03 19:37:32 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
@ -33,7 +33,6 @@
|
||||||
#include "bspf.hxx"
|
#include "bspf.hxx"
|
||||||
#include "Console.hxx"
|
#include "Console.hxx"
|
||||||
#include "Event.hxx"
|
#include "Event.hxx"
|
||||||
#include "StellaEvent.hxx"
|
|
||||||
#include "EventHandler.hxx"
|
#include "EventHandler.hxx"
|
||||||
#include "FrameBuffer.hxx"
|
#include "FrameBuffer.hxx"
|
||||||
#include "FrameBufferSoft.hxx"
|
#include "FrameBufferSoft.hxx"
|
||||||
|
@ -60,62 +59,9 @@
|
||||||
static void mainGameLoop();
|
static void mainGameLoop();
|
||||||
static Console* CreateConsole(const string& romfile);
|
static Console* CreateConsole(const string& romfile);
|
||||||
static void Cleanup();
|
static void Cleanup();
|
||||||
static bool SetupJoystick();
|
|
||||||
static void HandleEvents();
|
|
||||||
static uInt32 GetTicks();
|
static uInt32 GetTicks();
|
||||||
static void SetupProperties(PropertiesSet& set);
|
static void SetupProperties(PropertiesSet& set);
|
||||||
static void ShowInfo(const string& msg);
|
static void ShowInfo(const string& msg);
|
||||||
static void SetPaddleMode(Int32 mode);
|
|
||||||
|
|
||||||
#ifdef JOYSTICK_SUPPORT
|
|
||||||
// Lookup table for joystick numbers and events
|
|
||||||
StellaEvent::JoyStick joyList[StellaEvent::LastJSTICK] = {
|
|
||||||
StellaEvent::JSTICK_0, StellaEvent::JSTICK_1, StellaEvent::JSTICK_2,
|
|
||||||
StellaEvent::JSTICK_3, StellaEvent::JSTICK_5, StellaEvent::JSTICK_5
|
|
||||||
};
|
|
||||||
StellaEvent::JoyCode joyButtonList[StellaEvent::LastJCODE] = {
|
|
||||||
StellaEvent::JBUTTON_0, StellaEvent::JBUTTON_1, StellaEvent::JBUTTON_2,
|
|
||||||
StellaEvent::JBUTTON_3, StellaEvent::JBUTTON_4, StellaEvent::JBUTTON_5,
|
|
||||||
StellaEvent::JBUTTON_6, StellaEvent::JBUTTON_7, StellaEvent::JBUTTON_8,
|
|
||||||
StellaEvent::JBUTTON_9, StellaEvent::JBUTTON_10, StellaEvent::JBUTTON_11,
|
|
||||||
StellaEvent::JBUTTON_12, StellaEvent::JBUTTON_13, StellaEvent::JBUTTON_14,
|
|
||||||
StellaEvent::JBUTTON_15, StellaEvent::JBUTTON_16, StellaEvent::JBUTTON_17,
|
|
||||||
StellaEvent::JBUTTON_18, StellaEvent::JBUTTON_19
|
|
||||||
};
|
|
||||||
|
|
||||||
enum JoyType { JT_NONE, JT_REGULAR, JT_STELLADAPTOR_1, JT_STELLADAPTOR_2 };
|
|
||||||
|
|
||||||
struct Stella_Joystick
|
|
||||||
{
|
|
||||||
SDL_Joystick* stick;
|
|
||||||
JoyType type;
|
|
||||||
};
|
|
||||||
|
|
||||||
static Stella_Joystick theJoysticks[StellaEvent::LastJSTICK];
|
|
||||||
|
|
||||||
// Static lookup tables for Stelladaptor axis support
|
|
||||||
static Event::Type SA_Axis[2][2][3] = {
|
|
||||||
Event::JoystickZeroLeft, Event::JoystickZeroRight, Event::PaddleZeroResistance,
|
|
||||||
Event::JoystickZeroUp, Event::JoystickZeroDown, Event::PaddleOneResistance,
|
|
||||||
Event::JoystickOneLeft, Event::JoystickOneRight, Event::PaddleTwoResistance,
|
|
||||||
Event::JoystickOneUp, Event::JoystickOneDown, Event::PaddleThreeResistance
|
|
||||||
};
|
|
||||||
static Event::Type SA_DrivingValue[2] = {
|
|
||||||
Event::DrivingZeroValue, Event::DrivingOneValue
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Lookup table for paddle resistance events
|
|
||||||
static Event::Type Paddle_Resistance[4] = {
|
|
||||||
Event::PaddleZeroResistance, Event::PaddleOneResistance,
|
|
||||||
Event::PaddleTwoResistance, Event::PaddleThreeResistance
|
|
||||||
};
|
|
||||||
|
|
||||||
// Lookup table for paddle button events
|
|
||||||
static Event::Type Paddle_Button[4] = {
|
|
||||||
Event::PaddleZeroFire, Event::PaddleOneFire,
|
|
||||||
Event::PaddleTwoFire, Event::PaddleThreeFire
|
|
||||||
};
|
|
||||||
|
|
||||||
// Pointer to the main parent osystem object or the null pointer
|
// Pointer to the main parent osystem object or the null pointer
|
||||||
static OSystem* theOSystem = (OSystem*) NULL;
|
static OSystem* theOSystem = (OSystem*) NULL;
|
||||||
|
@ -132,47 +78,14 @@ static Sound* theSound = (Sound*) NULL;
|
||||||
// Pointer to the settings object or the null pointer
|
// Pointer to the settings object or the null pointer
|
||||||
static Settings* theSettings = (Settings*) NULL;
|
static Settings* theSettings = (Settings*) NULL;
|
||||||
|
|
||||||
// Indicates if the mouse should be grabbed
|
|
||||||
static bool theGrabMouseIndicator = false;
|
|
||||||
|
|
||||||
// Indicates if the mouse cursor should be hidden
|
|
||||||
static bool theHideCursorIndicator = false;
|
|
||||||
|
|
||||||
// Indicates the current paddle mode
|
|
||||||
static Int32 thePaddleMode;
|
|
||||||
|
|
||||||
// Indicates relative mouse position horizontally
|
|
||||||
static Int32 mouseX = 0;
|
|
||||||
|
|
||||||
// Indicates whether to show information during program execution
|
// Indicates whether to show information during program execution
|
||||||
static bool theShowInfoFlag;
|
static bool theShowInfoFlag;
|
||||||
|
|
||||||
struct KeyList
|
|
||||||
{
|
|
||||||
SDLKey scanCode;
|
|
||||||
StellaEvent::KeyCode keyCode;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Set the mouse to emulate the given paddle
|
|
||||||
*/
|
|
||||||
void SetPaddleMode(Int32 mode)
|
|
||||||
{
|
|
||||||
thePaddleMode = mode;
|
|
||||||
|
|
||||||
ostringstream buf;
|
|
||||||
buf << "Mouse is paddle " << mode;
|
|
||||||
theDisplay->showMessage(buf.str());
|
|
||||||
|
|
||||||
theSettings->setInt("paddle",thePaddleMode);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Prints given message based on 'theShowInfoFlag'
|
Prints given message based on 'theShowInfoFlag'
|
||||||
*/
|
*/
|
||||||
static void ShowInfo(const string& msg)
|
static inline void ShowInfo(const string& msg)
|
||||||
{
|
{
|
||||||
if(theShowInfoFlag && msg != "")
|
if(theShowInfoFlag && msg != "")
|
||||||
cout << msg << endl;
|
cout << msg << endl;
|
||||||
|
@ -198,431 +111,6 @@ inline uInt32 GetTicks()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
This routine should be called once setupDisplay is called
|
|
||||||
to create the joystick stuff.
|
|
||||||
*/
|
|
||||||
bool SetupJoystick()
|
|
||||||
{
|
|
||||||
#ifdef JOYSTICK_SUPPORT
|
|
||||||
ostringstream message;
|
|
||||||
|
|
||||||
// Keep track of how many Stelladaptors we've found
|
|
||||||
uInt8 saCount = 0;
|
|
||||||
|
|
||||||
// First clear the joystick array
|
|
||||||
for(uInt32 i = 0; i < StellaEvent::LastJSTICK; i++)
|
|
||||||
{
|
|
||||||
theJoysticks[i].stick = (SDL_Joystick*) NULL;
|
|
||||||
theJoysticks[i].type = JT_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize the joystick subsystem
|
|
||||||
if((SDL_InitSubSystem(SDL_INIT_JOYSTICK) == -1) || (SDL_NumJoysticks() <= 0))
|
|
||||||
{
|
|
||||||
ShowInfo("No joysticks present, use the keyboard.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Try to open 4 regular joysticks and 2 Stelladaptor devices
|
|
||||||
uInt32 limit = SDL_NumJoysticks() <= StellaEvent::LastJSTICK ?
|
|
||||||
SDL_NumJoysticks() : StellaEvent::LastJSTICK;
|
|
||||||
for(uInt32 i = 0; i < limit; i++)
|
|
||||||
{
|
|
||||||
message.str("");
|
|
||||||
|
|
||||||
string name = SDL_JoystickName(i);
|
|
||||||
theJoysticks[i].stick = SDL_JoystickOpen(i);
|
|
||||||
|
|
||||||
// Skip if we couldn't open it for any reason
|
|
||||||
if(theJoysticks[i].stick == NULL)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// Figure out what type of joystick this is
|
|
||||||
if(name.find("Stelladaptor", 0) != string::npos)
|
|
||||||
{
|
|
||||||
saCount++;
|
|
||||||
if(saCount > 2) // Ignore more than 2 Stelladaptors
|
|
||||||
{
|
|
||||||
theJoysticks[i].type = JT_NONE;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else if(saCount == 1)
|
|
||||||
{
|
|
||||||
name = "Left Stelladaptor (Left joystick, Paddles 0 and 1, Left driving controller)";
|
|
||||||
theJoysticks[i].type = JT_STELLADAPTOR_1;
|
|
||||||
}
|
|
||||||
else if(saCount == 2)
|
|
||||||
{
|
|
||||||
name = "Right Stelladaptor (Right joystick, Paddles 2 and 3, Right driving controller)";
|
|
||||||
theJoysticks[i].type = JT_STELLADAPTOR_2;
|
|
||||||
}
|
|
||||||
|
|
||||||
message << "Joystick " << i << ": " << name;
|
|
||||||
ShowInfo(message.str());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
theJoysticks[i].type = JT_REGULAR;
|
|
||||||
|
|
||||||
message << "Joystick " << i << ": " << SDL_JoystickName(i)
|
|
||||||
<< " with " << SDL_JoystickNumButtons(theJoysticks[i].stick)
|
|
||||||
<< " buttons.";
|
|
||||||
ShowInfo(message.str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
This routine should be called regularly to handle events
|
|
||||||
*/
|
|
||||||
void HandleEvents()
|
|
||||||
{
|
|
||||||
SDL_Event event;
|
|
||||||
|
|
||||||
// Check for an event
|
|
||||||
while(SDL_PollEvent(&event))
|
|
||||||
{
|
|
||||||
switch(event.type)
|
|
||||||
{
|
|
||||||
// keyboard events
|
|
||||||
case SDL_KEYUP:
|
|
||||||
case SDL_KEYDOWN:
|
|
||||||
{
|
|
||||||
SDLKey key = event.key.keysym.sym;
|
|
||||||
SDLMod mod = event.key.keysym.mod;
|
|
||||||
uInt8 state = event.key.type == SDL_KEYDOWN ? 1 : 0;
|
|
||||||
|
|
||||||
// An attempt to speed up event processing
|
|
||||||
// All SDL-specific event actions are accessed by either
|
|
||||||
// Control or Alt keys. So we quickly check for those.
|
|
||||||
if(mod & KMOD_ALT && state)
|
|
||||||
{
|
|
||||||
switch(int(key))
|
|
||||||
{
|
|
||||||
case SDLK_EQUALS:
|
|
||||||
theDisplay->resize(1);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDLK_MINUS:
|
|
||||||
theDisplay->resize(-1);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDLK_RETURN:
|
|
||||||
theDisplay->toggleFullscreen();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDLK_LEFTBRACKET:
|
|
||||||
theSound->adjustVolume(-1);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDLK_RIGHTBRACKET:
|
|
||||||
theSound->adjustVolume(1);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDLK_f:
|
|
||||||
theDisplay->toggleFilter();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef DEVELOPER_SUPPORT
|
|
||||||
if(theOSystem->eventHandler().state() == EventHandler::S_EMULATE)
|
|
||||||
{
|
|
||||||
switch(int(key))
|
|
||||||
{
|
|
||||||
case SDLK_END: // Alt-End increases XStart
|
|
||||||
theOSystem->console().changeXStart(1);
|
|
||||||
theDisplay->resize(0);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDLK_HOME: // Alt-Home decreases XStart
|
|
||||||
theOSystem->console().changeXStart(0);
|
|
||||||
theDisplay->resize(0);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDLK_PAGEUP: // Alt-PageUp increases YStart
|
|
||||||
theOSystem->console().changeYStart(1);
|
|
||||||
theDisplay->resize(0);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDLK_PAGEDOWN: // Alt-PageDown decreases YStart
|
|
||||||
theOSystem->console().changeYStart(0);
|
|
||||||
theDisplay->resize(0);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else if(mod & KMOD_CTRL && state)
|
|
||||||
{
|
|
||||||
if(key == SDLK_q)
|
|
||||||
{
|
|
||||||
theOSystem->eventHandler().handleEvent(Event::Quit, 1);
|
|
||||||
}
|
|
||||||
else if(theOSystem->eventHandler().state() == EventHandler::S_EMULATE)
|
|
||||||
{
|
|
||||||
switch(int(key))
|
|
||||||
{
|
|
||||||
case SDLK_g:
|
|
||||||
// don't change grabmouse in fullscreen mode
|
|
||||||
if(!theDisplay->fullScreen())
|
|
||||||
{
|
|
||||||
theGrabMouseIndicator = !theGrabMouseIndicator;
|
|
||||||
theSettings->setBool("grabmouse", theGrabMouseIndicator);
|
|
||||||
theDisplay->grabMouse(theGrabMouseIndicator);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDLK_h:
|
|
||||||
// don't change hidecursor in fullscreen mode
|
|
||||||
if(!theDisplay->fullScreen())
|
|
||||||
{
|
|
||||||
theHideCursorIndicator = !theHideCursorIndicator;
|
|
||||||
theSettings->setBool("hidecursor", theHideCursorIndicator);
|
|
||||||
theDisplay->showCursor(!theHideCursorIndicator);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDLK_0: // Ctrl-0 sets the mouse to paddle 0
|
|
||||||
SetPaddleMode(0);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDLK_1: // Ctrl-1 sets the mouse to paddle 1
|
|
||||||
SetPaddleMode(1);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDLK_2: // Ctrl-2 sets the mouse to paddle 2
|
|
||||||
SetPaddleMode(2);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDLK_3: // Ctrl-3 sets the mouse to paddle 3
|
|
||||||
SetPaddleMode(3);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDLK_f: // Ctrl-f toggles NTSC/PAL mode
|
|
||||||
theOSystem->console().toggleFormat();
|
|
||||||
theDisplay->setupPalette();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDLK_p: // Ctrl-p toggles different palettes
|
|
||||||
theOSystem->console().togglePalette();
|
|
||||||
// theDisplay->setupPalette();
|
|
||||||
break;
|
|
||||||
|
|
||||||
#ifdef DEVELOPER_SUPPORT
|
|
||||||
case SDLK_END: // Ctrl-End increases Width
|
|
||||||
theOSystem->console().changeWidth(1);
|
|
||||||
theDisplay->resize(0);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDLK_HOME: // Ctrl-Home decreases Width
|
|
||||||
theOSystem->console().changeWidth(0);
|
|
||||||
theDisplay->resize(0);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDLK_PAGEUP: // Ctrl-PageUp increases Height
|
|
||||||
theOSystem->console().changeHeight(1);
|
|
||||||
theDisplay->resize(0);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDLK_PAGEDOWN: // Ctrl-PageDown decreases Height
|
|
||||||
theOSystem->console().changeHeight(0);
|
|
||||||
theDisplay->resize(0);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
case SDLK_s: // Ctrl-s saves properties to a file
|
|
||||||
// Attempt to merge with propertiesSet
|
|
||||||
if(theSettings->getBool("mergeprops"))
|
|
||||||
theOSystem->console().saveProperties(theOSystem->propertiesOutputFilename(), true);
|
|
||||||
else // Save to file in home directory
|
|
||||||
{
|
|
||||||
string newPropertiesFile = theOSystem->baseDir() + "/" + \
|
|
||||||
theOSystem->console().properties().get("Cartridge.Name") + ".pro";
|
|
||||||
theOSystem->console().saveProperties(newPropertiesFile);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Otherwise, let the event handler deal with it
|
|
||||||
theOSystem->eventHandler().handleKeyEvent(key, mod, state);
|
|
||||||
break; // SDL_KEYUP, SDL_KEYDOWN
|
|
||||||
}
|
|
||||||
|
|
||||||
case SDL_MOUSEMOTION:
|
|
||||||
{
|
|
||||||
theOSystem->eventHandler().handleMouseMotionEvent(event);
|
|
||||||
break; // SDL_MOUSEMOTION
|
|
||||||
}
|
|
||||||
|
|
||||||
case SDL_MOUSEBUTTONUP:
|
|
||||||
case SDL_MOUSEBUTTONDOWN:
|
|
||||||
{
|
|
||||||
uInt8 state = event.button.type == SDL_MOUSEBUTTONDOWN ? 1 : 0;
|
|
||||||
theOSystem->eventHandler().handleMouseButtonEvent(event, state);
|
|
||||||
break; // SDL_MOUSEBUTTONUP, SDL_MOUSEBUTTONDOWN
|
|
||||||
}
|
|
||||||
|
|
||||||
case SDL_ACTIVEEVENT:
|
|
||||||
{
|
|
||||||
if((event.active.state & SDL_APPACTIVE) && (event.active.gain == 0))
|
|
||||||
{
|
|
||||||
if(!theOSystem->eventHandler().doPause())
|
|
||||||
theOSystem->eventHandler().handleEvent(Event::Pause, 1);
|
|
||||||
}
|
|
||||||
break; // SDL_ACTIVEEVENT
|
|
||||||
}
|
|
||||||
|
|
||||||
case SDL_QUIT:
|
|
||||||
{
|
|
||||||
theOSystem->eventHandler().handleEvent(Event::Quit, 1);
|
|
||||||
break; // SDL_QUIT
|
|
||||||
}
|
|
||||||
|
|
||||||
case SDL_VIDEOEXPOSE:
|
|
||||||
{
|
|
||||||
theDisplay->refresh();
|
|
||||||
break; // SDL_VIDEOEXPOSE
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef JOYSTICK_SUPPORT
|
|
||||||
// Read joystick events and modify event states
|
|
||||||
StellaEvent::JoyStick stick;
|
|
||||||
StellaEvent::JoyCode code;
|
|
||||||
Int32 state;
|
|
||||||
Uint8 axis;
|
|
||||||
Uint8 button;
|
|
||||||
Int32 resistance;
|
|
||||||
Sint16 value;
|
|
||||||
JoyType type;
|
|
||||||
|
|
||||||
if(event.jbutton.which >= StellaEvent::LastJSTICK)
|
|
||||||
return;
|
|
||||||
|
|
||||||
stick = joyList[event.jbutton.which];
|
|
||||||
type = theJoysticks[event.jbutton.which].type;
|
|
||||||
|
|
||||||
// Figure put what type of joystick we're dealing with
|
|
||||||
// Stelladaptors behave differently, and can't be remapped
|
|
||||||
switch(type)
|
|
||||||
{
|
|
||||||
case JT_NONE:
|
|
||||||
break;
|
|
||||||
|
|
||||||
case JT_REGULAR:
|
|
||||||
switch(event.type)
|
|
||||||
{
|
|
||||||
case SDL_JOYBUTTONUP:
|
|
||||||
case SDL_JOYBUTTONDOWN:
|
|
||||||
if(event.jbutton.button >= StellaEvent::LastJCODE)
|
|
||||||
return;
|
|
||||||
|
|
||||||
code = joyButtonList[event.jbutton.button];
|
|
||||||
state = event.jbutton.state == SDL_PRESSED ? 1 : 0;
|
|
||||||
|
|
||||||
theOSystem->eventHandler().sendJoyEvent(stick, code, state);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_JOYAXISMOTION:
|
|
||||||
axis = event.jaxis.axis;
|
|
||||||
value = event.jaxis.value;
|
|
||||||
|
|
||||||
if(axis == 0) // x-axis
|
|
||||||
{
|
|
||||||
theOSystem->eventHandler().sendJoyEvent(stick, StellaEvent::JAXIS_LEFT,
|
|
||||||
(value < -16384) ? 1 : 0);
|
|
||||||
theOSystem->eventHandler().sendJoyEvent(stick, StellaEvent::JAXIS_RIGHT,
|
|
||||||
(value > 16384) ? 1 : 0);
|
|
||||||
}
|
|
||||||
else if(axis == 1) // y-axis
|
|
||||||
{
|
|
||||||
theOSystem->eventHandler().sendJoyEvent(stick, StellaEvent::JAXIS_UP,
|
|
||||||
(value < -16384) ? 1 : 0);
|
|
||||||
theOSystem->eventHandler().sendJoyEvent(stick, StellaEvent::JAXIS_DOWN,
|
|
||||||
(value > 16384) ? 1 : 0);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break; // Regular joystick
|
|
||||||
|
|
||||||
case JT_STELLADAPTOR_1:
|
|
||||||
case JT_STELLADAPTOR_2:
|
|
||||||
switch(event.type)
|
|
||||||
{
|
|
||||||
case SDL_JOYBUTTONUP:
|
|
||||||
case SDL_JOYBUTTONDOWN:
|
|
||||||
button = event.jbutton.button;
|
|
||||||
state = event.jbutton.state == SDL_PRESSED ? 1 : 0;
|
|
||||||
|
|
||||||
// Send button events for the joysticks/paddles/driving controllers
|
|
||||||
if(button == 0)
|
|
||||||
{
|
|
||||||
if(type == JT_STELLADAPTOR_1)
|
|
||||||
{
|
|
||||||
theOSystem->eventHandler().handleEvent(Event::JoystickZeroFire, state);
|
|
||||||
theOSystem->eventHandler().handleEvent(Event::DrivingZeroFire, state);
|
|
||||||
theOSystem->eventHandler().handleEvent(Event::PaddleZeroFire, state);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
theOSystem->eventHandler().handleEvent(Event::JoystickOneFire, state);
|
|
||||||
theOSystem->eventHandler().handleEvent(Event::DrivingOneFire, state);
|
|
||||||
theOSystem->eventHandler().handleEvent(Event::PaddleTwoFire, state);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(button == 1)
|
|
||||||
{
|
|
||||||
if(type == JT_STELLADAPTOR_1)
|
|
||||||
theOSystem->eventHandler().handleEvent(Event::PaddleOneFire, state);
|
|
||||||
else
|
|
||||||
theOSystem->eventHandler().handleEvent(Event::PaddleThreeFire, state);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_JOYAXISMOTION:
|
|
||||||
axis = event.jaxis.axis;
|
|
||||||
value = event.jaxis.value;
|
|
||||||
|
|
||||||
// Send axis events for the joysticks
|
|
||||||
theOSystem->eventHandler().handleEvent(SA_Axis[type-2][axis][0],
|
|
||||||
(value < -16384) ? 1 : 0);
|
|
||||||
theOSystem->eventHandler().handleEvent(SA_Axis[type-2][axis][1],
|
|
||||||
(value > 16384) ? 1 : 0);
|
|
||||||
|
|
||||||
// Send axis events for the paddles
|
|
||||||
resistance = (Int32) (1000000.0 * (32767 - value) / 65534);
|
|
||||||
theOSystem->eventHandler().handleEvent(SA_Axis[type-2][axis][2], resistance);
|
|
||||||
|
|
||||||
// Send events for the driving controllers
|
|
||||||
if(axis == 1)
|
|
||||||
{
|
|
||||||
if(value <= -16384-4096)
|
|
||||||
theOSystem->eventHandler().handleEvent(SA_DrivingValue[type-2],2);
|
|
||||||
else if(value > 16384+4096)
|
|
||||||
theOSystem->eventHandler().handleEvent(SA_DrivingValue[type-2],1);
|
|
||||||
else if(value >= 16384-4096)
|
|
||||||
theOSystem->eventHandler().handleEvent(SA_DrivingValue[type-2],0);
|
|
||||||
else
|
|
||||||
theOSystem->eventHandler().handleEvent(SA_DrivingValue[type-2],3);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break; // Stelladaptor joystick
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Setup the properties set by first checking for a user file,
|
Setup the properties set by first checking for a user file,
|
||||||
then a system-wide file.
|
then a system-wide file.
|
||||||
|
@ -690,6 +178,8 @@ Console* CreateConsole(const string& romfile)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// FIXME - move this into OSystem, so that different systems can make use
|
||||||
|
// of system-specific timers (probably more accurate than SDL can provide)
|
||||||
/**
|
/**
|
||||||
Runs the main game loop until the current game exits.
|
Runs the main game loop until the current game exits.
|
||||||
*/
|
*/
|
||||||
|
@ -717,7 +207,7 @@ void mainGameLoop()
|
||||||
break;
|
break;
|
||||||
|
|
||||||
startTime = GetTicks();
|
startTime = GetTicks();
|
||||||
HandleEvents();
|
theOSystem->eventHandler().poll();
|
||||||
theOSystem->frameBuffer().update();
|
theOSystem->frameBuffer().update();
|
||||||
|
|
||||||
// Now, waste time if we need to so that we are at the desired frame rate
|
// Now, waste time if we need to so that we are at the desired frame rate
|
||||||
|
@ -752,7 +242,7 @@ void mainGameLoop()
|
||||||
break;
|
break;
|
||||||
|
|
||||||
startTime = GetTicks();
|
startTime = GetTicks();
|
||||||
HandleEvents();
|
theOSystem->eventHandler().poll();
|
||||||
theOSystem->frameBuffer().update();
|
theOSystem->frameBuffer().update();
|
||||||
|
|
||||||
currentTime = GetTicks();
|
currentTime = GetTicks();
|
||||||
|
@ -790,6 +280,7 @@ void mainGameLoop()
|
||||||
*/
|
*/
|
||||||
void Cleanup()
|
void Cleanup()
|
||||||
{
|
{
|
||||||
|
/* FIXME
|
||||||
#ifdef JOYSTICK_SUPPORT
|
#ifdef JOYSTICK_SUPPORT
|
||||||
if(SDL_WasInit(SDL_INIT_JOYSTICK) & SDL_INIT_JOYSTICK)
|
if(SDL_WasInit(SDL_INIT_JOYSTICK) & SDL_INIT_JOYSTICK)
|
||||||
{
|
{
|
||||||
|
@ -800,6 +291,7 @@ void Cleanup()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
*/
|
||||||
|
|
||||||
if(theSound)
|
if(theSound)
|
||||||
delete theSound;
|
delete theSound;
|
||||||
|
@ -853,10 +345,7 @@ int main(int argc, char* argv[])
|
||||||
theEventHandler = new EventHandler(theOSystem);
|
theEventHandler = new EventHandler(theOSystem);
|
||||||
|
|
||||||
// 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");
|
|
||||||
theShowInfoFlag = theSettings->getBool("showinfo");
|
theShowInfoFlag = theSettings->getBool("showinfo");
|
||||||
theGrabMouseIndicator = theSettings->getBool("grabmouse");
|
|
||||||
theHideCursorIndicator = theSettings->getBool("hidecursor");
|
|
||||||
bool theRomLauncherFlag = false;//true;//FIXMEtheSettings->getBool("romlauncher");
|
bool theRomLauncherFlag = false;//true;//FIXMEtheSettings->getBool("romlauncher");
|
||||||
|
|
||||||
// Create a properties set for us to use and set it up
|
// Create a properties set for us to use and set it up
|
||||||
|
@ -913,12 +402,14 @@ int main(int argc, char* argv[])
|
||||||
theSound = new Sound(theOSystem);
|
theSound = new Sound(theOSystem);
|
||||||
|
|
||||||
// Setup the SDL joysticks (must be done after FrameBuffer is created)
|
// Setup the SDL joysticks (must be done after FrameBuffer is created)
|
||||||
if(!SetupJoystick())
|
/* FIXME - don't exit if joysticks can't be initialized
|
||||||
|
if(!theOSystem->eventHandler().setupJoystick()) // move this into eventhandler
|
||||||
{
|
{
|
||||||
cerr << "ERROR: Couldn't set up joysticks.\n";
|
cerr << "ERROR: Couldn't set up joysticks.\n";
|
||||||
Cleanup();
|
Cleanup();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// Print message about the framerate
|
// Print message about the framerate
|
||||||
ostringstream message;
|
ostringstream message;
|
||||||
|
|
|
@ -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: EventHandler.cxx,v 1.39 2005-03-28 00:04:53 stephena Exp $
|
// $Id: EventHandler.cxx,v 1.40 2005-04-03 19:37:32 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
@ -42,7 +42,9 @@ EventHandler::EventHandler(OSystem* osystem)
|
||||||
myLSState(0),
|
myLSState(0),
|
||||||
myPauseFlag(false),
|
myPauseFlag(false),
|
||||||
myExitGameFlag(false),
|
myExitGameFlag(false),
|
||||||
myQuitFlag(false)
|
myQuitFlag(false),
|
||||||
|
myGrabMouseFlag(false),
|
||||||
|
myPaddleMode(0)
|
||||||
{
|
{
|
||||||
// Add this eventhandler object to the OSystem
|
// Add this eventhandler object to the OSystem
|
||||||
myOSystem->attach(this);
|
myOSystem->attach(this);
|
||||||
|
@ -76,6 +78,8 @@ EventHandler::EventHandler(OSystem* osystem)
|
||||||
|
|
||||||
setKeymap();
|
setKeymap();
|
||||||
setJoymap();
|
setJoymap();
|
||||||
|
|
||||||
|
myGrabMouseFlag = myOSystem->settings().getBool("grabmouse");
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -99,6 +103,105 @@ void EventHandler::reset(State state)
|
||||||
myPauseFlag = false;
|
myPauseFlag = false;
|
||||||
myExitGameFlag = false;
|
myExitGameFlag = false;
|
||||||
myQuitFlag = false;
|
myQuitFlag = false;
|
||||||
|
myPaddleMode = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
void EventHandler::poll() // FIXME - add modifiers for OSX
|
||||||
|
{
|
||||||
|
SDL_Event event;
|
||||||
|
|
||||||
|
// Check for an event
|
||||||
|
while(SDL_PollEvent(&event))
|
||||||
|
{
|
||||||
|
switch(event.type)
|
||||||
|
{
|
||||||
|
// keyboard events
|
||||||
|
case SDL_KEYUP:
|
||||||
|
case SDL_KEYDOWN:
|
||||||
|
{
|
||||||
|
SDLKey key = event.key.keysym.sym;
|
||||||
|
SDLMod mod = event.key.keysym.mod;
|
||||||
|
uInt8 state = event.key.type == SDL_KEYDOWN ? 1 : 0;
|
||||||
|
|
||||||
|
// An attempt to speed up event processing
|
||||||
|
// All SDL-specific event actions are accessed by either
|
||||||
|
// Control or Alt keys. So we quickly check for those.
|
||||||
|
if(mod & KMOD_ALT && state)
|
||||||
|
{
|
||||||
|
switch(int(key))
|
||||||
|
{
|
||||||
|
case SDLK_EQUALS:
|
||||||
|
myOSystem->frameBuffer().resize(1);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SDLK_MINUS:
|
||||||
|
myOSystem->frameBuffer().resize(-1);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SDLK_RETURN:
|
||||||
|
myOSystem->frameBuffer().toggleFullscreen();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SDLK_f:
|
||||||
|
myOSystem->frameBuffer().toggleFilter();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(mod & KMOD_CTRL && state)
|
||||||
|
{
|
||||||
|
switch(int(key))
|
||||||
|
{
|
||||||
|
case SDLK_q:
|
||||||
|
handleEvent(Event::Quit, 1);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SDLK_g:
|
||||||
|
// don't change grabmouse in fullscreen mode
|
||||||
|
if(!myOSystem->frameBuffer().fullScreen())
|
||||||
|
{
|
||||||
|
myGrabMouseFlag = !myGrabMouseFlag;
|
||||||
|
myOSystem->settings().setBool("grabmouse", myGrabMouseFlag);
|
||||||
|
myOSystem->frameBuffer().grabMouse(myGrabMouseFlag);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Otherwise, let the event handler deal with it
|
||||||
|
handleKeyEvent(key, mod, state);
|
||||||
|
break; // SDL_KEYUP, SDL_KEYDOWN
|
||||||
|
}
|
||||||
|
|
||||||
|
case SDL_MOUSEMOTION:
|
||||||
|
handleMouseMotionEvent(event);
|
||||||
|
break; // SDL_MOUSEMOTION
|
||||||
|
|
||||||
|
case SDL_MOUSEBUTTONUP:
|
||||||
|
case SDL_MOUSEBUTTONDOWN:
|
||||||
|
{
|
||||||
|
uInt8 state = event.button.type == SDL_MOUSEBUTTONDOWN ? 1 : 0;
|
||||||
|
handleMouseButtonEvent(event, state);
|
||||||
|
break; // SDL_MOUSEBUTTONUP, SDL_MOUSEBUTTONDOWN
|
||||||
|
}
|
||||||
|
|
||||||
|
case SDL_ACTIVEEVENT:
|
||||||
|
if((event.active.state & SDL_APPACTIVE) && (event.active.gain == 0))
|
||||||
|
if(!myPauseFlag)
|
||||||
|
handleEvent(Event::Pause, 1);
|
||||||
|
break; // SDL_ACTIVEEVENT
|
||||||
|
|
||||||
|
case SDL_QUIT:
|
||||||
|
handleEvent(Event::Quit, 1);
|
||||||
|
break; // SDL_QUIT
|
||||||
|
|
||||||
|
case SDL_VIDEOEXPOSE:
|
||||||
|
myOSystem->frameBuffer().refresh();
|
||||||
|
break; // SDL_VIDEOEXPOSE
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIXME - joystick stuff goes here
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -107,7 +210,7 @@ void EventHandler::handleKeyEvent(SDLKey key, SDLMod mod, uInt8 state)
|
||||||
// Handle keys here that are accessible no matter which mode we're in
|
// Handle keys here that are accessible no matter which mode we're in
|
||||||
|
|
||||||
// Toggle menu mode
|
// Toggle menu mode
|
||||||
if(key == SDLK_TAB && state == 1 && !myPauseFlag)
|
if(key == SDLK_TAB && state == 1 && !myPauseFlag) // FIXME - add remappable 'enter menu mode key here'
|
||||||
{
|
{
|
||||||
if(myState == S_EMULATE)
|
if(myState == S_EMULATE)
|
||||||
{
|
{
|
||||||
|
@ -132,14 +235,73 @@ void EventHandler::handleKeyEvent(SDLKey key, SDLMod mod, uInt8 state)
|
||||||
switch(myState)
|
switch(myState)
|
||||||
{
|
{
|
||||||
case S_EMULATE:
|
case S_EMULATE:
|
||||||
// if(mod & KMOD_ALT && state)
|
// An attempt to speed up event processing
|
||||||
// handleEvent(myAltKeyTable[key], state);
|
// All SDL-specific event actions are accessed by either
|
||||||
// else if(mod & KMOD_CTRL && state)
|
// Control or Alt keys. So we quickly check for those.
|
||||||
// handleEvent(myCtrlKeyTable[key], state);
|
if(mod & KMOD_ALT && state)
|
||||||
// else
|
{
|
||||||
handleEvent(myKeyTable[key], state);
|
switch(int(key))
|
||||||
|
{
|
||||||
|
case SDLK_LEFTBRACKET:
|
||||||
|
myOSystem->sound().adjustVolume(-1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case SDLK_RIGHTBRACKET:
|
||||||
|
myOSystem->sound().adjustVolume(1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// FIXME - alt developer stuff goes here
|
||||||
|
}
|
||||||
|
else if(mod & KMOD_CTRL && state)
|
||||||
|
{
|
||||||
|
switch(int(key))
|
||||||
|
{
|
||||||
|
case SDLK_0: // Ctrl-0 sets the mouse to paddle 0
|
||||||
|
setPaddleMode(0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SDLK_1: // Ctrl-1 sets the mouse to paddle 1
|
||||||
|
setPaddleMode(1);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SDLK_2: // Ctrl-2 sets the mouse to paddle 2
|
||||||
|
setPaddleMode(2);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SDLK_3: // Ctrl-3 sets the mouse to paddle 3
|
||||||
|
setPaddleMode(3);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SDLK_f: // Ctrl-f toggles NTSC/PAL mode
|
||||||
|
myOSystem->console().toggleFormat();
|
||||||
|
myOSystem->frameBuffer().setupPalette();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SDLK_p: // Ctrl-p toggles different palettes
|
||||||
|
myOSystem->console().togglePalette();
|
||||||
|
myOSystem->frameBuffer().setupPalette();
|
||||||
|
break;
|
||||||
|
|
||||||
|
// FIXME - Ctrl developer support goes here
|
||||||
|
|
||||||
|
case SDLK_s: // Ctrl-s saves properties to a file
|
||||||
|
// Attempt to merge with propertiesSet
|
||||||
|
if(myOSystem->settings().getBool("mergeprops"))
|
||||||
|
myOSystem->console().saveProperties(myOSystem->propertiesOutputFilename(), true);
|
||||||
|
else // Save to file in base directory
|
||||||
|
{
|
||||||
|
string newPropertiesFile = myOSystem->baseDir() + "/" + \
|
||||||
|
myOSystem->console().properties().get("Cartridge.Name") + ".pro";
|
||||||
|
myOSystem->console().saveProperties(newPropertiesFile);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
handleEvent(myKeyTable[key], state);
|
||||||
|
|
||||||
|
break; // S_EMULATE
|
||||||
|
|
||||||
case S_MENU:
|
case S_MENU:
|
||||||
myOSystem->menu().handleKeyEvent(key, mod, state);
|
myOSystem->menu().handleKeyEvent(key, mod, state);
|
||||||
break;
|
break;
|
||||||
|
@ -483,6 +645,12 @@ void EventHandler::setDefaultKeymap()
|
||||||
#ifndef MAC_OSX
|
#ifndef MAC_OSX
|
||||||
myKeyTable[ SDLK_ESCAPE ] = Event::ExitGame;
|
myKeyTable[ SDLK_ESCAPE ] = Event::ExitGame;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Iterate through the keymap table and create a colon-separated list
|
||||||
|
ostringstream keybuf;
|
||||||
|
for(uInt32 i = 0; i < 256; ++i)
|
||||||
|
keybuf << myKeyTable[i] << ":";
|
||||||
|
myOSystem->settings().setString("keymap", keybuf.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -621,3 +789,15 @@ void EventHandler::takeSnapshot()
|
||||||
myOSystem->frameBuffer().showMessage("Snapshots unsupported");
|
myOSystem->frameBuffer().showMessage("Snapshots unsupported");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
void EventHandler::setPaddleMode(Int8 num)
|
||||||
|
{
|
||||||
|
myPaddleMode = num;
|
||||||
|
|
||||||
|
ostringstream buf;
|
||||||
|
buf << "Mouse is paddle " << num;
|
||||||
|
myOSystem->frameBuffer().showMessage(buf.str());
|
||||||
|
|
||||||
|
myOSystem->settings().setInt("paddle", myPaddleMode);
|
||||||
|
}
|
||||||
|
|
|
@ -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: EventHandler.hxx,v 1.19 2005-03-14 04:08:14 stephena Exp $
|
// $Id: EventHandler.hxx,v 1.20 2005-04-03 19:37:32 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#ifndef EVENTHANDLER_HXX
|
#ifndef EVENTHANDLER_HXX
|
||||||
|
@ -50,7 +50,7 @@ enum MouseButton {
|
||||||
mapping can take place.
|
mapping can take place.
|
||||||
|
|
||||||
@author Stephen Anthony
|
@author Stephen Anthony
|
||||||
@version $Id: EventHandler.hxx,v 1.19 2005-03-14 04:08:14 stephena Exp $
|
@version $Id: EventHandler.hxx,v 1.20 2005-04-03 19:37:32 stephena Exp $
|
||||||
*/
|
*/
|
||||||
class EventHandler
|
class EventHandler
|
||||||
{
|
{
|
||||||
|
@ -75,6 +75,12 @@ class EventHandler
|
||||||
*/
|
*/
|
||||||
Event* event();
|
Event* event();
|
||||||
|
|
||||||
|
/**
|
||||||
|
Collects and dispatches any pending events. This method should be
|
||||||
|
called regularly (at X times per second, where X is the game framerate).
|
||||||
|
*/
|
||||||
|
void poll();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Returns the current state of the EventHandler
|
Returns the current state of the EventHandler
|
||||||
|
|
||||||
|
@ -89,6 +95,26 @@ class EventHandler
|
||||||
*/
|
*/
|
||||||
void reset(State state);
|
void reset(State state);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
This method indicates whether a pause event has been received.
|
||||||
|
*/
|
||||||
|
inline bool doPause() { return myPauseFlag; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
This method indicates whether a exit game event has been received.
|
||||||
|
*/
|
||||||
|
inline bool doExitGame() { return myExitGameFlag; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
This method indicates whether a quit event has been received.
|
||||||
|
*/
|
||||||
|
inline bool doQuit() { return myQuitFlag; }
|
||||||
|
|
||||||
|
void getKeymapArray(Event::Type** array, uInt32* size);
|
||||||
|
void getJoymapArray(Event::Type** array, uInt32* size);
|
||||||
|
|
||||||
|
private:
|
||||||
/**
|
/**
|
||||||
Send an event directly to the event handler.
|
Send an event directly to the event handler.
|
||||||
These events cannot be remapped.
|
These events cannot be remapped.
|
||||||
|
@ -132,24 +158,12 @@ class EventHandler
|
||||||
Int32 state);
|
Int32 state);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This method indicates whether a pause event has been received.
|
Sets the mouse to act as paddle 'which'
|
||||||
|
|
||||||
|
@param which The paddle which the mouse should emulate
|
||||||
*/
|
*/
|
||||||
inline bool doPause() { return myPauseFlag; }
|
void setPaddleMode(Int8 which);
|
||||||
|
|
||||||
/**
|
|
||||||
This method indicates whether a exit game event has been received.
|
|
||||||
*/
|
|
||||||
inline bool doExitGame() { return myExitGameFlag; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
This method indicates whether a quit event has been received.
|
|
||||||
*/
|
|
||||||
inline bool doQuit() { return myQuitFlag; }
|
|
||||||
|
|
||||||
void getKeymapArray(Event::Type** array, uInt32* size);
|
|
||||||
void getJoymapArray(Event::Type** array, uInt32* size);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void setKeymap();
|
void setKeymap();
|
||||||
void setJoymap();
|
void setJoymap();
|
||||||
void setDefaultKeymap();
|
void setDefaultKeymap();
|
||||||
|
@ -199,6 +213,12 @@ class EventHandler
|
||||||
// Indicates whether to quit the emulator
|
// Indicates whether to quit the emulator
|
||||||
bool myQuitFlag;
|
bool myQuitFlag;
|
||||||
|
|
||||||
|
// Indicates whether the mouse cursor is grabbed
|
||||||
|
bool myGrabMouseFlag;
|
||||||
|
|
||||||
|
// Indicates which paddle the mouse currently emulates
|
||||||
|
Int8 myPaddleMode;
|
||||||
|
|
||||||
// The current keymap in string form
|
// The current keymap in string form
|
||||||
string myKeymapString;
|
string myKeymapString;
|
||||||
|
|
||||||
|
|
|
@ -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: FrameBuffer.hxx,v 1.23 2005-03-28 00:04:54 stephena Exp $
|
// $Id: FrameBuffer.hxx,v 1.24 2005-04-03 19:37:32 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#ifndef FRAMEBUFFER_HXX
|
#ifndef FRAMEBUFFER_HXX
|
||||||
|
@ -41,7 +41,7 @@ class OSystem;
|
||||||
All GUI elements (ala ScummVM) are drawn here as well.
|
All GUI elements (ala ScummVM) are drawn here as well.
|
||||||
|
|
||||||
@author Stephen Anthony
|
@author Stephen Anthony
|
||||||
@version $Id: FrameBuffer.hxx,v 1.23 2005-03-28 00:04:54 stephena Exp $
|
@version $Id: FrameBuffer.hxx,v 1.24 2005-04-03 19:37:32 stephena Exp $
|
||||||
*/
|
*/
|
||||||
class FrameBuffer
|
class FrameBuffer
|
||||||
{
|
{
|
||||||
|
@ -106,7 +106,7 @@ class FrameBuffer
|
||||||
|
|
||||||
@return The current width
|
@return The current width
|
||||||
*/
|
*/
|
||||||
// inline const uInt32 imageWidth() { return myImageDim.w; }
|
inline const uInt32 imageWidth() { return myImageDim.w; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Returns the current height of the framebuffer image.
|
Returns the current height of the framebuffer image.
|
||||||
|
@ -114,7 +114,7 @@ class FrameBuffer
|
||||||
|
|
||||||
@return The current height
|
@return The current height
|
||||||
*/
|
*/
|
||||||
// inline const uInt32 imageHeight() { return myImageDim.h; }
|
inline const uInt32 imageHeight() { return myImageDim.h; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Sets the pause status. While pause is selected, the
|
Sets the pause status. While pause is selected, the
|
||||||
|
|
Loading…
Reference in New Issue