2001-12-27 19:54:36 +00:00
|
|
|
//============================================================================
|
|
|
|
//
|
2016-12-30 00:00:30 +00:00
|
|
|
// SSSS tt lll lll
|
|
|
|
// SS SS tt ll ll
|
|
|
|
// SS tttttt eeee ll ll aaaa
|
2001-12-27 19:54:36 +00:00
|
|
|
// 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
|
|
|
|
//
|
2019-12-31 17:18:56 +00:00
|
|
|
// Copyright (c) 1995-2020 by Bradford W. Mott, Stephen Anthony
|
2010-04-10 21:37:23 +00:00
|
|
|
// and the Stella Team
|
2001-12-27 19:54:36 +00:00
|
|
|
//
|
2010-01-10 03:23:32 +00:00
|
|
|
// See the file "License.txt" for information on usage and redistribution of
|
2001-12-27 19:54:36 +00:00
|
|
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
#ifndef DRIVING_HXX
|
|
|
|
#define DRIVING_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 Indy 500 driving controller.
|
|
|
|
|
|
|
|
@author Bradford W. Mott
|
|
|
|
*/
|
|
|
|
class Driving : public Controller
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
2016-12-30 00:00:30 +00:00
|
|
|
Create a new Indy 500 driving controller plugged into
|
2001-12-27 19:54:36 +00:00
|
|
|
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
|
2001-12-27 19:54:36 +00:00
|
|
|
*/
|
2008-04-13 23:43:14 +00:00
|
|
|
Driving(Jack jack, const Event& event, const System& system);
|
2015-12-29 21:28:10 +00:00
|
|
|
virtual ~Driving() = default;
|
2001-12-27 19:54:36 +00:00
|
|
|
|
|
|
|
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
|
|
|
*/
|
2015-07-10 18:59:03 +00:00
|
|
|
void update() override;
|
2001-12-27 19:54:36 +00:00
|
|
|
|
2019-03-29 23:17:24 +00:00
|
|
|
/**
|
|
|
|
Returns the name of this controller.
|
|
|
|
*/
|
|
|
|
string name() const override { return "Driving"; }
|
|
|
|
|
2018-03-17 22:33:05 +00:00
|
|
|
/**
|
|
|
|
Answers whether the controller is intrinsically an analog controller.
|
|
|
|
*/
|
|
|
|
bool isAnalog() const override { return true; }
|
|
|
|
|
2011-12-26 21:40:28 +00:00
|
|
|
/**
|
|
|
|
Determines how this controller will treat values received from the
|
2012-01-22 21:01:13 +00:00
|
|
|
X/Y axis and left/right buttons of the mouse. Since not all controllers
|
2012-04-19 13:00:02 +00:00
|
|
|
use the mouse the same way (or at all), it's up to the specific class to
|
|
|
|
decide how to use this data.
|
2012-01-22 21:01:13 +00:00
|
|
|
|
|
|
|
In the current implementation, the left button is tied to the X axis,
|
|
|
|
and the right one tied to the Y axis.
|
2011-12-26 21:40:28 +00:00
|
|
|
|
2012-04-19 13:00:02 +00:00
|
|
|
@param xtype The controller to use for x-axis data
|
|
|
|
@param xid The controller ID to use for x-axis data (-1 for no id)
|
|
|
|
@param ytype The controller to use for y-axis data
|
|
|
|
@param yid The controller ID to use for y-axis data (-1 for no id)
|
|
|
|
|
|
|
|
@return Whether the controller supports using the mouse
|
2011-12-26 21:40:28 +00:00
|
|
|
*/
|
2012-04-19 13:00:02 +00:00
|
|
|
bool setMouseControl(
|
2015-07-10 18:59:03 +00:00
|
|
|
Controller::Type xtype, int xid, Controller::Type ytype, int yid) override;
|
2011-12-26 21:40:28 +00:00
|
|
|
|
2020-04-05 17:55:45 +00:00
|
|
|
/**
|
|
|
|
Sets the sensitivity for digital emulation of driving controlle movement
|
|
|
|
using a keyboard.
|
|
|
|
|
|
|
|
@param sensitivity Value from 1 to 20, with larger values causing
|
|
|
|
more movement (10 represents the baseline)
|
|
|
|
*/
|
|
|
|
static void setSensitivity(int sensitivity);
|
|
|
|
|
2001-12-27 19:54:36 +00:00
|
|
|
private:
|
|
|
|
// Counter to iterate through the gray codes
|
2020-04-05 17:55:45 +00:00
|
|
|
Int32 myCounter{0};
|
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
|
|
|
|
2008-03-03 16:27:16 +00:00
|
|
|
// Index into the gray code table
|
2019-12-29 22:06:56 +00:00
|
|
|
uInt32 myGrayIndex{0};
|
2008-03-03 16:27:16 +00:00
|
|
|
|
|
|
|
// Y axis value from last yaxis event that was used to generate a new
|
|
|
|
// gray code
|
2019-12-29 22:06:56 +00:00
|
|
|
int myLastYaxis{0};
|
2008-03-03 16:27:16 +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
|
|
|
// Pre-compute the events we care about based on given port
|
|
|
|
// This will eliminate test for left or right port in update()
|
2011-05-06 14:29:39 +00:00
|
|
|
Event::Type myCWEvent, myCCWEvent, myFireEvent,
|
2013-05-07 18:53:21 +00:00
|
|
|
myXAxisValue, myYAxisValue;
|
2011-12-26 21:40:28 +00:00
|
|
|
|
2012-04-19 13:00:02 +00:00
|
|
|
// Controller to emulate in normal mouse axis mode
|
2019-12-29 22:06:56 +00:00
|
|
|
int myControlID{-1};
|
2012-01-29 17:33:36 +00:00
|
|
|
|
2012-04-19 13:00:02 +00:00
|
|
|
// Controllers to emulate in 'specific' mouse axis mode
|
2019-12-29 22:06:56 +00:00
|
|
|
int myControlIDX{-1}, myControlIDY{-1};
|
2015-04-26 19:02:42 +00:00
|
|
|
|
2020-04-05 17:55:45 +00:00
|
|
|
// User-defined sensitivity; adjustable since end-users may prefer different
|
|
|
|
// speeds
|
|
|
|
static float SENSITIVITY;
|
|
|
|
|
2015-04-26 19:02:42 +00:00
|
|
|
private:
|
|
|
|
// Following constructors and assignment operators not supported
|
|
|
|
Driving() = delete;
|
|
|
|
Driving(const Driving&) = delete;
|
|
|
|
Driving(Driving&&) = delete;
|
|
|
|
Driving& operator=(const Driving&) = delete;
|
|
|
|
Driving& operator=(Driving&&) = delete;
|
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
|
|
|
#endif
|