You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在uefi-rs(UEFI Rust封装库)中读取用户输入?

UEFI Rust开发:如何获取用户输入?

我想了解是否可以使用uefi-rs(UEFI Rust封装库)在UEFI中读取用户输入,或者是否有其他基于Rust的UEFI用户输入获取方式。

我尝试了read_key、按键事件等多种方法,其中一种无法编译,另一种仅输出零值。我还查阅了数十个GitHub仓库,但似乎没有仓库使用这些方法。

第一种方法(读取按键)

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.");
}

第二种方法(等待事件)

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.");

由于我对Rust并不十分熟练,代码中可能存在很多新手错误。我做过几个Rust项目,现在尝试UEFI开发,发现用户输入在汇编中相对容易实现,但在Rust中遇到了困难。

若有人知晓可参考的仓库或解决方案,恳请帮忙,我已为此耗费数小时。


内容的提问来源于stack exchange,提问作者Skyslycer

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.24 23:33:22