Microsoft DirectX 8.1 (Visual Basic)

Using CPOINTs

The CPOINT type is used to calibrate segments of the response curve of a device axis. Up to eight CPOINTs can be set through the DIPROPCPOINTS type. Each CPOINT type contains a raw data value representing the position of the joystick along the axis, and a logical value. When your application receives the raw value, the logical value is used to calculate the returned value that is actually used. Raw values that fall between specific CPOINT raw data values are interpolated to logical values based on a line drawn between the CPOINTs to either side of the value.

The following is an example of the effect of five CPOINTs applied to the response curve of a joystick's X axis. Before application of the DIPROPCPOINTS type, the response graph for the example axis would appear as shown below, including saturation and dead zones.

A DIPROPCPOINTS type is initialized as follows, assuming the physical range to be -500 to 500.

Dim dipcp as DIPROPCPOINTS

dipcp.lHow = DIPH_BYOFFSET 
dipcp.lObj = DIJOFS_X 
dipcp.dwCPointsNum = 5 
dipcp.cp(0).lp = -500
dipcp.cp(0).dwLog = 0
dipcp.cp(1).lp = -300
dipcp.cp(1).dwLog = 1000
dipcp.cp(2).lp = -100
dipcp.cp(2).dwLog = 5000
dipcp.cp(3).lp = 200
dipcp.cp(3).dwLog = 9000
dipcp.cp(4).lp = 500
dipcp.cp(4).dwLog = 10000

You do not need to know the actual maximum returned value as the values in the dwLog member of the CPOINT type are expressed as a percentage of the total, multiplied by 10000 (the number of discrete divisions in the total range). For instance, the example sets the curve so that 10% of the maximum value is returned at the -300 point in the joystick's range. 0.10 * 10000 = 1000, so that value is given to the dwLog member while -300 is assigned to the corresponding lp member.

After applying this DIPROPCPOINTS structure through DirectInputDevice8.SetProperty, the curve responds as shown below.