1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
const uefi = @import("std").os.uefi;
const Event = uefi.Event;
const Guid = uefi.Guid;
const Status = uefi.Status;
/// Character input devices, e.g. Keyboard
pub const SimpleTextInputExProtocol = extern struct {
_reset: fn (*const SimpleTextInputExProtocol, bool) callconv(.C) Status,
_read_key_stroke_ex: fn (*const SimpleTextInputExProtocol, *KeyData) callconv(.C) Status,
wait_for_key_ex: Event,
_set_state: fn (*const SimpleTextInputExProtocol, *const u8) callconv(.C) Status,
_register_key_notify: fn (*const SimpleTextInputExProtocol, *const KeyData, fn (*const KeyData) callconv(.C) usize, **anyopaque) callconv(.C) Status,
_unregister_key_notify: fn (*const SimpleTextInputExProtocol, *const anyopaque) callconv(.C) Status,
/// Resets the input device hardware.
pub fn reset(self: *const SimpleTextInputExProtocol, verify: bool) Status {
return self._reset(self, verify);
}
/// Reads the next keystroke from the input device.
pub fn readKeyStrokeEx(self: *const SimpleTextInputExProtocol, key_data: *KeyData) Status {
return self._read_key_stroke_ex(self, key_data);
}
/// Set certain state for the input device.
pub fn setState(self: *const SimpleTextInputExProtocol, state: *const u8) Status {
return self._set_state(self, state);
}
/// Register a notification function for a particular keystroke for the input device.
pub fn registerKeyNotify(self: *const SimpleTextInputExProtocol, key_data: *const KeyData, notify: fn (*const KeyData) callconv(.C) usize, handle: **anyopaque) Status {
return self._register_key_notify(self, key_data, notify, handle);
}
/// Remove the notification that was previously registered.
pub fn unregisterKeyNotify(self: *const SimpleTextInputExProtocol, handle: *const anyopaque) Status {
return self._unregister_key_notify(self, handle);
}
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 KeyData = extern struct {
key: InputKey = undefined,
key_state: KeyState = undefined,
};
pub const KeyState = extern struct {
key_shift_state: packed struct {
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,
},
key_toggle_state: packed struct {
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 InputKey = extern struct {
scan_code: u16,
unicode_char: u16,
};
|