JoystickManager.h 1.96 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 24 25
class QGCApplicaiton;

class JoystickManager : public QGCTool
26 27 28 29
{
    Q_OBJECT
    
public:
30
    JoystickManager(QGCApplication* app);
31
    ~JoystickManager();
32

33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
    /// List of available joysticks
    Q_PROPERTY(QVariantList joysticks READ joysticks CONSTANT)
    Q_PROPERTY(QStringList  joystickNames READ joystickNames CONSTANT)
    
    /// 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);

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

53 54 55 56 57 58 59 60 61 62
signals:
    void activeJoystickChanged(Joystick* joystick);
    void activeJoystickNameChanged(const QString& name);

private slots:
    
private:
    void _setActiveJoystickFromSettings(void);
    
private:
63
    Joystick*                   _activeJoystick;
64
    QMap<QString, Joystick*>    _name2JoystickMap;
65
    MultiVehicleManager*        _multiVehicleManager;
66 67 68 69 70 71
    
    static const char * _settingsGroup;
    static const char * _settingsKeyActiveJoystick;
};

#endif