1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/hal/HalSensor.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,77 @@ 1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* vim: set sw=2 ts=8 et ft=cpp : */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#ifndef __HAL_SENSOR_H_ 1.11 +#define __HAL_SENSOR_H_ 1.12 + 1.13 +#include "mozilla/Observer.h" 1.14 + 1.15 +namespace mozilla { 1.16 +namespace hal { 1.17 + 1.18 +/** 1.19 + * Enumeration of sensor types. They are used to specify type while 1.20 + * register or unregister an observer for a sensor of given type. 1.21 + */ 1.22 +enum SensorType { 1.23 + SENSOR_UNKNOWN = -1, 1.24 + SENSOR_ORIENTATION, 1.25 + SENSOR_ACCELERATION, 1.26 + SENSOR_PROXIMITY, 1.27 + SENSOR_LINEAR_ACCELERATION, 1.28 + SENSOR_GYROSCOPE, 1.29 + SENSOR_LIGHT, 1.30 + NUM_SENSOR_TYPE 1.31 +}; 1.32 + 1.33 +class SensorData; 1.34 + 1.35 +typedef Observer<SensorData> ISensorObserver; 1.36 + 1.37 +/** 1.38 + * Enumeration of sensor accuracy types. 1.39 + */ 1.40 +enum SensorAccuracyType { 1.41 + SENSOR_ACCURACY_UNKNOWN = -1, 1.42 + SENSOR_ACCURACY_UNRELIABLE, 1.43 + SENSOR_ACCURACY_LOW, 1.44 + SENSOR_ACCURACY_MED, 1.45 + SENSOR_ACCURACY_HIGH, 1.46 + NUM_SENSOR_ACCURACY_TYPE 1.47 +}; 1.48 + 1.49 +class SensorAccuracy; 1.50 + 1.51 +typedef Observer<SensorAccuracy> ISensorAccuracyObserver; 1.52 + 1.53 +} 1.54 +} 1.55 + 1.56 +#include "ipc/IPCMessageUtils.h" 1.57 + 1.58 +namespace IPC { 1.59 + /** 1.60 + * Serializer for SensorType 1.61 + */ 1.62 + template <> 1.63 + struct ParamTraits<mozilla::hal::SensorType>: 1.64 + public ContiguousEnumSerializer< 1.65 + mozilla::hal::SensorType, 1.66 + mozilla::hal::SENSOR_UNKNOWN, 1.67 + mozilla::hal::NUM_SENSOR_TYPE> { 1.68 + }; 1.69 + 1.70 + template <> 1.71 + struct ParamTraits<mozilla::hal::SensorAccuracyType>: 1.72 + public ContiguousEnumSerializer< 1.73 + mozilla::hal::SensorAccuracyType, 1.74 + mozilla::hal::SENSOR_ACCURACY_UNKNOWN, 1.75 + mozilla::hal::NUM_SENSOR_ACCURACY_TYPE> { 1.76 + 1.77 + }; 1.78 +} // namespace IPC 1.79 + 1.80 +#endif /* __HAL_SENSOR_H_ */