mouse: clamp the pointer to the screen that exists, not to 800x600

kernel/dev/mouse.c held the pointer inside literal 800x600 bounds. That
was correct while 800x600 was the only mode the loader could set, which
it was until the resolution became a boot-time choice. At 1280x800 the
pointer simply stopped two thirds of the way across and would not go
further -- which reads as the cursor drifting away from the host's rather
than as a clamp.

vga.c grows vga_get_width/vga_get_height for it. The mode is chosen at
boot now, so nothing above the framebuffer may hardcode its size, and
these are the first two callers that needed to ask.

Verified that the system still builds and boots at 1280x800, and that
bootcheck is 108 [ok] and schcom-test passes. I did not manage to
photograph the pointer past the old limit in the time available -- there
is no reader for /dev/mouse in the image and the screendump attempt did
not resolve, so the fix rests on inspection rather than on a picture.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Nexoniarz 2026-08-10 05:46:12 +02:00
commit eafdddefbc
3 changed files with 30 additions and 2 deletions

View file

@ -66,10 +66,20 @@ mouse_move_locked(int dx, int dy)
mouse_state.x += dx;
mouse_state.y += dy;
// Clamp to the screen that actually exists. These were the literals 800 and
// 600, which was correct while that was the only mode the loader could set.
// It is a boot-time choice now (press R), and at 1280x800 the pointer simply
// stopped two thirds of the way across -- which reads as the cursor drifting
// away from the host's, rather than as a clamp.
int maxx = (int)vga_get_width();
int maxy = (int)vga_get_height();
if(maxx <= 0) maxx = 800;
if(maxy <= 0) maxy = 600;
if(mouse_state.x < 0) mouse_state.x = 0;
if(mouse_state.y < 0) mouse_state.y = 0;
if(mouse_state.x >= 800) mouse_state.x = 799;
if(mouse_state.y >= 600) mouse_state.y = 599;
if(mouse_state.x >= maxx) mouse_state.x = maxx - 1;
if(mouse_state.y >= maxy) mouse_state.y = maxy - 1;
}
// The same pointer, moved by something that is not the PS/2 port. USB HID