ozone: evdev: Sync caps lock LED state to evdev
[chromium-blink-merge.git] / chromeos / accelerometer / accelerometer_types.h
blobf72e296974ee98995bf934215e35d25d6f2c952a
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"
11 namespace chromeos {
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
18 // described at:
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
26 // towards the user.
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.
37 bool present;
39 // The readings from this accelerometer measured in m/s^2.
40 float x;
41 float y;
42 float z;
45 // An accelerometer update contains the last known value for each of the
46 // accelerometers present on the device.
47 class CHROMEOS_EXPORT AccelerometerUpdate {
48 public:
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 {
57 return data_[source];
60 void Set(AccelerometerSource source, float x, float y, float z) {
61 data_[source].present = true;
62 data_[source].x = x;
63 data_[source].y = y;
64 data_[source].z = z;
67 protected:
68 AccelerometerReading data_[ACCELEROMETER_SOURCE_COUNT];
70 private:
71 DISALLOW_COPY_AND_ASSIGN(AccelerometerUpdate);
74 } // namespace chromeos
76 #endif // CHROMEOS_ACCELEROMETER_ACCELEROMETER_TYPES_H_