kernel32: Use new IOCTL_CONDRV_SCROLL ioctl for FlushConsoleInputBuffer implementation.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2020-10-15 18:19:36 +02:00 committed by Alexandre Julliard
parent 591cb80dea
commit 6f05b299bc
3 changed files with 10 additions and 29 deletions

View File

@ -148,38 +148,12 @@ HANDLE WINAPI GetConsoleInputWaitHandle(void)
}
/******************************************************************************
* read_console_input
*
* Helper function for ReadConsole, ReadConsoleInput and FlushConsoleInputBuffer
*
* Returns
* 0 for error, 1 for no INPUT_RECORD ready, 2 with INPUT_RECORD ready
*/
enum read_console_input_return {rci_error = 0, rci_timeout = 1, rci_gotone = 2};
static enum read_console_input_return read_console_input(HANDLE handle, PINPUT_RECORD ir, DWORD timeout)
{
int blocking = timeout != 0;
DWORD read_bytes;
if (!DeviceIoControl( handle, IOCTL_CONDRV_READ_INPUT, &blocking, sizeof(blocking), ir, sizeof(*ir), &read_bytes, NULL ))
return rci_error;
return read_bytes ? rci_gotone : rci_timeout;
}
/***********************************************************************
* FlushConsoleInputBuffer (KERNEL32.@)
*/
BOOL WINAPI FlushConsoleInputBuffer( HANDLE handle )
{
enum read_console_input_return last;
INPUT_RECORD ir;
while ((last = read_console_input(handle, &ir, 0)) == rci_gotone);
return last == rci_timeout;
return DeviceIoControl( handle, IOCTL_CONDRV_FLUSH, NULL, 0, NULL, 0, NULL, NULL );
}

View File

@ -39,6 +39,7 @@
#define IOCTL_CONDRV_SET_TITLE CTL_CODE(FILE_DEVICE_CONSOLE, 17, METHOD_BUFFERED, FILE_WRITE_ACCESS)
#define IOCTL_CONDRV_CTRL_EVENT CTL_CODE(FILE_DEVICE_CONSOLE, 18, METHOD_BUFFERED, FILE_WRITE_ACCESS)
#define IOCTL_CONDRV_BEEP CTL_CODE(FILE_DEVICE_CONSOLE, 19, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_CONDRV_FLUSH CTL_CODE(FILE_DEVICE_CONSOLE, 20, METHOD_BUFFERED, FILE_ANY_ACCESS)
/* console output ioctls */
#define IOCTL_CONDRV_WRITE_CONSOLE CTL_CODE(FILE_DEVICE_CONSOLE, 30, METHOD_BUFFERED, FILE_WRITE_ACCESS)

View File

@ -2321,8 +2321,8 @@ static NTSTATUS screen_buffer_ioctl( struct screen_buffer *screen_buffer, unsign
return scroll_output( screen_buffer, in_data );
default:
FIXME( "unsupported ioctl %x\n", code );
return STATUS_NOT_SUPPORTED;
WARN( "invalid ioctl %x\n", code );
return STATUS_INVALID_HANDLE;
}
}
@ -2439,6 +2439,12 @@ static NTSTATUS console_input_ioctl( struct console *console, unsigned int code,
}
return STATUS_SUCCESS;
case IOCTL_CONDRV_FLUSH:
if (in_size || *out_size) return STATUS_INVALID_PARAMETER;
TRACE( "flush\n" );
console->record_count = 0;
return STATUS_SUCCESS;
default:
FIXME( "unsupported ioctl %x\n", code );
return STATUS_NOT_SUPPORTED;