I'm trying to get mouse events & inputs working in my UEFI Kernel (made with GNU-EFI)
The thing is, it doesn't work at all in QEMU but when i test it on real hardware it works just fine!
I've tried adding the mouse to the qemu like this: -usb -device usb-host,hostbus=1,hostaddr=3
lsusb lists this as my mouse: Bus 001 Device 003: ID 1532:0078 Razer USA, Ltd Viper (wired) (my mouse is razer viper so this is the mouse)
when i add this option the mouse becomes completely unusable outside and inside of QEMU, i cannot move it or click anything so i have to force shutdown QEMU for my mouse to work again
Sorry again if this sounds such a noob post, really couldn't find anything about this on google
Code:
Code: Select all
EFI_SIMPLE_POINTER_PROTOCOL *mouse;
EFI_SIMPLE_POINTER_STATE State;
EFI_GUID pointer_guid = EFI_SIMPLE_POINTER_PROTOCOL_GUID;
void pointer_mouse_setup() {
uefi_call_wrapper(ST->BootServices->LocateProtocol, 3, &pointer_guid, NULL, (VOID **)&mouse);
uefi_call_wrapper(mouse->Reset, 2, mouse, true);
}
EFI_STATUS EFIAPI efi_main(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) {
InitializeLib(ImageHandle, SystemTable);
// Print(L"Hello, World!\n");
EFI_INPUT_KEY key;
__volume = __getvolume(ImageHandle);
UINTN key_event = 0;
pointer_mouse_setup();
ST = SystemTable;
// ...
UINTN index;
EFI_EVENT Events[2] = {mouse->WaitForInput, ST->ConIn->WaitForKey};
while(!exit) {
uefi_call_wrapper(ST->BootServices->WaitForEvent, 3, 2, Events, &index);
if (index == 0) {
// THIS DOES NOT Get called in the qemu at all while it works just fine when tested on real hardware!
EFI_STATUS x = uefi_call_wrapper(mouse->GetState, 2, mouse, &State); // This says not ready on QEMU too btw!
Print(L"X:%d Y:%d Z:%d L:%d R:%d\n",
State.RelativeMovementX,
State.RelativeMovementY,
State.RelativeMovementZ,
State.LeftButton,
State.RightButton);
}
// keyboard input ...
}
}