mirror of https://github.com/stella-emu/stella.git
Autodetect serial port for AVox-USB adaptor on startup, and set 'avoxport' argument.
This completely automates the discovery of the AVox port when only one such port exists. If there is more than one, this code selects the first one. Further work will allow the user to go into the Input dialog and select the correct one, if more than one exists. On my system, this adds about a 0.02 second delay to startup, so I think we can just leave it enabled. If it ends up being too slow on some systems, we can introduce an option to disable autodetection.
This commit is contained in:
parent
448df9765a
commit
91db2cdd33
|
@ -160,6 +160,12 @@ namespace BSPF
|
|||
return (val < lower) ? upper : (val > upper) ? lower : val;
|
||||
}
|
||||
|
||||
// Test whether the vector contains the given value
|
||||
template<typename T>
|
||||
bool contains(const std::vector<T>& v, const T& elem) {
|
||||
return !(v.empty() || std::find(v.begin(), v.end(), elem) == v.end());
|
||||
}
|
||||
|
||||
// Convert string to given case
|
||||
inline const string& toUpperCase(string& s)
|
||||
{
|
||||
|
|
|
@ -185,6 +185,14 @@ bool OSystem::create()
|
|||
|
||||
myPropSet->load(myPropertiesFile);
|
||||
|
||||
// Detect serial port for AtariVox-USB
|
||||
// If a previously set port is available, use it;
|
||||
// otherwise use the first one found (if any)
|
||||
StringList ports = MediaFactory::createSerialPort()->portNames();
|
||||
bool oldPortFound = BSPF::contains(ports, mySettings->getString("avoxport"));
|
||||
if(!oldPortFound && ports.size() > 0)
|
||||
mySettings->setValue("avoxport", ports[0]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue