Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(322)

Side by Side Diff: chromeos/accelerometer/accelerometer_reader.cc

Issue 867623005: chromeos: Remove unneeded geometry dependency from both GYP and GN. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: REBASE Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chromeos/BUILD.gn ('k') | chromeos/chromeos.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "chromeos/accelerometer/accelerometer_reader.h" 5 #include "chromeos/accelerometer/accelerometer_reader.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 22 matching lines...) Expand all
33 // File within the device in kAccelerometerIioBasePath containing the scale of 33 // File within the device in kAccelerometerIioBasePath containing the scale of
34 // the accelerometers. 34 // the accelerometers.
35 const base::FilePath::CharType kScaleNameFormatString[] = "in_accel_%s_scale"; 35 const base::FilePath::CharType kScaleNameFormatString[] = "in_accel_%s_scale";
36 36
37 // The filename giving the path to read the scan index of each accelerometer 37 // The filename giving the path to read the scan index of each accelerometer
38 // axis. 38 // axis.
39 const char kAccelerometerScanIndexPath[] = 39 const char kAccelerometerScanIndexPath[] =
40 "scan_elements/in_accel_%s_%s_index"; 40 "scan_elements/in_accel_%s_%s_index";
41 41
42 // The names of the accelerometers. Matches up with the enum AccelerometerSource 42 // The names of the accelerometers. Matches up with the enum AccelerometerSource
43 // in ui/accelerometer/accelerometer_types.h. 43 // in chromeos/accelerometer/accelerometer_types.h.
44 const char kAccelerometerNames[ACCELEROMETER_SOURCE_COUNT][5] = {"lid", "base"}; 44 const char kAccelerometerNames[ACCELEROMETER_SOURCE_COUNT][5] = {"lid", "base"};
45 45
46 // The axes on each accelerometer. 46 // The axes on each accelerometer.
47 const char kAccelerometerAxes[][2] = {"y", "x", "z"}; 47 const char kAccelerometerAxes[][2] = {"y", "x", "z"};
48 48
49 // The length required to read uint values from configuration files. 49 // The length required to read uint values from configuration files.
50 const size_t kMaxAsciiUintLength = 21; 50 const size_t kMaxAsciiUintLength = 21;
51 51
52 // The size of individual values. 52 // The size of individual values.
53 const size_t kDataSize = 2; 53 const size_t kDataSize = 2;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 kAccelerometerScanIndexPath, kAccelerometerAxes[j], 113 kAccelerometerScanIndexPath, kAccelerometerAxes[j],
114 kAccelerometerNames[i]); 114 kAccelerometerNames[i]);
115 if (!ReadFileToInt(iio_path.Append(accelerometer_index_path.c_str()), 115 if (!ReadFileToInt(iio_path.Append(accelerometer_index_path.c_str()),
116 &(configuration->data.index[i][j]))) { 116 &(configuration->data.index[i][j]))) {
117 return false; 117 return false;
118 } 118 }
119 } 119 }
120 } 120 }
121 121
122 // Adjust the directions of accelerometers to match the AccelerometerUpdate 122 // Adjust the directions of accelerometers to match the AccelerometerUpdate
123 // type specified in ui/accelerometer/accelerometer_types.h. 123 // type specified in chromeos/accelerometer/accelerometer_types.h.
124 configuration->data.scale[ACCELEROMETER_SOURCE_SCREEN][0] *= -1.0f; 124 configuration->data.scale[ACCELEROMETER_SOURCE_SCREEN][0] *= -1.0f;
125 for (int i = 0; i < 3; ++i) { 125 for (int i = 0; i < 3; ++i) {
126 configuration->data.scale[ACCELEROMETER_SOURCE_ATTACHED_KEYBOARD][i] *= 126 configuration->data.scale[ACCELEROMETER_SOURCE_ATTACHED_KEYBOARD][i] *=
127 -1.0f; 127 -1.0f;
128 } 128 }
129 129
130 // Verify indices are within bounds. 130 // Verify indices are within bounds.
131 for (int i = 0; i < ACCELEROMETER_SOURCE_COUNT; ++i) { 131 for (int i = 0; i < ACCELEROMETER_SOURCE_COUNT; ++i) {
132 if (!configuration->data.has[i]) 132 if (!configuration->data.has[i])
133 continue; 133 continue;
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 263
264 // Trigger another read after the current sampling delay. 264 // Trigger another read after the current sampling delay.
265 base::MessageLoop::current()->PostDelayedTask( 265 base::MessageLoop::current()->PostDelayedTask(
266 FROM_HERE, 266 FROM_HERE,
267 base::Bind(&AccelerometerReader::TriggerRead, 267 base::Bind(&AccelerometerReader::TriggerRead,
268 weak_factory_.GetWeakPtr()), 268 weak_factory_.GetWeakPtr()),
269 base::TimeDelta::FromMilliseconds(kDelayBetweenReadsMs)); 269 base::TimeDelta::FromMilliseconds(kDelayBetweenReadsMs));
270 } 270 }
271 271
272 } // namespace chromeos 272 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/BUILD.gn ('k') | chromeos/chromeos.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698