blob: 27f50d723a85c06d3cd2f327725aa8340106fc0e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "mybackend.h"
#include <qsensorplugin.h>
#include <qsensormanager.h>
const char *MyBackend::id = "mybackend";
//! [Plugin]
class MyPluginClass : public QObject, public QSensorPluginInterface, public QSensorBackendFactory
{
Q_OBJECT
//Q_PLUGIN_METADATA(IID "com.qt-project.Qt.QSensorPluginInterface/1.0" FILE "plugin.json")
Q_INTERFACES(QSensorPluginInterface)
public:
void registerSensors() override
{
QSensorManager::registerBackend(QAccelerometer::sensorType, MyBackend::id, this);
}
QSensorBackend *createBackend(QSensor *sensor) override
{
if (sensor->identifier() == MyBackend::id)
return new MyBackend(sensor);
return 0;
}
};
//! [Plugin]
#include "plugin.moc"
|