5#include "deviceorientation.h"
7#if defined(Q_OS_ANDROID)
8#include <QAndroidJniObject>
9#include <QtAndroidExtras>
11#define ALPHA_LOW_PASS 0.1
14DeviceOrientation::DeviceOrientation(
QObject *parent) :
QObject(parent)
18void DeviceOrientation::stopSensors()
20#if defined(Q_OS_ANDROID)
21 QAndroidJniObject activity = QtAndroid::androidActivity();
22 activity.callMethod<
void>(
"stopSensors");
26void DeviceOrientation::startSensors()
28#if defined(Q_OS_ANDROID)
29 QAndroidJniObject activity = QtAndroid::androidActivity();
30 activity.callMethod<
void>(
"startSensors");
34void DeviceOrientation::getOrientation()
36#if defined(Q_OS_ANDROID)
37 QAndroidJniObject activity = QtAndroid::androidActivity();
38 m_Azimuth = m_Azimuth + ALPHA_LOW_PASS * (activity.callMethod<
float>(
"getAzimuth") - m_Azimuth);
39 m_Altitude = m_Altitude + ALPHA_LOW_PASS * (activity.callMethod<
float>(
"getPitch") - m_Altitude);
41 float newRoll = activity.callMethod<
float>(
"getRoll");
42 m_Roll = abs(newRoll - m_Roll) > 10 ? newRoll : m_Roll + ALPHA_LOW_PASS * (newRoll - m_Roll);
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 20 2024 11:53:00 by
doxygen 1.12.0 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.