did some stuff, will probably refactor later
This commit is contained in:
parent
10ee4fcbd9
commit
bc4ec556e2
46 changed files with 1013 additions and 35635 deletions
|
@ -26,13 +26,15 @@
|
|||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
bool get_framebuffer(uintptr_t *fb_addr, struct fb_mode **available_modes, int *total_modes, int *current_mode_index)
|
||||
bool get_framebuffer(uint32_t **fb_addr, struct fb_mode **available_modes, int *total_modes, int *current_mode_index)
|
||||
{
|
||||
EFI_GUID gop_guid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID;
|
||||
EFI_GRAPHICS_OUTPUT_PROTOCOL *gop = NULL;
|
||||
EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *mode_info = NULL;
|
||||
EFI_UINTN mode_info_size = sizeof(EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);
|
||||
EFI_UINTN SizeOfInfo, numModes, nativeMode;
|
||||
EFI_UINTN SizeOfInfo;
|
||||
EFI_UINTN numModes = 0;
|
||||
EFI_UINTN nativeMode = 0;
|
||||
EFI_UINTN mode_index = 0;
|
||||
EFI_STATUS Status;
|
||||
|
||||
|
@ -45,10 +47,9 @@ bool get_framebuffer(uintptr_t *fb_addr, struct fb_mode **available_modes, int *
|
|||
// this is needed to get the current video mode
|
||||
if (Status == EFI_NOT_STARTED) {
|
||||
Status = gop->SetMode(gop, 0);
|
||||
}
|
||||
|
||||
if (EFI_ERROR(Status)) {
|
||||
} else if (EFI_ERROR(Status)) {
|
||||
debug("Unable to get native mode\n");
|
||||
return false;
|
||||
} else {
|
||||
nativeMode = gop->Mode->Mode;
|
||||
numModes = gop->Mode->MaxMode;
|
||||
|
@ -57,10 +58,10 @@ bool get_framebuffer(uintptr_t *fb_addr, struct fb_mode **available_modes, int *
|
|||
*total_modes = numModes;
|
||||
*available_modes = (struct fb_mode *)mem_alloc(sizeof(struct fb_mode) * numModes);
|
||||
|
||||
*fb_addr = gop->Mode->FrameBufferBase;
|
||||
*fb_addr = (uint32_t *)gop->Mode->FrameBufferBase;
|
||||
|
||||
// get all available modes
|
||||
for (int i = 0; i < numModes; i++) {
|
||||
for (int i = 0; i < (int)numModes; i++) {
|
||||
Status = gop->QueryMode(gop, i, &SizeOfInfo, &mode_info);
|
||||
|
||||
(*available_modes)[i].width = mode_info->HorizontalResolution;
|
||||
|
@ -77,7 +78,7 @@ bool get_framebuffer(uintptr_t *fb_addr, struct fb_mode **available_modes, int *
|
|||
(*available_modes)[i].format = FB_BGRA;
|
||||
}
|
||||
|
||||
if (i == nativeMode) {
|
||||
if (i == (int)nativeMode) {
|
||||
*current_mode_index = i;
|
||||
}
|
||||
}
|
||||
|
|
45
boot/platform/uefi/ui/mouse.c
Normal file
45
boot/platform/uefi/ui/mouse.c
Normal file
|
@ -0,0 +1,45 @@
|
|||
/*********************************************************************************/
|
||||
/* Module Name: mouse.c */
|
||||
/* Project: AurixOS */
|
||||
/* */
|
||||
/* Copyright (c) 2024-2025 Jozef Nagy */
|
||||
/* */
|
||||
/* This source is subject to the MIT License. */
|
||||
/* See License.txt in the root of this repository. */
|
||||
/* All other rights reserved. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR */
|
||||
/* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, */
|
||||
/* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE */
|
||||
/* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER */
|
||||
/* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, */
|
||||
/* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE */
|
||||
/* SOFTWARE. */
|
||||
/*********************************************************************************/
|
||||
|
||||
#include <ui/ui.h>
|
||||
#include <ui/mouse.h>
|
||||
#include <efi.h>
|
||||
#include <efilib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
extern EFI_SIMPLE_POINTER_PROTOCOL *gPointerProtocol;
|
||||
extern uint16_t mouse_resx;
|
||||
extern uint16_t mouse_resy;
|
||||
|
||||
void get_mouse(uint16_t *mouse_x, uint16_t *mouse_y, uint8_t *mouse_buttons)
|
||||
{
|
||||
if (!gPointerProtocol) {
|
||||
return;
|
||||
}
|
||||
|
||||
*mouse_buttons = 0;
|
||||
EFI_SIMPLE_POINTER_STATE state;
|
||||
gPointerProtocol->GetState(gPointerProtocol, &state);
|
||||
|
||||
*mouse_buttons |= state.LeftButton ? LEFT_MOUSE_BUTTON : 0;
|
||||
*mouse_buttons |= state.RightButton ? RIGHT_MOUSE_BUTTON : 0;
|
||||
|
||||
*mouse_x += state.RelativeMovementX / mouse_resx;
|
||||
*mouse_y += state.RelativeMovementY / mouse_resy;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue