forked from Felk/dolphin
-
Notifications
You must be signed in to change notification settings - Fork 3
/
dolphin_event.pyi
107 lines (71 loc) · 3.02 KB
/
dolphin_event.pyi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
"""
Module for awaiting or registering callbacks on all events emitted by Dolphin.
The odd-looking Protocol classes are just a lot of syntax to essentially describe
the callback's signature. See https://www.python.org/dev/peps/pep-0544/#callback-protocols
"""
from collections.abc import Callable
from typing import Protocol, type_check_only
def on_frameadvance(callback: Callable[[], None] | None) -> None:
"""Registers a callback to be called every time the game has rendered a new frame."""
async def frameadvance() -> None:
"""Awaitable event that completes once the game has rendered a new frame."""
@type_check_only
class _CodebreakpointCallback(Protocol):
def __call__(self, addr: int) -> None:
"""
Example callback stub for on_codebreakpoint.
:param addr: address that was accessed
"""
def on_codebreakpoint(callback: _CodebreakpointCallback | None) -> None:
"""
Registers a callback to be called every time a previously added code breakpoint is hit.
:param callback:
:return:
"""
async def codebreakpoint() -> tuple[int,]:
"""Awaitable event that completes once a previously added code breakpoint is hit."""
@type_check_only
class _MemorybreakpointCallback(Protocol):
def __call__(self, is_write: bool, addr: int, value: int) -> None:
"""
Example callback stub for on_memorybreakpoint.
:param is_write: true if a value was written, false if it was read
:param addr: address that was accessed
:param value: new value at the given address
"""
def on_memorybreakpoint(callback: _MemorybreakpointCallback | None) -> None:
"""
Registers a callback to be called every time a previously added memory breakpoint is hit.
:param callback:
:return:
"""
async def memorybreakpoint() -> tuple[bool, int, int]:
"""Awaitable event that completes once a previously added memory breakpoint is hit."""
@type_check_only
class _SaveStateCallback(Protocol):
def __call__(self, is_slot: bool, slot: int, /) -> None:
"""
Example callback stub for on_savestatesave and/or on_savestateload.
:param is_slot: true if save/load was with a savestate slot, \
false if save/load was from a file
:param slot: the slot the save/load occurred to/from. \
Should be disregarded if is_slot is false
"""
def on_savestatesave(callback: _SaveStateCallback | None) -> None:
"""
Registers a callback to be called every time a savestate is saved.
:param callback:
:return:
"""
async def savestatesave() -> tuple[bool, int]:
"""Awaitable event that completes once a savestate is saved."""
def on_savestateload(callback: _SaveStateCallback | None) -> None:
"""
Registers a callback to be called every time a savestate is loaded.
:param callback:
:return:
"""
async def savestateload() -> tuple[bool, int]:
"""Awaitable event that completes once a savestate is loaded."""
def system_reset() -> None:
"""Resets the emulation."""