Android-cuttlefish cvd tool
sensors.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2025 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#pragma once
17
18namespace cuttlefish {
19namespace sensors {
20/*
21 These must align with Goldfish sensor IDs as we reuse Goldfish sensor HAL
22 library for Cuttlefish sensor HAL. (See
23 `device/generic/goldfish/hals/sensors/sensor_list.h`.)
24*/
25inline constexpr int kAccelerationId = 0;
26inline constexpr int kGyroscopeId = 1;
27inline constexpr int kMagneticId = 2;
28inline constexpr int kTemperatureId = 4;
29inline constexpr int kProximityId = 5;
30inline constexpr int kLightId = 6;
31inline constexpr int kPressureId = 7;
32inline constexpr int kHumidityId = 8;
33inline constexpr int kUncalibMagneticId = 9;
34inline constexpr int kUncalibGyroscopeId = 10;
35inline constexpr int kHingeAngle0Id = 11;
36inline constexpr int kUncalibAccelerationId = 17;
37inline constexpr int kSensorHandleLowLatencyOffBodyDetect = 19;
38/*
39 This is reserved specifically for Cuttlefish to identify the device
40 orientation relative to the East-North-Up coordinates frame. This is
41 not really a sensor but rather input from web UI for us to calculate
42 IMU readings.
43*/
44inline constexpr int kRotationVecId = 31;
45inline constexpr int kMaxSensorId = 31;
46
47/*
48 Each sensor ID also represent a bit offset for an app to specify sensors
49 via a bitmask.
50*/
51using SensorsMask = int;
52
53inline constexpr char INNER_DELIM = ':';
54inline constexpr char OUTER_DELIM = ' ';
55
56/* Sensors Commands */
57inline constexpr int kUpdateRotationVec = 0;
58inline constexpr int kGetSensorsData = 1;
59inline constexpr int kUpdateHal = 2;
60inline constexpr int kUpdateHingeAngle = 3;
61
62using SensorsCmd = int;
63
64} // namespace sensors
65} // namespace cuttlefish
constexpr int kSensorHandleLowLatencyOffBodyDetect
Definition: sensors.h:37
constexpr int kRotationVecId
Definition: sensors.h:44
constexpr int kMaxSensorId
Definition: sensors.h:45
constexpr int kGetSensorsData
Definition: sensors.h:58
int SensorsCmd
Definition: sensors.h:62
constexpr int kTemperatureId
Definition: sensors.h:28
constexpr int kGyroscopeId
Definition: sensors.h:26
constexpr int kLightId
Definition: sensors.h:30
constexpr int kMagneticId
Definition: sensors.h:27
constexpr int kPressureId
Definition: sensors.h:31
constexpr int kUncalibAccelerationId
Definition: sensors.h:36
constexpr int kUpdateHingeAngle
Definition: sensors.h:60
constexpr char OUTER_DELIM
Definition: sensors.h:54
constexpr int kAccelerationId
Definition: sensors.h:25
constexpr int kUpdateHal
Definition: sensors.h:59
constexpr int kHingeAngle0Id
Definition: sensors.h:35
constexpr int kUpdateRotationVec
Definition: sensors.h:57
constexpr int kUncalibMagneticId
Definition: sensors.h:33
constexpr char INNER_DELIM
Definition: sensors.h:53
constexpr int kProximityId
Definition: sensors.h:29
constexpr int kUncalibGyroscopeId
Definition: sensors.h:34
int SensorsMask
Definition: sensors.h:51
constexpr int kHumidityId
Definition: sensors.h:32
Definition: alloc_driver.h:20