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 mice.
9pub const SimplePointer = struct {
10 _reset: *const fn (*SimplePointer, bool) callconv(cc) Status,
11 _get_state: *const fn (*const SimplePointer, *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{
17 NotReady,
18 DeviceError,
19 };
20
21 /// Resets the pointer device hardware.
22 pub fn reset(self: *SimplePointer, 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 /// Retrieves the current state of a pointer device.
31 pub fn getState(self: *const SimplePointer) GetStateError!State {
32 var state: State = undefined;
33 switch (self._get_state(self, &state)) {
34 .success => return state,
35 .not_ready => return error.NotReady,
36 .device_error => return error.DeviceError,
37 else => |status| return uefi.unexpectedStatus(status),
38 }
39 }
40
41 pub const guid align(8) = Guid{
42 .time_low = 0x31878c87,
43 .time_mid = 0x0b75,
44 .time_high_and_version = 0x11d5,
45 .clock_seq_high_and_reserved = 0x9a,
46 .clock_seq_low = 0x4f,
47 .node = [_]u8{ 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d },
48 };
49
50 pub const Mode = struct {
51 resolution_x: u64,
52 resolution_y: u64,
53 resolution_z: u64,
54 left_button: bool,
55 right_button: bool,
56 };
57
58 pub const State = struct {
59 relative_movement_x: i32,
60 relative_movement_y: i32,
61 relative_movement_z: i32,
62 left_button: bool,
63 right_button: bool,
64 };
65};