Skip to main content

Module mouse

Module mouse 

Source
Expand description

PS/2 Mouse driver (IRQ12)

Supports standard 3-byte PS/2 mouse and IntelliMouse (4-byte, scroll wheel). Initialization follows the standard PS/2 controller protocol via I/O ports 0x60 (data) and 0x64 (command/status).

Structsยง

EventBuffer ๐Ÿ”’
MouseEvent
A decoded mouse event.

Constantsยง

CMD_ENABLE_AUX ๐Ÿ”’
CMD_READ_CFG ๐Ÿ”’
CMD_SEND_TO_MOUSE ๐Ÿ”’
CMD_WRITE_CFG ๐Ÿ”’
EVENT_BUF_SIZE ๐Ÿ”’
MOUSE_ACK ๐Ÿ”’
MOUSE_ENABLE_STREAM ๐Ÿ”’
MOUSE_GET_ID ๐Ÿ”’
MOUSE_RESET ๐Ÿ”’
MOUSE_SET_DEFAULTS ๐Ÿ”’
MOUSE_SET_SAMPLE_RATE ๐Ÿ”’
PS2_CMD ๐Ÿ”’
PS2_DATA ๐Ÿ”’
STATUS_INPUT_FULL ๐Ÿ”’
STATUS_OUTPUT_FULL ๐Ÿ”’

Staticsยง

EVENT_BUF ๐Ÿ”’
INTELLIMOUSE ๐Ÿ”’
Whether IntelliMouse (4-byte) mode is active
MOUSE_ABS_X ๐Ÿ”’
MOUSE_ABS_Y ๐Ÿ”’
MOUSE_CYCLE ๐Ÿ”’
Current byte index within the current packet (0, 1, 2, [3])
MOUSE_READY
Mouse is initialized and streaming
PACKET_BUF ๐Ÿ”’
SCREEN_H ๐Ÿ”’
SCREEN_W ๐Ÿ”’

Functionsยง

decode_packet ๐Ÿ”’
Decode the current packet buffer and push a MouseEvent.
flush_output ๐Ÿ”’
Drain any pending bytes in the PS/2 output buffer.
handle_irq
Called from the IDT IRQ12 handler (interrupt context, interrupts disabled).
has_event
Returns true if at least one mouse event is pending.
init
Initialize the PS/2 mouse.
mouse_cmd ๐Ÿ”’
Send a command to the mouse and wait for ACK. Returns true on success.
mouse_cmd_arg ๐Ÿ”’
Send a command + argument to the mouse and wait for ACK.
mouse_pos
Returns the current accumulated mouse position (pixel coordinates).
mouse_write ๐Ÿ”’
Send a byte directly to the mouse (via the 0xD4 mux).
ps2_read ๐Ÿ”’
Read a byte from the PS/2 data port (waits for data).
ps2_write_cmd ๐Ÿ”’
Write a byte to the PS/2 command port.
ps2_write_data ๐Ÿ”’
Write a byte to the PS/2 data port.
push_event_from_hid
Push a mouse event from USB HID or other non-PS/2 source.
read_event
Dequeue the oldest mouse event (non-blocking).
try_enable_intellimouse ๐Ÿ”’
Try activating IntelliMouse scroll wheel mode. Returns true if the mouse identifies as IntelliMouse (ID = 0x03).
wait_read ๐Ÿ”’
Spin until the PS/2 output buffer has data (safe to read).
wait_write ๐Ÿ”’
Spin until the PS/2 input buffer is empty (safe to write).