-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Summary
Implement a unified input event system for GUI applications, abstracting keyboard and mouse events into a common event queue that can be consumed by the compositor and applications.
Background
The GUI needs a unified way to handle input from various devices (keyboard, mouse, future touch). Currently, PS/2 keyboard and mouse drivers generate raw input, but there's no abstraction layer for GUI consumption.
Goals
- Create abstract input event structures
- Implement event queue for GUI
- Integrate with existing PS/2 drivers (Implement semaphore synchronization primitive #37 keyboard, Implement PS/2 mouse driver and input support #143 mouse)
- Provide event dispatch to windows/applications
- Support keyboard focus and mouse grab semantics
Implementation
Input Event Structure
```c
enum event_type {
EVENT_KEY_PRESS,
EVENT_KEY_RELEASE,
EVENT_MOUSE_MOTION,
EVENT_MOUSE_BUTTON_PRESS,
EVENT_MOUSE_BUTTON_RELEASE,
EVENT_MOUSE_SCROLL
};
struct input_event {
uint64_t timestamp;
enum event_type type;
union {
struct {
uint32_t keycode;
uint32_t modifiers;
uint32_t unicode;
} key;
struct {
int32_t x, y;
int32_t dx, dy;
} motion;
struct {
uint32_t button;
int32_t x, y;
} button;
struct {
int32_t dx, dy;
} scroll;
};
};
```
Event Queue
```c
#define EVENT_QUEUE_SIZE 256
struct event_queue {
struct input_event events[EVENT_QUEUE_SIZE];
size_t head, tail;
struct mutex lock;
struct semaphore sem;
};
int event_queue_push(struct event_queue *q, struct input_event *evt);
int event_queue_pop(struct event_queue *q, struct input_event *evt);
```
Timeline
- Phase 1: Event structures and queue (1 week)
- Phase 2: PS/2 driver integration (1 week)
- Phase 3: Event dispatch to compositor (1 week)
- Phase 4: Testing and optimization (3-5 days)
Total: 4-5 weeks
Definition of Done
- Event structures defined
- Event queue implemented
- PS/2 keyboard integrated
- PS/2 mouse integrated
- Compositor can receive events
- Test programs demonstrate functionality
Dependencies
- Implement PS/2 mouse driver and input support #143: PS/2 Mouse Driver (CRITICAL BLOCKER)
- Implement semaphore synchronization primitive #37: PS/2 Keyboard (already complete)
Enables
- Compositor and window manager (all need input events)
See docs/road/road_to_gui.md for complete roadmap.