added QuadTari support for joysticks

added autodetection for QuadTari
This commit is contained in:
Thomas Jentzsch 2020-09-01 14:34:53 +02:00
parent f19792a9e2
commit 5e72e980c9
5 changed files with 47 additions and 10 deletions

View File

@ -37,6 +37,8 @@
are no longer corrupted/cut off. This includes properly supporting the are no longer corrupted/cut off. This includes properly supporting the
2600-daptor II, which is flashable to an AVox-USB converter. 2600-daptor II, which is flashable to an AVox-USB converter.
* Added QuadTari controller support for josticks (TODO: doc, settings etc.)
* Added option to select the audio device. * Added option to select the audio device.
* Added option to display detected settings info when a ROM is loaded. * Added option to display detected settings info when a ROM is loaded.

View File

@ -110,7 +110,7 @@ string Controller::getName(const Type type)
"AmigaMouse", "AtariMouse", "AtariVox", "BoosterGrip", "CompuMate", "AmigaMouse", "AtariMouse", "AtariVox", "BoosterGrip", "CompuMate",
"Driving", "Sega Genesis", "Joystick", "Keyboard", "KidVid", "MindLink", "Driving", "Sega Genesis", "Joystick", "Keyboard", "KidVid", "MindLink",
"Paddles", "Paddles_IAxis", "Paddles_IAxDr", "SaveKey", "TrakBall", "Paddles", "Paddles_IAxis", "Paddles_IAxDr", "SaveKey", "TrakBall",
"Lightgun" "Lightgun", "QuadTari"
}; };
return NAMES[int(type)]; return NAMES[int(type)];

View File

@ -62,6 +62,10 @@ Controller::Type ControllerDetector::autodetectPort(
if(isProbablySaveKey(image, size, port)) if(isProbablySaveKey(image, size, port))
type = Controller::Type::SaveKey; type = Controller::Type::SaveKey;
else if(isProbablyQuadTari(image, size, port))
{
type = Controller::Type::QuadTari;
}
else if(usesJoystickButton(image, size, port)) else if(usesJoystickButton(image, size, port))
{ {
if(isProbablyTrakBall(image, size)) if(isProbablyTrakBall(image, size))
@ -693,3 +697,21 @@ bool ControllerDetector::isProbablyLightGun(const ByteBuffer& image, size_t size
return false; return false;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool ControllerDetector::isProbablyQuadTari(const ByteBuffer& image, size_t size,
Controller::Jack port)
{
if(port == Controller::Jack::Left)
{
uInt8 signature[] = { 'Q', 'U', 'A', 'D', 'L' };
return searchForBytes(image, size, signature, 5);
}
else if(port == Controller::Jack::Right)
{
uInt8 signature[] = { 'Q', 'U', 'A', 'D', 'R' };
return searchForBytes(image, size, signature, 5);
}
}

View File

@ -16,6 +16,9 @@
//============================================================================ //============================================================================
#include "Event.hxx" #include "Event.hxx"
#include "System.hxx"
#include "TIA.hxx"
#include "FrameBuffer.hxx"
#include "Joystick.hxx" #include "Joystick.hxx"
#include "QuadTari.hxx" #include "QuadTari.hxx"
@ -23,7 +26,7 @@
QuadTari::QuadTari(Jack jack, const Event& event, const System& system) QuadTari::QuadTari(Jack jack, const Event& event, const System& system)
: Controller(jack, event, system, Controller::Type::QuadTari) : Controller(jack, event, system, Controller::Type::QuadTari)
{ {
// TODO: allow multiple controller types // TODO: support multiple controller types
if(myJack == Jack::Left) if(myJack == Jack::Left)
{ {
myFirstController = make_unique<Joystick>(Jack::Left, event, system); myFirstController = make_unique<Joystick>(Jack::Left, event, system);
@ -34,6 +37,9 @@ QuadTari::QuadTari(Jack jack, const Event& event, const System& system)
myFirstController = make_unique<Joystick>(Jack::Right, event, system); myFirstController = make_unique<Joystick>(Jack::Right, event, system);
mySecondController = make_unique<Joystick>(Jack::Left, event, system); // TODO: use P3 mapping mySecondController = make_unique<Joystick>(Jack::Left, event, system); // TODO: use P3 mapping
} }
// QuadTari auto detection setting
setPin(AnalogPin::Five, MIN_RESISTANCE);
setPin(AnalogPin::Nine, MAX_RESISTANCE);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -43,8 +49,11 @@ bool QuadTari::read(DigitalPin pin)
// can switch the controller multiple times per frame // can switch the controller multiple times per frame
// (we can't just read 60 times per second in the ::update() method) // (we can't just read 60 times per second in the ::update() method)
if(true) // TODO handle controller switch // If bit 7 of VBlank is not set, read first, else second controller
if(!(mySystem.tia().registerValue(VBLANK) & 0x80))
return myFirstController->read(pin); return myFirstController->read(pin);
else
return mySecondController->read(pin);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -54,20 +63,25 @@ void QuadTari::update()
mySecondController->update(); mySecondController->update();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string QuadTari::name() const
{
return "QuadTari (" + myFirstController->name() + "/" + mySecondController->name() + ")";
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool QuadTari::isAnalog() const bool QuadTari::isAnalog() const
{ {
// TODO: does this work? // For now, use mouse for first controller only
return myFirstController->isAnalog() || mySecondController->isAnalog(); return myFirstController->isAnalog();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool QuadTari::setMouseControl( bool QuadTari::setMouseControl(
Controller::Type xtype, int xid, Controller::Type ytype, int yid) Controller::Type xtype, int xid, Controller::Type ytype, int yid)
{ {
// TODO: does this work? // Use mouse for first controller only (TODO: support multiple controller types)
myFirstController->setMouseControl(xtype, xid, ytype, yid); myFirstController->setMouseControl(Controller::Type::Joystick, xid, Controller::Type::Joystick, yid);
mySecondController->setMouseControl(xtype, xid, ytype, yid);
return true; return true;
} }

View File

@ -57,9 +57,8 @@ class QuadTari: public Controller
/** /**
Returns the name of this controller. Returns the name of this controller.
// TODO: Or the names of the attached controllers?
*/ */
string name() const override { return "QuadTari"; } string name() const override;
/** /**
Answers whether the controller is intrinsically an analog controller. Answers whether the controller is intrinsically an analog controller.