Input

Struct Input 

Source
pub struct Input(/* private fields */);
Expand description

safety wrapper for SimpleTextInputExProtocol

Implementations§

Source§

impl Input

Source

pub fn reset(&mut self, extended_verification: bool) -> Result

clear keyboard cache

Source

pub fn read_key_stroke_ex(&mut self) -> Option<KeyData>

non-blocking keyboard read

Source

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

Source

pub fn set_state(&mut self, state: KeyToggleState) -> Result

only set toggle state

Source

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
  1. 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
}
  1. 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();
Source

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)

Source

pub unsafe fn unregister_key_notify( &mut self, handle: ManualKeyNotifyHandle, ) -> Result

Unregister a callback function

Trait Implementations§

Source§

impl Debug for Input

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Identify for Input

Source§

const GUID: Guid = SimpleTextInputExProtocol::GUID

Unique protocol identifier.
Source§

impl Protocol for Input

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The metadata type for pointers and references to this type.
Source§

impl<P> ProtocolPointer for P
where P: Protocol,

Source§

unsafe fn ptr_from_ffi(ptr: *const c_void) -> *const P

Create a const pointer to a Protocol from a c_void pointer. Read more
Source§

unsafe fn mut_ptr_from_ffi(ptr: *mut c_void) -> *mut P

Create a mutable pointer to a Protocol from a c_void pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.