From 3b4b10df769cb65ac72a9530e6872428a73cc766 Mon Sep 17 00:00:00 2001 From: stephena Date: Sat, 3 Mar 2012 00:56:31 +0000 Subject: [PATCH] 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 --- docs/index.html | 29 ++++++++------- src/emucore/EventHandler.cxx | 70 ++++++++++++++++++++++++++---------- src/emucore/EventHandler.hxx | 12 ++++--- src/emucore/Settings.cxx | 6 ++-- src/gui/InputDialog.cxx | 17 ++++----- 5 files changed, 84 insertions(+), 50 deletions(-) diff --git a/docs/index.html b/docs/index.html index 5d18d5d35..4fea8a1a4 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1471,6 +1471,12 @@ Control + 0 + + Swap Stelladaptor/2600-daptor port ordering + Control + 1 + Control + 1 + + Reload current ROM (singlecart ROM, TIA mode)
Load next game in ROM (multicart ROM, TIA mode) @@ -1602,7 +1608,7 @@ ✓ ✕ ✕ - ✕ + ✓ (2600-daptor II) Driving @@ -1901,13 +1907,10 @@ -
-sa1 <left|right>
- Stelladaptor/2600-daptor 1 emulates specified joystick port. - - - -
-sa2 <left|right>
- Stelladaptor/2600-daptor 2 emulates specified joystick port. +
-saport <lr|rl>
+ 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. @@ -2469,7 +2472,7 @@ - + @@ -2640,16 +2643,18 @@ diff --git a/src/emucore/EventHandler.cxx b/src/emucore/EventHandler.cxx index 93fd19efc..0ad14365f 100644 --- a/src/emucore/EventHandler.cxx +++ b/src/emucore/EventHandler.cxx @@ -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; diff --git a/src/emucore/EventHandler.hxx b/src/emucore/EventHandler.hxx index edd8a5b11..be5ef3b83 100644 --- a/src/emucore/EventHandler.hxx +++ b/src/emucore/EventHandler.hxx @@ -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 diff --git a/src/emucore/Settings.cxx b/src/emucore/Settings.cxx index 591b5b900..9cb631b73 100644 --- a/src/emucore/Settings.cxx +++ b/src/emucore/Settings.cxx @@ -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 Sensitivity of digital emulated paddle movement (1-10)\n" << " -msense Sensitivity of mouse emulated paddle movement (1-15)\n" - << " -sa1 Stelladaptor 1 emulates specified joystick port\n" - << " -sa2 Stelladaptor 2 emulates specified joystick port\n" + << " -saport 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" diff --git a/src/gui/InputDialog.cxx b/src/gui/InputDialog.cxx index 2b30fec71..ab5b7b6a0 100644 --- a/src/gui/InputDialog.cxx +++ b/src/gui/InputDialog.cxx @@ -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);
ItemBrief descriptionFor more information,
see CommandLine
Stelladaptor X isSpecifies which virtual port each Stelladaptor/2600-daptor uses (See Advanced Configuration - Stelladaptor/2600-daptor Support)-sa1 & -sa2
Stelladaptor X isSpecifies which virtual port each Stelladaptor/2600-daptor uses (See Advanced Configuration - Stelladaptor/2600-daptor Support)-saport
AVox serial portDescribed in further detail in Advanced Configuration - AtariVox/SaveKey Support -avoxport
Joy deadzone sizeDeadzone area for axes on joysticks/gamepads-joydeadzone
Digital paddle sensitivitySensitvity used when emulating a paddle using a digital device-dsense