2008-05-12 22:40:26 +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
|
2008-05-12 22:40:26 +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
|
|
|
|
//
|
2016-12-30 00:00:30 +00:00
|
|
|
// Copyright (c) 1995-2017 by Bradford W. Mott, Stephen Anthony
|
2010-04-10 21:37:23 +00:00
|
|
|
// and the Stella Team
|
2008-05-12 22:40:26 +00:00
|
|
|
//
|
2010-01-10 03:23:32 +00:00
|
|
|
// See the file "License.txt" for information on usage and redistribution of
|
2008-05-12 22:40:26 +00:00
|
|
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
|
|
|
//============================================================================
|
|
|
|
|
2017-02-12 00:37:42 +00:00
|
|
|
#ifndef ATARIMOUSE_HXX
|
|
|
|
#define ATARIMOUSE_HXX
|
2008-05-12 22:40:26 +00:00
|
|
|
|
|
|
|
#include "bspf.hxx"
|
|
|
|
#include "Control.hxx"
|
|
|
|
#include "Event.hxx"
|
|
|
|
|
|
|
|
/**
|
2017-02-12 00:37:42 +00:00
|
|
|
Trakball-like controller emulating the Atari ST mouse.
|
|
|
|
This code was heavily borrowed from z26.
|
2008-05-12 22:40:26 +00:00
|
|
|
|
|
|
|
@author Stephen Anthony & z26 team
|
|
|
|
*/
|
2017-02-12 00:37:42 +00:00
|
|
|
class AtariMouse : public Controller
|
2008-05-12 22:40:26 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
2017-02-12 00:37:42 +00:00
|
|
|
Create a new AtariMouse controller plugged into the specified jack
|
2008-05-12 22:40:26 +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
|
|
|
|
*/
|
2017-02-12 00:37:42 +00:00
|
|
|
AtariMouse(Jack jack, const Event& event, const System& system);
|
|
|
|
virtual ~AtariMouse() = default;
|
2008-05-12 22:40:26 +00:00
|
|
|
|
|
|
|
public:
|
2012-10-24 10:10:32 +00:00
|
|
|
using Controller::read;
|
|
|
|
|
2008-05-12 22:40:26 +00:00
|
|
|
/**
|
2012-01-02 16:37:17 +00:00
|
|
|
Read the entire state of all digital pins for this controller.
|
2012-01-28 15:19:41 +00:00
|
|
|
Note that this method must use the lower 4 bits, and zero the upper bits.
|
2012-01-02 16:37:17 +00:00
|
|
|
|
|
|
|
@return The state of all digital pins
|
2008-05-12 22:40:26 +00:00
|
|
|
*/
|
2015-07-10 18:59:03 +00:00
|
|
|
uInt8 read() override;
|
2008-05-12 22:40:26 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Update the entire digital and analog pin state according to the
|
|
|
|
events currently set.
|
|
|
|
*/
|
2015-07-10 18:59:03 +00:00
|
|
|
void update() override;
|
2008-05-12 22:40:26 +00:00
|
|
|
|
2012-04-19 13:00:02 +00:00
|
|
|
/**
|
|
|
|
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 the same way (or at all), it's up to the specific class to
|
|
|
|
decide how to use this data.
|
|
|
|
|
|
|
|
In the current implementation, the left button is tied to the X axis,
|
|
|
|
and the right one tied to the Y axis.
|
|
|
|
|
|
|
|
@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
|
|
|
|
*/
|
2015-07-10 18:59:03 +00:00
|
|
|
bool setMouseControl(Controller::Type xtype, int xid,
|
|
|
|
Controller::Type ytype, int yid) override;
|
2012-04-19 13:00:02 +00:00
|
|
|
|
2008-05-12 22:40:26 +00:00
|
|
|
private:
|
|
|
|
// Counter to iterate through the gray codes
|
|
|
|
int myHCounter, myVCounter;
|
|
|
|
|
|
|
|
// How many new horizontal and vertical values this frame
|
|
|
|
int myTrakBallCountH, myTrakBallCountV;
|
|
|
|
|
|
|
|
// How many lines to wait before sending new horz and vert val
|
|
|
|
int myTrakBallLinesH, myTrakBallLinesV;
|
|
|
|
|
|
|
|
// Was TrakBall moved left or moved right instead
|
|
|
|
int myTrakBallLeft;
|
|
|
|
|
|
|
|
// Was TrakBall moved down or moved up instead
|
|
|
|
int myTrakBallDown;
|
|
|
|
|
|
|
|
int myScanCountH, myScanCountV, myCountH, myCountV;
|
|
|
|
|
2012-04-19 13:00:02 +00:00
|
|
|
// Whether to use the mouse to emulate this controller
|
2016-01-25 21:16:04 +00:00
|
|
|
int myMouseEnabled;
|
2012-04-19 13:00:02 +00:00
|
|
|
|
2015-04-26 19:02:42 +00:00
|
|
|
private:
|
|
|
|
// Following constructors and assignment operators not supported
|
2017-02-12 00:37:42 +00:00
|
|
|
AtariMouse() = delete;
|
|
|
|
AtariMouse(const AtariMouse&) = delete;
|
|
|
|
AtariMouse(AtariMouse&&) = delete;
|
|
|
|
AtariMouse& operator=(const AtariMouse&) = delete;
|
|
|
|
AtariMouse& operator=(AtariMouse&&) = delete;
|
2008-05-12 22:40:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|