libretro.drivers.environment.driver¶
Protocol definition for the retro_environment_t dispatcher.
See also
libretro.api.environmentThe matching
ctypestypes and callback definitions.
Classes
Protocol for the dispatcher that handles libretro environment calls and AV callbacks. |
- class EnvironmentDriver[source]¶
Bases:
ProtocolProtocol for the dispatcher that handles libretro environment calls and AV callbacks.
Acts as the single entry point libretro.py registers with the core via
Core.set_environment(),Core.set_video_refresh(), etc.See also
libretro.api.environmentThe matching
ctypestypes and callback definitions.
- abstractmethod environment(cmd, data)[source]¶
Dispatch an environment call from the core.
Implementations route
cmdto the appropriate_<env_call_name>helper (e.g._get_variableforRETRO_ENVIRONMENT_GET_VARIABLE) and returnTrueif the call was handled successfully.- Parameters:
cmd (
int) – TheRETRO_ENVIRONMENT_*command identifier.data (
c_void_ptr) – Pointer to the command-specific data buffer, interpreted according tocmd.
- Return type:
- Returns:
Trueif the call was handled,Falseif the command is unsupported or failed.
See also
retro_environment_tThe C function pointer type whose signature this method implements.
- abstractmethod video_refresh(data, width, height, pitch)[source]¶
Receive one frame of video output from the core.
- Parameters:
data (
c_void_ptr) – Pointer to the frame buffer in the core’s current pixel format, orNoneif the core asked the frontend to duplicate the previous frame.width (
int) – Width of the frame in pixels.height (
int) – Height of the frame in pixels.pitch (
int) – Number of bytes per scanline indata.
See also
retro_video_refresh_tThe C function pointer type whose signature this method implements.
- Return type:
- abstractmethod audio_sample(left, right)[source]¶
Receive a single stereo audio sample from the core.
- Parameters:
See also
retro_audio_sample_tThe C function pointer type whose signature this method implements.
- Return type:
- abstractmethod audio_sample_batch(data, frames)[source]¶
Receive a batch of interleaved stereo audio frames from the core.
- Parameters:
data (
LP_c_short) – Pointer to interleaved signed 16-bit stereo samples.frames (
int) – Number of stereo frames available indata.
- Return type:
- Returns:
The number of frames consumed.
See also
retro_audio_sample_batch_tThe C function pointer type whose signature this method implements.
- abstractmethod input_poll()[source]¶
Poll input devices for new input state.
Called by the core once per frame before any
input_state()queries.See also
retro_input_poll_tThe C function pointer type whose signature this method implements.
- Return type:
- abstractmethod input_state(port, device, index, id)[source]¶
Return the current input state for a given device control.
- Parameters:
- Return type:
- Returns:
The control’s current state, encoded per libretro’s input conventions.
See also
retro_input_state_tThe C function pointer type whose signature this method implements.
- static return_on_raise(default)[source]¶
Ctypes doesn’t propagate exceptions out of callbacks, so this is necessary to detect an error in a driver instead of just swallowing it with a warning.
- __init__(*args, **kwargs)¶
- classmethod __new__(*args, **kwargs)¶