1f001c92436b4a66eb7687286325ced7f10c9f917Mathias Agopian/* 2f001c92436b4a66eb7687286325ced7f10c9f917Mathias Agopian * Copyright (C) 2010 The Android Open Source Project 3f001c92436b4a66eb7687286325ced7f10c9f917Mathias Agopian * 4f001c92436b4a66eb7687286325ced7f10c9f917Mathias Agopian * Licensed under the Apache License, Version 2.0 (the "License"); 5f001c92436b4a66eb7687286325ced7f10c9f917Mathias Agopian * you may not use this file except in compliance with the License. 6f001c92436b4a66eb7687286325ced7f10c9f917Mathias Agopian * You may obtain a copy of the License at 7f001c92436b4a66eb7687286325ced7f10c9f917Mathias Agopian * 8f001c92436b4a66eb7687286325ced7f10c9f917Mathias Agopian * http://www.apache.org/licenses/LICENSE-2.0 9f001c92436b4a66eb7687286325ced7f10c9f917Mathias Agopian * 10f001c92436b4a66eb7687286325ced7f10c9f917Mathias Agopian * Unless required by applicable law or agreed to in writing, software 11f001c92436b4a66eb7687286325ced7f10c9f917Mathias Agopian * distributed under the License is distributed on an "AS IS" BASIS, 12f001c92436b4a66eb7687286325ced7f10c9f917Mathias Agopian * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13f001c92436b4a66eb7687286325ced7f10c9f917Mathias Agopian * See the License for the specific language governing permissions and 14f001c92436b4a66eb7687286325ced7f10c9f917Mathias Agopian * limitations under the License. 15f001c92436b4a66eb7687286325ced7f10c9f917Mathias Agopian */ 16f001c92436b4a66eb7687286325ced7f10c9f917Mathias Agopian 17f001c92436b4a66eb7687286325ced7f10c9f917Mathias Agopian#ifndef ANDROID_ROTATION_VECTOR_SENSOR_H 18f001c92436b4a66eb7687286325ced7f10c9f917Mathias Agopian#define ANDROID_ROTATION_VECTOR_SENSOR_H 19f001c92436b4a66eb7687286325ced7f10c9f917Mathias Agopian 20f001c92436b4a66eb7687286325ced7f10c9f917Mathias Agopian#include <stdint.h> 21f001c92436b4a66eb7687286325ced7f10c9f917Mathias Agopian#include <sys/types.h> 22f001c92436b4a66eb7687286325ced7f10c9f917Mathias Agopian 23f001c92436b4a66eb7687286325ced7f10c9f917Mathias Agopian#include <gui/Sensor.h> 24f001c92436b4a66eb7687286325ced7f10c9f917Mathias Agopian 25f001c92436b4a66eb7687286325ced7f10c9f917Mathias Agopian#include "SensorDevice.h" 26f001c92436b4a66eb7687286325ced7f10c9f917Mathias Agopian#include "SensorInterface.h" 27f001c92436b4a66eb7687286325ced7f10c9f917Mathias Agopian 28984826cc158193e61e3a00359ef4f6699c7d748aMathias Agopian#include "Fusion.h" 29984826cc158193e61e3a00359ef4f6699c7d748aMathias Agopian#include "SensorFusion.h" 30984826cc158193e61e3a00359ef4f6699c7d748aMathias Agopian 31f001c92436b4a66eb7687286325ced7f10c9f917Mathias Agopian// --------------------------------------------------------------------------- 32f001c92436b4a66eb7687286325ced7f10c9f917Mathias Agopiannamespace android { 33f001c92436b4a66eb7687286325ced7f10c9f917Mathias Agopian// --------------------------------------------------------------------------- 34f001c92436b4a66eb7687286325ced7f10c9f917Mathias Agopian 35755c451c7861a029e26e5f16e319b629169e656dPeng Xuclass RotationVectorSensor : public VirtualSensor { 36f001c92436b4a66eb7687286325ced7f10c9f917Mathias Agopianpublic: 37f66684a6fb2a2991e84a085673629db2a0494fc6Peng Xu RotationVectorSensor(int mode = FUSION_9AXIS); 380cc8f809924706c7d683da30605f432635dd5bb6Peng Xu virtual bool process(sensors_event_t* outEvent, const sensors_event_t& event) override; 390cc8f809924706c7d683da30605f432635dd5bb6Peng Xu virtual status_t activate(void* ident, bool enabled) override; 400cc8f809924706c7d683da30605f432635dd5bb6Peng Xu virtual status_t setDelay(void* ident, int handle, int64_t ns) override; 41755c451c7861a029e26e5f16e319b629169e656dPeng Xu 42755c451c7861a029e26e5f16e319b629169e656dPeng Xuprotected: 43755c451c7861a029e26e5f16e319b629169e656dPeng Xu const int mMode; 44755c451c7861a029e26e5f16e319b629169e656dPeng Xu int getSensorType() const; 45755c451c7861a029e26e5f16e319b629169e656dPeng Xu const char* getSensorName() const ; 46755c451c7861a029e26e5f16e319b629169e656dPeng Xu int getSensorToken() const ; 47f001c92436b4a66eb7687286325ced7f10c9f917Mathias Agopian}; 48f001c92436b4a66eb7687286325ced7f10c9f917Mathias Agopian 49f66684a6fb2a2991e84a085673629db2a0494fc6Peng Xuclass GameRotationVectorSensor : public RotationVectorSensor { 50f66684a6fb2a2991e84a085673629db2a0494fc6Peng Xupublic: 51f66684a6fb2a2991e84a085673629db2a0494fc6Peng Xu GameRotationVectorSensor() : RotationVectorSensor(FUSION_NOMAG) {} 52f66684a6fb2a2991e84a085673629db2a0494fc6Peng Xu}; 53f66684a6fb2a2991e84a085673629db2a0494fc6Peng Xu 54f66684a6fb2a2991e84a085673629db2a0494fc6Peng Xuclass GeoMagRotationVectorSensor : public RotationVectorSensor { 55f66684a6fb2a2991e84a085673629db2a0494fc6Peng Xupublic: 56f66684a6fb2a2991e84a085673629db2a0494fc6Peng Xu GeoMagRotationVectorSensor() : RotationVectorSensor(FUSION_NOGYRO) {} 57f66684a6fb2a2991e84a085673629db2a0494fc6Peng Xu}; 58f66684a6fb2a2991e84a085673629db2a0494fc6Peng Xu 59755c451c7861a029e26e5f16e319b629169e656dPeng Xuclass GyroDriftSensor : public VirtualSensor { 603301542828febc768e1df42892cfac4992c35474Mathias Agopianpublic: 613301542828febc768e1df42892cfac4992c35474Mathias Agopian GyroDriftSensor(); 620cc8f809924706c7d683da30605f432635dd5bb6Peng Xu virtual bool process(sensors_event_t* outEvent, const sensors_event_t& event) override; 630cc8f809924706c7d683da30605f432635dd5bb6Peng Xu virtual status_t activate(void* ident, bool enabled) override; 640cc8f809924706c7d683da30605f432635dd5bb6Peng Xu virtual status_t setDelay(void* ident, int handle, int64_t ns) override; 653301542828febc768e1df42892cfac4992c35474Mathias Agopian}; 663301542828febc768e1df42892cfac4992c35474Mathias Agopian 67f001c92436b4a66eb7687286325ced7f10c9f917Mathias Agopian// --------------------------------------------------------------------------- 68f001c92436b4a66eb7687286325ced7f10c9f917Mathias Agopian}; // namespace android 69f001c92436b4a66eb7687286325ced7f10c9f917Mathias Agopian 70f001c92436b4a66eb7687286325ced7f10c9f917Mathias Agopian#endif // ANDROID_ROTATION_VECTOR_SENSOR_H 71