Touch screen Driver Analysis

Source: Internet
Author: User

Touch screen driver analysis: (local drive)

Author: Lai yuping (auly) aulyp@163.com

The Touch Screen driver is a local driver. Microsoft provides the general-purpose-layer mdd. You only need to write the PDD layer. The Touch Screen driver is loaded by GWES, and GWES interacts with the driver through the device driver interface (DDI) in the DDI layer, the PDD layer implements the device driver Service Provider Interface (ddsi) to support the system and control the hardware. Their relationship is: MDD links to the PDD layer and defines the function interface that it wants to call: the device driver provider interface. At the same time, MDD provides different function sets to the operating system.

The Touch Screen driver of Windows CE links two static link libraries, tch_cal.lib and tchmdd. Lib.

So remember to add the following:

Sourcelibs = \

$ (_ Commonoakroot) \ Lib \ $ (_ cpuindpath) \ tch_cal.lib \

$ (_ Commonoakroot) \ Lib \ $ (_ cpuindpath) \ tchmdd. Lib

Standard Interface Declaration (Declaration in touch. Def definition)

Touchpanelgetdevicecaps;

Touchpanelenable;

Touchpaneldisable;

Touchpanelsetmode;

Touchpanelreadcalibrationpoint;

Touchpanelreadcalibrationabort;

Touchpanelsetcalibration;

Touchpanelcalibrateapoint;

Touchpanelpowerhandler;

Details:

The DDI interface is tchmain in wince500 \ public \ common \ oak \ drivers \ Touch \ tchmain. implemented in C producer. In this consumer, MDD calls the ddsi interface of PDD to implement the DDI function.

DDI interfaces include touchpanelgetdevicecaps,

Touchpanelenable,

Touchpaneldisable,

Touchpanelsetmode,

Touchpanelreadcalibrationpoint, touchpanelreadcalibrationabort,

Touchpanelsetcalibration,

Touchpanelcalibrateapoint,

Touchpanelpowerhandler.

The PDD layer is what we really want to write and is directly related to the hardware to be driven.

Ddsi interfaces include:

Ddsitouchpanelattach,

Ddsitouchpaneldetach,

Ddsitouchpaneldisable,

Ddsitouchpanelenable,

Ddsitouchpanelgetdevicecaps,

Ddsitouchpanelgetpoint,

Ddsitouchpanelpowerhandler.

We will focus on the ddsi functions to be implemented at the PDD layer.

Ddsitouchpanelenable
Called by touchpanelenable

1: Create the htouchpanelevent and hcalibrationsampleavailable events.

2: Check and initialize the required interrupt gintrtouch (touch screen interrupt) and

Gintrtouchchanged (timer interrupt)

3: Create an ISR thread touchpanelpisr

4:
Ddsitouchpaneldisable,
Ddsitouchpanelgetpoint:
The function obtains the position and status information of the current touch screen;
Ddsitouchpanelgetdevicecaps
Number of calibration points

Called by touchpanelgetdevicecaps

MDD analysis:

Between the file in the PDD layer and the MDD and the sequence, the tchddsi. h header is included together. To realize the general logic interrupt number and interrupt transfer. In wince5.0, The tchddsi. h file is placed in D: \ wince500 \ public \ common \ oak \ Inc. You can modify it if necessary.

The interface function declaration is also in the touch. Def file in this directory.

From tchddsi. h

// Define the logical interrupt number of the touch interrupt and timer interrupt

Extern DWORD gintrtouch;

Extern DWORD gintrtouchchanged;

In the tchmail. c file,

1: The touchpanelenable function mainly performs the following work:

// Associate the interrupt with the event

Interruptinitialize (gintrtouch, htouchpanelevent, null, 0)

Interruptinitialize (gintrtouchchanged, htouchpanelevent, null, 0)

// Create an ISR thread

Hthread = createthread (null, 0, touchpanelpisr, 0, 0, null)

// Obtain the thread priority

Touchpanelpgetpriority (& gthreadpriority, & gthreadhighpriority );

// Sets the thread priority.

Cesetthreadpriority (hthread, gthreadpriority );

2: touchpanelgetdevicecaps function:

Message sending to the system at the MDD layer

The MDD layer uses pfn_touch_panel_callback v_pfnpointcallback;

Messages sent to the system by Structure

3: touchpanelpattach function:

It mainly generates an event htouchpanelevent.

Hcalibrationsampleavailable

Htouchpanelevent = createevent (null,

False, // not manual reset

False, // not signalled

Null );

4: touchpanelreadcalibrationpoint Function

For screen calibration, read the corresponding touch screen coordinate value /.

Touchpanelreadcalibrationabort (void); end the current active calibration activity ()

5: touchpanelsetcalibration

Process the calibration data read by the touchpanelreadcalibrationpoint function above, which generates the calibration benchmark parameter,

The touchpanelsetcalibration function executes a set of mathematical algorithms. The specific content is:

The relationship between the touch screen data and its position offset is also linear.

In this case, the location information returned by the touch screen and the pixel location information are converted to 2D coordinates.

For the touch screen coordinate (TX, Ty) of the touch screen pressed by the touch screen and the point in the relationship between the display device location

The Conversion Relationship between screen coordinates (sx, Sy) can be expressed by the following coordinate transformations:

SX = A1 * Tx + B1 * ty + C1

Sy = a2 * Tx + B2 * ty + C2

Touchpanelsetcalibration is the screen coordinate obtained through the calibration action.

And touch screen coordinates touchcoordinate to determine A1, B1, C1 and A2, B2, C2.

Message definition: there are various message definitions in the file pegc_def.h. If necessary, you can modify them to combine them for use.

// Touch handler WND messages

# Define wm_stub_registwnd wm_user + 1

# Define wm_stub_unregistwnd wm_user + 2

# Define wm_stub_setvalue wm_user + 3

# Define wm_stub_getvalue wm_user + 4

# Define wm_stub_reset wm_user + 5

# Define wm_stub_event wm_user + 6

# Define wm_stub_getfocuswnd wm_user + 7

# Define wm_stub_focusback wm_user + 8

# Define wm_stub_getlasttouchfocuswnd wm_user + 9

# Define wm_stub_getversion wm_user + 10

# Define wm_stub_tablet wm_user + 11

# Define wm_stubhook_getfocus wm_user + 3000

# Define wm_stubhook_ready wm_user + 3001

Start Process:

This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/ok138ok/archive/2009/08/02/4399110.aspx

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.