2012-01-22 21:01:13 +00:00
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// 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$
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
#include "Console.hxx"
|
|
|
|
#include "Control.hxx"
|
|
|
|
#include "Props.hxx"
|
|
|
|
|
|
|
|
#include "MouseControl.hxx"
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
MouseControl::MouseControl(Console& console, const string& mode)
|
|
|
|
: myProps(console.properties()),
|
|
|
|
myLeftController(console.controller(Controller::Left)),
|
|
|
|
myRightController(console.controller(Controller::Right)),
|
|
|
|
myCurrentModeNum(0)
|
|
|
|
{
|
2012-01-29 17:08:51 +00:00
|
|
|
if(BSPF_equalsIgnoreCase(mode, "never"))
|
2012-01-22 21:01:13 +00:00
|
|
|
{
|
2012-01-29 17:08:51 +00:00
|
|
|
myModeList.push_back(MouseMode("Mouse input is disabled"));
|
2012-01-22 21:01:13 +00:00
|
|
|
return;
|
|
|
|
}
|
2012-01-29 17:08:51 +00:00
|
|
|
else if(!BSPF_equalsIgnoreCase(mode, "auto") && mode.length() == 2 &&
|
|
|
|
mode[0] >= '0' && mode[0] <= '5' &&
|
|
|
|
mode[1] >= '0' && mode[1] <= '5')
|
|
|
|
{
|
|
|
|
Axis xaxis = (Axis) ((int)mode[0] - '0');
|
|
|
|
Axis yaxis = (Axis) ((int)mode[1] - '0');
|
|
|
|
ostringstream msg;
|
|
|
|
msg << "Mouse X-axis is ";
|
|
|
|
switch(xaxis)
|
|
|
|
{
|
|
|
|
case Paddle0:
|
|
|
|
msg << "Paddle 0"; break;
|
|
|
|
case Paddle1:
|
|
|
|
msg << "Paddle 1"; break;
|
|
|
|
case Paddle2:
|
|
|
|
msg << "Paddle 2"; break;
|
|
|
|
case Paddle3:
|
|
|
|
msg << "Paddle 3"; break;
|
|
|
|
case Driving0:
|
|
|
|
msg << "Driving 0"; break;
|
|
|
|
case Driving1:
|
|
|
|
msg << "Driving 1"; break;
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
msg << ", Y-axis is ";
|
|
|
|
switch(yaxis)
|
|
|
|
{
|
|
|
|
case Paddle0:
|
|
|
|
msg << "Paddle 0"; break;
|
|
|
|
case Paddle1:
|
|
|
|
msg << "Paddle 1"; break;
|
|
|
|
case Paddle2:
|
|
|
|
msg << "Paddle 2"; break;
|
|
|
|
case Paddle3:
|
|
|
|
msg << "Paddle 3"; break;
|
|
|
|
case Driving0:
|
|
|
|
msg << "Driving 0"; break;
|
|
|
|
case Driving1:
|
|
|
|
msg << "Driving 1"; break;
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
myModeList.push_back(MouseMode(xaxis, yaxis, -1, msg.str()));
|
|
|
|
}
|
2012-01-22 21:01:13 +00:00
|
|
|
|
2012-01-29 17:08:51 +00:00
|
|
|
// Now consider the possible modes for the mouse based on the left
|
2012-01-22 21:01:13 +00:00
|
|
|
// and right controllers
|
2012-01-29 17:08:51 +00:00
|
|
|
bool noswap = BSPF_equalsIgnoreCase(myProps.get(Console_SwapPorts), "NO");
|
|
|
|
if(noswap)
|
|
|
|
{
|
|
|
|
addLeftControllerModes(noswap);
|
|
|
|
addRightControllerModes(noswap);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
addRightControllerModes(noswap);
|
|
|
|
addLeftControllerModes(noswap);
|
|
|
|
}
|
|
|
|
|
|
|
|
// If the mouse isn't used at all, we still need one item in the list
|
|
|
|
if(myModeList.size() == 0)
|
|
|
|
myModeList.push_back(MouseMode("Mouse not used for current controllers"));
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
MouseControl::~MouseControl()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
const string& MouseControl::next()
|
|
|
|
{
|
|
|
|
const MouseMode& mode = myModeList[myCurrentModeNum];
|
|
|
|
myCurrentModeNum = (myCurrentModeNum + 1) % myModeList.size();
|
|
|
|
|
|
|
|
myLeftController.setMouseControl(mode.xaxis, mode.yaxis, mode.controlID);
|
|
|
|
myRightController.setMouseControl(mode.xaxis, mode.yaxis, mode.controlID);
|
|
|
|
|
|
|
|
return mode.message;
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void MouseControl::addLeftControllerModes(bool noswap)
|
|
|
|
{
|
2012-01-22 21:01:13 +00:00
|
|
|
switch(myLeftController.type())
|
|
|
|
{
|
|
|
|
case Controller::Joystick:
|
|
|
|
case Controller::BoosterGrip:
|
|
|
|
case Controller::Genesis:
|
|
|
|
case Controller::Driving:
|
|
|
|
case Controller::TrackBall22:
|
|
|
|
case Controller::TrackBall80:
|
|
|
|
case Controller::AmigaMouse:
|
|
|
|
// case Controller::Mindlink:
|
|
|
|
{
|
|
|
|
ostringstream msg;
|
|
|
|
msg << "Mouse is left " << myLeftController.name() << " controller";
|
2012-01-29 17:08:51 +00:00
|
|
|
myModeList.push_back(MouseMode(Automatic, Automatic, noswap ? 0 : 1, msg.str()));
|
2012-01-22 21:01:13 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Controller::Paddles:
|
2012-01-29 17:08:51 +00:00
|
|
|
if(noswap) addPaddleModes(0, 1, 0, 1);
|
|
|
|
else addPaddleModes(2, 3, 0, 1);
|
2012-01-22 21:01:13 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2012-01-29 17:08:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void MouseControl::addRightControllerModes(bool noswap)
|
|
|
|
{
|
2012-01-22 21:01:13 +00:00
|
|
|
switch(myRightController.type())
|
|
|
|
{
|
|
|
|
case Controller::Joystick:
|
|
|
|
case Controller::BoosterGrip:
|
|
|
|
case Controller::Genesis:
|
|
|
|
case Controller::Driving:
|
|
|
|
case Controller::TrackBall22:
|
|
|
|
case Controller::TrackBall80:
|
|
|
|
case Controller::AmigaMouse:
|
|
|
|
// case Controller::Mindlink:
|
|
|
|
{
|
|
|
|
ostringstream msg;
|
|
|
|
msg << "Mouse is right " << myRightController.name() << " controller";
|
2012-01-29 17:08:51 +00:00
|
|
|
myModeList.push_back(MouseMode(Automatic, Automatic, noswap ? 1 : 0, msg.str()));
|
2012-01-22 21:01:13 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Controller::Paddles:
|
2012-01-29 17:08:51 +00:00
|
|
|
if(noswap) addPaddleModes(2, 3, 2, 3);
|
|
|
|
else addPaddleModes(0, 1, 2, 3);
|
2012-01-22 21:01:13 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2012-01-29 17:08:51 +00:00
|
|
|
void MouseControl::addPaddleModes(int lport, int rport, int lname, int rname)
|
2012-01-22 21:01:13 +00:00
|
|
|
{
|
2012-01-29 17:08:51 +00:00
|
|
|
ostringstream msg;
|
2012-01-29 22:33:24 +00:00
|
|
|
msg << "Mouse is Paddle " << lname << " controller";
|
2012-01-29 17:08:51 +00:00
|
|
|
MouseMode mode0(Automatic, Automatic, lport, msg.str());
|
2012-01-22 21:01:13 +00:00
|
|
|
|
2012-01-29 17:08:51 +00:00
|
|
|
msg.str("");
|
2012-01-29 22:33:24 +00:00
|
|
|
msg << "Mouse is Paddle " << rname << " controller";
|
2012-01-29 17:08:51 +00:00
|
|
|
MouseMode mode1(Automatic, Automatic, rport, msg.str());
|
2012-01-22 21:01:13 +00:00
|
|
|
|
2012-01-29 17:08:51 +00:00
|
|
|
if(BSPF_equalsIgnoreCase(myProps.get(Controller_SwapPaddles), "NO"))
|
2012-01-22 21:01:13 +00:00
|
|
|
{
|
2012-01-29 17:08:51 +00:00
|
|
|
myModeList.push_back(mode0);
|
|
|
|
myModeList.push_back(mode1);
|
2012-01-22 21:01:13 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-01-29 17:08:51 +00:00
|
|
|
myModeList.push_back(mode1);
|
|
|
|
myModeList.push_back(mode0);
|
2012-01-22 21:01:13 +00:00
|
|
|
}
|
|
|
|
}
|