📄 ps2keybd.cpp
字号:
/*
Copyright(c) 1998,1999 SIC/Hitachi,Ltd.
Copyright(c) 1998,1999 3RD Rail Engineering.
Module Name:
ps2keybd.cpp
Revision History:
26th April 1999 Released
16th June 1999 Revised
*/
#include <windows.h>
#include <ceddk.h>
#include <nkintr.h>
//#include <oalintr.h>
#include <pkfuncs.h>
#include <keybddr.h>
#include <keybdpdd.h>
#include "ps2p465.hpp"
#include "ps2mouse.hpp"
#include "ps2keybd.hpp"
#include "dbgzones.hpp"
// Scan code consts
static const UINT8 scE0Extended = 0xe0;
static const UINT8 scE1Extended = 0xe1;
static const UINT8 scKeyUpMask = 0x80;
extern PVBYTE v_pIoRegs;
extern DWORD dwSysIntrKeyboard;
// There is really only one physical keyboard supported by the system.
Ps2K465 *v_pp2k;
static KEY_STATE_FLAGS v_KeyStateToggled;
void
WINAPI
KeybdPdd_PowerHandler(
BOOL bOff
)
{
return;
}
BOOL
WINAPI
KeybdPdd_InitializeDriverEx(
PFN_KEYBD_EVENT_CALLBACK_EX pfnKeybdEventCallbackEx
)
{
return TRUE;
}
int
WINAPI
KeybdPdd_GetEventEx(
UINT32 VKeyBuf[16],
UINT32 ScanCodeBuf[16],
KEY_STATE_FLAGS KeyStateFlagsBuf[16]
)
{
UINT8 ui8ScanCode;
INT cEvents = 0;
KEY_STATE_FLAGS KeyStateFlags;
static UINT32 scInProgress;
static UINT32 scPrevious;
static BOOL tfKeyUp;
v_pp2k -> m_pp2p -> KeybdDataRead(&ui8ScanCode);
DEBUGMSG(ZONE_SCANCODES, (TEXT("ps2keybd.cpp: ScanCode: %02X\r\n"), ui8ScanCode));
if ( ui8ScanCode == 0xf0 )
{
tfKeyUp = TRUE;
}
else if ( ui8ScanCode == scE0Extended )
{
scInProgress = 0xe000;
}
else if ( ui8ScanCode == scE1Extended )
{
scInProgress = 0xe10000;
}
else if ( scInProgress == 0xe10000 )
{
scInProgress |= ui8ScanCode << 8;
}
else
{
scInProgress |= ui8ScanCode;
if ( ( scInProgress == scPrevious ) && ( tfKeyUp == FALSE ) )
{
// mdd handles auto-repeat so ignore auto-repeats from keybd
}
else // Not a repeated key. This is the real thing.
{
if ( tfKeyUp == TRUE )
{
KeyStateFlags = 0;
scPrevious = 0x00000000;
}
else
{
KeyStateFlags = KeyStateDownFlag;
scPrevious = scInProgress;
}
cEvents = ScanCodeToVKeyEx(scInProgress, KeyStateFlags, VKeyBuf, ScanCodeBuf, KeyStateFlagsBuf);
}
scInProgress = 0;
tfKeyUp = FALSE;
}
v_pp2k -> m_pp2p -> KeybdInterruptEnable();
return(cEvents);
}
void
WINAPI
KeybdPdd_ToggleKeyNotification(
KEY_STATE_FLAGS KeyStateFlags
)
{
unsigned int fLights;
v_KeyStateToggled = KeyStateFlags;
fLights = 0;
if ( KeyStateFlags & KeyShiftCapitalFlag )
{
fLights |= 0x04;
}
if ( KeyStateFlags & KeyShiftNumLockFlag )
{
fLights |= 0x02;
}
v_pp2k -> m_pp2p -> KeyboardLights(fLights);
return;
}
KEY_STATE_FLAGS
WINAPI
KeybdPdd_KeyStateToggled(
void
)
{
return v_KeyStateToggled;
}
BOOL
KeybdIstLoop(
HANDLE hevIntrKeybd
);
BOOL
Ps2K465::
IsrThreadProc(
void
)
{
m_hevInterrupt = CreateEvent(NULL, FALSE, FALSE, NULL);
if ( m_hevInterrupt == NULL)
{
goto leave;
}
if ( !InterruptInitialize(dwSysIntrKeyboard, m_hevInterrupt, NULL, 0) )
{
goto leave;
}
m_pp2p -> KeybdInterruptEnable();
KeybdIstLoop(m_hevInterrupt);
leave:
return 0;
}
DWORD
Ps2K465IsrThread(
Ps2K465 *pp2k
)
{
pp2k -> IsrThreadProc();
return 0;
}
BOOL
Ps2K465::
IsrThreadStart(
void
)
{
HANDLE hthrd;
hthrd = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)Ps2K465IsrThread, this, 0, NULL);
// Since we don't need the handle, close it now.
CloseHandle(hthrd);
return TRUE;
}
BOOL
Ps2K465::
Initialize(
Ps2P465 *pp2p
)
{
BOOL bRet = FALSE;
m_pp2p = pp2p;
if ( !m_pp2p -> KeyboardInterfaceTest() )
{
ASSERT(0);
goto leave;
}
v_pp2k -> m_pp2p -> KeyboardLights(0);
return bRet = TRUE;
leave:
return bRet;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -