The following steps detail the basic algorithm for using the touch screen:
Call TouchPanelEnable to start the screen sampling.
Call TouchPanelGetDeviceCaps to request the number of sampling points.
For every calibration point, perform the following steps:
Call TouchPanelGetDeviceCaps to get a calibration coordinate.
Draw a crosshair at the returned coordinate.
Call TouchPanelReadCalibrationPoint to get calibration data.
Call TouchPanelSetCalibration to calculate the calibration coefficients.
After executing this sequence, any finger or stylus samples generated for the screen are passed to the callback function specified in TouchPanelEnable. The driver may pass either calibrated or uncalibrated points to the callback. If the driver has an efficient calibration algorithm, it can return calibrated points. However, if the calibration is computationally intensive, the driver may choose to return uncalibrated points, rather than perform extensive calculations in the high-priority driver thread. The lower priority thread processing points from the callback can then perform the calibration.
You can calibrate your touch screen without the ENTER key. The GWES keyboard code opens HKEY_LOCAL_MACHINEHARDWAREDEVICEMAPKEYBD and looks for a DWORD value called Status. This is a bit mask combining the KBDI_KEYBOARD_XXX values from %_WINCEROOT%PublicCommonSDKINCKeybd.h. If it is not found, GWES assumes KBDI_KEYBOARD_PRESENT | KBDI_KEYBOARD_ENTER_ESC | KBDI_KEYBOARD_ALPHA_NUM. This registry access only occurs once, when the keyboard driver is loaded. This value is the basis for what you get when you call GetKeyboardStatus. GWES will add or subtract the KBDI_KEYBOARD_ENABLED bit based on EnableHardwareKeyboard calls. The KBDI_KEYBOARD_ENABLED bit is set when the keyboard driver is loaded. The UseEnterEsc behavior can be controlled by a registry key.
The following table shows the touch screen driver functions.
The following steps detail the basic algorithm for using the touch screen:
Call TouchPanelEnable to start the screen sampling.
Call TouchPanelGetDeviceCaps to request the number of sampling points.
For every calibration point, perform the following steps:
Call TouchPanelGetDeviceCaps to get a calibration coordinate.
Draw a crosshair at the returned coordinate.
Call TouchPanelReadCalibrationPoint to get calibration data.
Call TouchPanelSetCalibration to calculate the calibration coefficients.
After executing this sequence, any finger or stylus samples generated for the screen are passed to the callback function specified in TouchPanelEnable. The driver may pass either calibrated or uncalibrated points to the callback. If the driver has an efficient calibration algorithm, it can return calibrated points. However, if the calibration is computationally intensive, the driver may choose to return uncalibrated points, rather than perform extensive calculations in the high-priority driver thread. The lower priority thread processing points from the callback can then perform the calibration.
You can calibrate your touch screen without the ENTER key. The GWES keyboard code opens HKEY_LOCAL_MACHINEHARDWAREDEVICEMAPKEYBD and looks for a DWORD value called Status. This is a bit mask combining the KBDI_KEYBOARD_XXX values from %_WINCEROOT%PublicCommonSDKINCKeybd.h. If it is not found, GWES assumes KBDI_KEYBOARD_PRESENT | KBDI_KEYBOARD_ENTER_ESC | KBDI_KEYBOARD_ALPHA_NUM. This registry access only occurs once, when the keyboard driver is loaded. This value is the basis for what you get when you call GetKeyboardStatus. GWES will add or subtract the KBDI_KEYBOARD_ENABLED bit based on EnableHardwareKeyboard calls. The KBDI_KEYBOARD_ENABLED bit is set when the keyboard driver is loaded. The UseEnterEsc behavior can be controlled by a registry key.
The following table shows the touch screen driver functions.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this sample source code is subject to the terms of the Microsoft
// license agreement under which you licensed this sample source code. If
// you did not accept the terms of the license agreement, you are not
// authorized to use this sample source code. For the terms of the license,
// please see the license agreement between you and Microsoft or, if applicable,
// see the LICENSE.RTF on your install media or the root of your tools installation.
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
//
/*++
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.
Module Name:
tchddi.h
Abstract:
This module contains all the definitions for the DDI (Device Driver
Interface) for the touch panel device.
This module contains all the definitions for the DDI (Device Driver
Interface) for the touch panel device.
--*/
#ifndef __TCHDDI_H__
#define __TCHDDI_H__
#ifdef __cplusplus
extern "C" {
#endif
//
// Definitions
//
/* @TYPE TOUCH_PANEL_SAMPLE_FLAGS |
These flags specify information about a given touch sample sent to the input system.
See Also:
*/
typedef UINT32 TOUCH_PANEL_SAMPLE_FLAGS, *P_TOUCH_PANEL_SAMPLE_FLAGS;
/* @ENUM enumTouchPanelSampleFlags | The specific values of the touch sample flags.
@XREF
@COMM
The TouchSampleValidFlag is set to indicate a valid reading. The driver
is allowed to report back an invalid reading to the input system (which
will be ignored) but these should be kept to an absolute minimum.
The TouchSampleDownFlag shows the state of finger or stylus. When the
finger or stylus is pressed to the touch screen, the driver will be
reporting back readings with both the valid and down flags set. When the
stylus or finger is removed from the touch screen, the driver is REQUIRED
to send back at least one reading with the valid flag set but the down
flag cleared to indicate that the stylus/finger is up.
The TouchSampleIsCalibratedFlag is set by the driver to notify the input
system that it is not necessary to further calibrate the XY coordinates of
the sample.
The TouchSamplePreviousDownFlag shows the state from the previous valid
sample. It is not necessary for the driver to report this to the input
system but it is useful in the driver itself.
*/
enum enumTouchPanelSampleFlags
{
TouchSampleValidFlag = 0x01, //@EMEM The sample is valid.
TouchSampleDownFlag = 0x02, //@EMEM The finger/stylus is down.
TouchSampleIsCalibratedFlag = 0x04, //@EMEM The XY data has already been calibrated.
TouchSamplePreviousDownFlag = 0x08, //@EMEM The state of the previous valid sample.
TouchSampleIgnore = 0x10, //@EMEM Ignore this sample.
BOOL
TouchPanelGetDeviceCaps(
INT iIndex,
LPVOID lpOutput
);
typedef BOOL (*PFN_TOUCH_PANEL_GET_DEVICE_CAPS)(
INT iIndex,
LPVOID lpOutput
);
BOOL
TouchPanelSetMode(
INT iIndex,
LPVOID lpInput
);
typedef BOOL (*PFN_TOUCH_PANEL_SET_MODE)(
INT iIndex,
LPVOID lpInput
);
//
// Function Prototype definition for the point callback function
//
// @type PFN_TOUCH_PANEL_CALLBACK |
// The function signature for the calibration and point callback functions.
// A pointer to this function is passed to . The
// touch driver subsequently calls this function whenever a new touch
// sample is generated.
// @comm
// The signature function is:
// typedef VOID (*PFN_TOUCH_PANEL_CALLBACK)(
// DDI_TOUCH_PANEL_SAMPLE_FLAGS,
// INT,
// INT
// );
//
typedef BOOL (*PFN_TOUCH_PANEL_CALLBACK)(
TOUCH_PANEL_SAMPLE_FLAGS Flags,
INT X,
INT Y
);
typedef VOID (*PFN_DISP_DRIVER_MOVE_CURSOR)(
INT32 X,
INT32 Y
);
BOOL
TouchPanelReadCalibrationPoint(
INT *pUncalibratedX,
INT *pUncalibratedY
);
typedef BOOL (*PFN_TOUCH_PANEL_READ_CALIBRATION_POINT)(
INT *pUncalibratedX,
INT *pUncalibratedY
);