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