This repository has been archived on 2020-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
Files
YASMIN/sensors/android/AccelerometerSensorAndroid.h
2016-09-28 12:16:45 +02:00

61 lines
968 B
C++

#ifndef ACCELEROMETERSENSORANDROID_H
#define ACCELEROMETERSENSORANDROID_H
#ifdef ANDROID
#include <sstream>
#include "../AccelerometerSensor.h"
#include <QtSensors/QAccelerometer>
#include "../AccelerometerSensor.h"
class AccelerometerSensorAndroid : public AccelerometerSensor {
private:
QAccelerometer acc;
/** hidden ctor. use singleton */
AccelerometerSensorAndroid() {
;
}
public:
/** singleton access */
static AccelerometerSensorAndroid& get() {
static AccelerometerSensorAndroid acc;
return acc;
}
void start() override {
auto onSensorData = [&] () {
AccelerometerData data(acc.reading()->x(), acc.reading()->y(), acc.reading()->z());
informListeners(data);
};
acc.connect(&acc, &QAccelerometer::readingChanged, onSensorData);
acc.start();
}
bool isRunning() const override {
return acc.isActive();
}
void stop() override {
throw "TODO";
}
};
#endif // ANDROID
#endif // ACCELEROMETERSENSORANDROID_H