rust-osdev/uefi-rs

Impossible to create an instance of or use Input struct in uefi::console::text::input

Closed this issue · 2 comments

Impossible to create an instance of or use Input struct in uefi::console::text::input

Hello,

I'm trying to read keyboard input using the latest uefi crate (0.35.0), but I ran into a problem with the Input struct in uefi::console::text::input.

The documentation for Input is very sparse, and it seems impossible to create an instance manually. For example, trying to do something like:

let input = Input::new(); // Doesn't exist

fails because the struct is opaque and has no public constructor.

I also tried using the system table inside my entry function:

#[entry]
fn kernel_main(handle: Handle, mut st: SystemTable<Boot>) -> Status {
    let input = st.stdin(); // returns &Input
    // ... but entry function can't have arguments
}

Even the docs examples don't work.

Could the maintainers clarify:

  1. How to properly obtain and use an Input handle in uefi 0.35.0?
  2. Are there any working examples for reading keyboard input with the current version?

Thank you for your time and for maintaining the crate!

You can use uefi::system::with_stdin to use the Input protocol. I've uploaded a PR adding an example: #1755

For more general information on how to work with protocols, see:

Closing as I currently don't see the bug here. If the example provided by Nicholas in #1755 doesn't help and we indeed have a bug, please comment here and we can open the issue again :)