diff --git a/src/emucore/QuadTari.cxx b/src/emucore/QuadTari.cxx new file mode 100644 index 000000000..55adf8c53 --- /dev/null +++ b/src/emucore/QuadTari.cxx @@ -0,0 +1,73 @@ +//============================================================================ +// +// 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-2020 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. +//============================================================================ + +#include "Event.hxx" +#include "Joystick.hxx" +#include "QuadTari.hxx" + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +QuadTari::QuadTari(Jack jack, const Event& event, const System& system) + : Controller(jack, event, system, Controller::Type::QuadTari) +{ + // TODO: allow multiple controller types + if(myJack == Jack::Left) + { + myFirstController = make_unique(Jack::Left, event, system); + mySecondController = make_unique(Jack::Right, event, system); // TODO: use P2 mapping + } + else + { + myFirstController = make_unique(Jack::Right, event, system); + mySecondController = make_unique(Jack::Left, event, system); // TODO: use P3 mapping + } +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool QuadTari::read(DigitalPin pin) +{ + // We need to override the Controller::read() method, since the QuadTari + // can switch the controller multiple times per frame + // (we can't just read 60 times per second in the ::update() method) + + if(true) // TODO handle controller switch + return myFirstController->read(pin); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void QuadTari::update() +{ + myFirstController->update(); + mySecondController->update(); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool QuadTari::isAnalog() const +{ + // TODO: does this work? + return myFirstController->isAnalog() || mySecondController->isAnalog(); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool QuadTari::setMouseControl( + Controller::Type xtype, int xid, Controller::Type ytype, int yid) +{ + // TODO: does this work? + myFirstController->setMouseControl(xtype, xid, ytype, yid); + mySecondController->setMouseControl(xtype, xid, ytype, yid); + + return true; +} diff --git a/src/emucore/QuadTari.hxx b/src/emucore/QuadTari.hxx new file mode 100644 index 000000000..2499c5c2a --- /dev/null +++ b/src/emucore/QuadTari.hxx @@ -0,0 +1,102 @@ +//============================================================================ +// +// 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-2020 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. +//============================================================================ + +#ifndef QUADTARI_HXX +#define QUADTARI_HXX + +#include "Control.hxx" +#include "Event.hxx" + +/** + The QuadTari controller. + + @author Thomas Jentzsch +*/ +class QuadTari: public Controller +{ + public: + /** + Create a QuadTari controller 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 + */ + QuadTari(Jack jack, const Event& event, const System& system); + ~QuadTari() override = default; + + public: + /** + Read the value of the specified digital pin for this controller. + + @param pin The pin of the controller jack to read + @return The state of the pin + */ + bool read(DigitalPin pin) override; + + /** + Update the entire digital and analog pin state according to the + events currently set. + */ + void update() override; + + /** + Returns the name of this controller. + // TODO: Or the names of the attached controllers? + */ + string name() const override { return "QuadTari"; } + + /** + Answers whether the controller is intrinsically an analog controller. + TODO: Depends on the attached controllers. + */ + bool isAnalog() const override; + + /** + 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 + */ + bool setMouseControl( + Controller::Type xtype, int xid, Controller::Type ytype, int yid) override; + + private: + unique_ptr myFirstController; + unique_ptr mySecondController; + + private: + // Following constructors and assignment operators not supported + QuadTari() = delete; + QuadTari(const QuadTari&) = delete; + QuadTari(QuadTari&&) = delete; + QuadTari& operator=(const QuadTari&) = delete; + QuadTari& operator=(QuadTari&&) = delete; + }; + +#endif diff --git a/src/emucore/module.mk b/src/emucore/module.mk index 71bd33847..b7d88d331 100644 --- a/src/emucore/module.mk +++ b/src/emucore/module.mk @@ -1,95 +1,96 @@ MODULE := src/emucore MODULE_OBJS := \ - src/emucore/AtariVox.o \ - src/emucore/Bankswitch.o \ - src/emucore/Booster.o \ - src/emucore/Cart.o \ - src/emucore/CartCreator.o \ - src/emucore/CartDetector.o \ - src/emucore/CartEnhanced.o \ - src/emucore/Cart0840.o \ - src/emucore/Cart2K.o \ - src/emucore/Cart3E.o \ - src/emucore/Cart3EPlus.o \ - src/emucore/Cart3EX.o \ - src/emucore/Cart3F.o \ - src/emucore/Cart4A50.o \ - src/emucore/Cart4K.o \ - src/emucore/Cart4KSC.o \ - src/emucore/CartAR.o \ - src/emucore/CartBUS.o \ - src/emucore/CartCDF.o \ - src/emucore/CartCM.o \ - src/emucore/CartCTY.o \ - src/emucore/CartCV.o \ - src/emucore/CartDPC.o \ - src/emucore/CartDPCPlus.o \ - src/emucore/CartE0.o \ - src/emucore/CartMNetwork.o \ - src/emucore/CartE7.o \ - src/emucore/CartE78K.o \ - src/emucore/CartEF.o \ - src/emucore/CartEFSC.o \ - src/emucore/CartBF.o \ - src/emucore/CartBFSC.o \ - src/emucore/CartDF.o \ - src/emucore/CartDFSC.o \ - src/emucore/CartF0.o \ - src/emucore/CartF4.o \ - src/emucore/CartF4SC.o \ - src/emucore/CartF6.o \ - src/emucore/CartF6SC.o \ - src/emucore/CartF8.o \ - src/emucore/CartF8SC.o \ - src/emucore/CartFA.o \ - src/emucore/CartFA2.o \ - src/emucore/CartFC.o \ - src/emucore/CartFE.o \ - src/emucore/CartMDM.o \ - src/emucore/CartSB.o \ - src/emucore/CartTVBoy.o \ - src/emucore/CartUA.o \ - src/emucore/CartWD.o \ - src/emucore/CartX07.o \ - src/emucore/CompuMate.o \ - src/emucore/Console.o \ - src/emucore/Control.o \ - src/emucore/ControllerDetector.o \ - src/emucore/DispatchResult.o \ - src/emucore/Driving.o \ - src/emucore/EventHandler.o \ - src/emucore/EmulationTiming.o \ - src/emucore/EmulationWorker.o \ - src/emucore/FrameBuffer.o \ - src/emucore/FBSurface.o \ - src/emucore/FSNode.o \ - src/emucore/Genesis.o \ - src/emucore/Joystick.o \ - src/emucore/Keyboard.o \ - src/emucore/KidVid.o \ - src/emucore/Lightgun.o \ - src/emucore/MindLink.o \ - src/emucore/M6502.o \ - src/emucore/M6532.o \ - src/emucore/MT24LC256.o \ - src/emucore/MD5.o \ - src/emucore/OSystem.o \ - src/emucore/Paddles.o \ - src/emucore/PointingDevice.o \ - src/emucore/ProfilingRunner.o \ - src/emucore/Props.o \ - src/emucore/PropsSet.o \ - src/emucore/SaveKey.o \ - src/emucore/Serializer.o \ - src/emucore/Settings.o \ - src/emucore/Switches.o \ - src/emucore/System.o \ - src/emucore/TIASurface.o \ - src/emucore/Thumbulator.o + src/emucore/AtariVox.o \ + src/emucore/Bankswitch.o \ + src/emucore/Booster.o \ + src/emucore/Cart.o \ + src/emucore/CartCreator.o \ + src/emucore/CartDetector.o \ + src/emucore/CartEnhanced.o \ + src/emucore/Cart0840.o \ + src/emucore/Cart2K.o \ + src/emucore/Cart3E.o \ + src/emucore/Cart3EPlus.o \ + src/emucore/Cart3EX.o \ + src/emucore/Cart3F.o \ + src/emucore/Cart4A50.o \ + src/emucore/Cart4K.o \ + src/emucore/Cart4KSC.o \ + src/emucore/CartAR.o \ + src/emucore/CartBUS.o \ + src/emucore/CartCDF.o \ + src/emucore/CartCM.o \ + src/emucore/CartCTY.o \ + src/emucore/CartCV.o \ + src/emucore/CartDPC.o \ + src/emucore/CartDPCPlus.o \ + src/emucore/CartE0.o \ + src/emucore/CartMNetwork.o \ + src/emucore/CartE7.o \ + src/emucore/CartE78K.o \ + src/emucore/CartEF.o \ + src/emucore/CartEFSC.o \ + src/emucore/CartBF.o \ + src/emucore/CartBFSC.o \ + src/emucore/CartDF.o \ + src/emucore/CartDFSC.o \ + src/emucore/CartF0.o \ + src/emucore/CartF4.o \ + src/emucore/CartF4SC.o \ + src/emucore/CartF6.o \ + src/emucore/CartF6SC.o \ + src/emucore/CartF8.o \ + src/emucore/CartF8SC.o \ + src/emucore/CartFA.o \ + src/emucore/CartFA2.o \ + src/emucore/CartFC.o \ + src/emucore/CartFE.o \ + src/emucore/CartMDM.o \ + src/emucore/CartSB.o \ + src/emucore/CartTVBoy.o \ + src/emucore/CartUA.o \ + src/emucore/CartWD.o \ + src/emucore/CartX07.o \ + src/emucore/CompuMate.o \ + src/emucore/Console.o \ + src/emucore/Control.o \ + src/emucore/ControllerDetector.o \ + src/emucore/DispatchResult.o \ + src/emucore/Driving.o \ + src/emucore/EventHandler.o \ + src/emucore/EmulationTiming.o \ + src/emucore/EmulationWorker.o \ + src/emucore/FrameBuffer.o \ + src/emucore/FBSurface.o \ + src/emucore/FSNode.o \ + src/emucore/Genesis.o \ + src/emucore/Joystick.o \ + src/emucore/Keyboard.o \ + src/emucore/KidVid.o \ + src/emucore/Lightgun.o \ + src/emucore/MindLink.o \ + src/emucore/M6502.o \ + src/emucore/M6532.o \ + src/emucore/MT24LC256.o \ + src/emucore/MD5.o \ + src/emucore/OSystem.o \ + src/emucore/Paddles.o \ + src/emucore/PointingDevice.o \ + src/emucore/ProfilingRunner.o \ + src/emucore/Props.o \ + src/emucore/PropsSet.o \ + src/emucore/QuadTari.o \ + src/emucore/SaveKey.o \ + src/emucore/Serializer.o \ + src/emucore/Settings.o \ + src/emucore/Switches.o \ + src/emucore/System.o \ + src/emucore/TIASurface.o \ + src/emucore/Thumbulator.o MODULE_DIRS += \ - src/emucore + src/emucore # Include common rules include $(srcdir)/common.rules