With the recent launch of the 3rd Generation Intel Core Processors, Intel has introduced a new breed of Ultrabook and it’s a game-changer. Ultrabooks and Convertibles based on the 3rd Generation Intel Core Processors come with new touch and sensor features. In this blog, we will focus on the sensors and how to detect their presence on an Ultrabook running Windows 8:
- What sensors are available for the Ultrabook/Convertible
- What sensors are recommended/required for the Ultrabook/Convertible
- How to determine which sensors are on an Ultrabook
New Sensors Available for the Ultrabook/Convertible
There are five Sensors relevant to the Ultrabook/Convertibles:
- Compass
- Accelerometer
- Gyroscope
- GPS
- Ambient Light Sensor
Sensors Recommended for the Ultrabook
The following table provides information about the new sensors that are recommended for the Ultrabook (and required for convertibles).
It will be up to the OEMs which sensors are included for their specific models/usages.
Sensor Detection
Figuring out which sensors are on Convertibles is easy. All of the above sensors are required. For the basic Ultrabook, it isn't so easy. There will be different classes of Ultrabooks: the Business Ultrabook and the Consumer Ultrabook. While OEMs have been given a minimum specification that dictates what features an Ultrabook has, there will be some differentiating amongst the OEMS for the different classes of computers. The OEMs will determine which sensors are best suited for their various models.
Detecting Sensors on an Ultrabook
There are a few ways in which to determine if a system supports the sensors, and if so, which sensors:
- The first, most basic way, is to find the Computer Management App on the Windows UI Start Menu (if it isn't there you can view "All Apps" by right-clicking in the window and then click on the "All Apps" icon in the lower right-hand side of the window.
- If you want to get finer detail regarding each sensor and possibly even have some control over some of the sensor parameters (for testing purposes) you can run the Sensor Diagnostic Tool – it is part of the Windows Driver Kit ( WDK).
- Thirdly, if you are writing Apps for Windows 8 you will need to have your App query for all the sensors so that the right execution path can be taken (i.e. if the sensor you wanted to use is not present, you will need to find an alternate way of providing the user experience.)
Computer Management/Device Manager
Once the Device Manager is up, look for "Sensors" in the device tree. The "HID Sensor Collection" contains the new sensors associated with Ultrabook. Unfortunately it does not provide a breakout of which of the sensors are on the system; just that at least one of them is present. HID is "Human Interface Device" and the five Ultrabook sensors use the HID protocol.
Sensor Diagnostic Tool
The Sensor Diagnostic tool uses the Sensor and Location API for data retrieval, event handling, report intervals, changing sensitivity, and property retrieval. The tool can also be used to write the sensor data to a CSV file. I should note, however that the Sensor Diagnostic Tool really exists to aid with the development of Windows Drivers; its true use is to help with the testing and optimization of Windows Drivers. This tool can be found in the following folder once you have installed the Windows Driver Kit: C:\Program Files (x86)\Windows Kits\8.0\Tools\x86.
Sensor Diagnostic Tool run on an Ivy Bridge Software Development Platform + USB Sensor Hub
Programmatically detecting sensors using the Sensor APIs
The Sensor Diagnostic Tool is useful to monitor and test your sensors; however, in software that is written to take advantage of the Ultrabook Sensors, it would be better to call the Sensor APIs from within the code in order to ensure that the platform supports the sensors. If the system does not support a particular sensor then the software should still be able to offer a different but compelling experience for the end user.
Before we talk about the specific APIs, let’s take a look at what the development environment looks like for Windows 8.
Take note of the languages supported in Windows UI Style Apps and Desktop Apps. Also note that for Windows UI Style Apps, the Device APIs are included inside the Windows Run Time environment.
There is also a Windows 8 Sensor Platform that provides support for both Windows UI style app and desktop development. The examples below pertain to the Windows 8 Desktop environment. For Desktop Apps, accessing the sensors is done via the object
SensorManager
. Sensors can be queried in the following manners:
- Ask by Type
- Ask by Category
- Ask by Category "All"
Asking by Type
If you are interested in a specific type of sensor, for example, "Gyrometer3D", SensorManager will consult the list of sensor hardware present on the computer and return a collection of matching objects bound to that hardware. The Sensor Collection may have zero or more objects in it but usually will have only one.
- Method:
GetSensorByType
- Include Files: InitGuid.h, SensorsApi.h, Sensors.h
Steps:
- Create a COM interface to the
SensorManager
object
- Get a collection of all 3-axis Gyros on the computer
result = pSensorManager-> GetSensorsByType(SENSOR_TYPE_GYROMETER_3D, &pSensorCollection)
Asking by Category
Rather than looking for a specific type of sensor, you may be interested in looking for all sensors in a specific category, for example, "Motion" sensors. SensorManager will consult the list of sensor hardware on the computer, and return a collection of Motion objects bound to that hardware. The SensorCollection may have zero or more objects in it. On most computers, the collection will have two Motion objects: Accelerometer3D and Gyrometer3D.
- Method:
GetSensorByCategory
- Include Files: InitGuid.h, SensorsApi.h, Sensors.h
Steps:
- Create a COM interface to the SensorManager object
- Get a collection of all Motion Sensors on the computer
result = pSensorManager-> GetSensorsByCategory(SENSOR_CATEGORY_MOTION, &pSensorCollection)
Asking by Category "ALL"
Finally, you might be interested on getting all the sensors on the computer by using the "ALL" method. This would most likely be the preferred way to query the sensors on the system; however, it will return all sensors, not just the five listed above. Once again,
SensorManager
will consult the list of sensor hardware on the computer and return a collection of all the objects bound to that hardware. The
SensorCollection
may have zero or more objects in it. On most computers, the collection will have seven or more objects. Note that C++ does not have a
GetAllSensors
call, so you must use GetSensorsByCategory(SENSOR_CATEGORY_ALL, …)
instead.
- Method:
GetSensorsByCategory
- Include Files: InitGuid.h, SensorsApi.h, Sensors.h
Steps:
- Create a COM interface to the
SensorManager
object
- Get a collection of all Sensors on the computer
result = pSensorManager-> GetSensorsByCategory(SENSOR_CATEGORY_ALL,&pSensorCollection)
Querying the Sensors in Windows UI/WinRT
For Windows UI/WinRT, you will simply use the methods to get the sensor object and test for NULL. The
Geolocation
method is a little different. Here are some examples:
Resources
Here are some good resources from the Microsoft website for developing sensor-enabled apps:
Also, here are some more blogs/articles that may be useful regarding on Ultrabooks and Windows 8:
Conclusion
The primary goal for this blog was to educate the reader on how to detect the required sensors supported for Windows 8 Ultrabooks. The focus was primarily on the "clam-shell" form factor since Convertibles, Tablets and Mobile devices will be required to have all the sensors. It is important to note that sensor support for Ultrabooks is dependent on the OEM and Model. While it is possible to run local tools to determine the existence of sensors, software developers will need to be able to programmatically check for the sensors so that their software will not attempt to use a device that may or may not be there.