all repos — mgba @ 837f952230ae3a83bdbfa4f3d459ba0841622daf

mGBA Game Boy Advance Emulator

Python: Add support for keysRead core callback
Vicki Pfau vi@endrift.com
Sat, 09 Mar 2019 12:01:00 -0800
commit

837f952230ae3a83bdbfa4f3d459ba0841622daf

parent

a04cb97653efc918e4879771c6ae06000200b43c

3 files changed, 13 insertions(+), 0 deletions(-)

jump to
M src/platform/python/core.csrc/platform/python/core.c

@@ -13,6 +13,7 @@ callbacks->videoFrameStarted = _mCorePythonCallbacksVideoFrameStarted;

callbacks->videoFrameEnded = _mCorePythonCallbacksVideoFrameEnded; callbacks->coreCrashed = _mCorePythonCallbacksCoreCrashed; callbacks->sleep = _mCorePythonCallbacksSleep; + callbacks->keysRead = _mCorePythonCallbacksKeysRead; callbacks->context = pyobj; return callbacks;
M src/platform/python/core.hsrc/platform/python/core.h

@@ -13,3 +13,4 @@ PYEXPORT void _mCorePythonCallbacksVideoFrameStarted(void* user);

PYEXPORT void _mCorePythonCallbacksVideoFrameEnded(void* user); PYEXPORT void _mCorePythonCallbacksCoreCrashed(void* user); PYEXPORT void _mCorePythonCallbacksSleep(void* user); +PYEXPORT void _mCorePythonCallbacksKeysRead(void* user);
M src/platform/python/mgba/core.pysrc/platform/python/mgba/core.py

@@ -79,6 +79,12 @@ context = ffi.from_handle(user)

context._sleep() +@ffi.def_extern() +def _mCorePythonCallbacksKeysRead(user): # pylint: disable=invalid-name + context = ffi.from_handle(user) + context._keys_read() + + class CoreCallbacks(object): def __init__(self): self._handle = ffi.new_handle(self)

@@ -86,6 +92,7 @@ self.video_frame_started = []

self.video_frame_ended = [] self.core_crashed = [] self.sleep = [] + self.keys_read = [] self.context = lib.mCorePythonCallbackCreate(self._handle) def _video_frame_started(self):

@@ -102,6 +109,10 @@ callback()

def _sleep(self): for callback in self.sleep: + callback() + + def _keys_read(self): + for callback in self.keys_read: callback()