5 * th9x - http://code.google.com/p/th9x
6 * er9x - http://code.google.com/p/er9x
7 * gruvin9x - http://code.google.com/p/gruvin9x
9 * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
21 #ifndef _SIMULATORWIDGET_H_
22 #define _SIMULATORWIDGET_H_
24 #include "constants.h"
26 #include "radiodata.h"
27 #include "radiowidget.h"
28 #include "simulator.h"
29 #include "simulatorinterface.h"
31 #include <QElapsedTimer>
36 void traceCb(const char * text
);
39 class SimulatorInterface
;
40 class SimulatedUIWidget
;
41 class VirtualJoystickWidget
;
52 class SimulatorWidget
;
55 class SimulatorWidget
: public QWidget
60 explicit SimulatorWidget(QWidget
* parent
, SimulatorInterface
*simulator
, quint8 flags
=0);
61 virtual ~SimulatorWidget();
63 void setSdPath(const QString
& sdPath
);
64 void setDataPath(const QString
& dataPath
);
65 void setPaths(const QString
& sdPath
, const QString
& dataPath
);
66 void setRadioSettings(const GeneralSettings settings
);
67 bool setStartupData(const QByteArray
& dataSource
= NULL
, bool fromFile
= false);
68 bool setRadioData(RadioData
* radioData
);
69 bool setOptions(SimulatorOptions
& options
, bool withSave
= true);
70 bool saveRadioData(RadioData
* radioData
, const QString
& path
= "", QString
* error
= NULL
);
71 bool useTempDataPath(bool deleteOnClose
= true);
73 void deleteTempData();
75 void setUiAreaStyle(const QString
& style
);
76 void captureScreenshot(bool);
77 void setupJoysticks();
79 QString
getSdPath() const { return sdCardPath
; }
80 QString
getDataPath() const { return radioDataPath
; }
81 QVector
<Simulator::keymapHelp_t
> getKeymapHelp() const { return keymapHelp
; }
90 void stickValueChange(int axis
, int value
);
91 void stickModeChange(const unsigned mode
);
92 void widgetValueChange(const RadioWidget::RadioWidgetType type
, const int index
, const int value
);
93 void widgetStateChange(const RadioWidget::RadioWidgetState
& state
);
94 void inputValueChange(int type
, quint8 index
, qint16 value
);
95 void simulatorSetData(const QByteArray
& data
);
97 void simulatorStart(const char * filename
, bool tests
);
99 void simulatorSdPathChange(const QString
& sdPath
, const QString
& dataPath
);
100 void simulatorVolumeGainChange(const int gain
);
103 virtual void mousePressEvent(QMouseEvent
*event
);
104 virtual void mouseReleaseEvent(QMouseEvent
*event
);
105 virtual void wheelEvent(QWheelEvent
*event
);
108 void onSimulatorStarted();
109 void onSimulatorStopped();
110 void onSimulatorHeartbeat(qint32 loops
, qint64 timestamp
);
111 void onPhaseChanged(qint32 phase
, const QString
& name
);
112 void onSimulatorError(const QString
& error
);
113 void onRadioWidgetValueChange(const RadioWidget::RadioWidgetType type
, const int index
, int value
);
114 void onjoystickAxisValueChanged(int axis
, int value
);
116 void setRadioProfileId(int value
);
117 void setupRadioWidgets();
118 void restoreRadioWidgetsState();
121 void saveRadioWidgetsState(QList
<QByteArray
> & state
);
123 Ui::SimulatorWidget
* ui
;
124 SimulatorInterface
* simulator
;
126 GeneralSettings radioSettings
;
130 QVector
<Simulator::keymapHelp_t
> keymapHelp
;
131 QElapsedTimer m_heartbeatTimer
;
133 SimulatedUIWidget
* radioUiWidget
;
134 VirtualJoystickWidget
* vJoyLeft
;
135 VirtualJoystickWidget
* vJoyRight
;
136 QVector
<RadioWidget
*> m_radioWidgets
;
139 QString radioDataPath
;
140 QByteArray startupData
;
144 bool startupFromFile
;
145 bool deleteTempRadioData
;
146 bool saveTempRadioData
;
154 #endif // _SIMULATORWIDGET_H_