From f8cf40361cfc83cb5fc7949a763efa152a10f21f Mon Sep 17 00:00:00 2001 From: stephena Date: Wed, 3 Sep 2003 20:10:58 +0000 Subject: [PATCH] Beginning of support for key remapping in the core. For now, only the SDL version has been changed (not fully), and it doesn't actually do any remapping yet :) The new class 'EventHandler' will receive all events and will dispatch them to the core. The frontends will no longer deal with events directly, but will convert them from native format (SDL, X, DOS, etc.) to core events. The actual remapping will be taken care of in the core, and each frontend will never know about it. For those frontends that don't wish to take advantage of core remapping, they can still use the 'Event' class directly. Eventually, this will be extended to the joystick code as well, but I don't think it would be wise to remap the mouse. One thing that has changed is that it will no longer be possible for one key event to activate more than one core event. It doesn't make sense to do it, and I'm not sure the original code actually worked anyway. One core event can be mapped to more that one key event, however (Joystick fire 0 could be activated by Joy button 0, Space, Left Ctrl, etc). git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@173 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- stella/src/build/makefile | 153 +++++++++++------------ stella/src/emucore/EventHandler.cxx | 147 ++++++++++++++++++++++ stella/src/emucore/EventHandler.hxx | 98 +++++++++++++++ stella/src/emucore/StellaEvent.hxx | 74 +++++++++++ stella/src/ui/sdl/mainSDL.cxx | 183 +++++++++++++++++----------- 5 files changed, 505 insertions(+), 150 deletions(-) create mode 100644 stella/src/emucore/EventHandler.cxx create mode 100644 stella/src/emucore/EventHandler.hxx create mode 100644 stella/src/emucore/StellaEvent.hxx diff --git a/stella/src/build/makefile b/stella/src/build/makefile index b5e378e39..0a2d6a249 100644 --- a/stella/src/build/makefile +++ b/stella/src/build/makefile @@ -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.30 2003-02-17 05:20:18 bwmott Exp $ +## $Id: makefile,v 1.31 2003-09-03 20:10:58 stephena Exp $ ##============================================================================ ##============================================================================ @@ -23,19 +23,7 @@ ## Comment a line out to disable that option, remove comment to enable it. ##============================================================================ -OPTIMIZATIONS = -O2 -Wall -Wno-unused -### to get full optimization under gcc/x Intel based OS's.. -# OPTIMIZATIONS = -O3 -mcpu=pentiumpro -march=pentiumpro -Wall -Wno-unused \ -# -funroll-loops -fstrength-reduce -fomit-frame-pointer -ffast-math \ -# -falign-functions=2 -falign-jumps=2 -falign-loops=2 -### to get full optimization under gcc/x Athlon based OS's.. -# OPTIMIZATIONS = -O3 -mcpu=athlon -march=athlon -Wall -Wno-unused \ -# -funroll-loops -fstrength-reduce -fomit-frame-pointer -ffast-math \ -# -falign-functions=2 -falign-jumps=2 -falign-loops=2 -### to get full optimization under gcc/x Athlon-XP based OS's.. -# OPTIMIZATIONS = -O3 -mcpu=athlon-xp -march=athlon-xp -Wall -Wno-unused \ -# -funroll-loops -fstrength-reduce -fomit-frame-pointer -ffast-math \ -# -falign-functions=2 -falign-jumps=2 -falign-loops=2 +OPTIMIZATIONS = $(CXXFLAGS) -Wall -Wno-unused ### which sound drivers to compile for the X11 and SDL versions ### OSS is most compatible, SDL for platforms where OSS not available @@ -56,12 +44,12 @@ SOUND_OSS = 1 # DEBUG = 1 ### to include joystick support in the X11 and SDL versions -# JOYSTICK_SUPPORT = 1 + JOYSTICK_SUPPORT = 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 @@ -103,7 +91,7 @@ UI = $(SRC)/ui INCLUDES = -I. -I$(CORE) -I$(CORE)/m6502/src -I$(CORE)/m6502/src/bspf/src -I$(UI)/common -CXXFLAGS = $(OPTIMIZATIONS) $(INCLUDES) $(SYS_INCLUDES) +FLAGS = $(OPTIMIZATIONS) $(INCLUDES) $(SYS_INCLUDES) ## set the user-defined options ifdef BSPF_BOOL @@ -131,11 +119,11 @@ endif ifdef SNAPSHOT_SUPPORT OBJS.X11 += Snapshot.o OPTS.X11 += -DHAVE_PNG=1 -LIBS.X11 += -lpng +LIBS.X11 += -lpng -lz OBJS.SDL += Snapshot.o OPTS.SDL += -DHAVE_PNG=1 -LIBS.SDL += -lpng +LIBS.SDL += -lpng -lz endif ifdef HAVE_GETTIMEOFDAY @@ -277,7 +265,7 @@ CORE_OBJS = Booster.o Cart.o Cart2K.o Cart3F.o Cart4K.o CartAR.o CartDPC.o \ CartMB.o Console.o Control.o Driving.o \ Event.o Joystick.o Keyboard.o M6532.o MD5.o MediaSrc.o Paddles.o \ Props.o PropsSet.o Random.o Sound.o Switches.o Settings.o TIA.o \ - Serializer.o Deserializer.o TIASound.o \ + Serializer.o Deserializer.o TIASound.o EventHandler.o \ $(M6502_OBJS) stella.exe: $(CORE_OBJS) $(OBJS) @@ -317,184 +305,187 @@ cleanall: clean rm -f M6502Low.ins M6502Hi.ins Driving.o: $(CORE)/Driving.cxx - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/Driving.cxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/Driving.cxx Event.o: $(CORE)/Event.cxx - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/Event.cxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/Event.cxx + +EventHandler.o: $(CORE)/EventHandler.cxx $(CORE)/EventHandler.hxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/EventHandler.cxx Control.o: $(CORE)/Control.cxx - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/Control.cxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/Control.cxx Joystick.o: $(CORE)/Joystick.cxx - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/Joystick.cxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/Joystick.cxx Keyboard.o: $(CORE)/Keyboard.cxx - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/Keyboard.cxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/Keyboard.cxx Paddles.o: $(CORE)/Paddles.cxx - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/Paddles.cxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/Paddles.cxx Booster.o: $(CORE)/Booster.cxx - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/Booster.cxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/Booster.cxx Cart.o: $(CORE)/Cart.cxx - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/Cart.cxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/Cart.cxx Cart2K.o: $(CORE)/Cart2K.cxx - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/Cart2K.cxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/Cart2K.cxx Cart3F.o: $(CORE)/Cart3F.cxx - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/Cart3F.cxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/Cart3F.cxx Cart4K.o: $(CORE)/Cart4K.cxx - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/Cart4K.cxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/Cart4K.cxx CartAR.o: $(CORE)/CartAR.cxx - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/CartAR.cxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/CartAR.cxx CartDPC.o: $(CORE)/CartDPC.cxx - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/CartDPC.cxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/CartDPC.cxx CartE0.o: $(CORE)/CartE0.cxx - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/CartE0.cxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/CartE0.cxx CartE7.o: $(CORE)/CartE7.cxx - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/CartE7.cxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/CartE7.cxx CartF4.o: $(CORE)/CartF4.cxx - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/CartF4.cxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/CartF4.cxx CartF4SC.o: $(CORE)/CartF4SC.cxx - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/CartF4SC.cxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/CartF4SC.cxx CartF6.o: $(CORE)/CartF6.cxx - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/CartF6.cxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/CartF6.cxx CartF6SC.o: $(CORE)/CartF6SC.cxx - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/CartF6SC.cxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/CartF6SC.cxx CartF8.o: $(CORE)/CartF8.cxx - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/CartF8.cxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/CartF8.cxx CartF8SC.o: $(CORE)/CartF8SC.cxx - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/CartF8SC.cxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/CartF8SC.cxx CartFASC.o: $(CORE)/CartFASC.cxx - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/CartFASC.cxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/CartFASC.cxx CartFE.o: $(CORE)/CartFE.cxx - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/CartFE.cxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/CartFE.cxx CartMC.o: $(CORE)/CartMC.cxx - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/CartMC.cxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/CartMC.cxx CartMB.o: $(CORE)/CartMB.cxx - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/CartMB.cxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/CartMB.cxx CartCV.o: $(CORE)/CartCV.cxx - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/CartCV.cxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/CartCV.cxx M6532.o: $(CORE)/M6532.cxx - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/M6532.cxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/M6532.cxx TIA.o: $(CORE)/TIA.cxx - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/TIA.cxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/TIA.cxx TIASound.o: $(CORE)/TIASound.c - $(CXX) -c -DWIN32 $(CXXFLAGS) $(OPTIONS) $(CORE)/TIASound.c + $(CXX) -c -DWIN32 $(FLAGS) $(OPTIONS) $(CORE)/TIASound.c Console.o: $(CORE)/Console.cxx - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/Console.cxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/Console.cxx MD5.o: $(CORE)/MD5.cxx - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/MD5.cxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/MD5.cxx MediaSrc.o: $(CORE)/MediaSrc.cxx - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/MediaSrc.cxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/MediaSrc.cxx PropsSet.o: $(CORE)/PropsSet.cxx - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/PropsSet.cxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/PropsSet.cxx Props.o: $(CORE)/Props.cxx - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/Props.cxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/Props.cxx Random.o: $(CORE)/Random.cxx - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/Random.cxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/Random.cxx Sound.o: $(CORE)/Sound.cxx $(CORE)/Sound.hxx - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(LDFLAGS) $(CORE)/Sound.cxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(CORE)/Sound.cxx Switches.o: $(CORE)/Switches.cxx - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/Switches.cxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/Switches.cxx Serializer.o: $(CORE)/Serializer.cxx - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/Serializer.cxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/Serializer.cxx Deserializer.o: $(CORE)/Deserializer.cxx - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/Deserializer.cxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/Deserializer.cxx Settings.o: $(UI)/common/Settings.cxx $(UI)/common/Settings.hxx - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(LDFLAGS) $(UI)/common/Settings.cxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(UI)/common/Settings.cxx Terminal.o: $(UI)/x11/Terminal.cxx - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(UI)/x11/Terminal.cxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(UI)/x11/Terminal.cxx mainDOS.o: $(UI)/dos/mainDOS.cxx - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(UI)/dos/mainDOS.cxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(UI)/dos/mainDOS.cxx PCJoys.o: $(UI)/dos/PCJoys.cxx - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(UI)/dos/PCJoys.cxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(UI)/dos/PCJoys.cxx SndDOS.o: $(UI)/dos/SndDOS.cxx - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(UI)/dos/SndDOS.cxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(UI)/dos/SndDOS.cxx dos_sb.o: $(UI)/dos/dos_sb.c - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(UI)/dos/dos_sb.c + $(CXX) -c $(FLAGS) $(OPTIONS) $(UI)/dos/dos_sb.c vga.o: $(UI)/dos/vga.cxx - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(UI)/dos/vga.cxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(UI)/dos/vga.cxx SoundALSA.o: $(UI)/sound/SoundALSA.cxx $(UI)/sound/SoundALSA.hxx - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(LDFLAGS) $(UI)/sound/SoundALSA.cxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(UI)/sound/SoundALSA.cxx SoundOSS.o: $(UI)/sound/SoundOSS.cxx $(UI)/sound/SoundOSS.hxx - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(LDFLAGS) $(UI)/sound/SoundOSS.cxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(UI)/sound/SoundOSS.cxx SoundSDL.o: $(UI)/sound/SoundSDL.cxx $(UI)/sound/SoundSDL.hxx - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(LDFLAGS) $(UI)/sound/SoundSDL.cxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(UI)/sound/SoundSDL.cxx TermX11.o: $(UI)/x11/TermX11.cxx - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(UI)/x11/TermX11.cxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(UI)/x11/TermX11.cxx mainX11.o: $(UI)/x11/mainX11.cxx - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(LDFLAGS) $(UI)/x11/mainX11.cxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(UI)/x11/mainX11.cxx mainSDL.o: $(UI)/sdl/mainSDL.cxx - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(LDFLAGS) $(UI)/sdl/mainSDL.cxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(UI)/sdl/mainSDL.cxx RectList.o: $(UI)/sdl/RectList.cxx $(UI)/sdl/RectList.hxx - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(LDFLAGS) $(UI)/sdl/RectList.cxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(UI)/sdl/RectList.cxx Snapshot.o: $(UI)/common/Snapshot.cxx $(UI)/common/Snapshot.hxx - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(LDFLAGS) $(UI)/common/Snapshot.cxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(UI)/common/Snapshot.cxx D6502.o: $(CORE)/m6502/src/D6502.cxx - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/m6502/src/D6502.cxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/m6502/src/D6502.cxx Device.o: $(CORE)/m6502/src/Device.cxx - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/m6502/src/Device.cxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/m6502/src/Device.cxx M6502.o: $(CORE)/m6502/src/M6502.cxx - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/m6502/src/M6502.cxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/m6502/src/M6502.cxx M6502Low.o: $(CORE)/m6502/src/M6502Low.cxx - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/m6502/src/M6502Low.cxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/m6502/src/M6502Low.cxx M6502Hi.o: $(CORE)/m6502/src/M6502Hi.cxx - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/m6502/src/M6502Hi.cxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/m6502/src/M6502Hi.cxx NullDev.o: $(CORE)/m6502/src/NullDev.cxx - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/m6502/src/NullDev.cxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/m6502/src/NullDev.cxx System.o: $(CORE)/m6502/src/System.cxx - $(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/m6502/src/System.cxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/m6502/src/System.cxx diff --git a/stella/src/emucore/EventHandler.cxx b/stella/src/emucore/EventHandler.cxx new file mode 100644 index 000000000..0b9ab61e5 --- /dev/null +++ b/stella/src/emucore/EventHandler.cxx @@ -0,0 +1,147 @@ +//============================================================================ +// +// SSSS tt lll lll +// SS SS tt ll ll +// SS tttttt eeee ll ll aaaa +// SSSS tt ee ee ll ll aa +// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" +// SS SS tt ee ll ll aa aa +// SSSS ttt eeeee llll llll aaaaa +// +// Copyright (c) 1995-1998 by Bradford W. Mott +// +// 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.1 2003-09-03 20:10:58 stephena Exp $ +//============================================================================ + +#include "Event.hxx" +#include "StellaEvent.hxx" +#include "EventHandler.hxx" +#include "MediaSrc.hxx" +#include "bspf.hxx" + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +EventHandler::EventHandler() +{ + // Create the event object which will be used for this handler + myEvent = new Event(); + + // Erase the KeyEvent array + for(Int32 i = 0; i < StellaEvent::LastKCODE; ++i) + { + keyTable[i].type = Event::LastType; + keyTable[i].message = ""; + } + + setDefaultKeyMapping(); + setDefaultJoyMapping(); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +EventHandler::~EventHandler() +{ +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Event* EventHandler::event() +{ + return myEvent; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void EventHandler::setMediaSource(MediaSource& mediaSource) +{ + myMediaSource = &mediaSource; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void EventHandler::sendKeyEvent(StellaEvent::KeyCode key, + StellaEvent::KeyState state) +{ + // Ignore unmapped keys + if(keyTable[key].type == Event::LastType) + return; + + if((keyTable[key].message != "") && (state == StellaEvent::KSTATE_PRESSED)) + myMediaSource->showMessage(keyTable[key].message, 120); + + myEvent->set(keyTable[key].type, state); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void EventHandler::setDefaultKeyMapping() +{ + keyTable[StellaEvent::KCODE_1].type = Event::KeyboardZero1; + keyTable[StellaEvent::KCODE_2].type = Event::KeyboardZero2; + keyTable[StellaEvent::KCODE_3].type = Event::KeyboardZero3; + keyTable[StellaEvent::KCODE_q].type = Event::KeyboardZero4; + keyTable[StellaEvent::KCODE_w].type = Event::KeyboardZero5; + keyTable[StellaEvent::KCODE_e].type = Event::KeyboardZero6; + keyTable[StellaEvent::KCODE_a].type = Event::KeyboardZero7; + keyTable[StellaEvent::KCODE_s].type = Event::KeyboardZero8; + keyTable[StellaEvent::KCODE_d].type = Event::KeyboardZero9; + keyTable[StellaEvent::KCODE_z].type = Event::KeyboardZeroStar; + keyTable[StellaEvent::KCODE_x].type = Event::KeyboardZero0; + keyTable[StellaEvent::KCODE_c].type = Event::KeyboardZeroPound; + + keyTable[StellaEvent::KCODE_8].type = Event::KeyboardOne1; + keyTable[StellaEvent::KCODE_9].type = Event::KeyboardOne2; + keyTable[StellaEvent::KCODE_0].type = Event::KeyboardOne3; + keyTable[StellaEvent::KCODE_i].type = Event::KeyboardOne4; + keyTable[StellaEvent::KCODE_o].type = Event::KeyboardOne5; + keyTable[StellaEvent::KCODE_p].type = Event::KeyboardOne6; + keyTable[StellaEvent::KCODE_k].type = Event::KeyboardOne7; + keyTable[StellaEvent::KCODE_l].type = Event::KeyboardOne8; + keyTable[StellaEvent::KCODE_SEMICOLON].type = Event::KeyboardOne9; + keyTable[StellaEvent::KCODE_COMMA].type = Event::KeyboardOneStar; + keyTable[StellaEvent::KCODE_PERIOD].type = Event::KeyboardOne0; + keyTable[StellaEvent::KCODE_SLASH].type = Event::KeyboardOnePound; + + keyTable[StellaEvent::KCODE_UP].type = Event::JoystickZeroUp; + keyTable[StellaEvent::KCODE_DOWN].type = Event::JoystickZeroDown; + keyTable[StellaEvent::KCODE_LEFT].type = Event::JoystickZeroLeft; + keyTable[StellaEvent::KCODE_RIGHT].type = Event::JoystickZeroRight; + keyTable[StellaEvent::KCODE_SPACE].type = Event::JoystickZeroFire; +// keyTable[StellaEvent::KCODE_].type = Event::BoosterGripZeroTrigger; +// keyTable[StellaEvent::KCODE_].type = Event::BoosterGripZeroBooster; + + keyTable[StellaEvent::KCODE_y].type = Event::JoystickOneUp; + keyTable[StellaEvent::KCODE_h].type = Event::JoystickOneDown; + keyTable[StellaEvent::KCODE_g].type = Event::JoystickOneLeft; + keyTable[StellaEvent::KCODE_j].type = Event::JoystickOneRight; + keyTable[StellaEvent::KCODE_f].type = Event::JoystickOneFire; +// keyTable[StellaEvent::KCODE_].type = Event::BoosterGripOneTrigger; +// keyTable[StellaEvent::KCODE_].type = Event::BoosterGripOneBooster; + + keyTable[StellaEvent::KCODE_F1].type = Event::ConsoleSelect; + keyTable[StellaEvent::KCODE_F2].type = Event::ConsoleReset; + keyTable[StellaEvent::KCODE_F3].type = Event::ConsoleColor; + keyTable[StellaEvent::KCODE_F4].type = Event::ConsoleBlackWhite; + keyTable[StellaEvent::KCODE_F5].type = Event::ConsoleLeftDifficultyA; + keyTable[StellaEvent::KCODE_F6].type = Event::ConsoleLeftDifficultyB; + keyTable[StellaEvent::KCODE_F7].type = Event::ConsoleRightDifficultyA; + keyTable[StellaEvent::KCODE_F8].type = Event::ConsoleRightDifficultyB; +// keyTable[StellaEvent::KCODE_F9].type = Event:: +// keyTable[StellaEvent::KCODE_F10].type = Event:: +// keyTable[StellaEvent::KCODE_F11].type = Event:: +// keyTable[StellaEvent::KCODE_F12].type = Event:: + + keyTable[StellaEvent::KCODE_F3].message = "Color Mode"; + keyTable[StellaEvent::KCODE_F4].message = "BW Mode"; + keyTable[StellaEvent::KCODE_F5].message = "Left Difficulty A"; + keyTable[StellaEvent::KCODE_F6].message = "Left Difficulty B"; + keyTable[StellaEvent::KCODE_F7].message = "Right Difficulty A"; + keyTable[StellaEvent::KCODE_F8].message = "Right Difficulty B"; + +#if 0 + DrivingZeroClockwise, DrivingZeroCounterClockwise, DrivingZeroFire, + DrivingOneClockwise, DrivingOneCounterClockwise, DrivingOneFire, +#endif +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void EventHandler::setDefaultJoyMapping() +{ +} diff --git a/stella/src/emucore/EventHandler.hxx b/stella/src/emucore/EventHandler.hxx new file mode 100644 index 000000000..a34c0a078 --- /dev/null +++ b/stella/src/emucore/EventHandler.hxx @@ -0,0 +1,98 @@ +//============================================================================ +// +// SSSS tt lll lll +// SS SS tt ll ll +// SS tttttt eeee ll ll aaaa +// SSSS tt ee ee ll ll aa +// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" +// SS SS tt ee ll ll aa aa +// SSSS ttt eeeee llll llll aaaaa +// +// Copyright (c) 1995-1998 by Bradford W. Mott +// +// 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.1 2003-09-03 20:10:58 stephena Exp $ +//============================================================================ + +#ifndef EVENTHANDLER_HXX +#define EVENTHANDLER_HXX + +#include "bspf.hxx" +#include "Event.hxx" +#include "StellaEvent.hxx" +#include "MediaSrc.hxx" + +/** + This class takes care of event remapping and dispatching for the + Stella core, as well as keeping track of the current 'mode'. + + The frontends will send translated events here, and the handler will + check to see what the current 'mode' is. For now, the modes can be + normal and remap. + + If in normal mode, events received from the frontends are remapped and + sent to the emulation core. If in remap mode, the events are sent + unchanged to the remap class, where key remapping can take place. + + @author Stephen Anthony + @version $Id: EventHandler.hxx,v 1.1 2003-09-03 20:10:58 stephena Exp $ +*/ +class EventHandler +{ + public: + /** + Create a new event handler object + */ + EventHandler(); + + /** + Destructor + */ + virtual ~EventHandler(); + + /** + Returns the event object associated with this handler class. + + @return The event object + */ + Event* event(); + + /** + Send a keyboard event to the handler. + + @param key The StellaEvent key + @param state The StellaEvent state (pressed or released) + */ + void sendKeyEvent(StellaEvent::KeyCode key, StellaEvent::KeyState state); + + /** + Set the mediasource. + + @param mediaSource The mediasource + */ + void setMediaSource(MediaSource& mediaSource); + + private: + void setDefaultKeyMapping(); + void setDefaultJoyMapping(); + + private: + struct KeyEvent + { + Event::Type type; + string message; + }; + + // Array of key events + KeyEvent keyTable[StellaEvent::LastKCODE]; + + // Global Event object + Event* myEvent; + + // Global mediasource object + MediaSource* myMediaSource; +}; + +#endif diff --git a/stella/src/emucore/StellaEvent.hxx b/stella/src/emucore/StellaEvent.hxx new file mode 100644 index 000000000..61be189fa --- /dev/null +++ b/stella/src/emucore/StellaEvent.hxx @@ -0,0 +1,74 @@ +//============================================================================ +// +// SSSS tt lll lll +// SS SS tt ll ll +// SS tttttt eeee ll ll aaaa +// SSSS tt ee ee ll ll aa +// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" +// SS SS tt ee ll ll aa aa +// SSSS ttt eeeee llll llll aaaaa +// +// Copyright (c) 1995-1998 by Bradford W. Mott +// +// See the file "license" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +// +// $Id: StellaEvent.hxx,v 1.1 2003-09-03 20:10:58 stephena Exp $ +//============================================================================ + +#ifndef STELLAEVENT_HXX +#define STELLAEVENT_HXX + +/** + This file defines the global STELLA events that the frontends + will use to communicate with the Event Handler. + + Only the standard keys are defined here. Function and + navigation (HOME, END, etc) keys are special and must be handled + by the frontends directly. + + @author Stephen Anthony + @version $Id: StellaEvent.hxx,v 1.1 2003-09-03 20:10:58 stephena Exp $ +*/ +class StellaEvent +{ + public: + /** + Enumeration of keyboard keycodes and states + */ + enum KeyCode + { + KCODE_a, KCODE_b, KCODE_c, KCODE_d, KCODE_e, KCODE_f, KCODE_g, KCODE_h, + KCODE_i, KCODE_j, KCODE_k, KCODE_l, KCODE_m, KCODE_n, KCODE_o, KCODE_p, + KCODE_q, KCODE_r, KCODE_s, KCODE_t, KCODE_u, KCODE_v, KCODE_w, KCODE_x, + KCODE_y, KCODE_z, + + KCODE_0, KCODE_1, KCODE_2, KCODE_3, KCODE_4, KCODE_5, KCODE_6, KCODE_7, + KCODE_8, KCODE_9, + + KCODE_KP0, KCODE_KP1, KCODE_KP2, KCODE_KP3, KCODE_KP4, KCODE_KP5, KCODE_KP6, + KCODE_KP7, KCODE_KP8, KCODE_KP9, KCODE_KP_PERIOD, KCODE_KP_DIVIDE, + KCODE_KP_MULTIPLY, KCODE_KP_MINUS, KCODE_KP_PLUS, KCODE_KP_ENTER, + KCODE_KP_EQUALS, + + KCODE_BACKSPACE, KCODE_TAB, KCODE_RETURN, KCODE_PAUSE, KCODE_ESCAPE, + KCODE_COMMA, KCODE_PERIOD, KCODE_SLASH, KCODE_SEMICOLON, KCODE_BACKSLASH, + KCODE_QUOTE, KCODE_LEFTBRACKET, KCODE_RIGHTBRACKET, KCODE_BACKQUOTE, + + KCODE_CTRL, KCODE_ALT, KCODE_UP, KCODE_DOWN, KCODE_LEFT, KCODE_RIGHT, + KCODE_SPACE, + + KCODE_F1, KCODE_F2, KCODE_F3, KCODE_F4, KCODE_F5, KCODE_F6, KCODE_F7, + KCODE_F8, KCODE_F9, KCODE_F10, KCODE_F11, KCODE_F12, + + LastKCODE + }; + + enum KeyState + { + KSTATE_RELEASED, KSTATE_PRESSED, + LastKSTATE + }; +}; + +#endif diff --git a/stella/src/ui/sdl/mainSDL.cxx b/stella/src/ui/sdl/mainSDL.cxx index c6b9d1980..1588a9ba7 100644 --- a/stella/src/ui/sdl/mainSDL.cxx +++ b/stella/src/ui/sdl/mainSDL.cxx @@ -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.41 2002-12-05 16:46:14 stephena Exp $ +// $Id: mainSDL.cxx,v 1.42 2003-09-03 20:10:58 stephena Exp $ //============================================================================ #include @@ -34,6 +34,8 @@ #include "bspf.hxx" #include "Console.hxx" #include "Event.hxx" +#include "StellaEvent.hxx" +#include "EventHandler.hxx" #include "MediaSrc.hxx" #include "PropsSet.hxx" #include "Sound.hxx" @@ -123,74 +125,108 @@ static RectList* rectList = (RectList*) NULL; struct Switches { SDLKey scanCode; - Event::Type eventCode; - string message; + StellaEvent::KeyCode keyCode; }; +// Place the most used keys first to speed up access static Switches list[] = { - { SDLK_1, Event::KeyboardZero1, "" }, - { SDLK_2, Event::KeyboardZero2, "" }, - { SDLK_3, Event::KeyboardZero3, "" }, - { SDLK_q, Event::KeyboardZero4, "" }, - { SDLK_w, Event::KeyboardZero5, "" }, - { SDLK_e, Event::KeyboardZero6, "" }, - { SDLK_a, Event::KeyboardZero7, "" }, - { SDLK_s, Event::KeyboardZero8, "" }, - { SDLK_d, Event::KeyboardZero9, "" }, - { SDLK_z, Event::KeyboardZeroStar, "" }, - { SDLK_x, Event::KeyboardZero0, "" }, - { SDLK_c, Event::KeyboardZeroPound, "" }, + { SDLK_F1, StellaEvent::KCODE_F1 }, + { SDLK_F2, StellaEvent::KCODE_F2 }, + { SDLK_F3, StellaEvent::KCODE_F3 }, + { SDLK_F4, StellaEvent::KCODE_F4 }, + { SDLK_F5, StellaEvent::KCODE_F5 }, + { SDLK_F6, StellaEvent::KCODE_F6 }, + { SDLK_F7, StellaEvent::KCODE_F7 }, + { SDLK_F8, StellaEvent::KCODE_F8 }, + { SDLK_F9, StellaEvent::KCODE_F9 }, + { SDLK_F10, StellaEvent::KCODE_F10 }, + { SDLK_F11, StellaEvent::KCODE_F11 }, + { SDLK_F12, StellaEvent::KCODE_F12 }, - { SDLK_8, Event::KeyboardOne1, "" }, - { SDLK_9, Event::KeyboardOne2, "" }, - { SDLK_0, Event::KeyboardOne3, "" }, - { SDLK_i, Event::KeyboardOne4, "" }, - { SDLK_o, Event::KeyboardOne5, "" }, - { SDLK_p, Event::KeyboardOne6, "" }, - { SDLK_k, Event::KeyboardOne7, "" }, - { SDLK_l, Event::KeyboardOne8, "" }, - { SDLK_SEMICOLON, Event::KeyboardOne9, "" }, - { SDLK_COMMA, Event::KeyboardOneStar, "" }, - { SDLK_PERIOD, Event::KeyboardOne0, "" }, - { SDLK_SLASH, Event::KeyboardOnePound, "" }, + { SDLK_UP, StellaEvent::KCODE_UP }, + { SDLK_DOWN, StellaEvent::KCODE_DOWN }, + { SDLK_LEFT, StellaEvent::KCODE_LEFT }, + { SDLK_RIGHT, StellaEvent::KCODE_RIGHT }, + { SDLK_SPACE, StellaEvent::KCODE_SPACE }, + { SDLK_LCTRL, StellaEvent::KCODE_CTRL }, + { SDLK_RCTRL, StellaEvent::KCODE_CTRL }, + { SDLK_LALT, StellaEvent::KCODE_ALT }, + { SDLK_RALT, StellaEvent::KCODE_ALT }, - { SDLK_UP, Event::JoystickZeroUp, "" }, - { SDLK_DOWN, Event::JoystickZeroDown, "" }, - { SDLK_LEFT, Event::JoystickZeroLeft, "" }, - { SDLK_RIGHT, Event::JoystickZeroRight, "" }, - { SDLK_SPACE, Event::JoystickZeroFire, "" }, - { SDLK_RETURN, Event::JoystickZeroFire, "" }, - { SDLK_LCTRL, Event::JoystickZeroFire, "" }, - { SDLK_z, Event::BoosterGripZeroTrigger, "" }, - { SDLK_x, Event::BoosterGripZeroBooster, "" }, + { SDLK_a, StellaEvent::KCODE_a }, + { SDLK_b, StellaEvent::KCODE_b }, + { SDLK_c, StellaEvent::KCODE_c }, + { SDLK_d, StellaEvent::KCODE_d }, + { SDLK_e, StellaEvent::KCODE_e }, + { SDLK_f, StellaEvent::KCODE_f }, + { SDLK_g, StellaEvent::KCODE_g }, + { SDLK_h, StellaEvent::KCODE_h }, + { SDLK_i, StellaEvent::KCODE_i }, + { SDLK_j, StellaEvent::KCODE_j }, + { SDLK_k, StellaEvent::KCODE_k }, + { SDLK_l, StellaEvent::KCODE_l }, + { SDLK_m, StellaEvent::KCODE_m }, + { SDLK_n, StellaEvent::KCODE_n }, + { SDLK_o, StellaEvent::KCODE_o }, + { SDLK_p, StellaEvent::KCODE_p }, + { SDLK_q, StellaEvent::KCODE_q }, + { SDLK_r, StellaEvent::KCODE_r }, + { SDLK_s, StellaEvent::KCODE_s }, + { SDLK_t, StellaEvent::KCODE_t }, + { SDLK_u, StellaEvent::KCODE_u }, + { SDLK_v, StellaEvent::KCODE_v }, + { SDLK_w, StellaEvent::KCODE_w }, + { SDLK_x, StellaEvent::KCODE_x }, + { SDLK_y, StellaEvent::KCODE_y }, + { SDLK_z, StellaEvent::KCODE_z }, - { SDLK_w, Event::JoystickZeroUp, "" }, - { SDLK_s, Event::JoystickZeroDown, "" }, - { SDLK_a, Event::JoystickZeroLeft, "" }, - { SDLK_d, Event::JoystickZeroRight, "" }, - { SDLK_TAB, Event::JoystickZeroFire, "" }, - { SDLK_1, Event::BoosterGripZeroTrigger, "" }, - { SDLK_2, Event::BoosterGripZeroBooster, "" }, + { SDLK_0, StellaEvent::KCODE_0 }, + { SDLK_1, StellaEvent::KCODE_1 }, + { SDLK_2, StellaEvent::KCODE_2 }, + { SDLK_3, StellaEvent::KCODE_3 }, + { SDLK_4, StellaEvent::KCODE_4 }, + { SDLK_5, StellaEvent::KCODE_5 }, + { SDLK_6, StellaEvent::KCODE_6 }, + { SDLK_7, StellaEvent::KCODE_7 }, + { SDLK_8, StellaEvent::KCODE_8 }, + { SDLK_9, StellaEvent::KCODE_9 }, - { SDLK_o, Event::JoystickOneUp, "" }, - { SDLK_l, Event::JoystickOneDown, "" }, - { SDLK_k, Event::JoystickOneLeft, "" }, - { SDLK_SEMICOLON, Event::JoystickOneRight, "" }, - { SDLK_j, Event::JoystickOneFire, "" }, - { SDLK_n, Event::BoosterGripOneTrigger, "" }, - { SDLK_m, Event::BoosterGripOneBooster, "" }, + { SDLK_KP0, StellaEvent::KCODE_KP0 }, + { SDLK_KP1, StellaEvent::KCODE_KP1 }, + { SDLK_KP2, StellaEvent::KCODE_KP2 }, + { SDLK_KP3, StellaEvent::KCODE_KP3 }, + { SDLK_KP4, StellaEvent::KCODE_KP4 }, + { SDLK_KP5, StellaEvent::KCODE_KP5 }, + { SDLK_KP6, StellaEvent::KCODE_KP6 }, + { SDLK_KP7, StellaEvent::KCODE_KP7 }, + { SDLK_KP8, StellaEvent::KCODE_KP8 }, + { SDLK_KP9, StellaEvent::KCODE_KP9 }, + { SDLK_KP_PERIOD, StellaEvent::KCODE_KP_PERIOD }, + { SDLK_KP_DIVIDE, StellaEvent::KCODE_KP_DIVIDE }, + { SDLK_KP_MULTIPLY, StellaEvent::KCODE_KP_MULTIPLY}, + { SDLK_KP_MINUS, StellaEvent::KCODE_KP_MINUS }, + { SDLK_KP_PLUS, StellaEvent::KCODE_KP_PLUS }, + { SDLK_KP_ENTER, StellaEvent::KCODE_KP_ENTER }, + { SDLK_KP_EQUALS, StellaEvent::KCODE_KP_EQUALS }, - { SDLK_F1, Event::ConsoleSelect, "" }, - { SDLK_F2, Event::ConsoleReset, "" }, - { SDLK_F3, Event::ConsoleColor, "Color Mode" }, - { SDLK_F4, Event::ConsoleBlackWhite, "BW Mode" }, - { SDLK_F5, Event::ConsoleLeftDifficultyA, "Left Difficulty A" }, - { SDLK_F6, Event::ConsoleLeftDifficultyB, "Left Difficulty B" }, - { SDLK_F7, Event::ConsoleRightDifficultyA, "Right Difficulty A" }, - { SDLK_F8, Event::ConsoleRightDifficultyB, "Right Difficulty B" } + { SDLK_BACKSPACE, StellaEvent::KCODE_BACKSPACE }, + { SDLK_TAB, StellaEvent::KCODE_TAB }, + { SDLK_RETURN, StellaEvent::KCODE_RETURN }, + { SDLK_PAUSE, StellaEvent::KCODE_PAUSE }, + { SDLK_ESCAPE, StellaEvent::KCODE_ESCAPE }, + { SDLK_COMMA, StellaEvent::KCODE_COMMA }, + { SDLK_PERIOD, StellaEvent::KCODE_PERIOD }, + { SDLK_SLASH, StellaEvent::KCODE_SLASH }, + { SDLK_BACKSLASH, StellaEvent::KCODE_BACKSLASH }, + { SDLK_SEMICOLON, StellaEvent::KCODE_SEMICOLON }, + { SDLK_QUOTE, StellaEvent::KCODE_QUOTE }, + { SDLK_BACKQUOTE, StellaEvent::KCODE_BACKQUOTE }, + { SDLK_LEFTBRACKET, StellaEvent::KCODE_LEFTBRACKET}, + { SDLK_RIGHTBRACKET,StellaEvent::KCODE_RIGHTBRACKET} }; -// Event objects to use +// Pointer to the event handler object or the null pointer +static EventHandler* theEventHandler; static Event theEvent; static Event keyboardEvent; @@ -1064,14 +1100,11 @@ void handleEvents() else // check all the other keys { for(unsigned int i = 0; i < sizeof(list) / sizeof(Switches); ++i) - { + { if(list[i].scanCode == key) { - theEvent.set(list[i].eventCode, 1); - keyboardEvent.set(list[i].eventCode, 1); - if(list[i].message != "") - theConsole->mediaSource().showMessage(list[i].message, - MESSAGE_INTERVAL * settings->theDesiredFrameRate); + theEventHandler->sendKeyEvent(list[i].keyCode, + StellaEvent::KSTATE_PRESSED); } } } @@ -1085,8 +1118,8 @@ void handleEvents() { if(list[i].scanCode == key) { - theEvent.set(list[i].eventCode, 0); - keyboardEvent.set(list[i].eventCode, 0); + theEventHandler->sendKeyEvent(list[i].keyCode, + StellaEvent::KSTATE_RELEASED); } } } @@ -1699,6 +1732,15 @@ int main(int argc, char* argv[]) return 0; } + // Create an event handler which will collect and dispatch event. + theEventHandler = new EventHandler(); + if(!theEventHandler) + { + delete[] image; + cleanup(); + return 0; + } + // Create a sound object for playing audio if(settings->theSoundDriver == "0") { @@ -1746,11 +1788,11 @@ int main(int argc, char* argv[]) // Create the 2600 game console for users or developers #ifdef DEVELOPER_SUPPORT theConsole = new Console(image, size, filename, - theEvent, propertiesSet, sound->getSampleRate(), + *(theEventHandler->event()), propertiesSet, sound->getSampleRate(), &settings->userDefinedProperties); #else theConsole = new Console(image, size, filename, - theEvent, propertiesSet, sound->getSampleRate()); + *(theEventHandler->event()), propertiesSet, sound->getSampleRate()); #endif // Free the image since we don't need it any longer @@ -1770,6 +1812,9 @@ int main(int argc, char* argv[]) return 0; } + // Let the event handler know about the mediasource + theEventHandler->setMediaSource(theConsole->mediaSource()); + // These variables are common to both timing options // and are needed to calculate the overall frames per second. uInt32 frameTime = 0, numberOfFrames = 0;