00001 #ifndef QSHAKE_H 00002 #define QSHAKE_H 00003 00004 #include <QAccelerometer> 00005 #include <QAccelerometerFilter> 00006 #include <QAccelerometerReading> 00007 00008 QTM_USE_NAMESPACE 00009 00010 class QShake : public QObject, public QAccelerometerFilter 00011 { 00012 Q_OBJECT 00013 Q_CLASSINFO("Author", "Sebastiano Galazzo") 00014 Q_CLASSINFO("Email", "sebastiano.galazzo@gmail.com") 00015 Q_PROPERTY(float sensitivity READ sensitivity WRITE setSensitivity) 00016 Q_PROPERTY(QShake::Direction direction READ direction WRITE setDirection) 00017 Q_ENUMS(Level) 00018 Q_ENUMS(Direction) 00019 00020 public: 00021 QShake(QObject * parent = 0 ); 00022 00023 enum Level { 00024 Low=20, 00025 Medium=30, 00026 High=40, 00027 Step=10 00028 }; 00029 00030 enum Direction { 00031 All=0, 00032 LeftRight=1, 00033 UpDown=2, 00034 PushPull=3 00035 }; 00036 00037 float sensitivity() const; 00038 void setSensitivity(float value); 00039 00040 QShake::Direction direction() const; 00041 void setDirection(QShake::Direction value); 00042 00043 public slots: 00044 void start(); 00045 void stop(); 00046 00047 signals: 00048 void shake(bool shaked); 00049 00050 protected: 00051 bool filter(QAccelerometerReading *reading); 00052 00053 private: 00054 float module; 00055 float m_sensitivity; 00056 Direction m_direction; 00057 QAccelerometer sensor; 00058 }; 00059 00060 #endif // QSHAKE_H