OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROMEOS_ACCELEROMETER_ACCELEROMETER_READER_H_ | 5 #ifndef CHROMEOS_ACCELEROMETER_ACCELEROMETER_READER_H_ |
6 #define CHROMEOS_ACCELEROMETER_ACCELEROMETER_READER_H_ | 6 #define CHROMEOS_ACCELEROMETER_ACCELEROMETER_READER_H_ |
7 | 7 |
8 #include <vector> | |
9 | |
10 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
11 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
12 #include "base/observer_list.h" | 10 #include "base/observer_list.h" |
13 #include "chromeos/chromeos_export.h" | 11 #include "chromeos/chromeos_export.h" |
14 #include "ui/accelerometer/accelerometer_types.h" | 12 #include "ui/accelerometer/accelerometer_types.h" |
15 | 13 |
16 namespace base { | 14 namespace base { |
17 class TaskRunner; | 15 class TaskRunner; |
18 } | 16 } |
19 | 17 |
20 namespace chromeos { | 18 namespace chromeos { |
21 | 19 |
22 // Reads an accelerometer device and reports data back to an | 20 // Reads an accelerometer device and reports data back to an |
23 // AccelerometerDelegate. | 21 // AccelerometerDelegate. |
24 class CHROMEOS_EXPORT AccelerometerReader { | 22 class CHROMEOS_EXPORT AccelerometerReader { |
25 public: | 23 public: |
26 // Configuration structure for accelerometer device. | 24 // Configuration structure for accelerometer device. |
27 struct ConfigurationData { | 25 struct ConfigurationData { |
28 ConfigurationData(); | 26 ConfigurationData(); |
29 ~ConfigurationData(); | 27 ~ConfigurationData(); |
30 | 28 |
31 // Scale of accelerometers (i.e. raw value * 1.0f / scale = G's). | 29 // Number of accelerometers on device. |
32 unsigned int base_scale; | 30 size_t count; |
33 unsigned int lid_scale; | 31 |
| 32 // Length of accelerometer updates. |
| 33 size_t length; |
| 34 |
| 35 // Which accelerometers are present on device. |
| 36 bool has[ui::ACCELEROMETER_SOURCE_COUNT]; |
| 37 |
| 38 // Scale of accelerometers (i.e. raw value * scale = m/s^2). |
| 39 float scale[ui::ACCELEROMETER_SOURCE_COUNT][3]; |
34 | 40 |
35 // Index of each accelerometer axis in data stream. | 41 // Index of each accelerometer axis in data stream. |
36 std::vector<unsigned int> index; | 42 int index[ui::ACCELEROMETER_SOURCE_COUNT][3]; |
37 }; | 43 }; |
38 typedef base::RefCountedData<ConfigurationData> Configuration; | 44 typedef base::RefCountedData<ConfigurationData> Configuration; |
39 typedef base::RefCountedData<char[12]> Reading; | 45 typedef base::RefCountedData<char[12]> Reading; |
40 | 46 |
41 // An interface to receive data from the AccelerometerReader. | 47 // An interface to receive data from the AccelerometerReader. |
42 class Delegate { | 48 class Delegate { |
43 public: | 49 public: |
44 virtual void HandleAccelerometerUpdate( | 50 virtual void HandleAccelerometerUpdate( |
45 const ui::AccelerometerUpdate& update) = 0; | 51 const ui::AccelerometerUpdate& update) = 0; |
46 }; | 52 }; |
(...skipping 29 matching lines...) Expand all Loading... |
76 scoped_refptr<Configuration> configuration_; | 82 scoped_refptr<Configuration> configuration_; |
77 | 83 |
78 base::WeakPtrFactory<AccelerometerReader> weak_factory_; | 84 base::WeakPtrFactory<AccelerometerReader> weak_factory_; |
79 | 85 |
80 DISALLOW_COPY_AND_ASSIGN(AccelerometerReader); | 86 DISALLOW_COPY_AND_ASSIGN(AccelerometerReader); |
81 }; | 87 }; |
82 | 88 |
83 } // namespace chromeos | 89 } // namespace chromeos |
84 | 90 |
85 #endif // CHROMEOS_ACCELEROMETER_ACCELEROMETER_READER_H_ | 91 #endif // CHROMEOS_ACCELEROMETER_ACCELEROMETER_READER_H_ |
OLD | NEW |