Sensor Scol plugin
Multi platform sensors for handled devices
SASensor.h
1#ifndef _ASENSOR_H_
2#define _ASENSOR_H_
3
4#ifdef ANDROID
5
6#include <set>
7#include <stdint.h>
8#include <vector>
9#include <android/sensor.h>
10#include "SSensor.h"
11#include "tools/Vector3d.h"
12
13/* CLASS NAME: Sensor
14 * \brief Represents a sensor.
15
16 * Used to store sensor datas received by events. The purpose if to get datas synchronously (by a simple 'get' method)
17 */
18class SASensor : public SSensor
19{
20 /* * * * * * * * * * * * * FRIENDS * * * * * * * * * * * * */
21
22 /* * * * * * * * * * * * * ATTRIBUTES * * * * * * * * * * * * */
23 public:
24 protected:
25 SSensorData mData;
26 ASensor* mASensor;
27 Vector3d mGravity;
28 private:
29
30 /* * * * * * * * * * * * * CONSTRUCTORS * * * * * * * * * * * * */
31 public:
32 SASensor();
33 SASensor(SSensorType type);
34 ~SASensor();
35 protected:
36 private:
37
38 /* * * * * * * * * * * * * METHODS * * * * * * * * * * * * */
39 public:
40 virtual SSensorData GetData();
41 void SetData(SSensorData newData);
42 ASensor* GetASensor();
43 void SetASensor(ASensor* aSensor);
44 Vector3d GetLinearAcceleration(Vector3d acc);
45 protected:
46 private:
47};
48
49/* CLASS NAME: SensorManager
50 * \brief Manager sensors.
51
52 * Used to list sensor objects. It is possible to manage them through this class (enable/disable, ...).
53 */
54class SASensorManager : public SSensorManager
55{
56 /* * * * * * * * * * * * * FRIENDS * * * * * * * * * * * * */
57
58 /* * * * * * * * * * * * * ATTRIBUTES * * * * * * * * * * * * */
59 public:
60 protected:
61 ASensorEventQueue* mASensorEventQueue;
62 ASensorManager* mASensorManager;
63 private:
64 static SSensorManager* mSingletonInstance;
65 boost::thread mThread;
66 bool mTerminate;
67 int mScreenOrientation;
68
69 /* * * * * * * * * * * * * CONSTRUCTORS * * * * * * * * * * * * */
70 public:
71 SASensorManager();
72 ~SASensorManager();
73 protected:
74 private:
75
76 /* * * * * * * * * * * * * METHODS * * * * * * * * * * * * */
77 public:
78 static int UpdateSensorData(int fd, int events, void* data);
79 ASensorEventQueue* GetASensorEventQueue();
80 DeviceOrientation GetScreenOrientation();
81 virtual int SetSensorEnable(SSensorType sensorType, bool state);
82 virtual void Vibrate(long millis);
83 virtual void StartVibration();
84 virtual void StopVibration();
85 virtual void VibratePattern(std::vector<int> pattern, bool loop);
86 virtual void StartLocationService();
87 virtual void StopLocationService();
88 virtual bool GetLocation(float &longitude, float &latitude, float &altitude);
89
90 void UpdateThread();
91 protected:
92 private:
93};
94
95#endif
96#endif