为什么 Windows 8.1 加速度计 API 设备静止时不输出数据?

Why doesn't Windows 8.1 accelerometer API output data when device is motionless?

我正在 Windows 8.1 超极本上的 WinRT 中使用 C++ 加速度计 API。我惊讶地发现 API 仅在设备处于运动状态时更新加速度计数据。如果它静止在 table 上,加速度计读数不会更新。我尝试通过向 Accelerometer.ReadingChanged 添加事件处理程序来轮询和订阅更新。当设备静止不动时,不会调用事件处理程序。在设备静止不动的情况下进行轮询时,我会不断获得相同的旧数据和相同的旧时间戳。以下是一些样本数据,以 16 毫秒的间隔进行轮询。

130724777430758219  accel   x: -0.005   y: -0.836   z: -0.728
130724777430758219  accel   x: -0.005   y: -0.836   z: -0.728
130724777430758219  accel   x: -0.005   y: -0.836   z: -0.728
130724777430758219  accel   x: -0.005   y: -0.836   z: -0.728
130724777430758219  accel   x: -0.005   y: -0.836   z: -0.728
130724777430758219  accel   x: -0.005   y: -0.836   z: -0.728
130724777430758219  accel   x: -0.005   y: -0.836   z: -0.728

时间戳是第一列。你可以看到时间戳没有改变。我希望加速度数据不会改变,但令我惊讶的是时间戳不会改变。这不是它在其他平台上的工作方式(iOS、Android)。我希望在每个样本上看到不同的时间戳,即使设备是静止的。这让我怀疑 Windows 可能正在对数据进行一些过滤。

有谁知道 Windows 8.1 中是否有此行为?它可以特定于我的设备型号吗? Windows 是否对加速度计数据进行任何过滤?

原来 Windows 确实在过滤加速度计数据。有一个名为 ISensor that allows you to get unfiltered data. Unfortunately, it's not the nicest API, nor is it well documented. Here's a sample app that illustrates it's use. Note that in order to get unfiltered data, you have to set the sensor's SENSOR_PROPERTY_CHANGE_SENSITIVITY 的 COM API 到 0。示例应用程序不显示此内容。