mirror of https://github.com/stella-emu/stella.git
Fixed event mapping of analog events to different input types; the only
supported input type is joystick axes. It doesn't really make sense to assign analog events to hats/buttons/keys, since they're not analog in nature. Reworked the MediaFactory/FrameBuffer classes so that we always get a valid FrameBuffer object. So no more crashes because of NULL FrameBuffer pointers. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@971 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
a245adcc12
commit
02bc6ed0cf
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: FrameBufferGL.hxx,v 1.29 2006-01-15 16:31:00 stephena Exp $
|
||||
// $Id: FrameBufferGL.hxx,v 1.30 2006-01-19 00:45:12 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef FRAMEBUFFER_GL_HXX
|
||||
|
@ -37,7 +37,7 @@ class GUI::Font;
|
|||
This class implements an SDL OpenGL framebuffer.
|
||||
|
||||
@author Stephen Anthony
|
||||
@version $Id: FrameBufferGL.hxx,v 1.29 2006-01-15 16:31:00 stephena Exp $
|
||||
@version $Id: FrameBufferGL.hxx,v 1.30 2006-01-19 00:45:12 stephena Exp $
|
||||
*/
|
||||
class FrameBufferGL : public FrameBuffer
|
||||
{
|
||||
|
@ -70,6 +70,11 @@ class FrameBufferGL : public FrameBuffer
|
|||
*/
|
||||
virtual bool initSubsystem();
|
||||
|
||||
/**
|
||||
This method is called to query the type of the FrameBuffer.
|
||||
*/
|
||||
virtual BufferType type() { return kGLBuffer; }
|
||||
|
||||
/**
|
||||
This method is called to set the aspect ratio of the screen.
|
||||
*/
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: FrameBufferSoft.hxx,v 1.30 2006-01-15 22:43:21 stephena Exp $
|
||||
// $Id: FrameBufferSoft.hxx,v 1.31 2006-01-19 00:45:12 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef FRAMEBUFFER_SOFT_HXX
|
||||
|
@ -35,7 +35,7 @@ class RectList;
|
|||
This class implements an SDL software framebuffer.
|
||||
|
||||
@author Stephen Anthony
|
||||
@version $Id: FrameBufferSoft.hxx,v 1.30 2006-01-15 22:43:21 stephena Exp $
|
||||
@version $Id: FrameBufferSoft.hxx,v 1.31 2006-01-19 00:45:12 stephena Exp $
|
||||
*/
|
||||
class FrameBufferSoft : public FrameBuffer
|
||||
{
|
||||
|
@ -59,6 +59,11 @@ class FrameBufferSoft : public FrameBuffer
|
|||
*/
|
||||
virtual bool initSubsystem();
|
||||
|
||||
/**
|
||||
This method is called to query the type of the FrameBuffer.
|
||||
*/
|
||||
virtual BufferType type() { return kSoftBuffer; }
|
||||
|
||||
/**
|
||||
This method is called to set the aspect ratio of the screen.
|
||||
*/
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: EventHandler.cxx,v 1.147 2006-01-18 20:43:22 stephena Exp $
|
||||
// $Id: EventHandler.cxx,v 1.148 2006-01-19 00:45:12 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <sstream>
|
||||
|
@ -178,7 +178,7 @@ void EventHandler::reset(State state)
|
|||
setPaddleSpeed(2, myOSystem->settings().getInt("p3speed"));
|
||||
setPaddleSpeed(3, myOSystem->settings().getInt("p4speed"));
|
||||
|
||||
myEventStreamer->reset();
|
||||
// myEventStreamer->reset();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -343,9 +343,9 @@ void EventHandler::poll(uInt32 time)
|
|||
{
|
||||
// Check if we have an event from the eventstreamer
|
||||
// TODO - should we lock out input from the user while getting synthetic events?
|
||||
int type, value;
|
||||
while(myEventStreamer->pollEvent(type, value))
|
||||
myEvent->set((Event::Type)type, value);
|
||||
// int type, value;
|
||||
// while(myEventStreamer->pollEvent(type, value))
|
||||
// myEvent->set((Event::Type)type, value);
|
||||
|
||||
// Check for an event
|
||||
SDL_Event event;
|
||||
|
@ -457,6 +457,7 @@ void EventHandler::poll(uInt32 time)
|
|||
myOSystem->console().togglePhosphor();
|
||||
break;
|
||||
|
||||
#if 0
|
||||
// FIXME - these will be removed when a UI is added for event recording
|
||||
case SDLK_e: // Alt-e starts/stops event recording
|
||||
if(myEventStreamer->isRecording())
|
||||
|
@ -484,6 +485,7 @@ void EventHandler::poll(uInt32 time)
|
|||
return;
|
||||
break;
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -845,7 +847,7 @@ void EventHandler::poll(uInt32 time)
|
|||
|
||||
// Tell the eventstreamer that another frame has finished
|
||||
// This is used for event recording
|
||||
myEventStreamer->nextFrame();
|
||||
// myEventStreamer->nextFrame();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: FrameBuffer.hxx,v 1.64 2006-01-15 16:31:01 stephena Exp $
|
||||
// $Id: FrameBuffer.hxx,v 1.65 2006-01-19 00:45:12 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef FRAMEBUFFER_HXX
|
||||
|
@ -43,6 +43,12 @@ enum FrameStyle {
|
|||
kDashLine
|
||||
};
|
||||
|
||||
// Different types of framebuffer derived objects
|
||||
enum BufferType {
|
||||
kSoftBuffer,
|
||||
kGLBuffer
|
||||
};
|
||||
|
||||
/**
|
||||
This class encapsulates the MediaSource and is the basis for the video
|
||||
display in Stella. All graphics ports should derive from this class for
|
||||
|
@ -51,7 +57,7 @@ enum FrameStyle {
|
|||
All GUI elements (ala ScummVM) are drawn here as well.
|
||||
|
||||
@author Stephen Anthony
|
||||
@version $Id: FrameBuffer.hxx,v 1.64 2006-01-15 16:31:01 stephena Exp $
|
||||
@version $Id: FrameBuffer.hxx,v 1.65 2006-01-19 00:45:12 stephena Exp $
|
||||
*/
|
||||
class FrameBuffer
|
||||
{
|
||||
|
@ -193,7 +199,7 @@ class FrameBuffer
|
|||
Calculate the maximum window size that the current screen can hold.
|
||||
If not supported by platform, always return 4.
|
||||
*/
|
||||
uInt32 maxWindowSizeForScreen();
|
||||
virtual uInt32 maxWindowSizeForScreen();
|
||||
|
||||
/**
|
||||
Returns current zoomlevel of the framebuffer.
|
||||
|
@ -268,6 +274,11 @@ class FrameBuffer
|
|||
*/
|
||||
virtual bool initSubsystem() = 0;
|
||||
|
||||
/**
|
||||
This method is called to query the type of the FrameBuffer.
|
||||
*/
|
||||
virtual BufferType type() = 0;
|
||||
|
||||
/**
|
||||
This method is called to set the aspect ratio of the screen.
|
||||
*/
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: MediaFactory.cxx,v 1.2 2006-01-14 21:36:29 stephena Exp $
|
||||
// $Id: MediaFactory.cxx,v 1.3 2006-01-19 00:45:12 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
@ -47,43 +47,63 @@
|
|||
#endif
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
FrameBuffer* MediaFactory::createVideo(const string& type, OSystem* parent)
|
||||
FrameBuffer* MediaFactory::createVideo(OSystem* osystem)
|
||||
{
|
||||
FrameBuffer* fb = (FrameBuffer*) NULL;
|
||||
const string& type = osystem->settings().getString("video");
|
||||
|
||||
if(type == "soft")
|
||||
#if defined (PSP)
|
||||
fb = new FrameBufferPSP(parent);
|
||||
#elif defined (_WIN32_WCE)
|
||||
fb = new FrameBufferWinCE(parent);
|
||||
#else
|
||||
fb = new FrameBufferSoft(parent);
|
||||
#endif
|
||||
// OpenGL mode *may* fail, so we check for it first
|
||||
#ifdef DISPLAY_OPENGL
|
||||
else if(type == "gl")
|
||||
if(type == "gl")
|
||||
{
|
||||
const string& gl_lib = parent->settings().getString("gl_lib");
|
||||
const string& gl_lib = osystem->settings().getString("gl_lib");
|
||||
if(FrameBufferGL::loadFuncs(gl_lib))
|
||||
fb = new FrameBufferGL(parent);
|
||||
fb = new FrameBufferGL(osystem);
|
||||
}
|
||||
#endif
|
||||
|
||||
// If OpenGL failed, or if it wasn't requested, create the appropriate
|
||||
// software framebuffer
|
||||
if(!fb)
|
||||
{
|
||||
#if defined (PSP)
|
||||
fb = new FrameBufferPSP(osystem);
|
||||
#elif defined (_WIN32_WCE)
|
||||
fb = new FrameBufferWinCE(osystem);
|
||||
#else
|
||||
fb = new FrameBufferSoft(osystem);
|
||||
#endif
|
||||
}
|
||||
|
||||
// This should never happen
|
||||
assert(fb != NULL);
|
||||
switch(fb->type())
|
||||
{
|
||||
case kSoftBuffer:
|
||||
osystem->settings().setString("video", "soft");
|
||||
break;
|
||||
|
||||
case kGLBuffer:
|
||||
osystem->settings().setString("video", "gl");
|
||||
break;
|
||||
}
|
||||
|
||||
return fb;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Sound* MediaFactory::createAudio(const string& type, OSystem* parent)
|
||||
Sound* MediaFactory::createAudio(OSystem* osystem)
|
||||
{
|
||||
Sound* sound = (Sound*) NULL;
|
||||
|
||||
#ifdef SOUND_SUPPORT
|
||||
#if defined (_WIN32_WCE)
|
||||
sound = new SoundWinCE(parent);
|
||||
sound = new SoundWinCE(osystem);
|
||||
#else
|
||||
sound = new SoundSDL(parent);
|
||||
sound = new SoundSDL(osystem);
|
||||
#endif
|
||||
#else
|
||||
sound = new SoundNull(parent);
|
||||
sound = new SoundNull(osystem);
|
||||
#endif
|
||||
|
||||
return sound;
|
||||
|
|
|
@ -13,14 +13,12 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: MediaFactory.hxx,v 1.1 2005-12-18 18:37:03 stephena Exp $
|
||||
// $Id: MediaFactory.hxx,v 1.2 2006-01-19 00:45:12 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef MEDIA_FACTORY_HXX
|
||||
#define MEDIA_FACTORY_HXX
|
||||
|
||||
#include "bspf.hxx"
|
||||
|
||||
class FrameBuffer;
|
||||
class Sound;
|
||||
class OSystem;
|
||||
|
@ -31,13 +29,13 @@ class OSystem;
|
|||
based on the specific port and restrictions on that port.
|
||||
|
||||
@author Stephen Anthony
|
||||
@version $Id: MediaFactory.hxx,v 1.1 2005-12-18 18:37:03 stephena Exp $
|
||||
@version $Id: MediaFactory.hxx,v 1.2 2006-01-19 00:45:12 stephena Exp $
|
||||
*/
|
||||
class MediaFactory
|
||||
{
|
||||
public:
|
||||
static FrameBuffer* createVideo(const string& type, OSystem* parent);
|
||||
static Sound* createAudio(const string& type, OSystem* parent);
|
||||
static FrameBuffer* createVideo(OSystem* osystem);
|
||||
static Sound* createAudio(OSystem* osystem);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: OSystem.cxx,v 1.57 2006-01-14 21:36:29 stephena Exp $
|
||||
// $Id: OSystem.cxx,v 1.58 2006-01-19 00:45:12 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <cassert>
|
||||
|
@ -187,13 +187,9 @@ bool OSystem::createFrameBuffer(bool showmessage)
|
|||
// Delete the old framebuffer
|
||||
delete myFrameBuffer; myFrameBuffer = NULL;
|
||||
|
||||
// And recreate a new one
|
||||
string video = mySettings->getString("video");
|
||||
myFrameBuffer = MediaFactory::createVideo(video, this);
|
||||
if(!myFrameBuffer)
|
||||
{cerr << "FIXME - properly deal with video mode not existing\n";
|
||||
return false;
|
||||
}
|
||||
// And recreate a new one (we'll always get a valid pointer)
|
||||
myFrameBuffer = MediaFactory::createVideo(this);
|
||||
|
||||
// Re-initialize the framebuffer to current settings
|
||||
switch(myEventHandler->state())
|
||||
{
|
||||
|
@ -203,14 +199,15 @@ bool OSystem::createFrameBuffer(bool showmessage)
|
|||
myConsole->initializeVideo();
|
||||
if(showmessage)
|
||||
{
|
||||
if(video == "soft")
|
||||
myFrameBuffer->showMessage("Software mode");
|
||||
#ifdef DISPLAY_OPENGL
|
||||
else if(video == "gl")
|
||||
myFrameBuffer->showMessage("OpenGL mode");
|
||||
#endif
|
||||
else // a driver that doesn't exist was requested, so use software mode
|
||||
myFrameBuffer->showMessage("Software mode");
|
||||
switch(myFrameBuffer->type())
|
||||
{
|
||||
case kSoftBuffer:
|
||||
myFrameBuffer->showMessage("Software mode");
|
||||
break;
|
||||
case kGLBuffer:
|
||||
myFrameBuffer->showMessage("OpenGL mode");
|
||||
break;
|
||||
}
|
||||
}
|
||||
break; // S_EMULATE, S_MENU, S_CMDMENU
|
||||
|
||||
|
@ -234,6 +231,7 @@ bool OSystem::createFrameBuffer(bool showmessage)
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void OSystem::toggleFrameBuffer()
|
||||
{
|
||||
#ifdef DISPLAY_OPENGL
|
||||
// First figure out which mode to switch to
|
||||
string video = mySettings->getString("video");
|
||||
if(video == "soft")
|
||||
|
@ -246,6 +244,7 @@ void OSystem::toggleFrameBuffer()
|
|||
// Update the settings and create the framebuffer
|
||||
mySettings->setString("video", video);
|
||||
createFrameBuffer(true); // show onscreen message
|
||||
#endif
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -255,7 +254,7 @@ void OSystem::createSound()
|
|||
delete mySound; mySound = NULL;
|
||||
|
||||
// And recreate a new sound device
|
||||
mySound = MediaFactory::createAudio("", this);
|
||||
mySound = MediaFactory::createAudio(this);
|
||||
#ifndef SOUND_SUPPORT
|
||||
mySettings->setBool("sound", false);
|
||||
#endif
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: EventMappingWidget.cxx,v 1.10 2006-01-15 20:46:20 stephena Exp $
|
||||
// $Id: EventMappingWidget.cxx,v 1.11 2006-01-19 00:45:13 stephena Exp $
|
||||
//
|
||||
// Based on code from ScummVM - Scumm Interpreter
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
|
@ -192,9 +192,8 @@ bool EventMappingWidget::handleKeyDown(int ascii, int keycode, int modifiers)
|
|||
if(myRemapStatus && myActionSelected >= 0)
|
||||
{
|
||||
Event::Type event = EventHandler::ourActionList[ myActionSelected ].event;
|
||||
instance()->eventHandler().addKeyMapping(event, keycode);
|
||||
|
||||
stopRemapping();
|
||||
if(instance()->eventHandler().addKeyMapping(event, keycode))
|
||||
stopRemapping();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -206,9 +205,8 @@ void EventMappingWidget::handleJoyDown(int stick, int button)
|
|||
if(myRemapStatus && myActionSelected >= 0)
|
||||
{
|
||||
Event::Type event = EventHandler::ourActionList[ myActionSelected ].event;
|
||||
instance()->eventHandler().addJoyMapping(event, stick, button);
|
||||
|
||||
stopRemapping();
|
||||
if(instance()->eventHandler().addJoyMapping(event, stick, button))
|
||||
stopRemapping();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -219,9 +217,8 @@ void EventMappingWidget::handleJoyAxis(int stick, int axis, int value)
|
|||
if(myRemapStatus && myActionSelected >= 0)
|
||||
{
|
||||
Event::Type event = EventHandler::ourActionList[ myActionSelected ].event;
|
||||
instance()->eventHandler().addJoyAxisMapping(event, stick, axis, value);
|
||||
|
||||
stopRemapping();
|
||||
if(instance()->eventHandler().addJoyAxisMapping(event, stick, axis, value))
|
||||
stopRemapping();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -232,9 +229,8 @@ void EventMappingWidget::handleJoyHat(int stick, int hat, int value)
|
|||
if(myRemapStatus && myActionSelected >= 0)
|
||||
{
|
||||
Event::Type event = EventHandler::ourActionList[ myActionSelected ].event;
|
||||
instance()->eventHandler().addJoyHatMapping(event, stick, hat, value);
|
||||
|
||||
stopRemapping();
|
||||
if(instance()->eventHandler().addJoyHatMapping(event, stick, hat, value))
|
||||
stopRemapping();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: FrameBufferPSP.hxx,v 1.1 2005-09-18 14:35:59 optixx Exp $
|
||||
// $Id: FrameBufferPSP.hxx,v 1.2 2006-01-19 00:45:13 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef FRAMEBUFFER_PSP_HXX
|
||||
|
@ -31,7 +31,7 @@
|
|||
This class implements an SDL software framebuffer.
|
||||
|
||||
@author Stephen Anthony
|
||||
@version $Id: FrameBufferPSP.hxx,v 1.1 2005-09-18 14:35:59 optixx Exp $
|
||||
@version $Id: FrameBufferPSP.hxx,v 1.2 2006-01-19 00:45:13 stephena Exp $
|
||||
*/
|
||||
class FrameBufferPSP : public FrameBufferSoft
|
||||
{
|
||||
|
@ -55,6 +55,11 @@ class FrameBufferPSP : public FrameBufferSoft
|
|||
*/
|
||||
virtual bool initSubsystem();
|
||||
|
||||
/**
|
||||
This method is called to query the type of the FrameBuffer.
|
||||
*/
|
||||
virtual BufferType type() { return kSoftBuffer; }
|
||||
|
||||
/**
|
||||
This method is called whenever the screen needs to be recreated.
|
||||
It updates the global screen variable.
|
||||
|
|
|
@ -32,6 +32,7 @@ class FrameBufferWinCE : public FrameBuffer
|
|||
~FrameBufferWinCE();
|
||||
virtual void setPalette(const uInt32* palette);
|
||||
virtual bool initSubsystem();
|
||||
virtual BufferType type() { return kSoftBuffer; }
|
||||
virtual void setAspectRatio() ;
|
||||
virtual bool createScreen();
|
||||
virtual void toggleFilter();
|
||||
|
@ -76,4 +77,4 @@ class FrameBufferWinCE : public FrameBuffer
|
|||
uInt8 getmode(void) { return displaymode; }
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue