Browse
(440) 299-7778
Menu
(440) 299-7778
One-year parts and labor warranty30-day money-back guaranteeEnglishEspañolContact

The text of a manual · part 22 of 23

VRC 4000 Software Driver Manual: Appendix E TWDriver Application Programming Interface, pages 189 to 197

Pages 189 to 197 of 206, from VRC 4000 Software Driver Manual

The original document is the PDF (1.2 MB). This is its text as extracted, unedited; tables and drawings read best in the PDF, and each page heading opens it at that page.

For the Symbol VRC-4000

Page 189

Appendix E: TWDriver Application Programming Interface

Function: Syntax:

TWReadCalibration1 and 2 TWReadCalibration1(lpTWXY)

Description:

For all touchscreens EXCEPT MicroTouch: This function disables the normal function of TWdriver for the next touch. The next touch will not activate Windows in the normal way, ie, as a mouse. TWdriver waits for the next touch to complete, ie waits for a finger lift, then returns the RAW coordinates in the TWXY structure. It is then the callers's responsibility to adjust the coordinates if necessary and update the TWcalib file, if required. After this call returns, TWdriver returns to its normal functionality. For MicroTouch touchscreens: This function puts the controller into hard calibration mode, when it will wait for two touches. The first must be at the extreme bottom left corner of the video image and the second at the extreme top right corner of the image. For TWReadCalibration1, the X and Y coordinates returned are 0 and 0. For TWReadCalibration2, the X and Y coordinates returned are 999 and 999. These values should be stored as the soft calibration for the relevant video mode as normal, and will effectively cause TWdriver to map to the hard calibration. In either case, status returned is zero for successful calibration, or any other value if more than thirty seconds elapsed without a touch. If calibration times out on a MicroTouch controller, the calibration program should display the message “Calibration aborted - you may need to power the touchscreen controller off and on”.

Parameter:

lpTWXY. Far pointer to a TWXY structure. E-19

Page 190

VRC 4000 Software Driver Manual

Structure:

Pascal: TWxy = Record status: X: Y: end;

byte; { return status } word; { raw X coordinate } word; { raw Y coordinate }

C: typedef struct { BYTE status; /* return status */ WORD X; /* raw X coordinate */ WORD Y; /* raw Y coordinate */ } TWxy;

E-20

Page 191

Appendix E: TWDriver Application Programming Interface

Function: Syntax: Description:

TWUpdateCalibration TWUpdateCalibration(brfu,wX1,wY1,wX2,wY2,bInvertX,bInvertY)

This function updates the calibration coordinates in TWdriver's internal calibration coordinate buffer, replacing the values loaded from the TWcalib file. Parameter brfu wX1 wY1 wX2 wY2 bInvertX bInvertY

Type byte word word word word byte byte

Description Must be zero Raw coordinates of left edge Raw coordinates of bottom edge Raw coordinates of right edge Raw coordinates of top edge 1 = X axis inversion required ; 0 = no 1 = Y axis inversion required ; 0 = no

E-21

Page 192

VRC 4000 Software Driver Manual

Function: Syntax:

TWSendData

Description:

This function is available for all touchscreens, but is only functional with certain serial touchscreens. The raw data pointed to by lpDataBuff is sent to the touchscreen. The function returns immediately, without waiting for any response.

Parameters:

wDataLength is the number of bytes to send to the touchscreen, starting at the address given by lpDataBuff.

E-22

TWSendData(lpDataBuff : LPvoid; wDataLength : Word)

Page 193

Appendix E: TWDriver Application Programming Interface

Function: Syntax:

TWReceiveData

Description:

This function is available for all touchscreens, but is only functional with certain serial touchscreens. Any data received from the touchscreen which is not recognized as touch coordinates or other data relevant to TWdriver is placed in an internal buffer, 255 bytes in length. This API call transfers any data in that internal buffer to the buffer pointed to by lpDataBuff, and the internal buffer is reset. Note that the responsibility for synchronizing with incoming non-touch data lies with the application, not with TWdriver.

TWReceiveData(lpDataBuff : LPvoid; wDataLength : Word)

wDataLength specifies the maximum length of the buffer pointed to by lpDataBuff, which TWdriver will not exceed. However, the value returned in wDataLength specifies the amount of data which was available for transfer, even if this was greater than the buffer length given. In this case, the additional data is lost, as the internal buffer is still reset, even if not all the data could be transferred.

Parameters:

wDataLength is the length of the buffer pointed to by lpDataBuff.

E-23

Page 194

VRC 4000 Software Driver Manual

The Calibration Data File Calibration data for the touchscreen is held in a file called TWcalib which by default resides in the Windows directory, but can reside elsewhere as defined by the PATH= command in the [Touch-Base] section of Win.ini. The format of the file is:

Pascal: CalFileRec = RECORD FileVersion: BYTE; { $A4 } HardwareType: BYTE; { Touchscreen type } InvertX: BOOLEAN; { True if X coordinates need to be inverted } InvertY: BOOLEAN; { True if Y coordinates need to be inverted } X1: integer; { bottom left X coordinate } Y1: integer; { bottom left Y coordinate } X2: integer; { top right X coordinate } Y2: integer; { top right Y coordinate } reserved: array[0..99] of byte; END;

'C': typedef struct { BYTE BYTE BYTE BYTE INT INT INT INT BYTE } CalFileRec;

E-24

FileVersion; HardwareType; InvertX; InvertY; X1; Y1; X2; Y2; reserved[100];

/* 0xA4 */ /* Touchscreen type */ /* 1 if X coordinates need to be inverted, else 0 */ /* 1 if Y coordinates need to be inverted, else 0 */ /* bottom left X coordinate */ /* bottom left Y coordinate */ /* top right X coordinate */ /* top right Y coordinate */

Page 195

Appendix E: TWDriver Application Programming Interface

Note: FileVersion is used to identify the file as a TWcalib file, and must have the value A4 hex. Hardware Type is the Touch-Base defined hardware type number for the touchscreen in use. See section ’Touchscreen Type Numbers’. InvertX and InvertY should be set to 1 if touch coordinates need to be inverted in order to restore the origin to the top left of the screen, as required by Windows. X1, Y1 are the RAW coordinates returned by the touchscreen for the bottom left hand corner of the screen. X2, Y2 are the RAW coordinates returned by the touchscreen for the top right hand corner of the screen.

E-25

Page 196

VRC 4000 Software Driver Manual

Calibration Procedure The following minimum logic is required for a calibration procedure to be built into an application: 1. Check for the presence of TWdriver (see section “Before calling the API”) 2. Perform TWGetInfo call to determine touchscreen type and calibration file pathname. 3. Display prompt for user to touch extreme bottom left hand corner of physical screen. 4. Perform TWReadCalibration1 call to get raw coordinates touched. If timeout occurs, display message and quit. 5. Display prompt for user to touch extreme top right hand corner of physical screen. 6. Perform TWReadCalibration2 call to get raw coordinates touched. If timeout occurs, display message and quit. 7. Calculate invertX and invertY as follows: If X1 (bottom edge) > X2 (top edge) then touchscreen's X origin is its bottom edge, so X inversion is needed If Y2 (right edge) > Y1 (left edge) then touchscreen's Y origin is its right edge, so Y inversion is needed 8. Call TWUpdateCalibration to make the new coordinates active in TWdriver. 9. Re-create the TWcalib file using the new data, so that it will be used the next time TWdriver loads.

E-26

Page 197

Appendix E: TWDriver Application Programming Interface

Calibration Points 20% From True Edges In some cases the active video area may extend slightly beyond the active touch area, and a few touchscreens suffer from poor linearity at their extreme corners. In order to alleviate these problems TWsetup displays its calibration reference points 20% away from the true edges of the physical screen. The TWReadCalibration calls still return the actual coordinates touched, and so TWsetup must interpolate the coordinates of the true edges to pass back to the TWUpdateCalibration call and to store in the TWcalib file. The algorithm for this is as follows: • If invertX is set, then the left edge is high, so X1 is the high value edge and

X2 is the low value edge. • If invertX is not set, then the right edge is high, so X2 is the high edge and

X1 is the low edge. • DECREASE the value of the low value edge X coordinate by 1/3 of the difference between the returned X1 and X2. • INCREASE the value of the high value edge X coordinate by 1/3 of the difference between the returned X1 and X2. • If invertY is set, then the top edge is high, so Y2 is the high value edge and

Y1 is the low value edge. • If invertY is not set, then the bottom edge is high, so Y1 is the high edge and Y2 is the low edge. • DECREASE the value of the low value edge Y coordinate by 1/3 of the difference between the returned Y1 and Y2. • INCREASE the value of the high value edge Y coordinate by 1/3 of the difference between the returned Y1 and Y2.

MicroTouch Touchscreens For MicroTouch touchscreens, the TWReadCalibration procedures perform the hardware calibration procedure, storing the calibration coordinates in the touchscreen controller hardware. For this to work properly, the points touched must be at the extreme corners of the video image. Calibration programs using a “20% in” strategy must not do so if the touchscreen type is MicroTouch.

E-27