📄 ps2port.hpp
字号:
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
/*
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.
*/
#ifndef __PS2PORT_HPP_INCLUDED__
#define __PS2PORT_HPP_INCLUDED__
#include <windows.h>
/*++
Ps2Port:
This is a very simplistic i8042 interface.
It does not provide a complete interface to the i8042 chip. It is
intended to provide only basic keyboard and mouse support.
--*/
#define GPIO_PBDR_OFFSET 0x0004
#define GPIO_PBDDR_OFFSET 0x0014
class Ps2Port
{
CRITICAL_SECTION m_csWrite;
HANDLE m_hDevEvent;
int m_cEnterWrites;
BOOL m_bMouseFound;
BOOL m_bIntelliMouseFound;
UINT8 m_ui8CmdByte;
BOOL m_fEnableWake;
void CommandWrite( UINT8 cmd8042 )
{
WritePort( cmd8042 );
}
void WritePort( UINT8 data );
BOOL ReadPort( PUCHAR pui8Data );
UINT8 MouseId( void );
void SetModeIntelliMouse ( void );
public:
BOOL MouseTest( void );
BOOL Initialize( unsigned int iopBase );
BOOL KeyboardInterfaceTest( void );
BOOL KeyboardReset( void );
void KeyboardLights( unsigned int fLights );
BOOL KeyboardCommandPut( UINT8 ui8Cmd );
BOOL KeybdDataRead( UINT8 *pui8Data );
BOOL MouseDataRead( UINT8 *pui8Data );
BOOL bIntelliMouseFound( void );
// Note: On a PS/2 controller, if you have both a keyboard and mouse
// connected and one is set to wake but the other is not, there is a good
// chance that neither will wake the system. If the non-wake source
// has activity, its data will fill the controller's output buffer, but it will not
// be removed. Then, if the wake source has activity, it will wait for the
// controller to accept its data, but this will not happen until the data in
// the controller's output buffer is read. Thus, no activity on either device
// will wake the system. Moral: Have both the keyboard and mouse set as
// wake sources or neither set as wake sources. We enforce that here.
HANDLE GetDeviceEvent( void )
{
return m_hDevEvent;
}
void InterruptDone( void );
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -