1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QTAPSENSOR_H
5#define QTAPSENSOR_H
6
7#include <QtSensors/qsensor.h>
8
9QT_BEGIN_NAMESPACE
10
11class QTapReadingPrivate;
12
13class Q_SENSORS_EXPORT QTapReading : public QSensorReading
14{
15 Q_OBJECT
16 Q_PROPERTY(TapDirection tapDirection READ tapDirection)
17 Q_PROPERTY(bool doubleTap READ isDoubleTap)
18 DECLARE_READING(QTapReading)
19public:
20 enum TapDirection {
21 Undefined = 0,
22 X = 0x0001,
23 Y = 0x0002,
24 Z = 0x0004,
25 X_Pos = 0x0011,
26 Y_Pos = 0x0022,
27 Z_Pos = 0x0044,
28 X_Neg = 0x0101,
29 Y_Neg = 0x0202,
30 Z_Neg = 0x0404,
31 X_Both = 0x0111,
32 Y_Both = 0x0222,
33 Z_Both = 0x0444
34 };
35 Q_ENUM(TapDirection)
36
37 TapDirection tapDirection() const;
38 void setTapDirection(TapDirection tapDirection);
39
40 bool isDoubleTap() const;
41 void setDoubleTap(bool doubleTap);
42};
43
44class Q_SENSORS_EXPORT QTapFilter : public QSensorFilter
45{
46public:
47 virtual bool filter(QTapReading *reading) = 0;
48private:
49 bool filter(QSensorReading *reading) override;
50};
51
52class QTapSensorPrivate;
53
54class Q_SENSORS_EXPORT QTapSensor : public QSensor
55{
56 Q_OBJECT
57 Q_PROPERTY(bool returnDoubleTapEvents READ returnDoubleTapEvents WRITE setReturnDoubleTapEvents
58 NOTIFY returnDoubleTapEventsChanged)
59public:
60 explicit QTapSensor(QObject *parent = nullptr);
61 virtual ~QTapSensor();
62 QTapReading *reading() const;
63 static char const * const sensorType;
64
65 bool returnDoubleTapEvents() const;
66 void setReturnDoubleTapEvents(bool returnDoubleTapEvents);
67
68Q_SIGNALS:
69 void returnDoubleTapEventsChanged(bool returnDoubleTapEvents);
70
71private:
72 Q_DECLARE_PRIVATE(QTapSensor)
73 Q_DISABLE_COPY(QTapSensor)
74};
75
76QT_END_NAMESPACE
77
78#endif
79

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