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
This commit is contained in:
stephena 2003-09-03 20:10:58 +00:00
parent ec407e7c60
commit f8cf40361c
5 changed files with 505 additions and 150 deletions

View File

@ -13,7 +13,7 @@
## See the file "license" for information on usage and redistribution of ## See the file "license" for information on usage and redistribution of
## this file, and for a DISCLAIMER OF ALL WARRANTIES. ## this file, and for a DISCLAIMER OF ALL WARRANTIES.
## ##
## $Id: makefile,v 1.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. ## Comment a line out to disable that option, remove comment to enable it.
##============================================================================ ##============================================================================
OPTIMIZATIONS = -O2 -Wall -Wno-unused OPTIMIZATIONS = $(CXXFLAGS) -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
### which sound drivers to compile for the X11 and SDL versions ### which sound drivers to compile for the X11 and SDL versions
### OSS is most compatible, SDL for platforms where OSS not available ### OSS is most compatible, SDL for platforms where OSS not available
@ -56,12 +44,12 @@ SOUND_OSS = 1
# DEBUG = 1 # DEBUG = 1
### to include joystick support in the X11 and SDL versions ### 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 ### to include support for saving snapshots in png format
### (requires PNG library) ### (requires PNG library)
### Only X11 and SDL ports supported for now ### Only X11 and SDL ports supported for now
# SNAPSHOT_SUPPORT = 1 SNAPSHOT_SUPPORT = 1
### comment this out if your system doesn't ### comment this out if your system doesn't
### have the gettimeofday function ### 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 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 ## set the user-defined options
ifdef BSPF_BOOL ifdef BSPF_BOOL
@ -131,11 +119,11 @@ endif
ifdef SNAPSHOT_SUPPORT ifdef SNAPSHOT_SUPPORT
OBJS.X11 += Snapshot.o OBJS.X11 += Snapshot.o
OPTS.X11 += -DHAVE_PNG=1 OPTS.X11 += -DHAVE_PNG=1
LIBS.X11 += -lpng LIBS.X11 += -lpng -lz
OBJS.SDL += Snapshot.o OBJS.SDL += Snapshot.o
OPTS.SDL += -DHAVE_PNG=1 OPTS.SDL += -DHAVE_PNG=1
LIBS.SDL += -lpng LIBS.SDL += -lpng -lz
endif endif
ifdef HAVE_GETTIMEOFDAY 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 \ CartMB.o Console.o Control.o Driving.o \
Event.o Joystick.o Keyboard.o M6532.o MD5.o MediaSrc.o Paddles.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 \ 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) $(M6502_OBJS)
stella.exe: $(CORE_OBJS) $(OBJS) stella.exe: $(CORE_OBJS) $(OBJS)
@ -317,184 +305,187 @@ cleanall: clean
rm -f M6502Low.ins M6502Hi.ins rm -f M6502Low.ins M6502Hi.ins
Driving.o: $(CORE)/Driving.cxx Driving.o: $(CORE)/Driving.cxx
$(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/Driving.cxx $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/Driving.cxx
Event.o: $(CORE)/Event.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 Control.o: $(CORE)/Control.cxx
$(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/Control.cxx $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/Control.cxx
Joystick.o: $(CORE)/Joystick.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 Keyboard.o: $(CORE)/Keyboard.cxx
$(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/Keyboard.cxx $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/Keyboard.cxx
Paddles.o: $(CORE)/Paddles.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 Booster.o: $(CORE)/Booster.cxx
$(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/Booster.cxx $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/Booster.cxx
Cart.o: $(CORE)/Cart.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 Cart2K.o: $(CORE)/Cart2K.cxx
$(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/Cart2K.cxx $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/Cart2K.cxx
Cart3F.o: $(CORE)/Cart3F.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 Cart4K.o: $(CORE)/Cart4K.cxx
$(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/Cart4K.cxx $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/Cart4K.cxx
CartAR.o: $(CORE)/CartAR.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 CartDPC.o: $(CORE)/CartDPC.cxx
$(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/CartDPC.cxx $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/CartDPC.cxx
CartE0.o: $(CORE)/CartE0.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 CartE7.o: $(CORE)/CartE7.cxx
$(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/CartE7.cxx $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/CartE7.cxx
CartF4.o: $(CORE)/CartF4.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 CartF4SC.o: $(CORE)/CartF4SC.cxx
$(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/CartF4SC.cxx $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/CartF4SC.cxx
CartF6.o: $(CORE)/CartF6.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 CartF6SC.o: $(CORE)/CartF6SC.cxx
$(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/CartF6SC.cxx $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/CartF6SC.cxx
CartF8.o: $(CORE)/CartF8.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 CartF8SC.o: $(CORE)/CartF8SC.cxx
$(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/CartF8SC.cxx $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/CartF8SC.cxx
CartFASC.o: $(CORE)/CartFASC.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 CartFE.o: $(CORE)/CartFE.cxx
$(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/CartFE.cxx $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/CartFE.cxx
CartMC.o: $(CORE)/CartMC.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 CartMB.o: $(CORE)/CartMB.cxx
$(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/CartMB.cxx $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/CartMB.cxx
CartCV.o: $(CORE)/CartCV.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 M6532.o: $(CORE)/M6532.cxx
$(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/M6532.cxx $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/M6532.cxx
TIA.o: $(CORE)/TIA.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 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 Console.o: $(CORE)/Console.cxx
$(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/Console.cxx $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/Console.cxx
MD5.o: $(CORE)/MD5.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 MediaSrc.o: $(CORE)/MediaSrc.cxx
$(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/MediaSrc.cxx $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/MediaSrc.cxx
PropsSet.o: $(CORE)/PropsSet.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 Props.o: $(CORE)/Props.cxx
$(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/Props.cxx $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/Props.cxx
Random.o: $(CORE)/Random.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 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 Switches.o: $(CORE)/Switches.cxx
$(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/Switches.cxx $(CXX) -c $(FLAGS) $(OPTIONS) $(CORE)/Switches.cxx
Serializer.o: $(CORE)/Serializer.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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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

View File

@ -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()
{
}

View File

@ -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

View File

@ -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

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: mainSDL.cxx,v 1.41 2002-12-05 16:46:14 stephena Exp $ // $Id: mainSDL.cxx,v 1.42 2003-09-03 20:10:58 stephena Exp $
//============================================================================ //============================================================================
#include <fstream> #include <fstream>
@ -34,6 +34,8 @@
#include "bspf.hxx" #include "bspf.hxx"
#include "Console.hxx" #include "Console.hxx"
#include "Event.hxx" #include "Event.hxx"
#include "StellaEvent.hxx"
#include "EventHandler.hxx"
#include "MediaSrc.hxx" #include "MediaSrc.hxx"
#include "PropsSet.hxx" #include "PropsSet.hxx"
#include "Sound.hxx" #include "Sound.hxx"
@ -123,74 +125,108 @@ static RectList* rectList = (RectList*) NULL;
struct Switches struct Switches
{ {
SDLKey scanCode; SDLKey scanCode;
Event::Type eventCode; StellaEvent::KeyCode keyCode;
string message;
}; };
// Place the most used keys first to speed up access
static Switches list[] = { static Switches list[] = {
{ SDLK_1, Event::KeyboardZero1, "" }, { SDLK_F1, StellaEvent::KCODE_F1 },
{ SDLK_2, Event::KeyboardZero2, "" }, { SDLK_F2, StellaEvent::KCODE_F2 },
{ SDLK_3, Event::KeyboardZero3, "" }, { SDLK_F3, StellaEvent::KCODE_F3 },
{ SDLK_q, Event::KeyboardZero4, "" }, { SDLK_F4, StellaEvent::KCODE_F4 },
{ SDLK_w, Event::KeyboardZero5, "" }, { SDLK_F5, StellaEvent::KCODE_F5 },
{ SDLK_e, Event::KeyboardZero6, "" }, { SDLK_F6, StellaEvent::KCODE_F6 },
{ SDLK_a, Event::KeyboardZero7, "" }, { SDLK_F7, StellaEvent::KCODE_F7 },
{ SDLK_s, Event::KeyboardZero8, "" }, { SDLK_F8, StellaEvent::KCODE_F8 },
{ SDLK_d, Event::KeyboardZero9, "" }, { SDLK_F9, StellaEvent::KCODE_F9 },
{ SDLK_z, Event::KeyboardZeroStar, "" }, { SDLK_F10, StellaEvent::KCODE_F10 },
{ SDLK_x, Event::KeyboardZero0, "" }, { SDLK_F11, StellaEvent::KCODE_F11 },
{ SDLK_c, Event::KeyboardZeroPound, "" }, { SDLK_F12, StellaEvent::KCODE_F12 },
{ SDLK_8, Event::KeyboardOne1, "" }, { SDLK_UP, StellaEvent::KCODE_UP },
{ SDLK_9, Event::KeyboardOne2, "" }, { SDLK_DOWN, StellaEvent::KCODE_DOWN },
{ SDLK_0, Event::KeyboardOne3, "" }, { SDLK_LEFT, StellaEvent::KCODE_LEFT },
{ SDLK_i, Event::KeyboardOne4, "" }, { SDLK_RIGHT, StellaEvent::KCODE_RIGHT },
{ SDLK_o, Event::KeyboardOne5, "" }, { SDLK_SPACE, StellaEvent::KCODE_SPACE },
{ SDLK_p, Event::KeyboardOne6, "" }, { SDLK_LCTRL, StellaEvent::KCODE_CTRL },
{ SDLK_k, Event::KeyboardOne7, "" }, { SDLK_RCTRL, StellaEvent::KCODE_CTRL },
{ SDLK_l, Event::KeyboardOne8, "" }, { SDLK_LALT, StellaEvent::KCODE_ALT },
{ SDLK_SEMICOLON, Event::KeyboardOne9, "" }, { SDLK_RALT, StellaEvent::KCODE_ALT },
{ SDLK_COMMA, Event::KeyboardOneStar, "" },
{ SDLK_PERIOD, Event::KeyboardOne0, "" },
{ SDLK_SLASH, Event::KeyboardOnePound, "" },
{ SDLK_UP, Event::JoystickZeroUp, "" }, { SDLK_a, StellaEvent::KCODE_a },
{ SDLK_DOWN, Event::JoystickZeroDown, "" }, { SDLK_b, StellaEvent::KCODE_b },
{ SDLK_LEFT, Event::JoystickZeroLeft, "" }, { SDLK_c, StellaEvent::KCODE_c },
{ SDLK_RIGHT, Event::JoystickZeroRight, "" }, { SDLK_d, StellaEvent::KCODE_d },
{ SDLK_SPACE, Event::JoystickZeroFire, "" }, { SDLK_e, StellaEvent::KCODE_e },
{ SDLK_RETURN, Event::JoystickZeroFire, "" }, { SDLK_f, StellaEvent::KCODE_f },
{ SDLK_LCTRL, Event::JoystickZeroFire, "" }, { SDLK_g, StellaEvent::KCODE_g },
{ SDLK_z, Event::BoosterGripZeroTrigger, "" }, { SDLK_h, StellaEvent::KCODE_h },
{ SDLK_x, Event::BoosterGripZeroBooster, "" }, { 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_0, StellaEvent::KCODE_0 },
{ SDLK_s, Event::JoystickZeroDown, "" }, { SDLK_1, StellaEvent::KCODE_1 },
{ SDLK_a, Event::JoystickZeroLeft, "" }, { SDLK_2, StellaEvent::KCODE_2 },
{ SDLK_d, Event::JoystickZeroRight, "" }, { SDLK_3, StellaEvent::KCODE_3 },
{ SDLK_TAB, Event::JoystickZeroFire, "" }, { SDLK_4, StellaEvent::KCODE_4 },
{ SDLK_1, Event::BoosterGripZeroTrigger, "" }, { SDLK_5, StellaEvent::KCODE_5 },
{ SDLK_2, Event::BoosterGripZeroBooster, "" }, { 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_KP0, StellaEvent::KCODE_KP0 },
{ SDLK_l, Event::JoystickOneDown, "" }, { SDLK_KP1, StellaEvent::KCODE_KP1 },
{ SDLK_k, Event::JoystickOneLeft, "" }, { SDLK_KP2, StellaEvent::KCODE_KP2 },
{ SDLK_SEMICOLON, Event::JoystickOneRight, "" }, { SDLK_KP3, StellaEvent::KCODE_KP3 },
{ SDLK_j, Event::JoystickOneFire, "" }, { SDLK_KP4, StellaEvent::KCODE_KP4 },
{ SDLK_n, Event::BoosterGripOneTrigger, "" }, { SDLK_KP5, StellaEvent::KCODE_KP5 },
{ SDLK_m, Event::BoosterGripOneBooster, "" }, { 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_BACKSPACE, StellaEvent::KCODE_BACKSPACE },
{ SDLK_F2, Event::ConsoleReset, "" }, { SDLK_TAB, StellaEvent::KCODE_TAB },
{ SDLK_F3, Event::ConsoleColor, "Color Mode" }, { SDLK_RETURN, StellaEvent::KCODE_RETURN },
{ SDLK_F4, Event::ConsoleBlackWhite, "BW Mode" }, { SDLK_PAUSE, StellaEvent::KCODE_PAUSE },
{ SDLK_F5, Event::ConsoleLeftDifficultyA, "Left Difficulty A" }, { SDLK_ESCAPE, StellaEvent::KCODE_ESCAPE },
{ SDLK_F6, Event::ConsoleLeftDifficultyB, "Left Difficulty B" }, { SDLK_COMMA, StellaEvent::KCODE_COMMA },
{ SDLK_F7, Event::ConsoleRightDifficultyA, "Right Difficulty A" }, { SDLK_PERIOD, StellaEvent::KCODE_PERIOD },
{ SDLK_F8, Event::ConsoleRightDifficultyB, "Right Difficulty B" } { 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 theEvent;
static Event keyboardEvent; static Event keyboardEvent;
@ -1067,11 +1103,8 @@ void handleEvents()
{ {
if(list[i].scanCode == key) if(list[i].scanCode == key)
{ {
theEvent.set(list[i].eventCode, 1); theEventHandler->sendKeyEvent(list[i].keyCode,
keyboardEvent.set(list[i].eventCode, 1); StellaEvent::KSTATE_PRESSED);
if(list[i].message != "")
theConsole->mediaSource().showMessage(list[i].message,
MESSAGE_INTERVAL * settings->theDesiredFrameRate);
} }
} }
} }
@ -1085,8 +1118,8 @@ void handleEvents()
{ {
if(list[i].scanCode == key) if(list[i].scanCode == key)
{ {
theEvent.set(list[i].eventCode, 0); theEventHandler->sendKeyEvent(list[i].keyCode,
keyboardEvent.set(list[i].eventCode, 0); StellaEvent::KSTATE_RELEASED);
} }
} }
} }
@ -1699,6 +1732,15 @@ int main(int argc, char* argv[])
return 0; 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 // Create a sound object for playing audio
if(settings->theSoundDriver == "0") if(settings->theSoundDriver == "0")
{ {
@ -1746,11 +1788,11 @@ int main(int argc, char* argv[])
// Create the 2600 game console for users or developers // Create the 2600 game console for users or developers
#ifdef DEVELOPER_SUPPORT #ifdef DEVELOPER_SUPPORT
theConsole = new Console(image, size, filename, theConsole = new Console(image, size, filename,
theEvent, propertiesSet, sound->getSampleRate(), *(theEventHandler->event()), propertiesSet, sound->getSampleRate(),
&settings->userDefinedProperties); &settings->userDefinedProperties);
#else #else
theConsole = new Console(image, size, filename, theConsole = new Console(image, size, filename,
theEvent, propertiesSet, sound->getSampleRate()); *(theEventHandler->event()), propertiesSet, sound->getSampleRate());
#endif #endif
// Free the image since we don't need it any longer // Free the image since we don't need it any longer
@ -1770,6 +1812,9 @@ int main(int argc, char* argv[])
return 0; return 0;
} }
// Let the event handler know about the mediasource
theEventHandler->setMediaSource(theConsole->mediaSource());
// These variables are common to both timing options // These variables are common to both timing options
// and are needed to calculate the overall frames per second. // and are needed to calculate the overall frames per second.
uInt32 frameTime = 0, numberOfFrames = 0; uInt32 frameTime = 0, numberOfFrames = 0;