Home |
RTTarget-32 Programming Manual Function RTTouchCalibrate System Management BIOS (SMBIOS) Advanced Programmable Interrupt Controller (APIC) |
Function RTTouchCalibrateRTTouchCalibrate defines a calibration point for a touch screen input device: int RTTouchToPhys(int XPointer, int YPointer, int XScreen, int YScreen); ParametersXPointer, YPointerTouch device coordinates of the calibration point. XScreen, YScreenScreen coordinates of the calibration point. return value1 if the point has been accepted, 0 if not (i.e., because it is identical with the previous point or it is too far away from the expected value). RTTouchCalibrate associates a pointer device position (XPointer, YPointer) with a screen position (XScreen, YScreen) to calibrate the touch -> screen coordinate translation of the touch driver. RTTouchCalibrate should be called for at least two screen positions. An application should provide a calibration screen with two points which the user should touch. When touched (PEG event PM_LBUTTONDOWN), RTTouchToPhys and RTTouchCalibrate should be called as follows: { int XPointer, YPointer; if (RTTouchToPhys(Mesg.Point.x, Mesg.Point.y, &XPointer, &YPointer) && RTTouchCalibrate(XPointer, YPointer, X, Y)) { // you can save the values (XPointer, YPointer, X, Y) // here for later recalibration ... } } where X and Y are the screen coordinates which the user has touched. Note that RTTouchCalibrate must be called successfully for two different points in succession. You can save the values passed to RTTouchCalibrate for default calibration of future program runs. The RTPEG-32 demo program PegDemo contains function CalibrateDialog which creates a calibration screen. The screen displays two crosses, one in black and one in white. The user must touch the black cross. If successful, the crosses are swapped. Once the user has touched each cross at least once, a "Close" button is displayed, allowing the user to exit. It is recommended to continue calibration until the user has managed to exactly hit the two crosses in succession. Note that only the last two calls to RTTouchCalibrate are evaluated. It is recommended (but not required) to define two calibration points statically during initialization of the application. This will make the program at least usable even before calibration. If this is done, the calibration procedure does not need to be run modally before other windows are opened. Rather, you could make calibration a menu option of the application and run it whenever the user feels calibration is required. For systems with flash memory or a hard disk, the values of a successful calibration can be saved and reapplied during future program initializations.
|