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 QACCELEROMETER_H
5#define QACCELEROMETER_H
6
7#include <QtSensors/qsensor.h>
8
9QT_BEGIN_NAMESPACE
10
11class QAccelerometerReadingPrivate;
12
13class Q_SENSORS_EXPORT QAccelerometerReading : public QSensorReading
14{
15 Q_OBJECT
16 Q_PROPERTY(qreal x READ x)
17 Q_PROPERTY(qreal y READ y)
18 Q_PROPERTY(qreal z READ z)
19 DECLARE_READING(QAccelerometerReading)
20public:
21 qreal x() const;
22 void setX(qreal x);
23
24 qreal y() const;
25 void setY(qreal y);
26
27 qreal z() const;
28 void setZ(qreal z);
29};
30
31class Q_SENSORS_EXPORT QAccelerometerFilter : public QSensorFilter
32{
33public:
34 virtual bool filter(QAccelerometerReading *reading) = 0;
35private:
36 bool filter(QSensorReading *reading) override;
37};
38
39class QAccelerometerPrivate;
40
41class Q_SENSORS_EXPORT QAccelerometer : public QSensor
42{
43 Q_OBJECT
44 Q_PROPERTY(AccelerationMode accelerationMode READ accelerationMode WRITE setAccelerationMode
45 NOTIFY accelerationModeChanged)
46public:
47 explicit QAccelerometer(QObject *parent = nullptr);
48 virtual ~QAccelerometer();
49
50 // Keep this enum in sync with QmlAccelerometer::AccelerationMode
51 enum AccelerationMode {
52 Combined,
53 Gravity,
54 User
55 };
56 Q_ENUM(AccelerationMode)
57
58 AccelerationMode accelerationMode() const;
59 void setAccelerationMode(AccelerationMode accelerationMode);
60
61 QAccelerometerReading *reading() const;
62 static char const * const sensorType;
63
64Q_SIGNALS:
65 void accelerationModeChanged(AccelerationMode accelerationMode);
66
67private:
68 Q_DECLARE_PRIVATE(QAccelerometer)
69 Q_DISABLE_COPY(QAccelerometer)
70};
71
72QT_END_NAMESPACE
73
74#endif
75

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