I am trying to draw a cursor with GOP. Cursor drawing happens in while loop.
My file where GOP located: https://drive.google.com/file/d/1neifcwzow4WLGId7LRCzEFx5n43narDi/view?usp=sharing
/*...OTHER CODE...*/
RunGraphics(...); //CLEAR SCREEN
setCursorPosition(&cursor, (UINT32)(Info->HorizontalResolution/2), (UINT32)(Info->VerticalResolution/2));
while (1)
{
UINTN index;
Status = gBS->WaitForEvent(2, &Events, &index);
// INDEX 1 IS KEYBOARD MESSAGE
if (index == 1)
{
Status = gST->ConIn->ReadKeyStroke(gST->ConIn, &Key);
if ((UINTN)Key.ScanCode == SCAN_ESC)
{
if(ESC_KEY_DOWN_COUNT == 0)
{
SystemTable->ConIn->Reset(SystemTable->ConIn, FALSE);
SystemTable->RuntimeServices->ResetSystem(EfiResetShutdown, EFI_SUCCESS, 0, NULL);
return EFI_SUCCESS;
}
ESC_KEY_DOWN_COUNT--;
}
else
{
ESC_KEY_DOWN_COUNT = 2;
Print(L"%c", Key.UnicodeChar);
}
}
else if (index == 0)
{
Status = mouse->GetState(mouse, &State);
Print(L"X:%d Y:%d Z:%d L:%d R:%d\n",
State.RelativeMovementX,
State.RelativeMovementY,
State.RelativeMovementZ,
State.LeftButton,
State.RightButton
);
setCursorPosition(&cursor, cursor.Position.X + State.RelativeMovementX, cursor.Position.Y + State.RelativeMovementY, info->HorizontalResolution, info->VerticalResolution);
DrawCursorClassic(cursor.Position.X,cursor.Position.Y,255,255,255 /*RGB*/);
//RUNS VERY LAGGY.
}
}
What should I do to improve my performance or what I did wrong here ?