Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# .github/workflows/main.yml
name: VoidFrame kernel build

on:
push:
branches: [ main, dev ]
pull_request:
branches: [ main ]
release:
types: [created]

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive

- name: Setup build environment
run: |
sudo apt-get update
sudo apt-get install -y \
meson \
nasm \
xorriso \
grub-pc-bin \
grub-common \
mtools \
qemu-system-x86 \
llvm \

- name: Compile & Link
run: |
meson setup build
ninja -C build

- name: Test
run: |
timeout 30s ninja -C build run || true

ls -la build/voidframe.krnl
test -s build/voidframe.krnl

# Check if ISO was created
ls -la build/VoidFrame.iso
test -s build/VoidFrame.iso

- name: Upload kernel artifacts
uses: actions/upload-artifact@v4
with:
name: voidframe-build-${{ github.sha }}
path: |
build/voidframe.krnl
build/VoidFrame.iso
retention-days: 30
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ Makefile
CMakeLists.txt
*build*
target
.venv
.venv
*cache*
63 changes: 45 additions & 18 deletions drivers/PS2.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "Io.h"
#include "PS2.h"
#include "Io.h"
#include "Vesa.h"

// Keyboard buffer (unchanged)
static volatile char input_buffer[256];
Expand Down Expand Up @@ -160,10 +161,15 @@ void KeyboardHandler(void) {
c = c - 'A' + 1;
}

if (c && buffer_count < 255) {
input_buffer[buffer_tail] = c;
buffer_tail = (buffer_tail + 1) % 256;
buffer_count++;
if (c) {
if (OnKeyPress) {
OnKeyPress(c);
}
if (buffer_count < 255) {
input_buffer[buffer_tail] = c;
buffer_tail = (buffer_tail + 1) % 256;
buffer_count++;
}
}
}

Expand Down Expand Up @@ -202,23 +208,44 @@ void MouseHandler(void) {
delta_y = (delta_y == 0) ? 0 : (delta_y | 0xFFFFFF00);
}

// Y axis is inverted in PS2 mouse
delta_y = -delta_y;
// Store previous button state to detect changes
uint8_t old_buttons = mouse.buttons;

// Update position
mouse.delta_x = delta_x;
mouse.delta_y = delta_y;
// Update state
mouse.x += delta_x;
mouse.y += delta_y;
mouse.y -= delta_y;
mouse.delta_x = delta_x;
mouse.delta_y = -delta_y;
mouse.buttons = flags & 0x07;

// Clamp position to screen resolution
vbe_info_t* vbe = VBEGetInfo();
if (vbe) {
if (mouse.x < 0) mouse.x = 0;
if (mouse.y < 0) mouse.y = 0;
if (mouse.x >= (int)vbe->width) mouse.x = vbe->width - 1;
if (mouse.y >= (int)vbe->height) mouse.y = vbe->height - 1;
}

// Update button state
mouse.buttons = flags & 0x07; // Lower 3 bits are button states
// --- Fire Events ---
if (OnMouseMove) {
OnMouseMove(mouse.x, mouse.y, mouse.delta_x, mouse.delta_y);
}

// Clamp position to reasonable bounds (you can adjust these)
if (mouse.x < 0) mouse.x = 0;
if (mouse.y < 0) mouse.y = 0;
if (mouse.x > 1023) mouse.x = 1023; // Adjust for your screen resolution
if (mouse.y > 767) mouse.y = 767;
// Check for button presses/releases
uint8_t changed_buttons = mouse.buttons ^ old_buttons;
if (changed_buttons) {
for (int i = 0; i < 3; i++) {
uint8_t mask = 1 << i;
if (changed_buttons & mask) {
if ((mouse.buttons & mask) && OnMouseButtonDown) {
OnMouseButtonDown(mouse.x, mouse.y, i + 1);
} else if (OnMouseButtonUp) {
OnMouseButtonUp(mouse.x, mouse.y, i + 1);
}
}
}
}
}

mouse.packet_index = 0;
Expand Down
9 changes: 9 additions & 0 deletions drivers/PS2.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
#include "stdint.h"

#ifndef PS2_H
#define PS2_H

// --- Event Handler Function Pointers ---
// These are weak symbols that can be overridden by the window manager.
void __attribute__((weak)) OnKeyPress(char c);
void __attribute__((weak)) OnMouseMove(int x, int y, int dx, int dy);
void __attribute__((weak)) OnMouseButtonDown(int x, int y, uint8_t button);
void __attribute__((weak)) OnMouseButtonUp(int x, int y, uint8_t button);

#define KEYBOARD_DATA_PORT 0x60
#define KEYBOARD_STATUS_PORT 0x64

Expand Down
3 changes: 1 addition & 2 deletions drivers/Vesa.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#include "Vesa.h"

#include "Font.h"
#include "../mm/MemOps.h"
#include "Cpu.h"
#include "Font.h"
#include "Multiboot2.h"
#include "Serial.h"
#include "stdint.h"
Expand Down
Loading