feat(kernel): Add USB devicde and keyboard/mouse support

This commit is contained in:
2026-02-19 23:06:18 +01:00
parent 9ca51596ea
commit 5810306e14
21 changed files with 2377 additions and 24 deletions
+6
View File
@@ -291,4 +291,10 @@ namespace Drivers::PS2::Keyboard {
return g_Modifiers;
}
void InjectKeyEvent(const KeyEvent& event) {
g_BufferLock.Acquire();
BufferPush(event);
g_BufferLock.Release();
}
};
+3
View File
@@ -49,4 +49,7 @@ namespace Drivers::PS2::Keyboard {
// Modifier state query
const ModifierState& GetModifiers();
// Inject a key event from an external source (e.g., USB HID keyboard)
void InjectKeyEvent(const KeyEvent& event);
};
+17
View File
@@ -196,4 +196,21 @@ namespace Drivers::PS2::Mouse {
g_MaxY = maxY;
}
void InjectMouseReport(uint8_t buttons, int8_t deltaX, int8_t deltaY, int8_t scroll) {
g_StateLock.Acquire();
g_State.X += (int32_t)deltaX;
g_State.Y += (int32_t)deltaY;
g_State.Buttons = buttons;
g_State.ScrollDelta = (int32_t)scroll;
// Clamp to screen bounds
if (g_State.X < 0) g_State.X = 0;
if (g_State.Y < 0) g_State.Y = 0;
if (g_State.X > g_MaxX) g_State.X = g_MaxX;
if (g_State.Y > g_MaxY) g_State.Y = g_MaxY;
g_StateLock.Release();
}
};
+3
View File
@@ -34,4 +34,7 @@ namespace Drivers::PS2::Mouse {
void SetBounds(int32_t maxX, int32_t maxY);
// Inject a mouse report from an external source (e.g., USB HID mouse)
void InjectMouseReport(uint8_t buttons, int8_t deltaX, int8_t deltaY, int8_t scroll);
};