Finally, we have CVS access back!!

Finalized remapping of GUI/menu events, and added an interface to change
these mappings from 'Input Settings'.

Fixed bug with taking snapshots having a previously overlaid message
being part of the image.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1102 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2006-05-15 12:24:09 +00:00
parent ebf39cb52d
commit 893716abcd
8 changed files with 477 additions and 352 deletions

View File

@ -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: Event.hxx,v 1.20 2006-05-04 17:45:24 stephena Exp $
// $Id: Event.hxx,v 1.21 2006-05-15 12:24:09 stephena Exp $
//============================================================================
#ifndef EVENT_HXX
@ -26,7 +26,7 @@ class EventStreamer;
/**
@author Bradford W. Mott
@version $Id: Event.hxx,v 1.20 2006-05-04 17:45:24 stephena Exp $
@version $Id: Event.hxx,v 1.21 2006-05-15 12:24:09 stephena Exp $
*/
class Event
{
@ -81,7 +81,7 @@ class Event
VolumeDecrease, VolumeIncrease,
UIUp, UIDown, UILeft, UIRight, UIHome, UIEnd, UIPgUp, UIPgDown,
UIPrevDir, UINavNext, UINavPrev, UITabNext, UITabPrev, UISelect,
UISelect, UIPrevDir, UINavPrev, UINavNext, UITabPrev, UITabNext,
LastType
};

File diff suppressed because it is too large Load Diff

View File

@ -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.hxx,v 1.87 2006-05-05 18:00:51 stephena Exp $
// $Id: EventHandler.hxx,v 1.88 2006-05-15 12:24:09 stephena Exp $
//============================================================================
#ifndef EVENTHANDLER_HXX
@ -61,12 +61,14 @@ struct ActionList {
};
enum {
kActionListSize = 81
kEmulActionListSize = 81,
kMenuActionListSize = 14
};
enum EventMode {
kEmulationMode,
kMenuMode
kEmulationMode = 0, // make sure these are set correctly,
kMenuMode = 1, // since they'll be used as array indices
kNumModes = 2
};
// Joystick related items
@ -112,12 +114,10 @@ struct JoyMouse {
mapping can take place.
@author Stephen Anthony
@version $Id: EventHandler.hxx,v 1.87 2006-05-05 18:00:51 stephena Exp $
@version $Id: EventHandler.hxx,v 1.88 2006-05-15 12:24:09 stephena Exp $
*/
class EventHandler
{
friend class EventMappingWidget;
public:
/**
Create a new event handler object
@ -166,30 +166,36 @@ class EventHandler
Set the default action for a joystick button to the given event
@param event The event we are assigning
@param mode The mode where this event is active
@param stick The joystick number
@param button The joystick button
*/
void setDefaultJoyMapping(Event::Type event, int stick, int button);
void setDefaultJoyMapping(Event::Type event, EventMode mode,
int stick, int button);
/**
Set the default for a joystick axis to the given event
@param event The event we are assigning
@param mode The mode where this event is active
@param stick The joystick number
@param axis The joystick axis
@param value The value on the given axis
*/
void setDefaultJoyAxisMapping(Event::Type event, int stick, int axis, int value);
void setDefaultJoyAxisMapping(Event::Type event, EventMode mode,
int stick, int axis, int value);
/**
Set the default for a joystick hat to the given event
@param event The event we are assigning
@param mode The mode where this event is active
@param stick The joystick number
@param axis The joystick axis
@param value The value on the given axis
*/
void setDefaultJoyHatMapping(Event::Type event, int stick, int hat, int value);
void setDefaultJoyHatMapping(Event::Type event, EventMode mode,
int stick, int hat, int value);
/**
Returns the current state of the EventHandler
@ -333,67 +339,83 @@ class EventHandler
inline SDL_Joystick* getJoystick(int i) { return ourJoysticks[i].stick; }
StringList getEmulationActions();
StringList getMenuActions();
StringList getActionList(EventMode mode);
Event::Type eventForKey(int key, EventMode mode);
Event::Type eventForJoyButton(int stick, int button, EventMode mode);
Event::Type eventForJoyAxis(int stick, int axis, int value, EventMode mode);
Event::Type eventForJoyHat(int stick, int hat, int value, EventMode mode);
inline Event::Type eventForKey(int key, EventMode mode)
{ return myKeyTable[key][mode]; }
inline Event::Type eventForJoyButton(int stick, int button, EventMode mode)
{ return myJoyTable[stick][button][mode]; }
inline Event::Type eventForJoyAxis(int stick, int axis, int value, EventMode mode)
{ return myJoyAxisTable[stick][axis][(value > 0)][mode]; }
inline Event::Type eventForJoyHat(int stick, int hat, int value, EventMode mode)
{ return myJoyHatTable[stick][hat][value][mode]; }
Event::Type eventAtIndex(int idx, EventMode mode);
string actionAtIndex(int idx, EventMode mode);
string keyAtIndex(int idx, EventMode mode);
private:
/**
Bind a key to an event/action and regenerate the mapping array(s)
@param event The event we are remapping
@param mode The mode where this event is active
@param key The key to bind to this event
*/
bool addKeyMapping(Event::Type event, int key);
bool addKeyMapping(Event::Type event, EventMode mode, int key);
/**
Bind a joystick button to an event/action and regenerate the
mapping array(s)
@param event The event we are remapping
@param mode The mode where this event is active
@param stick The joystick number
@param button The joystick button
*/
bool addJoyMapping(Event::Type event, int stick, int button);
bool addJoyMapping(Event::Type event, EventMode mode, int stick, int button);
/**
Bind a joystick axis direction to an event/action and regenerate
the mapping array(s)
@param event The event we are remapping
@param mode The mode where this event is active
@param stick The joystick number
@param axis The joystick axis
@param value The value on the given axis
*/
bool addJoyAxisMapping(Event::Type event, int stick, int axis, int value);
bool addJoyAxisMapping(Event::Type event, EventMode mode,
int stick, int axis, int value);
/**
Bind a joystick hat direction to an event/action and regenerate
the mapping array(s)
@param event The event we are remapping
@param mode The mode where this event is active
@param stick The joystick number
@param axis The joystick hat
@param value The value on the given hat
*/
bool addJoyHatMapping(Event::Type event, int stick, int hat, int value);
bool addJoyHatMapping(Event::Type event, EventMode mode,
int stick, int hat, int value);
/**
Erase the specified mapping
@event The event for which we erase all mappings
@param mode The mode where this event is active
*/
void eraseMapping(Event::Type event);
void eraseMapping(Event::Type event, EventMode mode);
/**
Resets the event mappings to default values
*/
void setDefaultMapping();
@param mode The mode for which the defaults are set
*/
void setDefaultMapping(EventMode mode);
private:
/**
Send a mouse motion event to the handler.
@ -446,16 +468,16 @@ class EventHandler
/**
The following methods take care of assigning action mappings.
*/
void setActionMappings();
void setActionMappings(EventMode mode);
void setSDLMappings();
void setKeymap();
void setJoymap();
void setJoyAxisMap();
void setJoyHatMap();
void setDefaultKeymap();
void setDefaultJoymap();
void setDefaultJoyAxisMap();
void setDefaultJoyHatMap();
void setDefaultKeymap(EventMode mode);
void setDefaultJoymap(EventMode mode);
void setDefaultJoyAxisMap(EventMode mode);
void setDefaultJoyHatMap(EventMode mode);
void saveKeyMapping();
void saveJoyMapping();
void saveJoyAxisMapping();
@ -510,16 +532,16 @@ class EventHandler
DialogContainer* myOverlay;
// Array of key events, indexed by SDLKey
Event::Type myKeyTable[SDLK_LAST];
Event::Type myKeyTable[SDLK_LAST][kNumModes];
// Array of joystick button events
Event::Type myJoyTable[kNumJoysticks][kNumJoyButtons];
Event::Type myJoyTable[kNumJoysticks][kNumJoyButtons][kNumModes];
// Array of joystick axis events
Event::Type myJoyAxisTable[kNumJoysticks][kNumJoyAxis][2];
Event::Type myJoyAxisTable[kNumJoysticks][kNumJoyAxis][2][kNumModes];
// Array of joystick hat events (we don't record diagonals)
Event::Type myJoyHatTable[kNumJoysticks][kNumJoyHats][4];
Event::Type myJoyHatTable[kNumJoysticks][kNumJoyHats][4][kNumModes];
// Array of messages for each Event
string ourMessageTable[Event::LastType];
@ -566,8 +588,9 @@ class EventHandler
// Type of device on each controller port (based on ROM properties)
Controller::Type myController[2];
// Holds static strings for the remap menu
static ActionList ourActionList[kActionListSize];
// Holds static strings for the remap menu (emulation and menu events)
static ActionList ourEmulActionList[kEmulActionListSize];
static ActionList ourMenuActionList[kMenuActionListSize];
// Lookup table for paddle resistance events
static const Event::Type Paddle_Resistance[4];

View File

@ -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.cxx,v 1.86 2006-05-04 17:45:24 stephena Exp $
// $Id: FrameBuffer.cxx,v 1.87 2006-05-15 12:24:09 stephena Exp $
//============================================================================
#include <sstream>
@ -331,6 +331,13 @@ void FrameBuffer::pause(bool status)
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBuffer::refresh()
{
theRedrawTIAIndicator = true;
myMessage.counter = 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBuffer::setPalette(const uInt32* palette)
{

View File

@ -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.69 2006-03-25 00:34:17 stephena Exp $
// $Id: FrameBuffer.hxx,v 1.70 2006-05-15 12:24:09 stephena Exp $
//============================================================================
#ifndef FRAMEBUFFER_HXX
@ -82,7 +82,7 @@ enum {
All GUI elements (ala ScummVM) are drawn here as well.
@author Stephen Anthony
@version $Id: FrameBuffer.hxx,v 1.69 2006-03-25 00:34:17 stephena Exp $
@version $Id: FrameBuffer.hxx,v 1.70 2006-05-15 12:24:09 stephena Exp $
*/
class FrameBuffer
{
@ -172,7 +172,7 @@ class FrameBuffer
Indicates that the TIA area is dirty, and certain areas need
to be redrawn.
*/
void refresh() { theRedrawTIAIndicator = true; }
void refresh();
/**
Toggles between fullscreen and window mode.

View File

@ -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.68 2006-03-27 12:52:19 stephena Exp $
// $Id: OSystem.cxx,v 1.69 2006-05-15 12:24:09 stephena Exp $
//============================================================================
#include <cassert>
@ -453,36 +453,42 @@ bool OSystem::openROM(const string& rom, string& md5, uInt8** image, int* size)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void OSystem::setDefaultJoymap()
{
// Left joystick (assume joystick zero, button zero)
myEventHandler->setDefaultJoyMapping(Event::JoystickZeroFire, 0, 0);
EventMode mode;
mode = kEmulationMode; // Default emulation events
// Left joystick (assume joystick zero, button zero)
myEventHandler->setDefaultJoyMapping(Event::JoystickZeroFire, mode, 0, 0);
// Right joystick (assume joystick one, button zero)
myEventHandler->setDefaultJoyMapping(Event::JoystickOneFire, 1, 0);
myEventHandler->setDefaultJoyMapping(Event::JoystickOneFire, mode, 1, 0);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void OSystem::setDefaultJoyAxisMap()
{
EventMode mode;
mode = kEmulationMode; // Default emulation events
// Left joystick left/right directions (assume joystick zero)
myEventHandler->setDefaultJoyAxisMapping(Event::JoystickZeroLeft, 0, 0, 0);
myEventHandler->setDefaultJoyAxisMapping(Event::JoystickZeroRight, 0, 0, 1);
myEventHandler->setDefaultJoyAxisMapping(Event::JoystickZeroLeft, mode, 0, 0, 0);
myEventHandler->setDefaultJoyAxisMapping(Event::JoystickZeroRight, mode, 0, 0, 1);
// Left joystick up/down directions (assume joystick zero)
myEventHandler->setDefaultJoyAxisMapping(Event::JoystickZeroUp, 0, 1, 0);
myEventHandler->setDefaultJoyAxisMapping(Event::JoystickZeroDown, 0, 1, 1);
myEventHandler->setDefaultJoyAxisMapping(Event::JoystickZeroUp, mode, 0, 1, 0);
myEventHandler->setDefaultJoyAxisMapping(Event::JoystickZeroDown, mode, 0, 1, 1);
// Right joystick left/right directions (assume joystick one)
myEventHandler->setDefaultJoyAxisMapping(Event::JoystickOneLeft, 1, 0, 0);
myEventHandler->setDefaultJoyAxisMapping(Event::JoystickOneRight, 1, 0, 1);
myEventHandler->setDefaultJoyAxisMapping(Event::JoystickOneLeft, mode, 1, 0, 0);
myEventHandler->setDefaultJoyAxisMapping(Event::JoystickOneRight, mode, 1, 0, 1);
// Right joystick left/right directions (assume joystick one)
myEventHandler->setDefaultJoyAxisMapping(Event::JoystickOneUp, 1, 1, 0);
myEventHandler->setDefaultJoyAxisMapping(Event::JoystickOneDown, 1, 1, 1);
myEventHandler->setDefaultJoyAxisMapping(Event::JoystickOneUp, mode, 1, 1, 0);
myEventHandler->setDefaultJoyAxisMapping(Event::JoystickOneDown, mode, 1, 1, 1);
mode = kMenuMode; // Default menu/UI events
// FIXME - add UI events
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void OSystem::setDefaultJoyHatMap()
{
// FIXME - add emul and UI events
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -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.16 2006-05-05 18:00:51 stephena Exp $
// $Id: EventMappingWidget.cxx,v 1.17 2006-05-15 12:24:09 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -42,7 +42,6 @@ EventMappingWidget::EventMappingWidget(GuiObject* boss, const GUI::Font& font,
myRemapStatus(false),
myFirstTime(true)
{
// FIXME
const int fontHeight = font.getFontHeight(),
lineHeight = font.getLineHeight();
int xpos = 5, ypos = 5;
@ -93,7 +92,6 @@ EventMappingWidget::~EventMappingWidget()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventMappingWidget::loadConfig()
{
cerr << "EventMappingWidget::loadConfig() for " << myEventMode << endl;
if(myFirstTime)
{
myActionsList->setSelected(0);
@ -129,7 +127,7 @@ void EventMappingWidget::startRemapping()
// And show a message indicating which key is being remapped
ostringstream buf;
buf << "Select action for '"
<< EventHandler::ourActionList[ myActionSelected ].action
<< instance()->eventHandler().actionAtIndex(myActionSelected, myEventMode)
<< "' event";
myKeyMapping->setColor(kTextColorEm);
myKeyMapping->setLabel(buf.str());
@ -145,8 +143,9 @@ void EventMappingWidget::eraseRemapping()
if(myActionSelected < 0)
return;
Event::Type event = EventHandler::ourActionList[ myActionSelected ].event;
instance()->eventHandler().eraseMapping(event);
Event::Type event =
instance()->eventHandler().eventAtIndex(myActionSelected, myEventMode);
instance()->eventHandler().eraseMapping(event, myEventMode);
drawKeyMapping();
}
@ -182,7 +181,8 @@ void EventMappingWidget::drawKeyMapping()
if(myActionSelected >= 0)
{
ostringstream buf;
buf << "Action: " << EventHandler::ourActionList[ myActionSelected ].key;
buf << "Action: "
<< instance()->eventHandler().keyAtIndex(myActionSelected, myEventMode);
myKeyMapping->setColor(kTextColor);
myKeyMapping->setLabel(buf.str());
}
@ -194,8 +194,9 @@ bool EventMappingWidget::handleKeyDown(int ascii, int keycode, int modifiers)
// Remap keys in remap mode
if(myRemapStatus && myActionSelected >= 0)
{
Event::Type event = EventHandler::ourActionList[ myActionSelected ].event;
if(instance()->eventHandler().addKeyMapping(event, keycode))
Event::Type event =
instance()->eventHandler().eventAtIndex(myActionSelected, myEventMode);
if(instance()->eventHandler().addKeyMapping(event, myEventMode, keycode))
stopRemapping();
}
return true;
@ -207,8 +208,9 @@ void EventMappingWidget::handleJoyDown(int stick, int button)
// Remap joystick buttons in remap mode
if(myRemapStatus && myActionSelected >= 0)
{
Event::Type event = EventHandler::ourActionList[ myActionSelected ].event;
if(instance()->eventHandler().addJoyMapping(event, stick, button))
Event::Type event =
instance()->eventHandler().eventAtIndex(myActionSelected, myEventMode);
if(instance()->eventHandler().addJoyMapping(event, myEventMode, stick, button))
stopRemapping();
}
}
@ -219,8 +221,10 @@ void EventMappingWidget::handleJoyAxis(int stick, int axis, int value)
// Remap joystick axes in remap mode
if(myRemapStatus && myActionSelected >= 0)
{
Event::Type event = EventHandler::ourActionList[ myActionSelected ].event;
if(instance()->eventHandler().addJoyAxisMapping(event, stick, axis, value))
Event::Type event =
instance()->eventHandler().eventAtIndex(myActionSelected, myEventMode);
if(instance()->eventHandler().addJoyAxisMapping(event, myEventMode,
stick, axis, value))
stopRemapping();
}
}
@ -233,8 +237,10 @@ bool EventMappingWidget::handleJoyHat(int stick, int hat, int value)
// Remap joystick hats in remap mode
if(myRemapStatus && myActionSelected >= 0)
{
Event::Type event = EventHandler::ourActionList[ myActionSelected ].event;
if(instance()->eventHandler().addJoyHatMapping(event, stick, hat, value))
Event::Type event =
instance()->eventHandler().eventAtIndex(myActionSelected, myEventMode);
if(instance()->eventHandler().addJoyHatMapping(event, myEventMode,
stick, hat, value))
{
stopRemapping();
result = true;
@ -284,7 +290,7 @@ void EventMappingWidget::handleCommand(CommandSender* sender, int cmd,
break;
case kDefaultsCmd:
instance()->eventHandler().setDefaultMapping();
instance()->eventHandler().setDefaultMapping(myEventMode);
drawKeyMapping();
break;
}

View File

@ -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: InputDialog.cxx,v 1.15 2006-05-05 18:00:51 stephena Exp $
// $Id: InputDialog.cxx,v 1.16 2006-05-15 12:24:09 stephena Exp $
//============================================================================
// FIXME - this whole dialog should be a dialog of buttons instead of
@ -54,7 +54,7 @@ InputDialog::InputDialog(OSystem* osystem, DialogContainer* parent,
// 1) Event mapper for emulation actions
tabID = myTab->addTab("Emul. Events");
const StringList& eactions = instance()->eventHandler().getEmulationActions();
const StringList& eactions = instance()->eventHandler().getActionList(kEmulationMode);
myEmulEventMapper = new EventMappingWidget(myTab, font, 2, 2,
myTab->getWidth(),
myTab->getHeight() - ypos,
@ -64,7 +64,7 @@ InputDialog::InputDialog(OSystem* osystem, DialogContainer* parent,
// 2) Event mapper for menu actions
tabID = myTab->addTab("Menu Events");
const StringList& mactions = instance()->eventHandler().getMenuActions();
const StringList& mactions = instance()->eventHandler().getActionList(kMenuMode);
myMenuEventMapper = new EventMappingWidget(myTab, font, 2, 2,
myTab->getWidth(),
myTab->getHeight() - ypos,
@ -209,9 +209,6 @@ void InputDialog::addVDeviceTab(const GUI::Font& font)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void InputDialog::loadConfig()
{
myEmulEventMapper->loadConfig();
myMenuEventMapper->loadConfig();
// Left & right ports
const string& sa1 = instance()->settings().getString("sa1");
int lport = sa1 == "right" ? 2 : 1;
@ -237,6 +234,8 @@ void InputDialog::loadConfig()
myPaddleLabel[2]->setLabel(instance()->settings().getString("p3speed"));
myPaddleSpeed[3]->setValue(instance()->settings().getInt("p4speed"));
myPaddleLabel[3]->setLabel(instance()->settings().getString("p4speed"));
myTab->loadConfig();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -