diff options
author | Joursoir <chat@joursoir.net> | 2022-04-21 21:42:25 +0300 |
---|---|---|
committer | Joursoir <chat@joursoir.net> | 2022-04-21 21:42:25 +0300 |
commit | 87e0417eaf431d0d1bab9537bd9a9ed33c91e5d3 (patch) | |
tree | 9079001a51d124126ba717578b10ca62513b3024 | |
parent | ce8f793403d4b152425c3dbbf90c44c24a4be57a (diff) | |
download | umt-87e0417eaf431d0d1bab9537bd9a9ed33c91e5d3.tar.gz umt-87e0417eaf431d0d1bab9537bd9a9ed33c91e5d3.tar.bz2 umt-87e0417eaf431d0d1bab9537bd9a9ed33c91e5d3.zip |
main: add a mouse context to a graphics context
-rw-r--r-- | UefiMonitorTest/UefiMonitorTest.c | 53 | ||||
-rw-r--r-- | UefiMonitorTest/UefiMonitorTest.h | 8 | ||||
-rw-r--r-- | UefiMonitorTest/UefiMonitorTest.inf | 3 |
3 files changed, 60 insertions, 4 deletions
diff --git a/UefiMonitorTest/UefiMonitorTest.c b/UefiMonitorTest/UefiMonitorTest.c index 4933f27..92e5799 100644 --- a/UefiMonitorTest/UefiMonitorTest.c +++ b/UefiMonitorTest/UefiMonitorTest.c @@ -10,6 +10,7 @@ #include <Library/UefiRuntimeServicesTableLib.h> #include <Protocol/GraphicsOutput.h> +#include <Protocol/SimplePointer.h> #include "UefiMonitorTest.h" #include "fonts/System-8x16.h" @@ -130,10 +131,14 @@ PrepareGraphicsInfo ( IN EFI_GRAPHICS_OUTPUT_PROTOCOL *Gop ) { - CONST EFI_PIXEL_BITMASK *BitMask; - UINT32 PixelWidth; - INT8 PixelShl[4]; - INT8 PixelShr[4]; + EFI_STATUS Status; + CONST EFI_PIXEL_BITMASK *BitMask; + UINT32 PixelWidth; + INT8 PixelShl[4]; + INT8 PixelShr[4]; + EFI_HANDLE *HandleBuffer; + UINTN HandleCount; + UINTN Index; ASSERT (Graphics != NULL); ASSERT (Gop != NULL); @@ -188,6 +193,46 @@ PrepareGraphicsInfo ( Graphics->PixelWidth = PixelWidth; Graphics->Pitch = Gop->Mode->Info->PixelsPerScanLine; + // Find mouse in System Table ConsoleInHandle + Status = gBS->HandleProtocol ( + gST->ConsoleInHandle, + &gEfiSimplePointerProtocolGuid, + (VOID **)&Graphics->MouseInterface + ); + if (EFI_ERROR (Status)) + { + HandleBuffer = NULL; + Graphics->MouseInterface = NULL; + Status = gBS->LocateHandleBuffer ( + ByProtocol, + &gEfiSimplePointerProtocolGuid, + NULL, + &HandleCount, + &HandleBuffer + ); + if (!EFI_ERROR (Status)) { + for (Index = 0; Index < HandleCount; Index++) { + Status = gBS->HandleProtocol ( + HandleBuffer[Index], + &gEfiSimplePointerProtocolGuid, + (VOID **)&Graphics->MouseInterface + ); + if (!EFI_ERROR (Status)) { + break; + } + } + } + + if (HandleBuffer != NULL) { + FreePool (HandleBuffer); + } + } + + if (!EFI_ERROR (Status) && (Graphics->MouseInterface != NULL)) { + Graphics->MouseSupported = TRUE; + } + + DEBUG ((DEBUG_INFO, "Mouse support: %s\n\n", Graphics->MouseSupported ? L"Yes" : L"No")); return EFI_SUCCESS; } diff --git a/UefiMonitorTest/UefiMonitorTest.h b/UefiMonitorTest/UefiMonitorTest.h index 32214d6..3f82246 100644 --- a/UefiMonitorTest/UefiMonitorTest.h +++ b/UefiMonitorTest/UefiMonitorTest.h @@ -56,6 +56,14 @@ typedef struct { /// Amount of bytes you should skip to go one pixel down. /// UINT32 Pitch; + // + // A mouse support. + // + BOOLEAN MouseSupported; + // + // The MouseInterface instance. + // + EFI_SIMPLE_POINTER_PROTOCOL *MouseInterface; } GRAPHICS_CONTEXT; #endif /* UEFI_MONITOR_TEST_H */ diff --git a/UefiMonitorTest/UefiMonitorTest.inf b/UefiMonitorTest/UefiMonitorTest.inf index 36f7971..7eb27cc 100644 --- a/UefiMonitorTest/UefiMonitorTest.inf +++ b/UefiMonitorTest/UefiMonitorTest.inf @@ -24,6 +24,9 @@ UefiLib UefiRuntimeServicesTableLib +[Protocols] + gEfiSimplePointerProtocolGuid + [FeaturePcd] [Pcd] |