diff options
-rw-r--r-- | examples/sensors/accelbubble/Info.plist | 35 | ||||
-rw-r--r-- | examples/sensors/accelbubble/accelbubble.pro | 7 | ||||
-rw-r--r-- | examples/sensors/accelbubble/accelbubble.qml | 3 | ||||
-rw-r--r-- | src/plugins/sensors/ios/iosaccelerometer.mm | 3 | ||||
-rw-r--r-- | src/plugins/sensors/ios/iosgyroscope.mm | 3 | ||||
-rw-r--r-- | src/plugins/sensors/ios/iosmagnetometer.mm | 6 |
6 files changed, 57 insertions, 0 deletions
diff --git a/examples/sensors/accelbubble/Info.plist b/examples/sensors/accelbubble/Info.plist new file mode 100644 index 00000000..82e9bff0 --- /dev/null +++ b/examples/sensors/accelbubble/Info.plist @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CFBundleDisplayName</key> + <string>accelbubble</string> + <key>CFBundleExecutable</key> + <string>accelbubble</string> + <key>CFBundleGetInfoString</key> + <string>Created by Qt/QMake</string> + <key>CFBundleIdentifier</key> + <string>com.digia.accelbubble</string> + <key>CFBundleName</key> + <string>accelbubble</string> + <key>CFBundlePackageType</key> + <string>APPL</string> + <key>CFBundleResourceSpecification</key> + <string>ResourceRules.plist</string> + <key>CFBundleShortVersionString</key> + <string>1.0</string> + <key>CFBundleSignature</key> + <string>????</string> + <key>CFBundleVersion</key> + <string>1.0</string> + <key>UIDeviceFamily</key> + <array> + <integer>1</integer> + <integer>2</integer> + </array> + <key>UISupportedInterfaceOrientations</key> + <array> + <string>UIInterfaceOrientationPortrait</string> + </array> +</dict> +</plist> diff --git a/examples/sensors/accelbubble/accelbubble.pro b/examples/sensors/accelbubble/accelbubble.pro index cdb6ab75..4204f15b 100644 --- a/examples/sensors/accelbubble/accelbubble.pro +++ b/examples/sensors/accelbubble/accelbubble.pro @@ -15,4 +15,11 @@ OTHER_FILES = \ target.path = $$[QT_INSTALL_EXAMPLES]/sensors/accelbubble INSTALLS += target +ios { +QMAKE_INFO_PLIST = Info.plist + +# manual plugin loading needed with older Qt +# QTPLUGIN += qsvg qtsensors_ios qtsensors_generic +} + ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android diff --git a/examples/sensors/accelbubble/accelbubble.qml b/examples/sensors/accelbubble/accelbubble.qml index 8f676dc9..033e66a4 100644 --- a/examples/sensors/accelbubble/accelbubble.qml +++ b/examples/sensors/accelbubble/accelbubble.qml @@ -69,6 +69,9 @@ ApplicationWindow { var newX = (bubble.x + calcRoll(accel.reading.x, accel.reading.y, accel.reading.z) * .1) var newY = (bubble.y - calcPitch(accel.reading.x, accel.reading.y, accel.reading.z) * .1) + if (isNaN(newX) || isNaN(newY)) + return; + if (newX < 0) newX = 0 diff --git a/src/plugins/sensors/ios/iosaccelerometer.mm b/src/plugins/sensors/ios/iosaccelerometer.mm index 5f9c0f16..ef215465 100644 --- a/src/plugins/sensors/ios/iosaccelerometer.mm +++ b/src/plugins/sensors/ios/iosaccelerometer.mm @@ -77,6 +77,9 @@ void IOSAccelerometer::timerEvent(QTimerEvent *) // Convert from NSTimeInterval to microseconds and G to m/s2, and flip axes: CMAccelerometerData *data = m_motionManager.accelerometerData; CMAcceleration acc = data.acceleration; + // skip update if NaN + if (acc.x != acc.x || acc.y != acc.y || acc.z != acc.z) + return; static const qreal G = 9.8066; m_reading.setTimestamp(quint64(data.timestamp * 1e6)); m_reading.setX(qreal(acc.x) * G * -1); diff --git a/src/plugins/sensors/ios/iosgyroscope.mm b/src/plugins/sensors/ios/iosgyroscope.mm index 8dfa3a4a..751786ef 100644 --- a/src/plugins/sensors/ios/iosgyroscope.mm +++ b/src/plugins/sensors/ios/iosgyroscope.mm @@ -75,6 +75,9 @@ void IOSGyroscope::timerEvent(QTimerEvent *) // Convert NSTimeInterval to microseconds and radians to degrees: CMGyroData *data = m_motionManager.gyroData; CMRotationRate rate = data.rotationRate; + // skip update if NaN + if (rate.x != rate.x || rate.y != rate.y || rate.z != rate.z) + return; m_reading.setTimestamp(quint64(data.timestamp * 1e6)); m_reading.setX((qreal(rate.x) / M_PI) * 180); m_reading.setY((qreal(rate.y) / M_PI) * 180); diff --git a/src/plugins/sensors/ios/iosmagnetometer.mm b/src/plugins/sensors/ios/iosmagnetometer.mm index 95f85ae1..3cd8b10e 100644 --- a/src/plugins/sensors/ios/iosmagnetometer.mm +++ b/src/plugins/sensors/ios/iosmagnetometer.mm @@ -91,6 +91,9 @@ void IOSMagnetometer::timerEvent(QTimerEvent *) CMDeviceMotion *deviceMotion = m_motionManager.deviceMotion; CMCalibratedMagneticField calibratedField = deviceMotion.magneticField; field = calibratedField.field; + // skip update if NaN + if (field.x != field.x || field.y != field.y || field.z != field.z) + return; m_reading.setTimestamp(quint64(deviceMotion.timestamp * 1e6)); switch (calibratedField.accuracy) { @@ -110,6 +113,9 @@ void IOSMagnetometer::timerEvent(QTimerEvent *) } else { CMMagnetometerData *data = m_motionManager.magnetometerData; field = data.magneticField; + // skip update if NaN + if (field.x != field.x || field.y != field.y || field.z != field.z) + return; m_reading.setTimestamp(quint64(data.timestamp * 1e6)); m_reading.setCalibrationLevel(1.0); } |