pub struct Input(/* private fields */);Expand description
safety wrapper for SimpleTextInputExProtocol
Implementations§
Source§impl Input
impl Input
Sourcepub fn read_key_stroke_ex(&mut self) -> Option<KeyData>
pub fn read_key_stroke_ex(&mut self) -> Option<KeyData>
non-blocking keyboard read
Sourcepub fn wait_for_key_event(&self) -> Option<Event>
pub fn wait_for_key_event(&self) -> Option<Event>
Returns an event that is signaled when a key is pressed.
This allows the caller to wait for input without polling in a busy loop,
or to use it in wait_for_event along with other events (like timers).
Sourcepub fn set_state(&mut self, state: KeyToggleState) -> Result
pub fn set_state(&mut self, state: KeyToggleState) -> Result
only set toggle state
Sourcepub fn on_key_callback(
&mut self,
key_data: &KeyData,
notification_function: KeyNotifyFunction,
) -> Result<KeyNotifyHandle<'_>>
pub fn on_key_callback( &mut self, key_data: &KeyData, notification_function: KeyNotifyFunction, ) -> Result<KeyNotifyHandle<'_>>
Register a callback function to be invoked when a key is pressed.
§Usage
- Prepare callback function
extern "efiapi" fn listener(_key_data: *mut uefi_input2::simple_text_input_ex::RawKeyData) -> Status {
if _key_data.is_null() { return Status::INVALID_PARAMETER; }
let data = unsafe { *_key_data };
let data = KeyData::from(data);
uefi::println!("{:?}{:08X}", data.key, data.key_state.key_shift_state);
Status::SUCCESS
}- Register callback function
uefi_input2::with_stdin(|input| {
let trigger_key = KeyData::new('b')?;
let _listener = input.on_key_callback(&trigger_key, listener)?;
loop { core::hint::spin_loop() }
Ok(())
}).unwrap();Sourcepub unsafe fn register_key_notify(
&mut self,
key_data: &KeyData,
notification_function: KeyNotifyFunction,
) -> Result<ManualKeyNotifyHandle>
pub unsafe fn register_key_notify( &mut self, key_data: &KeyData, notification_function: KeyNotifyFunction, ) -> Result<ManualKeyNotifyHandle>
Register a callback function to be invoked when a key is pressed. (need manual unregister)
Sourcepub unsafe fn unregister_key_notify(
&mut self,
handle: ManualKeyNotifyHandle,
) -> Result
pub unsafe fn unregister_key_notify( &mut self, handle: ManualKeyNotifyHandle, ) -> Result
Unregister a callback function
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Input
impl RefUnwindSafe for Input
impl !Send for Input
impl !Sync for Input
impl Unpin for Input
impl UnwindSafe for Input
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more