跳转到内容

std.os.uefi.protocol.simple_text_input_ex

标准库Zig 0.17.0官方原文
源码std/os/uefi/protocol/simple_text_input_ex.zig

第 1 行

std.os.uefi.protocol.simple_text_input_ex.cc

别名

第 6 行

别名目标 std.os.uefi.cc

std.os.uefi.protocol.simple_text_input_ex.Event

别名

第 3 行

别名目标 std.os.uefi.Event

std.os.uefi.protocol.simple_text_input_ex.Guid

别名

第 4 行

别名目标 std.os.uefi.Guid

std.os.uefi.protocol.simple_text_input_ex.SimpleTextInputEx

容器

第 9 行

字符输入设备,例如键盘

字段

_reset: *const fn (*SimpleTextInputEx, bool) callconv(cc) Status
_read_key_stroke_ex: *const fn (*SimpleTextInputEx, *Key) callconv(cc) Status
wait_for_key_ex: Event
_set_state: *const fn (*SimpleTextInputEx, *const u8) callconv(cc) Status
_register_key_notify: *const fn (*SimpleTextInputEx, *const Key, *const fn (*const Key) callconv(cc) Status, **anyopaque) callconv(cc) Status
_unregister_key_notify: *const fn (*SimpleTextInputEx, *const anyopaque) callconv(cc) Status

std.os.uefi.protocol.simple_text_input_ex.SimpleTextInputEx.guid

常量

第 87 行

std.os.uefi.protocol.simple_text_input_ex.SimpleTextInputEx.Key

容器

第 96 行

字段

input: Input
state: State

std.os.uefi.protocol.simple_text_input_ex.SimpleTextInputEx.Key.Input

容器

第 129 行

字段

scan_code: u16
unicode_char: u16

std.os.uefi.protocol.simple_text_input_ex.SimpleTextInputEx.Key.State

容器

第 100 行

字段

shift: Shift
toggle: Toggle

std.os.uefi.protocol.simple_text_input_ex.SimpleTextInputEx.Key.State.Shift

容器

第 104 行

字段

right_shift_pressed: bool
left_shift_pressed: bool
right_control_pressed: bool
left_control_pressed: bool
right_alt_pressed: bool
left_alt_pressed: bool
right_logo_pressed: bool
left_logo_pressed: bool
menu_key_pressed: bool
sys_req_pressed: bool
_pad: u21 = 0
shift_state_valid: bool

std.os.uefi.protocol.simple_text_input_ex.SimpleTextInputEx.Key.State.Toggle

容器

第 119 行

字段

scroll_lock_active: bool
num_lock_active: bool
caps_lock_active: bool
_pad: u3 = 0
key_state_exposed: bool
toggle_state_valid: bool

std.os.uefi.protocol.simple_text_input_ex.SimpleTextInputEx.readKeyStroke

函数

第 40 行

从输入设备读取下一个按键。

pub fn readKeyStroke(self: *SimpleTextInputEx) ReadKeyStrokeError!Key

参数

错误

DeviceError
NotReady
Unexpected UnexpectedError
Unsupported

std.os.uefi.protocol.simple_text_input_ex.SimpleTextInputEx.ReadKeyStrokeError

错误集合

第 18 行

错误

DeviceError
NotReady
Unexpected UnexpectedError
Unsupported

std.os.uefi.protocol.simple_text_input_ex.SimpleTextInputEx.registerKeyNotify

函数

第 62 行

为输入设备的特定按键注册通知函数。

pub fn registerKeyNotify( self: *SimpleTextInputEx, key_data: *const Key, notify: *const fn (*const Key) callconv(cc) Status, ) RegisterKeyNotifyError!uefi.Handle

参数

self: *SimpleTextInputEx
key_data: *const Key
notify: *const fn (*const Key) callconv(cc) Status

错误

OutOfResources
Unexpected UnexpectedError

std.os.uefi.protocol.simple_text_input_ex.SimpleTextInputEx.RegisterKeyNotifyError

错误集合

第 27 行

错误

OutOfResources
Unexpected UnexpectedError

std.os.uefi.protocol.simple_text_input_ex.SimpleTextInputEx.reset

函数

第 31 行

重置输入设备硬件。

pub fn reset(self: *SimpleTextInputEx, verify: bool) ResetError!void

参数

self: *SimpleTextInputEx
verify: bool

错误

DeviceError
Unexpected UnexpectedError

std.os.uefi.protocol.simple_text_input_ex.SimpleTextInputEx.ResetError

错误集合

第 17 行

错误

DeviceError
Unexpected UnexpectedError

std.os.uefi.protocol.simple_text_input_ex.SimpleTextInputEx.setState

函数

第 52 行

为输入设备设置特定状态。

pub fn setState(self: *SimpleTextInputEx, state: *const Key.State.Toggle) SetStateError!void

参数

self: *SimpleTextInputEx
state: *const Key.State.Toggle

错误

DeviceError
Unexpected UnexpectedError
Unsupported

std.os.uefi.protocol.simple_text_input_ex.SimpleTextInputEx.SetStateError

错误集合

第 23 行

错误

DeviceError
Unexpected UnexpectedError
Unsupported

std.os.uefi.protocol.simple_text_input_ex.SimpleTextInputEx.unregisterKeyNotify

函数

第 76 行

移除先前注册的通知。

pub fn unregisterKeyNotify( self: *SimpleTextInputEx, handle: uefi.Handle, ) UnregisterKeyNotifyError!void

参数

self: *SimpleTextInputEx
handle: uefi.Handle

错误

InvalidParameter
Unexpected UnexpectedError

std.os.uefi.protocol.simple_text_input_ex.SimpleTextInputEx.UnregisterKeyNotifyError

错误集合

第 28 行

错误

InvalidParameter
Unexpected UnexpectedError

std.os.uefi.protocol.simple_text_input_ex.Status

别名

第 5 行

别名目标 std.os.uefi.Status

std.os.uefi.protocol.simple_text_input_ex.std

别名

第 1 行

别名目标 std

std.os.uefi.protocol.simple_text_input_ex.uefi

别名

第 2 行

别名目标 std.os.uefi

源码

std/os/uefi/protocol/simple_text_input_ex.zig

const std = @import("std");
const uefi = std.os.uefi;
const Event = uefi.Event;
const Guid = uefi.Guid;
const Status = uefi.Status;
const cc = uefi.cc;

/// 字符输入设备,例如键盘
pub const SimpleTextInputEx = extern struct {
    _reset: *const fn (*SimpleTextInputEx, bool) callconv(cc) Status,
    _read_key_stroke_ex: *const fn (*SimpleTextInputEx, *Key) callconv(cc) Status,
    wait_for_key_ex: Event,
    _set_state: *const fn (*SimpleTextInputEx, *const u8) callconv(cc) Status,
    _register_key_notify: *const fn (*SimpleTextInputEx, *const Key, *const fn (*const Key) callconv(cc) Status, **anyopaque) callconv(cc) Status,
    _unregister_key_notify: *const fn (*SimpleTextInputEx, *const anyopaque) callconv(cc) Status,

    pub const ResetError = uefi.UnexpectedError || error{DeviceError};
    pub const ReadKeyStrokeError = uefi.UnexpectedError || error{
        NotReady,
        DeviceError,
        Unsupported,
    };
    pub const SetStateError = uefi.UnexpectedError || error{
        DeviceError,
        Unsupported,
    };
    pub const RegisterKeyNotifyError = uefi.UnexpectedError || error{OutOfResources};
    pub const UnregisterKeyNotifyError = uefi.UnexpectedError || error{InvalidParameter};

    /// 重置输入设备硬件。
    pub fn reset(self: *SimpleTextInputEx, verify: bool) ResetError!void {
        switch (self._reset(self, verify)) {
            .success => {},
            .device_error => return error.DeviceError,
            else => |status| return uefi.unexpectedStatus(status),
        }
    }

    /// 从输入设备读取下一个按键。
    pub fn readKeyStroke(self: *SimpleTextInputEx) ReadKeyStrokeError!Key {
        var key: Key = undefined;
        switch (self._read_key_stroke_ex(self, &key)) {
            .success => return key,
            .not_ready => return error.NotReady,
            .device_error => return error.DeviceError,
            .unsupported => return error.Unsupported,
            else => |status| return uefi.unexpectedStatus(status),
        }
    }

    /// 为输入设备设置特定状态。
    pub fn setState(self: *SimpleTextInputEx, state: *const Key.State.Toggle) SetStateError!void {
        switch (self._set_state(self, @ptrCast(state))) {
            .success => {},
            .device_error => return error.DeviceError,
            .unsupported => return error.Unsupported,
            else => |status| return uefi.unexpectedStatus(status),
        }
    }

    /// 为输入设备的特定按键注册通知函数。
    pub fn registerKeyNotify(
        self: *SimpleTextInputEx,
        key_data: *const Key,
        notify: *const fn (*const Key) callconv(cc) Status,
    ) RegisterKeyNotifyError!uefi.Handle {
        var handle: uefi.Handle = undefined;
        switch (self._register_key_notify(self, key_data, notify, &handle)) {
            .success => return handle,
            .out_of_resources => return error.OutOfResources,
            else => |status| return uefi.unexpectedStatus(status),
        }
    }

    /// 移除先前注册的通知。
    pub fn unregisterKeyNotify(
        self: *SimpleTextInputEx,
        handle: uefi.Handle,
    ) UnregisterKeyNotifyError!void {
        switch (self._unregister_key_notify(self, handle)) {
            .success => {},
            .invalid_parameter => return error.InvalidParameter,
            else => |status| return uefi.unexpectedStatus(status),
        }
    }

    pub const guid align(8) = Guid{
        .time_low = 0xdd9e7534,
        .time_mid = 0x7762,
        .time_high_and_version = 0x4698,
        .clock_seq_high_and_reserved = 0x8c,
        .clock_seq_low = 0x14,
        .node = [_]u8{ 0xf5, 0x85, 0x17, 0xa6, 0x25, 0xaa },
    };

    pub const Key = extern struct {
        input: Input,
        state: State,

        pub const State = extern struct {
            shift: Shift,
            toggle: Toggle,

            pub const Shift = packed struct(u32) {
                right_shift_pressed: bool,
                left_shift_pressed: bool,
                right_control_pressed: bool,
                left_control_pressed: bool,
                right_alt_pressed: bool,
                left_alt_pressed: bool,
                right_logo_pressed: bool,
                left_logo_pressed: bool,
                menu_key_pressed: bool,
                sys_req_pressed: bool,
                _pad: u21 = 0,
                shift_state_valid: bool,
            };

            pub const Toggle = packed struct(u8) {
                scroll_lock_active: bool,
                num_lock_active: bool,
                caps_lock_active: bool,
                _pad: u3 = 0,
                key_state_exposed: bool,
                toggle_state_valid: bool,
            };
        };

        pub const Input = extern struct {
            scan_code: u16,
            unicode_char: u16,
        };
    };
};