diff options
Diffstat (limited to 'src/plugins/sensors')
171 files changed, 912 insertions, 8643 deletions
diff --git a/src/plugins/sensors/CMakeLists.txt b/src/plugins/sensors/CMakeLists.txt new file mode 100644 index 00000000..e7527d8f --- /dev/null +++ b/src/plugins/sensors/CMakeLists.txt @@ -0,0 +1,30 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +# all get generic sensor +add_subdirectory(generic) + +if(ANDROID AND NOT SENSORS_PLUGINS OR "sensorfw" IN_LIST SENSORS_PLUGINS) + add_subdirectory(android) +endif() + +# Currently disabled, see src/sensors/configure.cmake +#if (QT_FEATURE_sensorfw AND NOT SENSORS_PLUGINS OR "sensorfw" IN_LIST SENSORS_PLUGINS) +# add_subdirectory(sensorfw) +#endif() + +if (QT_FEATURE_winrt_sensors AND NOT SENSORS_PLUGINS OR "winrt" IN_LIST SENSORS_PLUGINS) + add_subdirectory(winrt) +endif() + +if (IOS AND NOT SENSORS_PLUGINS OR "ios" IN_LIST SENSORS_PLUGINS) + add_subdirectory(ios) +endif() + +if(LINUX AND TARGET Qt::DBus AND NOT SENSORS_PLUGINS OR "iio-sensor-proxy" IN_LIST SENSORS_PLUGINS) + add_subdirectory(iio-sensor-proxy) +endif() + +if("dummy" IN_LIST SENSORS_PLUGINS) + add_subdirectory(dummy) +endif() diff --git a/src/plugins/sensors/android/CMakeLists.txt b/src/plugins/sensors/android/CMakeLists.txt new file mode 100644 index 00000000..9a77a9a5 --- /dev/null +++ b/src/plugins/sensors/android/CMakeLists.txt @@ -0,0 +1,35 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +##################################################################### +## QCounterGesturePlugin Plugin: +##################################################################### + +qt_internal_add_plugin(AndroidSensorPlugin + OUTPUT_NAME qtsensors_android + PLUGIN_TYPE sensors + SOURCES + androidaccelerometer.cpp androidaccelerometer.h + androidcompass.cpp androidcompass.h + androidgyroscope.cpp androidgyroscope.h + androidlight.cpp androidlight.h + androidmagnetometer.cpp androidmagnetometer.h + androidpressure.cpp androidpressure.h + androidproximity.cpp androidproximity.h + androidrotation.cpp androidrotation.h + androidtemperature.cpp androidtemperature.h + main.cpp + sensoreventqueue.h + sensormanager.cpp sensormanager.h + DEFINES + # STATICPLUGIN needed because there's a Q_IMPORT_PLUGIN in main.cpp + # Yes, the plugin imports itself statically + QT_STATICPLUGIN + LIBRARIES + Qt::CorePrivate + Qt::Sensors + android +) + +#### Keys ignored in scope 1:.:.:android.pro:<TRUE>: +# OTHER_FILES = "plugin.json" diff --git a/src/plugins/sensors/android/android.pro b/src/plugins/sensors/android/android.pro deleted file mode 100644 index 15e26ee9..00000000 --- a/src/plugins/sensors/android/android.pro +++ /dev/null @@ -1,41 +0,0 @@ -TARGET = qtsensors_android - -QT = sensors core-private - -# STATICPLUGIN needed because there's a Q_IMPORT_PLUGIN in main.cpp -# Yes, the plugin imports itself statically -DEFINES += QT_STATICPLUGIN - -HEADERS = \ - androidaccelerometer.h \ - androidcompass.h \ - androidgyroscope.h \ - androidmagnetometer.h \ - androidpressure.h \ - androidproximity.h \ - androidrotation.h \ - androidtemperature.h \ - androidlight.h \ - sensoreventqueue.h \ - sensormanager.h - -SOURCES = \ - main.cpp \ - androidaccelerometer.cpp \ - androidcompass.cpp \ - androidgyroscope.cpp \ - androidmagnetometer.cpp \ - androidpressure.cpp \ - androidproximity.cpp \ - androidrotation.cpp \ - androidtemperature.cpp \ - androidlight.cpp \ - sensormanager.cpp - -OTHER_FILES = plugin.json - -LIBS += -landroid - -PLUGIN_TYPE = sensors -PLUGIN_CLASS_NAME = QCounterGesturePlugin -load(qt_plugin) diff --git a/src/plugins/sensors/android/androidaccelerometer.cpp b/src/plugins/sensors/android/androidaccelerometer.cpp index f38e0047..1e6004ed 100644 --- a/src/plugins/sensors/android/androidaccelerometer.cpp +++ b/src/plugins/sensors/android/androidaccelerometer.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 BogDan Vatra <bogdan@kde.org> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2019 BogDan Vatra <bogdan@kde.org> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "androidaccelerometer.h" #include <QDebug> diff --git a/src/plugins/sensors/android/androidaccelerometer.h b/src/plugins/sensors/android/androidaccelerometer.h index 04362451..32fa6410 100644 --- a/src/plugins/sensors/android/androidaccelerometer.h +++ b/src/plugins/sensors/android/androidaccelerometer.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 BogDan Vatra <bogdan@kde.org> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2019 BogDan Vatra <bogdan@kde.org> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef ANDROIDACCELEROMETER_H #define ANDROIDACCELEROMETER_H diff --git a/src/plugins/sensors/android/androidcompass.cpp b/src/plugins/sensors/android/androidcompass.cpp index 653c5e99..9cdea54d 100644 --- a/src/plugins/sensors/android/androidcompass.cpp +++ b/src/plugins/sensors/android/androidcompass.cpp @@ -1,58 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2019 BogDan Vatra <bogdan@kde.org> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - +// Copyright (C) 2019 BogDan Vatra <bogdan@kde.org> +// Copyright (C) 2008 The Android Open Source Project +// SPDX-License-Identifier: Apache-2.0 #include "androidcompass.h" diff --git a/src/plugins/sensors/android/androidcompass.h b/src/plugins/sensors/android/androidcompass.h index 1d20de72..592d641c 100644 --- a/src/plugins/sensors/android/androidcompass.h +++ b/src/plugins/sensors/android/androidcompass.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 BogDan Vatra <bogdan@kde.org> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2019 BogDan Vatra <bogdan@kde.org> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef ANDROIDCOMPASS_H #define ANDROIDCOMPASS_H diff --git a/src/plugins/sensors/android/androidgyroscope.cpp b/src/plugins/sensors/android/androidgyroscope.cpp index 2a38b5a0..acc4798a 100644 --- a/src/plugins/sensors/android/androidgyroscope.cpp +++ b/src/plugins/sensors/android/androidgyroscope.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 BogDan Vatra <bogdan@kde.org> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2019 BogDan Vatra <bogdan@kde.org> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "androidgyroscope.h" #include <QtCore/qmath.h> diff --git a/src/plugins/sensors/android/androidgyroscope.h b/src/plugins/sensors/android/androidgyroscope.h index 7d1ecec0..2dd3c8cc 100644 --- a/src/plugins/sensors/android/androidgyroscope.h +++ b/src/plugins/sensors/android/androidgyroscope.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 BogDan Vatra <bogdan@kde.org> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2019 BogDan Vatra <bogdan@kde.org> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef ANDROIDGYROSCOPE_H #define ANDROIDGYROSCOPE_H diff --git a/src/plugins/sensors/android/androidlight.cpp b/src/plugins/sensors/android/androidlight.cpp index 724ed970..42c8f0b7 100644 --- a/src/plugins/sensors/android/androidlight.cpp +++ b/src/plugins/sensors/android/androidlight.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 BogDan Vatra <bogdan@kde.org> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2019 BogDan Vatra <bogdan@kde.org> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "androidlight.h" diff --git a/src/plugins/sensors/android/androidlight.h b/src/plugins/sensors/android/androidlight.h index 74c963fb..59c67981 100644 --- a/src/plugins/sensors/android/androidlight.h +++ b/src/plugins/sensors/android/androidlight.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 BogDan Vatra <bogdan@kde.org> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2019 BogDan Vatra <bogdan@kde.org> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef ANDROIDLIGHT_H #define ANDROIDLIGHT_H diff --git a/src/plugins/sensors/android/androidmagnetometer.cpp b/src/plugins/sensors/android/androidmagnetometer.cpp index ec663c0b..54d2225e 100644 --- a/src/plugins/sensors/android/androidmagnetometer.cpp +++ b/src/plugins/sensors/android/androidmagnetometer.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 BogDan Vatra <bogdan@kde.org> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2019 BogDan Vatra <bogdan@kde.org> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "androidmagnetometer.h" diff --git a/src/plugins/sensors/android/androidmagnetometer.h b/src/plugins/sensors/android/androidmagnetometer.h index fb1f0ee7..e4e0fcbd 100644 --- a/src/plugins/sensors/android/androidmagnetometer.h +++ b/src/plugins/sensors/android/androidmagnetometer.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 BogDan Vatra <bogdan@kde.org> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2019 BogDan Vatra <bogdan@kde.org> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef ANDROIDMAGNETOMETER_H #define ANDROIDMAGNETOMETER_H diff --git a/src/plugins/sensors/android/androidpressure.cpp b/src/plugins/sensors/android/androidpressure.cpp index 46acffd6..50dd86a0 100644 --- a/src/plugins/sensors/android/androidpressure.cpp +++ b/src/plugins/sensors/android/androidpressure.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 BogDan Vatra <bogdan@kde.org> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2019 BogDan Vatra <bogdan@kde.org> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "androidpressure.h" diff --git a/src/plugins/sensors/android/androidpressure.h b/src/plugins/sensors/android/androidpressure.h index ec682e59..7121d73c 100644 --- a/src/plugins/sensors/android/androidpressure.h +++ b/src/plugins/sensors/android/androidpressure.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 BogDan Vatra <bogdan@kde.org> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2019 BogDan Vatra <bogdan@kde.org> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef ANDROIDPRESSURE_H #define ANDROIDPRESSURE_H diff --git a/src/plugins/sensors/android/androidproximity.cpp b/src/plugins/sensors/android/androidproximity.cpp index 000399b0..2c134ba0 100644 --- a/src/plugins/sensors/android/androidproximity.cpp +++ b/src/plugins/sensors/android/androidproximity.cpp @@ -1,42 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2016 BogDan Vatra <bogdan@kde.org> -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 BogDan Vatra <bogdan@kde.org> +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "androidproximity.h" diff --git a/src/plugins/sensors/android/androidproximity.h b/src/plugins/sensors/android/androidproximity.h index 22169d6f..215292e8 100644 --- a/src/plugins/sensors/android/androidproximity.h +++ b/src/plugins/sensors/android/androidproximity.h @@ -1,42 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2016 BogDan Vatra <bogdan@kde.org> -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 BogDan Vatra <bogdan@kde.org> +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef ANDROIDPROXIMITY_H #define ANDROIDPROXIMITY_H diff --git a/src/plugins/sensors/android/androidrotation.cpp b/src/plugins/sensors/android/androidrotation.cpp index c1d141a0..43586a0f 100644 --- a/src/plugins/sensors/android/androidrotation.cpp +++ b/src/plugins/sensors/android/androidrotation.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 BogDan Vatra <bogdan@kde.org> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2019 BogDan Vatra <bogdan@kde.org> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "androidrotation.h" @@ -48,12 +12,41 @@ AndroidRotation::AndroidRotation(int type, QSensor *sensor, QObject *parent) void AndroidRotation::dataReceived(const ASensorEvent &event) { - // ### Check me, at first look it seems wrong, - // here https://developer.android.com/reference/android/hardware/SensorEvent.html#sensor.type_rotation_vector: - // are the Android values - qreal rz = -qRadiansToDegrees(qreal(event.data[0])); // event.data[0] corresponds to x - qreal rx = -qRadiansToDegrees(qreal(event.data[1])); // event.data[1] corresponds to y - qreal ry = qRadiansToDegrees(qreal(event.data[2])); // event.data[2] corresponds to z + // From android documentation, the rotation sensor values are: + // values[0]: x*sin(θ/2) + // values[1]: y*sin(θ/2) + // values[2]: z*sin(θ/2) + // values[3]: cos(θ/2) + + // The mathematics below is adapted from + // https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/hardware/SensorManager.java#1644 + // and + // https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/hardware/SensorManager.java#1469 + // (getRotationMatrixFromVector() followed by getOrientation()) + qreal angles[3]; + qreal q1 = qreal(event.data[0]); + qreal q2 = qreal(event.data[1]); + qreal q3 = qreal(event.data[2]); + qreal q0 = qreal(event.data[3]); + + qreal sq_q1 = 2 * q1 * q1; + qreal sq_q2 = 2 * q2 * q2; + qreal sq_q3 = 2 * q3 * q3; + qreal q1_q2 = 2 * q1 * q2; + qreal q3_q0 = 2 * q3 * q0; + qreal q1_q3 = 2 * q1 * q3; + qreal q2_q0 = 2 * q2 * q0; + qreal q2_q3 = 2 * q2 * q3; + qreal q1_q0 = 2 * q1 * q0; + + angles[0] = std::atan2((q1_q2 - q3_q0), (1 - sq_q1 - sq_q3)); + angles[1] = std::asin(-(q2_q3 + q1_q0)); + angles[2] = std::atan2(-(q1_q3 - q2_q0), (1 - sq_q1 - sq_q2)); + + qreal rz = -qRadiansToDegrees(angles[0]); + qreal rx = -qRadiansToDegrees(angles[1]); + qreal ry = qRadiansToDegrees(angles[2]); + if (sensor()->skipDuplicates() && qFuzzyCompare(m_reader.x(), rx) && qFuzzyCompare(m_reader.y(), ry) && qFuzzyCompare(m_reader.z(), rz)) { diff --git a/src/plugins/sensors/android/androidrotation.h b/src/plugins/sensors/android/androidrotation.h index 9761b249..84860c11 100644 --- a/src/plugins/sensors/android/androidrotation.h +++ b/src/plugins/sensors/android/androidrotation.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 BogDan Vatra <bogdan@kde.org> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2019 BogDan Vatra <bogdan@kde.org> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef ANDROIDROTATION_H #define ANDROIDROTATION_H diff --git a/src/plugins/sensors/android/androidtemperature.cpp b/src/plugins/sensors/android/androidtemperature.cpp index 5f85750a..f4c6cbe2 100644 --- a/src/plugins/sensors/android/androidtemperature.cpp +++ b/src/plugins/sensors/android/androidtemperature.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 BogDan Vatra <bogdan@kde.org> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2019 BogDan Vatra <bogdan@kde.org> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "androidtemperature.h" diff --git a/src/plugins/sensors/android/androidtemperature.h b/src/plugins/sensors/android/androidtemperature.h index ba626051..654a5faa 100644 --- a/src/plugins/sensors/android/androidtemperature.h +++ b/src/plugins/sensors/android/androidtemperature.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 BogDan Vatra <bogdan@kde.org> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2019 BogDan Vatra <bogdan@kde.org> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef ANDROIDTEMPERATURE_H #define ANDROIDTEMPERATURE_H diff --git a/src/plugins/sensors/android/main.cpp b/src/plugins/sensors/android/main.cpp index 85853cd2..8c2855cd 100644 --- a/src/plugins/sensors/android/main.cpp +++ b/src/plugins/sensors/android/main.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 BogDan Vatra <bogdan@kde.org> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 BogDan Vatra <bogdan@kde.org> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include <qplugin.h> #include <qsensorplugin.h> @@ -77,7 +41,7 @@ public: switch (sensor) { case ASENSOR_TYPE_ACCELEROMETER: m_accelerationModes |= AndroidAccelerometer::Accelerometer; - QSensorManager::registerBackend(QAccelerometer::type, QByteArray::number(sensor), this); + QSensorManager::registerBackend(QAccelerometer::sensorType, QByteArray::number(sensor), this); accelerometer = true; break; case ASENSOR_TYPE_GRAVITY: @@ -87,26 +51,26 @@ public: m_accelerationModes |= AndroidAccelerometer::LinearAcceleration; break; case ASENSOR_TYPE_AMBIENT_TEMPERATURE: - QSensorManager::registerBackend(QAmbientTemperatureSensor::type, QByteArray::number(sensor), this); + QSensorManager::registerBackend(QAmbientTemperatureSensor::sensorType, QByteArray::number(sensor), this); break; case ASENSOR_TYPE_GYROSCOPE: - QSensorManager::registerBackend(QGyroscope::type, QByteArray::number(sensor), this); + QSensorManager::registerBackend(QGyroscope::sensorType, QByteArray::number(sensor), this); break; case ASENSOR_TYPE_LIGHT: - QSensorManager::registerBackend(QLightSensor::type, QByteArray::number(sensor), this); + QSensorManager::registerBackend(QLightSensor::sensorType, QByteArray::number(sensor), this); break; case ASENSOR_TYPE_MAGNETIC_FIELD: - QSensorManager::registerBackend(QMagnetometer::type, QByteArray::number(sensor), this); + QSensorManager::registerBackend(QMagnetometer::sensorType, QByteArray::number(sensor), this); magnetometer = true; break; case ASENSOR_TYPE_PRESSURE: - QSensorManager::registerBackend(QPressureSensor::type, QByteArray::number(sensor), this); + QSensorManager::registerBackend(QPressureSensor::sensorType, QByteArray::number(sensor), this); break; case ASENSOR_TYPE_PROXIMITY: - QSensorManager::registerBackend(QProximitySensor::type, QByteArray::number(sensor), this); + QSensorManager::registerBackend(QProximitySensor::sensorType, QByteArray::number(sensor), this); break; case ASENSOR_TYPE_ROTATION_VECTOR: - QSensorManager::registerBackend(QRotationSensor::type, QByteArray::number(sensor), this); + QSensorManager::registerBackend(QRotationSensor::sensorType, QByteArray::number(sensor), this); break; case ASENSOR_TYPE_RELATIVE_HUMIDITY: @@ -128,7 +92,7 @@ public: } } if (accelerometer && magnetometer) - QSensorManager::registerBackend(QCompass::type, AndroidCompassId, this); + QSensorManager::registerBackend(QCompass::sensorType, AndroidCompassId, this); } QSensorBackend *createBackend(QSensor *sensor) override diff --git a/src/plugins/sensors/android/qt_attribution.json b/src/plugins/sensors/android/qt_attribution.json new file mode 100644 index 00000000..9599e5bf --- /dev/null +++ b/src/plugins/sensors/android/qt_attribution.json @@ -0,0 +1,12 @@ +{ + "Id": "android-compass", + "Name": "Android getRotationMatrix and getOrientation", + "QDocModule": "qtsensors", + "Description": "Code to calculate the rotation matrix and orientation of a compass, adopted from Android sources.", + "QtUsage": "Used on Android, in the Android Sensor plugin.", + "Files": "androidcompass.cpp", + + "License": "Apache License 2.0", + "LicenseId": "Apache-2.0", + "Copyright": "Copyright (C) 2008 The Android Open Source Project" +} diff --git a/src/plugins/sensors/android/sensoreventqueue.h b/src/plugins/sensors/android/sensoreventqueue.h index 77bf05c6..b18401e9 100644 --- a/src/plugins/sensors/android/sensoreventqueue.h +++ b/src/plugins/sensors/android/sensoreventqueue.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 BogDan Vatra <bogdan@kde.org> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2019 BogDan Vatra <bogdan@kde.org> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef SENSOREVENTQUEUE_H #define SENSOREVENTQUEUE_H @@ -125,8 +89,9 @@ public: void start() override { ASensorEventQueue_enableSensor(m_sensorEventQueue, m_sensor); + // The QSensor datarate is in Hz (frequency), whereas the setEventRate expects microseconds if (sensor()->dataRate() > 0) - ASensorEventQueue_setEventRate(m_sensorEventQueue, m_sensor, std::max(ASensor_getMinDelay(m_sensor), sensor()->dataRate())); + ASensorEventQueue_setEventRate(m_sensorEventQueue, m_sensor, std::max(ASensor_getMinDelay(m_sensor), 1000000/sensor()->dataRate())); m_started = true; } void stop() override diff --git a/src/plugins/sensors/android/sensormanager.cpp b/src/plugins/sensors/android/sensormanager.cpp index 542e54c9..755b6109 100644 --- a/src/plugins/sensors/android/sensormanager.cpp +++ b/src/plugins/sensors/android/sensormanager.cpp @@ -1,48 +1,23 @@ -/**************************************************************************** -** -** Copyright (C) 2019 BogDan Vatra <bogdan@kde.org> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2021 The Qt Company Ltd. +// Copyright (C) 2019 BogDan Vatra <bogdan@kde.org> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "sensormanager.h" +#include <QtCore/qcoreapplication.h> +#include <QtCore/qjnitypes.h> + #include <dlfcn.h> +Q_DECLARE_JNI_CLASS(AndroidContext, "android/content/Context") +Q_DECLARE_JNI_CLASS(Sensor, "android/hardware/Sensor") + SensorManager::SensorManager() { - auto sensorService = QJNIObjectPrivate::getStaticObjectField("android.content.Context", "SENSOR_SERVICE", "Ljava/lang/String;"); - m_sensorManager = QJNIObjectPrivate{QtAndroidPrivate::context()}.callObjectMethod("getSystemService", "(Ljava/lang/String;)Ljava/lang/Object;", sensorService.object()); + auto sensorService = + QJniObject::getStaticField<QtJniTypes::AndroidContext, jstring>("SENSOR_SERVICE"); + + QJniObject context = QNativeInterface::QAndroidApplication::context(); + m_sensorManager = context.callMethod<jobject>("getSystemService", + sensorService.object<jstring>()); setObjectName("QtSensorsLooperThread"); start(); m_waitForStart.acquire(); @@ -50,13 +25,14 @@ SensorManager::SensorManager() SensorManager::~SensorManager() { - m_quit.store(1); + m_quit.storeRelaxed(1); wait(); } -QJNIObjectPrivate SensorManager::javaSensor(const ASensor *sensor) const +QJniObject SensorManager::javaSensor(const ASensor *sensor) const { - return m_sensorManager.callObjectMethod("getDefaultSensor", "(I)Landroid/hardware/Sensor;", ASensor_getType(sensor)); + return m_sensorManager.callMethod<QtJniTypes::Sensor>("getDefaultSensor", + ASensor_getType(sensor)); } QSharedPointer<SensorManager> &SensorManager::instance() @@ -72,19 +48,18 @@ ALooper *SensorManager::looper() const static inline ASensorManager* androidManager() { + QJniObject context = QNativeInterface::QAndroidApplication::context(); + auto packageName = context.callMethod<jstring>("getPackageName").toString().toUtf8(); + #if __ANDROID_API__ >= 26 - return ASensorManager_getInstanceForPackage(QJNIObjectPrivate{QtAndroidPrivate::context()} - .callObjectMethod("getPackageName", "()Ljava/lang/String;") - .toString().toUtf8().constData()); + return ASensorManager_getInstanceForPackage(packageName.constData()); #else - if (QtAndroidPrivate::androidSdkVersion() >= 26) { + if (QNativeInterface::QAndroidApplication::sdkVersion() >= 26) { using GetInstanceForPackage = ASensorManager *(*)(const char *); auto handler = dlopen("libandroid.so", RTLD_NOW); auto function = GetInstanceForPackage(dlsym(handler, "ASensorManager_getInstanceForPackage")); if (function) { - auto res = function(QJNIObjectPrivate{QtAndroidPrivate::context()} - .callObjectMethod("getPackageName", "()Ljava/lang/String;") - .toString().toUtf8().constData()); + auto res = function(packageName.constData()); dlclose(handler); return res; } @@ -101,7 +76,8 @@ ASensorManager *SensorManager::manager() const QString SensorManager::description(const ASensor *sensor) const { - return QString::fromUtf8(ASensor_getName(sensor)) + " " + ASensor_getVendor(sensor) + " v" + QString::number(javaSensor(sensor).callMethod<jint>("getVersion")); + return QString::fromUtf8(ASensor_getName(sensor)) + " " + ASensor_getVendor(sensor) + + " v" + QString::number(javaSensor(sensor).callMethod<jint>("getVersion")); } double SensorManager::getMaximumRange(const ASensor *sensor) const @@ -116,5 +92,5 @@ void SensorManager::run() do { if (ALooper_pollAll(5 /*ms*/, nullptr, nullptr, nullptr) == ALOOPER_POLL_TIMEOUT) QThread::yieldCurrentThread(); - } while (!m_quit.load()); + } while (!m_quit.loadRelaxed()); } diff --git a/src/plugins/sensors/android/sensormanager.h b/src/plugins/sensors/android/sensormanager.h index dc7ffe1f..1d3c274b 100644 --- a/src/plugins/sensors/android/sensormanager.h +++ b/src/plugins/sensors/android/sensormanager.h @@ -1,52 +1,15 @@ -/**************************************************************************** -** -** Copyright (C) 2019 BogDan Vatra <bogdan@kde.org> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2021 The Qt Company Ltd. +// Copyright (C) 2019 BogDan Vatra <bogdan@kde.org> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef SENSORMANAGER_H #define SENSORMANAGER_H -#include <QThread> -#include <QSemaphore> -#include <QMutex> -#include <QWaitCondition> - -#include <private/qjni_p.h> -#include <private/qjnihelpers_p.h> +#include <QtCore/qthread.h> +#include <QtCore/qsemaphore.h> +#include <QtCore/qmutex.h> +#include <QtCore/qwaitcondition.h> +#include <QtCore/qjniobject.h> #include <android/sensor.h> @@ -58,7 +21,7 @@ public: ALooper *looper() const; ASensorManager *manager() const; - QJNIObjectPrivate javaSensor(const ASensor *sensor) const; + QJniObject javaSensor(const ASensor *sensor) const; QString description(const ASensor *sensor) const; double getMaximumRange(const ASensor *sensor) const; @@ -71,7 +34,7 @@ private: QAtomicInt m_quit{0}; ALooper *m_looper = nullptr; QSemaphore m_waitForStart; - QJNIObjectPrivate m_sensorManager; + QJniObject m_sensorManager; }; #endif // SENSORMANAGER_H diff --git a/src/plugins/sensors/dummy/CMakeLists.txt b/src/plugins/sensors/dummy/CMakeLists.txt new file mode 100644 index 00000000..19f93329 --- /dev/null +++ b/src/plugins/sensors/dummy/CMakeLists.txt @@ -0,0 +1,30 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +##################################################################### +## dummySensorPlugin Plugin: +##################################################################### + +qt_internal_add_plugin(dummySensorPlugin + OUTPUT_NAME qtsensors_dummy + PLUGIN_TYPE sensors + SOURCES + dummyaccelerometer.cpp dummyaccelerometer.h + dummycommon.cpp dummycommon.h + dummylightsensor.cpp dummylightsensor.h + main.cpp + LIBRARIES + Qt::Core + Qt::Sensors +) + +#### Keys ignored in scope 1:.:.:dummy.pro:<TRUE>: +# OTHER_FILES = "plugin.json" + +## Scopes: +##################################################################### + +qt_internal_extend_target(dummySensorPlugin CONDITION UNIX AND NOT ANDROID AND NOT APPLE AND NOT OPENBSD AND NOT QNX + LIBRARIES + rt +) diff --git a/src/plugins/sensors/dummy/dummy.pro b/src/plugins/sensors/dummy/dummy.pro deleted file mode 100644 index 6eab4912..00000000 --- a/src/plugins/sensors/dummy/dummy.pro +++ /dev/null @@ -1,19 +0,0 @@ -TARGET = qtsensors_dummy -QT = sensors core - -HEADERS += dummycommon.h\ - dummyaccelerometer.h\ - dummylightsensor.h - -SOURCES += dummycommon.cpp\ - dummyaccelerometer.cpp\ - dummylightsensor.cpp\ - main.cpp - -OTHER_FILES = plugin.json - -unix:!darwin:!qnx:!android:!openbsd: LIBS += -lrt - -PLUGIN_TYPE = sensors -PLUGIN_CLASS_NAME = dummySensorPlugin -load(qt_plugin) diff --git a/src/plugins/sensors/dummy/dummyaccelerometer.cpp b/src/plugins/sensors/dummy/dummyaccelerometer.cpp index f0246915..c46683ef 100644 --- a/src/plugins/sensors/dummy/dummyaccelerometer.cpp +++ b/src/plugins/sensors/dummy/dummyaccelerometer.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "dummyaccelerometer.h" #include <QDebug> diff --git a/src/plugins/sensors/dummy/dummyaccelerometer.h b/src/plugins/sensors/dummy/dummyaccelerometer.h index 6c890f64..3d1a99cc 100644 --- a/src/plugins/sensors/dummy/dummyaccelerometer.h +++ b/src/plugins/sensors/dummy/dummyaccelerometer.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef DUMMYACCELEROMETER_H #define DUMMYACCELEROMETER_H diff --git a/src/plugins/sensors/dummy/dummycommon.cpp b/src/plugins/sensors/dummy/dummycommon.cpp index 4a19b13f..f5b63146 100644 --- a/src/plugins/sensors/dummy/dummycommon.cpp +++ b/src/plugins/sensors/dummy/dummycommon.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "dummycommon.h" @@ -54,7 +18,7 @@ void dummycommon::start() int dataRate = sensor()->dataRate(); if (dataRate == 0) { - if (sensor()->availableDataRates().count()) + if (sensor()->availableDataRates().size()) // Use the first available rate when -1 is chosen dataRate = sensor()->availableDataRates().first().first; else diff --git a/src/plugins/sensors/dummy/dummycommon.h b/src/plugins/sensors/dummy/dummycommon.h index 5e775b64..8f5f9703 100644 --- a/src/plugins/sensors/dummy/dummycommon.h +++ b/src/plugins/sensors/dummy/dummycommon.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef DUMMYCOMMON_H #define DUMMYCOMMON_H diff --git a/src/plugins/sensors/dummy/dummylightsensor.cpp b/src/plugins/sensors/dummy/dummylightsensor.cpp index 8f2a9b8e..efdf360b 100644 --- a/src/plugins/sensors/dummy/dummylightsensor.cpp +++ b/src/plugins/sensors/dummy/dummylightsensor.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "dummylightsensor.h" #include <QDebug> diff --git a/src/plugins/sensors/dummy/dummylightsensor.h b/src/plugins/sensors/dummy/dummylightsensor.h index 3bcaf413..5a4e84ec 100644 --- a/src/plugins/sensors/dummy/dummylightsensor.h +++ b/src/plugins/sensors/dummy/dummylightsensor.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef DUMMYLIGHTSENSOR_H #define DUMMYLIGHTSENSOR_H diff --git a/src/plugins/sensors/dummy/main.cpp b/src/plugins/sensors/dummy/main.cpp index 13dd732e..79755753 100644 --- a/src/plugins/sensors/dummy/main.cpp +++ b/src/plugins/sensors/dummy/main.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "dummyaccelerometer.h" #include "dummylightsensor.h" @@ -53,8 +17,8 @@ class dummySensorPlugin : public QObject, public QSensorPluginInterface, public public: void registerSensors() override { - QSensorManager::registerBackend(QAccelerometer::type, dummyaccelerometer::id, this); - QSensorManager::registerBackend(QAmbientLightSensor::type, dummylightsensor::id, this); + QSensorManager::registerBackend(QAccelerometer::sensorType, dummyaccelerometer::id, this); + QSensorManager::registerBackend(QAmbientLightSensor::sensorType, dummylightsensor::id, this); } QSensorBackend *createBackend(QSensor *sensor) override diff --git a/src/plugins/sensors/generic/CMakeLists.txt b/src/plugins/sensors/generic/CMakeLists.txt new file mode 100644 index 00000000..449401ab --- /dev/null +++ b/src/plugins/sensors/generic/CMakeLists.txt @@ -0,0 +1,36 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +##################################################################### +## genericSensorPlugin Plugin: +##################################################################### + +qt_internal_add_plugin(genericSensorPlugin + OUTPUT_NAME qtsensors_generic + PLUGIN_TYPE sensors + SOURCES + genericalssensor.cpp genericalssensor.h + genericorientationsensor.cpp genericorientationsensor.h + generictiltsensor.cpp generictiltsensor.h + main.cpp + DEFINES + QTSENSORS_GENERICALSSENSOR + QTSENSORS_GENERICORIENTATIONSENSOR + QTSENSORS_GENERICTILTSENSOR + LIBRARIES + Qt::Core + Qt::Sensors +) + +#### Keys ignored in scope 1:.:.:generic.pro:<TRUE>: +# OTHER_FILES = "plugin.json" + +## Scopes: +##################################################################### + +qt_internal_extend_target(genericSensorPlugin CONDITION NOT ANDROID + SOURCES + genericrotationsensor.cpp genericrotationsensor.h + DEFINES + QTSENSORS_GENERICROTATIONSENSOR +) diff --git a/src/plugins/sensors/generic/generic.pro b/src/plugins/sensors/generic/generic.pro deleted file mode 100644 index cf87ccf3..00000000 --- a/src/plugins/sensors/generic/generic.pro +++ /dev/null @@ -1,29 +0,0 @@ -TARGET = qtsensors_generic -QT = core sensors - -HEADERS += generictiltsensor.h - -SOURCES += main.cpp\ - generictiltsensor.cpp -DEFINES += QTSENSORS_GENERICTILTSENSOR - -HEADERS += genericorientationsensor.h\ - genericalssensor.h - -SOURCES += genericorientationsensor.cpp\ - genericalssensor.cpp -DEFINES += QTSENSORS_GENERICORIENTATIONSENSOR QTSENSORS_GENERICALSSENSOR - -!android { - HEADERS += genericrotationsensor.h - - SOURCES += genericrotationsensor.cpp - - DEFINES += QTSENSORS_GENERICROTATIONSENSOR -} - -OTHER_FILES = plugin.json - -PLUGIN_TYPE = sensors -PLUGIN_CLASS_NAME = genericSensorPlugin -load(qt_plugin) diff --git a/src/plugins/sensors/generic/genericalssensor.cpp b/src/plugins/sensors/generic/genericalssensor.cpp index cd20e7e8..af4441ef 100644 --- a/src/plugins/sensors/generic/genericalssensor.cpp +++ b/src/plugins/sensors/generic/genericalssensor.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "genericalssensor.h" #include <QDebug> diff --git a/src/plugins/sensors/generic/genericalssensor.h b/src/plugins/sensors/generic/genericalssensor.h index 3d10b9a1..544f27bb 100644 --- a/src/plugins/sensors/generic/genericalssensor.h +++ b/src/plugins/sensors/generic/genericalssensor.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef GENERICALSSENSOR_H #define GENERICALSSENSOR_H diff --git a/src/plugins/sensors/generic/genericorientationsensor.cpp b/src/plugins/sensors/generic/genericorientationsensor.cpp index 1bcaaa60..6f880cd8 100644 --- a/src/plugins/sensors/generic/genericorientationsensor.cpp +++ b/src/plugins/sensors/generic/genericorientationsensor.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "genericorientationsensor.h" #include <QDebug> diff --git a/src/plugins/sensors/generic/genericorientationsensor.h b/src/plugins/sensors/generic/genericorientationsensor.h index 01265a02..c2f322a7 100644 --- a/src/plugins/sensors/generic/genericorientationsensor.h +++ b/src/plugins/sensors/generic/genericorientationsensor.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef GENERICORIENTATIONSENSOR_H #define GENERICORIENTATIONSENSOR_H diff --git a/src/plugins/sensors/generic/genericrotationsensor.cpp b/src/plugins/sensors/generic/genericrotationsensor.cpp index 40768297..2da1fbca 100644 --- a/src/plugins/sensors/generic/genericrotationsensor.cpp +++ b/src/plugins/sensors/generic/genericrotationsensor.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "genericrotationsensor.h" #include <QDebug> diff --git a/src/plugins/sensors/generic/genericrotationsensor.h b/src/plugins/sensors/generic/genericrotationsensor.h index 98b8f974..cc642298 100644 --- a/src/plugins/sensors/generic/genericrotationsensor.h +++ b/src/plugins/sensors/generic/genericrotationsensor.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef GENERICROTATIONSENSOR_H #define GENERICROTATIONSENSOR_H diff --git a/src/plugins/sensors/generic/generictiltsensor.cpp b/src/plugins/sensors/generic/generictiltsensor.cpp index bb418893..1d17d0d2 100644 --- a/src/plugins/sensors/generic/generictiltsensor.cpp +++ b/src/plugins/sensors/generic/generictiltsensor.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "generictiltsensor.h" #include <QDebug> @@ -161,5 +125,5 @@ bool GenericTiltSensor::filter(QAccelerometerReading *reading) bool GenericTiltSensor::isFeatureSupported(QSensor::Feature feature) const { - return (feature == QSensor::SkipDuplicates); + return (feature == QSensor::Feature::SkipDuplicates); } diff --git a/src/plugins/sensors/generic/generictiltsensor.h b/src/plugins/sensors/generic/generictiltsensor.h index 71db69d3..3f7f438d 100644 --- a/src/plugins/sensors/generic/generictiltsensor.h +++ b/src/plugins/sensors/generic/generictiltsensor.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef GENERICTILTSENSOR_H #define GENERICTILTSENSOR_H diff --git a/src/plugins/sensors/generic/main.cpp b/src/plugins/sensors/generic/main.cpp index 44bfff09..02154b2f 100644 --- a/src/plugins/sensors/generic/main.cpp +++ b/src/plugins/sensors/generic/main.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifdef QTSENSORS_GENERICORIENTATIONSENSOR #include "genericorientationsensor.h" @@ -68,44 +32,44 @@ public: void sensorsChanged() override { - if (!QSensor::defaultSensorForType(QAccelerometer::type).isEmpty()) { + if (!QSensor::defaultSensorForType(QAccelerometer::sensorType).isEmpty()) { // There is an accelerometer available. Register the backends #ifdef QTSENSORS_GENERICORIENTATIONSENSOR - if (!QSensorManager::isBackendRegistered(QOrientationSensor::type, genericorientationsensor::id)) - QSensorManager::registerBackend(QOrientationSensor::type, genericorientationsensor::id, this); + if (!QSensorManager::isBackendRegistered(QOrientationSensor::sensorType, genericorientationsensor::id)) + QSensorManager::registerBackend(QOrientationSensor::sensorType, genericorientationsensor::id, this); #endif #ifdef QTSENSORS_GENERICROTATIONSENSOR - if (!QSensorManager::isBackendRegistered(QRotationSensor::type, genericrotationsensor::id)) - QSensorManager::registerBackend(QRotationSensor::type, genericrotationsensor::id, this); + if (!QSensorManager::isBackendRegistered(QRotationSensor::sensorType, genericrotationsensor::id)) + QSensorManager::registerBackend(QRotationSensor::sensorType, genericrotationsensor::id, this); #endif #ifdef QTSENSORS_GENERICTILTSENSOR - if (!QSensorManager::isBackendRegistered(QTiltSensor::type, GenericTiltSensor::id)) - QSensorManager::registerBackend(QTiltSensor::type, GenericTiltSensor::id, this); + if (!QSensorManager::isBackendRegistered(QTiltSensor::sensorType, GenericTiltSensor::id)) + QSensorManager::registerBackend(QTiltSensor::sensorType, GenericTiltSensor::id, this); #endif } else { #ifdef QTSENSORS_GENERICORIENTATIONSENSOR - if (QSensorManager::isBackendRegistered(QOrientationSensor::type, genericorientationsensor::id)) - QSensorManager::unregisterBackend(QOrientationSensor::type, genericorientationsensor::id); + if (QSensorManager::isBackendRegistered(QOrientationSensor::sensorType, genericorientationsensor::id)) + QSensorManager::unregisterBackend(QOrientationSensor::sensorType, genericorientationsensor::id); #endif #ifdef QTSENSORS_GENERICROTATIONSENSOR - if (QSensorManager::isBackendRegistered(QRotationSensor::type, genericrotationsensor::id)) - QSensorManager::unregisterBackend(QRotationSensor::type, genericrotationsensor::id); + if (QSensorManager::isBackendRegistered(QRotationSensor::sensorType, genericrotationsensor::id)) + QSensorManager::unregisterBackend(QRotationSensor::sensorType, genericrotationsensor::id); #endif #ifdef QTSENSORS_GENERICTILTSENSOR - if (QSensorManager::isBackendRegistered(QTiltSensor::type, GenericTiltSensor::id)) - QSensorManager::unregisterBackend(QTiltSensor::type, GenericTiltSensor::id); + if (QSensorManager::isBackendRegistered(QTiltSensor::sensorType, GenericTiltSensor::id)) + QSensorManager::unregisterBackend(QTiltSensor::sensorType, GenericTiltSensor::id); #endif } - if (!QSensor::defaultSensorForType(QLightSensor::type).isEmpty()) { + if (!QSensor::defaultSensorForType(QLightSensor::sensorType).isEmpty()) { #ifdef QTSENSORS_GENERICALSSENSOR - if (!QSensorManager::isBackendRegistered(QAmbientLightSensor::type, genericalssensor::id)) - QSensorManager::registerBackend(QAmbientLightSensor::type, genericalssensor::id, this); + if (!QSensorManager::isBackendRegistered(QAmbientLightSensor::sensorType, genericalssensor::id)) + QSensorManager::registerBackend(QAmbientLightSensor::sensorType, genericalssensor::id, this); #endif } else { #ifdef QTSENSORS_GENERICALSSENSOR - if (QSensorManager::isBackendRegistered(QAmbientLightSensor::type, genericalssensor::id)) - QSensorManager::unregisterBackend(QAmbientLightSensor::type, genericalssensor::id); + if (QSensorManager::isBackendRegistered(QAmbientLightSensor::sensorType, genericalssensor::id)) + QSensorManager::unregisterBackend(QAmbientLightSensor::sensorType, genericalssensor::id); #endif } } @@ -134,4 +98,3 @@ public: }; #include "main.moc" - diff --git a/src/plugins/sensors/iio-sensor-proxy/CMakeLists.txt b/src/plugins/sensors/iio-sensor-proxy/CMakeLists.txt new file mode 100644 index 00000000..83093e11 --- /dev/null +++ b/src/plugins/sensors/iio-sensor-proxy/CMakeLists.txt @@ -0,0 +1,50 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +##################################################################### +## IIOSensorProxySensorPlugin Plugin: +##################################################################### + +qt_internal_add_plugin(IIOSensorProxySensorPlugin + OUTPUT_NAME qtsensors_iio-sensor-proxy + PLUGIN_TYPE sensors + SOURCES + iiosensorproxycompass.cpp iiosensorproxycompass.h + iiosensorproxylightsensor.cpp iiosensorproxylightsensor.h + iiosensorproxyorientationsensor.cpp iiosensorproxyorientationsensor.h + iiosensorproxysensorbase.cpp iiosensorproxysensorbase.h + main.cpp + NO_UNITY_BUILD_SOURCES + # Duplicate symbol definition between, iiosensorproxycompass.cpp, and + # the followings + # TODO: dbusPath() can probably be implemented as a static data member + iiosensorproxylightsensor.cpp + iiosensorproxyorientationsensor.cpp + DBUS_INTERFACE_SOURCES + org.freedesktop.DBus.Properties.xml + net.hadess.SensorProxy.xml + net.hadess.SensorProxy.Compass.xml + DBUS_INTERFACE_FLAGS + "-N" + LIBRARIES + Qt::Core + Qt::DBus + Qt::Sensors +) + +#### Keys ignored in scope 1:.:.:iio-sensor-proxy.pro:<TRUE>: +# OTHER_FILES = "plugin.json" "$$DBUS_INTERFACES" +# dbus_properties.files = "org.freedesktop.DBus.Properties.xml" +# dbus_properties.header_flags = "-N" +# sensor_proxy.files = "net.hadess.SensorProxy.xml" +# sensor_proxy.header_flags = "-N" +# sensor_proxy_compass.files = "net.hadess.SensorProxy.Compass.xml" +# sensor_proxy_compass.header_flags = "-N" + +## Scopes: +##################################################################### + +qt_internal_extend_target(IIOSensorProxySensorPlugin CONDITION NOT ANDROID + LIBRARIES + rt +) diff --git a/src/plugins/sensors/iio-sensor-proxy/iio-sensor-proxy.pro b/src/plugins/sensors/iio-sensor-proxy/iio-sensor-proxy.pro deleted file mode 100644 index b68d9fbf..00000000 --- a/src/plugins/sensors/iio-sensor-proxy/iio-sensor-proxy.pro +++ /dev/null @@ -1,31 +0,0 @@ -TARGET = qtsensors_iio-sensor-proxy -QT = core dbus sensors - -PLUGIN_TYPE = sensors -PLUGIN_CLASS_NAME = IIOSensorProxySensorPlugin -load(qt_plugin) - -!android:LIBS += -lrt -HEADERS += iiosensorproxysensorbase.h \ - iiosensorproxylightsensor.h \ - iiosensorproxyorientationsensor.h \ - iiosensorproxycompass.h - -SOURCES += iiosensorproxysensorbase.cpp \ - iiosensorproxylightsensor.cpp \ - iiosensorproxyorientationsensor.cpp \ - iiosensorproxycompass.cpp \ - main.cpp - -DBUS_INTERFACES += sensor_proxy sensor_proxy_compass dbus_properties - -sensor_proxy.files = net.hadess.SensorProxy.xml -sensor_proxy.header_flags = -N - -sensor_proxy_compass.files = net.hadess.SensorProxy.Compass.xml -sensor_proxy_compass.header_flags = -N - -dbus_properties.files = org.freedesktop.DBus.Properties.xml -dbus_properties.header_flags = -N - -OTHER_FILES = plugin.json $$DBUS_INTERFACES diff --git a/src/plugins/sensors/iio-sensor-proxy/iiosensorproxycompass.cpp b/src/plugins/sensors/iio-sensor-proxy/iiosensorproxycompass.cpp index fd0b0f1f..f25fe574 100644 --- a/src/plugins/sensors/iio-sensor-proxy/iiosensorproxycompass.cpp +++ b/src/plugins/sensors/iio-sensor-proxy/iiosensorproxycompass.cpp @@ -1,42 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Alexander Volkov <a.volkov@rusbitech.ru> -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 Alexander Volkov <a.volkov@rusbitech.ru> +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "iiosensorproxycompass.h" #include "compass_interface.h" diff --git a/src/plugins/sensors/iio-sensor-proxy/iiosensorproxycompass.h b/src/plugins/sensors/iio-sensor-proxy/iiosensorproxycompass.h index 30d79e37..2be0408b 100644 --- a/src/plugins/sensors/iio-sensor-proxy/iiosensorproxycompass.h +++ b/src/plugins/sensors/iio-sensor-proxy/iiosensorproxycompass.h @@ -1,42 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Alexander Volkov <a.volkov@rusbitech.ru> -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 Alexander Volkov <a.volkov@rusbitech.ru> +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef IIOSENSORPROXY_COMPASS_H #define IIOSENSORPROXY_COMPASS_H diff --git a/src/plugins/sensors/iio-sensor-proxy/iiosensorproxylightsensor.cpp b/src/plugins/sensors/iio-sensor-proxy/iiosensorproxylightsensor.cpp index acd48147..b54126e4 100644 --- a/src/plugins/sensors/iio-sensor-proxy/iiosensorproxylightsensor.cpp +++ b/src/plugins/sensors/iio-sensor-proxy/iiosensorproxylightsensor.cpp @@ -1,42 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Alexander Volkov <a.volkov@rusbitech.ru> -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 Alexander Volkov <a.volkov@rusbitech.ru> +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "iiosensorproxylightsensor.h" #include "sensorproxy_interface.h" diff --git a/src/plugins/sensors/iio-sensor-proxy/iiosensorproxylightsensor.h b/src/plugins/sensors/iio-sensor-proxy/iiosensorproxylightsensor.h index 14c07d66..bf833815 100644 --- a/src/plugins/sensors/iio-sensor-proxy/iiosensorproxylightsensor.h +++ b/src/plugins/sensors/iio-sensor-proxy/iiosensorproxylightsensor.h @@ -1,42 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Alexander Volkov <a.volkov@rusbitech.ru> -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 Alexander Volkov <a.volkov@rusbitech.ru> +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef IIOSENSORPROXY_LIGHTSENSOR_H #define IIOSENSORPROXY_LIGHTSENSOR_H diff --git a/src/plugins/sensors/iio-sensor-proxy/iiosensorproxyorientationsensor.cpp b/src/plugins/sensors/iio-sensor-proxy/iiosensorproxyorientationsensor.cpp index 86ebb358..f589870a 100644 --- a/src/plugins/sensors/iio-sensor-proxy/iiosensorproxyorientationsensor.cpp +++ b/src/plugins/sensors/iio-sensor-proxy/iiosensorproxyorientationsensor.cpp @@ -1,42 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Alexander Volkov <a.volkov@rusbitech.ru> -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 Alexander Volkov <a.volkov@rusbitech.ru> +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "iiosensorproxyorientationsensor.h" #include "sensorproxy_interface.h" diff --git a/src/plugins/sensors/iio-sensor-proxy/iiosensorproxyorientationsensor.h b/src/plugins/sensors/iio-sensor-proxy/iiosensorproxyorientationsensor.h index 959113f1..0d81d312 100644 --- a/src/plugins/sensors/iio-sensor-proxy/iiosensorproxyorientationsensor.h +++ b/src/plugins/sensors/iio-sensor-proxy/iiosensorproxyorientationsensor.h @@ -1,42 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Alexander Volkov <a.volkov@rusbitech.ru> -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 Alexander Volkov <a.volkov@rusbitech.ru> +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef IIOSENSORPROXY_ORIENTATIONSENSOR_H #define IIOSENSORPROXY_ORIENTATIONSENSOR_H diff --git a/src/plugins/sensors/iio-sensor-proxy/iiosensorproxysensorbase.cpp b/src/plugins/sensors/iio-sensor-proxy/iiosensorproxysensorbase.cpp index 0a9f318c..9d7842f8 100644 --- a/src/plugins/sensors/iio-sensor-proxy/iiosensorproxysensorbase.cpp +++ b/src/plugins/sensors/iio-sensor-proxy/iiosensorproxysensorbase.cpp @@ -1,42 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Alexander Volkov <a.volkov@rusbitech.ru> -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 Alexander Volkov <a.volkov@rusbitech.ru> +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "iiosensorproxysensorbase.h" #include "sensorproxy_interface.h" diff --git a/src/plugins/sensors/iio-sensor-proxy/iiosensorproxysensorbase.h b/src/plugins/sensors/iio-sensor-proxy/iiosensorproxysensorbase.h index 96e036ad..12baedcd 100644 --- a/src/plugins/sensors/iio-sensor-proxy/iiosensorproxysensorbase.h +++ b/src/plugins/sensors/iio-sensor-proxy/iiosensorproxysensorbase.h @@ -1,42 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Alexander Volkov <a.volkov@rusbitech.ru> -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 Alexander Volkov <a.volkov@rusbitech.ru> +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef IIOSENSORPROXY_SENSORBASE_H #define IIOSENSORPROXY_SENSORBASE_H diff --git a/src/plugins/sensors/iio-sensor-proxy/main.cpp b/src/plugins/sensors/iio-sensor-proxy/main.cpp index 580e2c46..06b726a3 100644 --- a/src/plugins/sensors/iio-sensor-proxy/main.cpp +++ b/src/plugins/sensors/iio-sensor-proxy/main.cpp @@ -1,42 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Alexander Volkov <a.volkov@rusbitech.ru> -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 Alexander Volkov <a.volkov@rusbitech.ru> +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "iiosensorproxyorientationsensor.h" #include "iiosensorproxylightsensor.h" @@ -61,12 +25,12 @@ public: void registerSensors() override { if (QDBusConnection::systemBus().interface()->isServiceRegistered("net.hadess.SensorProxy")) { - if (!QSensorManager::isBackendRegistered(QOrientationSensor::type, IIOSensorProxyOrientationSensor::id)) - QSensorManager::registerBackend(QOrientationSensor::type, IIOSensorProxyOrientationSensor::id, this); - if (!QSensorManager::isBackendRegistered(QLightSensor::type, IIOSensorProxyLightSensor::id)) - QSensorManager::registerBackend(QLightSensor::type, IIOSensorProxyLightSensor::id, this); - if (!QSensorManager::isBackendRegistered(QCompass::type, IIOSensorProxyCompass::id)) - QSensorManager::registerBackend(QCompass::type, IIOSensorProxyCompass::id, this); + if (!QSensorManager::isBackendRegistered(QOrientationSensor::sensorType, IIOSensorProxyOrientationSensor::id)) + QSensorManager::registerBackend(QOrientationSensor::sensorType, IIOSensorProxyOrientationSensor::id, this); + if (!QSensorManager::isBackendRegistered(QLightSensor::sensorType, IIOSensorProxyLightSensor::id)) + QSensorManager::registerBackend(QLightSensor::sensorType, IIOSensorProxyLightSensor::id, this); + if (!QSensorManager::isBackendRegistered(QCompass::sensorType, IIOSensorProxyCompass::id)) + QSensorManager::registerBackend(QCompass::sensorType, IIOSensorProxyCompass::id, this); } } diff --git a/src/plugins/sensors/iio-sensor-proxy/org.freedesktop.DBus.Properties.xml b/src/plugins/sensors/iio-sensor-proxy/org.freedesktop.DBus.Properties.xml index 5dc94f5d..c7a43ca7 100644 --- a/src/plugins/sensors/iio-sensor-proxy/org.freedesktop.DBus.Properties.xml +++ b/src/plugins/sensors/iio-sensor-proxy/org.freedesktop.DBus.Properties.xml @@ -20,7 +20,7 @@ <signal name="PropertiesChanged"> <arg name="interface" type="s"/> <arg name="changed_properties" type="a{sv}"/> - <annotation name="org.qtproject.QtDBus.QtTypeName.In1" value="QVariantMap"/> + <annotation name="org.qtproject.QtDBus.QtTypeName.Out1" value="QVariantMap"/> <arg name="invalidated_properties" type="as"/> </signal> </interface> diff --git a/src/plugins/sensors/ios/CMakeLists.txt b/src/plugins/sensors/ios/CMakeLists.txt new file mode 100644 index 00000000..44f61427 --- /dev/null +++ b/src/plugins/sensors/ios/CMakeLists.txt @@ -0,0 +1,59 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +##################################################################### +## IOSSensorPlugin Plugin: +##################################################################### + +qt_internal_add_plugin(IOSSensorPlugin + OUTPUT_NAME qtsensors_ios + PLUGIN_TYPE sensors + SOURCES + main.mm + LIBRARIES + ${FWFoundation} + Qt::Core + Qt::Sensors +) + +#### Keys ignored in scope 1:.:.:ios.pro:<TRUE>: +# OTHER_FILES = "plugin.json" + +## Scopes: +##################################################################### + +set_target_properties(IOSSensorPlugin + PROPERTIES + DISABLE_PRECOMPILE_HEADERS ON +) + +qt_internal_extend_target(IOSSensorPlugin CONDITION IOS AND UIKIT + SOURCES + ioscompass.h ioscompass.mm + DEFINES + HAVE_COMPASS + LIBRARIES + ${FWCoreLocation} +) + +qt_internal_extend_target(IOSSensorPlugin CONDITION UIKIT AND NOT TVOS + SOURCES + iosaccelerometer.h iosaccelerometer.mm + iosgyroscope.h iosgyroscope.mm + iosmagnetometer.h iosmagnetometer.mm + iospressure.h iospressure.mm + iosmotionmanager.h iosmotionmanager.mm + DEFINES + HAVE_COREMOTION + LIBRARIES + ${FWCoreMotion} +) + +qt_internal_extend_target(IOSSensorPlugin CONDITION UIKIT AND NOT WATCHOS + SOURCES + iosproximitysensor.h iosproximitysensor.mm + DEFINES + HAVE_UIDEVICE + LIBRARIES + ${FWUIKit} +) diff --git a/src/plugins/sensors/ios/ios.pro b/src/plugins/sensors/ios/ios.pro deleted file mode 100644 index 91ec3ae0..00000000 --- a/src/plugins/sensors/ios/ios.pro +++ /dev/null @@ -1,49 +0,0 @@ -TARGET = qtsensors_ios -QT = core sensors - -OTHER_FILES = plugin.json - -OBJECTIVE_SOURCES += main.mm -LIBS += -framework Foundation - -uikit { - ios { - HEADERS += \ - ioscompass.h - OBJECTIVE_SOURCES += \ - ioscompass.mm - - DEFINES += HAVE_COMPASS - LIBS += -framework CoreLocation - } - - !tvos { - HEADERS += \ - iosaccelerometer.h \ - iosgyroscope.h \ - iosmagnetometer.h \ - iosmotionmanager.h - OBJECTIVE_SOURCES += \ - iosaccelerometer.mm \ - iosgyroscope.mm \ - iosmagnetometer.mm \ - iosmotionmanager.mm - - DEFINES += HAVE_COREMOTION - LIBS += -framework CoreMotion - } - - !watchos { - HEADERS += \ - iosproximitysensor.h - OBJECTIVE_SOURCES += \ - iosproximitysensor.mm - - DEFINES += HAVE_UIDEVICE - LIBS += -framework UIKit - } -} - -PLUGIN_TYPE = sensors -PLUGIN_CLASS_NAME = IOSSensorPlugin -load(qt_plugin) diff --git a/src/plugins/sensors/ios/iosaccelerometer.h b/src/plugins/sensors/ios/iosaccelerometer.h index 4ac73a97..fb8b93b5 100644 --- a/src/plugins/sensors/ios/iosaccelerometer.h +++ b/src/plugins/sensors/ios/iosaccelerometer.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Lorn Potter -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 Lorn Potter +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef IOSACCELEROMETER_H #define IOSACCELEROMETER_H diff --git a/src/plugins/sensors/ios/iosaccelerometer.mm b/src/plugins/sensors/ios/iosaccelerometer.mm index d2d6e9fb..84fd06ad 100644 --- a/src/plugins/sensors/ios/iosaccelerometer.mm +++ b/src/plugins/sensors/ios/iosaccelerometer.mm @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Lorn Potter -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 Lorn Potter +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "iosaccelerometer.h" #include "iosmotionmanager.h" diff --git a/src/plugins/sensors/ios/ioscompass.h b/src/plugins/sensors/ios/ioscompass.h index 2babc92a..3ebcb4ad 100644 --- a/src/plugins/sensors/ios/ioscompass.h +++ b/src/plugins/sensors/ios/ioscompass.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef IOSCompass_H #define IOSCompass_H diff --git a/src/plugins/sensors/ios/ioscompass.mm b/src/plugins/sensors/ios/ioscompass.mm index 7fc48d36..afcdef9f 100644 --- a/src/plugins/sensors/ios/ioscompass.mm +++ b/src/plugins/sensors/ios/ioscompass.mm @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #import <CoreLocation/CLHeading.h> #import <CoreLocation/CLLocationManagerDelegate.h> diff --git a/src/plugins/sensors/ios/iosgyroscope.h b/src/plugins/sensors/ios/iosgyroscope.h index 0d7fea49..f765a57d 100644 --- a/src/plugins/sensors/ios/iosgyroscope.h +++ b/src/plugins/sensors/ios/iosgyroscope.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef IOSGYROSCOPE_H #define IOSGYROSCOPE_H diff --git a/src/plugins/sensors/ios/iosgyroscope.mm b/src/plugins/sensors/ios/iosgyroscope.mm index 8155abac..5310e09b 100644 --- a/src/plugins/sensors/ios/iosgyroscope.mm +++ b/src/plugins/sensors/ios/iosgyroscope.mm @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "iosmotionmanager.h" #include "iosgyroscope.h" diff --git a/src/plugins/sensors/ios/iosmagnetometer.h b/src/plugins/sensors/ios/iosmagnetometer.h index 2c55eac3..7388c830 100644 --- a/src/plugins/sensors/ios/iosmagnetometer.h +++ b/src/plugins/sensors/ios/iosmagnetometer.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef IOSMAGNETOMETER_H #define IOSMAGNETOMETER_H diff --git a/src/plugins/sensors/ios/iosmagnetometer.mm b/src/plugins/sensors/ios/iosmagnetometer.mm index bfbe6e6d..9c60d544 100644 --- a/src/plugins/sensors/ios/iosmagnetometer.mm +++ b/src/plugins/sensors/ios/iosmagnetometer.mm @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "iosmotionmanager.h" #include "iosmagnetometer.h" @@ -53,7 +17,7 @@ IOSMagnetometer::IOSMagnetometer(QSensor *sensor) : QSensorBackend(sensor) , m_motionManager([QIOSMotionManager sharedManager]) , m_timer(0) - , m_returnGeoValues(false) + , m_returnGeoValues(true) { setReading<QMagnetometerReading>(&m_reading); // Technical information about data rate is not found, but @@ -75,7 +39,7 @@ void IOSMagnetometer::start() if (m_returnGeoValues) { if (++s_deviceMotionStartCount == 1) - [m_motionManager startDeviceMotionUpdates]; + [m_motionManager startDeviceMotionUpdatesUsingReferenceFrame:CMAttitudeReferenceFrameXMagneticNorthZVertical]; } else { if (++s_magnetometerStartCount == 1) [m_motionManager startMagnetometerUpdates]; diff --git a/src/plugins/sensors/ios/iosmotionmanager.h b/src/plugins/sensors/ios/iosmotionmanager.h index 7c2a1b27..cfb1d99f 100644 --- a/src/plugins/sensors/ios/iosmotionmanager.h +++ b/src/plugins/sensors/ios/iosmotionmanager.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Lorn Potter -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 Lorn Potter +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef IOSMOTIONMANAGER_H #define IOSMOTIONMANAGER_H diff --git a/src/plugins/sensors/ios/iosmotionmanager.mm b/src/plugins/sensors/ios/iosmotionmanager.mm index 90741089..3bf2c537 100644 --- a/src/plugins/sensors/ios/iosmotionmanager.mm +++ b/src/plugins/sensors/ios/iosmotionmanager.mm @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Lorn Potter -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 Lorn Potter +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "iosmotionmanager.h" diff --git a/src/plugins/sensors/ios/iospressure.h b/src/plugins/sensors/ios/iospressure.h new file mode 100644 index 00000000..f95b9bc4 --- /dev/null +++ b/src/plugins/sensors/ios/iospressure.h @@ -0,0 +1,37 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef IOSPRESSURE_H +#define IOSPRESSURE_H + +#include <qsensorbackend.h> +#include <qpressuresensor.h> + +@class CMAltimeter; + +QT_BEGIN_NAMESPACE + +class IOSPressure : public QSensorBackend +{ +public: + static char const * const id; + + explicit IOSPressure(QSensor *sensor); + ~IOSPressure(); + void timerEvent(QTimerEvent *) override; + + void start() override; + void stop() override; + +private: + Q_DISABLE_COPY_MOVE(IOSPressure) + CMAltimeter *m_altimeter = nullptr; + QPressureReading m_reading; + int m_timer = 0; + + static int s_startCount; +}; +QT_END_NAMESPACE + +#endif // IOSPRESSURE_H + diff --git a/src/plugins/sensors/ios/iospressure.mm b/src/plugins/sensors/ios/iospressure.mm new file mode 100644 index 00000000..d3a9275e --- /dev/null +++ b/src/plugins/sensors/ios/iospressure.mm @@ -0,0 +1,65 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#include "iospressure.h" +#import <CoreMotion/CoreMotion.h> + +char const * const IOSPressure::id("ios.pressure"); + +QT_BEGIN_NAMESPACE + +int IOSPressure::s_startCount = 0; + +IOSPressure::IOSPressure(QSensor *sensor) + : QSensorBackend(sensor) +{ + m_altimeter = [[CMAltimeter alloc] init]; + setReading<QPressureReading>(&m_reading); + addDataRate(1, 100); // 100Hz +} + +IOSPressure::~IOSPressure() +{ + [m_altimeter stopRelativeAltitudeUpdates]; + [m_altimeter release]; +} + +void IOSPressure::start() +{ + if (m_timer != 0) + return; + + int hz = sensor()->dataRate(); + m_timer = startTimer(1000 / (hz == 0 ? 60 : hz)); + if (++s_startCount == 1) { + [m_altimeter startRelativeAltitudeUpdatesToQueue:[NSOperationQueue mainQueue] + withHandler:^(CMAltitudeData * _Nullable altitudeData , NSError * _Nullable error) { + if (error == nil) { + m_reading.setPressure([altitudeData.pressure doubleValue] * 1000); + m_reading.setTimestamp(quint64(altitudeData.timestamp * 1e6)); + } + }]; + } +} + +void IOSPressure::stop() +{ + if (m_timer == 0) + return; + + killTimer(m_timer); + m_timer = 0; + if (--s_startCount == 0) + [m_altimeter stopRelativeAltitudeUpdates]; +} + +void IOSPressure::timerEvent(QTimerEvent *) +{ + // skip update if NaN or 0 + if ((m_reading.pressure() != m_reading.pressure()) || + m_reading.pressure() == 0) + return; + newReadingAvailable(); +} + +QT_END_NAMESPACE diff --git a/src/plugins/sensors/ios/iosproximitysensor.h b/src/plugins/sensors/ios/iosproximitysensor.h index 0d69391f..09d22650 100644 --- a/src/plugins/sensors/ios/iosproximitysensor.h +++ b/src/plugins/sensors/ios/iosproximitysensor.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef IOSPROXIMITYSENSOR_H #define IOSPROXIMITYSENSOR_H diff --git a/src/plugins/sensors/ios/iosproximitysensor.mm b/src/plugins/sensors/ios/iosproximitysensor.mm index e596aa5b..903877bf 100644 --- a/src/plugins/sensors/ios/iosproximitysensor.mm +++ b/src/plugins/sensors/ios/iosproximitysensor.mm @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #import <UIKit/UIDevice.h> diff --git a/src/plugins/sensors/ios/main.mm b/src/plugins/sensors/ios/main.mm index d6b98192..9e479de5 100644 --- a/src/plugins/sensors/ios/main.mm +++ b/src/plugins/sensors/ios/main.mm @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include <qsensorplugin.h> #include <qsensorbackend.h> @@ -47,6 +11,7 @@ #include "iosmagnetometer.h" #include "ioscompass.h" #include "iosproximitysensor.h" +#include "iospressure.h" #import <CoreLocation/CoreLocation.h> #ifdef HAVE_COREMOTION @@ -62,19 +27,21 @@ public: void registerSensors() override { #ifdef HAVE_COREMOTION - QSensorManager::registerBackend(QAccelerometer::type, IOSAccelerometer::id, this); + QSensorManager::registerBackend(QAccelerometer::sensorType, IOSAccelerometer::id, this); if ([QIOSMotionManager sharedManager].gyroAvailable) - QSensorManager::registerBackend(QGyroscope::type, IOSGyroscope::id, this); + QSensorManager::registerBackend(QGyroscope::sensorType, IOSGyroscope::id, this); if ([QIOSMotionManager sharedManager].magnetometerAvailable) - QSensorManager::registerBackend(QMagnetometer::type, IOSMagnetometer::id, this); + QSensorManager::registerBackend(QMagnetometer::sensorType, IOSMagnetometer::id, this); + if ([CMAltimeter isRelativeAltitudeAvailable]) + QSensorManager::registerBackend(QPressureSensor::sensorType, IOSPressure::id, this); #endif #ifdef HAVE_COMPASS if ([CLLocationManager headingAvailable]) - QSensorManager::registerBackend(QCompass::type, IOSCompass::id, this); + QSensorManager::registerBackend(QCompass::sensorType, IOSCompass::id, this); #endif #ifdef HAVE_UIDEVICE if (IOSProximitySensor::available()) - QSensorManager::registerBackend(QProximitySensor::type, IOSProximitySensor::id, this); + QSensorManager::registerBackend(QProximitySensor::sensorType, IOSProximitySensor::id, this); #endif } @@ -87,6 +54,8 @@ public: return new IOSGyroscope(sensor); if (sensor->identifier() == IOSMagnetometer::id) return new IOSMagnetometer(sensor); + if (sensor->identifier() == IOSPressure::id) + return new IOSPressure(sensor); #endif #ifdef HAVE_COMPASS if (sensor->identifier() == IOSCompass::id) diff --git a/src/plugins/sensors/linux/linux.pro b/src/plugins/sensors/linux/linux.pro deleted file mode 100644 index 33706e7d..00000000 --- a/src/plugins/sensors/linux/linux.pro +++ /dev/null @@ -1,13 +0,0 @@ -TARGET = qtsensors_linuxsys -QT = core sensors - -OTHER_FILES = plugin.json - -!android:LIBS += -lrt -HEADERS += linuxsysaccelerometer.h -SOURCES += linuxsysaccelerometer.cpp \ -main.cpp - -PLUGIN_TYPE = sensors -PLUGIN_CLASS_NAME = LinuxSensorPlugin -load(qt_plugin) diff --git a/src/plugins/sensors/linux/linuxsysaccelerometer.cpp b/src/plugins/sensors/linux/linuxsysaccelerometer.cpp deleted file mode 100644 index c5c7e375..00000000 --- a/src/plugins/sensors/linux/linuxsysaccelerometer.cpp +++ /dev/null @@ -1,188 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "linuxsysaccelerometer.h" -#include <QtCore/QDebug> -#include <QtCore/QtGlobal> -#include <QtCore/QFile> -#include <QtCore/QDebug> -#include <QtCore/QTimer> - -#include <QtCore/QStringList> - -#include <time.h> -#include <errno.h> - -char const * const LinuxSysAccelerometer::id("linuxsys.accelerometer"); - -// This plugin reads the accelerometer from a sys interface. - -// test machine (laptop): -// QT_ACCEL_FILEPATH=/sys/devices/platform/lis3lv02d/position -// QT_ACCEL_DATADIVISOR=7 -// QT_ACCEL_DELIMITER=, - -quint64 produceTimestamp() -{ - struct timespec tv; - int ok; - -#ifdef CLOCK_MONOTONIC_RAW - ok = clock_gettime(CLOCK_MONOTONIC_RAW, &tv); - if (ok != 0) -#endif - ok = clock_gettime(CLOCK_MONOTONIC, &tv); - Q_ASSERT(ok == 0); - - quint64 result = (tv.tv_sec * 1000000ULL) + (tv.tv_nsec * 0.001); // scale to microseconds - return result; -} - -// TODO get output template from env and apply -// Currently this assumes the output is like: -// (x,y,z) or x,y,z - -LinuxSysAccelerometer::LinuxSysAccelerometer(QSensor *sensor) - : QSensorBackend(sensor) - , m_timerid(0) - , path(QString()) - , divisor(0) - , delimiter(QString()) -{ - setReading<QAccelerometerReading>(&m_reading); - addDataRate(1, 100); // 100Hz - addOutputRange(-22.418, 22.418, 0.17651); // 2G -// not sure how to retrieve proper range - - path = QString::fromLatin1(qgetenv("QT_ACCEL_FILEPATH")); - bool ok; - divisor = QString::fromLatin1(qgetenv("QT_ACCEL_DATADIVISOR")).toInt(&ok); - if (divisor == 0 || !ok) { - divisor = 1; - } - delimiter = QString::fromLatin1(qgetenv("QT_ACCEL_DELIMITER")); - file.setFileName(path); -} - -LinuxSysAccelerometer::~LinuxSysAccelerometer() -{ -} - -void LinuxSysAccelerometer::start() -{ - if (m_timerid) - return; - - if (!openFile()) - return; - - int dataRate = sensor()->dataRate(); - if (dataRate == 0) { - if (sensor()->availableDataRates().count()) - dataRate = sensor()->availableDataRates().first().second; - else - dataRate = 1; - } - - int interval = 1000 / dataRate; - - if (interval) - m_timerid = startTimer(interval); -} - -void LinuxSysAccelerometer::stop() -{ - if (m_timerid) { - killTimer(m_timerid); - m_timerid = 0; - } - closeFile(); -} - -void LinuxSysAccelerometer::poll() -{ - if (!file.isOpen()) - return; - - file.seek(0); - QString str = file.readLine(); - if (str.isEmpty()) { - return; - } - str = str.simplified(); - - if (!str.at(0).isNumber() && str.at(0) != '-') { - str.remove(0,1); - } - - if (!str.at(str.size()-1).isNumber()) { - str.chop(1); - } - - QStringList accelDataList = str.split(delimiter); - - m_reading.setTimestamp(produceTimestamp()); - m_reading.setX(-accelDataList.at(0).toFloat() / divisor); - m_reading.setY(-accelDataList.at(1).toFloat() / divisor); - m_reading.setZ(-accelDataList.at(2).toFloat() / divisor); - - newReadingAvailable(); -} - -void LinuxSysAccelerometer::timerEvent(QTimerEvent * /*event*/) -{ - poll(); -} - -bool LinuxSysAccelerometer::openFile() -{ - if (!path.isEmpty() - && !file.open(QIODevice::ReadOnly)) { - qWarning() << "Could not open file" << strerror(errno); - return false; - } - return true; -} - -void LinuxSysAccelerometer::closeFile() -{ - file.close(); -} - - diff --git a/src/plugins/sensors/linux/linuxsysaccelerometer.h b/src/plugins/sensors/linux/linuxsysaccelerometer.h deleted file mode 100644 index af89bf77..00000000 --- a/src/plugins/sensors/linux/linuxsysaccelerometer.h +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef LINUXSYSACCELEROMETER_H -#define LINUXSYSACCELEROMETER_H - -#include <qsensorbackend.h> -#include <qaccelerometer.h> -#include <QtCore/QFile> - - -class LinuxSysAccelerometer : public QSensorBackend -{ -public: - static char const * const id; - - LinuxSysAccelerometer(QSensor *sensor); - ~LinuxSysAccelerometer(); - - void start() override; - void stop() override; - void poll(); - void timerEvent(QTimerEvent * /*event*/) override; - -private: - QAccelerometerReading m_reading; - int m_timerid; - - bool openFile(); - void closeFile(); - QString path; - QFile file; - float divisor; - QString delimiter; -}; - -#endif // LINUXSYSACCELEROMETER_H - diff --git a/src/plugins/sensors/linux/main.cpp b/src/plugins/sensors/linux/main.cpp deleted file mode 100644 index a82ab821..00000000 --- a/src/plugins/sensors/linux/main.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "linuxsysaccelerometer.h" - -#include <qsensorplugin.h> -#include <qsensorbackend.h> -#include <qsensormanager.h> - -#include <QtCore/QFile> -#include <QtCore/QDebug> - -class LinuxSensorPlugin : 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 - { - QString path = QString::fromLatin1(qgetenv("QT_ACCEL_FILEPATH")); - if (!path.isEmpty() && !QSensorManager::isBackendRegistered(QAccelerometer::type, LinuxSysAccelerometer::id)) - QSensorManager::registerBackend(QAccelerometer::type, LinuxSysAccelerometer::id, this); - } - - QSensorBackend *createBackend(QSensor *sensor) override - { - if (sensor->identifier() == LinuxSysAccelerometer::id) - return new LinuxSysAccelerometer(sensor); - - return 0; - } -}; - -#include "main.moc" - diff --git a/src/plugins/sensors/linux/plugin.json b/src/plugins/sensors/linux/plugin.json deleted file mode 100644 index f3863f11..00000000 --- a/src/plugins/sensors/linux/plugin.json +++ /dev/null @@ -1 +0,0 @@ -{ "Keys": [ "linux" ] } diff --git a/src/plugins/sensors/sensorfw/CMakeLists.txt b/src/plugins/sensors/sensorfw/CMakeLists.txt new file mode 100644 index 00000000..cc5e9dad --- /dev/null +++ b/src/plugins/sensors/sensorfw/CMakeLists.txt @@ -0,0 +1,38 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +##################################################################### +## sensorfwSensorPlugin Plugin: +##################################################################### + +qt_internal_add_plugin(sensorfwSensorPlugin + OUTPUT_NAME qtsensors_sensorfw + PLUGIN_TYPE sensors + SOURCES + main.cpp + sensorfwaccelerometer.cpp sensorfwaccelerometer.h + sensorfwals.cpp sensorfwals.h + sensorfwcompass.cpp sensorfwcompass.h + sensorfwgyroscope.cpp sensorfwgyroscope.h + sensorfwirproximitysensor.cpp sensorfwirproximitysensor.h + sensorfwlidsensor.cpp sensorfwlidsensor.h + sensorfwlightsensor.cpp sensorfwlightsensor.h + sensorfwmagnetometer.cpp sensorfwmagnetometer.h + sensorfworientationsensor.cpp sensorfworientationsensor.h + sensorfwproximitysensor.cpp sensorfwproximitysensor.h + sensorfwrotationsensor.cpp sensorfwrotationsensor.h + sensorfwsensorbase.cpp sensorfwsensorbase.h + sensorfwtapsensor.cpp sensorfwtapsensor.h + LIBRARIES + Qt::Core + Qt::DBus + Qt::Network + Qt::SensorsPrivate + sensorfw +) + +#### Keys ignored in scope 1:.:.:sensorfw.pro:<TRUE>: +# CONFIGFILES.files = "Sensors.conf" +# CONFIGFILES.path = "/etc/xdg/QtProject/" +# INSTALLS = "CONFIGFILES" +# OTHER_FILES = "plugin.json" diff --git a/src/plugins/sensors/sensorfw/main.cpp b/src/plugins/sensors/sensorfw/main.cpp index c1a02a57..9e8b6ac9 100644 --- a/src/plugins/sensors/sensorfw/main.cpp +++ b/src/plugins/sensors/sensorfw/main.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "sensorfwaccelerometer.h" #include "sensorfwals.h" diff --git a/src/plugins/sensors/sensorfw/sensorfw.pro b/src/plugins/sensors/sensorfw/sensorfw.pro deleted file mode 100644 index 63a66117..00000000 --- a/src/plugins/sensors/sensorfw/sensorfw.pro +++ /dev/null @@ -1,16 +0,0 @@ -TARGET = qtsensors_sensorfw -QT = core sensors-private network dbus - -include(sensorfw.pri) - -QMAKE_USE += sensorfw - -CONFIGFILES.files = Sensors.conf -CONFIGFILES.path = /etc/xdg/QtProject/ -INSTALLS += CONFIGFILES - -OTHER_FILES = plugin.json - -PLUGIN_TYPE = sensors -PLUGIN_CLASS_NAME = sensorfwSensorPlugin -load(qt_plugin) diff --git a/src/plugins/sensors/sensorfw/sensorfwaccelerometer.cpp b/src/plugins/sensors/sensorfw/sensorfwaccelerometer.cpp index 28152633..38910b3a 100644 --- a/src/plugins/sensors/sensorfw/sensorfwaccelerometer.cpp +++ b/src/plugins/sensors/sensorfw/sensorfwaccelerometer.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "sensorfwaccelerometer.h" diff --git a/src/plugins/sensors/sensorfw/sensorfwaccelerometer.h b/src/plugins/sensors/sensorfw/sensorfwaccelerometer.h index 036d3c1a..d877a4bb 100644 --- a/src/plugins/sensors/sensorfw/sensorfwaccelerometer.h +++ b/src/plugins/sensors/sensorfw/sensorfwaccelerometer.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef SENSORFWACCELEROMETER_H #define SENSORFWACCELEROMETER_H diff --git a/src/plugins/sensors/sensorfw/sensorfwals.cpp b/src/plugins/sensors/sensorfw/sensorfwals.cpp index c43f7648..8701f482 100644 --- a/src/plugins/sensors/sensorfw/sensorfwals.cpp +++ b/src/plugins/sensors/sensorfw/sensorfwals.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "sensorfwals.h" diff --git a/src/plugins/sensors/sensorfw/sensorfwals.h b/src/plugins/sensors/sensorfw/sensorfwals.h index 9a71550e..86af858b 100644 --- a/src/plugins/sensors/sensorfw/sensorfwals.h +++ b/src/plugins/sensors/sensorfw/sensorfwals.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef SENSORFWALS_H #define SENSORFWALS_H diff --git a/src/plugins/sensors/sensorfw/sensorfwcompass.cpp b/src/plugins/sensors/sensorfw/sensorfwcompass.cpp index 252404fa..05dc5672 100644 --- a/src/plugins/sensors/sensorfw/sensorfwcompass.cpp +++ b/src/plugins/sensors/sensorfw/sensorfwcompass.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "sensorfwcompass.h" diff --git a/src/plugins/sensors/sensorfw/sensorfwcompass.h b/src/plugins/sensors/sensorfw/sensorfwcompass.h index 9afe9b41..2db3e924 100644 --- a/src/plugins/sensors/sensorfw/sensorfwcompass.h +++ b/src/plugins/sensors/sensorfw/sensorfwcompass.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef SENSORFWCOMPASS_H #define SENSORFWCOMPASS_H diff --git a/src/plugins/sensors/sensorfw/sensorfwgyroscope.cpp b/src/plugins/sensors/sensorfw/sensorfwgyroscope.cpp index 8c516f3b..096b6be3 100644 --- a/src/plugins/sensors/sensorfw/sensorfwgyroscope.cpp +++ b/src/plugins/sensors/sensorfw/sensorfwgyroscope.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "sensorfwgyroscope.h" diff --git a/src/plugins/sensors/sensorfw/sensorfwgyroscope.h b/src/plugins/sensors/sensorfw/sensorfwgyroscope.h index 6b685a1d..97335379 100644 --- a/src/plugins/sensors/sensorfw/sensorfwgyroscope.h +++ b/src/plugins/sensors/sensorfw/sensorfwgyroscope.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef SENSORFWGYROSCOPE_H diff --git a/src/plugins/sensors/sensorfw/sensorfwirproximitysensor.cpp b/src/plugins/sensors/sensorfw/sensorfwirproximitysensor.cpp index 83714d82..05e4ce67 100644 --- a/src/plugins/sensors/sensorfw/sensorfwirproximitysensor.cpp +++ b/src/plugins/sensors/sensorfw/sensorfwirproximitysensor.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "sensorfwirproximitysensor.h" #define RM680_PS "/dev/bh1770glc_ps" diff --git a/src/plugins/sensors/sensorfw/sensorfwirproximitysensor.h b/src/plugins/sensors/sensorfw/sensorfwirproximitysensor.h index ece68a58..d82096a6 100644 --- a/src/plugins/sensors/sensorfw/sensorfwirproximitysensor.h +++ b/src/plugins/sensors/sensorfw/sensorfwirproximitysensor.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef SENSORFWIRPROXIMITYSENSOR_H #define SENSORFWIRPROXIMITYSENSOR_H diff --git a/src/plugins/sensors/sensorfw/sensorfwlidsensor.cpp b/src/plugins/sensors/sensorfw/sensorfwlidsensor.cpp index 18661b95..e922096a 100644 --- a/src/plugins/sensors/sensorfw/sensorfwlidsensor.cpp +++ b/src/plugins/sensors/sensorfw/sensorfwlidsensor.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Canonical, Ltd -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 Canonical, Ltd +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "sensorfwlidsensor.h" diff --git a/src/plugins/sensors/sensorfw/sensorfwlidsensor.h b/src/plugins/sensors/sensorfw/sensorfwlidsensor.h index 7ee967a9..50d222e9 100644 --- a/src/plugins/sensors/sensorfw/sensorfwlidsensor.h +++ b/src/plugins/sensors/sensorfw/sensorfwlidsensor.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Canonical, Ltd -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 Canonical, Ltd +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef SENSORFWLIDSENSOR_H diff --git a/src/plugins/sensors/sensorfw/sensorfwlightsensor.cpp b/src/plugins/sensors/sensorfw/sensorfwlightsensor.cpp index 9fc5bef3..cf20cdbe 100644 --- a/src/plugins/sensors/sensorfw/sensorfwlightsensor.cpp +++ b/src/plugins/sensors/sensorfw/sensorfwlightsensor.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "sensorfwlightsensor.h" diff --git a/src/plugins/sensors/sensorfw/sensorfwlightsensor.h b/src/plugins/sensors/sensorfw/sensorfwlightsensor.h index 9d8faa6c..c3e0fb87 100644 --- a/src/plugins/sensors/sensorfw/sensorfwlightsensor.h +++ b/src/plugins/sensors/sensorfw/sensorfwlightsensor.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef SENSORFWLIGHTSENSOR_H diff --git a/src/plugins/sensors/sensorfw/sensorfwmagnetometer.cpp b/src/plugins/sensors/sensorfw/sensorfwmagnetometer.cpp index 517e1fe8..2946f11f 100644 --- a/src/plugins/sensors/sensorfw/sensorfwmagnetometer.cpp +++ b/src/plugins/sensors/sensorfw/sensorfwmagnetometer.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "sensorfwmagnetometer.h" diff --git a/src/plugins/sensors/sensorfw/sensorfwmagnetometer.h b/src/plugins/sensors/sensorfw/sensorfwmagnetometer.h index 26a08108..0ba66b62 100644 --- a/src/plugins/sensors/sensorfw/sensorfwmagnetometer.h +++ b/src/plugins/sensors/sensorfw/sensorfwmagnetometer.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef SENSORFWMAGNETOMETER_H #define SENSORFWMAGNETOMETER_H diff --git a/src/plugins/sensors/sensorfw/sensorfworientationsensor.cpp b/src/plugins/sensors/sensorfw/sensorfworientationsensor.cpp index f659eb4c..f398b218 100644 --- a/src/plugins/sensors/sensorfw/sensorfworientationsensor.cpp +++ b/src/plugins/sensors/sensorfw/sensorfworientationsensor.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "sensorfworientationsensor.h" diff --git a/src/plugins/sensors/sensorfw/sensorfworientationsensor.h b/src/plugins/sensors/sensorfw/sensorfworientationsensor.h index fac59fe8..8863b0cd 100644 --- a/src/plugins/sensors/sensorfw/sensorfworientationsensor.h +++ b/src/plugins/sensors/sensorfw/sensorfworientationsensor.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef SENSORFWORIENTATIONSENSOR_H #define SENSORFWORIENTATIONSENSOR_H diff --git a/src/plugins/sensors/sensorfw/sensorfwproximitysensor.cpp b/src/plugins/sensors/sensorfw/sensorfwproximitysensor.cpp index 8eb28705..04eb698b 100644 --- a/src/plugins/sensors/sensorfw/sensorfwproximitysensor.cpp +++ b/src/plugins/sensors/sensorfw/sensorfwproximitysensor.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "sensorfwproximitysensor.h" diff --git a/src/plugins/sensors/sensorfw/sensorfwproximitysensor.h b/src/plugins/sensors/sensorfw/sensorfwproximitysensor.h index 992db84a..daeabd4d 100644 --- a/src/plugins/sensors/sensorfw/sensorfwproximitysensor.h +++ b/src/plugins/sensors/sensorfw/sensorfwproximitysensor.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef SENSORFWPROXIMITYSENSOR_H #define SENSORFWPROXIMITYSENSOR_H diff --git a/src/plugins/sensors/sensorfw/sensorfwrotationsensor.cpp b/src/plugins/sensors/sensorfw/sensorfwrotationsensor.cpp index fa36f76f..8c99cfb0 100644 --- a/src/plugins/sensors/sensorfw/sensorfwrotationsensor.cpp +++ b/src/plugins/sensors/sensorfw/sensorfwrotationsensor.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "sensorfwrotationsensor.h" diff --git a/src/plugins/sensors/sensorfw/sensorfwrotationsensor.h b/src/plugins/sensors/sensorfw/sensorfwrotationsensor.h index 9723922b..de0fe24d 100644 --- a/src/plugins/sensors/sensorfw/sensorfwrotationsensor.h +++ b/src/plugins/sensors/sensorfw/sensorfwrotationsensor.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef SENSORFWROTATION_H diff --git a/src/plugins/sensors/sensorfw/sensorfwsensorbase.cpp b/src/plugins/sensors/sensorfw/sensorfwsensorbase.cpp index 27a07ad6..9736857b 100644 --- a/src/plugins/sensors/sensorfw/sensorfwsensorbase.cpp +++ b/src/plugins/sensors/sensorfw/sensorfwsensorbase.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "sensorfwsensorbase.h" @@ -92,7 +56,7 @@ void SensorfwSensorBase::start() if (m_sensorInterface) { // dataRate QByteArray type = sensor()->type(); - if (type != QTapSensor::type && type != QProximitySensor::type) { + if (type != QTapSensor::sensorType && type != QProximitySensor::sensorType) { int dataRate = sensor()->dataRate(); int interval = dataRate > 0 ? 1000 / dataRate : 0; // for testing maximum speed @@ -291,8 +255,8 @@ bool SensorfwSensorBase::initSensorInterface(QString const &name) // TODO deztructor: Leaking abstraction detected. Just copied code // from initSensor<>() here, need to QByteArray type = sensor()->type(); - if ((type == QAmbientLightSensor::type) // SensorFW returns lux values, plugin enumerated values - || (type == QIRProximitySensor::type) // SensorFW returns raw reflectance values, plugin % of max reflectance + if ((type == QAmbientLightSensor::sensorType) // SensorFW returns lux values, plugin enumerated values + || (type == QIRProximitySensor::sensorType) // SensorFW returns raw reflectance values, plugin % of max reflectance || (name == "accelerometersensor") // SensorFW returns milliGs, plugin m/s^2 || (name == "magnetometersensor") // SensorFW returns nanoTeslas, plugin Teslas || (name == "gyroscopesensor")) // SensorFW returns DSPs, plugin milliDSPs @@ -330,4 +294,3 @@ bool SensorfwSensorBase::isFeatureSupported(QSensor::Feature feature) const return false; } - diff --git a/src/plugins/sensors/sensorfw/sensorfwsensorbase.h b/src/plugins/sensors/sensorfw/sensorfwsensorbase.h index 7e7f5c33..db78017a 100644 --- a/src/plugins/sensors/sensorfw/sensorfwsensorbase.h +++ b/src/plugins/sensors/sensorfw/sensorfwsensorbase.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef SENSORFWSENSORBASE_H @@ -101,7 +65,7 @@ protected: int bufferSize() const; virtual qreal correctionFactor() const; bool reinitIsNeeded; - bool isFeatureSupported(QSensor::Feature feature) const; + bool isFeatureSupported(QSensor::Feature feature) const override; private: bool initSensorInterface(QString const &); diff --git a/src/plugins/sensors/sensorfw/sensorfwtapsensor.cpp b/src/plugins/sensors/sensorfw/sensorfwtapsensor.cpp index 23498618..95dd794c 100644 --- a/src/plugins/sensors/sensorfw/sensorfwtapsensor.cpp +++ b/src/plugins/sensors/sensorfw/sensorfwtapsensor.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "sensorfwtapsensor.h" diff --git a/src/plugins/sensors/sensorfw/sensorfwtapsensor.h b/src/plugins/sensors/sensorfw/sensorfwtapsensor.h index 7e9edb4c..a8e48a86 100644 --- a/src/plugins/sensors/sensorfw/sensorfwtapsensor.h +++ b/src/plugins/sensors/sensorfw/sensorfwtapsensor.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef SENSORFWTAPSENSOR_H #define SENSORFWTAPSENSOR_H diff --git a/src/plugins/sensors/sensors.pro b/src/plugins/sensors/sensors.pro deleted file mode 100644 index 7fce2071..00000000 --- a/src/plugins/sensors/sensors.pro +++ /dev/null @@ -1,45 +0,0 @@ -TEMPLATE = subdirs -QT_FOR_CONFIG += sensors-private - -android { - isEmpty(SENSORS_PLUGINS): SENSORS_PLUGINS = android generic -} - -qtConfig(sensorfw) { - isEmpty(SENSORS_PLUGINS): SENSORS_PLUGINS = sensorfw generic -} - -darwin { - isEmpty(SENSORS_PLUGINS): SENSORS_PLUGINS = ios generic -} - -winrt { - isEmpty(SENSORS_PLUGINS): SENSORS_PLUGINS = winrt generic -} - -qtHaveModule(simulator) { - isEmpty(SENSORS_PLUGINS): SENSORS_PLUGINS = simulator generic -} - -linux { - isEmpty(SENSORS_PLUGINS): SENSORS_PLUGINS = linux iio-sensor-proxy generic -} - -contains(CONFIG, sensortag) { - qtHaveModule(bluetooth) { - SENSORS_PLUGINS = sensortag generic - } else { - message("You have configured for sensortag, but Qt Bluetooth module was not found.") - } -} - -contains(SENSORS_PLUGINS, dummy):SUBDIRS += dummy -isEmpty(SENSORS_PLUGINS)|contains(SENSORS_PLUGINS, generic):SUBDIRS += generic -isEmpty(SENSORS_PLUGINS)|contains(SENSORS_PLUGINS, simulator):qtHaveModule(simulator):SUBDIRS += simulator -isEmpty(SENSORS_PLUGINS)|contains(SENSORS_PLUGINS, linux):linux:SUBDIRS += linux -isEmpty(SENSORS_PLUGINS)|contains(SENSORS_PLUGINS, iio-sensor-proxy):linux:qtHaveModule(dbus):SUBDIRS += iio-sensor-proxy -isEmpty(SENSORS_PLUGINS)|contains(SENSORS_PLUGINS, android):android:SUBDIRS += android -isEmpty(SENSORS_PLUGINS)|contains(SENSORS_PLUGINS, sensorfw):sensorfw:SUBDIRS += sensorfw -isEmpty(SENSORS_PLUGINS)|contains(SENSORS_PLUGINS, sensortag):linux:SUBDIRS += sensortag -isEmpty(SENSORS_PLUGINS)|contains(SENSORS_PLUGINS, ios):darwin:SUBDIRS += ios -isEmpty(SENSORS_PLUGINS)|contains(SENSORS_PLUGINS, winrt):winrt:SUBDIRS += winrt diff --git a/src/plugins/sensors/sensortag/Sensors.conf b/src/plugins/sensors/sensortag/Sensors.conf deleted file mode 100644 index b8d79752..00000000 --- a/src/plugins/sensors/sensortag/Sensors.conf +++ /dev/null @@ -1,13 +0,0 @@ -[Default] -QAccelerometer=sensortag.accelerometer -QAmbientLightSensor=sensortag.als -QCompass=sensortag.compass -QMagnetometer=sensortag.magnetometer -QOrientationSensor=sensortag.orientationsensor -QProximitySensor=sensortag.proximitysensor -QRotationSensor=sensortag.rotationsensor -QTapSensor=sensortag.tapsensor -QLightSensor=sensortag.lightsensor -QIRProximitySensor=sensortag.irproximitysensor -QGyroscope=sensortag.gyroscope -QLidSensor=sensortag.lidsensor diff --git a/src/plugins/sensors/sensortag/main.cpp b/src/plugins/sensors/sensortag/main.cpp deleted file mode 100644 index e6dc54e5..00000000 --- a/src/plugins/sensors/sensortag/main.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Copyright (C) 2016 Canonical, Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "sensortagaccelerometer.h" -#include "sensortagals.h" -#include "sensortagbase.h" -#include "sensortaggyroscope.h" -#include "sensortaghumiditysensor.h" -#include "sensortaglightsensor.h" -#include "sensortagmagnetometer.h" -#include "sensortagpressuresensor.h" -#include "sensortagtemperaturesensor.h" - -#include <QtSensors/qsensorplugin.h> -#include <QtSensors/qsensorbackend.h> -#include <QtSensors/qsensormanager.h> -#include <QSettings> - -class SensortagSensorPlugin : 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() - { - if (!QSensorManager::isBackendRegistered(QAccelerometer::type, SensorTagAccelerometer::id)) - QSensorManager::registerBackend(QAccelerometer::type, SensorTagAccelerometer::id, this); - - if (!QSensorManager::isBackendRegistered(QAmbientLightSensor::type, SensorTagAls::id)) - QSensorManager::registerBackend(QAmbientLightSensor::type, SensorTagAls::id, this); - - if (!QSensorManager::isBackendRegistered(QLightSensor::type, SensorTagLightSensor::id)) - QSensorManager::registerBackend(QLightSensor::type, SensorTagLightSensor::id, this); - - if (!QSensorManager::isBackendRegistered(QAmbientTemperatureSensor::type, SensorTagTemperatureSensor::id)) - QSensorManager::registerBackend(QAmbientTemperatureSensor::type, SensorTagTemperatureSensor::id, this); - - if (!QSensorManager::isBackendRegistered(QHumiditySensor::type, SensorTagHumiditySensor::id)) - QSensorManager::registerBackend(QHumiditySensor::type, SensorTagHumiditySensor::id, this); - - if (!QSensorManager::isBackendRegistered(QPressureSensor::type, SensorTagPressureSensor::id)) - QSensorManager::registerBackend(QPressureSensor::type, SensorTagPressureSensor::id, this); - - if (!QSensorManager::isBackendRegistered(QGyroscope::type, SensorTagGyroscope::id)) - QSensorManager::registerBackend(QGyroscope::type, SensorTagGyroscope::id, this); - - if (!QSensorManager::isBackendRegistered(QMagnetometer::type, SensorTagMagnetometer::id)) - QSensorManager::registerBackend(QMagnetometer::type, SensorTagMagnetometer::id, this); - } - - QSensorBackend *createBackend(QSensor *sensor) - { - if (sensor->identifier() == SensorTagAccelerometer::id) - return new SensorTagAccelerometer(sensor); - if (sensor->identifier() == SensorTagAls::id) - return new SensorTagAls(sensor); - if (sensor->identifier() == SensorTagLightSensor::id) - return new SensorTagLightSensor(sensor); - if (sensor->identifier() == SensorTagTemperatureSensor::id) - return new SensorTagTemperatureSensor(sensor); - if (sensor->identifier() == SensorTagHumiditySensor::id) - return new SensorTagHumiditySensor(sensor); - if (sensor->identifier() == SensorTagPressureSensor::id) - return new SensorTagPressureSensor(sensor); - if (sensor->identifier() == SensorTagGyroscope::id) - return new SensorTagGyroscope(sensor); - if (sensor->identifier() == SensorTagMagnetometer::id) - return new SensorTagMagnetometer(sensor); - return nullptr; - } -}; - -#include "main.moc" diff --git a/src/plugins/sensors/sensortag/plugin.json b/src/plugins/sensors/sensortag/plugin.json deleted file mode 100644 index 9a0f4d52..00000000 --- a/src/plugins/sensors/sensortag/plugin.json +++ /dev/null @@ -1 +0,0 @@ -{ "Keys": [ "sensortag" ] } diff --git a/src/plugins/sensors/sensortag/sensortag.pri b/src/plugins/sensors/sensortag/sensortag.pri deleted file mode 100644 index d1d60cb1..00000000 --- a/src/plugins/sensors/sensortag/sensortag.pri +++ /dev/null @@ -1,22 +0,0 @@ -# Input -HEADERS += sensortagaccelerometer.h \ - sensortagals.h \ - sensortagbase.h \ - sensortaggyroscope.h \ - sensortaghumiditysensor.h \ - sensortaglightsensor.h \ - sensortagmagnetometer.h \ - sensortagpressuresensor.h \ - sensortagtemperaturesensor.h - -SOURCES += main.cpp \ - sensortagaccelerometer.cpp \ - sensortagals.cpp \ - sensortagbase.cpp \ - sensortaggyroscope.cpp \ - sensortaghumiditysensor.cpp \ - sensortaglightsensor.cpp \ - sensortagmagnetometer.cpp \ - sensortagpressuresensor.cpp \ - sensortagtemperaturesensor.cpp - diff --git a/src/plugins/sensors/sensortag/sensortag.pro b/src/plugins/sensors/sensortag/sensortag.pro deleted file mode 100644 index 42252970..00000000 --- a/src/plugins/sensors/sensortag/sensortag.pro +++ /dev/null @@ -1,11 +0,0 @@ -TARGET = qtsensors_sensortag -QT = core sensors-private bluetooth -CONFIG += c++11 - -include(sensortag.pri) - -OTHER_FILES = plugin.json - -PLUGIN_TYPE = sensors -PLUGIN_CLASS_NAME = SensortagSensorPlugin -load(qt_plugin) diff --git a/src/plugins/sensors/sensortag/sensortagaccelerometer.cpp b/src/plugins/sensors/sensortag/sensortagaccelerometer.cpp deleted file mode 100644 index b5b582a9..00000000 --- a/src/plugins/sensors/sensortag/sensortagaccelerometer.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Lorn Potter -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "sensortagaccelerometer.h" -#include <QtSensors/qsensorbackend.h> - -char const * const SensorTagAccelerometer::id("sensortag.accelerometer"); - -SensorTagAccelerometer::SensorTagAccelerometer(QSensor *sensor) - : SensorTagBase(sensor) -{ - init(); - setDescription(QLatin1String("x, y, and z axes accelerations in m/s^2")); - setReading<QAccelerometerReading>(&m_reading); - sensor->setDataRate(50);//set a default rate -} - -void SensorTagAccelerometer::slotDataAvailable(const QAccelerometerReading &data) -{ - m_reading.setX(data.x()); - m_reading.setY(data.y()); - m_reading.setZ(data.z()); - m_reading.setTimestamp(produceTimestamp()); - newReadingAvailable(); -} - -void SensorTagAccelerometer::init() -{ - m_initDone = false; -} - -void SensorTagAccelerometer::start() -{ - QObject::connect(this, &SensorTagBase::accelDataAvailable, - this, &SensorTagAccelerometer::slotDataAvailable); - d_ptr->enableService(TI_SENSORTAG_ACCELEROMETER_SERVICE); -} - -void SensorTagAccelerometer::stop() -{ - QObject::disconnect(this, &SensorTagBase::accelDataAvailable, - this, &SensorTagAccelerometer::slotDataAvailable); - d_ptr->disableService(TI_SENSORTAG_ACCELEROMETER_SERVICE); -} - diff --git a/src/plugins/sensors/sensortag/sensortagaccelerometer.h b/src/plugins/sensors/sensortag/sensortagaccelerometer.h deleted file mode 100644 index 39ad47f6..00000000 --- a/src/plugins/sensors/sensortag/sensortagaccelerometer.h +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Lorn Potter -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SENSORTAGACCELEROMETER_H -#define SENSORTAGACCELEROMETER_H - -#include "sensortagbase.h" -#include <QtSensors/qaccelerometer.h> - -class SensorTagAccelerometer : public SensorTagBase -{ - Q_OBJECT - -public: - static char const * const id; - SensorTagAccelerometer(QSensor *sensor); -protected: - void start() override; - void stop() override; - virtual void init(); - -private: - QAccelerometerReading m_reading; - bool m_initDone = false; - -private slots: - void slotDataAvailable(const QAccelerometerReading &data); -}; - -#endif -// SENSORTAGACCELEROMETER_H diff --git a/src/plugins/sensors/sensortag/sensortagals.cpp b/src/plugins/sensors/sensortag/sensortagals.cpp deleted file mode 100644 index 3fe2de4c..00000000 --- a/src/plugins/sensors/sensortag/sensortagals.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Lorn Potter -** Copyright (C) 2017 The Qt Company Ltd. -** Copyright (C) 2016 Canonical, Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "sensortagals.h" -#include "sensortagbase.h" -#include <QDebug> - -char const * const SensorTagAls::id("sensortag.als"); - -SensorTagAls::SensorTagAls(QSensor *sensor) - : SensorTagBase(sensor) - , m_initDone(false) -{ - init(); - setReading<QAmbientLightReading>(&m_reading); - setDescription(QLatin1String("ambient light intensity given as 5 pre-defined levels")); -} - -void SensorTagAls::start() -{ - QObject::connect(this, &SensorTagBase::luxDataAvailable, this, &SensorTagAls::slotDataAvailable); - d_ptr->enableService(TI_SENSORTAG_LIGHT_SERVICE); -} - -void SensorTagAls::stop() -{ - QObject::disconnect(this, &SensorTagBase::luxDataAvailable, this, &SensorTagAls::slotDataAvailable); - d_ptr->disableService(TI_SENSORTAG_LIGHT_SERVICE); -} - -void SensorTagAls::slotDataAvailable(qreal data) -{ - QAmbientLightReading::LightLevel level = getLightLevel(data); - if (level != m_reading.lightLevel()) { - m_reading.setLightLevel(level); - m_reading.setTimestamp(produceTimestamp()); - newReadingAvailable(); - } -} - -QAmbientLightReading::LightLevel SensorTagAls::getLightLevel(int lux) -{ - if (lux < 0) - return QAmbientLightReading::Undefined; - if (lux < 10) - return QAmbientLightReading::Dark; - if (lux < 80) - return QAmbientLightReading::Twilight; - if (lux < 400) - return QAmbientLightReading::Light; - if (lux < 2500) - return QAmbientLightReading::Bright; - return QAmbientLightReading::Sunny; -} - -void SensorTagAls::init() -{ - m_initDone = false; -} diff --git a/src/plugins/sensors/sensortag/sensortagals.h b/src/plugins/sensors/sensortag/sensortagals.h deleted file mode 100644 index 3ef1b928..00000000 --- a/src/plugins/sensors/sensortag/sensortagals.h +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Lorn Potter -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SENSORTAGALS_H -#define SENSORTAGALS_H - -#include "sensortagbase.h" -#include <QtSensors/qambientlightsensor.h> - -class SensorTagAls : public SensorTagBase -{ - Q_OBJECT - -public: - static char const * const id; - SensorTagAls(QSensor *sensor); -protected: - void start() override; - void stop() override; - virtual void init(); - -private: - QAmbientLightReading m_reading; - bool m_initDone = false; -private slots: - void slotDataAvailable(qreal data); - static QAmbientLightReading::LightLevel getLightLevel(int lux); -}; - -#endif -//SENSORTAGALS_H diff --git a/src/plugins/sensors/sensortag/sensortagbase.cpp b/src/plugins/sensors/sensortag/sensortagbase.cpp deleted file mode 100644 index 322a86d7..00000000 --- a/src/plugins/sensors/sensortag/sensortagbase.cpp +++ /dev/null @@ -1,600 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Lorn Potter -** Copyright (C) 2016 Canonical, Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "sensortagbase.h" - -#include <QLowEnergyCharacteristic> -#include <QtMath> -#include <QTimer> -#include <QDeadlineTimer> - -Q_GLOBAL_STATIC(SensorTagBasePrivate, sensortagBasePrivate) - -SensorTagBasePrivate::SensorTagBasePrivate(QObject *parent) - : QObject(parent) -{ - QTimer::singleShot(50, this, &SensorTagBasePrivate::deviceSearch); -} - -void SensorTagBasePrivate::deviceSearch() -{ - m_deviceDiscoveryAgent = new QBluetoothDeviceDiscoveryAgent(this); - - connect(m_deviceDiscoveryAgent, &QBluetoothDeviceDiscoveryAgent::deviceDiscovered, - this, &SensorTagBasePrivate::deviceFound); - connect(m_deviceDiscoveryAgent, QOverload<QBluetoothDeviceDiscoveryAgent::Error>::of(&QBluetoothDeviceDiscoveryAgent::error), - this, &SensorTagBasePrivate::deviceScanError); - connect(m_deviceDiscoveryAgent, &QBluetoothDeviceDiscoveryAgent::finished, - this, &SensorTagBasePrivate::scanFinished); - - QTimer::singleShot(20000, this, &SensorTagBasePrivate::deviceSearchTimeout); //make sure to timeout - m_deviceDiscoveryAgent->start(QBluetoothDeviceDiscoveryAgent::LowEnergyMethod); -} - -void SensorTagBasePrivate::deviceSearchTimeout() -{ - if (m_deviceDiscoveryAgent->isActive() && m_control == nullptr) { - m_deviceDiscoveryAgent->stop(); - qWarning("No Sensor Tag devices found"); - } -} - -void SensorTagBasePrivate::deviceFound(const QBluetoothDeviceInfo &device) -{ - if (device.coreConfigurations() & QBluetoothDeviceInfo::LowEnergyCoreConfiguration) { - const QString idString = QString::fromLatin1(qgetenv("QT_SENSORTAG_ID")); - - const QBluetoothAddress watchForAddress(idString); - //mac uses deviceUuid - const QUuid watchForId(idString); - - bool ok; - - if ((!watchForAddress.isNull() && watchForAddress == device.address()) || - (!watchForId.isNull() && watchForId == device.deviceUuid())) { - ok = true; - } - if (ok || device.name().contains("SensorTag")) { - - m_deviceDiscoveryAgent->stop(); - - m_control = new QLowEnergyController(device.address(), this); - - connect(m_control, &QLowEnergyController::discoveryFinished, - this, &SensorTagBasePrivate::serviceDiscoveryFinished); - connect(m_control, &QLowEnergyController::serviceDiscovered, - this, &SensorTagBasePrivate::serviceDiscovered); - connect(m_control, QOverload<QLowEnergyController::Error>::of(&QLowEnergyController::error), - this, &SensorTagBasePrivate::controllerError); - connect(m_control, &QLowEnergyController::connected, - this, &SensorTagBasePrivate::sensortagDeviceConnected); - connect(m_control, &QLowEnergyController::disconnected, - this, &SensorTagBasePrivate::deviceDisconnected); - - m_control->connectToDevice(); - } - } -} - -void SensorTagBasePrivate::serviceDiscoveryFinished() -{ - discoveryDone = true; -} - -void SensorTagBasePrivate::scanFinished() -{ - if (m_control == nullptr) - qWarning("No Sensor Tag devices found"); -} - -void SensorTagBasePrivate::deviceScanError(QBluetoothDeviceDiscoveryAgent::Error error) -{ - switch (error) { - case QBluetoothDeviceDiscoveryAgent::PoweredOffError: - qWarning("The Bluetooth adaptor is powered off, power it on before doing discovery."); - break; - case QBluetoothDeviceDiscoveryAgent::InputOutputError: - qWarning("Writing or reading from the device resulted in an error."); - break; - default: - qWarning("An unknown error has occurred."); - break; - }; -} - -void SensorTagBasePrivate::serviceError(QLowEnergyService::ServiceError e) -{ - switch (e) { - case QLowEnergyService::DescriptorWriteError: - qWarning("Cannot obtain SensorTag notifications"); - break; - default: - case QLowEnergyService::CharacteristicWriteError: - qWarning() << "SensorTag service error:" << e; - break; - }; -} - -void SensorTagBasePrivate::controllerError(QLowEnergyController::Error error) -{ - qWarning("Cannot connect to remote device."); - qWarning() << "Controller Error:" << error; -} - -void SensorTagBasePrivate::sensortagDeviceConnected() -{ - m_control->discoverServices(); -} - -void SensorTagBasePrivate::deviceDisconnected() -{ - if (q_ptr && q_ptr->sensor()->isActive()) - q_ptr->sensorStopped(); -} - -void SensorTagBasePrivate::serviceDiscovered(const QBluetoothUuid &gatt) -{ - if (enabledServiceUuids.contains(gatt)) { - - if (gatt == TI_SENSORTAG_LIGHT_SERVICE) { - lightService = m_control->createServiceObject(gatt, this); - doConnections(lightService); - } else if (gatt == TI_SENSORTAG_TEMPERATURE_SERVICE) { - temperatureService = m_control->createServiceObject(gatt, this); - doConnections(temperatureService); - } else if (gatt == TI_SENSORTAG_BAROMETER_SERVICE) { - barometerService = m_control->createServiceObject(gatt, this); - doConnections(barometerService); - } else if (gatt == TI_SENSORTAG_HUMIDTIY_SERVICE) { - humidityService = m_control->createServiceObject(gatt, this); - doConnections(humidityService); - } else if (gatt == TI_SENSORTAG_INFO_SERVICE) { - infoService = m_control->createServiceObject(gatt, this); - doConnections(infoService); - } else if (gatt == TI_SENSORTAG_ACCELEROMETER_SERVICE) { - acceleratorService = m_control->createServiceObject(gatt, this); - doConnections(acceleratorService); - } else if (gatt == TI_SENSORTAG_GYROSCOPE_SERVICE) { - gyroscopeService = m_control->createServiceObject(gatt, this); - doConnections(gyroscopeService); - } else if (gatt == TI_SENSORTAG_MAGNETOMETER_SERVICE) { - magnetometerService = m_control->createServiceObject(gatt, this); - doConnections(magnetometerService); - } else if (movementService == nullptr) { - if (gatt == TI_SENSORTAG_MOVEMENT_SERVICE) { - movementService = m_control->createServiceObject(gatt, this); - doConnections(movementService); - } - } - } -} - -void SensorTagBasePrivate::doConnections(QLowEnergyService *service) -{ - if (service) { - connect(service, &QLowEnergyService::stateChanged, - this, &SensorTagBasePrivate::serviceStateChanged); - - connect(service, &QLowEnergyService::characteristicChanged, - this, &SensorTagBasePrivate::updateCharacteristic); - - connect(service,SIGNAL(error(QLowEnergyService::ServiceError)), - this,SLOT(serviceError(QLowEnergyService::ServiceError))); - - if (service->state() == QLowEnergyService::DiscoveryRequired) { - service->discoverDetails(); - } else if (!enabledServiceUuids.isEmpty() - && enabledServiceUuids.contains(service->serviceUuid())) { - enableService(service->serviceUuid()); - } - } -} - -void SensorTagBasePrivate::serviceStateChanged(QLowEnergyService::ServiceState newState) -{ - if (newState != QLowEnergyService::ServiceDiscovered) - return; - - QLowEnergyService *m_service = qobject_cast<QLowEnergyService *>(sender()); - - if (!m_service) - return; - - if (!enabledServiceUuids.isEmpty() - && enabledServiceUuids.contains(m_service->serviceUuid())) { - enableService(m_service->serviceUuid()); - } -} - -void SensorTagBasePrivate::enableLight(bool on) -{ - if (!lightService && discoveryDone) - serviceDiscovered(TI_SENSORTAG_LIGHT_SERVICE); - if (!lightService) - return; - - const QLowEnergyCharacteristic hrChar = lightService->characteristic(TI_SENSORTAG_LIGHT_CONTROL); - lightService->writeCharacteristic(hrChar, on ? enableSensorCharacteristic : disableSensorCharacteristic); - - const QLowEnergyCharacteristic hrChar2 = lightService->characteristic(TI_SENSORTAG_LIGHT_DATA); - - if (hrChar2.descriptors().count() > 0) { - const QLowEnergyDescriptor m_notificationDesc = hrChar2.descriptors().at(0); - lightService->writeDescriptor(m_notificationDesc, - on ? enableNotificationsCharacteristic : disableNotificationsCharacteristic); - } -} - -void SensorTagBasePrivate::enableTemp(bool on) -{ - if (!temperatureService && discoveryDone) - serviceDiscovered(TI_SENSORTAG_TEMPERATURE_SERVICE); - - if (!temperatureService) - return; - - const QLowEnergyCharacteristic hrChar = temperatureService->characteristic(TI_SENSORTAG_IR_TEMPERATURE_CONTROL); - temperatureService->writeCharacteristic(hrChar,on ? enableSensorCharacteristic : disableSensorCharacteristic); - - const QLowEnergyCharacteristic hrChar2 = temperatureService->characteristic(TI_SENSORTAG_IR_TEMPERATURE_DATA); - - if (hrChar2.descriptors().count() > 0) { - const QLowEnergyDescriptor m_notificationDesc = hrChar2.descriptors().at(0); - temperatureService->writeDescriptor(m_notificationDesc, - on ? enableNotificationsCharacteristic : disableNotificationsCharacteristic); - } -} - -void SensorTagBasePrivate::enablePressure(bool on) -{ - if (!barometerService && discoveryDone) - serviceDiscovered(TI_SENSORTAG_BAROMETER_SERVICE); - if (!barometerService) - return; - - const QLowEnergyCharacteristic hrChar = barometerService->characteristic(TI_SENSORTAG_BAROMETER_CONTROL); - barometerService->writeCharacteristic(hrChar, on ? enableSensorCharacteristic : disableSensorCharacteristic); - - const QLowEnergyCharacteristic hrChar2 = barometerService->characteristic(TI_SENSORTAG_BAROMETER_DATA); - if (hrChar2.descriptors().count() > 0) { - const QLowEnergyDescriptor m_notificationDesc = hrChar2.descriptors().at(0); - - barometerService->writeDescriptor(m_notificationDesc, - on ? enableNotificationsCharacteristic : disableNotificationsCharacteristic); - } -} - -void SensorTagBasePrivate::enableHumidity(bool on) -{ - if (!humidityService && discoveryDone) - serviceDiscovered(TI_SENSORTAG_HUMIDTIY_SERVICE); - if (!humidityService) - return; - - const QLowEnergyCharacteristic hrChar = humidityService->characteristic(TI_SENSORTAG_HUMIDTIY_CONTROL); - humidityService->writeCharacteristic(hrChar, on ? enableSensorCharacteristic : disableSensorCharacteristic); - const QLowEnergyCharacteristic hrChar2 = humidityService->characteristic(TI_SENSORTAG_HUMIDTIY_DATA); - if (hrChar2.descriptors().count() > 0) { - const QLowEnergyDescriptor m_notificationDesc = hrChar2.descriptors().at(0); - humidityService->writeDescriptor(m_notificationDesc, - on ? enableNotificationsCharacteristic : disableNotificationsCharacteristic); - } -} - -void SensorTagBasePrivate::enableMovement(bool on) -{ - if (!movementService && discoveryDone) - serviceDiscovered(TI_SENSORTAG_MOVEMENT_SERVICE); - if (!movementService) - return; - - QByteArray controlCharacteristic; - - int movementControl = 0; - //movement service has different syntax here - if (on) { - if (gyroscopeEnabled) - movementControl += 7; - if (accelerometerEnabled) - movementControl += 56; - if (magnetometerEnabled) - movementControl += 64; - - controlCharacteristic = QByteArray::number(movementControl, 16); - controlCharacteristic.append("04"); - - } else { - controlCharacteristic = "00"; - } - - const QLowEnergyCharacteristic hrChar = movementService->characteristic(TI_SENSORTAG_MOVEMENT_CONTROL); - movementService->writeCharacteristic(hrChar, QByteArray::fromHex(controlCharacteristic)); - - const QLowEnergyCharacteristic hrChar2 = movementService->characteristic(TI_SENSORTAG_MOVEMENT_DATA); - if (hrChar2.descriptors().count() > 0) { - QLowEnergyDescriptor m_notificationDesc = hrChar2.descriptors().at(0); - - movementService->writeDescriptor(m_notificationDesc, - on ? enableNotificationsCharacteristic : disableNotificationsCharacteristic); - } -} - -void SensorTagBasePrivate::enableService(const QBluetoothUuid &uuid) -{ - if (uuid == TI_SENSORTAG_ACCELEROMETER_SERVICE - || uuid == TI_SENSORTAG_MAGNETOMETER_SERVICE - || uuid == TI_SENSORTAG_GYROSCOPE_SERVICE) { - - if ((uuid != TI_SENSORTAG_MOVEMENT_SERVICE) - && (accelerometerEnabled || magnetometerEnabled || gyroscopeEnabled)) - return; - - if (!enabledServiceUuids.contains(TI_SENSORTAG_MOVEMENT_SERVICE)) - enabledServiceUuids.append(TI_SENSORTAG_MOVEMENT_SERVICE); - - if (uuid == TI_SENSORTAG_ACCELEROMETER_SERVICE) - accelerometerEnabled = true; - else if (uuid == TI_SENSORTAG_MAGNETOMETER_SERVICE) - magnetometerEnabled = true; - else if (uuid == TI_SENSORTAG_GYROSCOPE_SERVICE) - gyroscopeEnabled = true; - - } else if (!enabledServiceUuids.contains(uuid)) - enabledServiceUuids.append(uuid); - - if (discoveryDone) { - - if (uuid == TI_SENSORTAG_LIGHT_SERVICE) - enableLight(true); - else if (uuid == TI_SENSORTAG_TEMPERATURE_SERVICE) - enableTemp(true); - else if (uuid == TI_SENSORTAG_BAROMETER_SERVICE) - enablePressure(true); - else if (uuid == TI_SENSORTAG_HUMIDTIY_SERVICE) - enableHumidity(true); - else if (uuid == TI_SENSORTAG_MOVEMENT_SERVICE) - enableMovement(true); - else if (uuid == TI_SENSORTAG_ACCELEROMETER_SERVICE) - enableMovement(true); - else if (uuid == TI_SENSORTAG_MAGNETOMETER_SERVICE) - enableMovement(true); - else if (uuid == TI_SENSORTAG_GYROSCOPE_SERVICE) - enableMovement(true); - } -} - -void SensorTagBasePrivate::disableService(const QBluetoothUuid &uuid) -{ - enabledServiceUuids.removeOne(uuid); - - if (uuid == TI_SENSORTAG_LIGHT_SERVICE) { - enableLight(false); - } else if (uuid == TI_SENSORTAG_TEMPERATURE_SERVICE) { - enableTemp(false); - } else if (uuid == TI_SENSORTAG_BAROMETER_SERVICE) { - enablePressure(false); - } else if (uuid == TI_SENSORTAG_HUMIDTIY_SERVICE) { - enableHumidity(false); - } else if (uuid == TI_SENSORTAG_MOVEMENT_SERVICE) { - enableMovement(false); - } else if (uuid == TI_SENSORTAG_ACCELEROMETER_SERVICE) { - enableMovement(false); - accelerometerEnabled = false; - } else if (uuid == TI_SENSORTAG_MAGNETOMETER_SERVICE) { - enableMovement(false); - magnetometerEnabled = false; - } else if (uuid == TI_SENSORTAG_GYROSCOPE_SERVICE) { - enableMovement(false); - gyroscopeEnabled = false; - } -} - -void SensorTagBasePrivate::updateCharacteristic(const QLowEnergyCharacteristic &c, - const QByteArray &value) -{ - if (c.uuid() == TI_SENSORTAG_LIGHT_DATA) { - convertLux(value); - } else if (c.uuid()== TI_SENSORTAG_IR_TEMPERATURE_DATA) { - convertTemperature(value); - } else if (c.uuid() == TI_SENSORTAG_BAROMETER_DATA) { - convertBarometer(value); - } else if (c.uuid()== TI_SENSORTAG_HUMIDTIY_DATA) { - convertHumidity(value); - } else if (c.uuid()== TI_SENSORTAG_BAROMETER_DATA) { - convertBarometer(value); - } else if ((c.uuid() == TI_SENSORTAG_ACCELEROMETER_DATA - || c.uuid() == TI_SENSORTAG_MOVEMENT_DATA) && accelerometerEnabled) { - convertAccelerometer(value); - } else if ((c.uuid() == TI_SENSORTAG_MAGNETOMETER_DATA - || c.uuid()== TI_SENSORTAG_MOVEMENT_DATA) && magnetometerEnabled) { - convertMagnetometer(value); - } else if ((c.uuid() == TI_SENSORTAG_GYROSCOPE_DATA - || c.uuid() == TI_SENSORTAG_MOVEMENT_DATA) && gyroscopeEnabled) { - convertGyroscope(value); - } -} - -void SensorTagBasePrivate::convertLux(const QByteArray &bytes) -{ - if (bytes.size() < 1) - return; - - quint16 dat = ((quint16)bytes[1] & 0xFF) << 8; - dat |= (quint16)(bytes[0] & 0xFF); - - qreal lux = dat * .01; - - emit luxDataAvailable(lux); -} - -void SensorTagBasePrivate::convertTemperature(const QByteArray &bytes) -{ - if (bytes.size() < 3) - return; - - qint16 objTemp = ((bytes[0] & 0xff) | ((bytes[1] << 8) & 0xff00)); - objTemp >>= 2; - qreal objectTemperature = objTemp * 0.03125; - // change to this if you want to use the ambient/die temp sensor - // qreal ambientTemperature = ambTemp / 128.0; - - emit tempDataAvailable(objectTemperature); -} - -void SensorTagBasePrivate::convertHumidity(const QByteArray &bytes) -{ - if (bytes.size() < 3) - return; - quint16 rawH = (bytes[2] & 0xff) | ((bytes[3] << 8) & 0xff00); - qreal rHumidity = (qreal)(rawH / 65535) * 100.0; - - emit humidityDataAvailable(rHumidity); -} - -void SensorTagBasePrivate::convertBarometer(const QByteArray &bytes) -{ - if (bytes.size() < 5) - return; - quint32 pressure = (bytes[3] & 0xff) | ((bytes[4] << 8) & 0xff00) | ((bytes[5] << 16) & 0xff0000); - - qreal mbars = (qreal)pressure / 100.0; - emit pressureDataAvailable(mbars); -} - -void SensorTagBasePrivate::convertAccelerometer(const QByteArray &bytes) -{ - if (bytes.size() < 3) - return; - - int range = 8; - - qint16 X = (qint16)((bytes[8]) + ((bytes[9] << 8))); - qint16 Y = (qint16)((bytes[6]) + ((bytes[7] << 8))); - qint16 Z = (qint16)((bytes[10]) + ((bytes[11] << 8))); - - accelReading.setX((qreal)(X * 1.0) / (32768 / range) * 9.80665); - accelReading.setY(-(qreal)(Y * 1.0) / (32768 / range) * 9.80665); - accelReading.setZ((qreal)(Z * 1.0) / (32768 / range) * 9.80665); - // TODO needs calibration - - emit accelDataAvailable(accelReading); -} - -void SensorTagBasePrivate::convertMagnetometer(const QByteArray &bytes) -{ - if (bytes.size() < 3) - return; - - qreal scale = 6.67100977199; // 32768 / 4912; - qint16 X = (qint16)((bytes[12]) + ((bytes[13] << 8))); - qint16 Y = (qint16)((bytes[14]) + ((bytes[15] << 8))); - qint16 Z = (qint16)((bytes[16]) + ((bytes[17] << 8))); - // TODO needs calibration - - magReading.setX((qreal)(X / scale)); - magReading.setY((qreal)(Y / scale)); - magReading.setZ((qreal)(Z / scale)); - - emit magDataAvailable(magReading); -} - -void SensorTagBasePrivate::convertGyroscope(const QByteArray &bytes) -{ - if (bytes.size() < 3) - return; - - qreal scale = 128.0; - qint16 X = (qint16)((bytes[2]) + ((bytes[3] << 8))); - qint16 Y = (qint16)((bytes[0]) + ((bytes[1] << 8))); - qint16 Z = (qint16)((bytes[4]) + ((bytes[5] << 8))); - - gyroReading.setX((qreal)(X / scale)); - gyroReading.setY((qreal)(Y / scale)); - gyroReading.setZ((qreal)(Z / scale)); - - emit gyroDataAvailable(gyroReading); -} - -SensorTagBasePrivate * SensorTagBasePrivate::instance() -{ - SensorTagBasePrivate *priv = sensortagBasePrivate(); - return priv; -} - -SensorTagBase::SensorTagBase(QSensor *sensor) - : QSensorBackend(sensor), - leService(nullptr), - serviceId(nullptr), - d_ptr(SensorTagBasePrivate::instance()) -{ - connect(d_ptr, &SensorTagBasePrivate::luxDataAvailable, - this, &SensorTagBase::luxDataAvailable); - connect(d_ptr, &SensorTagBasePrivate::tempDataAvailable, - this, &SensorTagBase::tempDataAvailable); - connect(d_ptr, &SensorTagBasePrivate::humidityDataAvailable, - this, &SensorTagBase::humidityDataAvailable); - connect(d_ptr, &SensorTagBasePrivate::pressureDataAvailable, - this, &SensorTagBase::pressureDataAvailable); - connect(d_ptr, &SensorTagBasePrivate::accelDataAvailable, - this, &SensorTagBase::accelDataAvailable); - connect(d_ptr, &SensorTagBasePrivate::gyroDataAvailable, - this, &SensorTagBase::gyroDataAvailable); - connect(d_ptr, &SensorTagBasePrivate::magDataAvailable, - this, &SensorTagBase::magDataAvailable); -} - -SensorTagBase::~SensorTagBase() -{ -} - -void SensorTagBase::start() -{ -} - -void SensorTagBase::stop() -{ -} - -quint64 SensorTagBase::produceTimestamp() -{ - return QDeadlineTimer::current().deadlineNSecs() / 1000; -} - - diff --git a/src/plugins/sensors/sensortag/sensortagbase.h b/src/plugins/sensors/sensortag/sensortagbase.h deleted file mode 100644 index 5d61aacf..00000000 --- a/src/plugins/sensors/sensortag/sensortagbase.h +++ /dev/null @@ -1,252 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Lorn Potter -** Copyright (C) 2017 Canonical, Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SENSORTAGBASEPRIVATE_H -#define SENSORTAGBASEPRIVATE_H - -#include <QObject> -#include <QSensorBackend> - -#include <QBluetoothDeviceDiscoveryAgent> -#include <QBluetoothDeviceInfo> -#include <QLowEnergyController> -#include <QLowEnergyService> - -#include <QAccelerometerReading> -#include <QGyroscopeReading> -#include <QMagnetometerReading> - -class SensorTagBase; - -class SensorTagBasePrivate : public QObject -{ - Q_OBJECT - Q_DECLARE_PUBLIC(SensorTagBase) -public: - explicit SensorTagBasePrivate(QObject *parent = 0); - - QLowEnergyService *lightService = nullptr; - QLowEnergyService *temperatureService = nullptr; - QLowEnergyService *barometerService = nullptr; - QLowEnergyService *humidityService = nullptr; - QLowEnergyService *movementService = nullptr; - QLowEnergyService *acceleratorService = nullptr; - QLowEnergyService *magnetometerService = nullptr; - QLowEnergyService *gyroscopeService = nullptr; - - void enableService(const QBluetoothUuid &uuid); - void disableService(const QBluetoothUuid &uuid); - - static SensorTagBasePrivate *instance(); - -signals: - void accelDataAvailable(const QAccelerometerReading &); - void gyroDataAvailable(const QGyroscopeReading &); - void magDataAvailable(const QMagnetometerReading &); - - void luxDataAvailable(qreal); - void tempDataAvailable(qreal); - void humidityDataAvailable(qreal); - void pressureDataAvailable(qreal); - void compassDataAvailable(qreal); - -public slots: - void enableLight(bool); - void enableTemp(bool); - void enablePressure(bool); - void enableHumidity(bool); - void enableMovement(bool); - - void deviceFound(const QBluetoothDeviceInfo&); - void scanFinished(); - - void deviceScanError(QBluetoothDeviceDiscoveryAgent::Error); - void serviceDiscovered(const QBluetoothUuid &); - - void controllerError(QLowEnergyController::Error); - - void sensortagDeviceConnected(); - void deviceDisconnected(); - - void serviceStateChanged(QLowEnergyService::ServiceState s); - void updateCharacteristic(const QLowEnergyCharacteristic &c, - const QByteArray &value); - void serviceError(QLowEnergyService::ServiceError e); - void doConnections(QLowEnergyService *service); - -private slots: - void deviceSearch(); - void serviceDiscoveryFinished(); - void deviceSearchTimeout(); - -private: - - void convertLux(const QByteArray &value); - void convertTemperature(const QByteArray &value); - void convertBarometer(const QByteArray &value); - void convertHumidity(const QByteArray &value); - void convertAccelerometer(const QByteArray &value); - void convertMagnetometer(const QByteArray &value); - void convertGyroscope(const QByteArray &value); - - QBluetoothDeviceDiscoveryAgent *m_deviceDiscoveryAgent = nullptr; - QLowEnergyDescriptor m_notificationDesc; - - QLowEnergyController *m_control = nullptr; - QLowEnergyService *infoService = nullptr; - - QAccelerometerReading accelReading; - QGyroscopeReading gyroReading; - QMagnetometerReading magReading; - - bool discoveryDone = false; - QList <QBluetoothUuid> enabledServiceUuids; - SensorTagBase *q_ptr; - - bool accelerometerEnabled = false; - bool gyroscopeEnabled = false; - bool magnetometerEnabled = false; - - const QByteArray enableSensorCharacteristic = QByteArrayLiteral("\x01"); - const QByteArray disableSensorCharacteristic = QByteArrayLiteral("\x00"); - - const QByteArray enableNotificationsCharacteristic = QByteArrayLiteral("\x01\x00"); - const QByteArray disableNotificationsCharacteristic = QByteArrayLiteral("\x00\x00"); -}; - -const QBluetoothUuid TI_SENSORTAG_TEMPERATURE_SERVICE(QUuid("{f000aa00-0451-4000-b000-000000000000}")); -const QBluetoothUuid TI_SENSORTAG_IR_TEMPERATURE_DATA(QUuid("{f000aa01-0451-4000-b000-000000000000}")); -const QBluetoothUuid TI_SENSORTAG_IR_TEMPERATURE_CONTROL(QUuid("{f000aa02-0451-4000-b000-000000000000}")); -const QBluetoothUuid TI_SENSORTAG_IR_TEMPERATURE_PERIOD(QUuid("{f000aa03-0451-4000-b000-000000000000}")); - -const QBluetoothUuid TI_SENSORTAG_ACCELEROMETER_SERVICE(QUuid("{f000aa10-0451-4000-b000-000000000000}")); -const QBluetoothUuid TI_SENSORTAG_ACCELEROMETER_DATA(QUuid("{f000aa11-0451-4000-b000-000000000000}")); -const QBluetoothUuid TI_SENSORTAG_ACCELEROMETER_CONTROL(QUuid("{f000aa12-0451-4000-b000-000000000000}")); -const QBluetoothUuid TI_SENSORTAG_ACCELEROMETER_PERIOD(QUuid("{f000aa13-0451-4000-b000-000000000000}")); - -const QBluetoothUuid TI_SENSORTAG_HUMIDTIY_SERVICE(QUuid("{f000aa20-0451-4000-b000-000000000000}")); -const QBluetoothUuid TI_SENSORTAG_HUMIDTIY_DATA(QUuid("{f000aa21-0451-4000-b000-000000000000}")); -const QBluetoothUuid TI_SENSORTAG_HUMIDTIY_CONTROL(QUuid("{f000aa22-0451-4000-b000-000000000000}")); -const QBluetoothUuid TI_SENSORTAG_HUMIDTIY_PERIOD(QUuid("{f000aa23-0451-4000-b000-000000000000}")); - -const QBluetoothUuid TI_SENSORTAG_MAGNETOMETER_SERVICE(QUuid("{f000aa30-0451-4000-b000-000000000000}")); -const QBluetoothUuid TI_SENSORTAG_MAGNETOMETER_DATA(QUuid("{f000aa31-0451-4000-b000-000000000000}")); -const QBluetoothUuid TI_SENSORTAG_MAGNETOMETER_CONTROL(QUuid("{f000aa32-0451-4000-b000-000000000000}")); -const QBluetoothUuid TI_SENSORTAG_MAGNETOMETER_PERIOD(QUuid("{f000aa33-0451-4000-b000-000000000000}")); - -const QBluetoothUuid TI_SENSORTAG_BAROMETER_SERVICE(QUuid("{f000aa40-0451-4000-b000-000000000000}")); -const QBluetoothUuid TI_SENSORTAG_BAROMETER_DATA(QUuid("{f000aa41-0451-4000-b000-000000000000}")); -const QBluetoothUuid TI_SENSORTAG_BAROMETER_CONTROL(QUuid("{f000aa42-0451-4000-b000-000000000000}")); -const QBluetoothUuid TI_SENSORTAG_BAROMETER_CALIBRATION(QUuid("{f000aa43-0451-4000-b000-000000000000}")); -const QBluetoothUuid TI_SENSORTAG_BAROMETER_PERIOD(QUuid("{f000aa44-0451-4000-b000-000000000000}")); - -const QBluetoothUuid TI_SENSORTAG_GYROSCOPE_SERVICE(QUuid("{f000aa50-0451-4000-b000-000000000000}")); -const QBluetoothUuid TI_SENSORTAG_GYROSCOPE_DATA(QUuid("{f000aa51-0451-4000-b000-000000000000}")); -const QBluetoothUuid TI_SENSORTAG_GYROSCOPE_CONTROL(QUuid("{f000aa52-0451-4000-b000-000000000000}")); -const QBluetoothUuid TI_SENSORTAG_GYROSCOPE_PERIOD(QUuid("{f000aa53-0451-4000-b000-000000000000}")); - -// test service "{f000aa60-0451-4000-b000-000000000000}" - -const QBluetoothUuid TI_SENSORTAG_IO_SERVICE(QUuid("{f000aa64-0451-4000-b000-000000000000}")); -const QBluetoothUuid TI_SENSORTAG_IO_DATA(QUuid("{f000aa65-0451-4000-b000-000000000000}")); -const QBluetoothUuid TI_SENSORTAG_IO_CONTROL(QUuid("{f000aa66-0451-4000-b000-000000000000}")); - -const QBluetoothUuid TI_SENSORTAG_LIGHT_SERVICE(QUuid("{f000aa70-0451-4000-b000-000000000000}")); -const QBluetoothUuid TI_SENSORTAG_LIGHT_DATA(QUuid("{f000aa71-0451-4000-b000-000000000000}")); -const QBluetoothUuid TI_SENSORTAG_LIGHT_CONTROL(QUuid("{f000aa72-0451-4000-b000-000000000000}")); -const QBluetoothUuid TI_SENSORTAG_LIGHT_PERIOD(QUuid("{f000aa73-0451-4000-b000-000000000000}")); - -const QBluetoothUuid TI_SENSORTAG_MOVEMENT_SERVICE(QUuid("{f000aa80-0451-4000-b000-000000000000}")); -const QBluetoothUuid TI_SENSORTAG_MOVEMENT_DATA(QUuid("{f000aa81-0451-4000-b000-000000000000}")); -const QBluetoothUuid TI_SENSORTAG_MOVEMENT_CONTROL(QUuid("{f000aa82-0451-4000-b000-000000000000}")); -const QBluetoothUuid TI_SENSORTAG_MOVEMENT_PERIOD(QUuid("{f000aa83-0451-4000-b000-000000000000}")); - -// keypress "{f000ffe0-0000-1000-8000-00805f9b34fb" - -// Connection Control Service "{f000ccc0-0451-4000-b000-000000000000}" -// OAD (over air download) Service "{f000ffc0-0451-4000-b000-000000000000}" - -const QBluetoothUuid TI_SENSORTAG_INFO_SERVICE(QUuid("{0000180a-0000-1000-8000-00805f9b34fb}")); -//we might want to use these somehow -//const QBluetoothUuid TI_SENSORTAG_BATTERY_SERVICE "180F" -//const QBluetoothUuid TI_SENSORTAG_BATTERY_BATTERY_LEVEL "2A19" - -// {00001800-0000-1000-8000-00805f9b34fb} //Generic Access Service -// {00001801-0000-1000-8000-00805f9b34fb} //Generic Attribute Service - -class SensorTagBase : public QSensorBackend -{ - Q_OBJECT - Q_DECLARE_PRIVATE(SensorTagBase) -public: - SensorTagBase(QSensor *sensor); - virtual ~SensorTagBase(); - - quint64 produceTimestamp(); -signals: - void accelDataAvailable(const QAccelerometerReading &); - void luxDataAvailable(qreal); - void tempDataAvailable(qreal); - void humidityDataAvailable(qreal); - void pressureDataAvailable(qreal); - void gyroDataAvailable(const QGyroscopeReading &); - void magDataAvailable(const QMagnetometerReading &); - -protected: - void start() override; - void stop() override; - QLowEnergyService *leService; - QBluetoothUuid *serviceId; - -private: - SensorTagBasePrivate *d_ptr; - friend class SensorTagTemperatureSensor; - friend class SensorTagAls; - friend class SensorTagHumiditySensor; - friend class SensorTagLightSensor; - - friend class SensorTagPressureSensor; - friend class SensorTagAccelerometer; - - friend class SensorTagGyroscope; - friend class SensorTagMagnetometer; -}; - -#endif // SENSORTAGBASEPRIVATE_H diff --git a/src/plugins/sensors/sensortag/sensortaggyroscope.cpp b/src/plugins/sensors/sensortag/sensortaggyroscope.cpp deleted file mode 100644 index 136d1433..00000000 --- a/src/plugins/sensors/sensortag/sensortaggyroscope.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Lorn Potter -** Copyright (C) 2017 The Qt Company Ltd. -** Copyright (C) 2016 Canonical, Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "sensortaggyroscope.h" - -char const * const SensorTagGyroscope::id("sensortag.gyroscope"); -const float SensorTagGyroscope::MILLI = 0.001; - -SensorTagGyroscope::SensorTagGyroscope(QSensor *sensor) - : SensorTagBase(sensor) -{ - init(); - setDescription(QLatin1String("angular velocities around x, y, and z axis in degrees per second")); - setReading<QGyroscopeReading>(&m_reading); - sensor->setDataRate(50);//set a default rate -} - -void SensorTagGyroscope::slotDataAvailable(const QGyroscopeReading& data) -{ - m_reading.setX(data.x()); - m_reading.setY(data.y()); - m_reading.setZ(data.z()); - m_reading.setTimestamp(produceTimestamp()); - newReadingAvailable(); -} - -void SensorTagGyroscope::init() -{ - m_initDone = false; -} - -void SensorTagGyroscope::start() -{ - QObject::connect(this, &SensorTagBase::gyroDataAvailable, - this, &SensorTagGyroscope::slotDataAvailable); - d_ptr->enableService(TI_SENSORTAG_GYROSCOPE_SERVICE); -} - - -void SensorTagGyroscope::stop() -{ - QObject::disconnect(this, &SensorTagBase::gyroDataAvailable, - this, &SensorTagGyroscope::slotDataAvailable); - d_ptr->disableService(TI_SENSORTAG_GYROSCOPE_SERVICE); -} - diff --git a/src/plugins/sensors/sensortag/sensortaggyroscope.h b/src/plugins/sensors/sensortag/sensortaggyroscope.h deleted file mode 100644 index af3cfe41..00000000 --- a/src/plugins/sensors/sensortag/sensortaggyroscope.h +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Lorn Potter -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SENSORTAGGYROSCOPE_H -#define SENSORTAGGYROSCOPE_H - -#include "sensortagbase.h" -#include <QtSensors/qgyroscope.h> - -class SensorTagGyroscope : public SensorTagBase -{ - Q_OBJECT - -public: - static char const * const id; - SensorTagGyroscope(QSensor *sensor); -protected: - void start() override; - void stop() override; - virtual void init(); - -private: - QGyroscopeReading m_reading; - bool m_initDone = false; - static const float MILLI; -private slots: - void slotDataAvailable(const QGyroscopeReading &data); -}; - -#endif // SENSORTAGGYROSCOPE_H diff --git a/src/plugins/sensors/sensortag/sensortaghumiditysensor.cpp b/src/plugins/sensors/sensortag/sensortaghumiditysensor.cpp deleted file mode 100644 index 77b4585c..00000000 --- a/src/plugins/sensors/sensortag/sensortaghumiditysensor.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Lorn Potter -** Copyright (C) 2017 The Qt Company Ltd. -** Copyright (C) 2016 Canonical, Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "sensortaghumiditysensor.h" -#include "sensortagbase.h" - -char const * const SensorTagHumiditySensor::id("sensortag.humidity"); - -SensorTagHumiditySensor::SensorTagHumiditySensor(QSensor *sensor) - : SensorTagBase(sensor) -{ - setReading<QHumidityReading>(&m_reading); -} - - -void SensorTagHumiditySensor::humidityChanged(qreal value) -{ - m_reading.setRelativeHumidity(value); - - m_reading.setTimestamp(produceTimestamp()); - newReadingAvailable(); -} - -void SensorTagHumiditySensor::start() -{ - QObject::connect(this, &SensorTagBase::humidityDataAvailable, - this, &SensorTagHumiditySensor::humidityChanged); - d_ptr->enableService(TI_SENSORTAG_HUMIDTIY_SERVICE); -} - -void SensorTagHumiditySensor::stop() -{ - QObject::disconnect(this, &SensorTagBase::humidityDataAvailable, - this, &SensorTagHumiditySensor::humidityChanged); - d_ptr->disableService(TI_SENSORTAG_HUMIDTIY_SERVICE); -} - diff --git a/src/plugins/sensors/sensortag/sensortaghumiditysensor.h b/src/plugins/sensors/sensortag/sensortaghumiditysensor.h deleted file mode 100644 index 5511bf05..00000000 --- a/src/plugins/sensors/sensortag/sensortaghumiditysensor.h +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Lorn Potter -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SENSORTAGHUMIDITYSENSOR_H -#define SENSORTAGHUMIDITYSENSOR_H - -#include "sensortagbase.h" -#include <QHumidityReading> - -class SensorTagHumiditySensor : public SensorTagBase -{ - Q_OBJECT -public: - SensorTagHumiditySensor(QSensor *sensor); - static char const * const id; -protected: - void start() override; - void stop() override; -private slots: - void humidityChanged(qreal value); -private: - QHumidityReading m_reading; -}; - -#endif // SENSORTAGHUMIDITYSENSOR_H diff --git a/src/plugins/sensors/sensortag/sensortaglightsensor.cpp b/src/plugins/sensors/sensortag/sensortaglightsensor.cpp deleted file mode 100644 index 9e4038b3..00000000 --- a/src/plugins/sensors/sensortag/sensortaglightsensor.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Lorn Potter -** Copyright (C) 2017 The Qt Company Ltd. -** Copyright (C) 2016 Canonical, Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "sensortaglightsensor.h" - -char const * const SensorTagLightSensor::id("sensortag.lightsensor"); - -SensorTagLightSensor::SensorTagLightSensor(QSensor *sensor) - : SensorTagBase(sensor) -{ - init(); - setReading<QLightReading>(&m_reading); - sensor->setDataRate(10);//set a default rate -} - -void SensorTagLightSensor::slotDataAvailable(qreal data) -{ - m_reading.setLux(data); - m_reading.setTimestamp(produceTimestamp()); - newReadingAvailable(); -} - -void SensorTagLightSensor::init() -{ - m_initDone = false; -} - -void SensorTagLightSensor::start() -{ - QObject::connect(this, &SensorTagBase::luxDataAvailable, - this, &SensorTagLightSensor::slotDataAvailable); - d_ptr->enableService(TI_SENSORTAG_LIGHT_SERVICE); -} - -void SensorTagLightSensor::stop() -{ - QObject::disconnect(this, &SensorTagBase::luxDataAvailable, - this, &SensorTagLightSensor::slotDataAvailable); - d_ptr->disableService(TI_SENSORTAG_LIGHT_SERVICE); -} diff --git a/src/plugins/sensors/sensortag/sensortaglightsensor.h b/src/plugins/sensors/sensortag/sensortaglightsensor.h deleted file mode 100644 index edff8263..00000000 --- a/src/plugins/sensors/sensortag/sensortaglightsensor.h +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Lorn Potter -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SENSORTAGLIGHTSENSOR_H -#define SENSORTAGLIGHTSENSOR_H - -#include "sensortagbase.h" -#include <QtSensors/qlightsensor.h> - -class SensorTagLightSensor : public SensorTagBase -{ - Q_OBJECT - -public: - static char const * const id; - SensorTagLightSensor(QSensor *sensor); -protected: - void start() override; - void stop() override; - virtual void init(); -private: - QLightReading m_reading; - bool m_initDone = false; -private slots: - void slotDataAvailable(qreal data); -}; - -#endif -//SENSORTAGLIGHTSENSOR_H diff --git a/src/plugins/sensors/sensortag/sensortagmagnetometer.cpp b/src/plugins/sensors/sensortag/sensortagmagnetometer.cpp deleted file mode 100644 index d5d46221..00000000 --- a/src/plugins/sensors/sensortag/sensortagmagnetometer.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Lorn Potter -** Copyright (C) 2017 The Qt Company Ltd. -** Copyright (C) 2016 Canonical, Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "sensortagmagnetometer.h" - -char const * const SensorTagMagnetometer::id("sensortag.magnetometer"); -const float SensorTagMagnetometer::NANO = 0.000000001; - -SensorTagMagnetometer::SensorTagMagnetometer(QSensor *sensor) - : SensorTagBase(sensor) -{ - init(); - setDescription(QLatin1String("magnetic flux density in teslas (T)")); - setReading<QMagnetometerReading>(&m_reading); -} - -void SensorTagMagnetometer::start() -{ - QObject::connect(this, &SensorTagBase::magDataAvailable, - this, &SensorTagMagnetometer::slotDataAvailable); - d_ptr->enableService(TI_SENSORTAG_MAGNETOMETER_SERVICE); -} - -void SensorTagMagnetometer::stop() -{ - QObject::disconnect(this, &SensorTagBase::magDataAvailable, - this, &SensorTagMagnetometer::slotDataAvailable); - d_ptr->disableService(TI_SENSORTAG_MAGNETOMETER_SERVICE); -} - -void SensorTagMagnetometer::slotDataAvailable(const QMagnetometerReading &data) -{ - m_reading.setX(data.x()); - m_reading.setY(data.y()); - m_reading.setZ(data.z()); - m_reading.setTimestamp(produceTimestamp()); - newReadingAvailable(); -} - -void SensorTagMagnetometer::init() -{ - m_initDone = false; -} diff --git a/src/plugins/sensors/sensortag/sensortagmagnetometer.h b/src/plugins/sensors/sensortag/sensortagmagnetometer.h deleted file mode 100644 index 424727a2..00000000 --- a/src/plugins/sensors/sensortag/sensortagmagnetometer.h +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Lorn Potter -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SENSORTAGMAGNETOMETER_H -#define SENSORTAGMAGNETOMETER_H - -#include "sensortagbase.h" -#include <QtSensors/qmagnetometer.h> - -class SensorTagMagnetometer : public SensorTagBase -{ - Q_OBJECT - -public: - static char const * const id; - SensorTagMagnetometer(QSensor *sensor); -protected: - void start() override; - void stop() override; - virtual void init(); - -private: - static const float NANO; - QMagnetometerReading m_reading; - bool m_initDone = false; - -private slots: - void slotDataAvailable(const QMagnetometerReading &data); -}; - -#endif -//SENSORTAGMAGNETOMETER_H diff --git a/src/plugins/sensors/sensortag/sensortagpressuresensor.cpp b/src/plugins/sensors/sensortag/sensortagpressuresensor.cpp deleted file mode 100644 index 7d2c8f93..00000000 --- a/src/plugins/sensors/sensortag/sensortagpressuresensor.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Lorn Potter -** Copyright (C) 2017 The Qt Company Ltd. -** Copyright (C) 2016 Canonical, Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "sensortagpressuresensor.h" -#include "sensortagbase.h" - -char const * const SensorTagPressureSensor::id("sensortag.pressure"); - -SensorTagPressureSensor::SensorTagPressureSensor(QSensor *sensor) - : SensorTagBase(sensor) -{ - setReading<QPressureReading>(&m_reading); -} - -void SensorTagPressureSensor::pressureChanged(qreal value) -{ - m_reading.setPressure(value); - m_reading.setTimestamp(produceTimestamp()); - newReadingAvailable(); -} - -void SensorTagPressureSensor::start() -{ - QObject::connect(this, &SensorTagBase::pressureDataAvailable, - this, &SensorTagPressureSensor::pressureChanged); - d_ptr->enableService(TI_SENSORTAG_BAROMETER_SERVICE); -} - -void SensorTagPressureSensor::stop() -{ - QObject::disconnect(this, &SensorTagBase::pressureDataAvailable, - this, &SensorTagPressureSensor::pressureChanged); - d_ptr->disableService(TI_SENSORTAG_BAROMETER_SERVICE); -} - diff --git a/src/plugins/sensors/sensortag/sensortagpressuresensor.h b/src/plugins/sensors/sensortag/sensortagpressuresensor.h deleted file mode 100644 index 5f8b0cfd..00000000 --- a/src/plugins/sensors/sensortag/sensortagpressuresensor.h +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Lorn Potter -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SENSORTAGPRESSURESENSOR_H -#define SENSORTAGPRESSURESENSOR_H - -#include "sensortagbase.h" -#include <QObject> -#include <QPressureReading> - -class SensorTagPressureSensor : public SensorTagBase -{ - Q_OBJECT -public: - SensorTagPressureSensor(QSensor *sensor); - static char const * const id; - -protected: - void start() override; - void stop() override; - -private slots: - void pressureChanged(qreal value); -private: - QPressureReading m_reading; -}; - -#endif // SENSORTAGPRESSURESENSOR_H diff --git a/src/plugins/sensors/sensortag/sensortagtemperaturesensor.cpp b/src/plugins/sensors/sensortag/sensortagtemperaturesensor.cpp deleted file mode 100644 index ab8c4a2f..00000000 --- a/src/plugins/sensors/sensortag/sensortagtemperaturesensor.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Lorn Potter -** Copyright (C) 2017 The Qt Company Ltd. -** Copyright (C) 2016 Canonical, Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "sensortagtemperaturesensor.h" -#include "sensortagbase.h" - -char const * const SensorTagTemperatureSensor::id("sensortag.temperature"); - -SensorTagTemperatureSensor::SensorTagTemperatureSensor(QSensor *sensor) - : SensorTagBase(sensor) -{ - setReading<QAmbientTemperatureReading>(&m_reading); -} - -void SensorTagTemperatureSensor::temperatureChanged(qreal value) -{ - m_reading.setTemperature(value); - m_reading.setTimestamp(produceTimestamp()); - newReadingAvailable(); -} - -void SensorTagTemperatureSensor::start() -{ - QObject::connect(this, &SensorTagBase::tempDataAvailable, - this, &SensorTagTemperatureSensor::temperatureChanged); - d_ptr->enableService(TI_SENSORTAG_TEMPERATURE_SERVICE); -} - -void SensorTagTemperatureSensor::stop() -{ - QObject::disconnect(this, &SensorTagBase::tempDataAvailable, - this, &SensorTagTemperatureSensor::temperatureChanged); - d_ptr->disableService(TI_SENSORTAG_TEMPERATURE_SERVICE); -} - diff --git a/src/plugins/sensors/sensortag/sensortagtemperaturesensor.h b/src/plugins/sensors/sensortag/sensortagtemperaturesensor.h deleted file mode 100644 index c4c45d58..00000000 --- a/src/plugins/sensors/sensortag/sensortagtemperaturesensor.h +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Lorn Potter -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SENSORTAGTEMPERATURESENSOR_H -#define SENSORTAGTEMPERATURESENSOR_H - -#include "sensortagbase.h" -#include <QAmbientTemperatureReading> - -class SensorTagTemperatureSensor : public SensorTagBase -{ - Q_OBJECT -public: - SensorTagTemperatureSensor(QSensor *sensor); - static char const * const id; -protected: - void start() override; - void stop() override; -private slots: - void temperatureChanged(qreal value); -private: - QAmbientTemperatureReading m_reading; -}; - -#endif // SENSORTAGTEMPERATURESENSOR_H diff --git a/src/plugins/sensors/simulator/main.cpp b/src/plugins/sensors/simulator/main.cpp deleted file mode 100644 index 167711a9..00000000 --- a/src/plugins/sensors/simulator/main.cpp +++ /dev/null @@ -1,143 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "simulatoraccelerometer.h" -#include "simulatorambientlightsensor.h" -#include "simulatorlightsensor.h" -#include "simulatorcompass.h" -#include "simulatorproximitysensor.h" -#include "simulatorirproximitysensor.h" -#include "simulatormagnetometer.h" -#include <QSensorPluginInterface> -#include <QSensorBackend> -#include <QSensorManager> - -class SimulatorSensorPlugin : 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: - SimulatorSensorPlugin() - { - SensorsConnection *connection = SensorsConnection::instance(); - if (!connection) return; // hardly likely but just in case... - connect(connection, SIGNAL(setAvailableFeatures(quint32)), this, SLOT(setAvailableFeatures(quint32))); - } - - void registerSensors() override - { - QSensorManager::registerBackend(QAccelerometer::type, SimulatorAccelerometer::id, this); - QSensorManager::registerBackend(QAmbientLightSensor::type, SimulatorAmbientLightSensor::id, this); - QSensorManager::registerBackend(QLightSensor::type, SimulatorLightSensor::id, this); - QSensorManager::registerBackend(QCompass::type, SimulatorCompass::id, this); - QSensorManager::registerBackend(QProximitySensor::type, SimulatorProximitySensor::id, this); - QSensorManager::registerBackend(QIRProximitySensor::type, SimulatorIRProximitySensor::id, this); - QSensorManager::registerBackend(QMagnetometer::type, SimulatorMagnetometer::id, this); - } - - QSensorBackend *createBackend(QSensor *sensor) override - { - if (sensor->identifier() == SimulatorAccelerometer::id) { - return new SimulatorAccelerometer(sensor); - } - - if (sensor->identifier() == SimulatorAmbientLightSensor::id) { - return new SimulatorAmbientLightSensor(sensor); - } - - if (sensor->identifier() == SimulatorLightSensor::id) { - return new SimulatorLightSensor(sensor); - } - - if (sensor->identifier() == SimulatorProximitySensor::id) { - return new SimulatorProximitySensor(sensor); - } - - if (sensor->identifier() == SimulatorIRProximitySensor::id) { - return new SimulatorIRProximitySensor(sensor); - } - - if (sensor->identifier() == SimulatorCompass::id) { - return new SimulatorCompass(sensor); - } - - if (sensor->identifier() == SimulatorMagnetometer::id) { - return new SimulatorMagnetometer(sensor); - } - - return 0; - } - - // Copied from the emulator codebase - enum Features { - Accelerometer = 0x01, - Magnetometer = 0x02, - Compass = 0x04, - Infraredsensor = 0x08, - Lightsensor = 0x10 - }; - -public slots: - void setAvailableFeatures(quint32 features) - { - check(features&Accelerometer, QAccelerometer::type, SimulatorAccelerometer::id); - check(features&Lightsensor, QLightSensor::type, SimulatorLightSensor::id); - check(features&Lightsensor, QAmbientLightSensor::type, SimulatorAmbientLightSensor::id); - check(features&Magnetometer, QMagnetometer::type, SimulatorMagnetometer::id); - check(features&Compass, QCompass::type, SimulatorCompass::id); - check(features&Infraredsensor, QIRProximitySensor::type, SimulatorIRProximitySensor::id); - check(features&Infraredsensor, QProximitySensor::type, SimulatorProximitySensor::id); - } - -private: - void check(bool test, const QByteArray &type, const QByteArray &id) - { - if (test) { - if (!QSensorManager::isBackendRegistered(type, id)) - QSensorManager::registerBackend(type, id, this); - } else { - if (QSensorManager::isBackendRegistered(type, id)) - QSensorManager::unregisterBackend(type, id); - } - } -}; - -#include "main.moc" - diff --git a/src/plugins/sensors/simulator/plugin.json b/src/plugins/sensors/simulator/plugin.json deleted file mode 100644 index 77f47afe..00000000 --- a/src/plugins/sensors/simulator/plugin.json +++ /dev/null @@ -1 +0,0 @@ -{ "Keys": [ "simulator" ] } diff --git a/src/plugins/sensors/simulator/qsensordata_simulator.cpp b/src/plugins/sensors/simulator/qsensordata_simulator.cpp deleted file mode 100644 index 3e590d66..00000000 --- a/src/plugins/sensors/simulator/qsensordata_simulator.cpp +++ /dev/null @@ -1,143 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qsensordata_simulator_p.h" - -#include <QtCore/QDataStream> - -namespace QtMobility { - -void qt_registerSensorTypes() -{ - qRegisterMetaTypeStreamOperators<QAmbientLightReadingData>("QtMobility::QAmbientLightReadingData"); - qRegisterMetaTypeStreamOperators<QLightReadingData>("QtMobility::QLightReadingData"); - qRegisterMetaTypeStreamOperators<QAccelerometerReadingData>("QtMobility::QAccelerometerReadingData"); - qRegisterMetaTypeStreamOperators<QCompassReadingData>("QtMobility::QCompassReadingData"); - qRegisterMetaTypeStreamOperators<QProximityReadingData>("QtMobility::QProximityReadingData"); - qRegisterMetaTypeStreamOperators<QIRProximityReadingData>("QtMobility::QIRProximityReadingData"); - qRegisterMetaTypeStreamOperators<QMagnetometerReadingData>("QtMobility::QMagnetometerReadingData"); -} - -QDataStream &operator<<(QDataStream &out, const QAmbientLightReadingData &s) -{ - out << static_cast<qint32>(s.lightLevel) << s.timestamp; - return out; -} - -QDataStream &operator>>(QDataStream &in, QAmbientLightReadingData &s) -{ - qint32 lightLevel; - in >> lightLevel >> s.timestamp; - s.lightLevel = static_cast<SimulatorLightLevel>(lightLevel); - return in; -} - -QDataStream &operator<<(QDataStream &out, const QLightReadingData &s) -{ - out << s.lux << s.timestamp; - return out; -} - -QDataStream &operator>>(QDataStream &in, QLightReadingData &s) -{ - in >> s.lux >> s.timestamp; - return in; -} - -QDataStream &operator<<(QDataStream &out, const QAccelerometerReadingData &s) -{ - out << s.x << s.y << s.z << s.timestamp; - return out; -} - -QDataStream &operator>>(QDataStream &in, QAccelerometerReadingData &s) -{ - in >> s.x >> s.y >> s.z >> s.timestamp; - return in; -} - -QDataStream &operator<<(QDataStream &out, const QCompassReadingData &s) -{ - out << s.azimuth << s.calibrationLevel << s.timestamp; - return out; -} - -QDataStream &operator>>(QDataStream &in, QCompassReadingData &s) -{ - in >> s.azimuth >> s.calibrationLevel >> s.timestamp; - return in; -} - -QDataStream &operator<<(QDataStream &out, const QProximityReadingData &s) -{ - out << s.close << s.timestamp; - return out; -} - -QDataStream &operator>>(QDataStream &in, QProximityReadingData &s) -{ - in >> s.close >> s.timestamp; - return in; -} - -QDataStream &operator<<(QDataStream &out, const QIRProximityReadingData &s) -{ - out << s.irProximity << s.timestamp; - return out; -} - -QDataStream &operator>>(QDataStream &in, QIRProximityReadingData &s) -{ - in >> s.irProximity >> s.timestamp; - return in; -} - -QDataStream &operator<<(QDataStream &out, const QMagnetometerReadingData &s) -{ - out << s.x << s.y << s.z << s.calibrationLevel << s.timestamp; - return out; -} - -QDataStream &operator>>(QDataStream &in, QMagnetometerReadingData &s) -{ - in >> s.x >> s.y >> s.z >> s.calibrationLevel >> s.timestamp; - return in; -} - -} // namespace diff --git a/src/plugins/sensors/simulator/qsensordata_simulator_p.h b/src/plugins/sensors/simulator/qsensordata_simulator_p.h deleted file mode 100644 index 410078d8..00000000 --- a/src/plugins/sensors/simulator/qsensordata_simulator_p.h +++ /dev/null @@ -1,128 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QSENSORDATA_SIMULATOR_P_H -#define QSENSORDATA_SIMULATOR_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QtCore/QMetaType> -#include <QtCore/QDateTime> - -namespace QtMobility { - -enum SimulatorLightLevel { - Undefined = 0, - Dark, - Twilight, - Light, - Bright, - Sunny -}; - -struct QAmbientLightReadingData -{ - SimulatorLightLevel lightLevel; - QDateTime timestamp; -}; - -struct QLightReadingData -{ - double lux; - QDateTime timestamp; -}; - -struct QAccelerometerReadingData -{ - double x; - double y; - double z; - QDateTime timestamp; -}; - -struct QMagnetometerReadingData -{ - double x; - double y; - double z; - double calibrationLevel; - QDateTime timestamp; -}; - -struct QCompassReadingData -{ - double azimuth; - double calibrationLevel; - QDateTime timestamp; -}; - -struct QProximityReadingData -{ - bool close; - QDateTime timestamp; -}; - -struct QIRProximityReadingData -{ - double irProximity; - QDateTime timestamp; -}; - -void qt_registerSensorTypes(); - -} - -Q_DECLARE_METATYPE(QtMobility::QAmbientLightReadingData) -Q_DECLARE_METATYPE(QtMobility::QLightReadingData) -Q_DECLARE_METATYPE(QtMobility::QAccelerometerReadingData) -Q_DECLARE_METATYPE(QtMobility::QMagnetometerReadingData) -Q_DECLARE_METATYPE(QtMobility::QCompassReadingData) -Q_DECLARE_METATYPE(QtMobility::QProximityReadingData) -Q_DECLARE_METATYPE(QtMobility::QIRProximityReadingData) - -#endif // QSENSORDATA_SIMULATOR_P_H diff --git a/src/plugins/sensors/simulator/simulator.pro b/src/plugins/sensors/simulator/simulator.pro deleted file mode 100644 index ac8ea506..00000000 --- a/src/plugins/sensors/simulator/simulator.pro +++ /dev/null @@ -1,32 +0,0 @@ -TARGET = qtsensors_simulator - -QT=core gui network sensors simulator - -HEADERS += \ - simulatorcommon.h\ - simulatoraccelerometer.h\ - simulatorambientlightsensor.h\ - simulatorlightsensor.h\ - simulatorcompass.h\ - simulatorproximitysensor.h\ - simulatorirproximitysensor.h\ - simulatormagnetometer.h\ - qsensordata_simulator_p.h - -SOURCES += \ - simulatorcommon.cpp\ - simulatoraccelerometer.cpp\ - simulatorambientlightsensor.cpp\ - simulatorlightsensor.cpp\ - simulatorcompass.cpp\ - simulatorproximitysensor.cpp\ - simulatorirproximitysensor.cpp\ - simulatormagnetometer.cpp\ - qsensordata_simulator.cpp\ - main.cpp - -OTHER_FILES = plugin.json - -PLUGIN_TYPE = sensors -PLUGIN_CLASS_NAME = SimulatorSensorPlugin -load(qt_plugin) diff --git a/src/plugins/sensors/simulator/simulatoraccelerometer.cpp b/src/plugins/sensors/simulator/simulatoraccelerometer.cpp deleted file mode 100644 index 280fc7ee..00000000 --- a/src/plugins/sensors/simulator/simulatoraccelerometer.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "simulatoraccelerometer.h" -#include <QDebug> -#include <QtGlobal> - -const char *SimulatorAccelerometer::id("Simulator.Accelerometer"); - -SimulatorAccelerometer::SimulatorAccelerometer(QSensor *sensor) - : SimulatorCommon(sensor) -{ - setReading<QAccelerometerReading>(&m_reading); -} - -void SimulatorAccelerometer::poll() -{ - QtMobility::QAccelerometerReadingData data = SensorsConnection::instance()->qtAccelerometerData; - quint64 newTimestamp; - if (!data.timestamp.isValid()) - newTimestamp = static_cast<quint64>(QDateTime::currentMSecsSinceEpoch()) / 1000; - else - newTimestamp = static_cast<quint64>(data.timestamp.toSecsSinceEpoch()); - if (m_reading.x() != data.x - || m_reading.y() != data.y - || m_reading.z() != data.z) { - m_reading.setTimestamp(newTimestamp); - m_reading.setX(data.x); - m_reading.setY(data.y); - m_reading.setZ(data.z); - - newReadingAvailable(); - } -} - diff --git a/src/plugins/sensors/simulator/simulatoraccelerometer.h b/src/plugins/sensors/simulator/simulatoraccelerometer.h deleted file mode 100644 index a4205867..00000000 --- a/src/plugins/sensors/simulator/simulatoraccelerometer.h +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SIMULATORACCELEROMETER_H -#define SIMULATORACCELEROMETER_H - -#include "simulatorcommon.h" -#include <qaccelerometer.h> - -class SimulatorAccelerometer : public SimulatorCommon -{ -public: - static const char *id; - - SimulatorAccelerometer(QSensor *sensor); - - void poll() override; -private: - QAccelerometerReading m_reading; -}; - -#endif - diff --git a/src/plugins/sensors/simulator/simulatorambientlightsensor.cpp b/src/plugins/sensors/simulator/simulatorambientlightsensor.cpp deleted file mode 100644 index 5d84b36c..00000000 --- a/src/plugins/sensors/simulator/simulatorambientlightsensor.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "simulatorambientlightsensor.h" -#include <QDebug> -#include <QtGlobal> - -const char *SimulatorAmbientLightSensor::id("Simulator.AmbientLightSensor"); - -SimulatorAmbientLightSensor::SimulatorAmbientLightSensor(QSensor *sensor) - : SimulatorCommon(sensor) -{ - setReading<QAmbientLightReading>(&m_reading); -} - -void SimulatorAmbientLightSensor::poll() -{ - QtMobility::QAmbientLightReadingData data = SensorsConnection::instance()->qtAmbientLightData; - QAmbientLightReading::LightLevel convertedLightLevel; - switch (data.lightLevel) { - case QtMobility::Dark: - convertedLightLevel = QAmbientLightReading::Dark; - break; - case QtMobility::Twilight: - convertedLightLevel = QAmbientLightReading::Twilight; - break; - case QtMobility::Light: - convertedLightLevel = QAmbientLightReading::Light; - break; - case QtMobility::Bright: - convertedLightLevel = QAmbientLightReading::Bright; - break; - case QtMobility::Sunny: - convertedLightLevel = QAmbientLightReading::Sunny; - break; - default: - convertedLightLevel = QAmbientLightReading::Undefined; - break; - } - - quint64 newTimestamp; - if (!data.timestamp.isValid()) - newTimestamp = static_cast<quint64>(QDateTime::currentMSecsSinceEpoch()) / 1000; - else - newTimestamp = static_cast<quint64>(data.timestamp.toSecsSinceEpoch()); - if (m_reading.lightLevel() != convertedLightLevel) { - m_reading.setTimestamp(newTimestamp); - m_reading.setLightLevel(convertedLightLevel); - - newReadingAvailable(); - } -} - diff --git a/src/plugins/sensors/simulator/simulatorambientlightsensor.h b/src/plugins/sensors/simulator/simulatorambientlightsensor.h deleted file mode 100644 index 0aadffe6..00000000 --- a/src/plugins/sensors/simulator/simulatorambientlightsensor.h +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SIMULATORAMBIENTLIGHTSENSOR_H -#define SIMULATORAMBIENTLIGHTSENSOR_H - -#include "simulatorcommon.h" -#include <qambientlightsensor.h> - -class SimulatorAmbientLightSensor : public SimulatorCommon -{ -public: - static const char *id; - - SimulatorAmbientLightSensor(QSensor *sensor); - - void poll() override; -private: - QAmbientLightReading m_reading; -}; - -#endif - diff --git a/src/plugins/sensors/simulator/simulatorcommon.cpp b/src/plugins/sensors/simulator/simulatorcommon.cpp deleted file mode 100644 index a1693364..00000000 --- a/src/plugins/sensors/simulator/simulatorcommon.cpp +++ /dev/null @@ -1,252 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "simulatorcommon.h" -#include "qsensordata_simulator_p.h" -#include <QtSimulator/QtSimulator> -#include <QDebug> -#include <QThread> - -using namespace Simulator; - -Q_GLOBAL_STATIC(SensorsConnection, sensorsConnection) - -class SimulatorAsyncConnection: public QThread -{ - Q_OBJECT -public: - SimulatorAsyncConnection() - : QThread() - { - QtMobility::qt_registerSensorTypes(); - - moveToThread(this); - connect(this, SIGNAL(queueConnectToServer()), - this, SLOT(doConnectToServer()), - Qt::QueuedConnection); - - start(); - } - - ~SimulatorAsyncConnection() - { - quit(); - wait(); - } - - void connectToServer() - { - emit queueConnectToServer(); - } - -signals: - void queueConnectToServer(); - - void initialSensorsDataSent(); - void connectionFailed(); - void setAvailableFeatures(quint32 features); - void setAmbientLightData(const QtMobility::QAmbientLightReadingData &); - void setLightData(const QtMobility::QLightReadingData &); - void setAccelerometerData(const QtMobility::QAccelerometerReadingData &); - void setMagnetometerData(const QtMobility::QMagnetometerReadingData &); - void setCompassData(const QtMobility::QCompassReadingData &); - void setProximityData(const QtMobility::QProximityReadingData &); - void setIRProximityData(const QtMobility::QIRProximityReadingData &); - -private slots: - void doConnectToServer() - { - mConnection.reset(new Connection(Connection::Client, "QtSimulator_Mobility_ServerName1.3.0.0", - 0xbeef+1, Version(1,0,0,0), this)); - mWorker.reset(mConnection->connectToServer(Connection::simulatorHostName(true), 0xbeef+1)); - if (!mWorker) { - qWarning("QtSensors simulator backend could not connect to the simulator!"); - emit connectionFailed(); - return; - } - mWorker->addReceiver(this); - mWorker->call("setRequestsSensors"); - } - -private: - QScopedPointer<Simulator::Connection> mConnection; - QScopedPointer<Simulator::ConnectionWorker> mWorker; -}; - -SensorsConnection::SensorsConnection(QObject *parent) - : QObject(parent) - , mInitialDataSent(false) - , mConnectionFailed(false) -{ - mConnection = new SimulatorAsyncConnection(); - - connect(mConnection, SIGNAL(initialSensorsDataSent()), - this, SLOT(initialSensorsDataSent())); - connect(mConnection, SIGNAL(connectionFailed()), - this, SLOT(slotConnectionFailed())); - connect(mConnection, SIGNAL(setAvailableFeatures(quint32)), - this, SIGNAL(setAvailableFeatures(quint32))); - connect(mConnection, SIGNAL(setAmbientLightData(QtMobility::QAmbientLightReadingData)), - this, SLOT(setAmbientLightData(QtMobility::QAmbientLightReadingData))); - connect(mConnection, SIGNAL(setLightData(QtMobility::QLightReadingData)), - this, SLOT(setLightData(QtMobility::QLightReadingData))); - connect(mConnection, SIGNAL(setAccelerometerData(QtMobility::QAccelerometerReadingData)), - this, SLOT(setAccelerometerData(QtMobility::QAccelerometerReadingData))); - connect(mConnection, SIGNAL(setMagnetometerData(QtMobility::QMagnetometerReadingData)), - this, SLOT(setMagnetometerData(QtMobility::QMagnetometerReadingData))); - connect(mConnection, SIGNAL(setCompassData(QtMobility::QCompassReadingData)), - this, SLOT(setCompassData(QtMobility::QCompassReadingData))); - connect(mConnection, SIGNAL(setProximityData(QtMobility::QProximityReadingData)), - this, SLOT(setProximityData(QtMobility::QProximityReadingData))); - connect(mConnection, SIGNAL(setIRProximityData(QtMobility::QIRProximityReadingData)), - this, SLOT(setIRProximityData(QtMobility::QIRProximityReadingData))); - - mConnection->connectToServer(); -} - -SensorsConnection::~SensorsConnection() -{ - delete mConnection; -} - -SensorsConnection *SensorsConnection::instance() -{ - SensorsConnection *connection = sensorsConnection(); - // It's safe to return 0 because this is checked when used - //if (!connection) qFatal("Cannot return from SensorsConnection::instance because sensorsConnection() returned 0"); - return connection; -} - -void SensorsConnection::setAmbientLightData(const QtMobility::QAmbientLightReadingData &data) -{ - qtAmbientLightData = data; -} - -void SensorsConnection::setLightData(const QtMobility::QLightReadingData &data) -{ - qtLightData = data; -} - -void SensorsConnection::setAccelerometerData(const QtMobility::QAccelerometerReadingData &data) -{ - qtAccelerometerData = data; -} - -void SensorsConnection::setMagnetometerData(const QtMobility::QMagnetometerReadingData &data) -{ - qtMagnetometerData = data; -} - -void SensorsConnection::setCompassData(const QtMobility::QCompassReadingData &data) -{ - qtCompassData = data; -} - -void SensorsConnection::setProximityData(const QtMobility::QProximityReadingData &data) -{ - qtProximityData = data; -} - -void SensorsConnection::setIRProximityData(const QtMobility::QIRProximityReadingData &data) -{ - qtIRProximityData = data; -} - -void SensorsConnection::initialSensorsDataSent() -{ - mInitialDataSent = true; -} - -void SensorsConnection::slotConnectionFailed() -{ - mInitialDataSent = false; - mConnectionFailed = true; -} - -SimulatorCommon::SimulatorCommon(QSensor *sensor) - : QSensorBackend(sensor) - , m_timerid(0) -{ - addDataRate(1, 100); - sensor->setDataRate(20); - (void)SensorsConnection::instance(); // Ensure this exists -} - -void SimulatorCommon::start() -{ - SensorsConnection *connection = SensorsConnection::instance(); - if (!connection) { - sensorStopped(); - return; - } - - if (m_timerid) - return; - - int rate = sensor()->dataRate(); - if (rate == 0) - rate = 20; - int interval = 1000 / rate; - if (interval < 0) - interval = 1000; - - if (interval) - m_timerid = startTimer(interval); -} - -void SimulatorCommon::stop() -{ - if (m_timerid) { - killTimer(m_timerid); - m_timerid = 0; - } -} - -void SimulatorCommon::timerEvent(QTimerEvent * /*event*/) -{ - SensorsConnection *connection = SensorsConnection::instance(); - if (!connection || connection->connectionFailed()) { - stop(); - sensorStopped(); - } - if (!connection->safe()) return; // wait until it's safe to read the data - poll(); -} - -#include "simulatorcommon.moc" diff --git a/src/plugins/sensors/simulator/simulatorcommon.h b/src/plugins/sensors/simulator/simulatorcommon.h deleted file mode 100644 index e47f24d0..00000000 --- a/src/plugins/sensors/simulator/simulatorcommon.h +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SIMULATORCOMMON_H -#define SIMULATORCOMMON_H - -#include <qsensorbackend.h> -#include "qsensordata_simulator_p.h" - -class QTimer; - -class SimulatorAsyncConnection; - -class SensorsConnection : public QObject -{ - Q_OBJECT -public: - explicit SensorsConnection(QObject *parent = 0); - virtual ~SensorsConnection(); - - static SensorsConnection *instance(); - bool safe() const { return mInitialDataSent; } - bool connectionFailed() const { return mConnectionFailed; } - -signals: - void setAvailableFeatures(quint32 features); - -public slots: - void setAmbientLightData(const QtMobility::QAmbientLightReadingData &); - void setLightData(const QtMobility::QLightReadingData &); - void setAccelerometerData(const QtMobility::QAccelerometerReadingData &); - void setMagnetometerData(const QtMobility::QMagnetometerReadingData &); - void setCompassData(const QtMobility::QCompassReadingData &); - void setProximityData(const QtMobility::QProximityReadingData &); - void setIRProximityData(const QtMobility::QIRProximityReadingData &); - void initialSensorsDataSent(); - void slotConnectionFailed(); - -private: - SimulatorAsyncConnection *mConnection; - bool mInitialDataSent; - bool mConnectionFailed; - -public: - QtMobility::QAmbientLightReadingData qtAmbientLightData; - QtMobility::QLightReadingData qtLightData; - QtMobility::QAccelerometerReadingData qtAccelerometerData; - QtMobility::QMagnetometerReadingData qtMagnetometerData; - QtMobility::QCompassReadingData qtCompassData; - QtMobility::QProximityReadingData qtProximityData; - QtMobility::QIRProximityReadingData qtIRProximityData; -}; - -class SimulatorCommon : public QSensorBackend -{ -public: - SimulatorCommon(QSensor *sensor); - - void start() override; - void stop() override; - virtual void poll() = 0; - void timerEvent(QTimerEvent * /*event*/) override; - -private: - int m_timerid; -}; - -#endif - diff --git a/src/plugins/sensors/simulator/simulatorcompass.cpp b/src/plugins/sensors/simulator/simulatorcompass.cpp deleted file mode 100644 index e9d0f1d7..00000000 --- a/src/plugins/sensors/simulator/simulatorcompass.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "simulatorcompass.h" -#include <QDebug> -#include <QtGlobal> - -const char *SimulatorCompass::id("Simulator.Compass"); - -SimulatorCompass::SimulatorCompass(QSensor *sensor) - : SimulatorCommon(sensor) -{ - setReading<QCompassReading>(&m_reading); -} - -void SimulatorCompass::poll() -{ - QtMobility::QCompassReadingData data = SensorsConnection::instance()->qtCompassData; - quint64 newTimestamp; - if (!data.timestamp.isValid()) - newTimestamp = static_cast<quint64>(QDateTime::currentMSecsSinceEpoch()) / 1000; - else - newTimestamp = static_cast<quint64>(data.timestamp.toSecsSinceEpoch()); - if (m_reading.azimuth() != data.azimuth - || m_reading.calibrationLevel() != data.calibrationLevel) { - m_reading.setTimestamp(newTimestamp); - m_reading.setAzimuth(data.azimuth); - m_reading.setCalibrationLevel(data.calibrationLevel); - - newReadingAvailable(); - } -} - diff --git a/src/plugins/sensors/simulator/simulatorcompass.h b/src/plugins/sensors/simulator/simulatorcompass.h deleted file mode 100644 index 69162c69..00000000 --- a/src/plugins/sensors/simulator/simulatorcompass.h +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SIMULATORCOMPASS_H -#define SIMULATORCOMPASS_H - -#include "simulatorcommon.h" -#include <qcompass.h> - -class SimulatorCompass : public SimulatorCommon -{ -public: - static const char *id; - - SimulatorCompass(QSensor *sensor); - - void poll() override; -private: - QCompassReading m_reading; -}; - -#endif - diff --git a/src/plugins/sensors/simulator/simulatorirproximitysensor.cpp b/src/plugins/sensors/simulator/simulatorirproximitysensor.cpp deleted file mode 100644 index d041a86d..00000000 --- a/src/plugins/sensors/simulator/simulatorirproximitysensor.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "simulatorirproximitysensor.h" -#include <QDebug> -#include <QtGlobal> - -const char *SimulatorIRProximitySensor::id("Simulator.IRProximitySensor"); - -SimulatorIRProximitySensor::SimulatorIRProximitySensor(QSensor *sensor) - : SimulatorCommon(sensor) -{ - setReading<QIRProximityReading>(&m_reading); -} - -void SimulatorIRProximitySensor::poll() -{ - QtMobility::QIRProximityReadingData data = SensorsConnection::instance()->qtIRProximityData; - quint64 newTimestamp; - if (!data.timestamp.isValid()) - newTimestamp = static_cast<quint64>(QDateTime::currentMSecsSinceEpoch()) / 1000; - else - newTimestamp = static_cast<quint64>(data.timestamp.toSecsSinceEpoch()); - if (m_reading.reflectance() != data.irProximity) { - m_reading.setTimestamp(newTimestamp); - m_reading.setReflectance(data.irProximity); - - newReadingAvailable(); - } -} - diff --git a/src/plugins/sensors/simulator/simulatorirproximitysensor.h b/src/plugins/sensors/simulator/simulatorirproximitysensor.h deleted file mode 100644 index db20968b..00000000 --- a/src/plugins/sensors/simulator/simulatorirproximitysensor.h +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SIMULATORIRPROXIMITYSENSOR_H -#define SIMULATORIRPROXIMITYSENSOR_H - -#include "simulatorcommon.h" -#include <qirproximitysensor.h> - -class SimulatorIRProximitySensor : public SimulatorCommon -{ -public: - static const char *id; - - SimulatorIRProximitySensor(QSensor *sensor); - - void poll() override; -private: - QIRProximityReading m_reading; -}; - -#endif - diff --git a/src/plugins/sensors/simulator/simulatorlightsensor.cpp b/src/plugins/sensors/simulator/simulatorlightsensor.cpp deleted file mode 100644 index bb4dd94d..00000000 --- a/src/plugins/sensors/simulator/simulatorlightsensor.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "simulatorlightsensor.h" -#include <QDebug> -#include <QtGlobal> - -const char *SimulatorLightSensor::id("Simulator.LightSensor"); - -SimulatorLightSensor::SimulatorLightSensor(QSensor *sensor) - : SimulatorCommon(sensor) -{ - setReading<QLightReading>(&m_reading); -} - -void SimulatorLightSensor::poll() -{ - QtMobility::QLightReadingData data = SensorsConnection::instance()->qtLightData; - quint64 newTimestamp; - if (!data.timestamp.isValid()) - newTimestamp = static_cast<quint64>(QDateTime::currentMSecsSinceEpoch()) / 1000; - else - newTimestamp = static_cast<quint64>(data.timestamp.toSecsSinceEpoch()); - if (m_reading.lux() != data.lux) { - m_reading.setTimestamp(newTimestamp); - m_reading.setLux(data.lux); - - newReadingAvailable(); - } -} - diff --git a/src/plugins/sensors/simulator/simulatorlightsensor.h b/src/plugins/sensors/simulator/simulatorlightsensor.h deleted file mode 100644 index 3af3a526..00000000 --- a/src/plugins/sensors/simulator/simulatorlightsensor.h +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SIMULATORLIGHTSENSOR_H -#define SIMULATORLIGHTSENSOR_H - -#include "simulatorcommon.h" -#include <qlightsensor.h> - -class SimulatorLightSensor : public SimulatorCommon -{ -public: - static const char *id; - - SimulatorLightSensor(QSensor *sensor); - - void poll() override; -private: - QLightReading m_reading; -}; - -#endif - diff --git a/src/plugins/sensors/simulator/simulatormagnetometer.cpp b/src/plugins/sensors/simulator/simulatormagnetometer.cpp deleted file mode 100644 index b54525ab..00000000 --- a/src/plugins/sensors/simulator/simulatormagnetometer.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "simulatormagnetometer.h" -#include <QDebug> -#include <QtGlobal> - -const char *SimulatorMagnetometer::id("Simulator.Magnetometer"); - -SimulatorMagnetometer::SimulatorMagnetometer(QSensor *sensor) - : SimulatorCommon(sensor) -{ - setReading<QMagnetometerReading>(&m_reading); -} - -void SimulatorMagnetometer::poll() -{ - QtMobility::QMagnetometerReadingData data = SensorsConnection::instance()->qtMagnetometerData; - quint64 newTimestamp; - if (!data.timestamp.isValid()) - newTimestamp = static_cast<quint64>(QDateTime::currentMSecsSinceEpoch()) / 1000; - else - newTimestamp = static_cast<quint64>(data.timestamp.toSecsSinceEpoch()); - if (m_reading.x() != data.x - || m_reading.y() != data.y - || m_reading.z() != data.z - || m_reading.calibrationLevel() != data.calibrationLevel) { - m_reading.setTimestamp(newTimestamp); - m_reading.setX(data.x); - m_reading.setY(data.y); - m_reading.setZ(data.z); - m_reading.setCalibrationLevel(data.calibrationLevel); - - newReadingAvailable(); - } -} - diff --git a/src/plugins/sensors/simulator/simulatormagnetometer.h b/src/plugins/sensors/simulator/simulatormagnetometer.h deleted file mode 100644 index facbad41..00000000 --- a/src/plugins/sensors/simulator/simulatormagnetometer.h +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SIMULATORMAGNETOMETER_H -#define SIMULATORMAGNETOMETER_H - -#include "simulatorcommon.h" -#include <qmagnetometer.h> - -class SimulatorMagnetometer : public SimulatorCommon -{ -public: - static const char *id; - - SimulatorMagnetometer(QSensor *sensor); - - void poll() override; -private: - QMagnetometerReading m_reading; -}; - -#endif - diff --git a/src/plugins/sensors/simulator/simulatorproximitysensor.cpp b/src/plugins/sensors/simulator/simulatorproximitysensor.cpp deleted file mode 100644 index 6a28ce52..00000000 --- a/src/plugins/sensors/simulator/simulatorproximitysensor.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "simulatorproximitysensor.h" -#include <QDebug> -#include <QtGlobal> - -const char *SimulatorProximitySensor::id("Simulator.ProximitySensor"); - -SimulatorProximitySensor::SimulatorProximitySensor(QSensor *sensor) - : SimulatorCommon(sensor) -{ - setReading<QProximityReading>(&m_reading); -} - -void SimulatorProximitySensor::poll() -{ - QtMobility::QProximityReadingData data = SensorsConnection::instance()->qtProximityData; - quint64 newTimestamp; - if (!data.timestamp.isValid()) - newTimestamp = static_cast<quint64>(QDateTime::currentMSecsSinceEpoch() / 1000; - else - newTimestamp = static_cast<quint64>(data.timestamp.toSecsSinceEpoch(); - if (m_reading.close() != data.close) { - m_reading.setTimestamp(newTimestamp); - m_reading.setClose(data.close); - - newReadingAvailable(); - } -} - diff --git a/src/plugins/sensors/simulator/simulatorproximitysensor.h b/src/plugins/sensors/simulator/simulatorproximitysensor.h deleted file mode 100644 index 16e6f6bb..00000000 --- a/src/plugins/sensors/simulator/simulatorproximitysensor.h +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SIMULATORPROXIMITYSENSOR_H -#define SIMULATORPROXIMITYSENSOR_H - -#include "simulatorcommon.h" -#include <qproximitysensor.h> - -class SimulatorProximitySensor : public SimulatorCommon -{ -public: - static const char *id; - - SimulatorProximitySensor(QSensor *sensor); - - void poll() override; -private: - QProximityReading m_reading; -}; - -#endif - diff --git a/src/plugins/sensors/winrt/CMakeLists.txt b/src/plugins/sensors/winrt/CMakeLists.txt new file mode 100644 index 00000000..78baef86 --- /dev/null +++ b/src/plugins/sensors/winrt/CMakeLists.txt @@ -0,0 +1,32 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +##################################################################### +## WinRtSensorPlugin Plugin: +##################################################################### + +qt_internal_add_plugin(WinRtSensorPlugin + OUTPUT_NAME qtsensors_winrt + PLUGIN_TYPE sensors + SOURCES + main.cpp + winrtaccelerometer.cpp winrtaccelerometer.h + winrtambientlightsensor.cpp winrtambientlightsensor.h + winrtcommon.cpp winrtcommon.h + winrtcompass.cpp winrtcompass.h + winrtgyroscope.cpp winrtgyroscope.h + winrtorientationsensor.cpp winrtorientationsensor.h + winrtrotationsensor.cpp winrtrotationsensor.h + LIBRARIES + Qt::Core + Qt::CorePrivate + Qt::Sensors +) + +qt_internal_extend_target(WinRtSensorPlugin CONDITION MSVC + LIBRARIES + runtimeobject +) + +#### Keys ignored in scope 1:.:.:winrt.pro:<TRUE>: +# OTHER_FILES = "plugin.json" diff --git a/src/plugins/sensors/winrt/main.cpp b/src/plugins/sensors/winrt/main.cpp index ecf2a41b..04869082 100644 --- a/src/plugins/sensors/winrt/main.cpp +++ b/src/plugins/sensors/winrt/main.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "winrtaccelerometer.h" #include "winrtcompass.h" @@ -52,6 +16,7 @@ #include <QtSensors/QSensorBackendFactory> #include <QtSensors/QSensorManager> #include <QtSensors/QSensorPluginInterface> +#include <wrl.h> class WinRtSensorPlugin : public QObject, public QSensorPluginInterface, public QSensorBackendFactory { @@ -59,14 +24,24 @@ class WinRtSensorPlugin : public QObject, public QSensorPluginInterface, public Q_PLUGIN_METADATA(IID "com.qt-project.Qt.QSensorPluginInterface/1.0" FILE "plugin.json") Q_INTERFACES(QSensorPluginInterface) public: + + ~WinRtSensorPlugin() + { + CoUninitialize(); + } + void registerSensors() override { - QSensorManager::registerBackend(QAccelerometer::type, QByteArrayLiteral("WinRtAccelerometer"), this); - QSensorManager::registerBackend(QCompass::type, QByteArrayLiteral("WinRtCompass"), this); - QSensorManager::registerBackend(QGyroscope::type, QByteArrayLiteral("WinRtGyroscope"), this); - QSensorManager::registerBackend(QRotationSensor::type, QByteArrayLiteral("WinRtRotationSensor"), this); - QSensorManager::registerBackend(QAmbientLightSensor::type, QByteArrayLiteral("WinRtAmbientLightSensor"), this); - QSensorManager::registerBackend(QOrientationSensor::type, QByteArrayLiteral("WinRtOrientationSensor"), this); + if (FAILED(CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED))) { + qErrnoWarning("CoInitializeEx() failed."); + return; + } + QSensorManager::registerBackend(QAccelerometer::sensorType, QByteArrayLiteral("WinRtAccelerometer"), this); + QSensorManager::registerBackend(QCompass::sensorType, QByteArrayLiteral("WinRtCompass"), this); + QSensorManager::registerBackend(QGyroscope::sensorType, QByteArrayLiteral("WinRtGyroscope"), this); + QSensorManager::registerBackend(QRotationSensor::sensorType, QByteArrayLiteral("WinRtRotationSensor"), this); + QSensorManager::registerBackend(QAmbientLightSensor::sensorType, QByteArrayLiteral("WinRtAmbientLightSensor"), this); + QSensorManager::registerBackend(QOrientationSensor::sensorType, QByteArrayLiteral("WinRtOrientationSensor"), this); } QSensorBackend *createBackend(QSensor *sensor) override diff --git a/src/plugins/sensors/winrt/winrt.pro b/src/plugins/sensors/winrt/winrt.pro deleted file mode 100644 index 21996fdd..00000000 --- a/src/plugins/sensors/winrt/winrt.pro +++ /dev/null @@ -1,27 +0,0 @@ -TARGET = qtsensors_winrt -QT = sensors core core_private - -HEADERS += \ - winrtaccelerometer.h \ - winrtambientlightsensor.h \ - winrtcommon.h \ - winrtcompass.h \ - winrtorientationsensor.h \ - winrtrotationsensor.h \ - winrtgyroscope.h - -SOURCES += \ - main.cpp \ - winrtaccelerometer.cpp \ - winrtambientlightsensor.cpp \ - winrtcommon.cpp \ - winrtcompass.cpp \ - winrtorientationsensor.cpp \ - winrtrotationsensor.cpp \ - winrtgyroscope.cpp - -OTHER_FILES = plugin.json - -PLUGIN_TYPE = sensors -PLUGIN_CLASS_NAME = WinRtSensorPlugin -load(qt_plugin) diff --git a/src/plugins/sensors/winrt/winrtaccelerometer.cpp b/src/plugins/sensors/winrt/winrtaccelerometer.cpp index 3570a47d..43a364c9 100644 --- a/src/plugins/sensors/winrt/winrtaccelerometer.cpp +++ b/src/plugins/sensors/winrt/winrtaccelerometer.cpp @@ -1,51 +1,15 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "winrtaccelerometer.h" #include "winrtcommon.h" #include <QtSensors/QAccelerometerReading> -#include <private/qeventdispatcher_winrt_p.h> #include <functional> #include <wrl.h> #include <windows.devices.sensors.h> + using namespace Microsoft::WRL; using namespace Microsoft::WRL::Wrappers; using namespace ABI::Windows::Foundation; @@ -119,28 +83,30 @@ WinRtAccelerometer::WinRtAccelerometer(QSensor *sensor) : QSensorBackend(sensor), d_ptr(new WinRtAccelerometerPrivate(this)) { Q_D(WinRtAccelerometer); - HRESULT hr = QEventDispatcherWinRT::runOnXamlThread([d]() { - HStringReference classId(RuntimeClass_Windows_Devices_Sensors_Accelerometer); - ComPtr<IAccelerometerStatics> factory; - HRESULT hr = RoGetActivationFactory(classId.Get(), IID_PPV_ARGS(&factory)); - if (FAILED(hr)) { - qCWarning(lcWinRtSensors) << "Unable to initialize accelerometer factory." + + HStringReference classId(RuntimeClass_Windows_Devices_Sensors_Accelerometer); + ComPtr<IAccelerometerStatics> factory; + HRESULT hr = RoGetActivationFactory(classId.Get(), IID_PPV_ARGS(&factory)); + if (FAILED(hr)) { + qCWarning(lcWinRtSensors) << "Unable to initialize accelerometer factory." << qt_error_string(hr); - return hr; - } + sensorError(hr); + return; + } + hr = factory->GetDefault(&d->sensor); - hr = factory->GetDefault(&d->sensor); - if (FAILED(hr)) { - qCWarning(lcWinRtSensors) << "Unable to get default accelerometer." + if (FAILED(hr)) { + qCWarning(lcWinRtSensors) << "Unable to get default accelerometer." << qt_error_string(hr); - } - return hr; - }); - if (FAILED(hr) || !d->sensor) { sensorError(hr); return; } + if (!d->sensor) { + qCWarning(lcWinRtSensors) << "Default accelerometer was not found on the system."; + return; + } + hr = d->sensor->get_MinimumReportInterval(&d->minimumReportInterval); if (FAILED(hr)) { qCWarning(lcWinRtSensors) << "Unable to get the minimum report interval." @@ -167,11 +133,10 @@ void WinRtAccelerometer::start() if (d->token.value) return; - HRESULT hr = QEventDispatcherWinRT::runOnXamlThread([d]() { - ComPtr<AccelerometerReadingHandler> callback = - Callback<AccelerometerReadingHandler>(d, &WinRtAccelerometerPrivate::readingChanged); - return d->sensor->add_ReadingChanged(callback.Get(), &d->token); - }); + ComPtr<AccelerometerReadingHandler> callback = + Callback<AccelerometerReadingHandler>(d, &WinRtAccelerometerPrivate::readingChanged); + HRESULT hr = d->sensor->add_ReadingChanged(callback.Get(), &d->token); + if (FAILED(hr)) { qCWarning(lcWinRtSensors) << "Unable to attach to reading changed event." << qt_error_string(hr); @@ -200,9 +165,7 @@ void WinRtAccelerometer::stop() if (!d->token.value) return; - HRESULT hr = QEventDispatcherWinRT::runOnXamlThread([d]() { - return d->sensor->remove_ReadingChanged(d->token); - }); + HRESULT hr = d->sensor->remove_ReadingChanged(d->token); if (FAILED(hr)) { qCWarning(lcWinRtSensors) << "Unable to detach from reading changed event." << qt_error_string(hr); diff --git a/src/plugins/sensors/winrt/winrtaccelerometer.h b/src/plugins/sensors/winrt/winrtaccelerometer.h index dcb52ee5..96b0f093 100644 --- a/src/plugins/sensors/winrt/winrtaccelerometer.h +++ b/src/plugins/sensors/winrt/winrtaccelerometer.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef WINRTACCELEROMETER_H #define WINRTACCELEROMETER_H diff --git a/src/plugins/sensors/winrt/winrtambientlightsensor.cpp b/src/plugins/sensors/winrt/winrtambientlightsensor.cpp index 426d61bf..17785256 100644 --- a/src/plugins/sensors/winrt/winrtambientlightsensor.cpp +++ b/src/plugins/sensors/winrt/winrtambientlightsensor.cpp @@ -1,47 +1,10 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "winrtambientlightsensor.h" #include "winrtcommon.h" #include <QtSensors/QAmbientLightSensor> -#include <private/qeventdispatcher_winrt_p.h> #include <functional> #include <wrl.h> @@ -118,27 +81,27 @@ WinRtAmbientLightSensor::WinRtAmbientLightSensor(QSensor *sensor) : QSensorBackend(sensor), d_ptr(new WinRtAmbientLightSensorPrivate(this)) { Q_D(WinRtAmbientLightSensor); - HRESULT hr = QEventDispatcherWinRT::runOnXamlThread([d]() { - HStringReference classId(RuntimeClass_Windows_Devices_Sensors_LightSensor); - ComPtr<ILightSensorStatics> factory; - HRESULT hr = RoGetActivationFactory(classId.Get(), IID_PPV_ARGS(&factory)); - if (FAILED(hr)) { - qCWarning(lcWinRtSensors) << "Unable to initialize light sensor factory." - << qt_error_string(hr); - return hr; - } - hr = factory->GetDefault(&d->sensor); - if (FAILED(hr)) { - qCWarning(lcWinRtSensors) << "Unable to get default light sensor." + HStringReference classId(RuntimeClass_Windows_Devices_Sensors_LightSensor); + ComPtr<ILightSensorStatics> factory; + HRESULT hr = RoGetActivationFactory(classId.Get(), IID_PPV_ARGS(&factory)); + if (FAILED(hr)) { + qCWarning(lcWinRtSensors) << "Unable to initialize light sensor factory." << qt_error_string(hr); - } - return hr; - }); - if (FAILED(hr) || !d->sensor) { sensorError(hr); return; } + hr = factory->GetDefault(&d->sensor); + if (FAILED(hr)) { + qCWarning(lcWinRtSensors) << "Unable to get default light sensor." + << qt_error_string(hr); + sensorError(hr); + return; + } + if (!d->sensor) { + qCWarning(lcWinRtSensors) << "Default lightsensor was not found on the system."; + return; + } hr = d->sensor->get_MinimumReportInterval(&d->minimumReportInterval); if (FAILED(hr)) { @@ -166,11 +129,10 @@ void WinRtAmbientLightSensor::start() if (d->token.value) return; - HRESULT hr = QEventDispatcherWinRT::runOnXamlThread([d]() { - ComPtr<LightSensorReadingHandler> callback = + ComPtr<LightSensorReadingHandler> callback = Callback<LightSensorReadingHandler>(d, &WinRtAmbientLightSensorPrivate::readingChanged); - return d->sensor->add_ReadingChanged(callback.Get(), &d->token); - }); + HRESULT hr = d->sensor->add_ReadingChanged(callback.Get(), &d->token); + if (FAILED(hr)) { qCWarning(lcWinRtSensors) << "Unable to attach to reading changed event." << qt_error_string(hr); @@ -199,9 +161,7 @@ void WinRtAmbientLightSensor::stop() if (!d->token.value) return; - HRESULT hr = QEventDispatcherWinRT::runOnXamlThread([d]() { - return d->sensor->remove_ReadingChanged(d->token); - }); + HRESULT hr = d->sensor->remove_ReadingChanged(d->token); if (FAILED(hr)) { qCWarning(lcWinRtSensors) << "Unable to detach from reading changed event." << qt_error_string(hr); diff --git a/src/plugins/sensors/winrt/winrtambientlightsensor.h b/src/plugins/sensors/winrt/winrtambientlightsensor.h index e32db890..160d7474 100644 --- a/src/plugins/sensors/winrt/winrtambientlightsensor.h +++ b/src/plugins/sensors/winrt/winrtambientlightsensor.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef WINRTAMBIENTLIGHTSENSOR_H #define WINRTAMBIENTLIGHTSENSOR_H diff --git a/src/plugins/sensors/winrt/winrtcommon.cpp b/src/plugins/sensors/winrt/winrtcommon.cpp index 3e5d1525..e655a672 100644 --- a/src/plugins/sensors/winrt/winrtcommon.cpp +++ b/src/plugins/sensors/winrt/winrtcommon.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "winrtcommon.h" diff --git a/src/plugins/sensors/winrt/winrtcommon.h b/src/plugins/sensors/winrt/winrtcommon.h index db3c8197..6f4c868c 100644 --- a/src/plugins/sensors/winrt/winrtcommon.h +++ b/src/plugins/sensors/winrt/winrtcommon.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef WINRTCOMMON_H #define WINRTCOMMON_H diff --git a/src/plugins/sensors/winrt/winrtcompass.cpp b/src/plugins/sensors/winrt/winrtcompass.cpp index 5ef730d0..a12f1dcd 100644 --- a/src/plugins/sensors/winrt/winrtcompass.cpp +++ b/src/plugins/sensors/winrt/winrtcompass.cpp @@ -1,47 +1,10 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "winrtcompass.h" #include "winrtcommon.h" #include <QtSensors/QCompass> -#include <private/qeventdispatcher_winrt_p.h> #include <functional> #include <wrl.h> @@ -136,28 +99,30 @@ WinRtCompass::WinRtCompass(QSensor *sensor) : QSensorBackend(sensor), d_ptr(new WinRtCompassPrivate(this)) { Q_D(WinRtCompass); - HRESULT hr = QEventDispatcherWinRT::runOnXamlThread([d]() { - HStringReference classId(RuntimeClass_Windows_Devices_Sensors_Compass); - ComPtr<ICompassStatics> factory; - HRESULT hr = RoGetActivationFactory(classId.Get(), IID_PPV_ARGS(&factory)); - if (FAILED(hr)) { - qCWarning(lcWinRtSensors) << "Unable to initialize light sensor factory." + + HStringReference classId(RuntimeClass_Windows_Devices_Sensors_Compass); + ComPtr<ICompassStatics> factory; + HRESULT hr = RoGetActivationFactory(classId.Get(), IID_PPV_ARGS(&factory)); + if (FAILED(hr)) { + qCWarning(lcWinRtSensors) << "Unable to initialize light sensor factory." << qt_error_string(hr); - return hr; - } + sensorError(hr); + return; + } - hr = factory->GetDefault(&d->sensor); - if (FAILED(hr)) { - qCWarning(lcWinRtSensors) << "Unable to get default compass." + hr = factory->GetDefault(&d->sensor); + if (FAILED(hr)) { + qCWarning(lcWinRtSensors) << "Unable to get default compass." << qt_error_string(hr); - } - return hr; - }); - if (FAILED(hr) || !d->sensor) { sensorError(hr); return; } + if (!d->sensor) { + qCWarning(lcWinRtSensors) << "Default compass was not found on the system."; + return; + } + hr = d->sensor->get_MinimumReportInterval(&d->minimumReportInterval); if (FAILED(hr)) { qCWarning(lcWinRtSensors) << "Unable to get the minimum report interval." @@ -183,12 +148,10 @@ void WinRtCompass::start() return; if (d->token.value) return; - - HRESULT hr = QEventDispatcherWinRT::runOnXamlThread([d]() { - ComPtr<CompassReadingHandler> callback = + ComPtr<CompassReadingHandler> callback = Callback<CompassReadingHandler>(d, &WinRtCompassPrivate::readingChanged); - return d->sensor->add_ReadingChanged(callback.Get(), &d->token); - }); + HRESULT hr = d->sensor->add_ReadingChanged(callback.Get(), &d->token); + if (FAILED(hr)) { qCWarning(lcWinRtSensors) << "Unable to attach to reading changed event." << qt_error_string(hr); @@ -216,9 +179,8 @@ void WinRtCompass::stop() return; if (!d->token.value) return; - HRESULT hr = QEventDispatcherWinRT::runOnXamlThread([d]() { - return d->sensor->remove_ReadingChanged(d->token); - }); + HRESULT hr = d->sensor->remove_ReadingChanged(d->token); + if (FAILED(hr)) { qCWarning(lcWinRtSensors) << "Unable to detach from reading changed event." << qt_error_string(hr); diff --git a/src/plugins/sensors/winrt/winrtcompass.h b/src/plugins/sensors/winrt/winrtcompass.h index 5bb8faf1..f4297c36 100644 --- a/src/plugins/sensors/winrt/winrtcompass.h +++ b/src/plugins/sensors/winrt/winrtcompass.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef WINRTCOMPASS_H #define WINRTCOMPASS_H diff --git a/src/plugins/sensors/winrt/winrtgyroscope.cpp b/src/plugins/sensors/winrt/winrtgyroscope.cpp index 45b544c7..c5fff500 100644 --- a/src/plugins/sensors/winrt/winrtgyroscope.cpp +++ b/src/plugins/sensors/winrt/winrtgyroscope.cpp @@ -1,47 +1,10 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "winrtgyroscope.h" #include "winrtcommon.h" #include <QtSensors/QGyroscope> -#include <private/qeventdispatcher_winrt_p.h> #include <functional> #include <wrl.h> @@ -51,7 +14,7 @@ using namespace Microsoft::WRL::Wrappers; using namespace ABI::Windows::Foundation; using namespace ABI::Windows::Devices::Sensors; -typedef ITypedEventHandler<Gyrometer *, GyrometerReadingChangedEventArgs *> InclinometerReadingHandler; +typedef ITypedEventHandler<Gyrometer *, GyrometerReadingChangedEventArgs *> GyrometerReadingHandler; QT_USE_NAMESPACE @@ -116,28 +79,30 @@ WinRtGyroscope::WinRtGyroscope(QSensor *sensor) : QSensorBackend(sensor), d_ptr(new WinRtGyroscopePrivate(this)) { Q_D(WinRtGyroscope); - HRESULT hr = QEventDispatcherWinRT::runOnXamlThread([d]() { - HStringReference classId(RuntimeClass_Windows_Devices_Sensors_Gyrometer); - ComPtr<IGyrometerStatics> factory; - HRESULT hr = RoGetActivationFactory(classId.Get(), IID_PPV_ARGS(&factory)); - if (FAILED(hr)) { - qCWarning(lcWinRtSensors) << "Unable to initialize gyroscope sensor factory." + + HStringReference classId(RuntimeClass_Windows_Devices_Sensors_Gyrometer); + ComPtr<IGyrometerStatics> factory; + HRESULT hr = RoGetActivationFactory(classId.Get(), IID_PPV_ARGS(&factory)); + if (FAILED(hr)) { + qCWarning(lcWinRtSensors) << "Unable to initialize gyroscope sensor factory." << qt_error_string(hr); - return hr; - } + sensorError(hr); + return; + } - hr = factory->GetDefault(&d->sensor); - if (FAILED(hr)) { - qCWarning(lcWinRtSensors) << "Unable to get default gyroscope sensor." + hr = factory->GetDefault(&d->sensor); + if (FAILED(hr)) { + qCWarning(lcWinRtSensors) << "Unable to get default gyroscope sensor." << qt_error_string(hr); - } - return hr; - }); - if (FAILED(hr) || !d->sensor) { sensorError(hr); return; } + if (!d->sensor) { + qCWarning(lcWinRtSensors) << "Default gyroscope was not found on the system."; + return; + } + hr = d->sensor->get_MinimumReportInterval(&d->minimumReportInterval); if (FAILED(hr)) { qCWarning(lcWinRtSensors) << "Unable to get the minimum report interval." @@ -164,11 +129,10 @@ void WinRtGyroscope::start() if (d->token.value) return; - HRESULT hr = QEventDispatcherWinRT::runOnXamlThread([d]() { - ComPtr<InclinometerReadingHandler> callback = - Callback<InclinometerReadingHandler>(d, &WinRtGyroscopePrivate::readingChanged); - return d->sensor->add_ReadingChanged(callback.Get(), &d->token); - }); + ComPtr<GyrometerReadingHandler> callback = + Callback<GyrometerReadingHandler>(d, &WinRtGyroscopePrivate::readingChanged); + HRESULT hr = d->sensor->add_ReadingChanged(callback.Get(), &d->token); + if (FAILED(hr)) { qCWarning(lcWinRtSensors) << "Unable to attach to reading changed event." << qt_error_string(hr); @@ -197,9 +161,7 @@ void WinRtGyroscope::stop() if (!d->token.value) return; - HRESULT hr = QEventDispatcherWinRT::runOnXamlThread([d]() { - return d->sensor->remove_ReadingChanged(d->token); - }); + HRESULT hr = d->sensor->remove_ReadingChanged(d->token); if (FAILED(hr)) { qCWarning(lcWinRtSensors) << "Unable to detach from reading changed event." << qt_error_string(hr); diff --git a/src/plugins/sensors/winrt/winrtgyroscope.h b/src/plugins/sensors/winrt/winrtgyroscope.h index 7bd85332..9d2fad4b 100644 --- a/src/plugins/sensors/winrt/winrtgyroscope.h +++ b/src/plugins/sensors/winrt/winrtgyroscope.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef WINRTGYROSCOPE_H #define WINRTGYROSCOPE_H @@ -55,7 +19,7 @@ public: bool isFeatureSupported(QSensor::Feature feature) const override { - if (feature == QSensor::AxesOrientation || feature == QSensor::AccelerationMode) + if (feature == QSensor::Feature::AxesOrientation || feature == QSensor::Feature::AccelerationMode) return true; return false; } diff --git a/src/plugins/sensors/winrt/winrtorientationsensor.cpp b/src/plugins/sensors/winrt/winrtorientationsensor.cpp index e24ff954..330ccae7 100644 --- a/src/plugins/sensors/winrt/winrtorientationsensor.cpp +++ b/src/plugins/sensors/winrt/winrtorientationsensor.cpp @@ -1,47 +1,10 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "winrtorientationsensor.h" #include "winrtcommon.h" #include <QtSensors/QOrientationSensor> -#include <private/qeventdispatcher_winrt_p.h> #include <functional> #include <wrl.h> @@ -122,27 +85,26 @@ WinRtOrientationSensor::WinRtOrientationSensor(QSensor *sensor) : QSensorBackend(sensor), d_ptr(new WinRtOrientationSensorPrivate(this)) { Q_D(WinRtOrientationSensor); - HRESULT hr = QEventDispatcherWinRT::runOnXamlThread([d]() { - HStringReference classId(RuntimeClass_Windows_Devices_Sensors_SimpleOrientationSensor); - ComPtr<ISimpleOrientationSensorStatics> factory; - HRESULT hr = RoGetActivationFactory(classId.Get(), IID_PPV_ARGS(&factory)); - if (FAILED(hr)) { - qCWarning(lcWinRtSensors) << "Unable to initialize orientation sensor factory." + HStringReference classId(RuntimeClass_Windows_Devices_Sensors_SimpleOrientationSensor); + ComPtr<ISimpleOrientationSensorStatics> factory; + HRESULT hr = RoGetActivationFactory(classId.Get(), IID_PPV_ARGS(&factory)); + if (FAILED(hr)) { + qCWarning(lcWinRtSensors) << "Unable to initialize orientation sensor factory." << qt_error_string(hr); - return hr; - } - - hr = factory->GetDefault(&d->sensor); - if (FAILED(hr)) { - qCWarning(lcWinRtSensors) << "Unable to get default orientation sensor." + sensorError(hr); + return; + } + hr = factory->GetDefault(&d->sensor); + if (FAILED(hr)) { + qCWarning(lcWinRtSensors) << "Unable to get default orientation sensor." << qt_error_string(hr); - } - return hr; - }); - if (FAILED(hr) || !d->sensor) { sensorError(hr); return; } + if (!d->sensor) { + qCWarning(lcWinRtSensors) << "Default orientationsensor was not found on the system."; + return; + } setReading<QOrientationReading>(&d->reading); } @@ -159,11 +121,10 @@ void WinRtOrientationSensor::start() if (d->token.value) return; - HRESULT hr = QEventDispatcherWinRT::runOnXamlThread([d]() { - ComPtr<SimpleOrientationReadingHandler> callback = + ComPtr<SimpleOrientationReadingHandler> callback = Callback<SimpleOrientationReadingHandler>(d, &WinRtOrientationSensorPrivate::readingChanged); - return d->sensor->add_OrientationChanged(callback.Get(), &d->token); - }); + HRESULT hr = d->sensor->add_OrientationChanged(callback.Get(), &d->token); + if (FAILED(hr)) { qCWarning(lcWinRtSensors) << "Unable to attach to reading changed event." << qt_error_string(hr); @@ -180,9 +141,7 @@ void WinRtOrientationSensor::stop() if (!d->token.value) return; - HRESULT hr = QEventDispatcherWinRT::runOnXamlThread([d]() { - return d->sensor->remove_OrientationChanged(d->token); - }); + HRESULT hr = d->sensor->remove_OrientationChanged(d->token); if (FAILED(hr)) { qCWarning(lcWinRtSensors) << "Unable to detach from reading changed event." << qt_error_string(hr); diff --git a/src/plugins/sensors/winrt/winrtorientationsensor.h b/src/plugins/sensors/winrt/winrtorientationsensor.h index 8e40a3e9..e7aaf4d8 100644 --- a/src/plugins/sensors/winrt/winrtorientationsensor.h +++ b/src/plugins/sensors/winrt/winrtorientationsensor.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef WINRTORIENTATIONSENSOR_H #define WINRTORIENTATIONSENSOR_H diff --git a/src/plugins/sensors/winrt/winrtrotationsensor.cpp b/src/plugins/sensors/winrt/winrtrotationsensor.cpp index 5dd4eae5..c29395fa 100644 --- a/src/plugins/sensors/winrt/winrtrotationsensor.cpp +++ b/src/plugins/sensors/winrt/winrtrotationsensor.cpp @@ -1,47 +1,10 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "winrtrotationsensor.h" #include "winrtcommon.h" #include <QtSensors/QRotationSensor> -#include <private/qeventdispatcher_winrt_p.h> #include <functional> #include <wrl.h> @@ -114,28 +77,29 @@ WinRtRotationSensor::WinRtRotationSensor(QSensor *sensor) : QSensorBackend(sensor), d_ptr(new WinRtRotationSensorPrivate(this)) { Q_D(WinRtRotationSensor); - HRESULT hr = QEventDispatcherWinRT::runOnXamlThread([d]() { - HStringReference classId(RuntimeClass_Windows_Devices_Sensors_Inclinometer); - ComPtr<IInclinometerStatics> factory; - HRESULT hr = RoGetActivationFactory(classId.Get(), IID_PPV_ARGS(&factory)); - if (FAILED(hr)) { - qCWarning(lcWinRtSensors) << "Unable to initialize rotation sensor factory." - << qt_error_string(hr); - return hr; - } - hr = factory->GetDefault(&d->sensor); - if (FAILED(hr)) { - qCWarning(lcWinRtSensors) << "Unable to get default rotation sensor." + HStringReference classId(RuntimeClass_Windows_Devices_Sensors_Inclinometer); + ComPtr<IInclinometerStatics> factory; + HRESULT hr = RoGetActivationFactory(classId.Get(), IID_PPV_ARGS(&factory)); + if (FAILED(hr)) { + qCWarning(lcWinRtSensors) << "Unable to initialize rotation sensor factory." + << qt_error_string(hr); + sensorError(hr); + return; + } + hr = factory->GetDefault(&d->sensor); + if (FAILED(hr)) { + qCWarning(lcWinRtSensors) << "Unable to get default rotation sensor." << qt_error_string(hr); - } - return hr; - }); - if (FAILED(hr) || !d->sensor) { sensorError(hr); return; } + if (!d->sensor) { + qCWarning(lcWinRtSensors) << "Default rotationsensor was not found on the system."; + return; + } + hr = d->sensor->get_MinimumReportInterval(&d->minimumReportInterval); if (FAILED(hr)) { qCWarning(lcWinRtSensors) << "Unable to get the minimum report interval." @@ -162,11 +126,10 @@ void WinRtRotationSensor::start() if (d->token.value) return; - HRESULT hr = QEventDispatcherWinRT::runOnXamlThread([d]() { - ComPtr<InclinometerReadingHandler> callback = + ComPtr<InclinometerReadingHandler> callback = Callback<InclinometerReadingHandler>(d, &WinRtRotationSensorPrivate::readingChanged); - return d->sensor->add_ReadingChanged(callback.Get(), &d->token); - }); + HRESULT hr = d->sensor->add_ReadingChanged(callback.Get(), &d->token); + if (FAILED(hr)) { qCWarning(lcWinRtSensors) << "Unable to attach to reading changed event." << qt_error_string(hr); @@ -195,9 +158,7 @@ void WinRtRotationSensor::stop() if (!d->token.value) return; - HRESULT hr = QEventDispatcherWinRT::runOnXamlThread([d]() { - return d->sensor->remove_ReadingChanged(d->token); - }); + HRESULT hr = d->sensor->remove_ReadingChanged(d->token); if (FAILED(hr)) { qCWarning(lcWinRtSensors) << "Unable to detach from reading changed event." << qt_error_string(hr); diff --git a/src/plugins/sensors/winrt/winrtrotationsensor.h b/src/plugins/sensors/winrt/winrtrotationsensor.h index 4b3e6faf..add2d027 100644 --- a/src/plugins/sensors/winrt/winrtrotationsensor.h +++ b/src/plugins/sensors/winrt/winrtrotationsensor.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef WINRTROTATIONSENSOR_H #define WINRTROTATIONSENSOR_H @@ -55,7 +19,7 @@ public: bool isFeatureSupported(QSensor::Feature feature) const override { - if (feature == QSensor::AxesOrientation || feature == QSensor::AccelerationMode) + if (feature == QSensor::Feature::AxesOrientation || feature == QSensor::Feature::AccelerationMode) return true; return false; } |