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)]
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 SHIFT_STATE_VALID: u32 = 0x8000_0000;
35pub const RIGHT_SHIFT_PRESSED: u32 = 0x0000_0001;
36pub const LEFT_SHIFT_PRESSED: u32 = 0x0000_0002;
37pub const RIGHT_CONTROL_PRESSED: u32 = 0x0000_0004;
38pub const LEFT_CONTROL_PRESSED: u32 = 0x0000_0008;
39pub const RIGHT_ALT_PRESSED: u32 = 0x0000_0010;
40pub const LEFT_ALT_PRESSED: u32 = 0x0000_0020;
41pub const RIGHT_LOGO_PRESSED: u32 = 0x0000_0040;
42pub const LEFT_LOGO_PRESSED: u32 = 0x0000_0080;
43pub const MENU_KEY_PRESSED: u32 = 0x0000_0100;
44pub const SYS_REQ_PRESSED: u32 = 0x0000_0200;
45
46pub const TOGGLE_STATE_VALID: u8 = 0x80;
48pub const KEY_STATE_EXPOSED: u8 = 0x40;
49pub const SCROLL_LOCK_ACTIVE: u8 = 0x01;
50pub const NUM_LOCK_ACTIVE: u8 = 0x02;
51pub const CAPS_LOCK_ACTIVE: u8 = 0x04;
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}