diff options
Diffstat (limited to 'src/plugins/sensors/ios')
-rw-r--r-- | src/plugins/sensors/ios/CMakeLists.txt | 59 | ||||
-rw-r--r-- | src/plugins/sensors/ios/ios.pro | 49 | ||||
-rw-r--r-- | src/plugins/sensors/ios/iosaccelerometer.h | 40 | ||||
-rw-r--r-- | src/plugins/sensors/ios/iosaccelerometer.mm | 40 | ||||
-rw-r--r-- | src/plugins/sensors/ios/ioscompass.h | 40 | ||||
-rw-r--r-- | src/plugins/sensors/ios/ioscompass.mm | 40 | ||||
-rw-r--r-- | src/plugins/sensors/ios/iosgyroscope.h | 40 | ||||
-rw-r--r-- | src/plugins/sensors/ios/iosgyroscope.mm | 40 | ||||
-rw-r--r-- | src/plugins/sensors/ios/iosmagnetometer.h | 40 | ||||
-rw-r--r-- | src/plugins/sensors/ios/iosmagnetometer.mm | 44 | ||||
-rw-r--r-- | src/plugins/sensors/ios/iosmotionmanager.h | 40 | ||||
-rw-r--r-- | src/plugins/sensors/ios/iosmotionmanager.mm | 40 | ||||
-rw-r--r-- | src/plugins/sensors/ios/iospressure.h | 37 | ||||
-rw-r--r-- | src/plugins/sensors/ios/iospressure.mm | 65 | ||||
-rw-r--r-- | src/plugins/sensors/ios/iosproximitysensor.h | 40 | ||||
-rw-r--r-- | src/plugins/sensors/ios/iosproximitysensor.mm | 40 | ||||
-rw-r--r-- | src/plugins/sensors/ios/main.mm | 55 |
17 files changed, 199 insertions, 550 deletions
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) |