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