阅读:3832回复:3
HID键盘,在VC中用ReadFile()没法返回数据!
VC应用程序是在网上找的,HID固件是cypress的一个HID键盘例子
每次执行到ReadFile()就不行? if( !ReadFile( hCom, InputReport, InputReportLen, &TransBytes, NULL)) { CString strShow; strShow.Format("Could not read value %d\r\n", GetLastError()); m_strLog += strShow; SetDlgItemText(IDC_EDIT_RESULT,m_strLog); } 另外InputReportByteLength=6对应着下面报表的哪一句啊? HIDReportDscr: db 05h, 01h ; Usage Page (Generic Desktop) db 09h, 06h ; Usage (Keyboard) db 0A1h, 01h ; Collection (Application) db 05h, 07h ; Usage Page (Key codes) db 19h, 0E0h ; Usage minimum (234) db 29h, 0E7h ; Usage maximum (231) db 15h, 00h ; Logical minimum (0) db 25h, 01h ; Logical maximum (1) db 75h, 01h ; Report size (1) db 95h, 08h ; Report count (8) db 81h, 02h ; Input (data, variable, absolute) db 95h, 01h ; Report count (1) db 75h, 08h ; Report size (8) db 81h, 01h ; Input (constant) db 95h, 05h ; Report count (5) db 75h, 01h ; Report size (1) db 05h, 08h ; Usage Page (LED) db 19h, 01h ; Usage minimum (1) db 29h, 05h ; Usage maximum (5) db 91h, 02h ; Output (data, variable, absolute) db 95h, 01h ; Report count (1) db 75h, 03h ; Report size (3) db 91h, 01h ; Output (constant) db 95h, 03h ; Report count (3) db 75h, 08h ; Report size (8) db 15h, 00h ; Logical minimum (0) db 25h, 65h ; Logical maximum (101)// db 05h, 07h ; Usage page (key codes) db 19h, 00h ; Usage minimum (0) db 29h, 65h ; Usage maximum (101) db 81h, 00h ; Input (data, array) //----------- db 0C0h ; End Collection HIDReportDscrEnd: |
|
沙发#
发布于:2007-11-08 08:21
帖一下你之前的代码先
|
|
板凳#
发布于:2007-11-08 21:18
我查了很多以前的网页,都说在win2000和winXP下是无法读写HID设备的!真是这样么?
那我用directX SDK的API来读写行不?另外,我的68013除了传标准按键信息外,还要传8字节的其他信息,不知道报表方面怎么写? |
|
地板#
发布于:2007-11-09 09:14
引用第2楼helloxieyu于2007-11-08 21:18发表的 : 你的描述不正确,是在Win2000和WinXP下不能用CreateFile+ReadFile/WriteFile的方式来读写标准鼠标和标准键盘的数据,因为它们是系统独占的(Exlusive)。 如果你是其他HID类设备,比如游戏手柄或者自定义HID设备,都可以用上面的方式来收发数据。 解决的方法是: 1、你要么不要定义成标准键盘或标准鼠标; 2、要么用其他的方式读。具体怎么读,我也没有研究过,但是很感兴趣,如果你做出来了,记得发帖子分享一下,或者给我发站内信息或邮件。谢谢。 |
|