Commit 41b2fd7e authored by Gus Grubba's avatar Gus Grubba

WIP

parent 2aa69014
This diff is collapsed.
...@@ -21,10 +21,33 @@ ...@@ -21,10 +21,33 @@
Q_DECLARE_LOGGING_CATEGORY(JoystickLog) Q_DECLARE_LOGGING_CATEGORY(JoystickLog)
Q_DECLARE_LOGGING_CATEGORY(JoystickValuesLog) Q_DECLARE_LOGGING_CATEGORY(JoystickValuesLog)
//-- Action assigned to button
class AssignedButtonAction : public QObject {
Q_OBJECT
public:
QString action;
QTime buttonTime;
bool repeat = false;
int frequency = 1;
};
//-- Assignable Button Action
class ButtonAction : public QObject {
Q_OBJECT
public:
ButtonAction(QObject* parent, QString action_, bool canRepeat_ = false);
Q_PROPERTY(QString action READ action CONSTANT)
Q_PROPERTY(bool canRepeat READ canRepeat CONSTANT)
QString action () { return _action; }
bool repeat () { return _repeat; }
private:
QString _action;
bool _repeat = false;
};
class Joystick : public QThread class Joystick : public QThread
{ {
Q_OBJECT Q_OBJECT
public: public:
Joystick(const QString& name, int axisCount, int buttonCount, int hatCount, MultiVehicleManager* multiVehicleManager); Joystick(const QString& name, int axisCount, int buttonCount, int hatCount, MultiVehicleManager* multiVehicleManager);
...@@ -65,8 +88,8 @@ public: ...@@ -65,8 +88,8 @@ public:
Q_PROPERTY(int totalButtonCount READ totalButtonCount CONSTANT) Q_PROPERTY(int totalButtonCount READ totalButtonCount CONSTANT)
Q_PROPERTY(int axisCount READ axisCount CONSTANT) Q_PROPERTY(int axisCount READ axisCount CONSTANT)
Q_PROPERTY(bool requiresCalibration READ requiresCalibration CONSTANT) Q_PROPERTY(bool requiresCalibration READ requiresCalibration CONSTANT)
Q_PROPERTY(QStringList actions READ actions CONSTANT) Q_PROPERTY(QList<ButtonAction*> actions READ actions CONSTANT)
Q_PROPERTY(QVariantList buttonActions READ buttonActions NOTIFY buttonActionsChanged) Q_PROPERTY(QStringList actionTitles READ actionTitles NOTIFY actionTitlesChanged)
Q_PROPERTY(bool gimbalEnabled READ gimbalEnabled WRITE setGimbalEnabled NOTIFY gimbalEnabledChanged) Q_PROPERTY(bool gimbalEnabled READ gimbalEnabled WRITE setGimbalEnabled NOTIFY gimbalEnabledChanged)
Q_PROPERTY(int throttleMode READ throttleMode WRITE setThrottleMode NOTIFY throttleModeChanged) Q_PROPERTY(int throttleMode READ throttleMode WRITE setThrottleMode NOTIFY throttleModeChanged)
...@@ -85,8 +108,8 @@ public: ...@@ -85,8 +108,8 @@ public:
int totalButtonCount () { return _totalButtonCount; } int totalButtonCount () { return _totalButtonCount; }
int axisCount () { return _axisCount; } int axisCount () { return _axisCount; }
bool gimbalEnabled () { return _gimbalEnabled; } bool gimbalEnabled () { return _gimbalEnabled; }
QStringList actions (); QList<ButtonAction*> actions ();
QVariantList buttonActions (); QStringList actionTitles ();
void setGimbalEnabled (bool set); void setGimbalEnabled (bool set);
...@@ -143,7 +166,7 @@ signals: ...@@ -143,7 +166,7 @@ signals:
void rawAxisValueChanged(int index, int value); void rawAxisValueChanged(int index, int value);
void rawButtonPressedChanged(int index, int pressed); void rawButtonPressedChanged(int index, int pressed);
void buttonActionsChanged(QVariantList actions); void actionTitlesChanged(QStringList actions);
void throttleModeChanged(int mode); void throttleModeChanged(int mode);
...@@ -166,7 +189,7 @@ signals: ...@@ -166,7 +189,7 @@ signals:
void manualControl (float roll, float pitch, float yaw, float throttle, quint16 buttons, int joystickMmode); void manualControl (float roll, float pitch, float yaw, float throttle, quint16 buttons, int joystickMmode);
void manualControlGimbal (float gimbalPitch, float gimbalYaw); void manualControlGimbal (float gimbalPitch, float gimbalYaw);
void buttonActionTriggered(int action); void buttonActionTriggered (int action);
void gimbalEnabledChanged (); void gimbalEnabledChanged ();
void frequencyChanged (); void frequencyChanged ();
...@@ -192,6 +215,8 @@ protected: ...@@ -192,6 +215,8 @@ protected:
void _buttonAction (const QString& action); void _buttonAction (const QString& action);
bool _validAxis (int axis); bool _validAxis (int axis);
bool _validButton (int button); bool _validButton (int button);
void _handleAxis ();
void _handleButtons ();
private: private:
virtual bool _open () = 0; virtual bool _open () = 0;
...@@ -244,11 +269,11 @@ protected: ...@@ -244,11 +269,11 @@ protected:
int _totalButtonCount; int _totalButtonCount;
static int _transmitterMode; static int _transmitterMode;
int _rgFunctionAxis[maxFunction] = {}; int _rgFunctionAxis[maxFunction] = {};
QTime _axisTime;
QStringList _rgButtonActions; QList<ButtonAction*> _actions;
QList<AssignedButtonAction*> _buttonActionArray;
MultiVehicleManager* _multiVehicleManager = nullptr; MultiVehicleManager* _multiVehicleManager = nullptr;
private: private:
...@@ -256,7 +281,9 @@ private: ...@@ -256,7 +281,9 @@ private:
static const char* _settingsGroup; static const char* _settingsGroup;
static const char* _calibratedSettingsKey; static const char* _calibratedSettingsKey;
static const char* _buttonActionSettingsKey; static const char* _buttonActionNameKey;
static const char* _buttonActionRepeatKey;
static const char* _buttonActionFrequencyKey;
static const char* _throttleModeSettingsKey; static const char* _throttleModeSettingsKey;
static const char* _exponentialSettingsKey; static const char* _exponentialSettingsKey;
static const char* _accumulatorSettingsKey; static const char* _accumulatorSettingsKey;
......
...@@ -48,7 +48,7 @@ Item { ...@@ -48,7 +48,7 @@ Item {
property bool pressed property bool pressed
QGCCheckBox { QGCCheckBox {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
checked: _activeJoystick ? _activeJoystick.buttonActions[modelData] !== "" : false checked: _activeJoystick ? _activeJoystick.actionTitles[modelData] !== "" : false
onClicked: _activeJoystick.setButtonAction(modelData, checked ? buttonActionCombo.textAt(buttonActionCombo.currentIndex) : "") onClicked: _activeJoystick.setButtonAction(modelData, checked ? buttonActionCombo.textAt(buttonActionCombo.currentIndex) : "")
} }
Rectangle { Rectangle {
...@@ -69,9 +69,23 @@ Item { ...@@ -69,9 +69,23 @@ Item {
QGCComboBox { QGCComboBox {
id: buttonActionCombo id: buttonActionCombo
width: ScreenTools.defaultFontPixelWidth * 26 width: ScreenTools.defaultFontPixelWidth * 26
model: _activeJoystick ? _activeJoystick.actions : 0 model: _activeJoystick ? _activeJoystick.actions : []
onActivated: _activeJoystick.setButtonAction(modelData, textAt(index)) onActivated: _activeJoystick.setButtonAction(modelData, textAt(index))
Component.onCompleted: currentIndex = find(_activeJoystick.buttonActions[modelData]) Component.onCompleted: currentIndex = find(_activeJoystick.actionTitles[modelData])
}
QGCCheckBox {
id: repeatCheck
text: qsTr("Repeat")
anchors.verticalCenter: parent.verticalCenter
}
QGCComboBox {
width: ScreenTools.defaultFontPixelWidth * 10
model: ["1Hz","2Hz","5Hz","10Hz"]
enabled: repeatCheck.checked
}
Item {
width: ScreenTools.defaultFontPixelWidth * 2
height: 1
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment