JoystickManager.h 1.94 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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
    /// 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);

48 49 50
    // Override from QGCTool
    virtual void setToolbox(QGCToolbox *toolbox);

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

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

#endif