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 QtSensors module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
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 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.LGPL3 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-3.0.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 (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#ifndef QTAPSENSOR_H
41#define QTAPSENSOR_H
42
43#include <QtSensors/qsensor.h>
44
45QT_BEGIN_NAMESPACE
46
47class QTapReadingPrivate;
48
49class Q_SENSORS_EXPORT QTapReading : public QSensorReading
50{
51 Q_OBJECT
52 Q_ENUMS(TapDirection)
53 Q_PROPERTY(TapDirection tapDirection READ tapDirection)
54 Q_PROPERTY(bool doubleTap READ isDoubleTap)
55 DECLARE_READING(QTapReading)
56public:
57 enum TapDirection {
58 Undefined = 0,
59 X = 0x0001,
60 Y = 0x0002,
61 Z = 0x0004,
62 X_Pos = 0x0011,
63 Y_Pos = 0x0022,
64 Z_Pos = 0x0044,
65 X_Neg = 0x0101,
66 Y_Neg = 0x0202,
67 Z_Neg = 0x0404,
68 X_Both = 0x0111,
69 Y_Both = 0x0222,
70 Z_Both = 0x0444
71 };
72
73 TapDirection tapDirection() const;
74 void setTapDirection(TapDirection tapDirection);
75
76 bool isDoubleTap() const;
77 void setDoubleTap(bool doubleTap);
78};
79
80class Q_SENSORS_EXPORT QTapFilter : public QSensorFilter
81{
82public:
83 virtual bool filter(QTapReading *reading) = 0;
84private:
85 bool filter(QSensorReading *reading) override;
86};
87
88class QTapSensorPrivate;
89
90class Q_SENSORS_EXPORT QTapSensor : public QSensor
91{
92 Q_OBJECT
93 Q_PROPERTY(bool returnDoubleTapEvents READ returnDoubleTapEvents WRITE setReturnDoubleTapEvents
94 NOTIFY returnDoubleTapEventsChanged)
95public:
96 explicit QTapSensor(QObject *parent = Q_NULLPTR);
97 virtual ~QTapSensor();
98 QTapReading *reading() const;
99 static char const * const type;
100
101 bool returnDoubleTapEvents() const;
102 void setReturnDoubleTapEvents(bool returnDoubleTapEvents);
103
104Q_SIGNALS:
105 void returnDoubleTapEventsChanged(bool returnDoubleTapEvents);
106
107private:
108 Q_DECLARE_PRIVATE(QTapSensor)
109 Q_DISABLE_COPY(QTapSensor)
110};
111
112QT_END_NAMESPACE
113
114#endif
115
116

source code of qtsensors/src/sensors/qtapsensor.h