2013-06-23 23:19:42 +00:00
|
|
|
/*
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
2013-07-06 15:59:28 +00:00
|
|
|
* PROJECT: ReactOS Console Driver DLL
|
2015-10-05 12:21:25 +00:00
|
|
|
* FILE: win32ss/user/winsrv/consrv/condrv/coninput.c
|
2013-06-23 23:19:42 +00:00
|
|
|
* PURPOSE: Console Input functions
|
|
|
|
* PROGRAMMERS: Jeffrey Morlan
|
|
|
|
* Hermes Belusca-Maito (hermes.belusca@sfr.fr)
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES *******************************************************************/
|
|
|
|
|
2014-02-04 19:54:42 +00:00
|
|
|
#include <consrv.h>
|
2013-06-23 23:19:42 +00:00
|
|
|
|
|
|
|
#define NDEBUG
|
|
|
|
#include <debug.h>
|
|
|
|
|
|
|
|
/* PRIVATE FUNCTIONS **********************************************************/
|
|
|
|
|
2014-08-31 11:24:23 +00:00
|
|
|
// ConDrvAddInputEvents
|
2014-08-31 11:07:09 +00:00
|
|
|
static NTSTATUS
|
2014-08-31 11:24:23 +00:00
|
|
|
AddInputEvents(PCONSOLE Console,
|
|
|
|
PINPUT_RECORD InputRecords, // InputEvent
|
|
|
|
ULONG NumEventsToWrite,
|
|
|
|
PULONG NumEventsWritten,
|
|
|
|
BOOLEAN AppendToEnd)
|
[KERNEL32][CONSRV]
- Make kernel32 / winsrv console CSR structures Win2k3-compliant for Read/WriteConsole functions.
An attentive code reader will see that there are structure members in CONSOLE_WRITECONSOLE that are
indeed unused by kernel32 that can be used in ReactOS for undocumented extensions of WriteConsole...
(for instance, adding a parameter for ANSI codes support, who knows!... :P)
- Fix a bit the support for the CONSOLE_READCONSOLE_CONTROL parameter in ReadConsole (for unicode only).
- Use the actual exe name for command history management, given via a hackish way by ReadConsole:
the exe name is passed via the 80-byte-length limited static buffer, and is of course retrieved before
actually using the static buffer (if needed).
[CONSRV]
- Fix writing input events in the console, but first preprocessing them for pausing commands (we treat them separately and remove them),
then, in case we write many single events, we merge them in case they are mouse moves or repeated key down presses. This helps in not
overflowing too quickly the input buffer, and that fixes all the remaining kernel32:console winetests!! (see CORE-8256)
- Use the actual exe name for command history management, given via a hackish way by ReadConsole (blame MS!)
Part 8/X
CORE-7931
CORE-8256 #resolve #comment Fixed in the condrv_restructure branch in revision .
svn path=/branches/condrv_restructure/; revision=63793
2014-08-01 18:08:29 +00:00
|
|
|
{
|
|
|
|
NTSTATUS Status = STATUS_SUCCESS;
|
|
|
|
ULONG i = 0;
|
|
|
|
BOOLEAN SetWaitEvent = FALSE;
|
|
|
|
|
|
|
|
if (NumEventsWritten) *NumEventsWritten = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* When adding many single events, in the case of repeated mouse move or
|
|
|
|
* key down events, we try to coalesce them so that we do not saturate
|
|
|
|
* too quickly the input buffer.
|
|
|
|
*/
|
|
|
|
if (NumEventsToWrite == 1 && !IsListEmpty(&Console->InputBuffer.InputEvents))
|
|
|
|
{
|
|
|
|
PINPUT_RECORD InputRecord = InputRecords; // Only one element
|
|
|
|
PINPUT_RECORD LastInputRecord;
|
|
|
|
ConsoleInput* ConInRec; // Input
|
|
|
|
|
|
|
|
/* Get the "next" event of the input buffer */
|
|
|
|
if (AppendToEnd)
|
|
|
|
{
|
|
|
|
/* Get the tail element */
|
|
|
|
ConInRec = CONTAINING_RECORD(Console->InputBuffer.InputEvents.Blink,
|
|
|
|
ConsoleInput, ListEntry);
|
|
|
|
}
|
2013-06-23 23:19:42 +00:00
|
|
|
else
|
|
|
|
{
|
[KERNEL32][CONSRV]
- Make kernel32 / winsrv console CSR structures Win2k3-compliant for Read/WriteConsole functions.
An attentive code reader will see that there are structure members in CONSOLE_WRITECONSOLE that are
indeed unused by kernel32 that can be used in ReactOS for undocumented extensions of WriteConsole...
(for instance, adding a parameter for ANSI codes support, who knows!... :P)
- Fix a bit the support for the CONSOLE_READCONSOLE_CONTROL parameter in ReadConsole (for unicode only).
- Use the actual exe name for command history management, given via a hackish way by ReadConsole:
the exe name is passed via the 80-byte-length limited static buffer, and is of course retrieved before
actually using the static buffer (if needed).
[CONSRV]
- Fix writing input events in the console, but first preprocessing them for pausing commands (we treat them separately and remove them),
then, in case we write many single events, we merge them in case they are mouse moves or repeated key down presses. This helps in not
overflowing too quickly the input buffer, and that fixes all the remaining kernel32:console winetests!! (see CORE-8256)
- Use the actual exe name for command history management, given via a hackish way by ReadConsole (blame MS!)
Part 8/X
CORE-7931
CORE-8256 #resolve #comment Fixed in the condrv_restructure branch in revision .
svn path=/branches/condrv_restructure/; revision=63793
2014-08-01 18:08:29 +00:00
|
|
|
/* Get the head element */
|
|
|
|
ConInRec = CONTAINING_RECORD(Console->InputBuffer.InputEvents.Flink,
|
|
|
|
ConsoleInput, ListEntry);
|
|
|
|
}
|
|
|
|
LastInputRecord = &ConInRec->InputEvent;
|
|
|
|
|
|
|
|
if (InputRecord->EventType == MOUSE_EVENT &&
|
|
|
|
InputRecord->Event.MouseEvent.dwEventFlags == MOUSE_MOVED)
|
|
|
|
{
|
|
|
|
if (LastInputRecord->EventType == MOUSE_EVENT &&
|
|
|
|
LastInputRecord->Event.MouseEvent.dwEventFlags == MOUSE_MOVED)
|
|
|
|
{
|
|
|
|
/* Update the mouse position */
|
|
|
|
LastInputRecord->Event.MouseEvent.dwMousePosition.X =
|
|
|
|
InputRecord->Event.MouseEvent.dwMousePosition.X;
|
|
|
|
LastInputRecord->Event.MouseEvent.dwMousePosition.Y =
|
|
|
|
InputRecord->Event.MouseEvent.dwMousePosition.Y;
|
|
|
|
|
|
|
|
i = 1;
|
|
|
|
// return STATUS_SUCCESS;
|
|
|
|
Status = STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (InputRecord->EventType == KEY_EVENT &&
|
|
|
|
InputRecord->Event.KeyEvent.bKeyDown)
|
|
|
|
{
|
|
|
|
if (LastInputRecord->EventType == KEY_EVENT &&
|
|
|
|
LastInputRecord->Event.KeyEvent.bKeyDown &&
|
|
|
|
(LastInputRecord->Event.KeyEvent.wVirtualScanCode == // Same scancode
|
|
|
|
InputRecord->Event.KeyEvent.wVirtualScanCode) &&
|
|
|
|
(LastInputRecord->Event.KeyEvent.uChar.UnicodeChar == // Same character
|
|
|
|
InputRecord->Event.KeyEvent.uChar.UnicodeChar) &&
|
|
|
|
(LastInputRecord->Event.KeyEvent.dwControlKeyState == // Same Ctrl/Alt/Shift state
|
|
|
|
InputRecord->Event.KeyEvent.dwControlKeyState) )
|
2013-06-23 23:19:42 +00:00
|
|
|
{
|
[KERNEL32][CONSRV]
- Make kernel32 / winsrv console CSR structures Win2k3-compliant for Read/WriteConsole functions.
An attentive code reader will see that there are structure members in CONSOLE_WRITECONSOLE that are
indeed unused by kernel32 that can be used in ReactOS for undocumented extensions of WriteConsole...
(for instance, adding a parameter for ANSI codes support, who knows!... :P)
- Fix a bit the support for the CONSOLE_READCONSOLE_CONTROL parameter in ReadConsole (for unicode only).
- Use the actual exe name for command history management, given via a hackish way by ReadConsole:
the exe name is passed via the 80-byte-length limited static buffer, and is of course retrieved before
actually using the static buffer (if needed).
[CONSRV]
- Fix writing input events in the console, but first preprocessing them for pausing commands (we treat them separately and remove them),
then, in case we write many single events, we merge them in case they are mouse moves or repeated key down presses. This helps in not
overflowing too quickly the input buffer, and that fixes all the remaining kernel32:console winetests!! (see CORE-8256)
- Use the actual exe name for command history management, given via a hackish way by ReadConsole (blame MS!)
Part 8/X
CORE-7931
CORE-8256 #resolve #comment Fixed in the condrv_restructure branch in revision .
svn path=/branches/condrv_restructure/; revision=63793
2014-08-01 18:08:29 +00:00
|
|
|
/* Update the repeat count */
|
|
|
|
LastInputRecord->Event.KeyEvent.wRepeatCount +=
|
|
|
|
InputRecord->Event.KeyEvent.wRepeatCount;
|
|
|
|
|
|
|
|
i = 1;
|
|
|
|
// return STATUS_SUCCESS;
|
|
|
|
Status = STATUS_SUCCESS;
|
2013-06-23 23:19:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
[KERNEL32][CONSRV]
- Make kernel32 / winsrv console CSR structures Win2k3-compliant for Read/WriteConsole functions.
An attentive code reader will see that there are structure members in CONSOLE_WRITECONSOLE that are
indeed unused by kernel32 that can be used in ReactOS for undocumented extensions of WriteConsole...
(for instance, adding a parameter for ANSI codes support, who knows!... :P)
- Fix a bit the support for the CONSOLE_READCONSOLE_CONTROL parameter in ReadConsole (for unicode only).
- Use the actual exe name for command history management, given via a hackish way by ReadConsole:
the exe name is passed via the 80-byte-length limited static buffer, and is of course retrieved before
actually using the static buffer (if needed).
[CONSRV]
- Fix writing input events in the console, but first preprocessing them for pausing commands (we treat them separately and remove them),
then, in case we write many single events, we merge them in case they are mouse moves or repeated key down presses. This helps in not
overflowing too quickly the input buffer, and that fixes all the remaining kernel32:console winetests!! (see CORE-8256)
- Use the actual exe name for command history management, given via a hackish way by ReadConsole (blame MS!)
Part 8/X
CORE-7931
CORE-8256 #resolve #comment Fixed in the condrv_restructure branch in revision .
svn path=/branches/condrv_restructure/; revision=63793
2014-08-01 18:08:29 +00:00
|
|
|
/* If we coalesced the only one element, we can quit */
|
|
|
|
if (i == 1 && Status == STATUS_SUCCESS /* && NumEventsToWrite == 1 */)
|
|
|
|
goto Done;
|
2013-06-23 23:19:42 +00:00
|
|
|
|
[KERNEL32][CONSRV]
- Make kernel32 / winsrv console CSR structures Win2k3-compliant for Read/WriteConsole functions.
An attentive code reader will see that there are structure members in CONSOLE_WRITECONSOLE that are
indeed unused by kernel32 that can be used in ReactOS for undocumented extensions of WriteConsole...
(for instance, adding a parameter for ANSI codes support, who knows!... :P)
- Fix a bit the support for the CONSOLE_READCONSOLE_CONTROL parameter in ReadConsole (for unicode only).
- Use the actual exe name for command history management, given via a hackish way by ReadConsole:
the exe name is passed via the 80-byte-length limited static buffer, and is of course retrieved before
actually using the static buffer (if needed).
[CONSRV]
- Fix writing input events in the console, but first preprocessing them for pausing commands (we treat them separately and remove them),
then, in case we write many single events, we merge them in case they are mouse moves or repeated key down presses. This helps in not
overflowing too quickly the input buffer, and that fixes all the remaining kernel32:console winetests!! (see CORE-8256)
- Use the actual exe name for command history management, given via a hackish way by ReadConsole (blame MS!)
Part 8/X
CORE-7931
CORE-8256 #resolve #comment Fixed in the condrv_restructure branch in revision .
svn path=/branches/condrv_restructure/; revision=63793
2014-08-01 18:08:29 +00:00
|
|
|
/*
|
|
|
|
* No event coalesced, add them in the usual way.
|
|
|
|
*/
|
2013-10-26 20:53:05 +00:00
|
|
|
|
|
|
|
if (AppendToEnd)
|
|
|
|
{
|
[KERNEL32][CONSRV]
- Make kernel32 / winsrv console CSR structures Win2k3-compliant for Read/WriteConsole functions.
An attentive code reader will see that there are structure members in CONSOLE_WRITECONSOLE that are
indeed unused by kernel32 that can be used in ReactOS for undocumented extensions of WriteConsole...
(for instance, adding a parameter for ANSI codes support, who knows!... :P)
- Fix a bit the support for the CONSOLE_READCONSOLE_CONTROL parameter in ReadConsole (for unicode only).
- Use the actual exe name for command history management, given via a hackish way by ReadConsole:
the exe name is passed via the 80-byte-length limited static buffer, and is of course retrieved before
actually using the static buffer (if needed).
[CONSRV]
- Fix writing input events in the console, but first preprocessing them for pausing commands (we treat them separately and remove them),
then, in case we write many single events, we merge them in case they are mouse moves or repeated key down presses. This helps in not
overflowing too quickly the input buffer, and that fixes all the remaining kernel32:console winetests!! (see CORE-8256)
- Use the actual exe name for command history management, given via a hackish way by ReadConsole (blame MS!)
Part 8/X
CORE-7931
CORE-8256 #resolve #comment Fixed in the condrv_restructure branch in revision .
svn path=/branches/condrv_restructure/; revision=63793
2014-08-01 18:08:29 +00:00
|
|
|
/* Go to the beginning of the list */
|
|
|
|
// InputRecords = InputRecords;
|
2013-10-26 20:53:05 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
[KERNEL32][CONSRV]
- Make kernel32 / winsrv console CSR structures Win2k3-compliant for Read/WriteConsole functions.
An attentive code reader will see that there are structure members in CONSOLE_WRITECONSOLE that are
indeed unused by kernel32 that can be used in ReactOS for undocumented extensions of WriteConsole...
(for instance, adding a parameter for ANSI codes support, who knows!... :P)
- Fix a bit the support for the CONSOLE_READCONSOLE_CONTROL parameter in ReadConsole (for unicode only).
- Use the actual exe name for command history management, given via a hackish way by ReadConsole:
the exe name is passed via the 80-byte-length limited static buffer, and is of course retrieved before
actually using the static buffer (if needed).
[CONSRV]
- Fix writing input events in the console, but first preprocessing them for pausing commands (we treat them separately and remove them),
then, in case we write many single events, we merge them in case they are mouse moves or repeated key down presses. This helps in not
overflowing too quickly the input buffer, and that fixes all the remaining kernel32:console winetests!! (see CORE-8256)
- Use the actual exe name for command history management, given via a hackish way by ReadConsole (blame MS!)
Part 8/X
CORE-7931
CORE-8256 #resolve #comment Fixed in the condrv_restructure branch in revision .
svn path=/branches/condrv_restructure/; revision=63793
2014-08-01 18:08:29 +00:00
|
|
|
/* Go to the end of the list */
|
|
|
|
InputRecords = &InputRecords[NumEventsToWrite - 1];
|
2013-10-26 20:53:05 +00:00
|
|
|
}
|
2013-06-23 23:19:42 +00:00
|
|
|
|
[KERNEL32][CONSRV]
- Make kernel32 / winsrv console CSR structures Win2k3-compliant for Read/WriteConsole functions.
An attentive code reader will see that there are structure members in CONSOLE_WRITECONSOLE that are
indeed unused by kernel32 that can be used in ReactOS for undocumented extensions of WriteConsole...
(for instance, adding a parameter for ANSI codes support, who knows!... :P)
- Fix a bit the support for the CONSOLE_READCONSOLE_CONTROL parameter in ReadConsole (for unicode only).
- Use the actual exe name for command history management, given via a hackish way by ReadConsole:
the exe name is passed via the 80-byte-length limited static buffer, and is of course retrieved before
actually using the static buffer (if needed).
[CONSRV]
- Fix writing input events in the console, but first preprocessing them for pausing commands (we treat them separately and remove them),
then, in case we write many single events, we merge them in case they are mouse moves or repeated key down presses. This helps in not
overflowing too quickly the input buffer, and that fixes all the remaining kernel32:console winetests!! (see CORE-8256)
- Use the actual exe name for command history management, given via a hackish way by ReadConsole (blame MS!)
Part 8/X
CORE-7931
CORE-8256 #resolve #comment Fixed in the condrv_restructure branch in revision .
svn path=/branches/condrv_restructure/; revision=63793
2014-08-01 18:08:29 +00:00
|
|
|
/* Set the event if the list is going to be non-empty */
|
|
|
|
if (IsListEmpty(&Console->InputBuffer.InputEvents))
|
|
|
|
SetWaitEvent = TRUE;
|
|
|
|
|
|
|
|
for (i = 0; i < NumEventsToWrite && NT_SUCCESS(Status); ++i)
|
2013-06-23 23:19:42 +00:00
|
|
|
{
|
[KERNEL32][CONSRV]
- Make kernel32 / winsrv console CSR structures Win2k3-compliant for Read/WriteConsole functions.
An attentive code reader will see that there are structure members in CONSOLE_WRITECONSOLE that are
indeed unused by kernel32 that can be used in ReactOS for undocumented extensions of WriteConsole...
(for instance, adding a parameter for ANSI codes support, who knows!... :P)
- Fix a bit the support for the CONSOLE_READCONSOLE_CONTROL parameter in ReadConsole (for unicode only).
- Use the actual exe name for command history management, given via a hackish way by ReadConsole:
the exe name is passed via the 80-byte-length limited static buffer, and is of course retrieved before
actually using the static buffer (if needed).
[CONSRV]
- Fix writing input events in the console, but first preprocessing them for pausing commands (we treat them separately and remove them),
then, in case we write many single events, we merge them in case they are mouse moves or repeated key down presses. This helps in not
overflowing too quickly the input buffer, and that fixes all the remaining kernel32:console winetests!! (see CORE-8256)
- Use the actual exe name for command history management, given via a hackish way by ReadConsole (blame MS!)
Part 8/X
CORE-7931
CORE-8256 #resolve #comment Fixed in the condrv_restructure branch in revision .
svn path=/branches/condrv_restructure/; revision=63793
2014-08-01 18:08:29 +00:00
|
|
|
PINPUT_RECORD InputRecord;
|
|
|
|
ConsoleInput* ConInRec;
|
|
|
|
|
|
|
|
if (AppendToEnd)
|
|
|
|
{
|
|
|
|
/* Select the event and go to the next one */
|
|
|
|
InputRecord = InputRecords++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Select the event and go to the previous one */
|
|
|
|
InputRecord = InputRecords--;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add event to the queue */
|
|
|
|
ConInRec = ConsoleAllocHeap(0, sizeof(ConsoleInput));
|
|
|
|
if (ConInRec == NULL)
|
|
|
|
{
|
|
|
|
// return STATUS_INSUFFICIENT_RESOURCES;
|
|
|
|
Status = STATUS_INSUFFICIENT_RESOURCES;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
ConInRec->InputEvent = *InputRecord;
|
|
|
|
|
|
|
|
if (AppendToEnd)
|
|
|
|
{
|
|
|
|
/* Append the event to the end of the queue */
|
|
|
|
InsertTailList(&Console->InputBuffer.InputEvents, &ConInRec->ListEntry);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Append the event to the beginning of the queue */
|
|
|
|
InsertHeadList(&Console->InputBuffer.InputEvents, &ConInRec->ListEntry);
|
|
|
|
}
|
|
|
|
|
|
|
|
// return STATUS_SUCCESS;
|
|
|
|
Status = STATUS_SUCCESS;
|
2013-06-23 23:19:42 +00:00
|
|
|
}
|
|
|
|
|
2014-11-22 22:13:08 +00:00
|
|
|
if (SetWaitEvent) NtSetEvent(Console->InputBuffer.ActiveEvent, NULL);
|
[KERNEL32][CONSRV]
- Make kernel32 / winsrv console CSR structures Win2k3-compliant for Read/WriteConsole functions.
An attentive code reader will see that there are structure members in CONSOLE_WRITECONSOLE that are
indeed unused by kernel32 that can be used in ReactOS for undocumented extensions of WriteConsole...
(for instance, adding a parameter for ANSI codes support, who knows!... :P)
- Fix a bit the support for the CONSOLE_READCONSOLE_CONTROL parameter in ReadConsole (for unicode only).
- Use the actual exe name for command history management, given via a hackish way by ReadConsole:
the exe name is passed via the 80-byte-length limited static buffer, and is of course retrieved before
actually using the static buffer (if needed).
[CONSRV]
- Fix writing input events in the console, but first preprocessing them for pausing commands (we treat them separately and remove them),
then, in case we write many single events, we merge them in case they are mouse moves or repeated key down presses. This helps in not
overflowing too quickly the input buffer, and that fixes all the remaining kernel32:console winetests!! (see CORE-8256)
- Use the actual exe name for command history management, given via a hackish way by ReadConsole (blame MS!)
Part 8/X
CORE-7931
CORE-8256 #resolve #comment Fixed in the condrv_restructure branch in revision .
svn path=/branches/condrv_restructure/; revision=63793
2014-08-01 18:08:29 +00:00
|
|
|
|
|
|
|
Done:
|
|
|
|
if (NumEventsWritten) *NumEventsWritten = i;
|
|
|
|
|
2014-08-04 20:23:33 +00:00
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
2014-09-05 21:06:36 +00:00
|
|
|
static VOID
|
2013-06-23 23:19:42 +00:00
|
|
|
PurgeInputBuffer(PCONSOLE Console)
|
|
|
|
{
|
|
|
|
PLIST_ENTRY CurrentEntry;
|
|
|
|
ConsoleInput* Event;
|
|
|
|
|
|
|
|
while (!IsListEmpty(&Console->InputBuffer.InputEvents))
|
|
|
|
{
|
|
|
|
CurrentEntry = RemoveHeadList(&Console->InputBuffer.InputEvents);
|
|
|
|
Event = CONTAINING_RECORD(CurrentEntry, ConsoleInput, ListEntry);
|
|
|
|
ConsoleFreeHeap(Event);
|
|
|
|
}
|
|
|
|
|
2014-09-05 21:06:36 +00:00
|
|
|
// CloseHandle(Console->InputBuffer.ActiveEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS NTAPI
|
|
|
|
ConDrvInitInputBuffer(IN PCONSOLE Console,
|
|
|
|
IN ULONG InputBufferSize)
|
|
|
|
{
|
2014-11-22 22:13:08 +00:00
|
|
|
NTSTATUS Status;
|
|
|
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
2014-09-05 21:06:36 +00:00
|
|
|
|
|
|
|
ConSrvInitObject(&Console->InputBuffer.Header, INPUT_BUFFER, Console);
|
|
|
|
|
2014-11-22 22:13:08 +00:00
|
|
|
InitializeObjectAttributes(&ObjectAttributes,
|
|
|
|
NULL,
|
|
|
|
OBJ_INHERIT,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
2014-09-05 21:06:36 +00:00
|
|
|
|
2014-11-22 22:13:08 +00:00
|
|
|
Status = NtCreateEvent(&Console->InputBuffer.ActiveEvent, EVENT_ALL_ACCESS,
|
|
|
|
&ObjectAttributes, NotificationEvent, FALSE);
|
|
|
|
if (!NT_SUCCESS(Status))
|
2015-01-02 20:32:44 +00:00
|
|
|
return Status;
|
2014-09-05 21:06:36 +00:00
|
|
|
|
|
|
|
Console->InputBuffer.InputBufferSize = InputBufferSize;
|
|
|
|
InitializeListHead(&Console->InputBuffer.InputEvents);
|
|
|
|
Console->InputBuffer.Mode = ENABLE_PROCESSED_INPUT | ENABLE_LINE_INPUT |
|
|
|
|
ENABLE_ECHO_INPUT | ENABLE_MOUSE_INPUT;
|
|
|
|
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
VOID NTAPI
|
|
|
|
ConDrvDeinitInputBuffer(IN PCONSOLE Console)
|
|
|
|
{
|
|
|
|
PurgeInputBuffer(Console);
|
2013-06-23 23:19:42 +00:00
|
|
|
CloseHandle(Console->InputBuffer.ActiveEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-06 15:59:28 +00:00
|
|
|
/* PUBLIC DRIVER APIS *********************************************************/
|
2013-06-23 23:19:42 +00:00
|
|
|
|
2013-06-27 00:20:58 +00:00
|
|
|
NTSTATUS NTAPI
|
|
|
|
ConDrvReadConsole(IN PCONSOLE Console,
|
|
|
|
IN PCONSOLE_INPUT_BUFFER InputBuffer,
|
|
|
|
IN BOOLEAN Unicode,
|
|
|
|
OUT PVOID Buffer,
|
|
|
|
IN OUT PCONSOLE_READCONSOLE_CONTROL ReadControl,
|
2014-12-14 16:53:47 +00:00
|
|
|
IN PVOID Parameter OPTIONAL,
|
2013-06-27 00:20:58 +00:00
|
|
|
IN ULONG NumCharsToRead,
|
|
|
|
OUT PULONG NumCharsRead OPTIONAL)
|
|
|
|
{
|
|
|
|
// STATUS_PENDING : Wait if more to read ; STATUS_SUCCESS : Don't wait.
|
2014-08-29 19:54:10 +00:00
|
|
|
// NTSTATUS Status; = STATUS_PENDING;
|
2013-06-27 00:20:58 +00:00
|
|
|
|
|
|
|
if (Console == NULL || InputBuffer == NULL || /* Buffer == NULL || */
|
|
|
|
ReadControl == NULL || ReadControl->nLength != sizeof(CONSOLE_READCONSOLE_CONTROL))
|
|
|
|
{
|
|
|
|
return STATUS_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Validity checks */
|
|
|
|
ASSERT(Console == InputBuffer->Header.Console);
|
2014-07-28 21:20:36 +00:00
|
|
|
ASSERT((Buffer != NULL) || (Buffer == NULL && NumCharsToRead == 0));
|
2013-06-27 00:20:58 +00:00
|
|
|
|
2014-08-29 19:54:10 +00:00
|
|
|
/* Call the line-discipline */
|
|
|
|
return TermReadStream(Console,
|
|
|
|
Unicode,
|
|
|
|
Buffer,
|
|
|
|
ReadControl,
|
2014-12-14 16:53:47 +00:00
|
|
|
Parameter,
|
2014-08-29 19:54:10 +00:00
|
|
|
NumCharsToRead,
|
|
|
|
NumCharsRead);
|
2013-06-27 00:20:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS NTAPI
|
|
|
|
ConDrvGetConsoleInput(IN PCONSOLE Console,
|
|
|
|
IN PCONSOLE_INPUT_BUFFER InputBuffer,
|
2013-11-10 20:20:57 +00:00
|
|
|
IN BOOLEAN KeepEvents,
|
2013-06-27 00:20:58 +00:00
|
|
|
IN BOOLEAN WaitForMoreEvents,
|
|
|
|
OUT PINPUT_RECORD InputRecord,
|
|
|
|
IN ULONG NumEventsToRead,
|
|
|
|
OUT PULONG NumEventsRead OPTIONAL)
|
|
|
|
{
|
|
|
|
PLIST_ENTRY CurrentInput;
|
|
|
|
ConsoleInput* Input;
|
|
|
|
ULONG i = 0;
|
|
|
|
|
|
|
|
if (Console == NULL || InputBuffer == NULL /* || InputRecord == NULL */)
|
|
|
|
return STATUS_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
/* Validity checks */
|
|
|
|
ASSERT(Console == InputBuffer->Header.Console);
|
2014-07-28 21:20:36 +00:00
|
|
|
ASSERT((InputRecord != NULL) || (InputRecord == NULL && NumEventsToRead == 0));
|
2013-06-27 00:20:58 +00:00
|
|
|
|
2014-07-28 21:20:36 +00:00
|
|
|
if (NumEventsRead) *NumEventsRead = 0;
|
2013-06-27 00:20:58 +00:00
|
|
|
|
|
|
|
if (IsListEmpty(&InputBuffer->InputEvents))
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* No input is available. Wait for more input if requested,
|
|
|
|
* otherwise, we don't wait, so we return success.
|
|
|
|
*/
|
|
|
|
return (WaitForMoreEvents ? STATUS_PENDING : STATUS_SUCCESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Only get input if there is any */
|
|
|
|
CurrentInput = InputBuffer->InputEvents.Flink;
|
2014-07-28 21:20:36 +00:00
|
|
|
i = 0;
|
2013-06-27 00:20:58 +00:00
|
|
|
while ((CurrentInput != &InputBuffer->InputEvents) && (i < NumEventsToRead))
|
|
|
|
{
|
|
|
|
Input = CONTAINING_RECORD(CurrentInput, ConsoleInput, ListEntry);
|
|
|
|
|
|
|
|
*InputRecord = Input->InputEvent;
|
|
|
|
|
|
|
|
++InputRecord;
|
|
|
|
++i;
|
|
|
|
CurrentInput = CurrentInput->Flink;
|
|
|
|
|
2013-11-10 20:20:57 +00:00
|
|
|
/* Remove the events from the queue if needed */
|
|
|
|
if (!KeepEvents)
|
2013-06-27 00:20:58 +00:00
|
|
|
{
|
|
|
|
RemoveEntryList(&Input->ListEntry);
|
|
|
|
ConsoleFreeHeap(Input);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NumEventsRead) *NumEventsRead = i;
|
|
|
|
|
|
|
|
if (IsListEmpty(&InputBuffer->InputEvents))
|
|
|
|
{
|
|
|
|
ResetEvent(InputBuffer->ActiveEvent);
|
|
|
|
}
|
|
|
|
|
2014-08-31 11:24:23 +00:00
|
|
|
// FIXME: If we add back UNICODE support, it's here that we need to do the translation.
|
|
|
|
|
2013-06-27 00:20:58 +00:00
|
|
|
/* We read all the inputs available, we return success */
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2013-06-23 23:19:42 +00:00
|
|
|
NTSTATUS NTAPI
|
|
|
|
ConDrvWriteConsoleInput(IN PCONSOLE Console,
|
|
|
|
IN PCONSOLE_INPUT_BUFFER InputBuffer,
|
2013-10-26 20:53:05 +00:00
|
|
|
IN BOOLEAN AppendToEnd,
|
2013-06-23 23:19:42 +00:00
|
|
|
IN PINPUT_RECORD InputRecord,
|
|
|
|
IN ULONG NumEventsToWrite,
|
2013-06-27 00:20:58 +00:00
|
|
|
OUT PULONG NumEventsWritten OPTIONAL)
|
2013-06-23 23:19:42 +00:00
|
|
|
{
|
|
|
|
if (Console == NULL || InputBuffer == NULL /* || InputRecord == NULL */)
|
|
|
|
return STATUS_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
/* Validity checks */
|
|
|
|
ASSERT(Console == InputBuffer->Header.Console);
|
2014-07-28 21:20:36 +00:00
|
|
|
ASSERT((InputRecord != NULL) || (InputRecord == NULL && NumEventsToWrite == 0));
|
2013-06-23 23:19:42 +00:00
|
|
|
|
[KERNEL32][CONSRV]
- Make kernel32 / winsrv console CSR structures Win2k3-compliant for Read/WriteConsole functions.
An attentive code reader will see that there are structure members in CONSOLE_WRITECONSOLE that are
indeed unused by kernel32 that can be used in ReactOS for undocumented extensions of WriteConsole...
(for instance, adding a parameter for ANSI codes support, who knows!... :P)
- Fix a bit the support for the CONSOLE_READCONSOLE_CONTROL parameter in ReadConsole (for unicode only).
- Use the actual exe name for command history management, given via a hackish way by ReadConsole:
the exe name is passed via the 80-byte-length limited static buffer, and is of course retrieved before
actually using the static buffer (if needed).
[CONSRV]
- Fix writing input events in the console, but first preprocessing them for pausing commands (we treat them separately and remove them),
then, in case we write many single events, we merge them in case they are mouse moves or repeated key down presses. This helps in not
overflowing too quickly the input buffer, and that fixes all the remaining kernel32:console winetests!! (see CORE-8256)
- Use the actual exe name for command history management, given via a hackish way by ReadConsole (blame MS!)
Part 8/X
CORE-7931
CORE-8256 #resolve #comment Fixed in the condrv_restructure branch in revision .
svn path=/branches/condrv_restructure/; revision=63793
2014-08-01 18:08:29 +00:00
|
|
|
/* Now, add the events */
|
2014-08-31 11:07:09 +00:00
|
|
|
if (NumEventsWritten) *NumEventsWritten = 0;
|
2013-06-23 23:19:42 +00:00
|
|
|
|
2014-08-31 11:24:23 +00:00
|
|
|
// FIXME: If we add back UNICODE support, it's here that we need to do the translation.
|
|
|
|
|
|
|
|
return AddInputEvents(Console,
|
|
|
|
InputRecord,
|
|
|
|
NumEventsToWrite,
|
|
|
|
NumEventsWritten,
|
|
|
|
AppendToEnd);
|
2013-06-23 23:19:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS NTAPI
|
|
|
|
ConDrvFlushConsoleInputBuffer(IN PCONSOLE Console,
|
|
|
|
IN PCONSOLE_INPUT_BUFFER InputBuffer)
|
|
|
|
{
|
|
|
|
PLIST_ENTRY CurrentEntry;
|
|
|
|
ConsoleInput* Event;
|
|
|
|
|
|
|
|
if (Console == NULL || InputBuffer == NULL)
|
|
|
|
return STATUS_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
/* Validity check */
|
|
|
|
ASSERT(Console == InputBuffer->Header.Console);
|
|
|
|
|
|
|
|
/* Discard all entries in the input event queue */
|
|
|
|
while (!IsListEmpty(&InputBuffer->InputEvents))
|
|
|
|
{
|
|
|
|
CurrentEntry = RemoveHeadList(&InputBuffer->InputEvents);
|
|
|
|
Event = CONTAINING_RECORD(CurrentEntry, ConsoleInput, ListEntry);
|
|
|
|
ConsoleFreeHeap(Event);
|
|
|
|
}
|
|
|
|
ResetEvent(InputBuffer->ActiveEvent);
|
|
|
|
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS NTAPI
|
|
|
|
ConDrvGetConsoleNumberOfInputEvents(IN PCONSOLE Console,
|
|
|
|
IN PCONSOLE_INPUT_BUFFER InputBuffer,
|
2014-04-20 11:25:38 +00:00
|
|
|
OUT PULONG NumberOfEvents)
|
2013-06-23 23:19:42 +00:00
|
|
|
{
|
|
|
|
PLIST_ENTRY CurrentInput;
|
|
|
|
|
2014-04-20 11:25:38 +00:00
|
|
|
if (Console == NULL || InputBuffer == NULL || NumberOfEvents == NULL)
|
2013-06-23 23:19:42 +00:00
|
|
|
return STATUS_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
/* Validity check */
|
|
|
|
ASSERT(Console == InputBuffer->Header.Console);
|
|
|
|
|
2014-04-20 11:25:38 +00:00
|
|
|
*NumberOfEvents = 0;
|
2013-06-23 23:19:42 +00:00
|
|
|
|
|
|
|
/* If there are any events ... */
|
|
|
|
CurrentInput = InputBuffer->InputEvents.Flink;
|
|
|
|
while (CurrentInput != &InputBuffer->InputEvents)
|
|
|
|
{
|
|
|
|
CurrentInput = CurrentInput->Flink;
|
2014-04-20 11:25:38 +00:00
|
|
|
(*NumberOfEvents)++;
|
2013-06-23 23:19:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* EOF */
|