diff --git a/Changes.txt b/Changes.txt index 682031785..154bb8440 100644 --- a/Changes.txt +++ b/Changes.txt @@ -37,6 +37,8 @@ are no longer corrupted/cut off. This includes properly supporting the 2600-daptor II, which is flashable to an AVox-USB converter. + * The serial port to use for an AtariVox-USB adaptor is now autodetected. + * Added QuadTari controller support. * Added option to select the audio device. diff --git a/src/common/bspf.hxx b/src/common/bspf.hxx index 9c7fb02df..d03174558 100644 --- a/src/common/bspf.hxx +++ b/src/common/bspf.hxx @@ -93,6 +93,14 @@ constexpr size_t operator "" _KB(unsigned long long size) return static_cast(size * 1024); } +// Output contents of a vector +template +std::ostream& operator<< (std::ostream& out, const std::vector& v) { + for(const auto& elem: v) + out << elem << " "; + return out; +} + static const string EmptyString(""); // This is defined by some systems, but Stella has other uses for it diff --git a/src/gui/InputDialog.cxx b/src/gui/InputDialog.cxx index 727c9a874..d7b915e75 100644 --- a/src/gui/InputDialog.cxx +++ b/src/gui/InputDialog.cxx @@ -34,6 +34,7 @@ #include "Widget.hxx" #include "Font.hxx" #include "MessageBox.hxx" +#include "MediaFactory.hxx" #include "InputDialog.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -222,10 +223,11 @@ void InputDialog::addDevicePortTab() // Add AtariVox serial port ypos += lineHeight + VGAP * 3; lwidth = _font.getStringWidth("AtariVox serial port "); - fwidth = _w - HBORDER * 2 - 2 - lwidth; - new StaticTextWidget(myTab, _font, HBORDER, ypos + 2, "AtariVox serial port "); - myAVoxPort = new EditTextWidget(myTab, _font, HBORDER + lwidth, ypos, - fwidth, fontHeight); + fwidth = _w - HBORDER * 2 - 2 - lwidth - 20; + VariantList items; + VarList::push_back(items, "None detected", ""); + myAVoxPort = new PopUpWidget(myTab, _font, HBORDER, ypos, fwidth, lineHeight, items, + "AtariVox serial port ", lwidth, kCursorStateChanged); wid.push_back(myAVoxPort); // Add items for virtual device ports @@ -359,7 +361,16 @@ void InputDialog::loadConfig() myAutoFireRate->setValue(settings.getInt("autofirerate")); // AtariVox serial port - myAVoxPort->setText(settings.getString("avoxport")); + const string& avoxport = settings.getString("avoxport"); + StringList ports = MediaFactory::createSerialPort()->portNames(); + if(avoxport != EmptyString && !BSPF::contains(ports, avoxport)) + ports.push_back(avoxport); + VariantList items; + VarList::push_back(items, "None detected", ""); + for(const auto& port: ports) + VarList::push_back(items, port, port); + myAVoxPort->addItems(items); + myAVoxPort->setSelected(avoxport); // EEPROM erase (only enable in emulation mode and for valid controllers) if(instance().hasConsole()) @@ -440,7 +451,7 @@ void InputDialog::saveConfig() Controller::setAutoFireRate(rate); // AtariVox serial port - settings.setValue("avoxport", myAVoxPort->getText()); + settings.setValue("avoxport", myAVoxPort->getSelectedTag().toString()); // Allow all 4 joystick directions bool allowall4 = myAllowAll4->getState(); @@ -500,7 +511,7 @@ void InputDialog::setDefaults() // Autofire rate myAutoFireRate->setValue(0); // AtariVox serial port - myAVoxPort->setText(""); + myAVoxPort->setSelectedMax(); // Allow all 4 joystick directions myAllowAll4->setState(false); diff --git a/src/gui/InputDialog.hxx b/src/gui/InputDialog.hxx index 6cb6c4742..201f807d3 100644 --- a/src/gui/InputDialog.hxx +++ b/src/gui/InputDialog.hxx @@ -94,7 +94,7 @@ class InputDialog : public Dialog CheckboxWidget* mySAPort{nullptr}; - EditTextWidget* myAVoxPort{nullptr}; + PopUpWidget* myAVoxPort{nullptr}; SliderWidget* myDeadzone{nullptr}; SliderWidget* myPaddleSpeed{nullptr};