mini-arcade-native-backend 0.3.5__cp39-cp39-win_amd64.whl → 0.4.1__cp39-cp39-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -53,6 +53,12 @@ _NATIVE_TO_CORE = {
53
53
  native.EventType.Quit: EventType.QUIT,
54
54
  native.EventType.KeyDown: EventType.KEYDOWN,
55
55
  native.EventType.KeyUp: EventType.KEYUP,
56
+ native.EventType.MouseMotion: EventType.MOUSEMOTION,
57
+ native.EventType.MouseButtonDown: EventType.MOUSEBUTTONDOWN,
58
+ native.EventType.MouseButtonUp: EventType.MOUSEBUTTONUP,
59
+ native.EventType.MouseWheel: EventType.MOUSEWHEEL,
60
+ native.EventType.WindowResized: EventType.WINDOWRESIZED,
61
+ native.EventType.TextInput: EventType.TEXTINPUT,
56
62
  }
57
63
 
58
64
 
@@ -70,6 +76,7 @@ class NativeBackend(Backend):
70
76
  self._engine = native.Engine()
71
77
  self._font_path = font_path
72
78
  self._font_size = font_size
79
+ self._default_font_id: int | None = None
73
80
 
74
81
  def init(self, width: int, height: int, title: str):
75
82
  """
@@ -88,7 +95,9 @@ class NativeBackend(Backend):
88
95
 
89
96
  # Load font if provided
90
97
  if self._font_path is not None:
91
- self._engine.load_font(self._font_path, self._font_size)
98
+ self._default_font_id = self._engine.load_font(
99
+ self._font_path, self._font_size
100
+ )
92
101
 
93
102
  def set_clear_color(self, r: int, g: int, b: int):
94
103
  """
@@ -105,6 +114,8 @@ class NativeBackend(Backend):
105
114
  """
106
115
  self._engine.set_clear_color(int(r), int(g), int(b))
107
116
 
117
+ # Justification: Many local variables needed for event mapping
118
+ # pylint: disable=too-many-locals
108
119
  def poll_events(self) -> list[Event]:
109
120
  """
110
121
  Poll for events from the backend and return them as a list of Event objects.
@@ -112,12 +123,54 @@ class NativeBackend(Backend):
112
123
  :return: List of Event objects representing the polled events.
113
124
  :rtype: list[Event]
114
125
  """
115
- events: list[Event] = []
126
+ out: list[Event] = []
116
127
  for ev in self._engine.poll_events():
117
- core_type = _NATIVE_TO_CORE.get(ev.type, EventType.UNKNOWN)
128
+ etype = _NATIVE_TO_CORE.get(ev.type, EventType.UNKNOWN)
129
+
130
+ # "0 means not present" convention from C++ side
118
131
  key = ev.key if getattr(ev, "key", 0) != 0 else None
119
- events.append(Event(type=core_type, key=key))
120
- return events
132
+
133
+ x = getattr(ev, "x", 0) or None
134
+ y = getattr(ev, "y", 0) or None
135
+ dx = getattr(ev, "dx", 0) or None
136
+ dy = getattr(ev, "dy", 0) or None
137
+ button = getattr(ev, "button", 0) or None
138
+
139
+ wheel_x = getattr(ev, "wheel_x", 0)
140
+ wheel_y = getattr(ev, "wheel_y", 0)
141
+ wheel = (wheel_x, wheel_y) if (wheel_x or wheel_y) else None
142
+
143
+ w = getattr(ev, "width", 0)
144
+ h = getattr(ev, "height", 0)
145
+ size = (w, h) if (w and h) else None
146
+
147
+ text = getattr(ev, "text", "") or None
148
+
149
+ scancode = getattr(ev, "scancode", 0) or None
150
+ mod = getattr(ev, "mod", 0) or None
151
+ repeat_raw = getattr(ev, "repeat", 0)
152
+ repeat = bool(repeat_raw) if repeat_raw else None
153
+
154
+ out.append(
155
+ Event(
156
+ type=etype,
157
+ key=key,
158
+ x=x,
159
+ y=y,
160
+ dx=dx,
161
+ dy=dy,
162
+ button=button,
163
+ wheel=wheel,
164
+ size=size,
165
+ text=text,
166
+ scancode=scancode,
167
+ mod=mod,
168
+ repeat=repeat,
169
+ )
170
+ )
171
+ return out
172
+
173
+ # pylint: enable=too-many-locals
121
174
 
122
175
  def begin_frame(self):
123
176
  """Begin a new frame for rendering."""
@@ -192,7 +245,10 @@ class NativeBackend(Backend):
192
245
  """
193
246
  # We rely on C++ side to no-op if font is missing
194
247
  r, g, b = color
195
- self._engine.draw_text(text, x, y, int(r), int(g), int(b))
248
+ font_id = (
249
+ self._default_font_id if self._default_font_id is not None else -1
250
+ )
251
+ self._engine.draw_text(text, x, y, int(r), int(g), int(b), font_id)
196
252
 
197
253
  def capture_frame(self, path: str | None = None) -> bool:
198
254
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: mini-arcade-native-backend
3
- Version: 0.3.5
3
+ Version: 0.4.1
4
4
  Summary: Native SDL2 backend for mini-arcade-core using SDL2 + pybind11.
5
5
  Author-Email: Santiago Rincon <rincores@gmail.com>
6
6
  License: Copyright (c) 2025 Santiago Rincón
@@ -24,7 +24,7 @@ License: Copyright (c) 2025 Santiago Rincón
24
24
  SOFTWARE.
25
25
 
26
26
  Requires-Python: <3.12,>=3.9
27
- Requires-Dist: mini-arcade-core>=0.2.3
27
+ Requires-Dist: mini-arcade-core~=0.9
28
28
  Provides-Extra: dev
29
29
  Requires-Dist: pytest~=8.3; extra == "dev"
30
30
  Requires-Dist: pytest-cov~=6.0; extra == "dev"
@@ -0,0 +1,6 @@
1
+ mini_arcade_native_backend/__init__.py,sha256=CISb6F09IyBc8xg5gEoiG5hUgBjCSOtkw-4SNNzQMLM,8699
2
+ mini_arcade_native_backend/_native.cp39-win_amd64.pyd,sha256=d8dOv39HS3sVcnm88kT8fCW0dlwWGi3OMrZICt6nikE,224768
3
+ mini_arcade_native_backend-0.4.1.dist-info/METADATA,sha256=Ar02qqV_fKEgajUC3fF4DNOU2_xhRf8ZqiaNEDukyN8,10517
4
+ mini_arcade_native_backend-0.4.1.dist-info/WHEEL,sha256=9tsL4JT94eZPTkcS3bNng2riasYJMxXndrO9CxUfJHs,104
5
+ mini_arcade_native_backend-0.4.1.dist-info/licenses/LICENSE,sha256=cZRgTdRJ3YASekMxkGAvylB2nROh4ov228DxAogK3yY,1115
6
+ mini_arcade_native_backend-0.4.1.dist-info/RECORD,,
@@ -1,6 +0,0 @@
1
- mini_arcade_native_backend/__init__.py,sha256=QmgzE3psHKW59_vp-ZCS7CPe53YhoXqEJCjrdaQckGY,6648
2
- mini_arcade_native_backend/_native.cp39-win_amd64.pyd,sha256=RMqI6WAxeYxzgG2onKlGIlWFYWlr6lBtg6Tn_FJsyyQ,219648
3
- mini_arcade_native_backend-0.3.5.dist-info/METADATA,sha256=A3gIz5wFRc8fQi_Ks-t0Dbqn-7JdbAzVzU99rq_2niQ,10519
4
- mini_arcade_native_backend-0.3.5.dist-info/WHEEL,sha256=9tsL4JT94eZPTkcS3bNng2riasYJMxXndrO9CxUfJHs,104
5
- mini_arcade_native_backend-0.3.5.dist-info/licenses/LICENSE,sha256=cZRgTdRJ3YASekMxkGAvylB2nROh4ov228DxAogK3yY,1115
6
- mini_arcade_native_backend-0.3.5.dist-info/RECORD,,