master
 1const std = @import("std");
 2const uefi = std.os.uefi;
 3const Event = uefi.Event;
 4const Guid = uefi.Guid;
 5const Status = uefi.Status;
 6const cc = uefi.cc;
 7const Error = Status.Error;
 8
 9/// Character input devices, e.g. Keyboard
10pub const SimpleTextInput = extern struct {
11    _reset: *const fn (*SimpleTextInput, bool) callconv(cc) Status,
12    _read_key_stroke: *const fn (*SimpleTextInput, *Key.Input) callconv(cc) Status,
13    wait_for_key: Event,
14
15    pub const ResetError = uefi.UnexpectedError || error{DeviceError};
16    pub const ReadKeyStrokeError = uefi.UnexpectedError || error{
17        NotReady,
18        DeviceError,
19        Unsupported,
20    };
21
22    /// Resets the input device hardware.
23    pub fn reset(self: *SimpleTextInput, verify: bool) ResetError!void {
24        switch (self._reset(self, verify)) {
25            .success => {},
26            .device_error => return Error.DeviceError,
27            else => |status| return uefi.unexpectedStatus(status),
28        }
29    }
30
31    /// Reads the next keystroke from the input device.
32    pub fn readKeyStroke(self: *SimpleTextInput) ReadKeyStrokeError!Key.Input {
33        var key: Key.Input = undefined;
34        switch (self._read_key_stroke(self, &key)) {
35            .success => return key,
36            .not_ready => return Error.NotReady,
37            .device_error => return Error.DeviceError,
38            .unsupported => return Error.Unsupported,
39            else => |status| return uefi.unexpectedStatus(status),
40        }
41    }
42
43    pub const guid align(8) = Guid{
44        .time_low = 0x387477c1,
45        .time_mid = 0x69c7,
46        .time_high_and_version = 0x11d2,
47        .clock_seq_high_and_reserved = 0x8e,
48        .clock_seq_low = 0x39,
49        .node = [_]u8{ 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b },
50    };
51
52    pub const Key = uefi.protocol.SimpleTextInputEx.Key;
53};