libretro.drivers.environment.composite

Default EnvironmentDriver that composes per-feature drivers into a single dispatcher.

See also

EnvironmentDriver

The protocol this implementation satisfies.

Classes

CompositeEnvironmentDriver

EnvironmentDriver that composes individual feature drivers into one dispatcher.

class CompositeEnvironmentDriver[source]

Bases: DefaultEnvironmentDriver, Generic

EnvironmentDriver that composes individual feature drivers into one dispatcher.

Each constructor argument supplies the driver responsible for one libretro subsystem (audio, input, video, etc.); None indicates the subsystem is not provided and the corresponding environment calls will return false.

__init__(audio, input, video, content=None, overscan=None, message=None, options=None, path=None, rumble=None, sensor=None, camera=None, log=None, perf=None, location=None, user=None, vfs=None, led=None, av_enable=None, midi=None, timing=None, preferred_hw=None, driver_switch_enable=None, savestate_context=None, jit_capable=None, mic=None, device_power=None)[source]

Store envcalls as the registered handler mapping.

Parameters:

envcalls – Mapping from EnvironmentCall to a callback that handles it.

property audio

Return the AudioDriver supplied at construction time.

property input

Return the InputDriver supplied at construction time.

property video

Return the VideoDriver supplied at construction time.

property content

Return the ContentDriver supplied at construction time, or None if absent.

property sensor

Return the SensorDriver supplied at construction time, or None if absent.

property camera

Return the CameraDriver supplied at construction time, or None if absent.

property user

Return the UserDriver supplied at construction time, or None if absent.

property path

Return the PathDriver supplied at construction time, or None if absent.

property timing

Return the TimingDriver supplied at construction time, or None if absent.

property rumble

Return the RumbleDriver supplied at construction time, or None if absent.

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, or None if 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 in data.

See also

retro_video_refresh_t

The C function pointer type whose signature this method implements.

Return type:

None

audio_sample(left, right)[source]

Receive a single stereo audio sample from the core.

Parameters:
  • left (int) – The left-channel sample as a signed 16-bit integer.

  • right (int) – The right-channel sample as a signed 16-bit integer.

See also

retro_audio_sample_t

The C function pointer type whose signature this method implements.

Return type:

None

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 in data.

Return type:

int

Returns:

The number of frames consumed.

See also

retro_audio_sample_batch_t

The C function pointer type whose signature this method implements.

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_t

The C function pointer type whose signature this method implements.

Return type:

None

input_state(port, device, index, id)[source]

Return the current input state for a given device control.

Parameters:
  • port (Port (int)) – The input port being queried.

  • device (int) – The RETRO_DEVICE_* device class.

  • index (int) – The sub-device index (e.g. analog stick number).

  • id (int) – The button or axis identifier within the device class.

Return type:

int

Returns:

The control’s current state, encoded per libretro’s input conventions.

See also

retro_input_state_t

The C function pointer type whose signature this method implements.

property rotation

Return the screen Rotation currently set on the underlying VideoDriver.

See also

EnvironmentCall.SET_ROTATION

The environment call that updates this value.

property overscan

Return whether the frontend wants overscan to be visible, or None if unset.

See also

EnvironmentCall.GET_OVERSCAN

The environment call that queries this value.

property can_dupe

Return whether the underlying VideoDriver supports frame duping.

See also

EnvironmentCall.GET_CAN_DUPE

The environment call that queries this value.

property message

Return the MessageDriver supplied at construction time, or None if absent.

property is_shutdown

Return True if the core has requested a shutdown via the environment call.

See also

EnvironmentCall.SHUTDOWN

The environment call that flips this flag.

property performance_level

Return the performance level the core has reported, or None if unset.

See also

EnvironmentCall.SET_PERFORMANCE_LEVEL

The environment call that sets this value.

property pixel_format

Return the PixelFormat currently set on the underlying VideoDriver.

See also

EnvironmentCall.SET_PIXEL_FORMAT

The environment call that updates this value.

property input_descriptors

Return the input descriptors registered by the core, or None if none were set.

See also

EnvironmentCall.SET_INPUT_DESCRIPTORS

The environment call that registers these descriptors.

property keyboard_callback

Return the keyboard callback registered by the core, or None if none was set.

See also

EnvironmentCall.SET_KEYBOARD_CALLBACK

The environment call that registers this callback.

property options

Return the OptionDriver supplied at construction time, or None if absent.

property support_no_game

Return whether the core can run without content, or None if no content driver is set.

See also

EnvironmentCall.SET_SUPPORT_NO_GAME

The environment call that sets this value.

property log

Return the LogDriver supplied at construction time, or None if absent.

property perf

Return the PerfDriver supplied at construction time, or None if absent.

property location

Return the LocationDriver supplied at construction time, or None if absent.

property proc_address_callback

Return the retro_get_proc_address_interface registered by the core, if any.

See also

EnvironmentCall.SET_PROC_ADDRESS_CALLBACK

The environment call that registers this interface.

get_proc_address(sym, funtype=None)[source]
Overloads:
  • self, sym (str | bytes), funtype (type[T]) → T | None

  • self, sym (str | bytes), funtype (None) → retro_proc_address_t | None

  • self, sym (Literal[b’’, ‘’]), funtype (type[_CFunctionType] | None) → None

  • self, sym (str | bytes), funtype (type[TypedFunctionPointer[R, P]]) → TypedFunctionPointer[R, P] | None

Look up a function pointer the core exposed via its proc-address interface.

Parameters:
  • sym – The name of the symbol to look up; an empty name returns None.

  • funtype – An optional ctypes function type to cast the returned pointer to; if omitted, a generic retro_proc_address_t is returned.

Returns:

The requested function pointer cast to funtype, or None if the core has not registered a proc-address interface, the symbol is empty, or the lookup failed.

property subsystems

Return the subsystem info the core registered, or None if no content driver is set.

See also

EnvironmentCall.SET_SUBSYSTEM_INFO

The environment call that registers this information.

property controller_info

Return the controller descriptions the core registered, or None if none were set.

See also

EnvironmentCall.SET_CONTROLLER_INFO

The environment call that registers this information.

property memory_maps

Return the memory map the core registered, or None if none was set.

See also

EnvironmentCall.SET_MEMORY_MAPS

The environment call that registers this information.

property geometry

Return the current frame geometry from the underlying VideoDriver.

See also

EnvironmentCall.SET_GEOMETRY

The environment call that updates this value.

property support_achievements

Return whether the core supports achievements, or None if it has not declared.

See also

EnvironmentCall.SET_SUPPORT_ACHIEVEMENTS

The environment call that sets this value.

property serialization_quirks

Return the SerializationQuirks the core declared, or None if unset.

See also

EnvironmentCall.SET_SERIALIZATION_QUIRKS

The environment call that sets these flags.

property hw_shared_context

Return whether the underlying VideoDriver is configured for a shared HW context.

See also

EnvironmentCall.SET_HW_SHARED_CONTEXT

The environment call that enables shared-context mode.

property vfs

Return the FileSystemDriver supplied at construction time, or None if absent.

property led

Return the LedDriver supplied at construction time, or None if absent.

property av_enable

Return the AvEnableFlags the frontend exposes to the core, or None if unset.

See also

EnvironmentCall.GET_AUDIO_VIDEO_ENABLE

The environment call that queries this value.

property midi

Return the MidiDriver supplied at construction time, or None if absent.

property input_bitmasks

Return whether the underlying InputDriver supports input bitmasks.

See also

EnvironmentCall.GET_INPUT_BITMASKS

The environment call that queries this value.

property core_options_version

Return the core-options API version supported by the option driver, or None if absent.

See also

EnvironmentCall.GET_CORE_OPTIONS_VERSION

The environment call that queries this value.

property preferred_hw_render

Return the preferred HardwareContext exposed to the core, or None if unset.

See also

EnvironmentCall.GET_PREFERRED_HW_RENDER

The environment call that queries this value.

property savestate_context

Return the SavestateContext the frontend exposes to the core, or None if unset.

See also

EnvironmentCall.GET_SAVESTATE_CONTEXT

The environment call that queries this value.

key in self
self[_DictEnvironmentDriver__key]
Return type:

Callable[[c_void_p], bool]

iter(self)
Return type:

Iterator[EnvironmentCall]

len(self)
classmethod __new__(*args, **kwargs)
environment(cmd, data)

Dispatch an environment call from the core.

Implementations route cmd to the appropriate _<env_call_name> helper (e.g. _get_variable for RETRO_ENVIRONMENT_GET_VARIABLE) and return True if the call was handled successfully.

Parameters:
  • cmd (int) – The RETRO_ENVIRONMENT_* command identifier.

  • data (c_void_p) – Pointer to the command-specific data buffer, interpreted according to cmd.

Return type:

bool

Returns:

True if the call was handled, False if the command is unsupported or failed.

See also

retro_environment_t

The C function pointer type whose signature this method implements.

get(k[, d]) D[k] if k in D, else d.  d defaults to None.
items() a set-like object providing a view on D's items
keys() a set-like object providing a view on D's keys
static return_on_raise(default)

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.

Return type:

Callable[[Callable[[ParamSpec(P)], TypeVar(T)]], Callable[[ParamSpec(P)], TypeVar(T)]]

values() an object providing a view on D's values
property jit_capable

Return whether the frontend permits JIT compilation, or None if unset.

See also

EnvironmentCall.GET_JIT_CAPABLE

The environment call that queries this value.

property mic

Return the MicrophoneDriver supplied at construction time, or None if absent.

property power

Return the PowerDriver supplied at construction time, or None if absent.