The left and right mouse buttons are now recognized separately in emulation mode.

Checking in first pass at revamping the 'mcontrol' functionality.  The idea is
that the mouse will be able to emulate different controllers on each of its
axes.  For now, the left mouse button is tied to the X-axis, and the right to 
the Y-axis.  These modes will be saved per-ROM, meaning that the mapping can
be different for each ROM (it is saved as part of the ROM properties).  Only
the paddles and driving controllers will allow this, since they're the only
controllers where a single axis makes sense.

Switching between mouse modes will be done with Control-0 (the Control-1..3
keys have been removed).  This will allow switching all possible combinations
(left controller, right controller, per-ROM setting, etc).


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2366 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2012-01-22 21:01:13 +00:00
parent 8704fea8be
commit c136a30cbc
25 changed files with 3693 additions and 3448 deletions

172
src/common/MouseControl.cxx Normal file
View File

@ -0,0 +1,172 @@
//============================================================================
//
// 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)
{
cerr << "MouseControl c'tor: using mode = " << mode << endl;
if(mode == "never")
{
MouseMode mmode;
myModeList.push_back(mmode);
return;
}
// First consider the possible modes for the mouse based on the left
// and right controllers
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";
MouseMode mmode(Automatic, Automatic, 0, msg.str());
myModeList.push_back(mmode);
break;
}
case Controller::Paddles:
{
MouseMode mmode0(Automatic, Automatic, 0, "Mouse is Paddle 0 controller");
MouseMode mmode1(Automatic, Automatic, 1, "Mouse is Paddle 1 controller");
myModeList.push_back(mmode0);
myModeList.push_back(mmode1);
break;
}
default:
break;
}
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";
MouseMode mmode(Automatic, Automatic, 1, msg.str());
myModeList.push_back(mmode);
break;
}
case Controller::Paddles:
{
MouseMode mmode0(Automatic, Automatic, 2, "Mouse is Paddle 2 controller");
MouseMode mmode1(Automatic, Automatic, 3, "Mouse is Paddle 3 controller");
myModeList.push_back(mmode0);
myModeList.push_back(mmode1);
break;
}
default:
break;
}
// Now add per-ROM setting (if one exists)
if(mode != "auto")
{
/*
// Note: these constants are from Controller::MouseAxisType enum
if(s.length() != 2 || s[0] < '0' || s[0] > '7' || s[1] < '0' || s[1] > '7')
setInternal("mcontrol", "auto");
*/
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MouseControl::~MouseControl()
{
}
#if 0
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void MouseControl::setMode(const string& mode)
{
cerr << "MouseControl::setMode: " << mode << endl;
if(!&myOSystem->console())
return;
Controller& lc = myOSystem->console().controller(Controller::Left);
Controller& rc = myOSystem->console().controller(Controller::Right);
if(mode == "auto")
{
bool swap = myOSystem->console().properties().get(Controller_SwapPaddles) == "YES";
lc.setMouseControl(Controller::Automatic, Controller::Automatic, swap ? 1 : 0);
rc.setMouseControl(Controller::Automatic, Controller::Automatic, swap ? 1 : 0);
}
else
{
Controller::MouseAxisControl xaxis = (Controller::MouseAxisControl)
((int)mode[0] - '0');
Controller::MouseAxisControl yaxis = (Controller::MouseAxisControl)
((int)mode[1] - '0');
lc.setMouseControl(xaxis, yaxis);
rc.setMouseControl(xaxis, yaxis);
}
}
#endif
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const string& MouseControl::next()
{
const MouseMode& mode = myModeList[myCurrentModeNum];
myCurrentModeNum = (myCurrentModeNum + 1) % myModeList.size();
return mode.message;
#if 0
if(myOSystem->settings().getString("mcontrol") == "auto")
{
myOSystem->console().controller(Controller::Left).setMouseControl(
Controller::Automatic, Controller::Automatic, paddle);
myOSystem->console().controller(Controller::Right).setMouseControl(
Controller::Automatic, Controller::Automatic, paddle);
myOSystem->frameBuffer().showMessage(message);
}
else
{
myOSystem->frameBuffer().showMessage(
"Mouse axis mode not auto, paddle not changed");
}
#endif
}

101
src/common/MouseControl.hxx Normal file
View File

@ -0,0 +1,101 @@
//============================================================================
//
// 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$
//============================================================================
#ifndef MOUSE_CONTROL_HXX
#define MOUSE_CONTROL_HXX
class Console;
class Controller;
class Properties;
#include "bspf.hxx"
#include "Array.hxx"
/**
The mouse can control various virtual 'controllers' in many different
ways. In 'auto' mode, the entire mouse (both axes and buttons) are used
as one controller. In per-ROM axis mode, each axis/button may control
separate controllers. As well, we'd like to switch dynamically between
each of these modes at runtime.
This class encapsulates all required info to implement this functionality.
@author Stephen Anthony
*/
class MouseControl
{
public:
/**
Enumeration of mouse axis control types
*/
enum Axis
{
Paddle0 = 0, Paddle1, Paddle2, Paddle3,
Driving0, Driving1, Automatic, NoControl
};
public:
/**
Create a new MouseControl object
@param console The console in use by the system
@param mode Contains information about how to use the mouse axes/buttons
*/
MouseControl(Console& console, const string& mode);
/**
Destructor
*/
virtual ~MouseControl();
public:
/**
Cycle through each available mouse control mode
@return A message explaining the current mouse mode
*/
const string& next();
private:
const Properties& myProps;
Controller& myLeftController;
Controller& myRightController;
struct MouseMode {
Axis xaxis, yaxis;
int controlID;
string message;
MouseMode()
: xaxis(NoControl),
yaxis(NoControl),
controlID(-1),
message("Mouse input is disabled") { }
MouseMode(Axis x, Axis y, int id, const string& msg)
: xaxis(x),
yaxis(y),
controlID(id),
message(msg) { }
};
int myCurrentModeNum;
Common::Array<MouseMode> myModeList;
};
#endif

View File

@ -9,6 +9,7 @@ MODULE_OBJS := \
src/common/FBSurfaceGL.o \
src/common/FBSurfaceTIA.o \
src/common/PNGLibrary.o \
src/common/MouseControl.o \
src/common/RectList.o \
src/common/Snapshot.o

View File

@ -123,21 +123,22 @@ void BoosterGrip::update()
}
}
// Get mouse button state
if(myEvent.get(Event::MouseButtonValue))
if(myEvent.get(Event::MouseButtonLeftValue) ||
myEvent.get(Event::MouseButtonRightValue))
myDigitalPinState[Six] = false;
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void BoosterGrip::setMouseControl(
MouseAxisControl xaxis, MouseAxisControl yaxis, int ctrlID)
MouseControl::Axis xaxis, MouseControl::Axis yaxis, int ctrlID)
{
// In 'automatic' mode, both axes on the mouse map to a single normal booster
if(xaxis == Controller::Automatic || yaxis == Controller::Automatic)
if(xaxis == MouseControl::Automatic || yaxis == MouseControl::Automatic)
{
myControlID = ((myJack == Left && (ctrlID == 0 || ctrlID == 1)) ||
(myJack == Right && (ctrlID == 2 || ctrlID == 3))
) ? ctrlID & 0x01 : -1;
myControlID = ((myJack == Left && ctrlID == 0) ||
(myJack == Right && ctrlID == 1)
) ? ctrlID : -1;
}
else // Otherwise, boosters are not used in 'non-auto' mode
myControlID = -1;

View File

@ -57,22 +57,21 @@ class BoosterGrip : public Controller
/**
Determines how this controller will treat values received from the
X and Y axis of the mouse. Since not all controllers use the mouse,
it's up to the specific class to decide how to use this data.
X/Y axis and left/right buttons of the mouse. Since not all controllers
use the mouse, it's up to the specific class to decide how to use this data.
If either of the axis is set to 'Automatic', then we automatically
use this number for the control type as follows:
0 - paddle 0, joystick 0 (and controllers similar to a joystick)
1 - paddle 1, joystick 1 (and controllers similar to a joystick)
2 - paddle 2, joystick 0 (and controllers similar to a joystick)
3 - paddle 3, joystick 1 (and controllers similar to a joystick)
use the ctrlID for the control type.
In the current implementation, the left button is tied to the X axis,
and the right one tied to the Y axis.
@param xaxis How the controller should use x-axis data
@param yaxis How the controller should use y-axis data
@param ctrlID The controller ID to use axis 'auto' mode
*/
void setMouseControl(
MouseAxisControl xaxis, MouseAxisControl yaxis, int ctrlID = -1);
MouseControl::Axis xaxis, MouseControl::Axis yaxis, int ctrlID = -1);
private:
// Pre-compute the events we care about based on given port

View File

@ -119,10 +119,9 @@ Console::Console(OSystem* osystem, Cartridge* cart, const Properties& props)
// The 'fastscbios' option must be changed before the system is reset
// The algorithm used is as follows:
// Run for 60 frames, only consider frames in appropriate scanline range
// If there's a frame that starts drawing at scanline 50 or
// has more than 287 scanlines, count it as PAL
// If at least 20 PAL frames are found, then the format is PAL, else NTSC
// Run for 60 frames; if there's a frame that has more than 287
// scanlines, count it as PAL
// If at least 25 PAL frames are found, then the format is PAL, else NTSC
bool fastscbios = myOSystem->settings().getBool("fastscbios");
myOSystem->settings().setBool("fastscbios", true);
mySystem->reset(true); // autodetect in reset enabled
@ -130,12 +129,9 @@ Console::Console(OSystem* osystem, Cartridge* cart, const Properties& props)
for(int i = 0; i < 60; ++i)
{
myTIA->update();
int lines = myTIA->scanlines() - myTIA->startLine();
if((lines >= 180 && lines <= 342) &&
(myTIA->startLine() >= 50 || myTIA->scanlines() >= 287))
if(myTIA->scanlines() >= 287)
++palCount;
}
myDisplayFormat = (palCount >= 25) ? "PAL" : "NTSC";
if(myProperties.get(Display_Format) == "AUTO-DETECT")
autodetected = "*";

View File

@ -26,6 +26,7 @@ class System;
#include "Serializable.hxx"
#include "bspf.hxx"
#include "MouseControl.hxx"
/**
A controller is a device that plugs into either the left or right
@ -93,15 +94,6 @@ class Controller : public Serializable
KidVid, Genesis, MindLink, CompuMate
};
/**
Enumeration of mouse axis control types
*/
enum MouseAxisControl
{
Paddle0 = 0, Paddle1, Paddle2, Paddle3,
Automatic, NoControl
};
public:
/**
Create a new controller plugged into the specified jack
@ -190,22 +182,21 @@ class Controller : public Serializable
/**
Determines how this controller will treat values received from the
X and Y axis of the mouse. Since not all controllers use the mouse,
it's up to the specific class to decide how to use this data.
X/Y axis and left/right buttons of the mouse. Since not all controllers
use the mouse, it's up to the specific class to decide how to use this data.
If either of the axis is set to 'Automatic', then we automatically
use this number for the control type as follows:
0 - paddle 0, joystick 0 (and controllers similar to a joystick)
1 - paddle 1, joystick 1 (and controllers similar to a joystick)
2 - paddle 2, joystick 0 (and controllers similar to a joystick)
3 - paddle 3, joystick 1 (and controllers similar to a joystick)
use the ctrlID for the control type.
In the current implementation, the left button is tied to the X axis,
and the right one tied to the Y axis.
@param xaxis How the controller should use x-axis data
@param yaxis How the controller should use y-axis data
@param ctrlID The controller ID to use axis 'auto' mode
*/
virtual void setMouseControl(
MouseAxisControl xaxis, MouseAxisControl yaxis, int ctrlID = -1) { };
MouseControl::Axis xaxis, MouseControl::Axis yaxis, int ctrlID = -1) { };
/**
Returns the name of this controller.

File diff suppressed because it is too large Load Diff

View File

@ -78,7 +78,7 @@ void Driving::update()
int m_axis = myEvent.get(Event::MouseAxisXValue);
if(m_axis < -2) myCounter--;
else if(m_axis > 2) myCounter++;
if(myEvent.get(Event::MouseButtonValue))
if(myEvent.get(Event::MouseButtonLeftValue))
myDigitalPinState[Six] = false;
}
@ -115,10 +115,10 @@ void Driving::update()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Driving::setMouseControl(
MouseAxisControl xaxis, MouseAxisControl yaxis, int ctrlID)
MouseControl::Axis xaxis, MouseControl::Axis yaxis, int ctrlID)
{
// In 'automatic' mode, only the X-axis is used
if(xaxis == Controller::Automatic || yaxis == Controller::Automatic)
if(xaxis == MouseControl::Automatic || yaxis == MouseControl::Automatic)
{
myControlID = ((myJack == Left && (ctrlID == 0 || ctrlID == 1)) ||
(myJack == Right && (ctrlID == 2 || ctrlID == 3))

View File

@ -57,22 +57,21 @@ class Driving : public Controller
/**
Determines how this controller will treat values received from the
X and Y axis of the mouse. Since not all controllers use the mouse,
it's up to the specific class to decide how to use this data.
X/Y axis and left/right buttons of the mouse. Since not all controllers
use the mouse, it's up to the specific class to decide how to use this data.
If either of the axis is set to 'Automatic', then we automatically
use this number for the control type as follows:
0 - paddle 0, joystick 0 (and controllers similar to a joystick)
1 - paddle 1, joystick 1 (and controllers similar to a joystick)
2 - paddle 2, joystick 0 (and controllers similar to a joystick)
3 - paddle 3, joystick 1 (and controllers similar to a joystick)
use the ctrlID for the control type.
In the current implementation, the left button is tied to the X axis,
and the right one tied to the Y axis.
@param xaxis How the controller should use x-axis data
@param yaxis How the controller should use y-axis data
@param ctrlID The controller ID to use axis 'auto' mode
*/
void setMouseControl(
MouseAxisControl xaxis, MouseAxisControl yaxis, int ctrlID = -1);
MouseControl::Axis xaxis, MouseControl::Axis yaxis, int ctrlID = -1);
private:
// Counter to iterate through the gray codes

View File

@ -70,7 +70,8 @@ class Event
SALeftAxis0Value, SALeftAxis1Value,
SARightAxis0Value, SARightAxis1Value,
MouseAxisXValue, MouseAxisYValue, MouseButtonValue,
MouseAxisXValue, MouseAxisYValue,
MouseButtonLeftValue, MouseButtonRightValue,
ChangeState, LoadState, SaveState, TakeSnapshot, Quit,
PauseMode, MenuMode, CmdMenuMode, DebuggerMode, LauncherMode,

View File

@ -43,6 +43,7 @@
#include "Sound.hxx"
#include "StateManager.hxx"
#include "Switches.hxx"
#include "MouseControl.hxx"
#include "EventHandler.hxx"
@ -58,6 +59,7 @@
EventHandler::EventHandler(OSystem* osystem)
: myOSystem(osystem),
myOverlay(NULL),
myMouseControl(NULL),
myState(S_NONE),
myAllowAllDirectionsFlag(false),
myFryingFlag(false),
@ -102,6 +104,7 @@ EventHandler::~EventHandler()
if(ourMenuActionList[i].key)
free(ourMenuActionList[i].key);
delete myMouseControl;
delete[] myJoysticks;
}
@ -335,7 +338,7 @@ void EventHandler::poll(uInt64 time)
// These only work when in emulation mode
else if(myState == S_EMULATE)
{
switch(int(key))
switch(key)
{
case KBDK_EQUALS:
myOSystem->frameBuffer().changeVidMode(+1);
@ -496,22 +499,14 @@ void EventHandler::poll(uInt64 time)
// These only work when in emulation mode
else if(myState == S_EMULATE)
{
switch(int(key))
switch(key)
{
case KBDK_0: // Ctrl-0 sets the mouse to paddle 0
setMouseAsPaddle(0, "Mouse is paddle 0");
break;
case KBDK_1: // Ctrl-1 sets the mouse to paddle 1
setMouseAsPaddle(1, "Mouse is paddle 1");
break;
case KBDK_2: // Ctrl-2 sets the mouse to paddle 2
setMouseAsPaddle(2, "Mouse is paddle 2");
break;
case KBDK_3: // Ctrl-3 sets the mouse to paddle 3
setMouseAsPaddle(3, "Mouse is paddle 3");
case KBDK_0: // Ctrl-0 switches between mouse control modes
if(myMouseControl)
{
const string& message = myMouseControl->next();
myOSystem->frameBuffer().showMessage(message);
}
break;
case KBDK_f: // Ctrl-f toggles NTSC/PAL mode
@ -613,11 +608,20 @@ void EventHandler::poll(uInt64 time)
// Determine which mode we're in, then send the event to the appropriate place
if(myState == S_EMULATE)
{
myEvent.set(Event::MouseButtonValue, state);
switch(event.button.button)
{
case SDL_BUTTON_LEFT:
myEvent.set(Event::MouseButtonLeftValue, state);
break;
case SDL_BUTTON_RIGHT:
myEvent.set(Event::MouseButtonRightValue, state);
break;
default:
break;
}
}
else if(myOverlay)
{
// Take window zooming into account
Int32 x = event.button.x, y = event.button.y;
switch(event.button.button)
@ -1906,51 +1910,16 @@ void EventHandler::takeSnapshot(uInt32 number)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::setMouseControllerMode(const string& mode,
const string& message)
void EventHandler::setMouseControllerMode(const string& mode)
{
if(!&myOSystem->console())
return;
Controller& lc = myOSystem->console().controller(Controller::Left);
Controller& rc = myOSystem->console().controller(Controller::Right);
if(mode == "auto")
delete myMouseControl; myMouseControl = NULL;
if(myState == S_EMULATE)
{
bool swap = myOSystem->console().properties().get(Controller_SwapPaddles) == "YES";
lc.setMouseControl(Controller::Automatic, Controller::Automatic, swap ? 1 : 0);
rc.setMouseControl(Controller::Automatic, Controller::Automatic, swap ? 1 : 0);
}
else
{
Controller::MouseAxisControl xaxis = (Controller::MouseAxisControl)
((int)mode[0] - '0');
Controller::MouseAxisControl yaxis = (Controller::MouseAxisControl)
((int)mode[1] - '0');
const string& control = mode == "rom" ?
myOSystem->console().properties().get(Controller_MouseAxis) : mode;
lc.setMouseControl(xaxis, yaxis);
rc.setMouseControl(xaxis, yaxis);
}
if(message != "")
myOSystem->frameBuffer().showMessage(message);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::setMouseAsPaddle(int paddle, const string& message)
{
if(myOSystem->settings().getString("mcontrol") == "auto")
{
myOSystem->console().controller(Controller::Left).setMouseControl(
Controller::Automatic, Controller::Automatic, paddle);
myOSystem->console().controller(Controller::Right).setMouseControl(
Controller::Automatic, Controller::Automatic, paddle);
myOSystem->frameBuffer().showMessage(message);
}
else
{
myOSystem->frameBuffer().showMessage(
"Mouse axis mode not auto, paddle not changed");
myMouseControl = new MouseControl(myOSystem->console(), control);
myMouseControl->next(); // set first available mode
}
}

View File

@ -29,6 +29,7 @@ class DialogContainer;
class EventMappingWidget;
class StringMap;
class StringList;
class MouseControl;
#include "Array.hxx"
#include "Event.hxx"
@ -152,13 +153,12 @@ class EventHandler
void quit() { handleEvent(Event::Quit, 1); }
/**
Sets the mouse axis to act as controller 'mode', where the mode is
defined from the Controller::MouseAxisControl enum
Sets the mouse axes and buttons to act as controller 'mode', where
the mode is defined from the Controller::MouseAxisControl enum
@param mode The controller which the mouse axes should emulate
@param message Print the (non-empty) message to the framebuffer
@param mode The controller which the mouse axes should emulate
*/
void setMouseControllerMode(const string& mode, const string& message = "");
void setMouseControllerMode(const string& mode);
/**
Set the number of seconds between taking a snapshot in
@ -375,6 +375,10 @@ class EventHandler
// Indicates current overlay object
DialogContainer* myOverlay;
// MouseControl object, which takes care of switching the mouse between
// all possible controller modes
MouseControl* myMouseControl;
// Array of key events, indexed by StellaKey
Event::Type myKeyTable[KBDK_LAST][kNumModes];
@ -411,9 +415,6 @@ class EventHandler
uInt32 myContSnapshotInterval;
uInt32 myContSnapshotCounter;
// Indicates which paddle the mouse currently emulates
Int8 myPaddleMode;
// Holds static strings for the remap menu (emulation and menu events)
static ActionList ourEmulActionList[kEmulActionListSize];
static ActionList ourMenuActionList[kMenuActionListSize];

View File

@ -115,21 +115,22 @@ void Joystick::update()
}
}
// Get mouse button state
if(myEvent.get(Event::MouseButtonValue))
if(myEvent.get(Event::MouseButtonLeftValue) ||
myEvent.get(Event::MouseButtonRightValue))
myDigitalPinState[Six] = false;
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Joystick::setMouseControl(
MouseAxisControl xaxis, MouseAxisControl yaxis, int ctrlID)
MouseControl::Axis xaxis, MouseControl::Axis yaxis, int ctrlID)
{
// In 'automatic' mode, both axes on the mouse map to a single normal joystick
if(xaxis == Controller::Automatic || yaxis == Controller::Automatic)
if(xaxis == MouseControl::Automatic || yaxis == MouseControl::Automatic)
{
myControlID = ((myJack == Left && (ctrlID == 0 || ctrlID == 1)) ||
(myJack == Right && (ctrlID == 2 || ctrlID == 3))
) ? ctrlID & 0x01 : -1;
myControlID = ((myJack == Left && ctrlID == 0) ||
(myJack == Right && ctrlID == 1)
) ? ctrlID : -1;
}
else // Otherwise, joysticks are not used in 'non-auto' mode
myControlID = -1;

View File

@ -56,22 +56,21 @@ class Joystick : public Controller
/**
Determines how this controller will treat values received from the
X and Y axis of the mouse. Since not all controllers use the mouse,
it's up to the specific class to decide how to use this data.
X/Y axis and left/right buttons of the mouse. Since not all controllers
use the mouse, it's up to the specific class to decide how to use this data.
If either of the axis is set to 'Automatic', then we automatically
use this number for the control type as follows:
0 - paddle 0, joystick 0 (and controllers similar to a joystick)
1 - paddle 1, joystick 1 (and controllers similar to a joystick)
2 - paddle 2, joystick 0 (and controllers similar to a joystick)
3 - paddle 3, joystick 1 (and controllers similar to a joystick)
use the ctrlID for the control type.
In the current implementation, the left button is tied to the X axis,
and the right one tied to the Y axis.
@param xaxis How the controller should use x-axis data
@param yaxis How the controller should use y-axis data
@param ctrlID The controller ID to use axis 'auto' mode
*/
void setMouseControl(
MouseAxisControl xaxis, MouseAxisControl yaxis, int ctrlID = -1);
MouseControl::Axis xaxis, MouseControl::Axis yaxis, int ctrlID = -1);
/**
Sets the deadzone amount for real analog joysticks.

View File

@ -66,7 +66,8 @@ void MindLink::update()
myMindlinkShift = 1;
nextMindlinkBit();
if(myEvent.get(Event::MouseButtonValue))
if(myEvent.get(Event::MouseButtonLeftValue) ||
myEvent.get(Event::MouseButtonRightValue))
myMindlinkPos |= 0x4000; /* this bit starts a game */
//cerr << HEX4 << (int)myMindlinkPos << " : " << HEX2 << (int)myIOPort << endl;

View File

@ -293,7 +293,8 @@ void Paddles::update()
myCharge[myMPaddleID] = TRIGMIN;
if(myCharge[myMPaddleID] > TRIGMAX)
myCharge[myMPaddleID] = TRIGMAX;
if(myEvent.get(Event::MouseButtonValue))
if(myEvent.get(Event::MouseButtonLeftValue) ||
myEvent.get(Event::MouseButtonRightValue))
myDigitalPinState[ourButtonPin[myMPaddleID]] = false;
}
else
@ -308,6 +309,8 @@ void Paddles::update()
myCharge[myMPaddleIDX] = TRIGMIN;
if(myCharge[myMPaddleIDX] > TRIGMAX)
myCharge[myMPaddleIDX] = TRIGMAX;
if(myEvent.get(Event::MouseButtonLeftValue))
myDigitalPinState[ourButtonPin[myMPaddleIDX]] = false;
}
if(myMPaddleIDY > -1)
{
@ -317,6 +320,8 @@ void Paddles::update()
myCharge[myMPaddleIDY] = TRIGMIN;
if(myCharge[myMPaddleIDY] > TRIGMAX)
myCharge[myMPaddleIDY] = TRIGMAX;
if(myEvent.get(Event::MouseButtonRightValue))
myDigitalPinState[ourButtonPin[myMPaddleIDY]] = false;
}
}
@ -377,11 +382,11 @@ void Paddles::update()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Paddles::setMouseControl(
MouseAxisControl xaxis, MouseAxisControl yaxis, int ctrlID)
MouseControl::Axis xaxis, MouseControl::Axis yaxis, int ctrlID)
{
// In 'automatic' mode, both axes on the mouse map to a single paddle
// This overrides any other mode
if(xaxis == Controller::Automatic || yaxis == Controller::Automatic)
if(xaxis == MouseControl::Automatic || yaxis == MouseControl::Automatic)
{
myMPaddleID = ((myJack == Left && (ctrlID == 0 || ctrlID == 1)) ||
(myJack == Right && (ctrlID == 2 || ctrlID == 3))
@ -397,30 +402,30 @@ void Paddles::setMouseControl(
{
switch(xaxis)
{
case Controller::Paddle0: myMPaddleIDX = 0; break;
case Controller::Paddle1: myMPaddleIDX = 1; break;
default: myMPaddleIDX = -1; break;
case MouseControl::Paddle0: myMPaddleIDX = 0; break;
case MouseControl::Paddle1: myMPaddleIDX = 1; break;
default: myMPaddleIDX = -1; break;
}
switch(yaxis)
{
case Controller::Paddle0: myMPaddleIDY = 0; break;
case Controller::Paddle1: myMPaddleIDY = 1; break;
default: myMPaddleIDY = -1; break;
case MouseControl::Paddle0: myMPaddleIDY = 0; break;
case MouseControl::Paddle1: myMPaddleIDY = 1; break;
default: myMPaddleIDY = -1; break;
}
}
else // myJack == Right
{
switch(xaxis)
{
case Controller::Paddle2: myMPaddleIDX = 0; break;
case Controller::Paddle3: myMPaddleIDX = 1; break;
default: myMPaddleIDX = -1; break;
case MouseControl::Paddle2: myMPaddleIDX = 0; break;
case MouseControl::Paddle3: myMPaddleIDX = 1; break;
default: myMPaddleIDX = -1; break;
}
switch(yaxis)
{
case Controller::Paddle2: myMPaddleIDY = 0; break;
case Controller::Paddle3: myMPaddleIDY = 1; break;
default: myMPaddleIDY = -1; break;
case MouseControl::Paddle2: myMPaddleIDY = 0; break;
case MouseControl::Paddle3: myMPaddleIDY = 1; break;
default: myMPaddleIDY = -1; break;
}
}
}

View File

@ -63,22 +63,21 @@ class Paddles : public Controller
/**
Determines how this controller will treat values received from the
X and Y axis of the mouse. Since not all controllers use the mouse,
it's up to the specific class to decide how to use this data.
X/Y axis and left/right buttons of the mouse. Since not all controllers
use the mouse, it's up to the specific class to decide how to use this data.
If either of the axis is set to 'Automatic', then we automatically
use this number for the control type as follows:
0 - paddle 0, joystick 0 (and controllers similar to a joystick)
1 - paddle 1, joystick 1 (and controllers similar to a joystick)
2 - paddle 2, joystick 0 (and controllers similar to a joystick)
3 - paddle 3, joystick 1 (and controllers similar to a joystick)
use the ctrlID for the control type.
In the current implementation, the left button is tied to the X axis,
and the right one tied to the Y axis.
@param xaxis How the controller should use x-axis data
@param yaxis How the controller should use y-axis data
@param ctrlID The controller ID to use axis 'auto' mode
*/
void setMouseControl(
MouseAxisControl xaxis, MouseAxisControl yaxis, int ctrlID = -1);
MouseControl::Axis xaxis, MouseControl::Axis yaxis, int ctrlID = -1);
/**
Sets the sensitivity for digital emulation of paddle movement.

View File

@ -68,6 +68,7 @@ void Properties::set(PropertyType key, const string& value)
case Controller_Left:
case Controller_Right:
case Controller_SwapPaddles:
case Controller_MouseAxis:
case Display_Format:
case Display_Phosphor:
{
@ -244,6 +245,7 @@ void Properties::print() const
<< get(Controller_Left) << "|"
<< get(Controller_Right) << "|"
<< get(Controller_SwapPaddles) << "|"
<< get(Controller_MouseAxis) << "|"
<< get(Display_Format) << "|"
<< get(Display_YStart) << "|"
<< get(Display_Height) << "|"
@ -288,6 +290,7 @@ void Properties::printHeader()
<< "Controller_Left|"
<< "Controller_Right|"
<< "Controller_SwapPaddles|"
<< "Controller_MouseAxis|"
<< "Display_Format|"
<< "Display_YStart|"
<< "Display_Height|"
@ -313,6 +316,7 @@ const char* Properties::ourDefaultProperties[LastPropType] = {
"JOYSTICK", // Controller.Left
"JOYSTICK", // Controller.Right
"NO", // Controller.SwapPaddles
"AUTO", // Controller.MouseAxis
"AUTO-DETECT", // Display.Format
"34", // Display.YStart
"210", // Display.Height
@ -337,6 +341,7 @@ const char* Properties::ourPropertyNames[LastPropType] = {
"Controller.Left",
"Controller.Right",
"Controller.SwapPaddles",
"Controller.MouseAxis",
"Display.Format",
"Display.YStart",
"Display.Height",

View File

@ -38,6 +38,7 @@ enum PropertyType {
Controller_Left,
Controller_Right,
Controller_SwapPaddles,
Controller_MouseAxis,
Display_Format,
Display_YStart,
Display_Height,

View File

@ -279,12 +279,8 @@ void Settings::validate()
else if(i > 29) setInternal("joydeadzone", "29");
s = getString("mcontrol");
if(s != "auto")
{
// Note: these constants are from Controller::MouseAxisType enum
if(s.length() != 2 || s[0] < '0' || s[0] > '5' || s[1] < '0' || s[1] > '5')
setInternal("mcontrol", "auto");
}
if(s != "never" && s != "auto" && s != "rom")
setInternal("mcontrol", "auto");
if(i < 1) setInternal("dsense", "1");
else if(i > 10) setInternal("dsense", "10");
@ -373,7 +369,8 @@ void Settings::usage()
<< " -logtoconsole <1|0> Log output to console/commandline\n"
<< " -joydeadzone <number> Sets 'deadzone' area for analog joysticks (0-29)\n"
<< " -joyallow4 <1|0> Allow all 4 directions on a joystick to be pressed simultaneously\n"
<< " -mcontrol <auto|XY> Use mouse axes as specified paddle controller type (see manual)\n"
<< " -mcontrol <never|auto| Use mouse axes as specified controller type (see manual)\n"
<< " rom>\n"
<< " -dsense <number> Sensitivity of digital emulated paddle movement (1-10)\n"
<< " -msense <number> Sensitivity of mouse emulated paddle movement (1-15)\n"
<< " -sa1 <left|right> Stelladaptor 1 emulates specified joystick port\n"

View File

@ -30,9 +30,9 @@ class Sound;
#include "TIATables.hxx"
/**
This class is a device that emulates the Television Interface Adapator
This class is a device that emulates the Television Interface Adaptor
found in the Atari 2600 and 7800 consoles. The Television Interface
Adapator is an integrated circuit designed to interface between an
Adaptor is an integrated circuit designed to interface between an
eight bit microprocessor and a television video modulator. It converts
eight bit parallel data into serial outputs for the color, luminosity,
and composite sync required by a video modulator.

View File

@ -131,7 +131,9 @@ void TrackBall::update()
if(myTrakBallLinesV == 0) myTrakBallLinesV = 1;
// Get mouse button state
myDigitalPinState[Six] = (myEvent.get(Event::MouseButtonValue) == 0);
myDigitalPinState[Six] =
(myEvent.get(Event::MouseButtonLeftValue) == 0) ||
(myEvent.get(Event::MouseButtonRightValue) == 0);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -204,13 +204,15 @@ void InputDialog::addDevicePortTab(const GUI::Font& font)
// Mouse controller specific axis
lwidth = font.getStringWidth("X-Axis is: ");
pwidth = font.getStringWidth("Paddle 3");
pwidth = font.getStringWidth("Driving 0");
items.clear();
items.push_back("not used", BSPF_toString(Controller::NoControl));
items.push_back("Paddle 0", BSPF_toString(Controller::Paddle0));
items.push_back("Paddle 1", BSPF_toString(Controller::Paddle1));
items.push_back("Paddle 2", BSPF_toString(Controller::Paddle2));
items.push_back("Paddle 3", BSPF_toString(Controller::Paddle3));
items.push_back("not used", BSPF_toString(MouseControl::NoControl));
items.push_back("Paddle 0", BSPF_toString(MouseControl::Paddle0));
items.push_back("Paddle 1", BSPF_toString(MouseControl::Paddle1));
items.push_back("Paddle 2", BSPF_toString(MouseControl::Paddle2));
items.push_back("Paddle 3", BSPF_toString(MouseControl::Paddle3));
items.push_back("Driving 0", BSPF_toString(MouseControl::Driving0));
items.push_back("Driving 1", BSPF_toString(MouseControl::Driving1));
xpos = 45; ypos += lineHeight + 4;
myMouseX = new PopUpWidget(myTab, font, xpos, ypos, pwidth, lineHeight, items,

View File

@ -19,11 +19,12 @@ my %proptype = (
"Controller.Left" => 12,
"Controller.Right" => 13,
"Controller.SwapPaddles" => 14,
"Display.Format" => 15,
"Display.YStart" => 16,
"Display.Height" => 17,
"Display.Phosphor" => 18,
"Display.PPBlend" => 19
"Controller.MouseAxis" => 15,
"Display.Format" => 16,
"Display.YStart" => 17,
"Display.Height" => 18,
"Display.Phosphor" => 19,
"Display.PPBlend" => 20
);
my @prop_defaults = (
@ -42,6 +43,7 @@ my @prop_defaults = (
"JOYSTICK",
"JOYSTICK",
"NO",
"AUTO",
"AUTO-DETECT",
"34",
"210",