lib/gterm: Support framebuffer rotation

This commit is contained in:
iretq
2025-12-08 09:26:00 +01:00
committed by Mintsuki
parent e6bd838bc6
commit aaa500ba70
4 changed files with 30 additions and 3 deletions

View File

@@ -120,6 +120,8 @@ Limine interface control options:
Limine will pick a resolution automatically. If the resolution is not
available, Limine will pick another one automatically. Ignored if using text
mode.
* `interface_rotation` - Specifies the rotation of the Limine interface.
It can be any of the following values: `0`, `90`, `180`, `270`. Default is `0`.
* `interface_branding` - A string that will be displayed on top of the Limine
interface.
* `interface_branding_colour` - A value between 0 and 7 specifying the colour

View File

@@ -104,7 +104,7 @@ if ! test -f version; then
clone_repo_commit \
https://codeberg.org/Mintsuki/Flanterm.git \
flanterm \
ea6a6cdecf3b830f2a8cb4ffe3e58098937224c3
f9d424145bdde18872714094434797e2f44ff5b4
download_by_hash \
https://github.com/nothings/stb/raw/5c205738c191bcb0abc65c4febfa9bd25ff35234/stb_image.h \

View File

@@ -525,6 +525,18 @@ bool gterm_init(struct fb_info **_fbs, size_t *_fbs_count,
margin = 64;
margin_gradient = 4;
int fb_rotation = FLANTERM_FB_ROTATE_0;
char *rotation_str = config_get_value(config, 0, "INTERFACE_ROTATION");
if (rotation_str != NULL) {
int rotation_val = strtoui(rotation_str, NULL, 10);
switch (rotation_val) {
case 90: fb_rotation = FLANTERM_FB_ROTATE_90; break;
case 180: fb_rotation = FLANTERM_FB_ROTATE_180; break;
case 270: fb_rotation = FLANTERM_FB_ROTATE_270; break;
}
pmm_free(rotation_str, strlen(rotation_str) + 1);
}
uint32_t ansi_colours[8];
ansi_colours[0] = 0x00000000; // black
@@ -713,6 +725,12 @@ no_load_font:;
continue;
}
if (fb_rotation == FLANTERM_FB_ROTATE_90 || fb_rotation == FLANTERM_FB_ROTATE_270) {
uint64_t tmp = fb->framebuffer_width;
fb->framebuffer_width = fb->framebuffer_height;
fb->framebuffer_height = tmp;
}
if (background != NULL) {
char *background_layout = config_get_value(config, 0, "WALLPAPER_STYLE");
if (background_layout != NULL && strcmp(background_layout, "centered") == 0) {
@@ -740,6 +758,12 @@ no_load_font:;
}
}
if (fb_rotation == FLANTERM_FB_ROTATE_90 || fb_rotation == FLANTERM_FB_ROTATE_270) {
uint64_t tmp = fb->framebuffer_width;
fb->framebuffer_width = fb->framebuffer_height;
fb->framebuffer_height = tmp;
}
terms[terms_i] = flanterm_fb_init(ext_mem_alloc,
pmm_free,
(void *)(uintptr_t)fb->framebuffer_addr,
@@ -753,7 +777,7 @@ no_load_font:;
&default_bg_bright, &default_fg_bright,
font, font_width, font_height, font_spacing,
font_scale_x, font_scale_y,
margin);
margin, fb_rotation);
if (terms[terms_i] != NULL) {
terms_i++;

View File

@@ -311,7 +311,8 @@ static void limine_main(void) {
NULL, NULL,
NULL, 0, 0, 1,
0, 0,
0
0,
FLANTERM_FB_ROTATE_0
);
uint64_t executable_slide = (uint64_t)executable_start - 0xffffffff80000000;