summaryrefslogtreecommitdiffstats
path: root/src/plugins/sensors/winrt
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/sensors/winrt')
-rw-r--r--src/plugins/sensors/winrt/CMakeLists.txt32
-rw-r--r--src/plugins/sensors/winrt/main.cpp63
-rw-r--r--src/plugins/sensors/winrt/winrt.pro27
-rw-r--r--src/plugins/sensors/winrt/winrtaccelerometer.cpp87
-rw-r--r--src/plugins/sensors/winrt/winrtaccelerometer.h40
-rw-r--r--src/plugins/sensors/winrt/winrtambientlightsensor.cpp84
-rw-r--r--src/plugins/sensors/winrt/winrtambientlightsensor.h40
-rw-r--r--src/plugins/sensors/winrt/winrtcommon.cpp40
-rw-r--r--src/plugins/sensors/winrt/winrtcommon.h40
-rw-r--r--src/plugins/sensors/winrt/winrtcompass.cpp86
-rw-r--r--src/plugins/sensors/winrt/winrtcompass.h40
-rw-r--r--src/plugins/sensors/winrt/winrtgyroscope.cpp88
-rw-r--r--src/plugins/sensors/winrt/winrtgyroscope.h42
-rw-r--r--src/plugins/sensors/winrt/winrtorientationsensor.cpp83
-rw-r--r--src/plugins/sensors/winrt/winrtorientationsensor.h40
-rw-r--r--src/plugins/sensors/winrt/winrtrotationsensor.cpp85
-rw-r--r--src/plugins/sensors/winrt/winrtrotationsensor.h42
17 files changed, 209 insertions, 750 deletions
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;
}