Chromium Code Reviews| Index: device/generic_sensor/platform_sensor_reader_win.cc |
| diff --git a/device/generic_sensor/platform_sensor_reader_win.cc b/device/generic_sensor/platform_sensor_reader_win.cc |
| index 566d69688669b0fab6ab1d9b123a270c086bd2bc..f4d44ff9051b3e53544e0ebc521cef8d5b7d742c 100644 |
| --- a/device/generic_sensor/platform_sensor_reader_win.cc |
| +++ b/device/generic_sensor/platform_sensor_reader_win.cc |
| @@ -5,6 +5,7 @@ |
| #include "device/generic_sensor/platform_sensor_reader_win.h" |
| #include <Sensors.h> |
| +#include <SensorsDef.h> |
| #include "base/callback.h" |
| #include "base/memory/ptr_util.h" |
| @@ -193,6 +194,39 @@ std::unique_ptr<ReaderInitParams> CreateAbsoluteOrientationReaderInitParams() { |
| return params; |
| } |
| +// RelativeOrientation sensor reader initialization parameters. |
| +std::unique_ptr<ReaderInitParams> CreateRelativeOrientationReaderInitParams() { |
| + auto params = base::MakeUnique<ReaderInitParams>(); |
| + params->sensor_type_id = GUID_SensorType_RelativeOrientation; |
| + params->reader_func = |
| + base::Bind([](ISensorDataReport& report, SensorReading& reading) { |
|
dcheng
2017/05/03 20:58:53
Google style does not permit mutable reference arg
juncai
2017/05/04 17:51:09
Bug filed:
https://bugs.chromium.org/p/chromium/is
|
| + double quat_x = 0.0; |
| + double quat_y = 0.0; |
| + double quat_z = 0.0; |
| + double quat_w = 0.0; |
| + if (!GetReadingValueForProperty(PKEY_SensorData_QuaternionX, report, |
| + &quat_x) || |
| + !GetReadingValueForProperty(PKEY_SensorData_QuaternionY, report, |
| + &quat_y) || |
| + !GetReadingValueForProperty(PKEY_SensorData_QuaternionZ, report, |
| + &quat_z) || |
| + !GetReadingValueForProperty(PKEY_SensorData_QuaternionW, report, |
| + &quat_w)) { |
| + return E_FAIL; |
| + } |
| + |
| + // Windows uses coordinate system where Z axis points down from device |
| + // screen, therefore, using right hand notation, we have to reverse |
| + // sign for each quaternion component. |
| + reading.values[0] = -quat_x; |
| + reading.values[1] = -quat_y; |
| + reading.values[2] = -quat_z; |
| + reading.values[3] = quat_w; |
| + return S_OK; |
| + }); |
| + return params; |
| +} |
| + |
| // Creates ReaderInitParams params structure. To implement support for new |
| // sensor types, new switch case should be added and appropriate fields must |
| // be set: |
| @@ -212,6 +246,8 @@ std::unique_ptr<ReaderInitParams> CreateReaderInitParamsForSensor( |
| return CreateMagnetometerReaderInitParams(); |
| case mojom::SensorType::ABSOLUTE_ORIENTATION: |
| return CreateAbsoluteOrientationReaderInitParams(); |
| + case mojom::SensorType::RELATIVE_ORIENTATION: |
| + return CreateRelativeOrientationReaderInitParams(); |
| default: |
| NOTIMPLEMENTED(); |
| return nullptr; |