mini-arcade-native-backend 0.4.1__tar.gz → 0.4.2__tar.gz
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.
- {mini_arcade_native_backend-0.4.1 → mini_arcade_native_backend-0.4.2}/CHANGELOG.md +5 -0
- {mini_arcade_native_backend-0.4.1 → mini_arcade_native_backend-0.4.2}/PKG-INFO +1 -1
- {mini_arcade_native_backend-0.4.1 → mini_arcade_native_backend-0.4.2}/pyproject.toml +1 -1
- {mini_arcade_native_backend-0.4.1 → mini_arcade_native_backend-0.4.2}/src/mini_arcade_native_backend/__init__.py +49 -21
- {mini_arcade_native_backend-0.4.1 → mini_arcade_native_backend-0.4.2}/tests/test_init.py +11 -2
- {mini_arcade_native_backend-0.4.1 → mini_arcade_native_backend-0.4.2}/.github/workflows/ci.yml +0 -0
- {mini_arcade_native_backend-0.4.1 → mini_arcade_native_backend-0.4.2}/.github/workflows/create-release-branch.yml +0 -0
- {mini_arcade_native_backend-0.4.1 → mini_arcade_native_backend-0.4.2}/.github/workflows/release-finalize.yml +0 -0
- {mini_arcade_native_backend-0.4.1 → mini_arcade_native_backend-0.4.2}/.github/workflows/release-publish.yml +0 -0
- {mini_arcade_native_backend-0.4.1 → mini_arcade_native_backend-0.4.2}/.gitignore +0 -0
- {mini_arcade_native_backend-0.4.1 → mini_arcade_native_backend-0.4.2}/.vscode/settings.json +0 -0
- {mini_arcade_native_backend-0.4.1 → mini_arcade_native_backend-0.4.2}/CMakeLists.txt +0 -0
- {mini_arcade_native_backend-0.4.1 → mini_arcade_native_backend-0.4.2}/LICENSE +0 -0
- {mini_arcade_native_backend-0.4.1 → mini_arcade_native_backend-0.4.2}/README.md +0 -0
- {mini_arcade_native_backend-0.4.1 → mini_arcade_native_backend-0.4.2}/cpp/bindings.cpp +0 -0
- {mini_arcade_native_backend-0.4.1 → mini_arcade_native_backend-0.4.2}/cpp/engine.cpp +0 -0
- {mini_arcade_native_backend-0.4.1 → mini_arcade_native_backend-0.4.2}/cpp/engine.h +0 -0
- {mini_arcade_native_backend-0.4.1 → mini_arcade_native_backend-0.4.2}/examples/native_backend_demo.py +0 -0
- {mini_arcade_native_backend-0.4.1 → mini_arcade_native_backend-0.4.2}/poetry.lock +0 -0
- {mini_arcade_native_backend-0.4.1 → mini_arcade_native_backend-0.4.2}/poetry.toml +0 -0
|
@@ -8,7 +8,7 @@ build-backend = "scikit_build_core.build"
|
|
|
8
8
|
|
|
9
9
|
[project]
|
|
10
10
|
name = "mini-arcade-native-backend"
|
|
11
|
-
version = "0.4.
|
|
11
|
+
version = "0.4.2"
|
|
12
12
|
description = "Native SDL2 backend for mini-arcade-core using SDL2 + pybind11."
|
|
13
13
|
authors = [
|
|
14
14
|
{ name = "Santiago Rincon", email = "rincores@gmail.com" },
|
|
@@ -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
|
|
@@ -127,34 +128,64 @@ class NativeBackend(Backend):
|
|
|
127
128
|
for ev in self._engine.poll_events():
|
|
128
129
|
etype = _NATIVE_TO_CORE.get(ev.type, EventType.UNKNOWN)
|
|
129
130
|
|
|
130
|
-
|
|
131
|
-
|
|
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
|
|
132
155
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
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)
|
|
138
161
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
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)
|
|
142
166
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
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
|
|
146
171
|
|
|
147
|
-
|
|
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
|
|
148
176
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
repeat = bool(repeat_raw) if repeat_raw else None
|
|
177
|
+
elif etype == EventType.TEXTINPUT:
|
|
178
|
+
t = getattr(ev, "text", "")
|
|
179
|
+
text = t if t else None
|
|
153
180
|
|
|
154
181
|
out.append(
|
|
155
182
|
Event(
|
|
156
183
|
type=etype,
|
|
157
184
|
key=key,
|
|
185
|
+
key_code=key_code,
|
|
186
|
+
scancode=scancode,
|
|
187
|
+
mod=mod,
|
|
188
|
+
repeat=repeat,
|
|
158
189
|
x=x,
|
|
159
190
|
y=y,
|
|
160
191
|
dx=dx,
|
|
@@ -163,9 +194,6 @@ class NativeBackend(Backend):
|
|
|
163
194
|
wheel=wheel,
|
|
164
195
|
size=size,
|
|
165
196
|
text=text,
|
|
166
|
-
scancode=scancode,
|
|
167
|
-
mod=mod,
|
|
168
|
-
repeat=repeat,
|
|
169
197
|
)
|
|
170
198
|
)
|
|
171
199
|
return out
|
|
@@ -34,6 +34,7 @@ def setup_fake_core_and_native(monkeypatch):
|
|
|
34
34
|
class FakeEvent:
|
|
35
35
|
type: object
|
|
36
36
|
key: object = None
|
|
37
|
+
key_code: object = None
|
|
37
38
|
x: object = None
|
|
38
39
|
y: object = None
|
|
39
40
|
dx: object = None
|
|
@@ -52,6 +53,13 @@ def setup_fake_core_and_native(monkeypatch):
|
|
|
52
53
|
|
|
53
54
|
sys.modules["mini_arcade_core"] = fake_core
|
|
54
55
|
|
|
56
|
+
fake_keymaps = types.ModuleType("mini_arcade_core.keymaps")
|
|
57
|
+
fake_sdl = types.ModuleType("mini_arcade_core.keymaps.sdl")
|
|
58
|
+
fake_sdl.SDL_KEYCODE_TO_KEY = {} # or mapping your test expects
|
|
59
|
+
|
|
60
|
+
sys.modules["mini_arcade_core.keymaps"] = fake_keymaps
|
|
61
|
+
sys.modules["mini_arcade_core.keymaps.sdl"] = fake_sdl
|
|
62
|
+
|
|
55
63
|
# --- Fake native extension: mini_arcade_native_backend._native -------------
|
|
56
64
|
fake_native = types.ModuleType("mini_arcade_native_backend._native")
|
|
57
65
|
|
|
@@ -253,6 +261,7 @@ def test_poll_events_maps_native_events_to_core_events_and_keys(
|
|
|
253
261
|
class FakeNativeEvent:
|
|
254
262
|
type: object
|
|
255
263
|
key: int = 0
|
|
264
|
+
key_code: int = 0
|
|
256
265
|
x: int = 0
|
|
257
266
|
y: int = 0
|
|
258
267
|
dx: int = 0
|
|
@@ -298,7 +307,7 @@ def test_poll_events_maps_native_events_to_core_events_and_keys(
|
|
|
298
307
|
|
|
299
308
|
# KeyDown: key passes through
|
|
300
309
|
assert events[1].type == fake_core.EventType.KEYDOWN
|
|
301
|
-
assert events[1].
|
|
310
|
+
assert events[1].key_code == 32
|
|
302
311
|
|
|
303
312
|
# MouseMotion: x/y/dx/dy mapped (0 becomes None; here non-zero)
|
|
304
313
|
assert events[2].type == fake_core.EventType.MOUSEMOTION
|
|
@@ -327,4 +336,4 @@ def test_poll_events_maps_native_events_to_core_events_and_keys(
|
|
|
327
336
|
|
|
328
337
|
# Unknown
|
|
329
338
|
assert events[7].type == fake_core.EventType.UNKNOWN
|
|
330
|
-
assert events[7].
|
|
339
|
+
assert events[7].key_code is None
|
{mini_arcade_native_backend-0.4.1 → mini_arcade_native_backend-0.4.2}/.github/workflows/ci.yml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|