Hello, so I'm reading the UEFI specification (https://uefi.org/sites/default/files/re ... _03_18.pdf) and within the UEFI there are those two protocols `EFI_SIMPLE_TEXT_INPUT_PROTOCOL` and `EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL` that allow you to read keyboard input within the UEFI.
You use either `EFI_BOOT_SERVICES.WaitForEvent` (blocking) or `EFI_BOOT_SERVICES.CheckEvent` (non-blocking) to check for input and then you use `EFI_SIMPLE_TEXT_INPUT_PROTOCOL.ReadKeyStroke` or `EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL.ReadKeyStrokeEx` to read input if there is any in the buffer.
As far as I understand it, `ReadKeyStrokeEx` and `ReadKeyStroke` behave the same with the exception that the former simply provides more information. Is that correct?
Well my problem is that I want to check whether a certain key is currently held down so that I can handle multiple keypresses at the same time.
I want to create a simple UEFI app game where the player can move in all 8 directions and I want to move diagonally to the top right if e.g. up arrow and right arrow are pressed at the same time.
Is there any way I can achieve that? Otherwise the player would have to spam up arrow, right arrow, up arrow, right arrow etc. to do that.
I also noticed there is this protocol called `EFI_SERIAL_IO_PROTOCOL`. Does this have any relevance here? Can it help me in some way? I'm not entirely sure what it allows me to do.
I appreciate any advice on how to do this.
Checking if a certain key is down within an UEFI app
-
- Member
- Posts: 5563
- Joined: Mon Mar 25, 2013 7:01 pm
Re: Checking if a certain key is down within an UEFI app
Yes.uefiguy wrote:As far as I understand it, `ReadKeyStrokeEx` and `ReadKeyStroke` behave the same with the exception that the former simply provides more information. Is that correct?
No. Held key reporting is limited to the modifiers listed under the description of ReadKeyStrokeEx().uefiguy wrote:I want to create a simple UEFI app game where the player can move in all 8 directions and I want to move diagonally to the top right if e.g. up arrow and right arrow are pressed at the same time.
Is there any way I can achieve that?
It allows you to send and receive data over a serial port. It might be helpful for debugging or remote control via serial terminal. It's irrelevant unless you're using a serial terminal instead of a keyboard.uefiguy wrote:I also noticed there is this protocol called `EFI_SERIAL_IO_PROTOCOL`. Does this have any relevance here? Can it help me in some way? I'm not entirely sure what it allows me to do.
Re: Checking if a certain key is down within an UEFI app
Even though it doesn't really matter, I'll say it anyway: UEFI isn't designed for you to be able to play games, browse the web etc. Its not a general-purpose OS or anything like that, so a lot of functionality you'd expect or think to be there based on how the protocols are described probably isn't. (E.g.: EDK II doesn't implement isochronous USB transfers for example, even though the function in the protocol exists.) If there's anything I've learned when working with UEFI, its the following two golden rules:
- Not all the protocols in the specification are implemented in any implementation, reference or not.
- Not all of the functions, structures, etc. for any given protocol are implemented in any implementation of the specification, reference or not.
Re: Checking if a certain key is down within an UEFI app
Thank you for the answers.