The CPOINT structure is used to calibrate segments of the response curve of a device axis. Up to eight CPOINTs can be set through the DIPROPCPOINTS structure. Each CPOINT structure 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 structure, the response graph for the example axis would appear as shown below, including saturation and dead zones.
A DIPROPCPOINTS structure is initialized as follows, assuming the physical range to be -500 to 500.
DIPROPCPOINTS dipcp; dipcp.diph.dwSize = sizeof(DIPROPCPOINTS); dipcp.diph.dwHeaderSize = sizeof(DIPROPHEADER); dipcp.diph.dwObj = GUID_XAxis; dipcp.diph.dwHow = DIPH_BYID; dipcp.dwCPointsNum = 5; dipcp.cp.lP = -500; dipcp.cp.dwLog = 0; dipcp.cp.lP = -300; dipcp.cp.dwLog = 1000; dipcp.cp.lP = -100; dipcp.cp.dwLog = 5000; dipcp.cp.lP = 200; dipcp.cp.dwLog = 9000; dipcp.cp.lP = 500; dipcp.cp.dwLog = 10000;
Note that you do not need to know the actual maximum returned value as the values in the dwLog member of the CPOINT structure 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 IDirectInputDevice8::SetProperty, the curve responds as seen below.