Combined 'sa1' and 'sa2' commandline arguments into one command named

'saport'.  This takes the values 'lr' or 'rl', corresponding to left/right
and right/left.

Added ability to dynamically swap the Stelladaptor/2600-daptor ports
with the 'Control-1' key.






git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2401 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2012-03-03 00:56:31 +00:00
parent 1e396f8408
commit 3b4b10df76
5 changed files with 84 additions and 50 deletions

View File

@ -1471,6 +1471,12 @@
<td>Control + 0</td>
</tr>
<tr>
<td>Swap Stelladaptor/2600-daptor port ordering</td>
<td>Control + 1</td>
<td>Control + 1</td>
</tr>
<tr>
<td>Reload current ROM (singlecart ROM, TIA mode)<br>
Load next game in ROM (multicart ROM, TIA mode)</td>
@ -1602,7 +1608,7 @@
<td> &#x2713;</td>
<td> &#x2715;</td>
<td> &#x2715;</td>
<td> &#x2715;</td>
<td> &#x2713; (2600-daptor II)</td>
</tr>
<tr>
<th> Driving</th>
@ -1901,13 +1907,10 @@
</tr>
<tr>
<td><pre>-sa1 &lt;left|right&gt;</pre></td>
<td>Stelladaptor/2600-daptor 1 emulates specified joystick port.</td>
</tr>
<tr>
<td><pre>-sa2 &lt;left|right&gt;</pre></td>
<td>Stelladaptor/2600-daptor 2 emulates specified joystick port.</td>
<td><pre>-saport &lt;lr|rl&gt;</pre></td>
<td>Determines how to enumerate the Stelladaptor/2600-daptor devices in the
order they are found: 'lr' means first is left port, second is right port,
'rl' means the opposite.</td>
</tr>
<tr>
@ -2469,7 +2472,7 @@
<td valign="top">
<table border="1" cellpadding="4">
<tr><th>Item</th><th>Brief description</th><th>For more information,<br>see <a href="#CommandLine">CommandLine</a></th></tr>
<tr><td>Stelladaptor X is</td><td>Specifies which virtual port each Stelladaptor/2600-daptor uses (See <b>Advanced Configuration - <a href="#Adaptor">Stelladaptor/2600-daptor Support</a></b>)</td><td>-sa1 &amp; -sa2</td></tr>
<tr><td>Stelladaptor X is</td><td>Specifies which virtual port each Stelladaptor/2600-daptor uses (See <b>Advanced Configuration - <a href="#Adaptor">Stelladaptor/2600-daptor Support</a></b>)</td><td>-saport</td></tr>
<tr><td>AVox serial port</td><td>Described in further detail in <b>Advanced Configuration - <a href="#AtariVox">AtariVox/SaveKey Support</a></b> </td><td>-avoxport</td></tr>
<tr><td>Joy deadzone size</td><td>Deadzone area for axes on joysticks/gamepads</td><td>-joydeadzone</td></tr>
<tr><td>Digital paddle sensitivity</td><td>Sensitvity used when emulating a paddle using a digital device</td><td>-dsense</td></tr>
@ -2640,16 +2643,18 @@
<ul>
<li>The first device found will act as the <b>left game port</b>
on a real Atari. Depending on the device, Stella will detect it as
either the left joystick, paddles 0 & 1, or the left driving controller.</li>
either the left joystick, paddles 0 & 1, the left driving controller,
left keypad, etc.</li>
<li>The second device found will act as the <b>right game port</b>
on a real Atari. Depending on the device, Stella will detect it as
either the right joystick, paddles 2 & 3, or the right driving controller.</li>
either the right joystick, paddles 2 & 3, the right driving controller,
right keypad, etc.</li>
<li>Any other devices will be ignored.</li>
<li>The assignment ordering of Stelladaptor/2600-daptor to port can be redefined with
'sa1' and 'sa2' (see description in 'Starting a Game').</li>
'saport' (see description in 'Starting a Game').</li>
</ul>
</blockquote>

View File

@ -161,15 +161,11 @@ void EventHandler::setupJoysticks()
if(name.find("2600-daptor", 0) != string::npos)
{
saCount++;
if(saCount > 2) // Ignore more than 2 Stelladaptors
if(saCount > 2) // Ignore more than 2 2600-daptors
{
myJoysticks[i].type = StellaJoystick::JT_NONE;
continue;
}
else if(saCount == 1) // Type will be set by mapStelladaptors()
myJoysticks[i].name = myJoysticks[i].numButtons > 2 ? "2600-daptorII 1" : "2600-daptor 1";
else if(saCount == 2)
myJoysticks[i].name = myJoysticks[i].numButtons > 2 ? "2600-daptorII 2" : "2600-daptor 2";
// 2600-daptorII devices have 3 axes and 12 buttons, and the value of the z-axis
// determines how those 12 buttons are used (not all buttons are used in all modes)
@ -177,17 +173,18 @@ void EventHandler::setupJoysticks()
{
// TODO - stubbed out for now, until we find a way to reliably get info
// from the Z axis
myJoysticks[i].name = "2600-daptor II";
}
else
myJoysticks[i].name = "2600-daptor";
}
else if(name.find("Stelladaptor", 0) != string::npos)
{
saCount++;
if(saCount > 2) // Ignore more than 2 Stelladaptors
continue;
else if(saCount == 1) // Type will be set by mapStelladaptors()
myJoysticks[i].name = "Stelladaptor 1";
else if(saCount == 2)
myJoysticks[i].name = "Stelladaptor 2";
else // Type will be set by mapStelladaptors()
myJoysticks[i].name = "Stelladaptor";
}
else
{
@ -211,9 +208,7 @@ void EventHandler::setupJoysticks()
}
// Map the stelladaptors we've found according to the specified ports
const string& sa1 = myOSystem->settings().getString("sa1");
const string& sa2 = myOSystem->settings().getString("sa2");
mapStelladaptors(sa1, sa2);
mapStelladaptors(myOSystem->settings().getString("saport"));
setJoymap();
setActionMappings(kEmulationMode);
@ -230,19 +225,36 @@ void EventHandler::setupJoysticks()
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::mapStelladaptors(const string& sa1, const string& sa2)
void EventHandler::mapStelladaptors(const string& saport)
{
#ifdef JOYSTICK_SUPPORT
// saport will have two values:
// 'lr' means treat first valid adaptor as left port, second as right port
// 'rl' means treat first valid adaptor as right port, second as left port
// We know there will be only two such devices (at most), since the logic
// in setupJoysticks take care of that
int saCount = 0;
int saOrder[2];
if(BSPF_equalsIgnoreCase(saport, "lr"))
{
saOrder[0] = 1; saOrder[1] = 2;
}
else
{
saOrder[0] = 2; saOrder[1] = 1;
}
for(uInt32 i = 0; i < myNumJoysticks; i++)
{
if(BSPF_startsWithIgnoreCase(myJoysticks[i].name, "Stelladaptor"))
{
if(sa1 == "left")
saCount++;
if(saOrder[saCount-1] == 1)
{
myJoysticks[i].name += " (emulates left joystick port)";
myJoysticks[i].type = StellaJoystick::JT_STELLADAPTOR_LEFT;
}
else if(sa1 == "right")
else if(saOrder[saCount-1] == 2)
{
myJoysticks[i].name += " (emulates right joystick port)";
myJoysticks[i].type = StellaJoystick::JT_STELLADAPTOR_RIGHT;
@ -250,23 +262,39 @@ void EventHandler::mapStelladaptors(const string& sa1, const string& sa2)
}
else if(BSPF_startsWithIgnoreCase(myJoysticks[i].name, "2600-daptor"))
{
if(sa1 == "left")
saCount++;
if(saOrder[saCount-1] == 1)
{
myJoysticks[i].name += " (emulates left joystick port)";
myJoysticks[i].type = StellaJoystick::JT_2600DAPTOR_LEFT;
}
else if(sa1 == "right")
else if(saOrder[saCount-1] == 2)
{
myJoysticks[i].name += " (emulates right joystick port)";
myJoysticks[i].type = StellaJoystick::JT_2600DAPTOR_RIGHT;
}
}
}
myOSystem->settings().setString("sa1", sa1);
myOSystem->settings().setString("sa2", sa2);
myOSystem->settings().setString("saport", saport);
#endif
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::toggleSAPortOrder()
{
const string& saport = myOSystem->settings().getString("saport");
if(saport == "lr")
{
mapStelladaptors("rl");
myOSystem->frameBuffer().showMessage("Stelladaptor ports right/left");
}
else
{
mapStelladaptors("lr");
myOSystem->frameBuffer().showMessage("Stelladaptor ports left/right");
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::poll(uInt64 time)
{
@ -479,6 +507,10 @@ void EventHandler::poll(uInt64 time)
}
break;
case KBDK_1: // Ctrl-1 swaps Stelladaptor/2600-daptor ports
toggleSAPortOrder();
break;
case KBDK_f: // Ctrl-f toggles NTSC/PAL mode
myOSystem->console().toggleFormat();
break;

View File

@ -118,12 +118,16 @@ class EventHandler
void setupJoysticks();
/**
Maps the given stelladaptors to specified ports on a real 2600
Maps the given Stelladaptor/2600-daptor(s) to specified ports on a real 2600.
@param sa1 Port for the first Stelladaptor to emulate (left or right)
@param sa2 Port for the second Stelladaptor to emulate (left or right)
@param saport How to map the ports ('lr' or 'rl')
*/
void mapStelladaptors(const string& sa1, const string& sa2);
void mapStelladaptors(const string& saport);
/**
Swaps the ordering of Stelladaptor/2600-daptor(s) devices.
*/
void toggleSAPortOrder();
/**
Collects and dispatches any pending events. This method should be

View File

@ -76,8 +76,7 @@ Settings::Settings(OSystem* osystem)
setInternal("mcontrol", "auto");
setInternal("dsense", "5");
setInternal("msense", "7");
setInternal("sa1", "left");
setInternal("sa2", "right");
setInternal("saport", "lr");
setInternal("ctrlcombo", "true");
// Snapshot options
@ -373,8 +372,7 @@ void Settings::usage()
<< " 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"
<< " -sa2 <left|right> Stelladaptor 2 emulates specified joystick port\n"
<< " -saport <lr|rl> How to assign virtual ports to multiple Stelladaptor/2600-daptors\n"
<< " -ctrlcombo <1|0> Use key combos involving the Control key (Control-Q for quit may be disabled!)\n"
<< " -autoslot <1|0> Automatically switch to next save slot when state saving\n"
<< " -stats <1|0> Overlay console info during emulation\n"

View File

@ -121,8 +121,8 @@ void InputDialog::addDevicePortTab(const GUI::Font& font)
pwidth = font.getStringWidth("left / right");
items.clear();
items.push_back("left / right", "leftright");
items.push_back("right / left", "rightleft");
items.push_back("left / right", "lr");
items.push_back("right / left", "rl");
mySAPort = new PopUpWidget(myTab, font, xpos, ypos, pwidth, lineHeight, items,
"Stelladaptor port order: ", lwidth);
wid.push_back(mySAPort);
@ -211,9 +211,8 @@ void InputDialog::addDevicePortTab(const GUI::Font& font)
void InputDialog::loadConfig()
{
// Left & right ports
const string& sa1 = instance().settings().getString("sa1");
int portorder = sa1 == "right" ? 1 : 0;
mySAPort->setSelected(portorder);
const string& saport = instance().settings().getString("saport");
mySAPort->setSelected(BSPF_equalsIgnoreCase(saport, "rl") ? 1 : 0);
// Joystick deadzone
myDeadzone->setValue(instance().settings().getInt("joydeadzone"));
@ -245,11 +244,7 @@ void InputDialog::loadConfig()
void InputDialog::saveConfig()
{
// Left & right ports
int sa_order = mySAPort->getSelected();
if(sa_order == 0)
instance().eventHandler().mapStelladaptors("left", "right");
else
instance().eventHandler().mapStelladaptors("right", "left");
instance().eventHandler().mapStelladaptors(mySAPort->getSelectedTag());
// Joystick deadzone
int deadzone = myDeadzone->getValue();
@ -298,7 +293,7 @@ void InputDialog::setDefaults()
case 2: // Virtual devices
{
// Left & right ports
mySAPort->setSelected("leftright", "leftright");
mySAPort->setSelected("lr", "lr");
// Joystick deadzone
myDeadzone->setValue(0);