libretro.drivers.options.driver

Protocol definition for the core options interface.

See also

libretro.api.options

The matching ctypes types and callback definitions.

Classes

OptionDriver

Protocol for drivers that store and resolve a core's runtime options.

class OptionDriver[source]

Bases: Protocol

Protocol for drivers that store and resolve a core’s runtime options.

See also

libretro.api.options

The matching ctypes types and callback definitions.

abstractmethod get_variable(key)[source]

Return the current value of a single core option.

Corresponds to RETRO_ENVIRONMENT_GET_VARIABLE.

Parameters:

key (bytes) – The key of the core option to retrieve.

Return type:

bytes | None

Returns:

None if no option with the key given by key exists. Otherwise, the option’s current value if it has a valid one (as determined by the option definitions), or the default value otherwise.

abstractmethod set_variables(variables)[source]

Register the v0 core option variables advertised by the core.

Corresponds to RETRO_ENVIRONMENT_SET_VARIABLES.

Parameters:

variables (Collection[retro_variable] | None) – The variables registered by the core, or None to clear the registration.

Return type:

None

abstract property variable_updated

Whether any core option has been changed since the core last queried it.

Corresponds to RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE. Reading this property is expected to clear the flag.

abstract property version

The core options interface version this driver implements.

Corresponds to RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION.

abstractmethod set_options(options)[source]

Register the v1 core option definitions advertised by the core.

Corresponds to RETRO_ENVIRONMENT_SET_CORE_OPTIONS.

Parameters:

options (Collection[retro_core_option_definition] | None) – The options registered by the core, or None to clear the registration.

Return type:

None

abstractmethod set_options_intl(options)[source]

Register the v1 core option definitions, with translations, advertised by the core.

Corresponds to RETRO_ENVIRONMENT_SET_CORE_OPTIONS_INTL.

Parameters:

options (retro_core_options_intl | None) – The options registered by the core, or None to clear the registration.

Return type:

None

abstractmethod set_display(key, visible)[source]

Show or hide a single core option in the frontend’s UI.

Corresponds to RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY.

Parameters:
  • key (bytes) – The key of the option to update.

  • visible (bool) – True to show the option, False to hide it.

Return type:

None

abstractmethod set_options_v2(options)[source]

Register the v2 core option definitions advertised by the core.

Corresponds to RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2.

Parameters:

options (retro_core_options_v2 | None) – The options registered by the core, or None to clear the registration.

Return type:

None

abstractmethod set_options_v2_intl(options)[source]

Register the v2 core option definitions, with translations, advertised by the core.

Corresponds to RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2_INTL.

Parameters:

options (retro_core_options_v2_intl | None) – The options registered by the core, or None to clear the registration.

Return type:

None

abstract property update_display_callback

The display-update callback registered by the core, if any.

Set via RETRO_ENVIRONMENT_SET_CORE_OPTIONS_UPDATE_DISPLAY_CALLBACK. None if the core has not registered one.

Parameters:

callback – The callback to register, or None to clear it.

Raises:

UnsupportedEnvCall – If this driver does not support the display-update callback.

abstractmethod set_variable(var, value)[source]

Set a single core option’s value.

Corresponds to RETRO_ENVIRONMENT_SET_VARIABLE.

Parameters:
  • var (bytes) – The key of the option to set.

  • value (bytes) – The new value for the option.

Return type:

bool

Returns:

True if the value was accepted by the driver.

abstract property supports_categories

Whether this driver groups core options into categories (v2 feature).

abstract property variables

A live, mutable mapping of option keys to current values.

Mutating the returned mapping changes the driver’s stored option values and is the primary way to drive option changes from a Python test harness.

abstract property visibility

A mapping of option keys to whether the frontend would show that option.

abstract property categories

The v2 option categories registered by the core, indexed by category key.

None if the core has not registered any categories or this driver does not support categories.

abstract property definitions

The v2 option definitions registered by the core, indexed by option key.

None if the core has not registered any v2 definitions.

__init__(*args, **kwargs)
classmethod __new__(*args, **kwargs)