OSDN Git Service

Merge remote-tracking branch 'x86/kitkat-x86' into lollipop-x86
[android-x86/hardware-intel-libsensors.git] / SynthCompassSensor.h
1 /*
2  * Copyright (C) 2013 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 HIDSENSOR_SYNTHCOMPASS_H
18 #define HIDSENSOR_SYNTHCOMPASS_H
19
20 #include "SensorIIODev.h"
21 #include "RotVecSensor.h"
22
23 class RotVecSensor;
24
25 class SynthCompassSensor : public SensorBase {
26
27 public:
28     SynthCompassSensor();
29
30     void setRotVecSensor(RotVecSensor *s) { mRotVec = s; }
31
32     // From the RotationVector sensor
33     void setQuaternion(float q[4]);
34
35     // From SensorBase:
36     virtual int open() { return mRotVec != NULL; }
37     virtual void close() {}
38     virtual int enable(int en);
39     virtual int readEvents(sensors_event_t *data, int count);
40     virtual int setDelay(int64_t ns) { return mRotVec ? mRotVec->setDelay(ns) : -1; }
41
42     static const struct sensor_t sSensorInfo_compass;
43
44  private:
45     RotVecSensor *mRotVec;
46 };
47 #endif