JoystickManager.h 2.27 KB
Newer Older
1 2 3 4 5 6 7 8 9
/****************************************************************************
 *
 *   (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/

10 11 12 13 14 15

#ifndef JoystickManager_H
#define JoystickManager_H

#include "QGCLoggingCategory.h"
#include "Joystick.h"
16 17
#include "MultiVehicleManager.h"
#include "QGCToolbox.h"
18 19 20 21 22

#include <QVariantList>

Q_DECLARE_LOGGING_CATEGORY(JoystickManagerLog)

23
class JoystickManager : public QGCTool
24 25 26 27
{
    Q_OBJECT
    
public:
28
    JoystickManager(QGCApplication* app, QGCToolbox* toolbox);
29
    ~JoystickManager();
30

31
    /// List of available joysticks
Jacob Walser's avatar
Jacob Walser committed
32 33
    Q_PROPERTY(QVariantList joysticks READ joysticks NOTIFY availableJoysticksChanged)
    Q_PROPERTY(QStringList  joystickNames READ joystickNames NOTIFY availableJoysticksChanged)
34 35 36 37 38 39 40 41 42 43 44 45 46 47
    
    /// Active joystick
    Q_PROPERTY(Joystick* activeJoystick READ activeJoystick WRITE setActiveJoystick NOTIFY activeJoystickChanged)
    Q_PROPERTY(QString activeJoystickName READ activeJoystickName WRITE setActiveJoystickName NOTIFY activeJoystickNameChanged)
    
    QVariantList joysticks();
    QStringList joystickNames(void);
    
    Joystick* activeJoystick(void);
    void setActiveJoystick(Joystick* joystick);
    
    QString activeJoystickName(void);
    void setActiveJoystickName(const QString& name);

48 49
    void restartJoystickCheckTimer(void);

50 51 52
    // Override from QGCTool
    virtual void setToolbox(QGCToolbox *toolbox);

53
public slots:
Jacob Walser's avatar
Jacob Walser committed
54
    void init();
55

56 57 58
signals:
    void activeJoystickChanged(Joystick* joystick);
    void activeJoystickNameChanged(const QString& name);
Jacob Walser's avatar
Jacob Walser committed
59
    void availableJoysticksChanged(void);
60
    void updateAvailableJoysticksSignal();
61 62

private slots:
Jacob Walser's avatar
Jacob Walser committed
63
    void _updateAvailableJoysticks(void);
64 65 66 67 68
    
private:
    void _setActiveJoystickFromSettings(void);
    
private:
69
    Joystick*                   _activeJoystick;
70
    QMap<QString, Joystick*>    _name2JoystickMap;
71
    MultiVehicleManager*        _multiVehicleManager;
72 73 74
    
    static const char * _settingsGroup;
    static const char * _settingsKeyActiveJoystick;
Jacob Walser's avatar
Jacob Walser committed
75

76
    int _joystickCheckTimerCounter;
Jacob Walser's avatar
Jacob Walser committed
77
    QTimer _joystickCheckTimer;
78 79 80
};

#endif