uefi_input2/
simple_text_input_ex.rs1use core::ffi::c_void;
2pub use uefi_raw::Boolean;
3use uefi_raw::{guid, Event, Guid, Status};
4pub use uefi_raw::protocol::console::InputKey;
5
6pub type KeyToggleState = u8;
7#[repr(C)]
10#[derive(Clone, Copy, Debug, Default)]
11pub struct KeyState {
12 pub key_shift_state: u32,
14 pub key_toggle_state: KeyToggleState,
16}
17
18#[repr(C)]
20#[derive(Clone, Copy, Debug, Default)]
21pub struct RawKeyData {
22 pub key: InputKey,
23 pub key_state: KeyState,
24}
25
26pub const SHIFT_STATE_VALID: u32 = 0x8000_0000;
29pub const RIGHT_SHIFT_PRESSED: u32 = 0x0000_0001;
30pub const LEFT_SHIFT_PRESSED: u32 = 0x0000_0002;
31pub const RIGHT_CONTROL_PRESSED: u32 = 0x0000_0004;
32pub const LEFT_CONTROL_PRESSED: u32 = 0x0000_0008;
33pub const RIGHT_ALT_PRESSED: u32 = 0x0000_0010;
34pub const LEFT_ALT_PRESSED: u32 = 0x0000_0020;
35pub const RIGHT_LOGO_PRESSED: u32 = 0x0000_0040;
36pub const LEFT_LOGO_PRESSED: u32 = 0x0000_0080;
37pub const MENU_KEY_PRESSED: u32 = 0x0000_0100;
38pub const SYS_REQ_PRESSED: u32 = 0x0000_0200;
39
40pub const TOGGLE_STATE_VALID: u8 = 0x80;
42pub const KEY_STATE_EXPOSED: u8 = 0x40;
43pub const SCROLL_LOCK_ACTIVE: u8 = 0x01;
44pub const NUM_LOCK_ACTIVE: u8 = 0x02;
45pub const CAPS_LOCK_ACTIVE: u8 = 0x04;
46
47pub type KeyNotifyFunction = unsafe extern "efiapi" fn(key_data: *mut RawKeyData) -> Status;
50
51#[derive(Debug)]
54#[repr(C)]
55pub struct SimpleTextInputExProtocol {
56 pub reset: unsafe extern "efiapi" fn(this: *mut Self, extended_verification: Boolean) -> Status,
58
59 pub read_key_stroke_ex: unsafe extern "efiapi" fn(this: *mut Self, key_data: *mut RawKeyData) -> Status,
61
62 pub wait_for_key_ex: Event,
64
65 pub set_state: unsafe extern "efiapi" fn(this: *mut Self, key_toggle_state: *mut KeyToggleState) -> Status,
67
68 pub register_key_notify: unsafe extern "efiapi" fn(
70 this: *mut Self,
71 key_data: *mut RawKeyData,
72 key_notification_function: KeyNotifyFunction,
73 notify_handle: *mut *mut c_void,
74 ) -> Status,
75
76 pub unregister_key_notify: unsafe extern "efiapi" fn(this: *mut Self, notification_handle: *mut c_void) -> Status,
78}
79
80impl SimpleTextInputExProtocol {
81 pub const GUID: Guid = guid!("dd9e7534-7762-4698-8c14-f58517a625aa");
82}