I want to know if there is any way I can read user input in UEFI using the uefi-rs Rust wrapper. (or possibly any other way I can gather user input in UEFI with Rust)
I have tried many different approaches with read_key, the key event, and one didn't even compile and the other one only printed zeros. I have also scavenged through dozens of GitHub repositories, but seemingly none of those used these methods.
The first method (read key):
let bs = st.boot_services();
let read_key = st.stdin().read_key();
let unwrap = read_key.unwrap();
if unwrap.is_some() {
st.stdout().write_str(&unwrap.expect("Error").fmt(&mut fmt::Formatter).to_string()).expect("Failed to write to the console.");
}
And the second method (wait for event):
let mut binding = st.unsafe_clone();
key_event = binding.stdin().wait_for_key_event();
let result = bs.wait_for_event(&mut [key_event.unsafe_clone()]);
let usize = result.unwrap();
st.stdout().write_str(&usize.to_string()).expect("Failed to write to the console.");
There are probably many beginner mistakes in there because I am not extremely experienced with Rust. I did a few projects and now I found this, so I wanted to try it. User input is a thing that is comparably easy in Assembly. (from what I've experienced with Rust so far)
If anyone knows a repository I could check or knows the answer, please help. Have been working on this for hours now.
Link to the crate docs: https://docs.rs/uefi/latest/uefi/ Source code: https://github.com/rust-osdev/uefi-rs