|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the Qt Mobility Components. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #include "maemo6accelerometer.h" |
|
43 #include "maemo6als.h" |
|
44 #include "maemo6compass.h" |
|
45 #include "maemo6magnetometer.h" |
|
46 #include "maemo6orientationsensor.h" |
|
47 #include "maemo6proximitysensor.h" |
|
48 #include "maemo6rotationsensor.h" |
|
49 #include "maemo6tapsensor.h" |
|
50 #include <qsensorplugin.h> |
|
51 #include <qsensorbackend.h> |
|
52 #include <qsensormanager.h> |
|
53 #include <QDebug> |
|
54 |
|
55 class maemo6SensorPlugin : public QObject, public QSensorPluginInterface, public QSensorBackendFactory |
|
56 { |
|
57 Q_OBJECT |
|
58 Q_INTERFACES(QtMobility::QSensorPluginInterface) |
|
59 public: |
|
60 void registerSensors() |
|
61 { |
|
62 QSensorManager::registerBackend(QAccelerometer::type, maemo6accelerometer::id, this); |
|
63 QSensorManager::registerBackend(QAmbientLightSensor::type, maemo6als::id, this); |
|
64 QSensorManager::registerBackend(QCompass::type, maemo6compass::id, this); |
|
65 QSensorManager::registerBackend(QMagnetometer::type, maemo6magnetometer::id, this); |
|
66 QSensorManager::registerBackend(QOrientationSensor::type, maemo6orientationsensor::id, this); |
|
67 QSensorManager::registerBackend(QProximitySensor::type, maemo6proximitysensor::id, this); |
|
68 QSensorManager::registerBackend(QRotationSensor::type, maemo6rotationsensor::id, this); |
|
69 QSensorManager::registerBackend(QTapSensor::type, maemo6tapsensor::id, this); |
|
70 qDebug() << "Loaded the Maemo 6 sensor plugin"; |
|
71 } |
|
72 |
|
73 QSensorBackend *createBackend(QSensor *sensor) |
|
74 { |
|
75 if (sensor->identifier() == maemo6accelerometer::id) |
|
76 return new maemo6accelerometer(sensor); |
|
77 else if (sensor->identifier() == maemo6als::id) |
|
78 return new maemo6als(sensor); |
|
79 else if (sensor->identifier() == maemo6compass::id) |
|
80 return new maemo6compass(sensor); |
|
81 else if (sensor->identifier() == maemo6magnetometer::id) |
|
82 return new maemo6magnetometer(sensor); |
|
83 else if (sensor->identifier() == maemo6orientationsensor::id) |
|
84 return new maemo6orientationsensor(sensor); |
|
85 else if (sensor->identifier() == maemo6proximitysensor::id) |
|
86 return new maemo6proximitysensor(sensor); |
|
87 else if (sensor->identifier() == maemo6rotationsensor::id) |
|
88 return new maemo6rotationsensor(sensor); |
|
89 else if (sensor->identifier() == maemo6tapsensor::id) |
|
90 return new maemo6tapsensor(sensor); |
|
91 |
|
92 return 0; |
|
93 } |
|
94 }; |
|
95 |
|
96 Q_EXPORT_PLUGIN2(libsensors_maemo6, maemo6SensorPlugin) |
|
97 |
|
98 #include "main.moc" |