kernelbase: Move ReadConsoleInput.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2020-09-22 17:50:45 +02:00 committed by Alexandre Julliard
parent 79cb33e192
commit cd9f96c7ce
4 changed files with 32 additions and 67 deletions

View File

@ -58,33 +58,9 @@
WINE_DEFAULT_DEBUG_CHANNEL(console);
static CRITICAL_SECTION CONSOLE_CritSect;
static CRITICAL_SECTION_DEBUG critsect_debug =
{
0, 0, &CONSOLE_CritSect,
{ &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
0, 0, { (DWORD_PTR)(__FILE__ ": CONSOLE_CritSect") }
};
static CRITICAL_SECTION CONSOLE_CritSect = { &critsect_debug, -1, 0, 0, 0, 0 };
static const WCHAR coninW[] = {'C','O','N','I','N','$',0};
static const WCHAR conoutW[] = {'C','O','N','O','U','T','$',0};
/* map input records to ASCII */
static void input_records_WtoA( INPUT_RECORD *buffer, int count )
{
UINT cp = GetConsoleCP();
int i;
char ch;
for (i = 0; i < count; i++)
{
if (buffer[i].EventType != KEY_EVENT) continue;
WideCharToMultiByte( cp, 0, &buffer[i].Event.KeyEvent.uChar.UnicodeChar, 1, &ch, 1, NULL, NULL );
buffer[i].Event.KeyEvent.uChar.AsciiChar = ch;
}
}
/******************************************************************************
* GetConsoleWindow [KERNEL32.@] Get hwnd of the console window.
*
@ -395,45 +371,6 @@ BOOL WINAPI ReadConsoleW(HANDLE hConsoleInput, LPVOID lpBuffer,
}
/***********************************************************************
* ReadConsoleInputA (KERNEL32.@)
*/
BOOL WINAPI ReadConsoleInputA( HANDLE handle, INPUT_RECORD *buffer, DWORD length, DWORD *count )
{
DWORD read;
if (!ReadConsoleInputW( handle, buffer, length, &read )) return FALSE;
input_records_WtoA( buffer, read );
if (count) *count = read;
return TRUE;
}
/***********************************************************************
* ReadConsoleInputW (KERNEL32.@)
*/
BOOL WINAPI ReadConsoleInputW(HANDLE hConsoleInput, PINPUT_RECORD lpBuffer,
DWORD nLength, LPDWORD lpNumberOfEventsRead)
{
DWORD idx = 0;
DWORD timeout = INFINITE;
if (!nLength)
{
if (lpNumberOfEventsRead) *lpNumberOfEventsRead = 0;
return TRUE;
}
/* loop until we get at least one event */
while (read_console_input(hConsoleInput, &lpBuffer[idx], timeout) == rci_gotone &&
++idx < nLength)
timeout = 0;
if (lpNumberOfEventsRead) *lpNumberOfEventsRead = idx;
return idx != 0;
}
/***********************************************************************
* GetNumberOfConsoleMouseButtons (KERNEL32.@)
*/

View File

@ -1194,10 +1194,10 @@
@ stdcall -import RaiseException(long long long ptr)
# @ stub RaiseFailFastException
@ stdcall ReadConsoleA(long ptr long ptr ptr)
@ stdcall ReadConsoleInputA(long ptr long ptr)
@ stdcall -import ReadConsoleInputA(long ptr long ptr)
@ stub ReadConsoleInputExA
@ stub ReadConsoleInputExW
@ stdcall ReadConsoleInputW(long ptr long ptr)
@ stdcall -import ReadConsoleInputW(long ptr long ptr)
@ stdcall -import ReadConsoleOutputA(long ptr long long ptr)
@ stdcall -import ReadConsoleOutputAttribute(long ptr long long ptr)
@ stdcall -import ReadConsoleOutputCharacterA(long ptr long long ptr)

View File

@ -1393,6 +1393,34 @@ BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleWindowInfo( HANDLE handle, BOOL absolute
}
/***********************************************************************
* ReadConsoleInputA (kernelbase.@)
*/
BOOL WINAPI ReadConsoleInputA( HANDLE handle, INPUT_RECORD *buffer, DWORD length, DWORD *count )
{
DWORD read;
if (!ReadConsoleInputW( handle, buffer, length, &read )) return FALSE;
input_records_WtoA( buffer, read );
if (count) *count = read;
return TRUE;
}
/***********************************************************************
* ReadConsoleInputW (kernelbase.@)
*/
BOOL WINAPI ReadConsoleInputW( HANDLE handle, INPUT_RECORD *buffer, DWORD length, DWORD *count )
{
int blocking = 1;
if (!console_ioctl( handle, IOCTL_CONDRV_READ_INPUT, &blocking, sizeof(blocking),
buffer, length * sizeof(*buffer), count ))
return FALSE;
*count /= sizeof(*buffer);
return TRUE;
}
/******************************************************************************
* WriteConsoleInputA (kernelbase.@)
*/

View File

@ -1238,10 +1238,10 @@
# @ stub RaiseFailFastException
@ stdcall ReOpenFile(ptr long long long)
@ stdcall ReadConsoleA(long ptr long ptr ptr) kernel32.ReadConsoleA
@ stdcall ReadConsoleInputA(long ptr long ptr) kernel32.ReadConsoleInputA
@ stdcall ReadConsoleInputA(long ptr long ptr)
@ stub ReadConsoleInputExA
@ stub ReadConsoleInputExW
@ stdcall ReadConsoleInputW(long ptr long ptr) kernel32.ReadConsoleInputW
@ stdcall ReadConsoleInputW(long ptr long ptr)
@ stdcall ReadConsoleOutputA(long ptr long long ptr)
@ stdcall ReadConsoleOutputAttribute(long ptr long long ptr)
@ stdcall ReadConsoleOutputCharacterA(long ptr long long ptr)