环境 TCC8900 官方V2.0版本BSP,WinCE6.0
使用扫描式键盘,驱动中通过keybd_event模拟按键消息:
发现上下左右确认等功能按键可以使用,如‘1’,‘a’等字符无法输入。
使用MFC编写代买,定时发送'a',在VS2005自带CE虚拟机上可以正常将‘a’输入到焦点处,下载到CE设备上依然有问题
使用USB远程桌面,同样也不能输入字符,而功能键正常。
驱动相关代码如下:
void KEY_SendEvent(int CurrentKey)
{
unsigned int timetick;
if(CurrentKey > 0) // Key pushed down
{
CurrentState = PRESSED;
timetick = GetTickCount();
if( (PreviousKey == CurrentKey) && ( (timetick - lasttick)<KEY_REPEAT_TIME) )
return ;// same key is pressed for a long time
keybd_event(CurrentKey,0,0,0); // If the second param is not specified, the key is being pressed.
RETAILMSG(1,(TEXT("[KEY ] Key %d Pressed\r\n"),CurrentKey));
lasttick = timetick;
PreviousKey = CurrentKey;
PreviousState = CurrentState;
return;
}
else // Key Release
CurrentState = RELEASED;
if( PreviousState == PRESSED) {
keybd_event(PreviousKey, 0, KEYEVENTF_KEYUP,0);
RETAILMSG(1,(TEXT("[KEY ] Key %d Released\r\n"),PreviousKey));
}
PreviousState = CurrentState;
PreviousKey = CurrentKey;
}
.bib文件
tcc_keypad.dll $(_FLATRELEASEDIR)\tcc_keypad.dll $(XIPKERNEL) SHK
请问诸位有没有遇到过类似情况,如何解决,先谢过。
------解决方案--------------------
PRESSED和RELEASED是不是配合使用的?
if
keybd_event(CurrentKey,0,0,0);
else
keybd_event(PreviousKey, 0, KEYEVENTF_KEYUP,0);
有问题吗?