simvx.graphics.platform._sdl3¶
SDL3 windowing backend with multitouch support.
Module Contents¶
Classes¶
WindowBackend implementation using SDL3. |
Data¶
API¶
- simvx.graphics.platform._sdl3.__all__¶
[‘Sdl3Backend’]
- simvx.graphics.platform._sdl3.log¶
‘getLogger(…)’
- class simvx.graphics.platform._sdl3.Sdl3Backend¶
WindowBackend implementation using SDL3.
Provides keyboard, mouse, and multitouch input. Touch events are delivered with window-relative coordinates via the touch_callback.
Initialization
- supports_gamepads¶
True
- create_window(width: int, height: int, title: str, *, visible: bool = True) None¶
- create_graphics_surface(instance: Any) Any¶
- get_required_instance_extensions() list[str]¶
- poll_events() None¶
- should_close() bool¶
- get_framebuffer_size() tuple[int, int]¶
- get_window_size() tuple[int, int]¶
- get_content_scale() tuple[float, float]¶
- set_title(title: str) None¶
- set_key_callback(callback: collections.abc.Callable[[int, int, int], None] | None) None¶
- set_mouse_button_callback(callback: collections.abc.Callable[[int, int, int], None] | None) None¶
- set_cursor_pos_callback(callback: collections.abc.Callable[[float, float], None] | None) None¶
- set_scroll_callback(callback: collections.abc.Callable[[float, float], None] | None) None¶
- set_char_callback(callback: collections.abc.Callable[[int], None] | None) None¶
- set_resize_callback(callback: collections.abc.Callable[[int, int], None] | None) None¶
- property paused: bool¶
Whether the app is paused (backgrounded on mobile).
- set_lifecycle_callback(callback: collections.abc.Callable[[str], None] | None) None¶
Set lifecycle event callback. Receives ‘paused’ or ‘resumed’.
- set_touch_callback(callback: collections.abc.Callable[[int, int, float, float, float], None] | None) None¶
Set touch event callback.
Args: callback: (finger_id, action, x, y, pressure) where action is 0=down, 1=up, 2=move. x,y are in window pixel coordinates.
- get_cursor_pos() tuple[float, float]¶
- set_cursor_shape(shape: int) None¶
Set cursor shape. 0=arrow, 1=ibeam, 2=crosshair, 3=hand, 4=hresize, 5=vresize.
- set_mouse_capture(mode: int) None¶
Apply a MouseCaptureMode int (0=visible, 1=hidden, 2=captured, 3=confined) to the OS cursor.
Each SDL symbol is guarded with getattr: the sdl3 binding may not expose all of them, in which case the call is skipped (debug-logged) rather than crashing.
Under CAPTURED, relative mode is enabled and poll_events integrates the per-event xrel/yrel into a virtual cursor position (
self._relative), so the shared delta path tracks motion while the OS cursor is locked.
- set_window_size(width: int, height: int) None¶
- request_close() None¶
- poll_gamepads() list[tuple[int, dict[str, bool], dict[str, float]]]¶
Poll all connected gamepads. Returns list of (id, buttons, axes).
Each pad is opened once and its handle held until the pad goes away or the window is destroyed. Opening and closing per poll would make SDL generate a connect and a disconnect event every frame and throw both away, and it costs a device open sixty times a second per controller.
SDL reports sticks as signed 16-bit and triggers as
0..32767;- Func:
gamepad.normalise_axesmaps both onto the engine’s convention.
- destroy() None¶