stella/src/emucore/Paddles.hxx

140 lines
4.6 KiB
C++
Raw Normal View History

//============================================================================
//
// 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-2012 by Bradford W. Mott, Stephen Anthony
// and the Stella Team
//
// See the file "License.txt" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id$
//============================================================================
#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"
/**
The standard Atari 2600 pair of paddle controllers.
@author Bradford W. Mott
@version $Id$
*/
class Paddles : public Controller
{
public:
/**
Create a new pair of paddle controllers plugged into the specified jack
@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 swappaddle Whether to swap the paddles plugged into this jack
@param swapaxis Whether to swap the axis on the paddle (x <-> y)
@param swapdir Whether to swap the direction for which an axis
causes movement (lesser axis values cause paddle
resistance to decrease instead of increase)
*/
Paddles(Jack jack, const Event& event, const System& system,
bool swappaddle, bool swapaxis, bool swapdir);
/**
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.
*/
void update();
/**
Determines how this controller will treat values received from the
X/Y axis and left/right buttons of the mouse. Since not all controllers
use the mouse, it's up to the specific class to decide how to use this data.
If either of the axis is set to 'Automatic', then we automatically
use the ctrlID for the control type.
In the current implementation, the left button is tied to the X axis,
and the right one tied to the Y axis.
@param xaxis How the controller should use x-axis data
@param yaxis How the controller should use y-axis data
@param ctrlID The controller ID to use axis 'auto' mode
*/
void setMouseControl(
MouseControl::Axis xaxis, MouseControl::Axis yaxis, int ctrlID = -1);
/**
Sets the sensitivity for digital emulation of paddle movement.
This is only used for *digital* events (ie, buttons or keys,
or digital joystick axis events); Stelladaptors or the mouse are
not modified.
@param sensitivity Value from 1 to 10, with larger values
causing more movement
*/
static void setDigitalSensitivity(int sensitivity);
/**
Sets the sensitivity for analog emulation of paddle movement
using a mouse.
@param sensitivity Value from 1 to 10, with larger values
causing more movement
*/
static void setMouseSensitivity(int sensitivity);
private:
// Range of values over which digital and mouse movement is scaled
// to paddle resistance
enum {
TRIGRANGE = 4096,
TRIGMAX = 3856,
TRIGMIN = 1
};
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()
Event::Type myP0AxisValue, myP1AxisValue,
myP0DecEvent1, myP0DecEvent2, myP0IncEvent1, myP0IncEvent2,
myP1DecEvent1, myP1DecEvent2, myP1IncEvent1, myP1IncEvent2,
myP0FireEvent1, myP0FireEvent2, myP1FireEvent1, myP1FireEvent2,
myAxisMouseMotion;
// The following are used for the various mouse-axis modes
int myMPaddleID; // paddle to emulate in 'automatic' mode
int myMPaddleIDX, myMPaddleIDY; // paddles to emulate in 'specific axis' mode
bool myKeyRepeat0, myKeyRepeat1;
int myPaddleRepeat0, myPaddleRepeat1;
int myCharge[2], myLastCharge[2];
int myLastAxisX, myLastAxisY;
int myAxisDigitalZero, myAxisDigitalOne;
bool mySwapPorts;
static int _DIGITAL_SENSITIVITY, _DIGITAL_DISTANCE;
static int _MOUSE_SENSITIVITY;
// Lookup table for associating paddle buttons with controller pins
// Yes, this is hideously complex
static const Controller::DigitalPin ourButtonPin[2];
};
#endif