Skip to content

GB_set_input_callback

Lior Halphon edited this page Nov 30, 2024 · 3 revisions

Definition

typedef char *(*GB_input_callback_t)(GB_gameboy_t *gb);

void GB_set_async_input_callback(GB_gameboy_t *gb, GB_input_callback_t callback);

void GB_set_input_callback(GB_gameboy_t *gb, GB_input_callback_t callback);

In gb.h

Description

GB_set_input_callback and GB_set_async_input_callback sets callback that will be called when an emulator instance's debugger requests input synchronously and asynchronously, respectively. The callbacks must return a UTF-8 string allocated by malloc (which will be automatically freed by the caller), or NULL.

Returning NULL from the synchronous callback tells the debugger the input source is not available, and ROM execution will resume until it's explicitly stopped or reaches a stopping condition again. Returning NULL from the asynchronous callback means the user has no pending asynchronous commands to execute, and will not prevent the debugger from calling the callback again.

If these functions are not called, the default callbacks will return lines read from stdin.

Thread Safety

If callback is not NULL, GB_set_input_callback and GB_set_async_input_callback are thread-safe and can be called from any thread and context. Otherwise, it must not be called if the instance is being run in another thread, but may be called from the current one (via a callback).

Notes

The default asynchronous input callback is not supported on Windows; provide a custom callback if you wish to support asynchronous debugger commands on Windows.

Clone this wiki locally