| 39 | } |
| 40 | |
| 41 | EFI_STATUS XPointer::MouseBirth() |
| 42 | { |
| 43 | EFI_STATUS Status = EFI_UNSUPPORTED; |
| 44 | |
| 45 | if (!gSettings.PointerEnabled) { |
| 46 | return EFI_SUCCESS; |
| 47 | } |
| 48 | |
| 49 | if (SimplePointerProtocol) { //do not double |
| 50 | // DBG("Mouse is already here\n"); |
| 51 | Draw(); |
| 52 | return EFI_SUCCESS; |
| 53 | } |
| 54 | |
| 55 | // Try first to use mouse from System Table |
| 56 | Status = gBS->HandleProtocol(gST->ConsoleInHandle, &gEfiSimplePointerProtocolGuid, (VOID**)&SimplePointerProtocol); |
| 57 | if (EFI_ERROR(Status)) { |
| 58 | // not found, so use the first found device |
| 59 | DBG("MouseBirth: No mouse at ConIn, checking if any other device exists\n"); |
| 60 | Status = gBS->LocateProtocol(&gEfiSimplePointerProtocolGuid, NULL, (VOID**)&SimplePointerProtocol); |
| 61 | } |
| 62 | |
| 63 | if (EFI_ERROR(Status)) { |
| 64 | MsgLog("No mouse driver found!\n"); |
| 65 | if (PointerImage) { |
| 66 | delete PointerImage; |
| 67 | PointerImage = NULL; |
| 68 | } |
| 69 | MouseEvent = NoEvents; |
| 70 | SimplePointerProtocol = NULL; |
| 71 | gSettings.PointerEnabled = FALSE; |
| 72 | return Status; |
| 73 | } |
| 74 | |
| 75 | if (PointerImage && !PointerImage->isEmpty() ) { |
| 76 | delete PointerImage; |
| 77 | PointerImage = nullptr; |
| 78 | } |
| 79 | // Now update image because of other theme has other image |
| 80 | PointerImage = new XImage(*ThemeX.GetIconP(BUILTIN_ICON_POINTER)->GetBest(night)); |
| 81 | |
| 82 | oldImage.setSizeInPixels(PointerImage->GetWidth(), PointerImage->GetHeight()); |
| 83 | LastClickTime = 0; |
| 84 | oldPlace.XPos = (INTN)(UGAWidth >> 2); |
| 85 | oldPlace.YPos = (INTN)(UGAHeight >> 2); |
| 86 | oldPlace.Width = PointerImage->GetWidth(); |
| 87 | oldPlace.Height = PointerImage->GetHeight(); |
| 88 | // CopyMem(&newPlace, &oldPlace, sizeof(EG_RECT)); |
| 89 | newPlace = oldPlace; |
| 90 | Draw(); |
| 91 | MouseEvent = NoEvents; |
| 92 | Alive = true; |
| 93 | return Status; |
| 94 | } |
| 95 | |
| 96 | VOID XPointer::Draw() |
| 97 | { |