uefi_input2/
simple_text_input_ex.rs1use core::ffi::c_void;
8pub use uefi_raw::Boolean;
9use uefi_raw::{guid, Event, Guid, Status};
10pub use uefi_raw::protocol::console::InputKey;
11
12pub type KeyToggleState = u8;
13#[repr(C)]
16#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
17pub struct KeyState {
18 pub key_shift_state: u32,
20 pub key_toggle_state: KeyToggleState,
22}
23
24#[repr(C)]
26#[derive(Clone, Copy, Debug, Default)]
27pub struct RawKeyData {
28 pub key: InputKey,
29 pub key_state: KeyState,
30}
31
32pub const RIGHT_SHIFT_PRESSED: u32 = 0b0000_0000_0000_0000_0000_00__0000000001;
35pub const LEFT_SHIFT_PRESSED: u32 = 0b0000_0000_0000_0000_0000_00__0000000010;
36pub const RIGHT_CONTROL_PRESSED: u32 = 0b0000_0000_0000_0000_0000_00__0000000100;
37pub const LEFT_CONTROL_PRESSED: u32 = 0b0000_0000_0000_0000_0000_00__0000001000;
38pub const RIGHT_ALT_PRESSED: u32 = 0b0000_0000_0000_0000_0000_00__0000010000;
39pub const LEFT_ALT_PRESSED: u32 = 0b0000_0000_0000_0000_0000_00__0000100000;
40pub const RIGHT_LOGO_PRESSED: u32 = 0b0000_0000_0000_0000_0000_00__0001000000;
41pub const LEFT_LOGO_PRESSED: u32 = 0b0000_0000_0000_0000_0000_00__0010000000;
42pub const MENU_KEY_PRESSED: u32 = 0b0000_0000_0000_0000_0000_00__0100000000;
43pub const SYS_REQ_PRESSED: u32 = 0b0000_0000_0000_0000_0000_00__1000000000;
44pub const SHIFT_STATE_VALID: u32 = 0b1000_0000_0000_0000_0000_00__0000000000;
45
46pub const SCROLL_LOCK_ACTIVE: u8 = 0b0000_0001;
48pub const NUM_LOCK_ACTIVE: u8 = 0b0000_0010;
49pub const CAPS_LOCK_ACTIVE: u8 = 0b0000_0100;
50pub const KEY_STATE_EXPOSED: u8 = 0b0100_0000;
51pub const TOGGLE_STATE_VALID: u8 = 0b1000_0000;
52
53pub type KeyNotifyFunction = unsafe extern "efiapi" fn(key_data: *mut RawKeyData) -> Status;
56
57#[derive(Debug)]
60#[repr(C)]
61pub struct SimpleTextInputExProtocol {
62 pub reset: unsafe extern "efiapi" fn(this: *mut Self, extended_verification: Boolean) -> Status,
64
65 pub read_key_stroke_ex: unsafe extern "efiapi" fn(this: *mut Self, key_data: *mut RawKeyData) -> Status,
67
68 pub wait_for_key_ex: Event,
70
71 pub set_state: unsafe extern "efiapi" fn(this: *mut Self, key_toggle_state: *mut KeyToggleState) -> Status,
73
74 pub register_key_notify: unsafe extern "efiapi" fn(
76 this: *mut Self,
77 key_data: *mut RawKeyData,
78 key_notification_function: KeyNotifyFunction,
79 notify_handle: *mut *mut c_void,
80 ) -> Status,
81
82 pub unregister_key_notify: unsafe extern "efiapi" fn(this: *mut Self, notification_handle: *mut c_void) -> Status,
84}
85
86impl SimpleTextInputExProtocol {
87 pub const GUID: Guid = guid!("dd9e7534-7762-4698-8c14-f58517a625aa");
88}