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

Side by Side Diff: device/generic_sensor/platform_sensor_reader_win.cc

Issue 2648423005: [sensors][win] Use angular velocity values for gyroscope sensor (Closed)
Patch Set: Created 3 years, 11 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 | « device/generic_sensor/platform_sensor_and_provider_unittest_win.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "device/generic_sensor/platform_sensor_reader_win.h" 5 #include "device/generic_sensor/platform_sensor_reader_win.h"
6 6
7 #include <Sensors.h> 7 #include <Sensors.h>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 // Gyroscope sensor reader initialization parameters. 102 // Gyroscope sensor reader initialization parameters.
103 std::unique_ptr<ReaderInitParams> CreateGyroscopeReaderInitParams() { 103 std::unique_ptr<ReaderInitParams> CreateGyroscopeReaderInitParams() {
104 auto params = base::MakeUnique<ReaderInitParams>(); 104 auto params = base::MakeUnique<ReaderInitParams>();
105 params->sensor_type_id = SENSOR_TYPE_GYROMETER_3D; 105 params->sensor_type_id = SENSOR_TYPE_GYROMETER_3D;
106 params->reader_func = base::Bind([](ISensorDataReport& report, 106 params->reader_func = base::Bind([](ISensorDataReport& report,
107 SensorReading& reading) { 107 SensorReading& reading) {
108 double x = 0.0; 108 double x = 0.0;
109 double y = 0.0; 109 double y = 0.0;
110 double z = 0.0; 110 double z = 0.0;
111 if (!GetReadingValueForProperty( 111 if (!GetReadingValueForProperty(
112 SENSOR_DATA_TYPE_ANGULAR_ACCELERATION_X_DEGREES_PER_SECOND_SQUARED, 112 SENSOR_DATA_TYPE_ANGULAR_VELOCITY_X_DEGREES_PER_SECOND, report,
113 report, &x) || 113 &x) ||
114 !GetReadingValueForProperty( 114 !GetReadingValueForProperty(
115 SENSOR_DATA_TYPE_ANGULAR_ACCELERATION_Y_DEGREES_PER_SECOND_SQUARED, 115 SENSOR_DATA_TYPE_ANGULAR_VELOCITY_Y_DEGREES_PER_SECOND, report,
116 report, &y) || 116 &y) ||
117 !GetReadingValueForProperty( 117 !GetReadingValueForProperty(
118 SENSOR_DATA_TYPE_ANGULAR_ACCELERATION_Z_DEGREES_PER_SECOND_SQUARED, 118 SENSOR_DATA_TYPE_ANGULAR_VELOCITY_Z_DEGREES_PER_SECOND, report,
119 report, &z)) { 119 &z)) {
120 return E_FAIL; 120 return E_FAIL;
121 } 121 }
122 122
123 // Windows uses coordinate system where Z axis points down from device 123 // Windows uses coordinate system where Z axis points down from device
124 // screen, therefore, using right hand notation, we have to reverse 124 // screen, therefore, using right hand notation, we have to reverse
125 // sign for each axis. Values are converted from deg/s^2 to rad/s^2. 125 // sign for each axis. Values are converted from deg/s to rad/s.
126 reading.values[0] = -x * kRadiansInDegreesPerSecond; 126 reading.values[0] = -x * kRadiansInDegreesPerSecond;
Mikhail 2017/01/24 14:24:48 s/kRadiansInDegreesPerSecond/kRadiansInDegrees
127 reading.values[1] = -y * kRadiansInDegreesPerSecond; 127 reading.values[1] = -y * kRadiansInDegreesPerSecond;
128 reading.values[2] = -z * kRadiansInDegreesPerSecond; 128 reading.values[2] = -z * kRadiansInDegreesPerSecond;
129 return S_OK; 129 return S_OK;
130 }); 130 });
131 return params; 131 return params;
132 } 132 }
133 133
134 // Magnetometer sensor reader initialization parameters. 134 // Magnetometer sensor reader initialization parameters.
135 std::unique_ptr<ReaderInitParams> CreateMagnetometerReaderInitParams() { 135 std::unique_ptr<ReaderInitParams> CreateMagnetometerReaderInitParams() {
136 auto params = base::MakeUnique<ReaderInitParams>(); 136 auto params = base::MakeUnique<ReaderInitParams>();
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 void PlatformSensorReaderWin::SensorError() { 430 void PlatformSensorReaderWin::SensorError() {
431 if (client_) 431 if (client_)
432 client_->OnSensorError(); 432 client_->OnSensorError();
433 } 433 }
434 434
435 unsigned long PlatformSensorReaderWin::GetMinimalReportingIntervalMs() const { 435 unsigned long PlatformSensorReaderWin::GetMinimalReportingIntervalMs() const {
436 return init_params_->min_reporting_interval_ms; 436 return init_params_->min_reporting_interval_ms;
437 } 437 }
438 438
439 } // namespace device 439 } // namespace device
OLDNEW
« no previous file with comments | « device/generic_sensor/platform_sensor_and_provider_unittest_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698