libretro.drivers.environment.default

Default EnvironmentDriver mapping that ships with libretro.py.

See also

EnvironmentDriver

The protocol this implementation satisfies.

Classes

DefaultEnvironmentDriver

EnvironmentDriver that registers handlers for the standard environment calls.

class DefaultEnvironmentDriver[source]

Bases: DictEnvironmentDriver

EnvironmentDriver that registers handlers for the standard environment calls.

Subclasses implement the underscore-prefixed handler methods (_set_rotation, _get_overscan, etc.) for each call they support.

__init__()[source]

Store envcalls as the registered handler mapping.

Parameters:

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

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)
abstractmethod audio_sample(left, right)

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

abstractmethod audio_sample_batch(data, frames)

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.

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.
abstractmethod input_poll()

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

abstractmethod input_state(port, device, index, id)

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.

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
abstractmethod video_refresh(data, width, height, pitch)

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