simvx.graphics.platform._base¶
Window backend protocol: duck-typing friendly contract.
Module Contents¶
Classes¶
A key going down, coming up or repeating: |
|
A mouse button, down or up: |
|
Motion of the mouse cursor, in logical (screen) pixels. |
|
A scroll offset, in notches. |
|
One typed character, after the layout and the IME have had their say. |
|
A finger pressing, moving, lifting or cancelled: |
|
One pen sample: |
|
What a poll knows about the pad beyond what it is doing. |
|
Protocol that all windowing backends must satisfy. |
Data¶
API¶
- simvx.graphics.platform._base.log¶
‘getLogger(…)’
- simvx.graphics.platform._base.__all__¶
[‘CharCallback’, ‘CursorPosCallback’, ‘KeyCallback’, ‘MouseButtonCallback’, ‘PenCallback’, ‘PadFacts…
- class simvx.graphics.platform._base.KeyCallback¶
Bases:
typing.ProtocolA key going down, coming up or repeating:
(key, action, mods).- __call__(key: int, action: int, mods: int, *, time: float | None = None, label: str | None = None, device_id: int = 0) None¶
- __slots__¶
()
- classmethod __init_subclass__(*args, **kwargs)¶
- classmethod __class_getitem__(item)¶
- class simvx.graphics.platform._base.MouseButtonCallback¶
Bases:
typing.ProtocolA mouse button, down or up:
(button, action, mods).The mouse only. A pen and a finger are pointers of their own and have their own callbacks; a mouse event the platform synthesised from either is dropped by the backend, or every tap would arrive twice.
- __call__(button: int, action: int, mods: int, *, time: float | None = None, device_id: int = 0) None¶
- __slots__¶
()
- classmethod __init_subclass__(*args, **kwargs)¶
- classmethod __class_getitem__(item)¶
- class simvx.graphics.platform._base.CursorPosCallback¶
Bases:
typing.ProtocolMotion of the mouse cursor, in logical (screen) pixels.
- __call__(x: float, y: float, *, time: float | None = None) None¶
- __slots__¶
()
- classmethod __init_subclass__(*args, **kwargs)¶
- classmethod __class_getitem__(item)¶
- class simvx.graphics.platform._base.ScrollCallback¶
Bases:
typing.ProtocolA scroll offset, in notches.
- __call__(x_offset: float, y_offset: float, *, time: float | None = None) None¶
- __slots__¶
()
- classmethod __init_subclass__(*args, **kwargs)¶
- classmethod __class_getitem__(item)¶
- class simvx.graphics.platform._base.CharCallback¶
Bases:
typing.ProtocolOne typed character, after the layout and the IME have had their say.
- __call__(codepoint: int, *, time: float | None = None) None¶
- __slots__¶
()
- classmethod __init_subclass__(*args, **kwargs)¶
- classmethod __class_getitem__(item)¶
- class simvx.graphics.platform._base.TouchCallback¶
Bases:
typing.ProtocolA finger pressing, moving, lifting or cancelled:
(finger_id, phase, x, y, pressure).pressureis None on a screen that cannot measure it, andcontact_sizethe contact’s width and height where the platform reports it. ACANCELis the system taking the finger away mid-gesture.- __call__(finger_id: int, phase: simvx.core.input.enums.PointerPhase, x: float, y: float, pressure: float | None, *, contact_size: tuple[float, float] | None = None, time: float | None = None, device_id: int = 0) None¶
- __slots__¶
()
- classmethod __init_subclass__(*args, **kwargs)¶
- classmethod __class_getitem__(item)¶
- class simvx.graphics.platform._base.PenCallback¶
Bases:
typing.ProtocolOne pen sample:
(pen_id, phase, x, y)and whatever the tablet measured.ENTERandLEAVEbracket the pen’s time in range,MOVEwith nothing pressed is the pen hovering, andDOWNandUPwith button 0 are the tip touching and lifting; a barrel button is its own index, the first barrel 1, as SDL3 and Qt number them. Tilt and twist are radians. An axis the tablet does not measure is None, and the eraser end is atool, never a button.- __call__(pen_id: int, phase: simvx.core.input.enums.PointerPhase, x: float, y: float, *, button: int = 0, pressure: float | None = None, tilt: tuple[float, float] | None = None, twist: float | None = None, distance: float | None = None, tangential_pressure: float | None = None, tool: simvx.core.input.enums.PointerTool = PointerTool.TIP, tool_id: int = 0, time: float | None = None, device_id: int = 0) None¶
- __slots__¶
()
- classmethod __init_subclass__(*args, **kwargs)¶
- classmethod __class_getitem__(item)¶
- class simvx.graphics.platform._base.PadFacts¶
Bases:
typing.TypedDictWhat a poll knows about the pad beyond what it is doing.
The keyword half of one pad’s entry in :meth:
WindowBackend.poll_controllers, splatted into the state layer’sreport(...), and the same bargain the event callbacks strike above: a backend states what its library told it and leaves out what it does not know. Every key is therefore optional, and absent means “this backend cannot say” rather than “empty” – a name left out keeps the name the pad already had, where a name of""would erase it.Attributes: name: What the driver calls the pad, which decides its family. guid: The pad’s stable device id: the same string for the same model of controller on the next run and in the next port, which is what a saved rebinding keys on. A backend with no concept of one leaves it out; it never invents one from a runtime index, because an index is the order the pads were plugged in. recognised: Whether the engine’s standard button and axis names mean what they say on this pad. Left out on a backend that only ever enumerates pads it has a layout for, since the enumeration already proves it. raw_buttons: The driver’s own button indices, for a device the engine cannot lay out and for a rebind screen recording whatever the player pressed. raw_axes: The driver’s own axis indices.
Initialization
Initialize self. See help(type(self)) for accurate signature.
- name: str¶
None
- guid: str¶
None
- recognised: bool¶
None
- raw_buttons: dict[int, bool]¶
None
- raw_axes: dict[int, float]¶
None
- __contains__()¶
- __delattr__()¶
- __delitem__()¶
- __dir__()¶
- __eq__()¶
- __format__()¶
- __ge__()¶
- __getattribute__()¶
- __getitem__()¶
- __getstate__()¶
- __gt__()¶
- __ior__()¶
- __iter__()¶
- __le__()¶
- __len__()¶
- __lt__()¶
- __ne__()¶
- __new__()¶
- __or__()¶
- __reduce__()¶
- __reduce_ex__()¶
- __repr__()¶
- __reversed__()¶
- __ror__()¶
- __setattr__()¶
- __setitem__()¶
- __sizeof__()¶
- __str__()¶
- __subclasshook__()¶
- clear()¶
- copy()¶
- get()¶
- items()¶
- keys()¶
- pop()¶
- popitem()¶
- setdefault()¶
- update()¶
- values()¶
- class simvx.graphics.platform._base.WindowBackend¶
Bases:
typing.ProtocolProtocol that all windowing backends must satisfy.
- supports_controllers: bool¶
None
- supports_rumble: bool¶
None
- create_window(width: int, height: int, title: str, *, visible: bool = True) None¶
- set_window_size(width: int, height: int) None¶
- set_title(title: str) 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_key_callback(callback: simvx.graphics.platform._base.KeyCallback | None) None¶
- set_mouse_button_callback(callback: simvx.graphics.platform._base.MouseButtonCallback | None) None¶
- set_cursor_pos_callback(callback: simvx.graphics.platform._base.CursorPosCallback | None) None¶
- set_char_callback(callback: simvx.graphics.platform._base.CharCallback | None) None¶
- set_scroll_callback(callback: simvx.graphics.platform._base.ScrollCallback | None) None¶
- set_resize_callback(callback: collections.abc.Callable[[int, int], None] | None) None¶
- set_focus_callback(callback: collections.abc.Callable[[bool], None] | None) None¶
Register the window focus callback, called with True on gain, False on loss.
The input layer needs the loss: a key or button held when focus moves away is released to whatever took it, so without this the engine goes on believing it is held.
- request_close() None¶
- get_cursor_pos() tuple[float, float]¶
- set_cursor_shape(shape: simvx.core.input.enums.CursorShape) None¶
- set_mouse_capture(mode: int) None¶
- destroy() None¶
- __slots__¶
()
- classmethod __init_subclass__(*args, **kwargs)¶
- classmethod __class_getitem__(item)¶