JoystickManager.h 2.13 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);
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 50
    // Override from QGCTool
    virtual void setToolbox(QGCToolbox *toolbox);

51
public slots:
Jacob Walser's avatar
Jacob Walser committed
52
    void init();
53

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

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

    QTimer _joystickCheckTimer;
74 75 76
};

#endif