Updated fetching mouse procedure

This commit is contained in:
Alex 2023-03-02 02:33:14 +02:00
parent 645578894e
commit 0f42ad6500
Signed by untrusted user who does not match committer: enderice2
GPG Key ID: EACC3AD603BAB4DD

View File

@ -16,31 +16,26 @@ namespace GraphicalUserInterface
{ {
void GUI::FetchInputs() void GUI::FetchInputs()
{ {
KernelCallback callback;
MouseData Mouse; MouseData Mouse;
bool FoundMouseDriver = false; bool FoundMouseDriver = false;
if (likely(DriverManager->GetDrivers().size() > 0)) if (likely(DriverManager->GetDrivers().size() > 0))
{ {
foreach (auto Driver in DriverManager->GetDrivers()) foreach (auto Driver in DriverManager->GetDrivers())
{ {
if (((FexExtended *)((uintptr_t)Driver->Address + EXTENDED_SECTION_ADDRESS))->Driver.Type == FexDriverType::FexDriverType_Input) if (((FexExtended *)((uintptr_t)Driver->Address + EXTENDED_SECTION_ADDRESS))->Driver.Type == FexDriverType::FexDriverType_Input &&
((FexExtended *)((uintptr_t)Driver->Address + EXTENDED_SECTION_ADDRESS))->Driver.TypeFlags & FexDriverInputTypes::FexDriverInputTypes_Mouse)
{ {
static uint32_t DisplayWidth = 0; #ifdef DEBUG
static uint32_t DisplayHeight = 0; static int once = 0;
if (!once++)
if (DisplayWidth == 0) debug("Found mouse driver %ld", Driver->DriverUID);
DisplayWidth = Display->GetBuffer(200)->Width; #endif
KernelCallback callback;
if (DisplayHeight == 0)
DisplayHeight = Display->GetBuffer(200)->Height;
memset(&callback, 0, sizeof(KernelCallback));
callback.Reason = FetchReason; callback.Reason = FetchReason;
DriverManager->IOCB(Driver->DriverUID, (void *)&callback); DriverManager->IOCB(Driver->DriverUID, (void *)&callback);
// TODO: I think I should check somehow what driver is the one that is mouse and not keyboard Mouse.X = callback.InputCallback.Mouse.X;
Mouse.X = (callback.InputCallback.Mouse.X * DisplayWidth) / 0xFFFF; // VMWARE mouse Mouse.Y = callback.InputCallback.Mouse.Y;
Mouse.Y = (callback.InputCallback.Mouse.Y * DisplayHeight) / 0xFFFF; // VMWARE mouse Mouse.Z = callback.InputCallback.Mouse.Z;
Mouse.Z = (callback.InputCallback.Mouse.Z);
Mouse.Left = callback.InputCallback.Mouse.Buttons.Left; Mouse.Left = callback.InputCallback.Mouse.Buttons.Left;
Mouse.Right = callback.InputCallback.Mouse.Buttons.Right; Mouse.Right = callback.InputCallback.Mouse.Buttons.Right;
Mouse.Middle = callback.InputCallback.Mouse.Buttons.Middle; Mouse.Middle = callback.InputCallback.Mouse.Buttons.Middle;
@ -52,8 +47,9 @@ namespace GraphicalUserInterface
if (unlikely(!FoundMouseDriver)) if (unlikely(!FoundMouseDriver))
{ {
Mouse.X = 0; debug("No mouse driver found.");
Mouse.Y = 0; Mouse.X = Display->GetBuffer(200)->Width / 2;
Mouse.Y = Display->GetBuffer(200)->Height / 2;
Mouse.Z = 0; Mouse.Z = 0;
Mouse.Left = false; Mouse.Left = false;
Mouse.Right = false; Mouse.Right = false;