| Research |
|
|
SDL Modifications for Accelerometer Game Control
|
| |||||||
|
SDL Accel: SDL Modifications for Accelerometer Game Control One of the benefits of working in IBM Almaden Research Center CS is the freedom we are given to pursue our technical interests even when they don't immediately align with our current research. This page is the result of one such digression. Since the release of the ThinkPad Accelerometer Interface in mid-2005, I have received a good deal of correspondence regarding the changes I described to the Simple Directmedia Layer (SDL) library. Small modifications to SDL can enable any game which uses the multimedia libary to use the acceleromter as input for games. Although the accelerometer can be used to trigger any of the input types to a game, directional input is the most obviously applicable. Of course, games which rely on directional input as their primary interface are optimal candidates for this feature. Consider Tux Racer and Neverball.
DownloadThis feature as implemented will only work with ThinkPads with accelerometers running either Windows or Linux. To install:
WindowsThe Windows version interfaces directly with sensor.dll, by calling an undocumented function:ShockproofGetAccelerometerData(). sensor.dll is included as part of the Active Protection System, and should come preinstalled with supported ThinkPads. However, if you need to install the APS, you can find it here.
LinuxYou'll need to build your own SDL library using this provided patch and Makefile. Please note that when these changes were made, the linux accelerometer driver was not yet available, so this code interfaces directly with the accelerometer. The patch should be updated to rely on the proper driver, which is included in the Linux kernel starting with 2.6.14. As written, this may interact or interfere with the aforementioned driver, but is useful as a demonstration.
Mac OS XSimilar changes can be made to SDL for the accelerometers in Macintoshes. However, the interface to the accelerometer in such machines is not public. Amit Singh, of kernelthread.com will be releasing his source for The Apple Motion Sensor As a Human Interface Device with his book, Mac OS X Internals. That code should be easily adaptable for SDL. It is also interesting to note that the Macintoshes' accelerometers measure and expose X, Y, and Z (or vertical) acceleration components, making "jump when I jump" style game-play possible.
Configuration One may notice that on Windows, some games may "freeze" momentarily during play. In many cases,
games will need to load parts of level maps as one moves through a level. If the Active Protection
System is detecting motion, however, it will "stop" the hard drive, causing the load of that map piece
to be delayed, causing the hiccup. The APS must be enabled because, as previously mentioned,
the modifications to SDL rely on the APS's sensor.dll for its accelerometer
readings. Fortunately, the APS is very configurable; the "Shock detection sensitivity" can be set to low, and even
suspended for some minutes. To reach the configuration menu, look in the Notification Area of the
Windows Taskbar for the APS icon: Note: Some ThinkPads have "reversed" accelerometer X and Y readings. This may cause left-right motion
to control the forward-back inputs on games, and vice versa.
Technical Small changes to
AcknowledgementsThis work was first pursued by Ted Bonkenburg
while he was working at the IBM Almaden Research Center.
Amit Singh has done similar work with his investigation of
The Apple Motion Sensor As a Human Interface Device, the source for which is
provided with his tome, Mac OS X Internals,
available as ISBN 0321278542.
|
|||||||
| Privacy | Terms of Use | IBM Home | Almaden Home | Almaden CS Home | Research Sites | Page Contact | ||||||||