summaryrefslogtreecommitdiffstats
path: root/src/plugins/sensors/ios/iosaccelerometer.h
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@digia.com>2013-05-30 10:07:29 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-06-05 21:15:26 +0200
commit102bdf35b13f1b60df26052341ebc5a2833518c7 (patch)
treed603ff2116af12f4d3a64a8a8987107b83e0383e /src/plugins/sensors/ios/iosaccelerometer.h
parente8237a3d19e90c31af6d5a6c5e3a2f7815740226 (diff)
iOS: change accelerometer to use QTimer for polling
According to the docs (CMMotionManager class reference) there are two ways of interacting with the accelerometer; Either through the callback API (NSOperationQueue), or peridic sampling (polling). Our first implementation of IOSAcceleometer used the former technique, which turns out to have bad performance when using the sensor together with a fine-grained QTimer. And this case is pretty common when using sensors together with e.g QML. Reading through the docs more carefully, they recommend using the polling technique when creating games instead since the NSOperationQueue introduces some overhead. So this patch does that, change the implementation to use QTimer based polling. And this solves the performance issues found. Change-Id: Ifde0d2292302467afb8db90a954ef45f3238350e Reviewed-by: Thomas McGuire <thomas.mcguire@kdab.com>
Diffstat (limited to 'src/plugins/sensors/ios/iosaccelerometer.h')
-rw-r--r--src/plugins/sensors/ios/iosaccelerometer.h9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/plugins/sensors/ios/iosaccelerometer.h b/src/plugins/sensors/ios/iosaccelerometer.h
index 5fcac19f..1a6560b1 100644
--- a/src/plugins/sensors/ios/iosaccelerometer.h
+++ b/src/plugins/sensors/ios/iosaccelerometer.h
@@ -42,29 +42,28 @@
#ifndef IOSACCELEROMETER_H
#define IOSACCELEROMETER_H
-#include <Foundation/Foundation.h>
+#include <CoreMotion/CMMotionManager.h>
#include <qsensorbackend.h>
#include <qaccelerometer.h>
QT_BEGIN_NAMESPACE
-@class QtIoAccelListener;
-
class IOSAccelerometer : public QSensorBackend
{
public:
static char const * const id;
explicit IOSAccelerometer(QSensor *sensor);
- ~IOSAccelerometer();
+ void timerEvent(QTimerEvent *);
void start();
void stop();
private:
- NSOperationQueue *m_updateQueue;
+ CMMotionManager *m_motionManager;
QAccelerometerReading m_reading;
+ int m_timer;
};
QT_END_NAMESPACE