libretro.api.disk

Types and callbacks for using the emulated system’s disk drives, if any.

Module Attributes

retro_set_eject_state_t

Open or close the emulated console's virtual disk tray.

retro_get_eject_state_t

Return whether the emulated disk tray is currently open.

retro_get_image_index_t

Return the index of the currently inserted disk image.

retro_set_image_index_t

Insert the disk image at the given index into the emulated drive.

retro_get_num_images_t

Return the number of disk images available to the core.

retro_replace_image_index_t

Replace the disk image at the given index with a new one.

retro_add_image_index_t

Add a new empty slot to the core's internal disk image list.

retro_set_initial_image_t

Set the disk image to insert before content is loaded.

retro_get_image_path_t

Retrieve the filesystem path of a disk image.

retro_get_image_label_t

Retrieve a friendly display label for a disk image.

Classes

retro_disk_control_callback

Corresponds to retro_disk_control_callback in libretro.h.

retro_disk_control_ext_callback

Corresponds to retro_disk_control_ext_callback in libretro.h.

class retro_disk_control_callback[source]

Bases: Structure

Corresponds to retro_disk_control_callback in libretro.h.

A set of callbacks for basic disk image management.

>>> from libretro.api import retro_disk_control_callback
>>> cb = retro_disk_control_callback()
>>> cb.set_eject_state is None
True
set_eject_state

Opens or closes the virtual disk tray.

get_eject_state

Returns the current eject state of the disk tray.

get_image_index

Returns the index of the currently inserted disk image.

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

Selects a disk image by index.

get_num_images

Returns the total number of available disk images.

replace_image_index

Replaces the disk image at the given index.

add_image_index

Adds a new empty disk image slot.

__deepcopy__(_)[source]

Return a copy of this object. Intended for use with copy.deepcopy().

>>> import copy
>>> from libretro.api import retro_disk_control_callback
>>> cb = retro_disk_control_callback()
>>> copy.deepcopy(cb).set_eject_state is None
True
class retro_disk_control_ext_callback[source]

Bases: retro_disk_control_callback

Corresponds to retro_disk_control_ext_callback in libretro.h.

Extends retro_disk_control_callback with additional functions for initial image selection, image paths, and labels.

>>> from libretro.api import retro_disk_control_ext_callback
>>> cb = retro_disk_control_ext_callback()
>>> cb.set_initial_image is None
True
__init__(*args, **kwargs)
classmethod __new__(*args, **kwargs)
add_image_index

Adds a new empty disk image slot.

get_eject_state

Returns the current eject state of the disk tray.

get_image_index

Returns the index of the currently inserted disk image.

get_num_images

Returns the total number of available disk images.

replace_image_index

Replaces the disk image at the given index.

set_eject_state

Opens or closes the virtual disk tray.

set_image_index

Selects a disk image by index.

set_initial_image

Sets the initial disk image to insert at startup. Optional.

get_image_path

Retrieves the filesystem path of a disk image. Optional.

get_image_label

Retrieves the display label of a disk image. Optional.

__deepcopy__(_)[source]

Return a copy of this object. Intended for use with copy.deepcopy().

>>> import copy
>>> from libretro.api import retro_disk_control_ext_callback
>>> cb = retro_disk_control_ext_callback()
>>> copy.deepcopy(cb).set_initial_image is None
True
retro_set_eject_state_t

Open or close the emulated console’s virtual disk tray.

Registered by the core and called by the frontend to swap the disk image currently inserted in the emulated drive. The frontend may only change the disk image index while the tray is open.

Parameters:

ejectedTrue to open the tray, False to close it.

Returns:

True if the tray’s state was changed (or was already in that state), False if the core could not change it.

Corresponds to retro_set_eject_state_t in libretro.h.

retro_get_eject_state_t

Return whether the emulated disk tray is currently open.

Registered by the core and called by the frontend.

Returns:

True if the virtual disk tray is open, False if it is closed.

Corresponds to retro_get_eject_state_t in libretro.h.

retro_get_image_index_t

Return the index of the currently inserted disk image.

Registered by the core and called by the frontend.

Returns:

The index of the inserted disk image (starting at 0), or a value greater than or equal to the result of retro_get_num_images_t if no disk is inserted.

Corresponds to retro_get_image_index_t in libretro.h.

retro_set_image_index_t

Insert the disk image at the given index into the emulated drive.

Registered by the core and called by the frontend. May only be called while the tray is open.

Parameters:

index – Index of the disk image to insert, starting at 0. A value greater than or equal to the result of retro_get_num_images_t represents removing the disk without inserting another.

Returns:

True if the disk image was successfully set, False if the tray is closed or another error occurred.

Corresponds to retro_set_image_index_t in libretro.h.

retro_get_num_images_t

Return the number of disk images available to the core.

Registered by the core and called by the frontend.

Returns:

The number of available disk images.

Corresponds to retro_get_num_images_t in libretro.h.

retro_replace_image_index_t

Replace the disk image at the given index with a new one.

Registered by the core and called by the frontend while the tray is open. Passing None for info removes the image at index from the playlist.

Parameters:
  • index – Index of the disk image to replace.

  • info – Pointer to a retro_game_info describing the new disk image, or None to remove the image at index from the playlist.

Returns:

True if the disk image was successfully replaced or removed, False if the tray is closed or another error occurred.

Corresponds to retro_replace_image_index_t in libretro.h.

retro_add_image_index_t

Add a new empty slot to the core’s internal disk image list.

Registered by the core and called by the frontend. The new slot must be populated with retro_replace_image_index_t before it can be used.

Returns:

True if a new slot was added, False otherwise.

Corresponds to retro_add_image_index_t in libretro.h.

retro_set_initial_image_t

Set the disk image to insert before content is loaded.

Registered by the core and called by the frontend immediately before Core.load_game(), so that the correct disk image from a multi-disk playlist is inserted into the emulated drive.

Parameters:
  • index – Index of the disk image to insert at startup.

  • path – Filesystem path of the disk image to insert, used by the core to validate that index refers to the expected image.

Returns:

True if the initial image was set, False if the arguments are invalid or the core does not support this function.

Corresponds to retro_set_initial_image_t in libretro.h.

retro_get_image_path_t

Retrieve the filesystem path of a disk image.

Registered by the core and called by the frontend.

Parameters:
  • index – Index of the disk image whose path will be returned.

  • path – Buffer that receives the path, written as a bytes string (UTF-8 encoded if applicable).

  • len – Size of the path buffer in bytes.

Returns:

True if a path was successfully written into path, False otherwise.

Corresponds to retro_get_image_path_t in libretro.h.

retro_get_image_label_t

Retrieve a friendly display label for a disk image.

Registered by the core and called by the frontend to obtain a human-readable label that helps the player choose which disk image to insert.

Parameters:
  • index – Index of the disk image whose label will be returned.

  • path – Buffer that receives the label, written as a bytes string.

  • len – Size of the path buffer in bytes.

Returns:

True if a label was successfully written into path, False otherwise.

Corresponds to retro_get_image_label_t in libretro.h.