| 94 | */ |
| 95 | |
| 96 | bool TouchManager::calibrate() { |
| 97 | |
| 98 | TouchScreenCalibration* newResults; |
| 99 | |
| 100 | // wait for the pen to come up |
| 101 | |
| 102 | while(_touchScreen->isTouched()); |
| 103 | |
| 104 | // create the calibrator |
| 105 | |
| 106 | ThreePointTouchScreenCalibrator calibrator(*_touchScreen,*this); |
| 107 | |
| 108 | // important preparation for calibration: we must set the screen to pass through mode |
| 109 | // so that the calibrator sees raw co-ordinates and not calibrated! |
| 110 | |
| 111 | _touchScreen->setCalibration(_passThroughCalibration); |
| 112 | |
| 113 | // calibrate the screen and get the new results |
| 114 | |
| 115 | if(!calibrator.calibrate(newResults)) |
| 116 | return false; |
| 117 | |
| 118 | _term.clearScreen(); |
| 119 | |
| 120 | // set the new results |
| 121 | |
| 122 | if(_calibration!=NULL) |
| 123 | delete _calibration; |
| 124 | |
| 125 | _calibration=newResults; |
| 126 | |
| 127 | // re-initialise the touch screen with the calibration data |
| 128 | |
| 129 | _touchScreen->setCalibration(*_calibration); |
| 130 | _needsCalibration=false; |
| 131 | |
| 132 | // save the new results to the file system as /pframe/touchcal.bin |
| 133 | |
| 134 | return saveCalibration(); |
| 135 | } |
| 136 | |
| 137 | |
| 138 | /* |
no test coverage detected