Appendix, 5 appendix – Hatteland Display 13 inch - HD 13T21 MMC (Widescreen, Inte Cor2 Duo CPU) User Manual

Page 11

Advertising
background image

DOC101699-1- rev 02 -2014-01-17 - Created by:6644

Page 11 of 12

Hatteland Display AS, Åmsosen, N-5578 Nedre Vats, Norway

Tel: (+47) 4814 2200 - [email protected] - www.hatteland-display.com

DOC101699-1_Touch_Keypad_Access

All intellectual properties belongs to Hatteland Display AS

5 Appendix


The code is to describe the simple procedure of accessing HID device via HIDAPI only. Not

compliable.

void

main

(

void

)

{

//enumurate all the HID devices

struct

hid_device_info

*

devs

,

*

cur_dev

;


devs

=

hid_enumerate

(

0x0

,

0x0

);

cur_dev

=

devs

;

while

(

cur_dev

)

{

//Compare VID and PID

if

(

cur_dev

->

vendor_id

==

TOUCH_VID

&&

cur_dev

->

product_id

==

TOUCH_PID

)

{

if

(

cur_dev

->

path

)

{

//Search "Col03" in current device path,

//if yes, Touch keypad is found.

if

(

strstr

(

cur_dev

->

path

,

"col03"

)!=

NULL

)

break

;

}

}

cur_dev

=

cur_dev

->

next

;

}


if

(

cur_dev

==

NULL

)

{

MessageBox

(

_T

(

"Can't find target HID

device!"

),

NULL

,

MB_ICONWARNING

);

return

;

}

//Free Enumeration

hid_free_enumeration

(

devs

);

//Open HID device

handle

=

hid_open

(

TOUCH_VID

,

TOUCH_PID

,

NULL

);

if

(!

handle

)

{

printf

(

"unable to open device\n"

);

return

1

;

}

// Set the hid_read() function to be non-blocking.

hid_set_nonblocking

(

handle

,

1

);

//Profile button key press

while

(

1

)

{

res

=

hid_read

(

handle

,

buf

,

64

);

if

(

res

>

0

)

{

if

(

buf

[

0

]!=

0x03

)

{

printf

(

"Error in Report ID!\n"

)

Advertising