1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROMEOS_ACCELEROMETER_ACCELEROMETER_TYPES_H_
6 #define CHROMEOS_ACCELEROMETER_ACCELEROMETER_TYPES_H_
8 #include "base/macros.h"
9 #include "chromeos/chromeos_export.h"
13 enum AccelerometerSource
{
14 // Accelerometer is located in the device's screen. In the screen's natural
15 // orientation, positive X points to the right, consistent with the pixel
16 // position. Positive Y points up the screen. Positive Z is perpendicular to
17 // the screen, pointing outwards towards the user. The orientation is
19 // http://www.html5rocks.com/en/tutorials/device/orientation/.
20 ACCELEROMETER_SOURCE_SCREEN
= 0,
22 // Accelerometer is located in a keyboard attached to the device's screen.
23 // If the device is open 180 degrees the orientation is consistent with the
24 // screen. I.e. Positive X points to the right, positive Y points up on the
25 // keyboard and positive Z is perpendicular to the keyboard pointing out
27 ACCELEROMETER_SOURCE_ATTACHED_KEYBOARD
,
29 ACCELEROMETER_SOURCE_COUNT
32 struct CHROMEOS_EXPORT AccelerometerReading
{
33 AccelerometerReading();
34 ~AccelerometerReading();
36 // If true, this accelerometer is being updated.
39 // The readings from this accelerometer measured in m/s^2.
45 // An accelerometer update contains the last known value for each of the
46 // accelerometers present on the device.
47 class CHROMEOS_EXPORT AccelerometerUpdate
{
49 AccelerometerUpdate();
50 ~AccelerometerUpdate();
52 // Returns true if |source| has a valid value in this update.
53 bool has(AccelerometerSource source
) const { return data_
[source
].present
; }
55 // Returns the last known value for |source|.
56 const AccelerometerReading
& get(AccelerometerSource source
) const {
60 void Set(AccelerometerSource source
, float x
, float y
, float z
) {
61 data_
[source
].present
= true;
68 AccelerometerReading data_
[ACCELEROMETER_SOURCE_COUNT
];
71 DISALLOW_COPY_AND_ASSIGN(AccelerometerUpdate
);
74 } // namespace chromeos
76 #endif // CHROMEOS_ACCELEROMETER_ACCELEROMETER_TYPES_H_