Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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. | |
| 4 | |
| 5 #ifndef CHROMEOS_ACCELEROMETER_ACCELEROMETER_TYPES_H_ | |
| 6 #define CHROMEOS_ACCELEROMETER_ACCELEROMETER_TYPES_H_ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 #include "ui/gfx/geometry/vector3d_f.h" | |
| 10 | |
| 11 namespace chromeos { | |
| 12 | |
| 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, | |
| 21 | |
| 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, | |
| 28 | |
| 29 ACCELEROMETER_SOURCE_COUNT | |
| 30 }; | |
| 31 | |
| 32 struct AccelerometerReading { | |
| 33 AccelerometerReading() : present(false) {} | |
|
Daniel Erat
2014/08/28 00:27:07
i suspect that this struct needs an explicit c'tor
flackr
2014/08/28 01:21:37
Done.
| |
| 34 | |
| 35 // If true, this accelerometer is being updated. | |
| 36 bool present; | |
| 37 | |
| 38 // The reading from this accelerometer measured in m/s^2. | |
| 39 gfx::Vector3dF reading; | |
| 40 }; | |
| 41 | |
| 42 // An accelerometer update contains the last known value for each of the | |
| 43 // accelerometers present on the device. | |
| 44 class AccelerometerUpdate { | |
| 45 public: | |
| 46 AccelerometerUpdate() {} | |
|
Daniel Erat
2014/08/28 00:27:07
same here
flackr
2014/08/28 01:21:36
Done.
| |
| 47 | |
| 48 // Returns true if |source| has a valid value in this update. | |
| 49 bool has(AccelerometerSource source) const { | |
| 50 return data_[source].present; | |
| 51 } | |
| 52 | |
| 53 // Returns the last known value for |source|. | |
| 54 const gfx::Vector3dF& get(AccelerometerSource source) const { | |
| 55 return data_[source].reading; | |
| 56 } | |
| 57 | |
| 58 void Set(AccelerometerSource source, float x, float y, float z) { | |
| 59 data_[source].present = true; | |
| 60 data_[source].reading.set_x(x); | |
| 61 data_[source].reading.set_y(y); | |
| 62 data_[source].reading.set_z(z); | |
| 63 } | |
| 64 | |
| 65 protected: | |
| 66 AccelerometerReading data_[ACCELEROMETER_SOURCE_COUNT]; | |
| 67 | |
| 68 DISALLOW_COPY_AND_ASSIGN(AccelerometerUpdate); | |
| 69 }; | |
| 70 | |
| 71 } // namespace chromeos | |
| 72 | |
| 73 #endif // CHROMEOS_ACCELEROMETER_ACCELEROMETER_TYPES_H_ | |
| OLD | NEW |