| 1 | /**************************************************************************** |
| 2 | ** |
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. |
| 4 | ** Contact: http://www.qt.io/licensing/ |
| 5 | ** |
| 6 | ** This file is part of the QtFeedback module of the Qt Toolkit. |
| 7 | ** |
| 8 | ** $QT_BEGIN_LICENSE:LGPL3$ |
| 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 http://www.qt.io/terms-conditions. For further |
| 15 | ** information use the contact form at http://www.qt.io/contact-us. |
| 16 | ** |
| 17 | ** GNU Lesser General Public License Usage |
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
| 19 | ** General Public License version 3 as published by the Free Software |
| 20 | ** Foundation and appearing in the file LICENSE.LGPLv3 included in the |
| 21 | ** packaging of this file. Please review the following information to |
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements |
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl.html. |
| 24 | ** |
| 25 | ** GNU General Public License Usage |
| 26 | ** Alternatively, this file may be used under the terms of the GNU |
| 27 | ** General Public License version 2.0 or later as published by the Free |
| 28 | ** Software Foundation and appearing in the file LICENSE.GPL included in |
| 29 | ** the packaging of this file. Please review the following information to |
| 30 | ** ensure the GNU General Public License version 2.0 requirements will be |
| 31 | ** met: http://www.gnu.org/licenses/gpl-2.0.html. |
| 32 | ** |
| 33 | ** $QT_END_LICENSE$ |
| 34 | ** |
| 35 | ****************************************************************************/ |
| 36 | |
| 37 | #ifndef QFEEDBACKPLUGIN_H |
| 38 | #define QFEEDBACKPLUGIN_H |
| 39 | |
| 40 | #include <qfeedbackactuator.h> |
| 41 | #include <qfeedbackeffect.h> |
| 42 | |
| 43 | QT_BEGIN_HEADER |
| 44 | QT_BEGIN_NAMESPACE |
| 45 | |
| 46 | class Q_FEEDBACK_EXPORT QFeedbackInterface |
| 47 | { |
| 48 | public: |
| 49 | enum PluginPriority { |
| 50 | PluginLowPriority, |
| 51 | PluginNormalPriority, |
| 52 | PluginHighPriority |
| 53 | }; |
| 54 | |
| 55 | protected: |
| 56 | static void reportError(const QFeedbackEffect *, QFeedbackEffect::ErrorType); |
| 57 | }; |
| 58 | |
| 59 | class Q_FEEDBACK_EXPORT QFeedbackHapticsInterface : public QFeedbackInterface |
| 60 | { |
| 61 | public: |
| 62 | //going with enums allow more flexibility without breaking BC |
| 63 | enum EffectProperty { |
| 64 | Duration, |
| 65 | Intensity, |
| 66 | AttackTime, |
| 67 | AttackIntensity, |
| 68 | FadeTime, |
| 69 | FadeIntensity, |
| 70 | Period //optional |
| 71 | }; |
| 72 | |
| 73 | enum ActuatorProperty { |
| 74 | Name, |
| 75 | State, |
| 76 | Enabled |
| 77 | }; |
| 78 | |
| 79 | //static members for actuators management |
| 80 | virtual QList<QFeedbackActuator*> actuators() = 0; |
| 81 | virtual ~QFeedbackHapticsInterface() {} |
| 82 | |
| 83 | virtual PluginPriority pluginPriority() = 0; |
| 84 | |
| 85 | //for actuator handling |
| 86 | virtual void setActuatorProperty(const QFeedbackActuator &, ActuatorProperty, const QVariant &) = 0; |
| 87 | virtual QVariant actuatorProperty(const QFeedbackActuator &, ActuatorProperty) = 0; |
| 88 | virtual bool isActuatorCapabilitySupported(const QFeedbackActuator &, QFeedbackActuator::Capability) = 0; |
| 89 | |
| 90 | //effects |
| 91 | virtual void updateEffectProperty(const QFeedbackHapticsEffect *, EffectProperty) = 0; |
| 92 | virtual void setEffectState(const QFeedbackHapticsEffect *, QFeedbackEffect::State) = 0; |
| 93 | virtual QFeedbackEffect::State effectState(const QFeedbackHapticsEffect *) = 0; |
| 94 | |
| 95 | static QFeedbackHapticsInterface *instance(); |
| 96 | |
| 97 | protected: |
| 98 | //utility function for the backends |
| 99 | QFeedbackActuator* createFeedbackActuator(QObject* parent, int id); |
| 100 | }; |
| 101 | |
| 102 | class QFeedbackThemeInterface : public QFeedbackInterface |
| 103 | { |
| 104 | public: |
| 105 | virtual ~QFeedbackThemeInterface() {} |
| 106 | virtual PluginPriority pluginPriority() = 0; |
| 107 | virtual bool play(QFeedbackEffect::Effect) = 0; |
| 108 | static QFeedbackThemeInterface *instance(); |
| 109 | }; |
| 110 | |
| 111 | class Q_FEEDBACK_EXPORT QFeedbackFileInterface : public QFeedbackInterface |
| 112 | { |
| 113 | public: |
| 114 | virtual ~QFeedbackFileInterface() {} |
| 115 | virtual void setLoaded(QFeedbackFileEffect*, bool) = 0; |
| 116 | virtual void setEffectState(QFeedbackFileEffect *, QFeedbackEffect::State) = 0; |
| 117 | virtual QFeedbackEffect::State effectState(const QFeedbackFileEffect *) = 0; |
| 118 | virtual int effectDuration(const QFeedbackFileEffect*) = 0; |
| 119 | virtual QStringList supportedMimeTypes() = 0; |
| 120 | |
| 121 | static QFeedbackFileInterface *instance(); |
| 122 | |
| 123 | protected: |
| 124 | static void reportLoadFinished(QFeedbackFileEffect*, bool success); |
| 125 | }; |
| 126 | |
| 127 | Q_DECLARE_INTERFACE(QFeedbackHapticsInterface, "com.nokia.qt.QFeedbackHapticsInterface/1.0" ) |
| 128 | Q_DECLARE_INTERFACE(QFeedbackThemeInterface, "com.nokia.qt.QFeedbackThemeInterface/1.0" ) |
| 129 | Q_DECLARE_INTERFACE(QFeedbackFileInterface, "com.nokia.qt.QFeedbackFileInterface/1.0" ) |
| 130 | |
| 131 | QT_END_NAMESPACE |
| 132 | QT_END_HEADER |
| 133 | |
| 134 | #endif // QFEEDBACKPLUGININTERFACES_H |
| 135 | |