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