Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as C# by Maksym ( 8 years ago )
int calibrationState = 0;
float calibrationMargin = .1f;
Warper warper = new Warper();
float[] srcX = new float[4];
float[] srcY = new float[4];
float[] dstX = new float[4];
float[] dstY = new float[4];
switch (calibrationState)
{
case 1:
srcX[calibrationState - 1] = warpedX1;
srcY[calibrationState - 1] = warpedY1;
calibrationState = 2;
doCalibration();
break;
case 2:
srcX[calibrationState - 1] = warpedX1;
srcY[calibrationState - 1] = warpedY1;
calibrationState = 3;
doCalibration();
break;
case 3:
srcX[calibrationState - 1] = warpedX1;
srcY[calibrationState - 1] = warpedY1;
calibrationState = 4;
doCalibration();
break;
case 4:
srcX[calibrationState - 1] = warpedX1;
srcY[calibrationState - 1] = warpedY1;
calibrationState = 5;
doCalibration();
break;
default:
break;
}//calibtation state
public void doCalibration(){
int x = 0;
int y = 0;
int size = 25;
Pen p = new Pen(Color.Red);
switch (calibrationState)
{
case 1:
x = (int)(screenWidth * calibrationMargin);
y = (int)(screenHeight * calibrationMargin);
cf.showCalibration(x, y, size, p);
dstX[calibrationState - 1] = x;
dstY[calibrationState - 1] = y;
break;
case 2:
x = screenWidth - (int)(screenWidth * calibrationMargin);
y = (int)(screenHeight * calibrationMargin);
cf.showCalibration(x, y, size, p);
dstX[calibrationState - 1] = x;
dstY[calibrationState - 1] = y;
break;
case 3:
x = (int)(screenWidth * calibrationMargin);
y = screenHeight -(int)(screenHeight * calibrationMargin);
cf.showCalibration(x, y, size, p);
dstX[calibrationState - 1] = x;
dstY[calibrationState - 1] = y;
break;
case 4:
x = screenWidth - (int)(screenWidth * calibrationMargin);
y = screenHeight -(int)(screenHeight * calibrationMargin);
cf.showCalibration(x, y, size, p);
dstX[calibrationState - 1] = x;
dstY[calibrationState - 1] = y;
break;
case 5:
//compute warp
warper.setDestination(dstX[0], dstY[0], dstX[1], dstY[1], dstX[2], dstY[2], dstX[3], dstY[3]);
warper.setSource(srcX[0], srcY[0], srcX[1], srcY[1], srcX[2], srcY[2], srcX[3], srcY[3]);
warper.computeWarp();
cf.Close();
cf = null;
calibrationState = 0;
cursorControl = true;
BeginInvoke((MethodInvoker)delegate() { cbCursorControl.Checked = cursorControl; });
// saveCalibrationData();
UpdateTrackingUtilization();
break;
default:
break;
}
}
Revise this Paste