]> git.ipfire.org Git - thirdparty/grub.git/commit
efi/console: Add grub_console_read_key_stroke() helper function
authorHans de Goede <hdegoede@redhat.com>
Wed, 15 Apr 2020 10:26:19 +0000 (12:26 +0200)
committerDaniel Kiper <daniel.kiper@oracle.com>
Tue, 21 Apr 2020 20:11:17 +0000 (22:11 +0200)
commit8bab36af603aa49fff628cd64722352fb96c3dd1
treed6ecf54e048e50436b37ce5d42fc7358e49a9a14
parent5bcdf676421308f463d0917e3e5eac04f41ee608
efi/console: Add grub_console_read_key_stroke() helper function

This is a preparatory patch for adding getkeystatus() support to the
EFI console driver.

We can get modifier status through the simple_text_input read_key_stroke()
method, but if a non-modifier key is (also) pressed the read_key_stroke()
call will consume that key from the firmware's queue.

The new grub_console_read_key_stroke() helper buffers upto 1 key-stroke.
If it has a non-modifier key buffered, it will return that one, if its
buffer is empty, it will fills its buffer by getting a new key-stroke.

If called with consume=1 it will empty its buffer after copying the
key-data to the callers buffer, this is how getkey() will use it.

If called with consume=0 it will keep the last key-stroke buffered, this
is how getkeystatus() will call it. This means that if a non-modifier
key gets pressed, repeated getkeystatus() calls will return the modifiers
of that key-press until it is consumed by a getkey() call.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/term/efi/console.c