From 5b90554b7604b76c1ba912cb585e30876d6042ba Mon Sep 17 00:00:00 2001 From: Joursoir Date: Wed, 1 Dec 2021 19:39:14 +0300 Subject: tbi/win: make wgetch() --- Library/UefiShellUfmCommandLib/tbi/win.c | 19 +++++++++++++++++++ Library/UefiShellUfmCommandLib/tbi/win.h | 10 ++++++++++ 2 files changed, 29 insertions(+) (limited to 'Library') diff --git a/Library/UefiShellUfmCommandLib/tbi/win.c b/Library/UefiShellUfmCommandLib/tbi/win.c index 55171da..6ef09a2 100644 --- a/Library/UefiShellUfmCommandLib/tbi/win.c +++ b/Library/UefiShellUfmCommandLib/tbi/win.c @@ -5,6 +5,7 @@ #include // UnicodeVSPrint() #include #include +#include #include "screen.h" #include "win.h" @@ -122,6 +123,24 @@ VOID echo(struct window *w, BOOLEAN state) w->echo = state; } +EFI_INPUT_KEY wgetch(struct window *w) +{ + UINTN key_event = 0; + EFI_SIMPLE_TEXT_INPUT_PROTOCOL *stdin; + EFI_INPUT_KEY key = { 0 }; + + ASSERT(w != NULL); + + stdin = w->scr->stdin; + gBS->WaitForEvent(1, &stdin->WaitForKey, &key_event); + stdin->ReadKeyStroke(stdin, &key); + + if(echo) { + ; // print char + } + return key; +} + BOOLEAN wmove(struct window *w, INT32 x, INT32 y) { ASSERT(w != NULL); diff --git a/Library/UefiShellUfmCommandLib/tbi/win.h b/Library/UefiShellUfmCommandLib/tbi/win.h index 02822d4..0dfe41b 100644 --- a/Library/UefiShellUfmCommandLib/tbi/win.h +++ b/Library/UefiShellUfmCommandLib/tbi/win.h @@ -86,6 +86,16 @@ VOID wattroff(struct window *w); */ VOID echo(struct window *w, BOOLEAN state); +/* + * Gets character from the input device. + * + * w: the window on which to operate + * + * return: A pointer to a buffer that is filled in with the keystroke + * information for the key that was pressed. +*/ +EFI_INPUT_KEY wgetch(struct window *w); + /* * Moves cursor position to specified coordinates * -- cgit v1.2.3-18-g5258