Initial support for key remapping is finally here. Now for the bad news:

1) It exists in the core, but only the SDL port is updated to use
it.  And the other ports don't even compile yet ...

2) The mappings for keyboard and joystick are saved in the rcfile, but
for reasons of efficiency and ease of programming, the format is somewhat
cryptic.  But the plan is to never have to edit the maps directly anyway.

3) There is no GUI in Stella to set the remapping.  This is the next
major thing to do, after I get the other ports to at least compile.

4) I haven't documented the format of the maps in the rcfile.  Its not
difficult to modify, just tedious.  If anyone is reading this and really
wants to know (or even cares), email me directly for instructions.

Enjoy :)


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@178 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2003-09-07 18:30:28 +00:00
parent 21eb45ddf1
commit 3ab45a632d
10 changed files with 253 additions and 189 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: makefile,v 1.33 2003-09-06 21:17:48 stephena Exp $
## $Id: makefile,v 1.34 2003-09-07 18:30:28 stephena Exp $
##============================================================================
##============================================================================
@ -49,7 +49,7 @@ SOUND_ALSA = 1
### to include support for saving snapshots in png format
### (requires PNG library)
### Only X11 and SDL ports supported for now
SNAPSHOT_SUPPORT = 1
# SNAPSHOT_SUPPORT = 1
### comment this out if your system doesn't
### have the gettimeofday function
@ -60,7 +60,7 @@ HAVE_GETTIMEOFDAY = 1
### enables some extra commandline options that allow the user
### to override some emulation defaults
### Only X11 and SDL ports supported for now
# DEVELOPER_SUPPORT = 1
DEVELOPER_SUPPORT = 1
##============================================================================
## All done, type make to get a list of frontends
@ -304,10 +304,10 @@ clean:
cleanall: clean
rm -f M6502Low.ins M6502Hi.ins
Driving.o: $(CORE)/Driving.cxx
Driving.o: $(CORE)/Driving.cxx $(CORE)/Driving.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/Driving.cxx
Event.o: $(CORE)/Event.cxx
Event.o: $(CORE)/Event.cxx $(CORE)/Event.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/Event.cxx
EventHandler.o: $(CORE)/EventHandler.cxx $(CORE)/EventHandler.hxx
@ -316,121 +316,121 @@ EventHandler.o: $(CORE)/EventHandler.cxx $(CORE)/EventHandler.hxx
Frontend.o: $(CORE)/Frontend.cxx $(CORE)/Frontend.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/Frontend.cxx
Control.o: $(CORE)/Control.cxx
Control.o: $(CORE)/Control.cxx $(CORE)/Control.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/Control.cxx
Joystick.o: $(CORE)/Joystick.cxx
Joystick.o: $(CORE)/Joystick.cxx $(CORE)/Joystick.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/Joystick.cxx
Keyboard.o: $(CORE)/Keyboard.cxx
Keyboard.o: $(CORE)/Keyboard.cxx $(CORE)/Keyboard.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/Keyboard.cxx
Paddles.o: $(CORE)/Paddles.cxx
Paddles.o: $(CORE)/Paddles.cxx $(CORE)/Paddles.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/Paddles.cxx
Booster.o: $(CORE)/Booster.cxx
Booster.o: $(CORE)/Booster.cxx $(CORE)/Booster.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/Booster.cxx
Cart.o: $(CORE)/Cart.cxx
Cart.o: $(CORE)/Cart.cxx $(CORE)/Cart.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/Cart.cxx
Cart2K.o: $(CORE)/Cart2K.cxx
Cart2K.o: $(CORE)/Cart2K.cxx $(CORE)/Cart2K.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/Cart2K.cxx
Cart3F.o: $(CORE)/Cart3F.cxx
Cart3F.o: $(CORE)/Cart3F.cxx $(CORE)/Cart3F.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/Cart3F.cxx
Cart4K.o: $(CORE)/Cart4K.cxx
Cart4K.o: $(CORE)/Cart4K.cxx $(CORE)/Cart4K.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/Cart4K.cxx
CartAR.o: $(CORE)/CartAR.cxx
CartAR.o: $(CORE)/CartAR.cxx $(CORE)/CartAR.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/CartAR.cxx
CartDPC.o: $(CORE)/CartDPC.cxx
CartDPC.o: $(CORE)/CartDPC.cxx $(CORE)/CartDPC.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/CartDPC.cxx
CartE0.o: $(CORE)/CartE0.cxx
CartE0.o: $(CORE)/CartE0.cxx $(CORE)/CartE0.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/CartE0.cxx
CartE7.o: $(CORE)/CartE7.cxx
CartE7.o: $(CORE)/CartE7.cxx $(CORE)/CartE7.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/CartE7.cxx
CartF4.o: $(CORE)/CartF4.cxx
CartF4.o: $(CORE)/CartF4.cxx $(CORE)/CartF4.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/CartF4.cxx
CartF4SC.o: $(CORE)/CartF4SC.cxx
CartF4SC.o: $(CORE)/CartF4SC.cxx $(CORE)/CartF4SC.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/CartF4SC.cxx
CartF6.o: $(CORE)/CartF6.cxx
CartF6.o: $(CORE)/CartF6.cxx $(CORE)/CartF6.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/CartF6.cxx
CartF6SC.o: $(CORE)/CartF6SC.cxx
CartF6SC.o: $(CORE)/CartF6SC.cxx $(CORE)/CartF6SC.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/CartF6SC.cxx
CartF8.o: $(CORE)/CartF8.cxx
CartF8.o: $(CORE)/CartF8.cxx $(CORE)/CartF8.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/CartF8.cxx
CartF8SC.o: $(CORE)/CartF8SC.cxx
CartF8SC.o: $(CORE)/CartF8SC.cxx $(CORE)/CartF8SC.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/CartF8SC.cxx
CartFASC.o: $(CORE)/CartFASC.cxx
CartFASC.o: $(CORE)/CartFASC.cxx $(CORE)/CartFASC.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/CartFASC.cxx
CartFE.o: $(CORE)/CartFE.cxx
CartFE.o: $(CORE)/CartFE.cxx $(CORE)/CartFE.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/CartFE.cxx
CartMC.o: $(CORE)/CartMC.cxx
CartMC.o: $(CORE)/CartMC.cxx $(CORE)/CartMC.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/CartMC.cxx
CartMB.o: $(CORE)/CartMB.cxx
CartMB.o: $(CORE)/CartMB.cxx $(CORE)/CartMB.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/CartMB.cxx
CartCV.o: $(CORE)/CartCV.cxx
CartCV.o: $(CORE)/CartCV.cxx $(CORE)/CartCV.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/CartCV.cxx
M6532.o: $(CORE)/M6532.cxx
M6532.o: $(CORE)/M6532.cxx $(CORE)/M6532.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/M6532.cxx
TIA.o: $(CORE)/TIA.cxx
TIA.o: $(CORE)/TIA.cxx $(CORE)/TIA.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/TIA.cxx
TIASound.o: $(CORE)/TIASound.c
TIASound.o: $(CORE)/TIASound.c $(CORE)/TIASound.h
$(CXX) -c -DWIN32 $(FLAGS) $(OPTIONS) $(CORE)/TIASound.c
Console.o: $(CORE)/Console.cxx
Console.o: $(CORE)/Console.cxx $(CORE)/Console.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/Console.cxx
MD5.o: $(CORE)/MD5.cxx
MD5.o: $(CORE)/MD5.cxx $(CORE)/MD5.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/MD5.cxx
MediaSrc.o: $(CORE)/MediaSrc.cxx
MediaSrc.o: $(CORE)/MediaSrc.cxx $(CORE)/MediaSrc.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/MediaSrc.cxx
PropsSet.o: $(CORE)/PropsSet.cxx
PropsSet.o: $(CORE)/PropsSet.cxx $(CORE)/PropsSet.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/PropsSet.cxx
Props.o: $(CORE)/Props.cxx
Props.o: $(CORE)/Props.cxx $(CORE)/Props.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/Props.cxx
Random.o: $(CORE)/Random.cxx
Random.o: $(CORE)/Random.cxx $(CORE)/Random.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/Random.cxx
Sound.o: $(CORE)/Sound.cxx $(CORE)/Sound.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(CORE)/Sound.cxx
Switches.o: $(CORE)/Switches.cxx
Switches.o: $(CORE)/Switches.cxx $(CORE)/Switches.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/Switches.cxx
Serializer.o: $(CORE)/Serializer.cxx
Serializer.o: $(CORE)/Serializer.cxx $(CORE)/Serializer.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/Serializer.cxx
Deserializer.o: $(CORE)/Deserializer.cxx
Deserializer.o: $(CORE)/Deserializer.cxx $(CORE)/Deserializer.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/Deserializer.cxx
Settings.o: $(CORE)/Settings.cxx $(CORE)/Settings.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(CORE)/Settings.cxx
Terminal.o: $(UI)/x11/Terminal.cxx
Terminal.o: $(UI)/x11/Terminal.cxx $(UI)/x11/Terminal.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(UI)/x11/Terminal.cxx
mainDOS.o: $(UI)/dos/mainDOS.cxx
@ -460,9 +460,6 @@ SoundSDL.o: $(UI)/sound/SoundSDL.cxx $(UI)/sound/SoundSDL.hxx
FrontendUNIX.o: $(UI)/frontend/FrontendUNIX.cxx $(UI)/frontend/FrontendUNIX.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(UI)/frontend/FrontendUNIX.cxx
TermX11.o: $(UI)/x11/TermX11.cxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(UI)/x11/TermX11.cxx
mainX11.o: $(UI)/x11/mainX11.cxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(UI)/x11/mainX11.cxx
@ -490,8 +487,8 @@ M6502Low.o: $(CORE)/m6502/src/M6502Low.cxx
M6502Hi.o: $(CORE)/m6502/src/M6502Hi.cxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/m6502/src/M6502Hi.cxx
NullDev.o: $(CORE)/m6502/src/NullDev.cxx
NullDev.o: $(CORE)/m6502/src/NullDev.cxx $(CORE)/m6502/src/NullDev.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/m6502/src/NullDev.cxx
System.o: $(CORE)/m6502/src/System.cxx
System.o: $(CORE)/m6502/src/System.cxx $(CORE)/m6502/src/System.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/m6502/src/System.cxx

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: Console.cxx,v 1.12 2003-09-06 21:17:48 stephena Exp $
// $Id: Console.cxx,v 1.13 2003-09-07 18:30:28 stephena Exp $
//============================================================================
#include <assert.h>
@ -47,7 +47,7 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Console::Console(const uInt8* image, uInt32 size, const char* filename,
Settings& rcsettings, PropertiesSet& propertiesSet, Frontend& frontend,
uInt32 sampleRate, const Properties* userDefinedProperties)
uInt32 sampleRate)
: mySettings(rcsettings),
myPropSet(propertiesSet),
myFrontend(frontend)
@ -75,11 +75,10 @@ Console::Console(const uInt8* image, uInt32 size, const char* filename,
// Search for the properties based on MD5
myPropSet.getMD5(md5, myProperties);
#ifdef DEVELOPER_SUPPORT
// Merge any user-defined properties
if(userDefinedProperties != 0)
{
myProperties.merge(*userDefinedProperties);
}
myProperties.merge(mySettings.userDefinedProperties);
#endif
// Make sure the MD5 value of the cartridge is set in the properties
if(myProperties.get("Cartridge.MD5") == "")
@ -204,7 +203,7 @@ const Properties& Console::properties() const
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const Settings& Console::settings() const
Settings& Console::settings() const
{
return mySettings;
}
@ -253,6 +252,7 @@ const Properties& Console::defaultProperties()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Properties Console::ourDefaultProperties;
#ifdef DEVELOPER_SUPPORT
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Console::toggleFormat()
{
@ -436,7 +436,7 @@ void Console::changeHeight(const uInt32 direction)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Console::saveProperties(string& filename, bool merge)
void Console::saveProperties(string filename, bool merge)
{
string message;
@ -472,3 +472,4 @@ void Console::saveProperties(string& filename, bool merge)
}
}
}
#endif

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: Console.hxx,v 1.8 2003-09-06 21:17:48 stephena Exp $
// $Id: Console.hxx,v 1.9 2003-09-07 18:30:28 stephena Exp $
//============================================================================
#ifndef CONSOLE_HXX
@ -39,7 +39,7 @@ class System;
This class represents the entire game console.
@author Bradford W. Mott
@version $Id: Console.hxx,v 1.8 2003-09-06 21:17:48 stephena Exp $
@version $Id: Console.hxx,v 1.9 2003-09-07 18:30:28 stephena Exp $
*/
class Console
{
@ -54,11 +54,10 @@ class Console
@param rcsettings The settings object to use
@param profiles The game profiles object to use
@param sampleRate The rate to create audio samples at
@param userDefinedProperties User properties that should override the defaults
*/
Console(const uInt8* image, uInt32 size, const char* filename,
Settings& rcsettings, PropertiesSet& propertiesSet, Frontend& frontend,
uInt32 sampleRate, const Properties* userDefinedProperties = 0);
uInt32 sampleRate);
/**
Create a new console object by copying another one
@ -112,7 +111,7 @@ class Console
@return The settings for this console
*/
const Settings& settings() const;
Settings& settings() const;
/**
Get the console switches
@ -161,9 +160,10 @@ class Console
*/
static const Properties& defaultProperties();
#ifdef DEVELOPER_SUPPORT
public:
/**
Toggle between NTSC and PAL mode. The GUI's may need to reload their palette.
Toggle between NTSC and PAL mode. The frontends may need to reload their palette.
*/
void toggleFormat();
@ -206,7 +206,8 @@ class Console
@param merge Whether or not to merge the changes into the
main properties file.
*/
void saveProperties(string& filename, bool merge = false);
void saveProperties(string filename, bool merge = false);
#endif
private:
// Pointers to the left and right controllers

View File

@ -13,9 +13,10 @@
// 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.4 2003-09-06 21:17:48 stephena Exp $
// $Id: EventHandler.cxx,v 1.5 2003-09-07 18:30:28 stephena Exp $
//============================================================================
#include <algorithm>
#include <sstream>
#include "Console.hxx"
@ -23,6 +24,7 @@
#include "EventHandler.hxx"
#include "Frontend.hxx"
#include "MediaSrc.hxx"
#include "Settings.hxx"
#include "StellaEvent.hxx"
#include "System.hxx"
#include "bspf.hxx"
@ -47,18 +49,18 @@ EventHandler::EventHandler(Console* console)
// Erase the Message array
for(Int32 i = 0; i < Event::LastType; ++i)
myMessageTable[i] = "";
ourMessageTable[i] = "";
// Set unchanging messages
myMessageTable[Event::ConsoleColor] = "Color Mode";
myMessageTable[Event::ConsoleBlackWhite] = "BW Mode";
myMessageTable[Event::ConsoleLeftDifficultyA] = "Left Difficulty A";
myMessageTable[Event::ConsoleLeftDifficultyB] = "Left Difficulty B";
myMessageTable[Event::ConsoleRightDifficultyA] = "Right Difficulty A";
myMessageTable[Event::ConsoleRightDifficultyB] = "Right Difficulty B";
ourMessageTable[Event::ConsoleColor] = "Color Mode";
ourMessageTable[Event::ConsoleBlackWhite] = "BW Mode";
ourMessageTable[Event::ConsoleLeftDifficultyA] = "Left Difficulty A";
ourMessageTable[Event::ConsoleLeftDifficultyB] = "Left Difficulty B";
ourMessageTable[Event::ConsoleRightDifficultyA] = "Right Difficulty A";
ourMessageTable[Event::ConsoleRightDifficultyB] = "Right Difficulty B";
setDefaultKeymap();
setDefaultJoymap();
setKeymap();
setJoymap();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -120,12 +122,13 @@ void EventHandler::sendKeyEvent(StellaEvent::KeyCode key, Int32 state)
}
else if(event == Event::Quit)
{
myConsole->settings().save();
myConsole->frontend().setQuitEvent();
return;
}
if(myMessageTable[event] != "")
myMediaSource->showMessage(myMessageTable[event], 120);
if(ourMessageTable[event] != "")
myMediaSource->showMessage(ourMessageTable[event], 120);
}
// Otherwise, pass it to the emulation core
@ -173,12 +176,13 @@ void EventHandler::sendJoyEvent(StellaEvent::JoyStick stick,
}
else if(event == Event::Quit)
{
myConsole->settings().save();
myConsole->frontend().setQuitEvent();
return;
}
if(myMessageTable[event] != "")
myMediaSource->showMessage(myMessageTable[event], 120);
if(ourMessageTable[event] != "")
myMediaSource->showMessage(ourMessageTable[event], 120);
}
// Otherwise, pass it to the emulation core
@ -186,9 +190,103 @@ void EventHandler::sendJoyEvent(StellaEvent::JoyStick stick,
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::sendEvent(Event::Type type, Int32 value)
void EventHandler::sendEvent(Event::Type event, Int32 state)
{
myEvent->set(type, value);
// Take care of special events that aren't technically part of
// the emulation core
if(event == Event::Pause && state == 1)
{
myConsole->frontend().setPauseEvent();
return;
}
else if(event == Event::Quit && state == 1)
{
myConsole->settings().save();
myConsole->frontend().setQuitEvent();
return;
}
myEvent->set(event, state);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::setKeymap()
{
// Since istringstream swallows whitespace, we have to make the
// delimiters be spaces
string list = myConsole->settings().theKeymapList;
replace(list.begin(), list.end(), ':', ' ');
if(isValidList(list, StellaEvent::LastKCODE))
{
Event::Type event;
istringstream buf(list);
string key;
// Fill the keymap table with events
for(Int32 i = 0; i < StellaEvent::LastKCODE; ++i)
{
buf >> key;
myKeyTable[i] = (Event::Type) atoi(key.c_str());
}
}
else
setDefaultKeymap();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::setJoymap()
{
// Since istringstream swallows whitespace, we have to make the
// delimiters be spaces
string list = myConsole->settings().theJoymapList;
replace(list.begin(), list.end(), ':', ' ');
if(isValidList(list, StellaEvent::LastJSTICK*StellaEvent::LastJCODE))
{
Event::Type event;
istringstream buf(list);
string key;
// Fill the joymap table with events
for(Int32 i = 0; i < StellaEvent::LastJSTICK; ++i)
{
for(Int32 j = 0; j < StellaEvent::LastJCODE; ++j)
{
buf >> key;
myJoyTable[i][j] = (Event::Type) atoi(key.c_str());
}
}
}
else
setDefaultJoymap();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string EventHandler::getKeymap()
{
ostringstream buf;
// Iterate through the keymap table and create a colon-separated list
for(Int32 i = 0; i < StellaEvent::LastKCODE; ++i)
buf << myKeyTable[i] << ":";
myKeymapString = buf.str();
return myKeymapString;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string EventHandler::getJoymap()
{
ostringstream buf;
// Iterate through the joymap table and create a colon-separated list
for(Int32 i = 0; i < StellaEvent::LastJSTICK; ++i)
for(Int32 j = 0; j < StellaEvent::LastJCODE; ++j)
buf << myJoyTable[i][j] << ":";
myJoymapString = buf.str();
return myJoymapString;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -276,6 +374,20 @@ void EventHandler::setDefaultJoymap()
myJoyTable[StellaEvent::JSTICK_1][StellaEvent::JBUTTON_0] = Event::JoystickOneFire;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool EventHandler::isValidList(string list, uInt32 length)
{
// Rudimentary check to see if the list contains 'length' keys
istringstream buf(list);
string key;
uInt32 i = 0;
while(buf >> key)
i++;
return (i == length);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::saveState()
{

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.4 2003-09-06 21:17:48 stephena Exp $
// $Id: EventHandler.hxx,v 1.5 2003-09-07 18:30:28 stephena Exp $
//============================================================================
#ifndef EVENTHANDLER_HXX
@ -40,7 +40,7 @@ class MediaSource;
unchanged to the remap class, where key remapping can take place.
@author Stephen Anthony
@version $Id: EventHandler.hxx,v 1.4 2003-09-06 21:17:48 stephena Exp $
@version $Id: EventHandler.hxx,v 1.5 2003-09-07 18:30:28 stephena Exp $
*/
class EventHandler
{
@ -97,24 +97,28 @@ class EventHandler
void setMediaSource(MediaSource* mediaSource);
/**
Set the keymapping from the settings object.
Get the current keymapping being used
@param keymap The keymap in comma-separated string form
@return The keymap list in string form
*/
void setKeyMap(string& keymap);
string getKeymap();
#if 0
/**
Set the keymapping from the settings object.
Get the current joymapping being used
@param keymap The keymap in comma-separated string form
@return The joymap list in string form
*/
void getKeyMap(string& keymap);
#endif
string getJoymap();
private:
void setKeymap();
void setJoymap();
void setDefaultKeymap();
void setDefaultJoymap();
bool isValidList(string list, uInt32 length);
void saveState();
void changeState();
void loadState();
@ -127,7 +131,7 @@ class EventHandler
Event::Type myJoyTable[StellaEvent::LastJSTICK][StellaEvent::LastJCODE];
// Array of messages for each Event
string myMessageTable[Event::LastType];
string ourMessageTable[Event::LastType];
// Global Console object
Console* myConsole;
@ -143,6 +147,12 @@ class EventHandler
// Indicates the current pause status
bool myPauseStatus;
// The current keymap in string form
string myKeymapString;
// The current joymap in string form
string myJoymapString;
};
#endif

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: Frontend.hxx,v 1.2 2003-09-06 21:17:48 stephena Exp $
// $Id: Frontend.hxx,v 1.3 2003-09-07 18:30:28 stephena Exp $
//============================================================================
#ifndef FRONTEND_HXX
@ -27,7 +27,7 @@ class Console;
This class provides an interface for accessing frontend specific data.
@author Stephen Anthony
@version $Id: Frontend.hxx,v 1.2 2003-09-06 21:17:48 stephena Exp $
@version $Id: Frontend.hxx,v 1.3 2003-09-07 18:30:28 stephena Exp $
*/
class Frontend
{
@ -123,6 +123,13 @@ class Frontend
*/
virtual string systemConfigFilename() = 0;
/**
This method should be called to get the filename of the users
base home directory.
@return String representing the full path of the home directory.
*/
virtual string userHomeDir() = 0;
private:
// Copy constructor isn't supported by this class so make it private

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: Settings.cxx,v 1.1 2003-09-05 18:02:58 stephena Exp $
// $Id: Settings.cxx,v 1.2 2003-09-07 18:30:28 stephena Exp $
//============================================================================
#include <fstream>
@ -32,6 +32,8 @@ Settings::Settings(const string& infile, const string& outfile)
: mySettingsInputFilename(infile),
mySettingsOutputFilename(outfile)
{
theKeymapList = "";
theJoymapList = "";
theUseFullScreenFlag = false;
theGrabMouseFlag = false;
theCenterWindowFlag = false;
@ -415,6 +417,14 @@ void Settings::handleRCFile()
theSoundDriver = value;
}
else if(key == "keymap")
{
theKeymapList = value;
}
else if(key == "joymap")
{
theJoymapList = value;
}
#ifdef DEVELOPER_SUPPORT
else if(key == "Dmerge")
{
@ -457,6 +467,8 @@ void Settings::save()
#ifdef DEVELOPER_SUPPORT
<< "Dmerge = " << theMergePropertiesFlag << endl
#endif
<< "keymap = " << myConsole->eventHandler().getKeymap() << endl
<< "joymap = " << myConsole->eventHandler().getJoymap() << endl
<< endl;
out.close();

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: Settings.hxx,v 1.1 2003-09-05 18:02:58 stephena Exp $
// $Id: Settings.hxx,v 1.2 2003-09-07 18:30:28 stephena Exp $
//============================================================================
#ifndef SETTINGS_HXX
@ -38,6 +38,12 @@ class Settings
void setConsole(Console* console);
public:
// The keymap to use
string theKeymapList;
// The joymap to use
string theJoymapList;
// Indicates whether to use fullscreen
bool theUseFullScreenFlag;

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: FrontendUNIX.hxx,v 1.2 2003-09-06 21:17:48 stephena Exp $
// $Id: FrontendUNIX.hxx,v 1.3 2003-09-07 18:30:28 stephena Exp $
//============================================================================
#ifndef FRONTEND_UNIX_HXX
@ -29,7 +29,7 @@ class Console;
and events.
@author Stephen Anthony
@version $Id: FrontendUNIX.hxx,v 1.2 2003-09-06 21:17:48 stephena Exp $
@version $Id: FrontendUNIX.hxx,v 1.3 2003-09-07 18:30:28 stephena Exp $
*/
class FrontendUNIX : public Frontend
{
@ -117,11 +117,11 @@ class FrontendUNIX : public Frontend
virtual string systemConfigFilename();
/**
Returns the UNIX filename representing a system config file.
Returns the filename representing the users home directory.
@return The full path and filename of the system config file.
@return The full path and filename of the home directory.
*/
string userHomeDir() { return myHomeDir; }
virtual string userHomeDir() { return myHomeDir; }
private:
bool myPauseIndicator;

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: mainSDL.cxx,v 1.45 2003-09-06 21:17:48 stephena Exp $
// $Id: mainSDL.cxx,v 1.46 2003-09-07 18:30:28 stephena Exp $
//============================================================================
#include <fstream>
@ -132,12 +132,6 @@ static Sound* sound = (Sound*) NULL;
// Pointer to the frontend object or the null pointer
static Frontend* frontend = (Frontend*) NULL;
// Indicates if the user wants to quit
//static bool theQuitIndicator = false;
// Indicates if the emulator should be paused
//static bool thePauseIndicator = false;
// Indicates if the mouse should be grabbed
static bool theGrabMouseIndicator = false;
@ -261,7 +255,6 @@ StellaEvent::JoyStick joyList[StellaEvent::LastJSTICK] = {
StellaEvent::JSTICK_0, StellaEvent::JSTICK_1,
StellaEvent::JSTICK_2, StellaEvent::JSTICK_3
};
StellaEvent::JoyCode joyButtonList[StellaEvent::LastJCODE] = {
StellaEvent::JBUTTON_0, StellaEvent::JBUTTON_1, StellaEvent::JBUTTON_2,
StellaEvent::JBUTTON_3, StellaEvent::JBUTTON_4, StellaEvent::JBUTTON_5,
@ -907,7 +900,6 @@ void handleEvents()
// update the palette
setupPalette();
}
else if(key == SDLK_END) // End decreases XStart
{ // Alt-End decreases Width
if(mod & KMOD_ALT)
@ -952,11 +944,11 @@ void handleEvents()
{
if(theConsole->settings().theMergePropertiesFlag) // Attempt to merge with propertiesSet
{
theConsole->saveProperties(homePropertiesFile, true);
theConsole->saveProperties(theConsole->frontend().userPropertiesFilename(), true);
}
else // Save to file in home directory
{
string newPropertiesFile = homeDir + "/" + \
string newPropertiesFile = theConsole->frontend().userHomeDir() + "/" + \
theConsole->properties().get("Cartridge.Name") + ".pro";
replace(newPropertiesFile.begin(), newPropertiesFile.end(), ' ', '_');
theConsole->saveProperties(newPropertiesFile);
@ -1050,13 +1042,13 @@ void handleEvents()
{
if(!frontend->pause())
{
frontend->setPauseEvent();
theConsole->eventHandler().sendEvent(Event::Pause, 1);
}
}
}
else if(event.type == SDL_QUIT)
{
frontend->setQuitEvent();
theConsole->eventHandler().sendEvent(Event::Quit, 1);
}
#ifdef HAVE_JOYSTICK
@ -1120,71 +1112,6 @@ void handleEvents()
theConsole->eventHandler().sendJoyEvent(stick, code, state);
}
/*
if(theRightJoystick)
{
if(((event.type == SDL_JOYBUTTONDOWN) || (event.type == SDL_JOYBUTTONUP))
&& (event.jbutton.which == 1))
{
button = event.jbutton.button;
state = event.jbutton.state;
state = (state == SDL_PRESSED) ? 1 : 0;
if(button == 0) // fire button
{
theEvent.set(Event::JoystickOneFire, state ?
1 : keyboardEvent.get(Event::JoystickOneFire));
// If we're using real paddles then set paddle event as well
if(theConsole->settings().thePaddleMode == 4)
theEvent.set(Event::PaddleTwoFire, state);
}
else if(button == 1) // booster button
{
theEvent.set(Event::BoosterGripOneTrigger, state ?
1 : keyboardEvent.get(Event::BoosterGripOneTrigger));
// If we're using real paddles then set paddle event as well
if(theConsole->settings().thePaddleMode == 4)
theEvent.set(Event::PaddleThreeFire, state);
}
}
else if((event.type == SDL_JOYAXISMOTION) && (event.jaxis.which == 1))
{
axis = event.jaxis.axis;
value = event.jaxis.value;
if(axis == 0) // x-axis
{
theEvent.set(Event::JoystickOneLeft, (value < -16384) ?
1 : keyboardEvent.get(Event::JoystickOneLeft));
theEvent.set(Event::JoystickOneRight, (value > 16384) ?
1 : keyboardEvent.get(Event::JoystickOneRight));
// If we're using real paddles then set paddle events as well
if(theConsole->settings().thePaddleMode == 4)
{
uInt32 r = (uInt32)((1.0E6L * (value + 32767L)) / 65536);
theEvent.set(Event::PaddleTwoResistance, r);
}
}
else if(axis == 1) // y-axis
{
theEvent.set(Event::JoystickOneUp, (value < -16384) ?
1 : keyboardEvent.get(Event::JoystickOneUp));
theEvent.set(Event::JoystickOneDown, (value > 16384) ?
1 : keyboardEvent.get(Event::JoystickOneDown));
// If we're using real paddles then set paddle events as well
if(theConsole->settings().thePaddleMode == 4)
{
uInt32 r = (uInt32)((1.0E6L * (value + 32767L)) / 65536);
theEvent.set(Event::PaddleThreeResistance, r);
}
}
}
}
*/
#endif
}
}
@ -1529,7 +1456,7 @@ int main(int argc, char* argv[])
// Create a sound object for playing audio
if(settings.theSoundDriver == "0")
{
// if sound has been disabled, we still need a sound object
// even if sound has been disabled, we still need a sound object
sound = new Sound();
if(settings.theShowInfoFlag)
cout << "Sound disabled.\n";
@ -1570,15 +1497,9 @@ int main(int argc, char* argv[])
// Get just the filename of the file containing the ROM image
const char* filename = (!strrchr(file, '/')) ? file : strrchr(file, '/') + 1;
// Create the 2600 game console for users or developers
#ifdef DEVELOPER_SUPPORT
theConsole = new Console(image, size, filename,
settings, propertiesSet, *frontend, sound->getSampleRate(),
&settings.userDefinedProperties);
#else
theConsole = new Console(image, size, filename,
settings, propertiesSet, *frontend, sound->getSampleRate());
#endif
// Create the 2600 game console
theConsole = new Console(image, size, filename, settings, propertiesSet,
*frontend, sound->getSampleRate());
// Free the image since we don't need it any longer
delete[] image;
@ -1703,9 +1624,6 @@ int main(int argc, char* argv[])
}
// Cleanup time ...
//// FIXME ... put this in the eventhandler and activate on QUIT event
settings.save();
//////////////////////////////
cleanup();
return 0;
}