mirror of https://github.com/mgba-emu/mgba.git
Python: Add support for keysRead core callback
This commit is contained in:
parent
a04cb97653
commit
837f952230
|
@ -13,6 +13,7 @@ struct mCoreCallbacks* mCorePythonCallbackCreate(void* pyobj) {
|
|||
callbacks->videoFrameEnded = _mCorePythonCallbacksVideoFrameEnded;
|
||||
callbacks->coreCrashed = _mCorePythonCallbacksCoreCrashed;
|
||||
callbacks->sleep = _mCorePythonCallbacksSleep;
|
||||
callbacks->keysRead = _mCorePythonCallbacksKeysRead;
|
||||
|
||||
callbacks->context = pyobj;
|
||||
return callbacks;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -79,6 +79,12 @@ def _mCorePythonCallbacksSleep(user): # pylint: disable=invalid-name
|
|||
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 @@ class CoreCallbacks(object):
|
|||
self.video_frame_ended = []
|
||||
self.core_crashed = []
|
||||
self.sleep = []
|
||||
self.keys_read = []
|
||||
self.context = lib.mCorePythonCallbackCreate(self._handle)
|
||||
|
||||
def _video_frame_started(self):
|
||||
|
@ -104,6 +111,10 @@ class CoreCallbacks(object):
|
|||
for callback in self.sleep:
|
||||
callback()
|
||||
|
||||
def _keys_read(self):
|
||||
for callback in self.keys_read:
|
||||
callback()
|
||||
|
||||
|
||||
class Core(object):
|
||||
if hasattr(lib, 'PLATFORM_GBA'):
|
||||
|
|
Loading…
Reference in New Issue