OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 3:03 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Checking if a certain key is down within an UEFI app
PostPosted: Thu Dec 30, 2021 4:12 am 
Offline

Joined: Mon Dec 27, 2021 1:33 pm
Posts: 4
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.


Top
 Profile  
 
 Post subject: Re: Checking if a certain key is down within an UEFI app
PostPosted: Thu Dec 30, 2021 10:48 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
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?

Yes.

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?

No. Held key reporting is limited to the modifiers listed under the description of ReadKeyStrokeEx().

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.

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.


Top
 Profile  
 
 Post subject: Re: Checking if a certain key is down within an UEFI app
PostPosted: Sat Jan 01, 2022 6:02 pm 
Offline
Member
Member

Joined: Sun Jun 23, 2019 5:36 pm
Posts: 618
Location: North Dakota, United States
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:
  1. Not all the protocols in the specification are implemented in any implementation, reference or not.
  2. Not all of the functions, structures, etc. for any given protocol are implemented in any implementation of the specification, reference or not.
Usually, you have to find out the second point the hard way -- by digging through the code or contacting the developers.


Top
 Profile  
 
 Post subject: Re: Checking if a certain key is down within an UEFI app
PostPosted: Mon Jan 03, 2022 12:25 pm 
Offline

Joined: Mon Dec 27, 2021 1:33 pm
Posts: 4
Thank you for the answers.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 74 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group