TechNet Magazine > Home > Issues > 2007 > December >  Windows Confidential: A Joystick Need Not Be a ...
Windows Confidential A Joystick Need Not Be a Microwave
Raymond Chen


I was recently reading a blog post by a colleague of mine, the Audio Fool, and it reminded me of a mistake I made many years ago that has continued to bother me. Back when the DirectInput® force feedback joystick interface was being worked out, joystick manufacturers were invited to the Microsoft offices in Redmond, WA in order to discuss the details of the proposed interface and provide some feedback of their own (no pun intended).
Many issues were hashed out during those meetings, but the one that sticks in my mind was a disagreement over whether periodic forces should be expressed as a period or as a frequency. One of the vendors present was putting up a fuss because his company had already written a driver that specified its periodic forces in terms of frequency, and he did not want to have to change this. Considering this was a meeting to hash out the details of a brand new interface, how could any vendor possibly expect to leave the meeting without having to make any changes to his driver?
But this vendor complained so much that we finally gave in and agreed to use frequency instead of period to specify the rate of periodic forces. After all, it wouldn't really matter either way. A force with a frequency of 10 oscillations per second is the same as a force with a period of one-tenth of a second. Period and frequency are just inverses of each other.
Oops, that's not exactly true. The period was expressed in milliseconds, which gives a dynamic range of 1ms to a shade under 50 days. A period of 50 days is imperceptible on a human time scale, and a period of 1ms is so fast it doesn't even register as a periodic phenomenon—instead it's perceived as a musical tone.
On the other hand, the frequency was expressed in hertz, which gives a dynamic range of 1Hz to 4 billion cycles per second. Think it's strange to play music out of your joystick? Imagine generating forces that range up into the microwave frequency band!
The problem is that the practically useless expressive power at the top of the frequency range came at the expense of the bottom end. It turns out that flight simulators are big fans of periodic forces with comparatively long periods. I don't know the physics behind it, but I'm told that one of the effects that pilots have to deal with is a slow periodic force on the control stick on the order of a few minutes. The plane has a natural tendency to travel in a very slow vertical sine wave, and pilots have to take steps to counteract this tendency in order to maintain level flight. If the rate of the force were expressed by its period, the flight simulator program could specify a period of 120,000 milliseconds. As a frequency, however, this is 0.0083 hertz, which is far slower than the slowest frequency that can be expressed in the driver interface—namely 1Hz. Therefore, the slowest force a flight simulator can request is one that repeats every second, which is still pretty fast relative to the physical effect that the flight simulator wants to mimic.
Since this issue has continued to bother me after all these years, I recently went to look up the force feedback documentation. To my surprise, it appears that the DIPERIODIC structure uses period instead of frequency to express periodic effects. (And for good measure, it uses microseconds, meaning you can now play music or fly a plane.) Either the mistake was fixed or I'm going senile and my memory is playing tricks on me. Either way, I don't have to worry about this mistake any longer—if it ever even happened in the first place.

Raymond Chen's Web site, The Old New Thing, and identically titled book (Addison-Wesley, 2007) deal with Windows history and Win32 programming. That color looks great on you.
© 2008 Microsoft Corporation and CMP Media, LLC. All rights reserved; reproduction in part or in whole without permission is prohibited.
Page view tracker