mini-arcade-native-backend 0.4.0__cp310-cp310-win_amd64.whl → 0.4.2__cp310-cp310-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.
@@ -37,6 +37,7 @@ if sys.platform == "win32":
37
37
  # Justification: Need to import core after setting DLL path on Windows
38
38
  # pylint: disable=wrong-import-position
39
39
  from mini_arcade_core import Backend, Event, EventType
40
+ from mini_arcade_core.keymaps.sdl import SDL_KEYCODE_TO_KEY
40
41
 
41
42
  # Justification: Importing the native extension module
42
43
  # pylint: disable=import-self,no-name-in-module
@@ -53,6 +54,12 @@ _NATIVE_TO_CORE = {
53
54
  native.EventType.Quit: EventType.QUIT,
54
55
  native.EventType.KeyDown: EventType.KEYDOWN,
55
56
  native.EventType.KeyUp: EventType.KEYUP,
57
+ native.EventType.MouseMotion: EventType.MOUSEMOTION,
58
+ native.EventType.MouseButtonDown: EventType.MOUSEBUTTONDOWN,
59
+ native.EventType.MouseButtonUp: EventType.MOUSEBUTTONUP,
60
+ native.EventType.MouseWheel: EventType.MOUSEWHEEL,
61
+ native.EventType.WindowResized: EventType.WINDOWRESIZED,
62
+ native.EventType.TextInput: EventType.TEXTINPUT,
56
63
  }
57
64
 
58
65
 
@@ -108,6 +115,8 @@ class NativeBackend(Backend):
108
115
  """
109
116
  self._engine.set_clear_color(int(r), int(g), int(b))
110
117
 
118
+ # Justification: Many local variables needed for event mapping
119
+ # pylint: disable=too-many-locals
111
120
  def poll_events(self) -> list[Event]:
112
121
  """
113
122
  Poll for events from the backend and return them as a list of Event objects.
@@ -115,12 +124,81 @@ class NativeBackend(Backend):
115
124
  :return: List of Event objects representing the polled events.
116
125
  :rtype: list[Event]
117
126
  """
118
- events: list[Event] = []
127
+ out: list[Event] = []
119
128
  for ev in self._engine.poll_events():
120
- core_type = _NATIVE_TO_CORE.get(ev.type, EventType.UNKNOWN)
121
- key = ev.key if getattr(ev, "key", 0) != 0 else None
122
- events.append(Event(type=core_type, key=key))
123
- return events
129
+ etype = _NATIVE_TO_CORE.get(ev.type, EventType.UNKNOWN)
130
+
131
+ key = None
132
+ key_code = None
133
+ scancode = None
134
+ mod = None
135
+ repeat = None
136
+
137
+ x = y = dx = dy = None
138
+ button = None
139
+ wheel = None
140
+ size = None
141
+ text = None
142
+
143
+ if etype in (EventType.KEYDOWN, EventType.KEYUP):
144
+ raw_key = int(getattr(ev, "key", 0) or 0)
145
+ key_code = raw_key if raw_key != 0 else None
146
+ key = SDL_KEYCODE_TO_KEY.get(raw_key) if raw_key != 0 else None
147
+
148
+ scancode = (
149
+ int(ev.scancode) if getattr(ev, "scancode", 0) else None
150
+ )
151
+ mod = int(ev.mod) if getattr(ev, "mod", 0) else None
152
+
153
+ rep = int(getattr(ev, "repeat", 0) or 0)
154
+ repeat = bool(rep) if etype == EventType.KEYDOWN else None
155
+
156
+ elif etype == EventType.MOUSEMOTION:
157
+ x = int(ev.x)
158
+ y = int(ev.y)
159
+ dx = int(ev.dx)
160
+ dy = int(ev.dy)
161
+
162
+ elif etype in (EventType.MOUSEBUTTONDOWN, EventType.MOUSEBUTTONUP):
163
+ button = int(ev.button) if ev.button else None
164
+ x = int(ev.x)
165
+ y = int(ev.y)
166
+
167
+ elif etype == EventType.MOUSEWHEEL:
168
+ wx = int(ev.wheel_x)
169
+ wy = int(ev.wheel_y)
170
+ wheel = (wx, wy) if (wx or wy) else None
171
+
172
+ elif etype == EventType.WINDOWRESIZED:
173
+ w = int(ev.width)
174
+ h = int(ev.height)
175
+ size = (w, h) if (w and h) else None
176
+
177
+ elif etype == EventType.TEXTINPUT:
178
+ t = getattr(ev, "text", "")
179
+ text = t if t else None
180
+
181
+ out.append(
182
+ Event(
183
+ type=etype,
184
+ key=key,
185
+ key_code=key_code,
186
+ scancode=scancode,
187
+ mod=mod,
188
+ repeat=repeat,
189
+ x=x,
190
+ y=y,
191
+ dx=dx,
192
+ dy=dy,
193
+ button=button,
194
+ wheel=wheel,
195
+ size=size,
196
+ text=text,
197
+ )
198
+ )
199
+ return out
200
+
201
+ # pylint: enable=too-many-locals
124
202
 
125
203
  def begin_frame(self):
126
204
  """Begin a new frame for rendering."""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: mini-arcade-native-backend
3
- Version: 0.4.0
3
+ Version: 0.4.2
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=R6N7QYH4Ez6mmZOtdJd3UcPqo4obAW9um7w9Hjsrv6o,9609
2
+ mini_arcade_native_backend/_native.cp310-win_amd64.pyd,sha256=1qDu9CQPieZR6065PjhDQUVV1JwhJtVnmwxBqcjG4L8,212480
3
+ mini_arcade_native_backend-0.4.2.dist-info/METADATA,sha256=9xVRtkbI96F7nljlKYgChuP6Au-z1jA6-pAhteCitOk,10517
4
+ mini_arcade_native_backend-0.4.2.dist-info/WHEEL,sha256=hrGeChGtn46HBGmzasO9QQDSLelRN-tUarBSv4gFcsI,106
5
+ mini_arcade_native_backend-0.4.2.dist-info/licenses/LICENSE,sha256=cZRgTdRJ3YASekMxkGAvylB2nROh4ov228DxAogK3yY,1115
6
+ mini_arcade_native_backend-0.4.2.dist-info/RECORD,,
@@ -1,6 +0,0 @@
1
- mini_arcade_native_backend/__init__.py,sha256=c5nVK2IazMmQs7-aWo4kAFW-JIN12gAs2blJWwgeHIk,6875
2
- mini_arcade_native_backend/_native.cp310-win_amd64.pyd,sha256=gBxv1AKBJJUd17muGioJFWsbJyyJ2KDIP_G0Wgo3v7I,208896
3
- mini_arcade_native_backend-0.4.0.dist-info/METADATA,sha256=Z8NcXEfzaLWgM3wRBflD7MlJv4HbsyYO_8A3tW3PfZg,10519
4
- mini_arcade_native_backend-0.4.0.dist-info/WHEEL,sha256=hrGeChGtn46HBGmzasO9QQDSLelRN-tUarBSv4gFcsI,106
5
- mini_arcade_native_backend-0.4.0.dist-info/licenses/LICENSE,sha256=cZRgTdRJ3YASekMxkGAvylB2nROh4ov228DxAogK3yY,1115
6
- mini_arcade_native_backend-0.4.0.dist-info/RECORD,,