1e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian/*
2e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * Copyright (C) 2010 The Android Open Source Project
3e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian *
4e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * Licensed under the Apache License, Version 2.0 (the "License");
5e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * you may not use this file except in compliance with the License.
6e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * You may obtain a copy of the License at
7e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian *
8e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian *      http://www.apache.org/licenses/LICENSE-2.0
9e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian *
10e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * Unless required by applicable law or agreed to in writing, software
11e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * distributed under the License is distributed on an "AS IS" BASIS,
12e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * See the License for the specific language governing permissions and
14e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * limitations under the License.
15e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */
16e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian
17bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine/**
18bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine * @addtogroup Sensor
19bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine * @{
20bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine */
21bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine
22bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine/**
23bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine * @file sensor.h
24bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine */
25e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian
26e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian#ifndef ANDROID_SENSOR_H
27e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian#define ANDROID_SENSOR_H
28e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian
29e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian/******************************************************************
30e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian *
31e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * IMPORTANT NOTICE:
32e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian *
33e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian *   This file is part of Android's set of stable system headers
34e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian *   exposed by the Android NDK (Native Development Kit).
35e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian *
36e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian *   Third-party source AND binary code relies on the definitions
37e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian *   here to be FROZEN ON ALL UPCOMING PLATFORM RELEASES.
38e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian *
39e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian *   - DO NOT MODIFY ENUMS (EXCEPT IF YOU ADD NEW 32-BIT VALUES)
40e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian *   - DO NOT MODIFY CONSTANTS OR FUNCTIONAL MACROS
41e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian *   - DO NOT CHANGE THE SIGNATURE OF FUNCTIONS IN ANY WAY
42e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian *   - DO NOT CHANGE THE LAYOUT OR SIZE OF STRUCTURES
43e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */
44e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian
45bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine/**
46e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * Structures and functions to receive and process sensor events in
47e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * native code.
48e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian *
49e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */
50e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian
51e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian#include <sys/types.h>
52e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian
53e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian#include <android/looper.h>
54e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian
55e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian#ifdef __cplusplus
56e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopianextern "C" {
57e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian#endif
58e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian
59e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian
60bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine/**
61bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine * Sensor types.
627d319fcafba64af72c1960e4d047a39401613096Johan Euphrosine * (keep in sync with hardware/sensors.h)
63e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */
64e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopianenum {
65bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine    /**
66bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine     * {@link ASENSOR_TYPE_ACCELEROMETER}
67bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine     * reporting-mode: continuous
68bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine     *
69bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine     *  All values are in SI units (m/s^2) and measure the acceleration of the
70bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine     *  device minus the force of gravity.
71bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine     */
727d319fcafba64af72c1960e4d047a39401613096Johan Euphrosine    ASENSOR_TYPE_ACCELEROMETER       = 1,
73bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine    /**
74bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine     * {@link ASENSOR_TYPE_MAGNETIC_FIELD}
75bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine     * reporting-mode: continuous
76bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine     *
77bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine     *  All values are in micro-Tesla (uT) and measure the geomagnetic
78bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine     *  field in the X, Y and Z axis.
79bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine     */
807d319fcafba64af72c1960e4d047a39401613096Johan Euphrosine    ASENSOR_TYPE_MAGNETIC_FIELD      = 2,
81bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine    /**
82bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine     * {@link ASENSOR_TYPE_GYROSCOPE}
83bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine     * reporting-mode: continuous
84bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine     *
85bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine     *  All values are in radians/second and measure the rate of rotation
86bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine     *  around the X, Y and Z axis.
87bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine     */
887d319fcafba64af72c1960e4d047a39401613096Johan Euphrosine    ASENSOR_TYPE_GYROSCOPE           = 4,
89bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine    /**
90bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine     * {@link ASENSOR_TYPE_LIGHT}
91bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine     * reporting-mode: on-change
92bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine     *
93bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine     * The light sensor value is returned in SI lux units.
94bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine     */
957d319fcafba64af72c1960e4d047a39401613096Johan Euphrosine    ASENSOR_TYPE_LIGHT               = 5,
96bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine    /**
97bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine     * {@link ASENSOR_TYPE_PROXIMITY}
98bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine     * reporting-mode: on-change
99bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine     *
100bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine     * The proximity sensor which turns the screen off and back on during calls is the
101bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine     * wake-up proximity sensor. Implement wake-up proximity sensor before implementing
102bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine     * a non wake-up proximity sensor. For the wake-up proximity sensor set the flag
103bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine     * SENSOR_FLAG_WAKE_UP.
104bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine     * The value corresponds to the distance to the nearest object in centimeters.
105bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine     */
1067d319fcafba64af72c1960e4d047a39401613096Johan Euphrosine    ASENSOR_TYPE_PROXIMITY           = 8,
1077d319fcafba64af72c1960e4d047a39401613096Johan Euphrosine    /**
1087d319fcafba64af72c1960e4d047a39401613096Johan Euphrosine     * {@link ASENSOR_TYPE_LINEAR_ACCELERATION}
1097d319fcafba64af72c1960e4d047a39401613096Johan Euphrosine     * reporting-mode: continuous
1107d319fcafba64af72c1960e4d047a39401613096Johan Euphrosine     *
1117d319fcafba64af72c1960e4d047a39401613096Johan Euphrosine     *  All values are in SI units (m/s^2) and measure the acceleration of the
1127d319fcafba64af72c1960e4d047a39401613096Johan Euphrosine     *  device not including the force of gravity.
1137d319fcafba64af72c1960e4d047a39401613096Johan Euphrosine     */
1147d319fcafba64af72c1960e4d047a39401613096Johan Euphrosine    ASENSOR_TYPE_LINEAR_ACCELERATION = 10
115e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian};
116e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian
117bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine/**
118bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine * Sensor accuracy measure.
119e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */
120e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopianenum {
121bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine    /** no contact */
122630e31d6ed539f5193fd20dde6c5afa58bd34a73Etienne Le Grand    ASENSOR_STATUS_NO_CONTACT       = -1,
123bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine    /** unreliable */
124e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian    ASENSOR_STATUS_UNRELIABLE       = 0,
125bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine    /** low accuracy */
126e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian    ASENSOR_STATUS_ACCURACY_LOW     = 1,
127bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine    /** medium accuracy */
128e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian    ASENSOR_STATUS_ACCURACY_MEDIUM  = 2,
129bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine    /** high accuracy */
130e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian    ASENSOR_STATUS_ACCURACY_HIGH    = 3
131e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian};
132e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian
133bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine/**
1340e025c5af365e45e02cb75c1d46b46c7f4cd44cbAravind Akella * Sensor Reporting Modes.
1350e025c5af365e45e02cb75c1d46b46c7f4cd44cbAravind Akella */
1360e025c5af365e45e02cb75c1d46b46c7f4cd44cbAravind Akellaenum {
137bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine    /** continuous reporting */
1380e025c5af365e45e02cb75c1d46b46c7f4cd44cbAravind Akella    AREPORTING_MODE_CONTINUOUS = 0,
139bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine    /** reporting on change */
1400e025c5af365e45e02cb75c1d46b46c7f4cd44cbAravind Akella    AREPORTING_MODE_ON_CHANGE = 1,
141bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine    /** on shot reporting */
1420e025c5af365e45e02cb75c1d46b46c7f4cd44cbAravind Akella    AREPORTING_MODE_ONE_SHOT = 2,
143bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine    /** special trigger reporting */
1440e025c5af365e45e02cb75c1d46b46c7f4cd44cbAravind Akella    AREPORTING_MODE_SPECIAL_TRIGGER = 3
1450e025c5af365e45e02cb75c1d46b46c7f4cd44cbAravind Akella};
1460e025c5af365e45e02cb75c1d46b46c7f4cd44cbAravind Akella
1470e025c5af365e45e02cb75c1d46b46c7f4cd44cbAravind Akella/*
148e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * A few useful constants
149e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */
150e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian
151bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine/** Earth's gravity in m/s^2 */
152e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian#define ASENSOR_STANDARD_GRAVITY            (9.80665f)
153bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine/** Maximum magnetic field on Earth's surface in uT */
154e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian#define ASENSOR_MAGNETIC_FIELD_EARTH_MAX    (60.0f)
155bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine/** Minimum magnetic field on Earth's surface in uT*/
156e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian#define ASENSOR_MAGNETIC_FIELD_EARTH_MIN    (30.0f)
157e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian
158bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine/**
159e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * A sensor event.
160e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */
161e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian
162e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian/* NOTE: Must match hardware/sensors.h */
163e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopiantypedef struct ASensorVector {
164e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian    union {
165e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian        float v[3];
166e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian        struct {
167e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian            float x;
168e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian            float y;
169e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian            float z;
170e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian        };
171e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian        struct {
172e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian            float azimuth;
173e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian            float pitch;
174e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian            float roll;
175e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian        };
176e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian    };
177e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian    int8_t status;
178e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian    uint8_t reserved[3];
179e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian} ASensorVector;
180e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian
181724d91d778e71c8186399f4955de14b54812b3edAravind Akellatypedef struct AMetaDataEvent {
182724d91d778e71c8186399f4955de14b54812b3edAravind Akella    int32_t what;
183724d91d778e71c8186399f4955de14b54812b3edAravind Akella    int32_t sensor;
184724d91d778e71c8186399f4955de14b54812b3edAravind Akella} AMetaDataEvent;
185724d91d778e71c8186399f4955de14b54812b3edAravind Akella
186724d91d778e71c8186399f4955de14b54812b3edAravind Akellatypedef struct AUncalibratedEvent {
1879e72046f399f13dfeb5ed0cb32343ca6697f52f5Peng Xu    union {
1889e72046f399f13dfeb5ed0cb32343ca6697f52f5Peng Xu        float uncalib[3];
1899e72046f399f13dfeb5ed0cb32343ca6697f52f5Peng Xu        struct {
1909e72046f399f13dfeb5ed0cb32343ca6697f52f5Peng Xu            float x_uncalib;
1919e72046f399f13dfeb5ed0cb32343ca6697f52f5Peng Xu            float y_uncalib;
1929e72046f399f13dfeb5ed0cb32343ca6697f52f5Peng Xu            float z_uncalib;
1939e72046f399f13dfeb5ed0cb32343ca6697f52f5Peng Xu        };
194724d91d778e71c8186399f4955de14b54812b3edAravind Akella    };
1959e72046f399f13dfeb5ed0cb32343ca6697f52f5Peng Xu    union {
1969e72046f399f13dfeb5ed0cb32343ca6697f52f5Peng Xu        float bias[3];
1979e72046f399f13dfeb5ed0cb32343ca6697f52f5Peng Xu        struct {
1989e72046f399f13dfeb5ed0cb32343ca6697f52f5Peng Xu            float x_bias;
1999e72046f399f13dfeb5ed0cb32343ca6697f52f5Peng Xu            float y_bias;
2009e72046f399f13dfeb5ed0cb32343ca6697f52f5Peng Xu            float z_bias;
2019e72046f399f13dfeb5ed0cb32343ca6697f52f5Peng Xu        };
202724d91d778e71c8186399f4955de14b54812b3edAravind Akella    };
203724d91d778e71c8186399f4955de14b54812b3edAravind Akella} AUncalibratedEvent;
204724d91d778e71c8186399f4955de14b54812b3edAravind Akella
205630e31d6ed539f5193fd20dde6c5afa58bd34a73Etienne Le Grandtypedef struct AHeartRateEvent {
2069e72046f399f13dfeb5ed0cb32343ca6697f52f5Peng Xu    float bpm;
2079e72046f399f13dfeb5ed0cb32343ca6697f52f5Peng Xu    int8_t status;
208630e31d6ed539f5193fd20dde6c5afa58bd34a73Etienne Le Grand} AHeartRateEvent;
209630e31d6ed539f5193fd20dde6c5afa58bd34a73Etienne Le Grand
2102576cb63b3fe1592f54816625036566b9eb0793aPeng Xutypedef struct ADynamicSensorEvent {
2119e72046f399f13dfeb5ed0cb32343ca6697f52f5Peng Xu    int32_t  connected;
2129e72046f399f13dfeb5ed0cb32343ca6697f52f5Peng Xu    int32_t  handle;
2132576cb63b3fe1592f54816625036566b9eb0793aPeng Xu} ADynamicSensorEvent;
2142576cb63b3fe1592f54816625036566b9eb0793aPeng Xu
2159e72046f399f13dfeb5ed0cb32343ca6697f52f5Peng Xutypedef struct {
2169e72046f399f13dfeb5ed0cb32343ca6697f52f5Peng Xu    int32_t type;
2179e72046f399f13dfeb5ed0cb32343ca6697f52f5Peng Xu    int32_t serial;
2189e72046f399f13dfeb5ed0cb32343ca6697f52f5Peng Xu    union {
2199e72046f399f13dfeb5ed0cb32343ca6697f52f5Peng Xu        int32_t data_int32[14];
2209e72046f399f13dfeb5ed0cb32343ca6697f52f5Peng Xu        float   data_float[14];
2219e72046f399f13dfeb5ed0cb32343ca6697f52f5Peng Xu    };
2229e72046f399f13dfeb5ed0cb32343ca6697f52f5Peng Xu} AAdditionalInfoEvent;
2239e72046f399f13dfeb5ed0cb32343ca6697f52f5Peng Xu
224e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian/* NOTE: Must match hardware/sensors.h */
225e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopiantypedef struct ASensorEvent {
226e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian    int32_t version; /* sizeof(struct ASensorEvent) */
227e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian    int32_t sensor;
228e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian    int32_t type;
229e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian    int32_t reserved0;
230e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian    int64_t timestamp;
231e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian    union {
232ba02cd2f6cc3f59adf66cb2b9176bfe6c9e382d1Mathias Agopian        union {
233ba02cd2f6cc3f59adf66cb2b9176bfe6c9e382d1Mathias Agopian            float           data[16];
234ba02cd2f6cc3f59adf66cb2b9176bfe6c9e382d1Mathias Agopian            ASensorVector   vector;
235ba02cd2f6cc3f59adf66cb2b9176bfe6c9e382d1Mathias Agopian            ASensorVector   acceleration;
236ba02cd2f6cc3f59adf66cb2b9176bfe6c9e382d1Mathias Agopian            ASensorVector   magnetic;
237ba02cd2f6cc3f59adf66cb2b9176bfe6c9e382d1Mathias Agopian            float           temperature;
238ba02cd2f6cc3f59adf66cb2b9176bfe6c9e382d1Mathias Agopian            float           distance;
239ba02cd2f6cc3f59adf66cb2b9176bfe6c9e382d1Mathias Agopian            float           light;
240ba02cd2f6cc3f59adf66cb2b9176bfe6c9e382d1Mathias Agopian            float           pressure;
241724d91d778e71c8186399f4955de14b54812b3edAravind Akella            float           relative_humidity;
242724d91d778e71c8186399f4955de14b54812b3edAravind Akella            AUncalibratedEvent uncalibrated_gyro;
243724d91d778e71c8186399f4955de14b54812b3edAravind Akella            AUncalibratedEvent uncalibrated_magnetic;
244724d91d778e71c8186399f4955de14b54812b3edAravind Akella            AMetaDataEvent meta_data;
245630e31d6ed539f5193fd20dde6c5afa58bd34a73Etienne Le Grand            AHeartRateEvent heart_rate;
2462576cb63b3fe1592f54816625036566b9eb0793aPeng Xu            ADynamicSensorEvent dynamic_sensor_meta;
2479e72046f399f13dfeb5ed0cb32343ca6697f52f5Peng Xu            AAdditionalInfoEvent additional_info;
248ba02cd2f6cc3f59adf66cb2b9176bfe6c9e382d1Mathias Agopian        };
249ba02cd2f6cc3f59adf66cb2b9176bfe6c9e382d1Mathias Agopian        union {
250ba02cd2f6cc3f59adf66cb2b9176bfe6c9e382d1Mathias Agopian            uint64_t        data[8];
251ba02cd2f6cc3f59adf66cb2b9176bfe6c9e382d1Mathias Agopian            uint64_t        step_counter;
252ba02cd2f6cc3f59adf66cb2b9176bfe6c9e382d1Mathias Agopian        } u64;
253e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian    };
2549a844cf78f09953145200b4074d47589257a408cAravind Akella
2559a844cf78f09953145200b4074d47589257a408cAravind Akella    uint32_t flags;
2569a844cf78f09953145200b4074d47589257a408cAravind Akella    int32_t reserved1[3];
257e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian} ASensorEvent;
258e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian
259e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopianstruct ASensorManager;
260bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine/**
261bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine * {@link ASensorManager} is an opaque type to manage sensors and
262bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine * events queues.
263bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine *
264bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine * {@link ASensorManager} is a singleton that can be obtained using
265bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine * ASensorManager_getInstance().
266bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine *
267bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine * This file provides a set of functions that uses {@link
268bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine * ASensorManager} to access and list hardware sensors, and
269bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine * create and destroy event queues:
270bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine * - ASensorManager_getSensorList()
271bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine * - ASensorManager_getDefaultSensor()
272bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine * - ASensorManager_getDefaultSensorEx()
273bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine * - ASensorManager_createEventQueue()
274bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine * - ASensorManager_destroyEventQueue()
275bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine */
276e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopiantypedef struct ASensorManager ASensorManager;
277e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian
278bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine
279e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopianstruct ASensorEventQueue;
280bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine/**
281bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine * {@link ASensorEventQueue} is an opaque type that provides access to
282bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine * {@link ASensorEvent} from hardware sensors.
283bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine *
284bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine * A new {@link ASensorEventQueue} can be obtained using ASensorManager_createEventQueue().
285bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine *
286bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine * This file provides a set of functions to enable and disable
287bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine * sensors, check and get events, and set event rates on a {@link
288bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine * ASensorEventQueue}.
289bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine * - ASensorEventQueue_enableSensor()
290bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine * - ASensorEventQueue_disableSensor()
291bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine * - ASensorEventQueue_hasEvents()
292bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine * - ASensorEventQueue_getEvents()
293bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine * - ASensorEventQueue_setEventRate()
294bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine */
295e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopiantypedef struct ASensorEventQueue ASensorEventQueue;
296e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian
297e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopianstruct ASensor;
298bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine/**
299bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine * {@link ASensor} is an opaque type that provides information about
300bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine * an hardware sensors.
301bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine *
302bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine * A {@link ASensor} pointer can be obtained using
303bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine * ASensorManager_getDefaultSensor(),
304bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine * ASensorManager_getDefaultSensorEx() or from a {@link ASensorList}.
305bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine *
306bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine * This file provides a set of functions to access properties of a
307bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine * {@link ASensor}:
308bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine * - ASensor_getName()
309bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine * - ASensor_getVendor()
310bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine * - ASensor_getType()
311bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine * - ASensor_getResolution()
312bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine * - ASensor_getMinDelay()
313bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine * - ASensor_getFifoMaxEventCount()
314bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine * - ASensor_getFifoReservedEventCount()
315bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine * - ASensor_getStringType()
316bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine * - ASensor_getReportingMode()
317bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine * - ASensor_isWakeUpSensor()
318bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine */
319e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopiantypedef struct ASensor ASensor;
320bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine/**
321bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine * {@link ASensorRef} is a type for constant pointers to {@link ASensor}.
322bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine *
323bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine * This is used to define entry in {@link ASensorList} arrays.
324bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine */
325e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopiantypedef ASensor const* ASensorRef;
326bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine/**
327bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine * {@link ASensorList} is an array of reference to {@link ASensor}.
328bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine *
329bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine * A {@link ASensorList} can be initialized using ASensorManager_getSensorList().
330bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine */
331e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopiantypedef ASensorRef const* ASensorList;
332e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian
333e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian/*****************************************************************************/
334e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian
335bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine/**
3365fa32d4b08843d0aeca567a173227e8e37322e8eSvet Ganov * Get a reference to the sensor manager. ASensorManager is a singleton
3375fa32d4b08843d0aeca567a173227e8e37322e8eSvet Ganov * per package as different packages may have access to different sensors.
3385fa32d4b08843d0aeca567a173227e8e37322e8eSvet Ganov *
3395fa32d4b08843d0aeca567a173227e8e37322e8eSvet Ganov * Deprecated: Use ASensorManager_getInstanceForPackage(const char*) instead.
3405fa32d4b08843d0aeca567a173227e8e37322e8eSvet Ganov *
3415fa32d4b08843d0aeca567a173227e8e37322e8eSvet Ganov * Example:
3425fa32d4b08843d0aeca567a173227e8e37322e8eSvet Ganov *
3435fa32d4b08843d0aeca567a173227e8e37322e8eSvet Ganov *     ASensorManager* sensorManager = ASensorManager_getInstance();
3445fa32d4b08843d0aeca567a173227e8e37322e8eSvet Ganov *
3455fa32d4b08843d0aeca567a173227e8e37322e8eSvet Ganov */
3465fa32d4b08843d0aeca567a173227e8e37322e8eSvet Ganov__attribute__ ((deprecated)) ASensorManager* ASensorManager_getInstance();
3475fa32d4b08843d0aeca567a173227e8e37322e8eSvet Ganov
3485fa32d4b08843d0aeca567a173227e8e37322e8eSvet Ganov/*
3495fa32d4b08843d0aeca567a173227e8e37322e8eSvet Ganov * Get a reference to the sensor manager. ASensorManager is a singleton
3505fa32d4b08843d0aeca567a173227e8e37322e8eSvet Ganov * per package as different packages may have access to different sensors.
3515fa32d4b08843d0aeca567a173227e8e37322e8eSvet Ganov *
3525fa32d4b08843d0aeca567a173227e8e37322e8eSvet Ganov * Example:
3535fa32d4b08843d0aeca567a173227e8e37322e8eSvet Ganov *
3545fa32d4b08843d0aeca567a173227e8e37322e8eSvet Ganov *    ASensorManager* sensorManager = ASensorManager_getInstanceForPackage("foo.bar.baz");
3555fa32d4b08843d0aeca567a173227e8e37322e8eSvet Ganov *
3565fa32d4b08843d0aeca567a173227e8e37322e8eSvet Ganov */
3575fa32d4b08843d0aeca567a173227e8e37322e8eSvet GanovASensorManager* ASensorManager_getInstanceForPackage(const char* packageName);
3585fa32d4b08843d0aeca567a173227e8e37322e8eSvet Ganov
359bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine/**
360e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * Returns the list of available sensors.
361e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */
362e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopianint ASensorManager_getSensorList(ASensorManager* manager, ASensorList* list);
363e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian
364bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine/**
365e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * Returns the default sensor for the given type, or NULL if no sensor
366b37ba399c1521c3eba40e126f65d9663532de446Aravind Akella * of that type exists.
367e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */
368e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias AgopianASensor const* ASensorManager_getDefaultSensor(ASensorManager* manager, int type);
369e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian
370bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine/**
371b37ba399c1521c3eba40e126f65d9663532de446Aravind Akella * Returns the default sensor with the given type and wakeUp properties or NULL if no sensor
372b37ba399c1521c3eba40e126f65d9663532de446Aravind Akella * of this type and wakeUp properties exists.
373b37ba399c1521c3eba40e126f65d9663532de446Aravind Akella */
374b37ba399c1521c3eba40e126f65d9663532de446Aravind AkellaASensor const* ASensorManager_getDefaultSensorEx(ASensorManager* manager, int type,
375b37ba399c1521c3eba40e126f65d9663532de446Aravind Akella        bool wakeUp);
376b37ba399c1521c3eba40e126f65d9663532de446Aravind Akella
377bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine/**
378e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * Creates a new sensor event queue and associate it with a looper.
379bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine *
380bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine * "ident" is a identifier for the events that will be returned when
381bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine * calling ALooper_pollOnce(). The identifier must be >= 0, or
382bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine * ALOOPER_POLL_CALLBACK if providing a non-NULL callback.
383e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */
384e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias AgopianASensorEventQueue* ASensorManager_createEventQueue(ASensorManager* manager,
385e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian        ALooper* looper, int ident, ALooper_callbackFunc callback, void* data);
386e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian
387bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine/**
388e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * Destroys the event queue and free all resources associated to it.
389e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */
390e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopianint ASensorManager_destroyEventQueue(ASensorManager* manager, ASensorEventQueue* queue);
391e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian
392e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian
393e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian/*****************************************************************************/
394e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian
395bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine/**
396da94fd86475d1ef417eb5a953806d307f2779489Aniroop Mathur * Enable the selected sensor with a specified sampling period and max batch report latency.
397da94fd86475d1ef417eb5a953806d307f2779489Aniroop Mathur * Returns a negative error code on failure.
398da94fd86475d1ef417eb5a953806d307f2779489Aniroop Mathur */
399da94fd86475d1ef417eb5a953806d307f2779489Aniroop Mathurint ASensorEventQueue_registerSensor(ASensorEventQueue* queue, ASensor const* sensor,
400da94fd86475d1ef417eb5a953806d307f2779489Aniroop Mathur        int32_t samplingPeriodUs, int maxBatchReportLatencyUs);
401da94fd86475d1ef417eb5a953806d307f2779489Aniroop Mathur
402da94fd86475d1ef417eb5a953806d307f2779489Aniroop Mathur/**
403e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * Enable the selected sensor. Returns a negative error code on failure.
404e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */
405e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopianint ASensorEventQueue_enableSensor(ASensorEventQueue* queue, ASensor const* sensor);
406e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian
407bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine/**
408e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * Disable the selected sensor. Returns a negative error code on failure.
409e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */
410e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopianint ASensorEventQueue_disableSensor(ASensorEventQueue* queue, ASensor const* sensor);
411e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian
412bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine/**
413e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * Sets the delivery rate of events in microseconds for the given sensor.
414e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * Note that this is a hint only, generally event will arrive at a higher
415e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * rate. It is an error to set a rate inferior to the value returned by
416e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * ASensor_getMinDelay().
417e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * Returns a negative error code on failure.
418e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */
419e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopianint ASensorEventQueue_setEventRate(ASensorEventQueue* queue, ASensor const* sensor, int32_t usec);
420e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian
421bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine/**
422e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * Returns true if there are one or more events available in the
423e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * sensor queue.  Returns 1 if the queue has events; 0 if
424e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * it does not have events; and a negative value if there is an error.
425e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */
426e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopianint ASensorEventQueue_hasEvents(ASensorEventQueue* queue);
427e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian
428bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine/**
429e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * Returns the next available events from the queue.  Returns a negative
430e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * value if no events are available or an error has occurred, otherwise
431e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * the number of events returned.
432e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian *
433e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * Examples:
434e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian *   ASensorEvent event;
435e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian *   ssize_t numEvent = ASensorEventQueue_getEvents(queue, &event, 1);
436e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian *
437e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian *   ASensorEvent eventBuffer[8];
438e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian *   ssize_t numEvent = ASensorEventQueue_getEvents(queue, eventBuffer, 8);
439e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian *
440e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */
441e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopianssize_t ASensorEventQueue_getEvents(ASensorEventQueue* queue,
442e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian                ASensorEvent* events, size_t count);
443e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian
444e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian
445e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian/*****************************************************************************/
446e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian
447bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine/**
448e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * Returns this sensor's name (non localized)
449e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */
450e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopianconst char* ASensor_getName(ASensor const* sensor);
451e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian
452bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine/**
453e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * Returns this sensor's vendor's name (non localized)
454e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */
455e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopianconst char* ASensor_getVendor(ASensor const* sensor);
456e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian
457bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine/**
458e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * Return this sensor's type
459e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */
460e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopianint ASensor_getType(ASensor const* sensor);
461e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian
462bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine/**
463e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * Returns this sensors's resolution
464e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */
465e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopianfloat ASensor_getResolution(ASensor const* sensor);
466e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian
467bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine/**
468e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * Returns the minimum delay allowed between events in microseconds.
469e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * A value of zero means that this sensor doesn't report events at a
470e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian * constant rate, but rather only when a new data is available.
471e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian */
472e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopianint ASensor_getMinDelay(ASensor const* sensor);
473e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian
474bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine/**
475700180487ffec09d9df1657b018a7caadac24b75Aravind Akella * Returns the maximum size of batches for this sensor. Batches will often be
476700180487ffec09d9df1657b018a7caadac24b75Aravind Akella * smaller, as the hardware fifo might be used for other sensors.
477700180487ffec09d9df1657b018a7caadac24b75Aravind Akella */
478700180487ffec09d9df1657b018a7caadac24b75Aravind Akellaint ASensor_getFifoMaxEventCount(ASensor const* sensor);
479700180487ffec09d9df1657b018a7caadac24b75Aravind Akella
480bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine/**
481700180487ffec09d9df1657b018a7caadac24b75Aravind Akella * Returns the hardware batch fifo size reserved to this sensor.
482700180487ffec09d9df1657b018a7caadac24b75Aravind Akella */
483700180487ffec09d9df1657b018a7caadac24b75Aravind Akellaint ASensor_getFifoReservedEventCount(ASensor const* sensor);
484700180487ffec09d9df1657b018a7caadac24b75Aravind Akella
485bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine/**
486700180487ffec09d9df1657b018a7caadac24b75Aravind Akella * Returns this sensor's string type.
487700180487ffec09d9df1657b018a7caadac24b75Aravind Akella */
488700180487ffec09d9df1657b018a7caadac24b75Aravind Akellaconst char* ASensor_getStringType(ASensor const* sensor);
489700180487ffec09d9df1657b018a7caadac24b75Aravind Akella
490bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine/**
4910e025c5af365e45e02cb75c1d46b46c7f4cd44cbAravind Akella * Returns the reporting mode for this sensor. One of AREPORTING_MODE_* constants.
4920e025c5af365e45e02cb75c1d46b46c7f4cd44cbAravind Akella */
4930e025c5af365e45e02cb75c1d46b46c7f4cd44cbAravind Akellaint ASensor_getReportingMode(ASensor const* sensor);
4940e025c5af365e45e02cb75c1d46b46c7f4cd44cbAravind Akella
495bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine/**
496b37ba399c1521c3eba40e126f65d9663532de446Aravind Akella * Returns true if this is a wake up sensor, false otherwise.
497b37ba399c1521c3eba40e126f65d9663532de446Aravind Akella */
498b37ba399c1521c3eba40e126f65d9663532de446Aravind Akellabool ASensor_isWakeUpSensor(ASensor const* sensor);
499b37ba399c1521c3eba40e126f65d9663532de446Aravind Akella
500e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian#ifdef __cplusplus
501e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian};
502e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian#endif
503e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian
504e1c61d3cc8458ce9a15d8109f728e60f5248939dMathias Agopian#endif // ANDROID_SENSOR_H
505bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine
506bf6d5e012cd9b15568c2351831f3349cf564bf18Johan Euphrosine/** @} */
507