From 41e8832080865b3d717cdefb6358d91561996902 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Sat, 27 Sep 2014 02:17:54 +0000 Subject: [PATCH] =?utf8?q?[NTVDM]=20Implement=20INT=2015h,=20AH=3D4Fh=20"K?= =?utf8?q?eyboard=20intercept",=20which=20is=20used=20by=20INT=209h=20/=20?= =?utf8?q?IRQ=201=20to=20possibly=20translate=20scan=20code=20before=20any?= =?utf8?q?=20further=20treatment.=20The=20default=20implementation=20is=20?= =?utf8?q?a=20trivial=20one,=20do=20it=20=C3=A0=20la=20DosBox.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit svn path=/trunk/; revision=64324 --- reactos/subsystems/ntvdm/bios/bios32/bios32.c | 12 ++++++++- .../subsystems/ntvdm/bios/bios32/kbdbios32.c | 26 +++++++++++++++++-- reactos/subsystems/ntvdm/dos/dem.c | 1 - reactos/subsystems/ntvdm/hardware/keyboard.c | 2 ++ 4 files changed, 37 insertions(+), 4 deletions(-) diff --git a/reactos/subsystems/ntvdm/bios/bios32/bios32.c b/reactos/subsystems/ntvdm/bios/bios32/bios32.c index aab15d3c8c8..b012d90ec20 100644 --- a/reactos/subsystems/ntvdm/bios/bios32/bios32.c +++ b/reactos/subsystems/ntvdm/bios/bios32/bios32.c @@ -146,6 +146,16 @@ static VOID WINAPI BiosMiscService(LPWORD Stack) { switch (getAH()) { + /* Keyboard intercept */ + case 0x4F: + { + /* CF should be set but let's just set it again just in case */ + /* Do not modify AL (the hardware scan code), but set CF to continue processing */ + // setCF(1); + Stack[STACK_FLAGS] |= EMULATOR_FLAG_CF; + break; + } + /* Wait */ case 0x86: { @@ -493,7 +503,7 @@ static VOID InitializeBiosInfo(VOID) Bct->Model = BIOS_MODEL; Bct->SubModel = BIOS_SUBMODEL; Bct->Revision = BIOS_REVISION; - Bct->Feature[0] = 0x64; // At the moment we don't support "INT 15/AH=4Fh called upon INT 09h" nor "wait for external event (INT 15/AH=41h) supported"; see http://www.ctyme.com/intr/rb-1594.htm#Table510 + Bct->Feature[0] = 0x70; // At the moment we don't support "wait for external event (INT 15/AH=41h)", we also don't have any "extended BIOS area allocated (usually at top of RAM)"; see http://www.ctyme.com/intr/rb-1594.htm#Table510 Bct->Feature[1] = 0x00; // We don't support anything from here; see http://www.ctyme.com/intr/rb-1594.htm#Table511 Bct->Feature[2] = 0x00; Bct->Feature[3] = 0x00; diff --git a/reactos/subsystems/ntvdm/bios/bios32/kbdbios32.c b/reactos/subsystems/ntvdm/bios/bios32/kbdbios32.c index 70b051348fc..0c60a546500 100644 --- a/reactos/subsystems/ntvdm/bios/bios32/kbdbios32.c +++ b/reactos/subsystems/ntvdm/bios/bios32/kbdbios32.c @@ -197,8 +197,26 @@ static VOID WINAPI BiosKeyboardIrq(LPWORD Stack) BYTE ScanCode, VirtualKey; WORD Character; - /* Get the scan code and virtual key code */ - ScanCode = IOReadB(PS2_DATA_PORT); + /* + * Get the scan code from the PS/2 port, then call the + * INT 15h, AH=4Fh Keyboard Intercept function to try to + * translate the scan code. CF must be set before the call. + * In return, if CF is set we continue processing the scan code + * stored in AL, and if not, we skip it. + */ + setCF(1); + setAL(IOReadB(PS2_DATA_PORT)); + setAH(0x4F); + Int32Call(&BiosContext, BIOS_MISC_INTERRUPT); + + /* Check whether CL is clear. If so, skip the scan code. */ + if (getCF() == 0) goto Quit; + /**/setCF(0);/**/ // FIXME: HACK: Reset CF otherwise we enter in an infinite loop. + + /* Retrieve the modified scan code in AL */ + ScanCode = getAL(); + + /* Get the corresponding virtual key code */ VirtualKey = MapVirtualKey(ScanCode & 0x7F, MAPVK_VSC_TO_VK); /* Check if this is a key press or release */ @@ -255,6 +273,10 @@ static VOID WINAPI BiosKeyboardIrq(LPWORD Stack) if (BiosKeyboardMap[VK_CAPITAL] & (1 << 7)) Bda->KeybdShiftFlags |= BDA_KBDFLAG_CAPSLOCK; if (BiosKeyboardMap[VK_INSERT] & (1 << 7)) Bda->KeybdShiftFlags |= BDA_KBDFLAG_INSERT; + DPRINT("BiosKeyboardIrq - Character = 0x%X, ScanCode = 0x%X, KeybdShiftFlags = 0x%X\n", + Character, ScanCode, Bda->KeybdShiftFlags); + +Quit: PicIRQComplete(Stack); } diff --git a/reactos/subsystems/ntvdm/dos/dem.c b/reactos/subsystems/ntvdm/dos/dem.c index b751e4b4f6e..4b75d85c69e 100644 --- a/reactos/subsystems/ntvdm/dos/dem.c +++ b/reactos/subsystems/ntvdm/dos/dem.c @@ -91,7 +91,6 @@ Quit: default: { - DPRINT1("Unknown DOS System BOP Function: 0x%02X\n", FuncNum); // setCF(1); // Disable, otherwise we enter an infinite loop break; diff --git a/reactos/subsystems/ntvdm/hardware/keyboard.c b/reactos/subsystems/ntvdm/hardware/keyboard.c index 7ce2aa29654..5e98bf73e89 100644 --- a/reactos/subsystems/ntvdm/hardware/keyboard.c +++ b/reactos/subsystems/ntvdm/hardware/keyboard.c @@ -40,6 +40,8 @@ VOID KeyboardEventHandler(PKEY_EVENT_RECORD KeyEvent) PS2QueuePush(PS2Port, ScanCode); } + DPRINT("Press 0x%X\n", ScanCode); + // PicInterruptRequest(1); } -- 2.17.1