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/// Protocol for touchscreens.
9pub const AbsolutePointer = extern struct {
10 _reset: *const fn (*AbsolutePointer, bool) callconv(cc) Status,
11 _get_state: *const fn (*const AbsolutePointer, *State) callconv(cc) Status,
12 wait_for_input: Event,
13 mode: *Mode,
14
15 pub const ResetError = uefi.UnexpectedError || error{DeviceError};
16 pub const GetStateError = uefi.UnexpectedError || error{ NotReady, DeviceError };
17
18 /// Resets the pointer device hardware.
19 pub fn reset(self: *AbsolutePointer, verify: bool) ResetError!void {
20 switch (self._reset(self, verify)) {
21 .success => {},
22 .device_error => return error.DeviceError,
23 else => |status| return uefi.unexpectedStatus(status),
24 }
25 }
26
27 /// Retrieves the current state of a pointer device.
28 pub fn getState(self: *const AbsolutePointer) GetStateError!State {
29 var state: State = undefined;
30 switch (self._get_state(self, &state)) {
31 .success => return state,
32 .not_ready => return error.NotReady,
33 .device_error => return error.DeviceError,
34 else => |status| return uefi.unexpectedStatus(status),
35 }
36 }
37
38 pub const guid align(8) = Guid{
39 .time_low = 0x8d59d32b,
40 .time_mid = 0xc655,
41 .time_high_and_version = 0x4ae9,
42 .clock_seq_high_and_reserved = 0x9b,
43 .clock_seq_low = 0x15,
44 .node = [_]u8{ 0xf2, 0x59, 0x04, 0x99, 0x2a, 0x43 },
45 };
46
47 pub const Mode = extern struct {
48 absolute_min_x: u64,
49 absolute_min_y: u64,
50 absolute_min_z: u64,
51 absolute_max_x: u64,
52 absolute_max_y: u64,
53 absolute_max_z: u64,
54 attributes: Attributes,
55
56 pub const Attributes = packed struct(u32) {
57 supports_alt_active: bool,
58 supports_pressure_as_z: bool,
59 _pad: u30 = 0,
60 };
61 };
62
63 pub const State = extern struct {
64 current_x: u64,
65 current_y: u64,
66 current_z: u64,
67 active_buttons: ActiveButtons,
68
69 pub const ActiveButtons = packed struct(u32) {
70 touch_active: bool,
71 alt_active: bool,
72 _pad: u30 = 0,
73 };
74 };
75};