diff -u PS2_8042/ps2keybd.cpp PS2_XT_PATCH/ps2keybd.cpp --- PS2_8042/ps2keybd.cpp 2004-07-01 13:00:00.000000000 -0700 +++ PS2_XT_PATCH/ps2keybd.cpp 2006-05-12 18:46:18.770932800 -0700 @@ -34,7 +34,102 @@ static const UINT8 scE0Extended = 0xe0; static const UINT8 scE1Extended = 0xe1; +#ifndef MODE_XT static const UINT8 scKeyUp = 0xf0; +#else // !MODE_XT +static const UINT8 scXtDepressMask = 0x80; + +static const UINT8 XtToAt[] = +{ + /* 00 */ 0x00, + /* 01 */ 0x76, + /* 02 */ 0x16, + /* 03 */ 0x1E, + /* 04 */ 0x26, + /* 05 */ 0x25, + /* 06 */ 0x2E, + /* 07 */ 0x36, + /* 08 */ 0x3D, + /* 09 */ 0x3E, + /* 0A */ 0x46, + /* 0B */ 0x45, + /* 0C */ 0x4E, + /* 0D */ 0x55, + /* 0E */ 0x66, + /* 0F */ 0x0D, + /* 10 */ 0x15, + /* 11 */ 0x1D, + /* 12 */ 0x24, + /* 13 */ 0x2D, + /* 14 */ 0x2C, + /* 15 */ 0x35, + /* 16 */ 0x3C, + /* 17 */ 0x43, + /* 18 */ 0x44, + /* 19 */ 0x4D, + /* 1A */ 0x54, + /* 1B */ 0x5B, + /* 1C */ 0x5A, + /* 1D */ 0x14, + /* 1E */ 0x1C, + /* 1F */ 0x1B, + /* 20 */ 0x23, + /* 21 */ 0x2B, + /* 22 */ 0x34, + /* 23 */ 0x33, + /* 24 */ 0x3B, + /* 25 */ 0x42, + /* 26 */ 0x4B, + /* 27 */ 0x4C, + /* 28 */ 0x52, + /* 29 */ 0x0E, + /* 2A */ 0x12, + /* 2B */ 0x5D, + /* 2C */ 0x1A, + /* 2D */ 0x22, + /* 2E */ 0x21, + /* 2F */ 0x2A, + /* 30 */ 0x32, + /* 31 */ 0x31, + /* 32 */ 0x3A, + /* 33 */ 0x41, + /* 34 */ 0x49, + /* 35 */ 0x4A, + /* 36 */ 0x59, + /* 37 */ 0x7C, + /* 38 */ 0x11, + /* 39 */ 0x29, + /* 3A */ 0x58, + /* 3B */ 0x05, + /* 3C */ 0x06, + /* 3D */ 0x04, + /* 3E */ 0x0C, + /* 3F */ 0x03, + /* 40 */ 0x0B, + /* 41 */ 0x83, + /* 42 */ 0x0A, + /* 43 */ 0x01, + /* 44 */ 0x09, + /* 45 */ 0x77, + /* 46 */ 0x7E, + /* 47 */ 0x6C, + /* 48 */ 0x75, + /* 49 */ 0x7D, + /* 4A */ 0x7B, + /* 4B */ 0x6B, + /* 4C */ 0x73, + /* 4D */ 0x74, + /* 4E */ 0x79, + /* 4F */ 0x69, + /* 50 */ 0x72, + /* 51 */ 0x7A, + /* 52 */ 0x70, + /* 53 */ 0x71, + /* 56 */ 0x61, + /* 57 */ 0x78, + /* 58 */ 0x07 +}; +#endif // MODE_XT // There is really only one physical keyboard supported by the system. @@ -85,8 +180,8 @@ static UINT32 scInProgress; static UINT32 scPrevious; - static BOOL fKeyUp; - + static BOOL fKeyUp; + UINT8 ui8ScanCode; BOOL fEvent = FALSE; UINT cEvents = 0; @@ -100,11 +195,28 @@ (_T("%s: scan code 0x%08x, code in progress 0x%08x, previous 0x%08x\r\n"), pszFname, ui8ScanCode, scInProgress, scPrevious)); - if ( ui8ScanCode == scKeyUp ) +#ifdef MODE_XT + fKeyUp = FALSE; + if ( ( ui8ScanCode & ~scXtDepressMask ) < dim ( XtToAt ) ) + { + fKeyUp = ( ui8ScanCode & scXtDepressMask ) ? TRUE : FALSE; + ui8ScanCode = XtToAt [ ui8ScanCode & ~scXtDepressMask ]; + } + else if ( ( ui8ScanCode != scE0Extended ) && ( ui8ScanCode != scE1Extended ) ) + { + ui8ScanCode = 0; + } + if ( ui8ScanCode == 0 ) + { + // Unknown scancode - do nothing + } +#else // MODE_XT + if ( ui8ScanCode == scKeyUp ) { fKeyUp = TRUE; } - else if ( ui8ScanCode == scE0Extended ) +#endif // !MODE_XT + else if ( ui8ScanCode == scE0Extended ) { scInProgress = 0xe000; } diff -u PS2_8042/ps2port.cpp PS2_XT_PATCH/ps2port.cpp --- PS2_8042/ps2port.cpp 2004-07-01 13:00:00.000000000 -0700 +++ PS2_XT_PATCH/ps2port.cpp 2006-05-12 18:46:18.871076800 -0700 @@ -68,6 +68,9 @@ // Keyboard modes static const UINT8 cmdKeybdModeAT = 0x02; +#ifdef MODE_XT +static const UINT8 cmdKeybdModeXT = 0x01; +#endif // MODE_XT // // Commands sent to the mouse. @@ -630,11 +633,10 @@ break; } - if( !OutputBufPollRead(&ui8Data) ) + if( !OutputBufPollRead(&ui8Data) ) { break; } - if( ui8Data == response8042Ack ) { bRet = true; @@ -758,7 +760,11 @@ if ( KeyboardCommandPut(cmdKeybdSetMode) ) { +#ifdef MODE_XT + KeyboardCommandPut(cmdKeybdModeXT); +#else KeyboardCommandPut(cmdKeybdModeAT); +#endif } bRet = true;