feat(gui): LVGL widgets, sleek aerodynamic cursor, right-click context menu, quick settings & settings app
This commit is contained in:
1 parent
7bbcf4567e
commit
2b3e8f0bb6
8 files changed
+948
-238
No files matched your search
+76
-3
@@ -4,10 +4,14 @@
|
||||
#include <airlys/vga.h>
|
||||
#include <airlys/pic.h>
|
||||
#include <airlys/shell.h>
|
||||
#include <airlys/mouse.h>
|
||||
#include <airlys/compositor.h>
|
||||
|
||||
#define KBD_DATA_PORT 0x60
|
||||
|
||||
static bool shift_pressed = false;
|
||||
static bool s_ext_scancode = false;
|
||||
static bool ctrl_pressed = false;
|
||||
|
||||
/* Scan Code Set 1 mapping (lower-case / normal) */
|
||||
static const char kbd_scancode_normal[128] = {
|
||||
@@ -43,18 +47,87 @@ static void keyboard_callback(registers_t* regs) {
|
||||
(void)regs;
|
||||
uint8_t scancode = inb(KBD_DATA_PORT);
|
||||
|
||||
/* Check for Shift key press (0x2A left, 0x36 right) */
|
||||
/* Check extended prefix */
|
||||
if (scancode == 0xE0) {
|
||||
s_ext_scancode = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (s_ext_scancode) {
|
||||
s_ext_scancode = false;
|
||||
/* Extended scancodes for laptop keyboard */
|
||||
switch (scancode) {
|
||||
case 0x48: /* Up Arrow */
|
||||
mouse_move_relative(0, -20);
|
||||
return;
|
||||
case 0x50: /* Down Arrow */
|
||||
mouse_move_relative(0, 20);
|
||||
return;
|
||||
case 0x4B: /* Left Arrow */
|
||||
mouse_move_relative(-20, 0);
|
||||
return;
|
||||
case 0x4D: /* Right Arrow */
|
||||
mouse_move_relative(20, 0);
|
||||
return;
|
||||
case 0x5B: /* Super / Windows Key */
|
||||
compositor_toggle_start_menu();
|
||||
return;
|
||||
case 0x5D: /* Context Menu Key (Right Click) */
|
||||
mouse_set_buttons(false, true);
|
||||
mouse_set_buttons(false, false);
|
||||
return;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/* Track Control key */
|
||||
if (scancode == 0x1D) {
|
||||
ctrl_pressed = true;
|
||||
return;
|
||||
}
|
||||
if (scancode == 0x9D) {
|
||||
ctrl_pressed = false;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Shift press / release */
|
||||
if (scancode == 0x2A || scancode == 0x36) {
|
||||
shift_pressed = true;
|
||||
return;
|
||||
}
|
||||
/* Check for Shift key release (0xAA left, 0xB6 right) */
|
||||
if (scancode == 0xAA || scancode == 0xB6) {
|
||||
shift_pressed = false;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Key release has bit 7 set (scancode >= 0x80) */
|
||||
/* Escape key (0x01): Dismiss menus */
|
||||
if (scancode == 0x01) {
|
||||
compositor_close_context_menu();
|
||||
return;
|
||||
}
|
||||
|
||||
/* Enter key (0x1C) - Left Click trigger for cursor */
|
||||
if (scancode == 0x1C) {
|
||||
mouse_set_buttons(true, false);
|
||||
} else if (scancode == 0x9C) {
|
||||
mouse_set_buttons(false, false);
|
||||
}
|
||||
|
||||
/* Ctrl+A: Toggle Action Center / Quick Settings */
|
||||
if (ctrl_pressed && scancode == 0x1E) {
|
||||
compositor_toggle_quick_settings();
|
||||
return;
|
||||
}
|
||||
|
||||
/* Keypad navigation when NumLock is off */
|
||||
if (scancode == 0x48) { mouse_move_relative(0, -20); return; }
|
||||
if (scancode == 0x50) { mouse_move_relative(0, 20); return; }
|
||||
if (scancode == 0x4B) { mouse_move_relative(-20, 0); return; }
|
||||
if (scancode == 0x4D) { mouse_move_relative(20, 0); return; }
|
||||
|
||||
/* Key release */
|
||||
if (scancode & 0x80) {
|
||||
return;
|
||||
}
|
||||
|
||||
+41
-19
@@ -38,15 +38,28 @@ static uint8_t mouse_read(void) {
|
||||
return inb(MOUSE_PORT_DATA);
|
||||
}
|
||||
|
||||
static void mouse_callback(registers_t* regs) {
|
||||
(void)regs;
|
||||
uint8_t status = inb(MOUSE_PORT_STATUS);
|
||||
if (!(status & 0x01)) return; /* No data ready */
|
||||
if (!(status & 0x20)) return; /* Not auxiliary (mouse) data */
|
||||
void mouse_move_relative(int32_t dx, int32_t dy) {
|
||||
s_mouse_x += dx;
|
||||
s_mouse_y += dy;
|
||||
|
||||
uint8_t b = inb(MOUSE_PORT_DATA);
|
||||
/* Clamp within display bounds */
|
||||
vbe_screen_t* scr = vbe_get_screen();
|
||||
if (scr && scr->width > 0 && scr->height > 0) {
|
||||
if (s_mouse_x < 0) s_mouse_x = 0;
|
||||
if (s_mouse_x >= (int32_t)scr->width) s_mouse_x = (int32_t)scr->width - 1;
|
||||
if (s_mouse_y < 0) s_mouse_y = 0;
|
||||
if (s_mouse_y >= (int32_t)scr->height) s_mouse_y = (int32_t)scr->height - 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Byte 0 alignment check: Bit 3 must always be 1 in PS/2 packet */
|
||||
void mouse_set_buttons(bool left, bool right) {
|
||||
s_left_button = left;
|
||||
s_right_button = right;
|
||||
compositor_handle_mouse(s_mouse_x, s_mouse_y, s_left_button, s_right_button);
|
||||
}
|
||||
|
||||
static void mouse_process_byte(uint8_t b) {
|
||||
/* Byte 0 alignment check: Bit 3 must always be 1 in standard PS/2 packet */
|
||||
if (s_mouse_cycle == 0 && !(b & 0x08)) {
|
||||
return;
|
||||
}
|
||||
@@ -67,26 +80,35 @@ static void mouse_callback(registers_t* regs) {
|
||||
/* Ignore overflow packets */
|
||||
if (flags & 0x40 || flags & 0x80) return;
|
||||
|
||||
s_mouse_x += dx;
|
||||
s_mouse_y -= dy; /* PS/2 Y is positive up, screen Y is positive down */
|
||||
|
||||
/* Clamp within display bounds */
|
||||
vbe_screen_t* scr = vbe_get_screen();
|
||||
if (scr && scr->width > 0 && scr->height > 0) {
|
||||
if (s_mouse_x < 0) s_mouse_x = 0;
|
||||
if (s_mouse_x >= (int32_t)scr->width) s_mouse_x = (int32_t)scr->width - 1;
|
||||
if (s_mouse_y < 0) s_mouse_y = 0;
|
||||
if (s_mouse_y >= (int32_t)scr->height) s_mouse_y = (int32_t)scr->height - 1;
|
||||
}
|
||||
/* Invert dy because PS/2 Y is positive upwards, display Y is downwards */
|
||||
mouse_move_relative(dx, -dy);
|
||||
|
||||
s_left_button = (flags & 0x01) != 0;
|
||||
s_right_button = (flags & 0x02) != 0;
|
||||
|
||||
/* Pass event to window compositor */
|
||||
/* Dispatch event to window compositor */
|
||||
compositor_handle_mouse(s_mouse_x, s_mouse_y, s_left_button, s_right_button);
|
||||
}
|
||||
}
|
||||
|
||||
static void mouse_callback(registers_t* regs) {
|
||||
(void)regs;
|
||||
uint8_t status = inb(MOUSE_PORT_STATUS);
|
||||
if (!(status & 0x01)) return; /* No data ready */
|
||||
|
||||
uint8_t b = inb(MOUSE_PORT_DATA);
|
||||
mouse_process_byte(b);
|
||||
}
|
||||
|
||||
/* Polling fallback for systems where IRQ 12 is intercepted by UEFI EC */
|
||||
void mouse_poll(void) {
|
||||
uint32_t guard = 16;
|
||||
while ((inb(MOUSE_PORT_STATUS) & 0x01) && guard-- > 0) {
|
||||
uint8_t b = inb(MOUSE_PORT_DATA);
|
||||
mouse_process_byte(b);
|
||||
}
|
||||
}
|
||||
|
||||
void mouse_init(void) {
|
||||
/* Step 1: Enable auxiliary mouse device on PS/2 controller */
|
||||
mouse_wait_input();
|
||||
|
||||
Reference in new issue
Block a user