1 /* Copyright (C) 2009 The Android Open Source Project 2 ** 3 ** This software is licensed under the terms of the GNU General Public 4 ** License version 2, as published by the Free Software Foundation, and 5 ** may be copied, distributed, and modified under those terms. 6 ** 7 ** This program is distributed in the hope that it will be useful, 8 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 9 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 ** GNU General Public License for more details. 11 */ 12 #ifndef _android_sensors_h 13 #define _android_sensors_h 14 15 #include "qemu-common.h" 16 17 /* initialize sensor emulation */ 18 extern void android_hw_sensors_init( void ); 19 20 /* NOTE: Sensor status Error definition, It will be used in the Sensors Command 21 * part in android/console.c. Details: 22 * SENSOR_STATUS_NO_SERVICE: "sensors" qemud service is not available/initiated. 23 * SENSOR_STATUS_DISABLED: sensor is disabled. 24 * SENSOR_STATUS_UNKNOWN: wrong sensor name. 25 * SENSOR_STATUS_OK: Everything is OK to the current sensor. 26 * */ 27 typedef enum{ 28 SENSOR_STATUS_NO_SERVICE = -3, 29 SENSOR_STATUS_DISABLED = -2, 30 SENSOR_STATUS_UNKNOWN = -1, 31 SENSOR_STATUS_OK = 0, 32 } SensorStatus; 33 34 /* NOTE: this list must be the same that the one defined in 35 * the sensors_qemu.c source of the libsensors.goldfish.so 36 * library. 37 * 38 * DO NOT CHANGE THE ORDER IN THIS LIST, UNLESS YOU INTEND 39 * TO BREAK SNAPSHOTS! 40 */ 41 #define SENSORS_LIST \ 42 SENSOR_(ACCELERATION,"acceleration") \ 43 SENSOR_(MAGNETIC_FIELD,"magnetic-field") \ 44 SENSOR_(ORIENTATION,"orientation") \ 45 SENSOR_(TEMPERATURE,"temperature") \ 46 SENSOR_(PROXIMITY,"proximity") \ 47 48 typedef enum { 49 #define SENSOR_(x,y) ANDROID_SENSOR_##x, 50 SENSORS_LIST 51 #undef SENSOR_ 52 MAX_SENSORS /* do not remove */ 53 } AndroidSensor; 54 55 extern void android_hw_sensor_enable( AndroidSensor sensor ); 56 57 /* COARSE ORIENTATION VALUES */ 58 typedef enum { 59 ANDROID_COARSE_PORTRAIT, 60 ANDROID_COARSE_LANDSCAPE 61 } AndroidCoarseOrientation; 62 63 /* change the coarse orientation value */ 64 extern void android_sensors_set_coarse_orientation( AndroidCoarseOrientation orient ); 65 66 /* get sensor values */ 67 extern int android_sensors_get( int sensor_id, float* a, float* b, float* c ); 68 69 /* set sensor values */ 70 extern int android_sensors_set( int sensor_id, float a, float b, float c ); 71 72 /* Get sensor id from sensor name */ 73 extern int android_sensors_get_id_from_name( char* sensorname ); 74 75 /* Get sensor name from sensor id */ 76 extern const char* android_sensors_get_name_from_id( int sensor_id ); 77 78 /* Get sensor from sensor id */ 79 extern uint8_t android_sensors_get_sensor_status( int sensor_id ); 80 81 #endif /* _android_gps_h */ 82