Calculating Calibration Values

To calculate the base and delta calibration values, the Joystick option of the Control Panel sets the base value to 0 and the delta values to 1. It then polls the joystick driver while the user holds the joystick at each corner of the device coordinate space. This produces the actual value range returned by the device for each coordinate.

After retrieving the coordinate ranges specified by the joyGetDevCaps function, the Joystick option uses the following formulas to calculate new base and delta values.

wDelta = (wTargetMax - wTargetMin) / (wActualMax - wActualMin)
wBase = (wActualMin * wDelta) - wTargetMin
 

In the following example, the joystick returned x coordinate values in the range 43 to 345, compared to a logical value range of 0 to 65535:

wDelta = (65535-0) / (345-43)
       = 216

wBase  = 43 * 216 - 0
       = 9288