The implementation contains three main classes:
The following diagram shows the typical usage flow:
Support for the SensorTypes defined by the Mojo interface on Windows is summarized below:
SensorType | Sensor GUID |
---|---|
AMBIENT_LIGHT | SENSOR_TYPE_AMBIENT_LIGHT |
ACCELEROMETER | SENSOR_TYPE_ACCELEROMETER_3D |
LINEAR_ACCELEROMETER | * |
GRAVITY | * |
GYROSCOPE | SENSOR_TYPE_GYROMETER_3D |
MAGNETOMETER | SENSOR_TYPE_COMPASS_3D |
ABSOLUTE_ORIENTATION_EULER_ANGLES | SENSOR_TYPE_INCLINOMETER_3D |
ABSOLUTE_ORIENTATION_QUATERNION | SENSOR_TYPE_AGGREGATED_DEVICE_ORIENTATION |
*The LINEAR_ACCELEROMETER sensor type is provided by implementing a low-pass-filter over the values returned by the ACCELEROMETER in order to remove the contribution of the gravitational force.
*The GRAVITY sensor type is provided by implementing a low-pass-filter over the values returned by the ACCELEROMETER in order to get the contribution of the gravitational force.
The “Sensor GUID” column specifies the names of the sensor type GUIDs used to provide data for a SensorType. Any SensorType not mentioned by this table are not supported on Windows.
The overall sensor backend design on Windows remains the same (as detailed in section 3). The classes which take a direct dependency on the ISensor API have their interfaces abstracted out and reimplemented with Windows.Devices.Sensors:
This allows the other classes, which are agnostic to the underlying API, to interchangeability use the ISensor vs. Windows.Devices.Sensors implementation. This is advantageous as the two implementations live side by side.
Please refer to platform_sensor_provider.cc.
The overall Windows.Devices.Sensors design is the same as the current design detailed in section 3 except the classes that take a dependency on the ISensor API have been reimplemented with these new classes:
The existing PlatformSensorReaderWin class has been pulled out into its own interface in platform_sensor_reader_win_base.h.
The existing (ISensor) PlatformSensorReaderWin32 class and new (Windows.Devices.Sensors) PlatformSensorReaderWinrt class inherit from this interface so both classes can be interchangeably used with the ISensor/Windows.Devices.Sensors agnostic PlatformSensorWin, which simply consume the PlatformSensorReaderWinBase interface.
Since there are several Windows.Devices.Sensors sensor functions which are identical between the different sensor types, an abstract class encapsulates the common functionality. Please refer to platform_sensor_reader_winrt.h.