示例#1
0
void MLX_API Driver_C_KeyBoard()									//KB driver c function
{
	unsigned char r=ReadKBRear();
	unsigned char f=ReadKBFront();
	static unsigned char shiftKey=0;
	char bb[2];
	char *keyBuff=(char*)KEY_BUFF_ADDR;
	unsigned char k;
	k=PortIn(0x60);
	if (k==0x2A || k==0x36)
	{
		shiftKey=1;
		return;
	}
	if (k==0xAA || k==0xB6)
	{
		shiftKey=0;
		return;
	}  
	k=GetAsciiCode(k,shiftKey);
	bb[1]=0;
	bb[0]=k;
	if (k==0)
	{
		return;
	}
	if ((r+1)%256==f)
	{   
		return;
	}
	keyBuff[r]=k;
	r++;
	SetKBRear(r);
}
示例#2
0
DWORD WINAPI CController::CheckKeybDisconnectionThread(LPVOID lpv)
{
	COPYDATASTRUCT cds;
	char szKbdEvent[1024];

	CController* pThis = (CController*)lpv;
	while(TRUE)
	{
		int c = 0;
		PortOut(0x60, 0x23);

		while(PortIn(0x60) != (char)0xFE)
		{
			c++;
		}
		PortOut(0x60, 0xEE);

		if ( c!= 0 )
		{
			char szStatus[256];
			if(c > pThis->dwBaseValue4ChkKeybCon)
			{
				if(g_nIsKeyBoardDisconnected == 0) 
				{
					sprintf(szStatus, "Keyboard is disconnected");
					//::MessageBox(NULL, szStatus, "Alarm", MB_OK);
					g_nIsKeyBoardDisconnected = 1;

					strcpy(szKbdEvent,"disconnect");
					cds.dwData = CLIENT_NOTIFICATION_KEYBOARD_EVENT;
					cds.cbData = strlen(szKbdEvent);
					cds.lpData = szKbdEvent;
					SendMessage((HWND)pThis->m_hDlg,WM_COPYDATA,0,(LPARAM)&cds);

				}
			}else if(c <= pThis->dwBaseValue4ChkKeybCon)
			{
				if(g_nIsKeyBoardDisconnected == 1)
				{
					sprintf(szStatus, "Keyboard is connected");
					//::MessageBox(NULL, szStatus, "Alarm", MB_OK);

					g_nIsKeyBoardDisconnected = 0;

					strcpy(szKbdEvent,"reconnect");
					cds.dwData = CLIENT_NOTIFICATION_KEYBOARD_EVENT;
					cds.cbData = strlen(szKbdEvent);
					cds.lpData = szKbdEvent;
					SendMessage((HWND)pThis->m_hDlg,WM_COPYDATA,0,(LPARAM)&cds);

					pThis->CheckKeyLogger();
				}
			}
		}
		Sleep(4000);
	}

	return 1;
}