2001-12-27 19:54:36 +00:00
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// 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
|
|
|
|
//
|
2010-01-10 02:58:28 +00:00
|
|
|
// Copyright (c) 1995-2010 by Bradford W. Mott and the Stella team
|
2001-12-27 19:54:36 +00:00
|
|
|
//
|
|
|
|
// See the file "license" for information on usage and redistribution of
|
|
|
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
|
|
|
//
|
2009-05-13 13:55:40 +00:00
|
|
|
// $Id$
|
2001-12-27 19:54:36 +00:00
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
#ifndef PADDLES_HXX
|
|
|
|
#define PADDLES_HXX
|
|
|
|
|
|
|
|
#include "bspf.hxx"
|
|
|
|
#include "Control.hxx"
|
OK, another huge commit. I need to commit this now, because things are
starting to go out of sync on my development machines. OK, where to
begin ...
Changed state file format, so older state files will no longer work. The
changes aren't finalized yet, so expect more breakage.
Added getByte() and putByte() methods to serialized data, resulting in
smaller state files (previously, 1-byte values were stored as 4-byte ints).
Totally reworked controller handling code. Controller state is now
explicitly set with an ::update() method, making it easier to serialize.
Some work is still required on the serialization stuff for more advanced
controllers.
Added a 'Serializable' interface to all carts, device, controllers, etc
that can be (de)serialized. This fixes a long-standing design issue
which I personally caused many years ago.
Console switches state (SWCHB register) is now saved to state files.
Added beginnings of movie support. Basically, this saves an initial
state file, and thereafter continuously saves controller and console
switches state. Support is still somewhat rough and there's no UI for
it, but it does successfully save and later load/play state movies.
Removed specific events for driving controllers, and have them use
joystick events instead. This has the nice side effect that
joystick direction remapping 'just works' for driving controllers too.
Fixed issues with paddle emulation seen in 'Night Driver' ROM. Related
to this, removed a hack wrt paddles when grabmouse is enabled. There's
still some work to do when using the mouse to emulate paddles, but the
Stelladaptor and real paddles work fine.
Added beginnings of TrackBall CX-22 controller emulation. It doesn't
actually do anything yet, but the class is there :)
Probably some other stuff that I'm forgetting ...
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1385 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2007-10-03 21:41:19 +00:00
|
|
|
#include "Event.hxx"
|
2001-12-27 19:54:36 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
The standard Atari 2600 pair of paddle controllers.
|
|
|
|
|
|
|
|
@author Bradford W. Mott
|
2009-05-13 13:55:40 +00:00
|
|
|
@version $Id$
|
2001-12-27 19:54:36 +00:00
|
|
|
*/
|
|
|
|
class Paddles : public Controller
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
Create a new pair of paddle controllers plugged into the specified jack
|
|
|
|
|
2008-04-13 23:43:14 +00:00
|
|
|
@param jack The jack the controller is plugged into
|
|
|
|
@param event The event object to use for events
|
|
|
|
@param system The system using this controller
|
|
|
|
@param swap Whether to swap the paddles plugged into this jack
|
2001-12-27 19:54:36 +00:00
|
|
|
*/
|
2008-04-13 23:43:14 +00:00
|
|
|
Paddles(Jack jack, const Event& event, const System& system, bool swap);
|
2001-12-27 19:54:36 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Destructor
|
|
|
|
*/
|
|
|
|
virtual ~Paddles();
|
|
|
|
|
|
|
|
public:
|
|
|
|
/**
|
OK, another huge commit. I need to commit this now, because things are
starting to go out of sync on my development machines. OK, where to
begin ...
Changed state file format, so older state files will no longer work. The
changes aren't finalized yet, so expect more breakage.
Added getByte() and putByte() methods to serialized data, resulting in
smaller state files (previously, 1-byte values were stored as 4-byte ints).
Totally reworked controller handling code. Controller state is now
explicitly set with an ::update() method, making it easier to serialize.
Some work is still required on the serialization stuff for more advanced
controllers.
Added a 'Serializable' interface to all carts, device, controllers, etc
that can be (de)serialized. This fixes a long-standing design issue
which I personally caused many years ago.
Console switches state (SWCHB register) is now saved to state files.
Added beginnings of movie support. Basically, this saves an initial
state file, and thereafter continuously saves controller and console
switches state. Support is still somewhat rough and there's no UI for
it, but it does successfully save and later load/play state movies.
Removed specific events for driving controllers, and have them use
joystick events instead. This has the nice side effect that
joystick direction remapping 'just works' for driving controllers too.
Fixed issues with paddle emulation seen in 'Night Driver' ROM. Related
to this, removed a hack wrt paddles when grabmouse is enabled. There's
still some work to do when using the mouse to emulate paddles, but the
Stelladaptor and real paddles work fine.
Added beginnings of TrackBall CX-22 controller emulation. It doesn't
actually do anything yet, but the class is there :)
Probably some other stuff that I'm forgetting ...
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1385 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2007-10-03 21:41:19 +00:00
|
|
|
Update the entire digital and analog pin state according to the
|
|
|
|
events currently set.
|
2001-12-27 19:54:36 +00:00
|
|
|
*/
|
OK, another huge commit. I need to commit this now, because things are
starting to go out of sync on my development machines. OK, where to
begin ...
Changed state file format, so older state files will no longer work. The
changes aren't finalized yet, so expect more breakage.
Added getByte() and putByte() methods to serialized data, resulting in
smaller state files (previously, 1-byte values were stored as 4-byte ints).
Totally reworked controller handling code. Controller state is now
explicitly set with an ::update() method, making it easier to serialize.
Some work is still required on the serialization stuff for more advanced
controllers.
Added a 'Serializable' interface to all carts, device, controllers, etc
that can be (de)serialized. This fixes a long-standing design issue
which I personally caused many years ago.
Console switches state (SWCHB register) is now saved to state files.
Added beginnings of movie support. Basically, this saves an initial
state file, and thereafter continuously saves controller and console
switches state. Support is still somewhat rough and there's no UI for
it, but it does successfully save and later load/play state movies.
Removed specific events for driving controllers, and have them use
joystick events instead. This has the nice side effect that
joystick direction remapping 'just works' for driving controllers too.
Fixed issues with paddle emulation seen in 'Night Driver' ROM. Related
to this, removed a hack wrt paddles when grabmouse is enabled. There's
still some work to do when using the mouse to emulate paddles, but the
Stelladaptor and real paddles work fine.
Added beginnings of TrackBall CX-22 controller emulation. It doesn't
actually do anything yet, but the class is there :)
Probably some other stuff that I'm forgetting ...
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1385 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2007-10-03 21:41:19 +00:00
|
|
|
virtual void update();
|
2006-12-09 00:25:20 +00:00
|
|
|
|
2008-03-02 20:48:51 +00:00
|
|
|
/**
|
|
|
|
Sets the speed for digital emulation of paddle movement.
|
|
|
|
This is only used for *digital* events (ie, buttons or keys
|
|
|
|
generating paddle movement events); axis events from joysticks,
|
|
|
|
Stelladaptors or the mouse are not modified.
|
|
|
|
*/
|
|
|
|
static void setDigitalSpeed(int speed) { _PADDLE_SPEED = speed; }
|
|
|
|
|
2008-03-22 17:35:03 +00:00
|
|
|
/**
|
|
|
|
Sets the mouse to emulate the paddle 'number' in the X or Y
|
|
|
|
axis. X -> dir 0, Y -> dir 1
|
|
|
|
*/
|
|
|
|
static void setMouseIsPaddle(int number, int dir = 0);
|
|
|
|
|
2006-12-09 00:25:20 +00:00
|
|
|
private:
|
OK, another huge commit. I need to commit this now, because things are
starting to go out of sync on my development machines. OK, where to
begin ...
Changed state file format, so older state files will no longer work. The
changes aren't finalized yet, so expect more breakage.
Added getByte() and putByte() methods to serialized data, resulting in
smaller state files (previously, 1-byte values were stored as 4-byte ints).
Totally reworked controller handling code. Controller state is now
explicitly set with an ::update() method, making it easier to serialize.
Some work is still required on the serialization stuff for more advanced
controllers.
Added a 'Serializable' interface to all carts, device, controllers, etc
that can be (de)serialized. This fixes a long-standing design issue
which I personally caused many years ago.
Console switches state (SWCHB register) is now saved to state files.
Added beginnings of movie support. Basically, this saves an initial
state file, and thereafter continuously saves controller and console
switches state. Support is still somewhat rough and there's no UI for
it, but it does successfully save and later load/play state movies.
Removed specific events for driving controllers, and have them use
joystick events instead. This has the nice side effect that
joystick direction remapping 'just works' for driving controllers too.
Fixed issues with paddle emulation seen in 'Night Driver' ROM. Related
to this, removed a hack wrt paddles when grabmouse is enabled. There's
still some work to do when using the mouse to emulate paddles, but the
Stelladaptor and real paddles work fine.
Added beginnings of TrackBall CX-22 controller emulation. It doesn't
actually do anything yet, but the class is there :)
Probably some other stuff that I'm forgetting ...
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1385 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2007-10-03 21:41:19 +00:00
|
|
|
// Pre-compute the events we care about based on given port
|
|
|
|
// This will eliminate test for left or right port in update()
|
Large number of changes related to controller input and handling.
Moved a lot of the code into the respective Controller classes, in the
process cleaning up the EventHandler (which was starting to get a little
unwieldy).
I've borrowed some code and ideas from z26, but also improved on it as
well:
1) Stelladaptor devices now send their events directly to a
controller class, allowing for any Stelladaptor device to emulate
a controller (to the limits of the input device, of course).
2) Hopefully fixed Stelladaptor driving controller support. Eckhard,
could you test this, since I don't have any of those myself?
3) Improved interaction with different input devices. For example,
a Stelladaptor, mouse, joystick (digital and/or analog axis), and
the keyboard can now simulate paddle events at the same time. So it
shouldn't matter what input devices you have plugged in; things should
'just work'. In the case of Stelladaptor paddles, you may have to
'zero' them by turning completely left, however.
4) Related to (3), changed mouse events to use relative motion. This
should fix the issues with paddle emulation/movement behaving
differently based on the window size.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1412 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2008-03-02 19:20:50 +00:00
|
|
|
Event::Type myP0AxisValue, myP1AxisValue,
|
|
|
|
myP0DecEvent1, myP0DecEvent2, myP0IncEvent1, myP0IncEvent2,
|
|
|
|
myP1DecEvent1, myP1DecEvent2, myP1IncEvent1, myP1IncEvent2,
|
|
|
|
myP0FireEvent1, myP0FireEvent2, myP1FireEvent1, myP1FireEvent2;
|
|
|
|
|
|
|
|
int myKeyRepeat0;
|
|
|
|
int myPaddleRepeat0;
|
|
|
|
int myKeyRepeat1;
|
|
|
|
int myPaddleRepeat1;
|
|
|
|
|
|
|
|
int myCharge[2];
|
|
|
|
int myLastCharge[2];
|
|
|
|
int myLeftMotion[2];
|
|
|
|
|
2008-03-02 20:48:51 +00:00
|
|
|
static int _PADDLE_SPEED;
|
2008-03-22 17:35:03 +00:00
|
|
|
static int _MOUSEX_PADDLE;
|
|
|
|
static int _MOUSEY_PADDLE;
|
|
|
|
|
|
|
|
// Lookup table for associating paddle buttons with controller pins
|
|
|
|
// Yes, this is hideously complex
|
|
|
|
static const Controller::DigitalPin ourButtonPin[2];
|
2001-12-27 19:54:36 +00:00
|
|
|
};
|
|
|
|
|
2005-11-12 22:59:20 +00:00
|
|
|
#endif
|