driver.hid.mouse¶
Mouse event abstraction, state tracking, and hook dispatch.
Overview¶
This unit provides a hardware-independent mouse interface. Lower-level mouse drivers (PS/2, USB HID) call the event functions here after decoding raw packet data. This unit maintains global cursor position, button state, and scroll accumulator, clamping coordinates to the framebuffer dimensions. Up to 8 hooks can be registered to receive mouse events.
Dependencies¶
driver.video(forfrontBufferWidth/frontBufferHeightclamping bounds)
Types¶
TMouseEventType¶
Enumeration of mouse event types:
| Value | Description |
|---|---|
MOVE |
Cursor position changed |
LMB_DOWN |
Left button pressed |
LMB_UP |
Left button released |
LMB_CLICK |
Left button clicked (down then up) |
RMB_DOWN |
Right button pressed |
RMB_UP |
Right button released |
RMB_CLICK |
Right button clicked |
Functions and Procedures¶
registerMouseHook¶
Adds a callback to the hook list (up to 8 hooks). The callback receives the event type, current X/Y position, and scroll delta.removeMouseHook¶
Removes a previously registered hook callback.setMousePos¶
Sets the cursor position, clamping to[0, frontBufferWidth-1] and [0, frontBufferHeight-1].
getMouseScroll¶
Returns the accumulated scroll wheel delta since the last call and resets the accumulator to zero.fireMouseEvent¶
Updates internal state (position, button flags, scroll accumulator) for the given event type and dispatches to all registered hooks.Notes¶
MouseX,MouseY,MouseLMB,MouseRMB, andScrollAccumare module-level globals accessible directly for polling-style consumers.- Coordinate clamping relies on
driver.video.frontBufferWidthanddriver.video.frontBufferHeight, so those must be valid before mouse events are processed.