Code: Select all
EFI_SIMPLE_POINTER_PROTOCOL* spp;
EFI_SIMPLE_POINTER_STATE ps;
void InitMouse() {
EFI_GUID sppg = EFI_SIMPLE_POINTER_PROTOCOL_GUID;
EFI_HANDLE* handle_buffer;
UINTN handle_count = 0;
EFI_STATUS statusx = BS->LocateHandleBuffer( ByProtocol,
&sppg,
NULL,
&handle_count,
&handle_buffer );
if ( EFI_ERROR(statusx) ) panic("UEFI broken");
EFI_STATUS status = BS->HandleProtocol( handle_buffer[0],
&sppg,
(VOID **)&spp );
if (EFI_ERROR(status)) {
panic("Mouse required!");
}
EFI_STATUS xx = spp->Reset(spp, FALSE);
if ( EFI_ERROR(xx) ) {
panic("Failed to initialize pointy I/O");
}
}
void UpdateMouse() {
WaitForSingleEvent(spp->WaitForInput, 0);
EFI_STATUS x = spp->GetState(spp, &ps);
printf("%d, %d, %d\n", ps.RelativeMovementX, ps.RelativeMovementY, ps.RelativeMovementZ);
if ( x == EFI_NOT_READY ) printf("Not ready");
if ( x == EFI_DEVICE_ERROR ) panic("Error");
}
/*
void panic(char *msg) -- Print error and halt
int printf(char *format, ...) -- Standard printf implementation
*/