What is the format of the data of SmoothMouseXCurve and SmoothMouseYCurve in the registry key:
HKEY_CURRENT_USER\Control Panel\Mouse
What is the format of the data of SmoothMouseXCurve and SmoothMouseYCurve in the registry key:
HKEY_CURRENT_USER\Control Panel\Mouse
The two registry keys contain the 5 coordinate pairs of a mouse acceleration graph inflection points (in this case, points in a graph that produce a curve). SmoothMouseXCurve contains the X coordinate points and SmoothMouseYCurve contain the Y coordinate points.
The first point is always 0,0, and refers to the beginning of the curved graph. So, if you inspect your values, you'll notice the first line of both registry values is 00,00,00,00,00,00,00,00. Each subsequent line introduces an inflection point in the graph. Any point after the fifth isn't required since Windows will extrapolate the remaining of the graph from these 5 points.
Each coordinate pair (each line of the five lines in the registry keys) is written in a 16.16 fixed point format (16 bit int + 16 bit fraction). As such you will always only use the first 4 hex of each line. 2 for the integer part and two for the fractional part.
EDIT: This is a somewhat old article on mouse acceleration in XP. It still applies to Vista and Windows 7. However, to my knowledge the formulas have changed slightly, for which reason if you intend to draw your own acceleration graphs, you shouldn't trust those formulas. In any case, it gives you an idea of the process that hasn't changed since then.
And the article mentioned above, which is now dead, is archived, and gives the full technical explanation answer to the question.
Updated: October 31, 2002
This paper describes the algorithms for the pointer ballistics for Microsoft Windows XP and is intended for hardware engineers, driver developers, test managers, and independent hardware vendors. The new algorithms overcome some of the limitations and fallbacks of the ballistic algorithms in the previous operating systems. The main feature results in smoother pointer movements regardless of the pointer speed setting.
The objectives of the pointer ballistics for Windows XP are to fix earlier problems and to:
Problems with pointer ballistics before Windows XP included the following:
For Windows XP, we designed a transfer function that relates the actual velocity of the mouse to the actual velocity of the pointer on the screen. Then an algorithm was applied to that transfer function to calculate the transferred pointer data. To improve design by giving physical meaning to the transfer function, the arbitrary units of the system were first converted to physical units.
Arbitrary units of the mouse were transformed to physical units by taking the X or Y value of the mouse called mickey and scaling it using the update rate of the mouse bus and the resolution of the pointing device:
The typical bus update rate for a USB mouse is 125 Hz, and the typical pointer resolution is 400 mickey/inch. The typical range of a mickey size per packet that coming from a mouse is between 0 and +50, though +127 is allowed in the packet structure. For example, if a standard USB mouse has a constant output of 3 mickey per packet, the physical velocity of that device is 0.9375 or about 1 inch/second.
To transfer the screen from arbitrary units to physical units the following relationship was used:
For example, a typical 17-inch monitor running at 1024 X 769 will have a resolution of about 80 dpi and a refresh rate of about 75 Hz. Thus, if the data is not transformed (default setting with no ballistics) from the previous example, then at 3 mickey per packet, the pointer physically moves at 2.8 inches/second on the screen. Thus, with a USB mouse and a 17-inch screen with the above specifications, there is a physical to virtual gain of 3 (2.8/9.375). In other words, the physical velocity of the pointer on the screen is three times faster than the physical velocity of the mouse.
When the physical units were established, the parent transfer function was constructed based on a usability study. The parent transfer function is illustrated in the following graph:
The transfer function consists of five points. Four of the five points reside in the lower end of the mouse velocity spectrum. The velocities that go beyond the 4-inch limit are linearly extrapolated.
A family of curves is extrapolated from the parent curve to yield a transfer function with varying speed and acceleration properties, as shown in the graph below. The user selects one of these curves using the pointer speed slider in the MouseProperties dialog box (Pointer Options tab).
The following figure shows a more detailed view of the critical inflection points of the transfer function graph.
The slope of the first line segment yields a physical-to-screen gain of less than one gain, providing the precision movement and ability to target every pixel on the screen, or subpixilation. Subpixilation is when the user has to move the mouse physically farther than the pointer moves on the screen, giving a high degree of precision and stability at low velocities. To achieve subpixilation, the divided remainder mouse counts have to be preserved and added into the next counts.
The following figure shows the same close-up with the family of curves. The most important feature to note is that regardless of whether a fast or slow curve is selected, the first set of points tends towards subpixilation, which means that the user is always able to target every pixel on the screen regardless of the mouse speed setting.
The transfer function is stored as a lookup table, and the points between the stored values are interpolated. The number used to look up the mouse X and Y translated values is the vector magnitude of incoming X and Y magnitudes. The ballistic algorithm used before Windows XP independently calculated the acceleration multiplier from X and Y. Therefore, the movement of the pointer was biased towards the greater axis, which resulted in rounded squares instead of perfect circles. To solve this problem, the vector magnitude of X and Y is now used to calculate the acceleration multiplier and is then applied to translate the X and Y data.
The ballistic Windows XP pointer algorithm resides between ring0 and ring3. Therefore, floating point math is not readily available, and because the Windows XP ballistics required the use of division with a remainder, fixed-point (16.16) integer math was used. This is important for the subpixilation and the increased smoothness of the pointer movement. Therefore, the maximum resultant number from two products is 2^16 (65536). While an overflow is possible, it is very unlikely. If an overflow ever becomes a problem in the future, the fixed point constants in the ballistics code are easily changed to support a 20.12 fixed-point format.
The values of the parent curve are stored in a registry setting, its possible to modify and customized the curves and could be achieved easily with a GUI. These characteristics should allow programmers and users custom control of the pointer ballistics to meet a wide variety of needs. Five X and Y pairs are stored in 16.16 fixed point format.
The following list summarizes the ballistic algorithm used in Windows XP, in sequence: