[Simulator] Further Simulator improvements. (#4282)
* Refactor CompStoreObj to use templates. Clean up some formatting.
* [Simulator] Add SimulatorOptions type to replace individual simulator options; Fix storage handler for custom types; Cleanup some redundant code.
* [Simulator][Joystick] Rework the joystick options/calibration dialog. Can now enable/disable/select the Joystick from there. Delay start of calibration until Start is pressed (otherwise looks like last calibration didn't work). And generally refactor a lot of it to be smarter.
* Cosmetics.
* [Simulator] Add state handling for RadioWidget class. Split code to cpp file.
* [Simulator] Add SimulatorStartupDialog as its own UI class.
* [Simulator] Multiple changes and new features:
All Horus data source options are now fully supported with data properly saved after use (SD path, .otx file, or custom data path);
Loading .otx files now works for all radio types (but not saving data back to .otx);
Switch and knob/slider states are now saved to per radio profile;
Joystick configuration/calibration is now available directly from inside Simulator;
Due to refactoring, all previously saved per-profile simulator settings are now invalid;
Further consolidated simulator dialog startup/shutdown, now handles temp. paths internally, etc;
With WIN_USE_CONSOLE defined, Simulator and Companion when started from Windows command line will now use that console for all messages (instead of opening a new one). This allows full debug output to be seen at all stages of execution and after exit.
* [Simulator] Fix build w/out SDL Joystick support.
* [Simulator] Fix bogus throttle warning on simulator start; Add forgotten RadioWidgetState flags to stream handlers; Add debug state saver in SimulatorOptions.
This commit is contained in:
committed by
Bertrand Songis
parent
b53ec7392c
commit
6e2474081f
@@ -30,8 +30,13 @@
|
||||
#include <QString>
|
||||
#include <QSettings>
|
||||
|
||||
#define COMPANY "OpenTX"
|
||||
#define PRODUCT "Companion 2.2"
|
||||
#include "simulator.h"
|
||||
|
||||
#define COMPANY "OpenTX"
|
||||
#define COMPANY_DOMAIN "open-tx.org"
|
||||
#define PRODUCT "Companion 2.2"
|
||||
#define APP_COMPANION "OpenTX Companion"
|
||||
#define APP_SIMULATOR "OpenTX Simulator"
|
||||
|
||||
#define MAX_PROFILES 15
|
||||
#define MAX_JOYSTICKS 8
|
||||
@@ -39,26 +44,24 @@
|
||||
class CompStoreObj
|
||||
{
|
||||
public:
|
||||
void clear (const QString tag1="", const QString tag2="", const QString tag3="");
|
||||
void store(const QByteArray newArray, QByteArray &array, const QString tag, const QString group1="", const QString group2="" );
|
||||
void store(const QStringList newSList, QStringList &stringList, const QString tag, const QString group1="", const QString group2="" );
|
||||
void store(const QString newString, QString &string, const QString tag, const QString group1="", const QString group2="" );
|
||||
void store(const bool newTruth, bool &truth, const QString tag, const QString group1="", const QString group2="" );
|
||||
void store(const int newNumber, int &number, const QString tag, const QString group1="", const QString group2="" );
|
||||
void clear (const QString & tag1 = "", const QString &tag2 = "", const QString &tag3 = "");
|
||||
|
||||
// Retrieval functions
|
||||
void retrieve( QByteArray &array, const QString tag, const QString def, const QString group1="", const QString group2="" );
|
||||
void retrieve( QStringList &stringList, const QString tag, const QString def, const QString group1="", const QString group2="" );
|
||||
void retrieve( QString &string, const QString tag, const QString def, const QString group1="", const QString group2="" );
|
||||
void retrieve( bool &truth, const QString tag, const bool def, const QString group1="", const QString group2="" );
|
||||
void retrieve( int &number, const QString tag, const int def, const QString group1="", const QString group2="" );
|
||||
// NOTE: OBJ_T can only be a standard or registered Qt type. To use custom types,
|
||||
// either Q_DECLARE_METATYPE() them or add additional logic in retrieve() to handle QMetaType::User.
|
||||
|
||||
template <typename OBJ_T, typename TAG_T, typename GP1_T = QString, typename GP2_T = QString>
|
||||
void store(const OBJ_T newValue, OBJ_T & destValue, const TAG_T tag, const GP1_T group1 = "", const GP2_T group2 = "");
|
||||
|
||||
template <typename OBJ_T, typename TAG_T, typename DEF_T, typename GP1_T = QString, typename GP2_T = QString>
|
||||
void retrieve(OBJ_T & destValue, const TAG_T tag, const DEF_T def, const GP1_T group1 = "", const GP2_T group2 = "");
|
||||
|
||||
template <typename OBJ_T, typename TAG_T, typename DEF_T, typename GP1_T = QString, typename GP2_T = QString>
|
||||
void getset(OBJ_T & value, const TAG_T tag, const DEF_T def, const GP1_T group1 = "", const GP2_T group2 = "" );
|
||||
|
||||
// this specialization is needed because QVariant::fromValue(const char *) fails
|
||||
template <typename OBJ_T, typename TAG_T, typename GP1_T = QString, typename GP2_T = QString>
|
||||
void getset(OBJ_T & value, const TAG_T tag, const char * def, const GP1_T group1 = "", const GP2_T group2 = "" );
|
||||
|
||||
// Retrieve and Store functions
|
||||
void getset( QByteArray &array, const QString tag, const QString def, const QString group1="", const QString group2="" );
|
||||
void getset( QStringList &stringList, const QString tag, const QString def, const QString group1="", const QString group2="" );
|
||||
void getset( QString &string, const QString tag, const QString def, const QString group1="", const QString group2="" );
|
||||
void getset( bool &truth, const QString tag, const bool def, const QString group1="", const QString group2="" );
|
||||
void getset( int &number, const QString tag, const int def, const QString group1="", const QString group2="" );
|
||||
};
|
||||
|
||||
class FwRevision: protected CompStoreObj
|
||||
@@ -122,9 +125,6 @@ class Profile: protected CompStoreObj
|
||||
int _channelOrder;
|
||||
int _defaultMode;
|
||||
|
||||
// Simulator variables
|
||||
QByteArray _simuWinGeo;
|
||||
|
||||
// Firmware Variables
|
||||
QString _beeper;
|
||||
QString _countryCode;
|
||||
@@ -136,13 +136,16 @@ class Profile: protected CompStoreObj
|
||||
QString _trainerCalib;
|
||||
QString _controlTypes;
|
||||
QString _controlNames;
|
||||
int _txCurrentCalibration;
|
||||
int _gsStickMode;
|
||||
int _ppmMultiplier;
|
||||
int _txVoltageCalibration;
|
||||
int _vBatWarn;
|
||||
int _vBatMin;
|
||||
int _vBatMax;
|
||||
int _txCurrentCalibration;
|
||||
int _txVoltageCalibration;
|
||||
|
||||
// Simulator variables
|
||||
SimulatorOptions _simulatorOptions;
|
||||
|
||||
public:
|
||||
// All the get definitions
|
||||
@@ -159,8 +162,6 @@ class Profile: protected CompStoreObj
|
||||
int channelOrder() const;
|
||||
int defaultMode() const;
|
||||
|
||||
QByteArray simuWinGeo() const;
|
||||
|
||||
QString beeper() const;
|
||||
QString countryCode() const;
|
||||
QString display() const;
|
||||
@@ -179,6 +180,8 @@ class Profile: protected CompStoreObj
|
||||
int vBatMin() const;
|
||||
int vBatMax() const;
|
||||
|
||||
SimulatorOptions simulatorOptions() const;
|
||||
|
||||
// All the set definitions
|
||||
void name (const QString);
|
||||
void fwName (const QString);
|
||||
@@ -193,8 +196,6 @@ class Profile: protected CompStoreObj
|
||||
void channelOrder (const int);
|
||||
void defaultMode (const int);
|
||||
|
||||
void simuWinGeo (const QByteArray);
|
||||
|
||||
void beeper (const QString);
|
||||
void countryCode (const QString);
|
||||
void display (const QString);
|
||||
@@ -213,6 +214,8 @@ class Profile: protected CompStoreObj
|
||||
void vBatMin (const int);
|
||||
void vBatMax (const int);
|
||||
|
||||
void simulatorOptions (const SimulatorOptions &);
|
||||
|
||||
Profile();
|
||||
Profile& operator=(const Profile&);
|
||||
void remove();
|
||||
@@ -220,6 +223,7 @@ class Profile: protected CompStoreObj
|
||||
void init(int newIndex);
|
||||
void initFwVariables();
|
||||
void flush();
|
||||
QString groupId();
|
||||
};
|
||||
|
||||
#define BOOL_PROPERTY(name, dflt) \
|
||||
@@ -231,12 +235,12 @@ class Profile: protected CompStoreObj
|
||||
|
||||
class AppData: protected CompStoreObj
|
||||
{
|
||||
BOOL_PROPERTY(enableBackup, false)
|
||||
BOOL_PROPERTY(outputDisplayDetails, false)
|
||||
BOOL_PROPERTY(backupOnFlash, true)
|
||||
BOOL_PROPERTY(enableBackup, false)
|
||||
BOOL_PROPERTY(backupOnFlash, true)
|
||||
BOOL_PROPERTY(outputDisplayDetails, false)
|
||||
BOOL_PROPERTY(checkHardwareCompatibility, true)
|
||||
BOOL_PROPERTY(useCompanionNightlyBuilds, false)
|
||||
BOOL_PROPERTY(useFirmwareNightlyBuilds, false)
|
||||
BOOL_PROPERTY(useCompanionNightlyBuilds, false)
|
||||
BOOL_PROPERTY(useFirmwareNightlyBuilds, false)
|
||||
|
||||
// All the global variables
|
||||
public:
|
||||
@@ -261,9 +265,6 @@ class AppData: protected CompStoreObj
|
||||
QString _programmer;
|
||||
QString _sambaLocation;
|
||||
QString _sambaPort;
|
||||
QString _lastSimulator;
|
||||
QString _simuLastEepe;
|
||||
QString _simuLastFolder;
|
||||
|
||||
QString _backupDir;
|
||||
QString _gePath;
|
||||
@@ -315,9 +316,6 @@ class AppData: protected CompStoreObj
|
||||
QString programmer();
|
||||
QString sambaLocation();
|
||||
QString sambaPort();
|
||||
QString lastSimulator();
|
||||
QString simuLastEepe();
|
||||
QString simuLastFolder();
|
||||
|
||||
QString backupDir();
|
||||
QString gePath();
|
||||
@@ -368,9 +366,6 @@ class AppData: protected CompStoreObj
|
||||
void programmer (const QString);
|
||||
void sambaLocation (const QString);
|
||||
void sambaPort (const QString);
|
||||
void lastSimulator (const QString);
|
||||
void simuLastEepe (const QString);
|
||||
void simuLastFolder (const QString);
|
||||
|
||||
void backupDir (const QString);
|
||||
void gePath (const QString);
|
||||
|
||||
Reference in New Issue
Block a user