Skip to content

mouse

FreeBodyEngine.core.mouse #

Mouse() #

Bases: Service

Base mouse service - tracks cursor position, button state, dragging, and double-clicks. Each window backend (GLFW/X11/Wayland) provides a concrete subclass implementing the abstract methods below.

Sets up default cursor/drag/button-state tracking.

double_click_threshold = 0.4 instance-attribute #

drag_start = Vector() instance-attribute #

position = Vector() instance-attribute #

world_position = Vector() instance-attribute #

get_double_click(button) #

Returns whether button was double-clicked this frame (two presses within double_click_threshold seconds).

get_down(button) #

Returns whether button is currently held down.

get_drag_offset(button, world=False) #

Returns how far the cursor has moved since button's drag started, in world or screen space depending on world.

get_drag_start(button, world=False) #

Returns the position button's current drag started at, in world or screen space depending on world.

get_dragging(button) #

Returns whether button is currently being dragged.

get_pressed(button) #

Returns whether button was pressed down this frame.

get_released(button) #

Returns whether button was released this frame.

get_scroll_delta() #

Returns how far the scroll wheel moved this frame (x = horizontal, y = vertical - positive y is scrolling up). Concrete default of Vector(0, 0) (no scrolling) for backends that don't report a wheel yet; GLFWMouse and WaylandMouse override this with real values.

hide_cursor() #

Hides the system cursor. Concrete no-op (with a one-time warning) for backends that haven't implemented real cursor control yet - see WaylandMouse/GLFWMouse for the backends that actually do.

lock_position() #

Locks the cursor position on screen, stoping it from moving while still getting movement information.

on_destroy() #

Unregisters update() from the EARLY update phase.

on_initialize() #

Registers update() to run every frame's EARLY phase.

set_cursor(shape='default') #

Sets the system cursor's shape - one of "default", "pointer", "text", "grab", "grabbing", "crosshair", "wait", "not_allowed" (backends may support more; unsupported names fall back to "default"). Concrete no-op (with a one-time warning) for backends that haven't implemented real cursor control yet - see WaylandMouse/GLFWMouse for the backends that actually do.

unlock_position() #

Releases a cursor lock previously set by lock_position(), letting the cursor move freely again.

update() #

Polls the window backend for the current cursor position and button state, refreshing this frame's press/release/drag/double-click tracking.