| 1 | /**************************************************************************** | 
| 2 | ** | 
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. | 
| 4 | ** Contact: https://www.qt.io/licensing/ | 
| 5 | ** | 
| 6 | ** This file is part of the QtFeedback module of the Qt Toolkit. | 
| 7 | ** | 
| 8 | ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ | 
| 9 | ** Commercial License Usage | 
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | 
| 11 | ** accordance with the commercial license agreement provided with the | 
| 12 | ** Software or, alternatively, in accordance with the terms contained in | 
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | 
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further | 
| 15 | ** information use the contact form at https://www.qt.io/contact-us. | 
| 16 | ** | 
| 17 | ** GNU General Public License Usage | 
| 18 | ** Alternatively, this file may be used under the terms of the GNU | 
| 19 | ** General Public License version 3 as published by the Free Software | 
| 20 | ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT | 
| 21 | ** included in the packaging of this file. Please review the following | 
| 22 | ** information to ensure the GNU General Public License requirements will | 
| 23 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. | 
| 24 | ** | 
| 25 | ** $QT_END_LICENSE$ | 
| 26 | ** | 
| 27 | ****************************************************************************/ | 
| 28 |  | 
| 29 | #ifndef QFEEDBACKTESTPLUGIN_H | 
| 30 | #define QFEEDBACKTESTPLUGIN_H | 
| 31 |  | 
| 32 |  | 
| 33 | #include <QtCore/QList> | 
| 34 | #include <QtCore/QVector> | 
| 35 | #include <QtCore/QHash> | 
| 36 | #include <QtCore/QMap> | 
| 37 | #include <QtCore/QObject> | 
| 38 | #include <QtCore/QMutex> | 
| 39 | #include <QtCore/QTimer> | 
| 40 |  | 
| 41 | #include <qfeedbackplugininterfaces.h> | 
| 42 |  | 
| 43 | QT_BEGIN_HEADER | 
| 44 | QT_USE_NAMESPACE | 
| 45 |  | 
| 46 | class QFeedbackTestPlugin : public QObject, public QFeedbackHapticsInterface, public QFeedbackFileInterface, public QFeedbackThemeInterface | 
| 47 | { | 
| 48 |     Q_OBJECT | 
| 49 |     Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtFeedbackTestPlugin" ) | 
| 50 |     Q_INTERFACES(QFeedbackHapticsInterface) | 
| 51 |     Q_INTERFACES(QFeedbackFileInterface) | 
| 52 |     Q_INTERFACES(QFeedbackThemeInterface) | 
| 53 | public: | 
| 54 |     QFeedbackTestPlugin(); | 
| 55 |     virtual ~QFeedbackTestPlugin(); | 
| 56 |  | 
| 57 |     virtual PluginPriority pluginPriority(); | 
| 58 |  | 
| 59 |     virtual QList<QFeedbackActuator*> actuators(); | 
| 60 |  | 
| 61 |     //for actuator handling | 
| 62 |     virtual void setActuatorProperty(const QFeedbackActuator &, ActuatorProperty, const QVariant &); | 
| 63 |     virtual QVariant actuatorProperty(const QFeedbackActuator &, ActuatorProperty); | 
| 64 |     virtual bool isActuatorCapabilitySupported(const QFeedbackActuator &, QFeedbackActuator::Capability); | 
| 65 |  | 
| 66 |     virtual void updateEffectProperty(const QFeedbackHapticsEffect *, EffectProperty); | 
| 67 |     virtual void setEffectState(const QFeedbackHapticsEffect *, QFeedbackEffect::State); | 
| 68 |     virtual QFeedbackEffect::State effectState(const QFeedbackHapticsEffect *); | 
| 69 |  | 
| 70 |     //for loading files | 
| 71 |     virtual void setLoaded(QFeedbackFileEffect*, bool); | 
| 72 |     virtual void setEffectState(QFeedbackFileEffect *, QFeedbackEffect::State); | 
| 73 |     virtual QFeedbackEffect::State effectState(const QFeedbackFileEffect *); | 
| 74 |     virtual int effectDuration(const QFeedbackFileEffect *); | 
| 75 |     virtual QStringList supportedMimeTypes(); | 
| 76 |  | 
| 77 |     // For themes | 
| 78 |     virtual bool play(QFeedbackEffect::Effect); | 
| 79 |  | 
| 80 | private slots: | 
| 81 |     void timerExpired(); | 
| 82 |  | 
| 83 | private: | 
| 84 |     QList<QFeedbackActuator*> actuators_; | 
| 85 |  | 
| 86 |     // Our hacky state | 
| 87 |     QFeedbackEffect::State mHapticState; | 
| 88 |     QFeedbackEffect::State mFileState; | 
| 89 |     QMap<QTimer*, const QFeedbackHapticsEffect*> mHapticEffects; | 
| 90 |     QTimer* ensureTimer(const QFeedbackHapticsEffect* effect); | 
| 91 | }; | 
| 92 |  | 
| 93 | QT_END_HEADER | 
| 94 |  | 
| 95 | #endif | 
| 96 |  |