2012-01-02 16:37:17 +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
|
2012-01-02 16:37:17 +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
|
2012-01-02 16:37:17 +00:00
|
|
|
// 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 "MindLink.hxx"
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
MindLink::MindLink(Jack jack, const Event& event, const System& system)
|
2019-12-29 22:06:56 +00:00
|
|
|
: Controller(jack, event, system, Controller::Type::MindLink)
|
2012-01-02 16:37:17 +00:00
|
|
|
{
|
2019-03-29 23:17:24 +00:00
|
|
|
setPin(DigitalPin::One, true);
|
|
|
|
setPin(DigitalPin::Two, true);
|
|
|
|
setPin(DigitalPin::Three, true);
|
|
|
|
setPin(DigitalPin::Four, true);
|
2012-01-02 16:37:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void MindLink::update()
|
|
|
|
{
|
2019-03-29 23:17:24 +00:00
|
|
|
setPin(DigitalPin::One, true);
|
|
|
|
setPin(DigitalPin::Two, true);
|
|
|
|
setPin(DigitalPin::Three, true);
|
|
|
|
setPin(DigitalPin::Four, true);
|
2012-03-25 14:42:09 +00:00
|
|
|
|
2012-04-19 13:00:02 +00:00
|
|
|
if(!myMouseEnabled)
|
|
|
|
return;
|
|
|
|
|
2012-01-02 16:37:17 +00:00
|
|
|
myMindlinkPos = (myMindlinkPos & 0x3fffffff) +
|
2019-12-30 16:27:28 +00:00
|
|
|
(myEvent.get(Event::MouseAxisXMove) << 3);
|
2012-01-02 16:37:17 +00:00
|
|
|
if(myMindlinkPos < 0x2800)
|
|
|
|
myMindlinkPos = 0x2800;
|
|
|
|
if(myMindlinkPos >= 0x3800)
|
|
|
|
myMindlinkPos = 0x3800;
|
|
|
|
|
|
|
|
myMindlinkShift = 1;
|
|
|
|
nextMindlinkBit();
|
|
|
|
|
2012-01-22 21:01:13 +00:00
|
|
|
if(myEvent.get(Event::MouseButtonLeftValue) ||
|
|
|
|
myEvent.get(Event::MouseButtonRightValue))
|
2012-03-25 14:42:09 +00:00
|
|
|
myMindlinkPos |= 0x4000; // this bit starts a game
|
2012-01-02 16:37:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void MindLink::nextMindlinkBit()
|
|
|
|
{
|
2019-03-29 23:17:24 +00:00
|
|
|
if(getPin(DigitalPin::One))
|
2012-01-02 16:37:17 +00:00
|
|
|
{
|
2019-03-29 23:17:24 +00:00
|
|
|
setPin(DigitalPin::Three, false);
|
|
|
|
setPin(DigitalPin::Four, false);
|
2012-01-02 16:37:17 +00:00
|
|
|
if(myMindlinkPos & myMindlinkShift)
|
2019-03-29 23:17:24 +00:00
|
|
|
setPin(DigitalPin::Four, true);
|
2012-01-02 16:37:17 +00:00
|
|
|
myMindlinkShift <<= 1;
|
|
|
|
}
|
|
|
|
}
|
2012-04-19 13:00:02 +00:00
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
bool MindLink::setMouseControl(
|
|
|
|
Controller::Type xtype, int xid, Controller::Type ytype, int yid)
|
|
|
|
{
|
|
|
|
// Currently, the mindlink takes full control of the mouse, but only ever
|
|
|
|
// uses the x-axis, and both mouse buttons for the single mindlink button
|
|
|
|
// As well, there's no separate setting for x and y axis, so any
|
|
|
|
// combination of Controller and id is valid
|
|
|
|
myMouseEnabled = (xtype == myType || ytype == myType) &&
|
|
|
|
(xid != -1 || yid != -1);
|
|
|
|
return true;
|
|
|
|
}
|