Calculation of Calibration Values

To calculate the base and delta calibration values, the Joystick application 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 application 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 returns 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