1/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ANDROID_ROTATION_VECTOR_SENSOR_H
18#define ANDROID_ROTATION_VECTOR_SENSOR_H
19
20#include <stdint.h>
21#include <sys/types.h>
22
23#include <gui/Sensor.h>
24
25#include "SensorDevice.h"
26#include "SensorInterface.h"
27
28#include "Fusion.h"
29#include "SensorFusion.h"
30
31// ---------------------------------------------------------------------------
32namespace android {
33// ---------------------------------------------------------------------------
34
35class RotationVectorSensor : public VirtualSensor {
36public:
37    RotationVectorSensor(int mode = FUSION_9AXIS);
38    virtual bool process(sensors_event_t* outEvent, const sensors_event_t& event) override;
39    virtual status_t activate(void* ident, bool enabled) override;
40    virtual status_t setDelay(void* ident, int handle, int64_t ns) override;
41
42protected:
43    const int mMode;
44    int getSensorType() const;
45    const char* getSensorName() const ;
46    int getSensorToken() const ;
47};
48
49class GameRotationVectorSensor : public RotationVectorSensor {
50public:
51    GameRotationVectorSensor() : RotationVectorSensor(FUSION_NOMAG) {}
52};
53
54class GeoMagRotationVectorSensor : public RotationVectorSensor {
55public:
56    GeoMagRotationVectorSensor() : RotationVectorSensor(FUSION_NOGYRO) {}
57};
58
59class GyroDriftSensor : public VirtualSensor {
60public:
61    GyroDriftSensor();
62    virtual bool process(sensors_event_t* outEvent, const sensors_event_t& event) override;
63    virtual status_t activate(void* ident, bool enabled) override;
64    virtual status_t setDelay(void* ident, int handle, int64_t ns) override;
65};
66
67// ---------------------------------------------------------------------------
68}; // namespace android
69
70#endif // ANDROID_ROTATION_VECTOR_SENSOR_H
71