steamctypes 0.1.0__py3-none-any.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.
- steamctypes/__init__.py +32 -0
- steamctypes/_dispatch.py +379 -0
- steamctypes/_generated/__init__.py +39 -0
- steamctypes/_generated/callbacks.py +206 -0
- steamctypes/_generated/constants.py +226 -0
- steamctypes/_generated/enums.py +3044 -0
- steamctypes/_generated/functions.py +4562 -0
- steamctypes/_generated/interfaces.py +7864 -0
- steamctypes/_generated/structs.py +2727 -0
- steamctypes/_generated/typedefs.py +75 -0
- steamctypes/_loader.py +92 -0
- steamctypes/_native.py +51 -0
- steamctypes/_raw.py +213 -0
- steamctypes/_steam.py +237 -0
- steamctypes/apps.py +98 -0
- steamctypes/cloud.py +107 -0
- steamctypes/constants.py +7 -0
- steamctypes/enums.py +7 -0
- steamctypes/errors.py +50 -0
- steamctypes/friends.py +162 -0
- steamctypes/interfaces.py +7 -0
- steamctypes/leaderboards.py +193 -0
- steamctypes/overlay.py +85 -0
- steamctypes/py.typed +0 -0
- steamctypes/stats.py +143 -0
- steamctypes/structs.py +7 -0
- steamctypes/types.py +101 -0
- steamctypes/utils.py +112 -0
- steamctypes-0.1.0.dist-info/METADATA +134 -0
- steamctypes-0.1.0.dist-info/RECORD +32 -0
- steamctypes-0.1.0.dist-info/WHEEL +4 -0
- steamctypes-0.1.0.dist-info/licenses/LICENSE +202 -0
steamctypes/__init__.py
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
from steamctypes._dispatch import CallResult
|
|
2
|
+
from steamctypes._generated import SDK_VERSION
|
|
3
|
+
from steamctypes._steam import Steam, restart_app_if_necessary
|
|
4
|
+
from steamctypes.errors import (
|
|
5
|
+
CallResultError,
|
|
6
|
+
IncompatibleLibraryError,
|
|
7
|
+
LibraryNotFoundError,
|
|
8
|
+
NoSteamClientError,
|
|
9
|
+
SteamError,
|
|
10
|
+
SteamInitError,
|
|
11
|
+
SteamWarning,
|
|
12
|
+
VersionMismatchError,
|
|
13
|
+
)
|
|
14
|
+
from steamctypes.types import SteamID
|
|
15
|
+
|
|
16
|
+
__version__ = "0.1.0"
|
|
17
|
+
|
|
18
|
+
__all__ = [
|
|
19
|
+
"SDK_VERSION",
|
|
20
|
+
"CallResult",
|
|
21
|
+
"CallResultError",
|
|
22
|
+
"IncompatibleLibraryError",
|
|
23
|
+
"LibraryNotFoundError",
|
|
24
|
+
"NoSteamClientError",
|
|
25
|
+
"Steam",
|
|
26
|
+
"SteamError",
|
|
27
|
+
"SteamID",
|
|
28
|
+
"SteamInitError",
|
|
29
|
+
"SteamWarning",
|
|
30
|
+
"VersionMismatchError",
|
|
31
|
+
"restart_app_if_necessary",
|
|
32
|
+
]
|
steamctypes/_dispatch.py
ADDED
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
"""Deliver Steam callbacks and asynchronous call results."""
|
|
2
|
+
|
|
3
|
+
import contextlib
|
|
4
|
+
import ctypes
|
|
5
|
+
import functools
|
|
6
|
+
import threading
|
|
7
|
+
import time
|
|
8
|
+
import warnings
|
|
9
|
+
from collections.abc import Callable, Generator
|
|
10
|
+
from typing import Any, Generic, TypeVar, cast
|
|
11
|
+
|
|
12
|
+
from steamctypes._generated import SDK_VERSION
|
|
13
|
+
from steamctypes._generated.callbacks import CALLBACKS
|
|
14
|
+
from steamctypes._generated.constants import k_uAPICallInvalid
|
|
15
|
+
from steamctypes._generated.enums import ESteamAPICallFailure
|
|
16
|
+
from steamctypes._generated.functions import ACCESSORS
|
|
17
|
+
from steamctypes._generated.structs import CallbackMsg_t, SteamAPICallCompleted_t
|
|
18
|
+
from steamctypes._native import Native
|
|
19
|
+
from steamctypes.errors import CallResultError, SteamError, SteamWarning
|
|
20
|
+
|
|
21
|
+
S = TypeVar("S", bound=ctypes.Structure)
|
|
22
|
+
T = TypeVar("T")
|
|
23
|
+
U = TypeVar("U")
|
|
24
|
+
Handler = Callable[[Any], object]
|
|
25
|
+
DoneCallback = Callable[[], object]
|
|
26
|
+
|
|
27
|
+
# The session is user-side, so an id shared with a game server struct delivers the user struct,
|
|
28
|
+
# and only that struct can be subscribed to.
|
|
29
|
+
_STRUCTS = {callback_id: structs[0] for callback_id, structs in CALLBACKS.items()}
|
|
30
|
+
_IDS = {struct: callback_id for callback_id, struct in _STRUCTS.items()}
|
|
31
|
+
_COMPLETED_ID = _IDS[SteamAPICallCompleted_t]
|
|
32
|
+
_WAIT_INTERVAL = 0.01 # seconds between attempts to pump a frame in CallResult.wait()
|
|
33
|
+
# Warnings point at the code that called Steam.run_callbacks() or CallResult.wait(): both reach
|
|
34
|
+
# _run_frame() through the same number of frames. They are delivered like handlers, after what
|
|
35
|
+
# precedes them in the frame, so a warning raised as an error joins the frame's other errors.
|
|
36
|
+
_DELIVERY_STACKLEVEL = 5
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def callback_id_of(struct: type[ctypes.Structure]) -> int:
|
|
40
|
+
try:
|
|
41
|
+
return _IDS[struct]
|
|
42
|
+
except KeyError:
|
|
43
|
+
raise TypeError(f"{struct.__name__} is not a Steam callback struct") from None
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class _Pending(Generic[T]):
|
|
47
|
+
"""The state a CallResult shares with what completes it."""
|
|
48
|
+
|
|
49
|
+
def __init__(self) -> None:
|
|
50
|
+
self.lock = threading.Lock()
|
|
51
|
+
self.finished = threading.Event()
|
|
52
|
+
self.value: T | None = None
|
|
53
|
+
self.error: Exception | None = None
|
|
54
|
+
self.callbacks: list[DoneCallback] = []
|
|
55
|
+
|
|
56
|
+
def finish(self, value: T | None, error: Exception | None) -> list[DoneCallback]:
|
|
57
|
+
"""Record the outcome, then mark it done; return the done callbacks to run."""
|
|
58
|
+
with self.lock:
|
|
59
|
+
self.value, self.error = value, error
|
|
60
|
+
self.finished.set()
|
|
61
|
+
callbacks, self.callbacks = self.callbacks, []
|
|
62
|
+
return callbacks
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
class CallResult(Generic[T]):
|
|
66
|
+
"""The result of an asynchronous Steam API call, delivered by Steam.run_callbacks()."""
|
|
67
|
+
|
|
68
|
+
def __init__(self, pending: _Pending[T], dispatcher: "Dispatcher") -> None:
|
|
69
|
+
self._pending = pending
|
|
70
|
+
self._dispatcher = dispatcher
|
|
71
|
+
|
|
72
|
+
def done(self) -> bool:
|
|
73
|
+
return self._pending.finished.is_set()
|
|
74
|
+
|
|
75
|
+
def result(self) -> T:
|
|
76
|
+
"""The result. Raises if the call failed or has not completed yet."""
|
|
77
|
+
pending = self._pending
|
|
78
|
+
if not pending.finished.is_set():
|
|
79
|
+
raise SteamError("the call has not completed yet")
|
|
80
|
+
if pending.error is not None:
|
|
81
|
+
raise pending.error
|
|
82
|
+
return cast(T, pending.value)
|
|
83
|
+
|
|
84
|
+
def map(self, fn: Callable[[T], U]) -> "CallResult[U]":
|
|
85
|
+
"""The same call with fn applied to its result.
|
|
86
|
+
|
|
87
|
+
fn runs when the call completes, on the thread that runs the frame, or right away if it
|
|
88
|
+
already has. A frame on another thread can complete the call before map() is called, so
|
|
89
|
+
if fn reads what Steam keeps only briefly, run the frames on the thread that makes the
|
|
90
|
+
call. The high-level API maps its own calls safely. An exception from fn raises from
|
|
91
|
+
result().
|
|
92
|
+
"""
|
|
93
|
+
mapped: _Pending[U] = _Pending()
|
|
94
|
+
|
|
95
|
+
def convert(call: CallResult[T]) -> None:
|
|
96
|
+
try:
|
|
97
|
+
value, error = fn(call.result()), None
|
|
98
|
+
except Exception as failure:
|
|
99
|
+
value, error = None, failure
|
|
100
|
+
# finish() hands the callbacks over only once, so each one runs whatever the others do.
|
|
101
|
+
errors: list[Exception] = []
|
|
102
|
+
for callback in mapped.finish(value, error):
|
|
103
|
+
try:
|
|
104
|
+
callback()
|
|
105
|
+
except Exception as failure:
|
|
106
|
+
errors.append(failure)
|
|
107
|
+
if errors:
|
|
108
|
+
raise ExceptionGroup("done callbacks raised exceptions", errors)
|
|
109
|
+
|
|
110
|
+
self.add_done_callback(convert)
|
|
111
|
+
return CallResult(mapped, self._dispatcher)
|
|
112
|
+
|
|
113
|
+
def add_done_callback(self, fn: "Callable[[CallResult[T]], object]") -> None:
|
|
114
|
+
"""Call fn(self) when the call completes, or now if it already has."""
|
|
115
|
+
with self._pending.lock:
|
|
116
|
+
if not self._pending.finished.is_set():
|
|
117
|
+
self._pending.callbacks.append(functools.partial(fn, self))
|
|
118
|
+
return
|
|
119
|
+
fn(self)
|
|
120
|
+
|
|
121
|
+
def wait(self, timeout: float | None = None) -> T:
|
|
122
|
+
"""Pump frames until done, return result(); handler errors raise as in run_callbacks()."""
|
|
123
|
+
dispatcher, finished = self._dispatcher, self._pending.finished
|
|
124
|
+
if dispatcher.in_handler():
|
|
125
|
+
raise SteamError("CallResult.wait() cannot run inside a callback handler")
|
|
126
|
+
deadline = None if timeout is None else time.monotonic() + timeout
|
|
127
|
+
while not finished.is_set():
|
|
128
|
+
remaining = None if deadline is None else deadline - time.monotonic()
|
|
129
|
+
if remaining is not None and remaining <= 0:
|
|
130
|
+
raise TimeoutError("the Steam API call did not complete in time")
|
|
131
|
+
# Pump a frame unless another thread is running one; either way, give the
|
|
132
|
+
# completion a moment to arrive before trying again.
|
|
133
|
+
dispatcher.try_run()
|
|
134
|
+
finished.wait(_WAIT_INTERVAL if remaining is None else min(_WAIT_INTERVAL, remaining))
|
|
135
|
+
return self.result()
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
class Dispatcher:
|
|
139
|
+
"""Drains the manual dispatch queue of one pipe and delivers what it finds."""
|
|
140
|
+
|
|
141
|
+
def __init__(self, native: Native, pipe: int) -> None:
|
|
142
|
+
self.native = native
|
|
143
|
+
self._pipe = pipe
|
|
144
|
+
self._subscribers: dict[type[ctypes.Structure], list[Handler]] = {}
|
|
145
|
+
# Each pending call by its handle, with the struct its result arrives in.
|
|
146
|
+
self._pending: dict[int, tuple[type[ctypes.Structure], _Pending[Any]]] = {}
|
|
147
|
+
self._warned_ids: set[int] = set()
|
|
148
|
+
self._warned_results: set[type[ctypes.Structure]] = set()
|
|
149
|
+
# Held while a frame drains the queue and while a call registers its handle, so no frame
|
|
150
|
+
# can consume a completion whose handle is not registered yet. Subscriptions and close()
|
|
151
|
+
# take it too, so nothing is added after close() clears it. Reentrant for
|
|
152
|
+
# holding_frames(), which registers a call while holding it.
|
|
153
|
+
self._frame = threading.RLock()
|
|
154
|
+
self._runner: int | None = None # the thread running a frame
|
|
155
|
+
self._closed = False
|
|
156
|
+
# Synchronous calls into Steam do not take the frame lock, so calls on several threads
|
|
157
|
+
# run at once. close() waits for them, so none runs into SteamAPI_Shutdown.
|
|
158
|
+
self._calls = threading.Condition()
|
|
159
|
+
self._running_calls = 0
|
|
160
|
+
|
|
161
|
+
def subscribe(self, struct: type[ctypes.Structure], handler: Handler) -> None:
|
|
162
|
+
callback_id_of(struct)
|
|
163
|
+
with self._frame_lock():
|
|
164
|
+
if self._closed:
|
|
165
|
+
raise SteamError("Steam has been shut down")
|
|
166
|
+
self._subscribers.setdefault(struct, []).append(handler)
|
|
167
|
+
|
|
168
|
+
def unsubscribe(self, struct: type[ctypes.Structure], handler: Handler) -> None:
|
|
169
|
+
with self._frame_lock():
|
|
170
|
+
if self._closed:
|
|
171
|
+
raise SteamError("Steam has been shut down")
|
|
172
|
+
handlers = self._subscribers.get(struct, [])
|
|
173
|
+
if handler not in handlers:
|
|
174
|
+
raise ValueError(f"{handler!r} is not subscribed to {struct.__name__}")
|
|
175
|
+
handlers.remove(handler)
|
|
176
|
+
|
|
177
|
+
def async_call(self, function: str, struct: type[S], *args: object) -> CallResult[S]:
|
|
178
|
+
"""Make a flat API call that returns a SteamAPICall_t and track its result in struct."""
|
|
179
|
+
return self._track(struct, lambda: (None, self.native[function](*args)))[1]
|
|
180
|
+
|
|
181
|
+
def async_call_into(
|
|
182
|
+
self, function: str, struct: type[S], handle: ctypes.c_ulonglong, *args: object
|
|
183
|
+
) -> tuple[Any, CallResult[S]]:
|
|
184
|
+
"""Make a flat API call that writes a SteamAPICall_t into handle; return its result too."""
|
|
185
|
+
|
|
186
|
+
def call() -> tuple[Any, int]:
|
|
187
|
+
return self.native[function](*args), handle.value
|
|
188
|
+
|
|
189
|
+
return self._track(struct, call)
|
|
190
|
+
|
|
191
|
+
def _track(
|
|
192
|
+
self, struct: type[S], call: Callable[[], tuple[Any, int]]
|
|
193
|
+
) -> tuple[Any, CallResult[S]]:
|
|
194
|
+
callback_id_of(struct)
|
|
195
|
+
# The call and the registration share the frame lock, so no frame can take the
|
|
196
|
+
# completion before the handle is registered.
|
|
197
|
+
with self._frame_lock():
|
|
198
|
+
if self._closed:
|
|
199
|
+
raise SteamError("Steam has been shut down")
|
|
200
|
+
result, handle = call()
|
|
201
|
+
pending: _Pending[S] = _Pending()
|
|
202
|
+
if handle == k_uAPICallInvalid:
|
|
203
|
+
invalid = ESteamAPICallFailure.k_ESteamAPICallFailureInvalidHandle
|
|
204
|
+
pending.finish(None, CallResultError(invalid))
|
|
205
|
+
else:
|
|
206
|
+
self._pending[handle] = struct, pending
|
|
207
|
+
return result, CallResult(pending, self)
|
|
208
|
+
|
|
209
|
+
@contextlib.contextmanager
|
|
210
|
+
def holding_frames(self) -> Generator[None]:
|
|
211
|
+
"""Keep other threads from running a frame, so a call made inside cannot complete yet."""
|
|
212
|
+
with self._frame_lock():
|
|
213
|
+
yield
|
|
214
|
+
|
|
215
|
+
def in_handler(self) -> bool:
|
|
216
|
+
return self._runner == threading.get_ident()
|
|
217
|
+
|
|
218
|
+
def run(self) -> int:
|
|
219
|
+
"""Dispatch one frame, after any frame running on another thread.
|
|
220
|
+
|
|
221
|
+
Returns how many callbacks reached a subscriber or call result.
|
|
222
|
+
"""
|
|
223
|
+
if self.in_handler():
|
|
224
|
+
raise SteamError("run_callbacks() cannot run inside a callback handler")
|
|
225
|
+
with self._frame:
|
|
226
|
+
dispatched = self._locked_frame()
|
|
227
|
+
if dispatched is None:
|
|
228
|
+
raise SteamError("Steam has been shut down")
|
|
229
|
+
return dispatched
|
|
230
|
+
|
|
231
|
+
def try_run(self) -> int | None:
|
|
232
|
+
"""Dispatch one frame, or return None if a frame is running or Steam was shut down."""
|
|
233
|
+
if not self._frame.acquire(blocking=False):
|
|
234
|
+
return None
|
|
235
|
+
try:
|
|
236
|
+
return self._locked_frame()
|
|
237
|
+
finally:
|
|
238
|
+
self._frame.release()
|
|
239
|
+
|
|
240
|
+
@contextlib.contextmanager
|
|
241
|
+
def calling(self) -> Generator[None]:
|
|
242
|
+
"""Keep the session open while a synchronous call into Steam runs."""
|
|
243
|
+
with self._calls:
|
|
244
|
+
if self._closed:
|
|
245
|
+
raise SteamError("Steam has been shut down")
|
|
246
|
+
self._running_calls += 1
|
|
247
|
+
try:
|
|
248
|
+
yield
|
|
249
|
+
finally:
|
|
250
|
+
with self._calls:
|
|
251
|
+
self._running_calls -= 1
|
|
252
|
+
self._calls.notify_all()
|
|
253
|
+
|
|
254
|
+
def close(self) -> list[DoneCallback]:
|
|
255
|
+
"""Fail pending call results and drop subscriptions; return the done callbacks to run.
|
|
256
|
+
|
|
257
|
+
Waits for a frame, call registration or synchronous call running on another thread.
|
|
258
|
+
"""
|
|
259
|
+
with self._frame:
|
|
260
|
+
with self._calls:
|
|
261
|
+
self._closed = True
|
|
262
|
+
self._calls.wait_for(lambda: self._running_calls == 0)
|
|
263
|
+
pending, self._pending = self._pending, {}
|
|
264
|
+
self._subscribers.clear()
|
|
265
|
+
return [
|
|
266
|
+
callback
|
|
267
|
+
for _, call in pending.values()
|
|
268
|
+
for callback in call.finish(
|
|
269
|
+
None, SteamError("Steam was shut down before the call completed")
|
|
270
|
+
)
|
|
271
|
+
]
|
|
272
|
+
|
|
273
|
+
def _frame_lock(self) -> contextlib.AbstractContextManager[object]:
|
|
274
|
+
"""The frame lock, or nothing if this thread's frame already holds it."""
|
|
275
|
+
return contextlib.nullcontext() if self.in_handler() else self._frame
|
|
276
|
+
|
|
277
|
+
def _locked_frame(self) -> int | None:
|
|
278
|
+
if self._closed:
|
|
279
|
+
return None
|
|
280
|
+
self._runner = threading.get_ident()
|
|
281
|
+
try:
|
|
282
|
+
return self._run_frame()
|
|
283
|
+
finally:
|
|
284
|
+
self._runner = None
|
|
285
|
+
|
|
286
|
+
def _run_frame(self) -> int:
|
|
287
|
+
native, pipe = self.native, self._pipe
|
|
288
|
+
native["SteamAPI_ManualDispatch_RunFrame"](pipe)
|
|
289
|
+
message = CallbackMsg_t()
|
|
290
|
+
dispatched = 0
|
|
291
|
+
errors: list[Exception] = []
|
|
292
|
+
while native["SteamAPI_ManualDispatch_GetNextCallback"](pipe, message):
|
|
293
|
+
# Handlers run before the free: pointer fields point into the message, which
|
|
294
|
+
# FreeLastCallback releases.
|
|
295
|
+
try:
|
|
296
|
+
reached, deliveries = self._read(message)
|
|
297
|
+
dispatched += reached
|
|
298
|
+
for deliver in deliveries:
|
|
299
|
+
try:
|
|
300
|
+
deliver()
|
|
301
|
+
except Exception as error:
|
|
302
|
+
errors.append(error)
|
|
303
|
+
finally:
|
|
304
|
+
native["SteamAPI_ManualDispatch_FreeLastCallback"](pipe)
|
|
305
|
+
if errors:
|
|
306
|
+
raise ExceptionGroup("callback handlers raised exceptions", errors)
|
|
307
|
+
return dispatched
|
|
308
|
+
|
|
309
|
+
def _read(self, message: CallbackMsg_t) -> tuple[bool, list[DoneCallback]]:
|
|
310
|
+
"""Copy the message's payload.
|
|
311
|
+
|
|
312
|
+
Returns whether it reached a subscriber or a pending call result, and the calls that
|
|
313
|
+
deliver it.
|
|
314
|
+
"""
|
|
315
|
+
callback_id, size = message.m_iCallback, message.m_cubParam
|
|
316
|
+
struct = _STRUCTS.get(callback_id)
|
|
317
|
+
if struct is None:
|
|
318
|
+
return False, []
|
|
319
|
+
if size != ctypes.sizeof(struct):
|
|
320
|
+
if callback_id in self._warned_ids:
|
|
321
|
+
return False, []
|
|
322
|
+
self._warned_ids.add(callback_id)
|
|
323
|
+
text = (
|
|
324
|
+
f"skipping callback {callback_id} ({struct.__name__}): Steam sent {size} "
|
|
325
|
+
f"bytes, steamctypes expects {ctypes.sizeof(struct)}. The steam_api library "
|
|
326
|
+
f"may not be from Steamworks SDK {SDK_VERSION}."
|
|
327
|
+
)
|
|
328
|
+
warn = functools.partial(
|
|
329
|
+
warnings.warn, text, SteamWarning, stacklevel=_DELIVERY_STACKLEVEL
|
|
330
|
+
)
|
|
331
|
+
return False, [warn]
|
|
332
|
+
handlers = tuple(self._subscribers.get(struct, ()))
|
|
333
|
+
completes_call = callback_id == _COMPLETED_ID
|
|
334
|
+
if not handlers and not completes_call:
|
|
335
|
+
return False, []
|
|
336
|
+
data = struct.from_buffer_copy(ctypes.string_at(message.m_pubParam, size))
|
|
337
|
+
deliveries: list[DoneCallback] = [functools.partial(h, data) for h in handlers]
|
|
338
|
+
call = self._pending.pop(data.m_hAsyncCall, None) if completes_call else None
|
|
339
|
+
if call is not None:
|
|
340
|
+
deliveries += self._complete(cast(SteamAPICallCompleted_t, data), *call)
|
|
341
|
+
return bool(handlers) or call is not None, deliveries
|
|
342
|
+
|
|
343
|
+
def _complete(
|
|
344
|
+
self,
|
|
345
|
+
completed: SteamAPICallCompleted_t,
|
|
346
|
+
struct: type[ctypes.Structure],
|
|
347
|
+
pending: _Pending[Any],
|
|
348
|
+
) -> list[DoneCallback]:
|
|
349
|
+
"""Fetch the result of a completed call and settle it; return its done callbacks."""
|
|
350
|
+
handle = completed.m_hAsyncCall
|
|
351
|
+
expected = (callback_id_of(struct), ctypes.sizeof(struct))
|
|
352
|
+
if (completed.m_iCallback, completed.m_cubParam) != expected:
|
|
353
|
+
message = (
|
|
354
|
+
f"{struct.__name__}: Steam reports call result {completed.m_iCallback} of "
|
|
355
|
+
f"{completed.m_cubParam} bytes, steamctypes expects {expected[0]} of {expected[1]} "
|
|
356
|
+
f"bytes. The steam_api library likely comes from another SDK version than "
|
|
357
|
+
f"{SDK_VERSION}."
|
|
358
|
+
)
|
|
359
|
+
mismatched = ESteamAPICallFailure.k_ESteamAPICallFailureMismatchedCallback
|
|
360
|
+
callbacks = pending.finish(None, CallResultError(mismatched, message))
|
|
361
|
+
if struct not in self._warned_results:
|
|
362
|
+
self._warned_results.add(struct)
|
|
363
|
+
# Delivered after the call is settled: a warning raised as an error then joins
|
|
364
|
+
# the frame's errors instead of leaving the call pending forever.
|
|
365
|
+
warn = functools.partial(
|
|
366
|
+
warnings.warn, message, SteamWarning, stacklevel=_DELIVERY_STACKLEVEL
|
|
367
|
+
)
|
|
368
|
+
callbacks.append(warn)
|
|
369
|
+
return callbacks
|
|
370
|
+
result = struct()
|
|
371
|
+
failed = ctypes.c_bool()
|
|
372
|
+
fetched = self.native["SteamAPI_ManualDispatch_GetAPICallResult"](
|
|
373
|
+
self._pipe, handle, ctypes.addressof(result), expected[1], expected[0], failed
|
|
374
|
+
)
|
|
375
|
+
if fetched and not failed.value:
|
|
376
|
+
return pending.finish(result, None)
|
|
377
|
+
utils = self.native[ACCESSORS["ISteamUtils"]["user"]]()
|
|
378
|
+
reason = self.native["SteamAPI_ISteamUtils_GetAPICallFailureReason"](utils, handle)
|
|
379
|
+
return pending.finish(None, CallResultError(reason))
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Generated from Steamworks SDK 1.65 by tools/generator. Do not edit.
|
|
2
|
+
from collections.abc import Mapping
|
|
3
|
+
from typing import Final
|
|
4
|
+
|
|
5
|
+
SDK_VERSION: Final = "1.65"
|
|
6
|
+
# sha256 of the SDK's steam_api library, by its redistributable_bin folder.
|
|
7
|
+
LIBRARY_SHA256: Final[Mapping[str, str]] = {
|
|
8
|
+
"linux64": "eb2dd015b84177cf4f4326fe578aab375fd8931bbbd719c7492420d9777007fe",
|
|
9
|
+
"linuxarm64": "6010ff5049f0154a270092cb93729f1fc691d28e3b8a6f5fc6f8fcccfbd1e508",
|
|
10
|
+
"osx": "a37faf19675b943a3c9717d25d9a881f5addb7f0ee728e03de7aac143ba759d2",
|
|
11
|
+
"win64": "e6d9bafb9a41e42fba7b21553db49f8719027af3f0deb23ff86cfc44d60e776d",
|
|
12
|
+
}
|
|
13
|
+
# The interface versions init asks the Steam client to support, in the SDK's order.
|
|
14
|
+
INIT_INTERFACE_VERSIONS: Final[tuple[str, ...]] = (
|
|
15
|
+
"SteamUtils011",
|
|
16
|
+
"SteamNetworkingUtils004",
|
|
17
|
+
"STEAMAPPS_INTERFACE_VERSION009",
|
|
18
|
+
"SteamController008",
|
|
19
|
+
"SteamFriends018",
|
|
20
|
+
"STEAMHTMLSURFACE_INTERFACE_VERSION_005",
|
|
21
|
+
"STEAMHTTP_INTERFACE_VERSION003",
|
|
22
|
+
"SteamInput007",
|
|
23
|
+
"STEAMINVENTORY_INTERFACE_V003",
|
|
24
|
+
"SteamMatchMakingServers003",
|
|
25
|
+
"SteamMatchMaking009",
|
|
26
|
+
"STEAMMUSIC_INTERFACE_VERSION001",
|
|
27
|
+
"SteamNetworkingMessages002",
|
|
28
|
+
"SteamNetworkingSockets013",
|
|
29
|
+
"SteamNetworking006",
|
|
30
|
+
"STEAMPARENTALSETTINGS_INTERFACE_VERSION001",
|
|
31
|
+
"SteamParties002",
|
|
32
|
+
"STEAMREMOTEPLAY_INTERFACE_VERSION004",
|
|
33
|
+
"STEAMREMOTESTORAGE_INTERFACE_VERSION016",
|
|
34
|
+
"STEAMSCREENSHOTS_INTERFACE_VERSION003",
|
|
35
|
+
"STEAMUGC_INTERFACE_VERSION021",
|
|
36
|
+
"STEAMUSERSTATS_INTERFACE_VERSION013",
|
|
37
|
+
"SteamUser023",
|
|
38
|
+
"STEAMVIDEO_INTERFACE_V007",
|
|
39
|
+
)
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
# Generated from Steamworks SDK 1.65 by tools/generator. Do not edit.
|
|
2
|
+
import ctypes
|
|
3
|
+
from collections.abc import Mapping
|
|
4
|
+
from typing import Final
|
|
5
|
+
|
|
6
|
+
from . import structs
|
|
7
|
+
|
|
8
|
+
# Every id maps to a tuple. An id shared by a user and a game server struct lists the
|
|
9
|
+
# user struct first; both have the same layout.
|
|
10
|
+
CALLBACKS: Final[Mapping[int, tuple[type[ctypes.Structure], ...]]] = {
|
|
11
|
+
101: (structs.SteamServersConnected_t,),
|
|
12
|
+
102: (structs.SteamServerConnectFailure_t,),
|
|
13
|
+
103: (structs.SteamServersDisconnected_t,),
|
|
14
|
+
113: (structs.ClientGameServerDeny_t,),
|
|
15
|
+
115: (structs.GSPolicyResponse_t,),
|
|
16
|
+
117: (structs.IPCFailure_t,),
|
|
17
|
+
125: (structs.LicensesUpdated_t,),
|
|
18
|
+
143: (structs.ValidateAuthTicketResponse_t,),
|
|
19
|
+
152: (structs.MicroTxnAuthorizationResponse_t,),
|
|
20
|
+
154: (structs.EncryptedAppTicketResponse_t,),
|
|
21
|
+
163: (structs.GetAuthSessionTicketResponse_t,),
|
|
22
|
+
164: (structs.GameWebCallback_t,),
|
|
23
|
+
165: (structs.StoreAuthURLResponse_t,),
|
|
24
|
+
166: (structs.MarketEligibilityResponse_t,),
|
|
25
|
+
167: (structs.DurationControl_t,),
|
|
26
|
+
168: (structs.GetTicketForWebApiResponse_t,),
|
|
27
|
+
201: (structs.GSClientApprove_t,),
|
|
28
|
+
202: (structs.GSClientDeny_t,),
|
|
29
|
+
203: (structs.GSClientKick_t,),
|
|
30
|
+
206: (structs.GSClientAchievementStatus_t,),
|
|
31
|
+
207: (structs.GSGameplayStats_t,),
|
|
32
|
+
208: (structs.GSClientGroupStatus_t,),
|
|
33
|
+
209: (structs.GSReputation_t,),
|
|
34
|
+
210: (structs.AssociateWithClanResult_t,),
|
|
35
|
+
211: (structs.ComputeNewPlayerCompatibilityResult_t,),
|
|
36
|
+
304: (structs.PersonaStateChange_t,),
|
|
37
|
+
331: (structs.GameOverlayActivated_t,),
|
|
38
|
+
332: (structs.GameServerChangeRequested_t,),
|
|
39
|
+
333: (structs.GameLobbyJoinRequested_t,),
|
|
40
|
+
334: (structs.AvatarImageLoaded_t,),
|
|
41
|
+
335: (structs.ClanOfficerListResponse_t,),
|
|
42
|
+
336: (structs.FriendRichPresenceUpdate_t,),
|
|
43
|
+
337: (structs.GameRichPresenceJoinRequested_t,),
|
|
44
|
+
338: (structs.GameConnectedClanChatMsg_t,),
|
|
45
|
+
339: (structs.GameConnectedChatJoin_t,),
|
|
46
|
+
340: (structs.GameConnectedChatLeave_t,),
|
|
47
|
+
341: (structs.DownloadClanActivityCountsResult_t,),
|
|
48
|
+
342: (structs.JoinClanChatRoomCompletionResult_t,),
|
|
49
|
+
343: (structs.GameConnectedFriendChatMsg_t,),
|
|
50
|
+
344: (structs.FriendsGetFollowerCount_t,),
|
|
51
|
+
345: (structs.FriendsIsFollowing_t,),
|
|
52
|
+
346: (structs.FriendsEnumerateFollowingList_t,),
|
|
53
|
+
348: (structs.UnreadChatMessagesChanged_t,),
|
|
54
|
+
349: (structs.OverlayBrowserProtocolNavigation_t,),
|
|
55
|
+
350: (structs.EquippedProfileItemsChanged_t,),
|
|
56
|
+
351: (structs.EquippedProfileItems_t,),
|
|
57
|
+
502: (structs.FavoritesListChanged_t,),
|
|
58
|
+
503: (structs.LobbyInvite_t,),
|
|
59
|
+
504: (structs.LobbyEnter_t,),
|
|
60
|
+
505: (structs.LobbyDataUpdate_t,),
|
|
61
|
+
506: (structs.LobbyChatUpdate_t,),
|
|
62
|
+
507: (structs.LobbyChatMsg_t,),
|
|
63
|
+
509: (structs.LobbyGameCreated_t,),
|
|
64
|
+
510: (structs.LobbyMatchList_t,),
|
|
65
|
+
512: (structs.LobbyKicked_t,),
|
|
66
|
+
513: (structs.LobbyCreated_t,),
|
|
67
|
+
516: (structs.FavoritesListAccountsUpdated_t,),
|
|
68
|
+
701: (structs.IPCountry_t,),
|
|
69
|
+
702: (structs.LowBatteryPower_t,),
|
|
70
|
+
703: (structs.SteamAPICallCompleted_t,),
|
|
71
|
+
704: (structs.SteamShutdown_t,),
|
|
72
|
+
705: (structs.CheckFileSignature_t,),
|
|
73
|
+
714: (structs.GamepadTextInputDismissed_t,),
|
|
74
|
+
736: (structs.AppResumingFromSuspend_t,),
|
|
75
|
+
738: (structs.FloatingGamepadTextInputDismissed_t,),
|
|
76
|
+
739: (structs.FilterTextDictionaryChanged_t,),
|
|
77
|
+
1005: (structs.DlcInstalled_t,),
|
|
78
|
+
1014: (structs.NewUrlLaunchParameters_t,),
|
|
79
|
+
1021: (structs.AppProofOfPurchaseKeyResponse_t,),
|
|
80
|
+
1023: (structs.FileDetailsResult_t,),
|
|
81
|
+
1030: (structs.TimedTrialStatus_t,),
|
|
82
|
+
1101: (structs.UserStatsReceived_t,),
|
|
83
|
+
1102: (structs.UserStatsStored_t,),
|
|
84
|
+
1103: (structs.UserAchievementStored_t,),
|
|
85
|
+
1104: (structs.LeaderboardFindResult_t,),
|
|
86
|
+
1105: (structs.LeaderboardScoresDownloaded_t,),
|
|
87
|
+
1106: (structs.LeaderboardScoreUploaded_t,),
|
|
88
|
+
1107: (structs.NumberOfCurrentPlayers_t,),
|
|
89
|
+
1108: (structs.UserStatsUnloaded_t, structs.GSStatsUnloaded_t),
|
|
90
|
+
1109: (structs.UserAchievementIconFetched_t,),
|
|
91
|
+
1110: (structs.GlobalAchievementPercentagesReady_t,),
|
|
92
|
+
1111: (structs.LeaderboardUGCSet_t,),
|
|
93
|
+
1112: (structs.GlobalStatsReceived_t,),
|
|
94
|
+
1201: (structs.SocketStatusCallback_t,),
|
|
95
|
+
1202: (structs.P2PSessionRequest_t,),
|
|
96
|
+
1203: (structs.P2PSessionConnectFail_t,),
|
|
97
|
+
1221: (structs.SteamNetConnectionStatusChangedCallback_t,),
|
|
98
|
+
1222: (structs.SteamNetAuthenticationStatus_t,),
|
|
99
|
+
1223: (structs.SteamNetworkingFakeIPResult_t,),
|
|
100
|
+
1251: (structs.SteamNetworkingMessagesSessionRequest_t,),
|
|
101
|
+
1252: (structs.SteamNetworkingMessagesSessionFailed_t,),
|
|
102
|
+
1281: (structs.SteamRelayNetworkStatus_t,),
|
|
103
|
+
1307: (structs.RemoteStorageFileShareResult_t,),
|
|
104
|
+
1309: (structs.RemoteStoragePublishFileResult_t,),
|
|
105
|
+
1311: (structs.RemoteStorageDeletePublishedFileResult_t,),
|
|
106
|
+
1312: (structs.RemoteStorageEnumerateUserPublishedFilesResult_t,),
|
|
107
|
+
1313: (structs.RemoteStorageSubscribePublishedFileResult_t,),
|
|
108
|
+
1314: (structs.RemoteStorageEnumerateUserSubscribedFilesResult_t,),
|
|
109
|
+
1315: (structs.RemoteStorageUnsubscribePublishedFileResult_t,),
|
|
110
|
+
1316: (structs.RemoteStorageUpdatePublishedFileResult_t,),
|
|
111
|
+
1317: (structs.RemoteStorageDownloadUGCResult_t,),
|
|
112
|
+
1318: (structs.RemoteStorageGetPublishedFileDetailsResult_t,),
|
|
113
|
+
1319: (structs.RemoteStorageEnumerateWorkshopFilesResult_t,),
|
|
114
|
+
1320: (structs.RemoteStorageGetPublishedItemVoteDetailsResult_t,),
|
|
115
|
+
1321: (structs.RemoteStoragePublishedFileSubscribed_t,),
|
|
116
|
+
1322: (structs.RemoteStoragePublishedFileUnsubscribed_t,),
|
|
117
|
+
1323: (structs.RemoteStoragePublishedFileDeleted_t,),
|
|
118
|
+
1324: (structs.RemoteStorageUpdateUserPublishedItemVoteResult_t,),
|
|
119
|
+
1325: (structs.RemoteStorageUserVoteDetails_t,),
|
|
120
|
+
1326: (structs.RemoteStorageEnumerateUserSharedWorkshopFilesResult_t,),
|
|
121
|
+
1327: (structs.RemoteStorageSetUserPublishedFileActionResult_t,),
|
|
122
|
+
1328: (structs.RemoteStorageEnumeratePublishedFilesByUserActionResult_t,),
|
|
123
|
+
1329: (structs.RemoteStoragePublishFileProgress_t,),
|
|
124
|
+
1330: (structs.RemoteStoragePublishedFileUpdated_t,),
|
|
125
|
+
1331: (structs.RemoteStorageFileWriteAsyncComplete_t,),
|
|
126
|
+
1332: (structs.RemoteStorageFileReadAsyncComplete_t,),
|
|
127
|
+
1333: (structs.RemoteStorageLocalFileChange_t,),
|
|
128
|
+
1800: (structs.GSStatsReceived_t,),
|
|
129
|
+
1801: (structs.GSStatsStored_t,),
|
|
130
|
+
2101: (structs.HTTPRequestCompleted_t,),
|
|
131
|
+
2102: (structs.HTTPRequestHeadersReceived_t,),
|
|
132
|
+
2103: (structs.HTTPRequestDataReceived_t,),
|
|
133
|
+
2301: (structs.ScreenshotReady_t,),
|
|
134
|
+
2302: (structs.ScreenshotRequested_t,),
|
|
135
|
+
2801: (structs.SteamInputDeviceConnected_t,),
|
|
136
|
+
2802: (structs.SteamInputDeviceDisconnected_t,),
|
|
137
|
+
2803: (structs.SteamInputConfigurationLoaded_t,),
|
|
138
|
+
2804: (structs.SteamInputGamepadSlotChange_t,),
|
|
139
|
+
3401: (structs.SteamUGCQueryCompleted_t,),
|
|
140
|
+
3402: (structs.SteamUGCRequestUGCDetailsResult_t,),
|
|
141
|
+
3403: (structs.CreateItemResult_t,),
|
|
142
|
+
3404: (structs.SubmitItemUpdateResult_t,),
|
|
143
|
+
3405: (structs.ItemInstalled_t,),
|
|
144
|
+
3406: (structs.DownloadItemResult_t,),
|
|
145
|
+
3407: (structs.UserFavoriteItemsListChanged_t,),
|
|
146
|
+
3408: (structs.SetUserItemVoteResult_t,),
|
|
147
|
+
3409: (structs.GetUserItemVoteResult_t,),
|
|
148
|
+
3410: (structs.StartPlaytimeTrackingResult_t,),
|
|
149
|
+
3411: (structs.StopPlaytimeTrackingResult_t,),
|
|
150
|
+
3412: (structs.AddUGCDependencyResult_t,),
|
|
151
|
+
3413: (structs.RemoveUGCDependencyResult_t,),
|
|
152
|
+
3414: (structs.AddAppDependencyResult_t,),
|
|
153
|
+
3415: (structs.RemoveAppDependencyResult_t,),
|
|
154
|
+
3416: (structs.GetAppDependenciesResult_t,),
|
|
155
|
+
3417: (structs.DeleteItemResult_t,),
|
|
156
|
+
3418: (structs.UserSubscribedItemsListChanged_t,),
|
|
157
|
+
3420: (structs.WorkshopEULAStatus_t,),
|
|
158
|
+
4001: (structs.PlaybackStatusHasChanged_t,),
|
|
159
|
+
4002: (structs.VolumeHasChanged_t,),
|
|
160
|
+
4501: (structs.HTML_BrowserReady_t,),
|
|
161
|
+
4502: (structs.HTML_NeedsPaint_t,),
|
|
162
|
+
4503: (structs.HTML_StartRequest_t,),
|
|
163
|
+
4504: (structs.HTML_CloseBrowser_t,),
|
|
164
|
+
4505: (structs.HTML_URLChanged_t,),
|
|
165
|
+
4506: (structs.HTML_FinishedRequest_t,),
|
|
166
|
+
4507: (structs.HTML_OpenLinkInNewTab_t,),
|
|
167
|
+
4508: (structs.HTML_ChangedTitle_t,),
|
|
168
|
+
4509: (structs.HTML_SearchResults_t,),
|
|
169
|
+
4510: (structs.HTML_CanGoBackAndForward_t,),
|
|
170
|
+
4511: (structs.HTML_HorizontalScroll_t,),
|
|
171
|
+
4512: (structs.HTML_VerticalScroll_t,),
|
|
172
|
+
4513: (structs.HTML_LinkAtPosition_t,),
|
|
173
|
+
4514: (structs.HTML_JSAlert_t,),
|
|
174
|
+
4515: (structs.HTML_JSConfirm_t,),
|
|
175
|
+
4516: (structs.HTML_FileOpenDialog_t,),
|
|
176
|
+
4521: (structs.HTML_NewWindow_t,),
|
|
177
|
+
4522: (structs.HTML_SetCursor_t,),
|
|
178
|
+
4523: (structs.HTML_StatusText_t,),
|
|
179
|
+
4524: (structs.HTML_ShowToolTip_t,),
|
|
180
|
+
4525: (structs.HTML_UpdateToolTip_t,),
|
|
181
|
+
4526: (structs.HTML_HideToolTip_t,),
|
|
182
|
+
4527: (structs.HTML_BrowserRestarted_t,),
|
|
183
|
+
4604: (structs.BroadcastUploadStart_t,),
|
|
184
|
+
4605: (structs.BroadcastUploadStop_t,),
|
|
185
|
+
4611: (structs.GetVideoURLResult_t,),
|
|
186
|
+
4624: (structs.GetOPFSettingsResult_t,),
|
|
187
|
+
4700: (structs.SteamInventoryResultReady_t,),
|
|
188
|
+
4701: (structs.SteamInventoryFullUpdate_t,),
|
|
189
|
+
4702: (structs.SteamInventoryDefinitionUpdate_t,),
|
|
190
|
+
4703: (structs.SteamInventoryEligiblePromoItemDefIDs_t,),
|
|
191
|
+
4704: (structs.SteamInventoryStartPurchaseResult_t,),
|
|
192
|
+
4705: (structs.SteamInventoryRequestPricesResult_t,),
|
|
193
|
+
5001: (structs.SteamParentalSettingsChanged_t,),
|
|
194
|
+
5301: (structs.JoinPartyCallback_t,),
|
|
195
|
+
5302: (structs.CreateBeaconCallback_t,),
|
|
196
|
+
5303: (structs.ReservationNotificationCallback_t,),
|
|
197
|
+
5304: (structs.ChangeNumOpenSlotsCallback_t,),
|
|
198
|
+
5305: (structs.AvailableBeaconLocationsUpdated_t,),
|
|
199
|
+
5306: (structs.ActiveBeaconsUpdated_t,),
|
|
200
|
+
5701: (structs.SteamRemotePlaySessionConnected_t,),
|
|
201
|
+
5702: (structs.SteamRemotePlaySessionDisconnected_t,),
|
|
202
|
+
5703: (structs.SteamRemotePlayTogetherGuestInvite_t,),
|
|
203
|
+
5704: (structs.SteamRemotePlaySessionAvatarLoaded_t,),
|
|
204
|
+
6001: (structs.SteamTimelineGamePhaseRecordingExists_t,),
|
|
205
|
+
6002: (structs.SteamTimelineEventRecordingExists_t,),
|
|
206
|
+
}
|