windows 用于笔记本电脑的加速度计 API

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2939685/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 14:32:59  来源:igfitidea点击:

Accelerometer API for Laptops

windowsaccelerometer

提问by Petrus Theron

Most IBM (and some Dell) laptops have built-in accelerometers to stop any moving parts during a sudden fall, but I was unable to find a standardised Windows API to access this data. I assume that each manufacturer would provide a driver to interface with the sensor.

大多数 IBM(和一些戴尔)笔记本电脑都有内置加速度计,可以在突然跌落时停止任何移动部件,但我无法找到标准化的 Windows API 来访问这些数据。我假设每个制造商都会提供一个驱动程序来与传感器连接。

  1. Which popular laptop brands come standard with accelerometers accessible from an API and which libraries should I use to access the data?
  2. Does an API* exist to abstract away the differences between different manufacturers? I am aware of the Windows 7 Sensor API, but I would like support for XP and earlier.
  1. 哪些流行的笔记本电脑品牌标配了可通过 API 访问的加速度计,我应该使用哪些库来访问数据?
  2. 是否存在 API* 来抽象不同制造商之间的差异?我知道 Windows 7 Sensor API,但我希望支持 XP 及更早版本。

采纳答案by lornova

Most reputable notebook vendors have accelerometers to park the hard drive head if the notebook is accidentally dropped or is abruptly impacted by another object (i.e. when a certain acceleration threshold is exceeded). For example, my HP has its "HP 3D DriveGuard". However this technology is embedded low-level, it seems to work even if the OS is not loaded, so I suppose it is in the BIOS. I suppose that it is exposed just an ACPI way to enable or disable this technology. So, even on Windows 7 with standardized sensor APIs it is not accessible as a standard accelerometer like in a smartphone. Maybe in future if market demands it (but I don't think so).

如果笔记本电脑意外跌落或突然受到另一个物体的撞击(即超过某个加速度阈值时),大多数有信誉的笔记本电脑供应商都有加速度计来停放硬盘驱动器磁头。例如,我的 HP 有它的“HP 3D DriveGuard”。然而,这项技术是低级嵌入的,即使没有加载操作系统,它似乎也能工作,所以我想它在 BIOS 中。我想它只是公开了一种启用或禁用此技术的 ACPI 方式。因此,即使在具有标准化传感器 API 的 Windows 7 上,也无法像智能手机那样作为标准加速度计进行访问。如果市场需要,也许在未来(但我不这么认为)。

回答by nhinkle

This won't work for all manufacturers, but after much searching (I've been wanting this feature myself), I found somebody who wrote a driver wrapperfor the accelerometers in HP laptops. If your laptop supports HP 3d DriveGuard or HP ProtectSmart, then this driver should let the accelerometer show up in the Windows sensor list.

这不适用于所有制造商,但经过多次搜索(我自己一直想要这个功能),我发现有人为 HP 笔记本电脑中的加速度计编写了驱动程序包装器。如果您的笔记本电脑支持 HP 3d DriveGuard 或 HP ProtectSmart,则此驱动程序应让加速度计显示在 Windows 传感器列表中。

Tested it out on my HP laptop and it installed without a hitch. The example program works, but it's pretty slow to respond. I don't think this would work well for high-precision needs (such as gaming), but it might work if you just need some slower orientation data.

在我的 HP 笔记本电脑上对其进行了测试,并且顺利安装。示例程序可以运行,但响应速度很慢。我认为这不适用于高精度需求(例如游戏),但如果您只需要一些较慢的方向数据,它可能会起作用。

windows control panel sensors

车窗控制面板传感器

Note that this works by exposing the accelerometer to the Windows sensors API. The sensors API provides a standard method of accessing any type of sensor regardless of the actual hardware installed. There's more information about the Windows Sensor Platform on MSDN.

请注意,这是通过将加速度计暴露给 Windows 传感器 API 来实现的。传感器 API 提供了一种访问任何类型传感器的标准方法,而不管安装的实际硬件如何。MSDN 上提供了有关Windows 传感器平台的更多信息。