Checking if a certain key is down within an UEFI app
Posted: Thu Dec 30, 2021 4:12 am
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.
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.