mirror of
https://github.com/reactos/reactos.git
synced 2024-08-01 00:58:16 +00:00
[NTVDM]: Return the latched data for keyboard ps/2 port only. Also when starting an app put a ENTER key release into the keyboard buffer because some apps expect it.
svn path=/trunk/; revision=65012
This commit is contained in:
parent
95928b831b
commit
454d38da22
|
@ -20,6 +20,9 @@
|
||||||
|
|
||||||
#include "bios/bios.h"
|
#include "bios/bios.h"
|
||||||
|
|
||||||
|
#include "io.h"
|
||||||
|
#include "hardware/ps2.h"
|
||||||
|
|
||||||
/* PRIVATE VARIABLES **********************************************************/
|
/* PRIVATE VARIABLES **********************************************************/
|
||||||
|
|
||||||
CALLBACK16 DosContext;
|
CALLBACK16 DosContext;
|
||||||
|
@ -1164,6 +1167,12 @@ DWORD DosStartProcess(IN LPCSTR ExecutablePath,
|
||||||
/* Attach to the console */
|
/* Attach to the console */
|
||||||
VidBiosAttachToConsole(); // FIXME: And in fact, attach the full NTVDM UI to the console
|
VidBiosAttachToConsole(); // FIXME: And in fact, attach the full NTVDM UI to the console
|
||||||
|
|
||||||
|
// HACK: Simulate a ENTER key release scancode on the PS/2 port because
|
||||||
|
// some apps expect to read a key release scancode (> 0x80) when they
|
||||||
|
// are started.
|
||||||
|
IOWriteB(PS2_CONTROL_PORT, 0xD2); // Next write is for the first PS/2 port
|
||||||
|
IOWriteB(PS2_DATA_PORT, 0x80 | 0x1C); // ENTER key release
|
||||||
|
|
||||||
/* Start simulation */
|
/* Start simulation */
|
||||||
SetEvent(VdmTaskEvent);
|
SetEvent(VdmTaskEvent);
|
||||||
CpuSimulate();
|
CpuSimulate();
|
||||||
|
|
|
@ -47,7 +47,7 @@ VOID KeyboardEventHandler(PKEY_EVENT_RECORD KeyEvent)
|
||||||
|
|
||||||
BOOLEAN KeyboardInit(BYTE PS2Connector)
|
BOOLEAN KeyboardInit(BYTE PS2Connector)
|
||||||
{
|
{
|
||||||
/* Finish to plug the mouse to the specified PS/2 port */
|
/* Finish to plug the keyboard to the specified PS/2 port */
|
||||||
PS2Port = PS2Connector;
|
PS2Port = PS2Connector;
|
||||||
PS2SetDeviceCmdProc(PS2Port, NULL, KeyboardCommand);
|
PS2SetDeviceCmdProc(PS2Port, NULL, KeyboardCommand);
|
||||||
|
|
||||||
|
|
|
@ -80,11 +80,14 @@ static BYTE WINAPI PS2ReadPort(USHORT Port)
|
||||||
if (StatusRegister & (1 << 0)) // || StatusRegister & (1 << 5) for second PS/2 port
|
if (StatusRegister & (1 << 0)) // || StatusRegister & (1 << 5) for second PS/2 port
|
||||||
StatusRegister &= ~(1 << 0); // StatusRegister &= ~(1 << 5);
|
StatusRegister &= ~(1 << 0); // StatusRegister &= ~(1 << 5);
|
||||||
|
|
||||||
|
// FIXME: We may check there whether there is data latched in
|
||||||
|
// PS2 ports 1 or 2 (keyboard or mouse) and retrieve it there...
|
||||||
|
|
||||||
/* Always return the available byte stored in the output buffer */
|
/* Always return the available byte stored in the output buffer */
|
||||||
return OutputBuffer;
|
return OutputBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0x00;
|
||||||
}
|
}
|
||||||
|
|
||||||
static VOID WINAPI PS2WritePort(USHORT Port, BYTE Data)
|
static VOID WINAPI PS2WritePort(USHORT Port, BYTE Data)
|
||||||
|
@ -270,7 +273,18 @@ static BOOLEAN PS2PortQueueRead(BYTE PS2Port)
|
||||||
if (!Port->IsEnabled) return FALSE;
|
if (!Port->IsEnabled) return FALSE;
|
||||||
|
|
||||||
/* Make sure the queue is not empty (fast check) */
|
/* Make sure the queue is not empty (fast check) */
|
||||||
if (Port->QueueEmpty) return FALSE;
|
if (Port->QueueEmpty)
|
||||||
|
{
|
||||||
|
/* Only the keyboard should have its last data latched */
|
||||||
|
// FIXME: Alternatively this can be done in PS2ReadPort when
|
||||||
|
// we read PS2_DATA_PORT. What is the best solution??
|
||||||
|
if (PS2Port == 0)
|
||||||
|
{
|
||||||
|
OutputBuffer = Port->Queue[(Port->QueueStart - 1) % BUFFER_SIZE];
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
WaitForSingleObject(Port->QueueMutex, INFINITE);
|
WaitForSingleObject(Port->QueueMutex, INFINITE);
|
||||||
|
|
||||||
|
@ -337,7 +351,7 @@ BOOLEAN PS2QueuePush(BYTE PS2Port, BYTE Data)
|
||||||
Port->QueueEnd++;
|
Port->QueueEnd++;
|
||||||
Port->QueueEnd %= BUFFER_SIZE;
|
Port->QueueEnd %= BUFFER_SIZE;
|
||||||
|
|
||||||
/* Since we inserted a value, it's not empty anymore */
|
/* The queue is not empty anymore */
|
||||||
Port->QueueEmpty = FALSE;
|
Port->QueueEmpty = FALSE;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue