SDL_Libretro 0.1.0
SDL3-power libretro frontend.
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Enumerations | Functions
SDL_Libretro

Data Structures

struct  SDL_LibretroCategory
 A group of related core options. More...
 
struct  SDL_LibretroOption
 A core option and its current state. More...
 
struct  SDL_LibretroOptionValue
 One selectable value for a core option. More...
 

Macros

#define SDL_EVENT_LIBRETRO   (SDL_EVENT_USER + 0x1000)
 The base SDL event type for SDL_libretro events.
 
#define SDL_EVENT_LIBRETRO_CORE_LOADED   (SDL_EVENT_LIBRETRO | 0xF00)
 A core finished loading; data2 is the core name, valid until the next load or unload.
 
#define SDL_EVENT_LIBRETRO_CORE_UNLOADED   (SDL_EVENT_LIBRETRO | 0xF04)
 The core was unloaded, along with any game it ran.
 
#define SDL_EVENT_LIBRETRO_ENVIRONMENT(cmd)   (SDL_EVENT_LIBRETRO | ((cmd) & 0x3FF) | (((cmd) >> 6) & 0xC00))
 The SDL event type a RETRO_ENVIRONMENT_* command arrives as, when SDL_libretro leaves the command to the application.
 
#define SDL_EVENT_LIBRETRO_ENVIRONMENT_LAST   (SDL_EVENT_LIBRETRO | 0xBFF)
 The last SDL event type an environment command can arrive as.
 
#define SDL_EVENT_LIBRETRO_GAME_LOADED   (SDL_EVENT_LIBRETRO | 0xF01)
 A game finished loading, whether directly or through the menu; data2 is the game name, valid until the next load or unload.
 
#define SDL_EVENT_LIBRETRO_GAME_UNLOADED   (SDL_EVENT_LIBRETRO | 0xF05)
 The game was unloaded, whether directly or through the core unloading.
 
#define SDL_EVENT_LIBRETRO_GEOMETRY_CHANGED   (SDL_EVENT_LIBRETRO | 0xF07)
 The video size, aspect ratio, or timing changed mid-game.
 
#define SDL_EVENT_LIBRETRO_LAST   (SDL_EVENT_LIBRETRO | 0xFFF)
 The last SDL event type in the SDL_libretro range.
 
#define SDL_EVENT_LIBRETRO_MENU_CLOSED   (SDL_EVENT_LIBRETRO | 0xF03)
 The menu was dismissed; the game resumes.
 
#define SDL_EVENT_LIBRETRO_MENU_OPENED   (SDL_EVENT_LIBRETRO | 0xF02)
 The menu became visible; the game pauses.
 
#define SDL_EVENT_LIBRETRO_SHUTDOWN   (SDL_EVENT_LIBRETRO | 0xF06)
 The core requested shutdown.
 
#define SDL_LIBRETRO_ENVIRONMENT_COMMAND(type)   ((((type) - SDL_EVENT_LIBRETRO) & 0x3FF) | ((((type) - SDL_EVENT_LIBRETRO) & 0xC00) << 6))
 The RETRO_ENVIRONMENT_* command, flags included, that an environment event type stands for; the reverse of SDL_EVENT_LIBRETRO_ENVIRONMENT().
 
#define SDL_LIBRETRO_MAJOR_VERSION   0
 The major version of SDL_Libretro.
 
#define SDL_LIBRETRO_MICRO_VERSION   0
 The micro/patch version of SDL_Libretro.
 
#define SDL_LIBRETRO_MINOR_VERSION   1
 The minor version of SDL_Libretro.
 
#define SDL_LIBRETRO_VERSION   SDL_VERSIONNUM(SDL_LIBRETRO_MAJOR_VERSION, SDL_LIBRETRO_MINOR_VERSION, SDL_LIBRETRO_MICRO_VERSION)
 Retrieves an integer representation of the of the SDL_Libretro version.
 
#define SDL_LIBRETRO_VERSION_ATLEAST(X, Y, Z)   (SDL_LIBRETRO_VERSION >= SDL_VERSIONNUM(X, Y, Z))
 Checks if SDL_Libretro is at least the given version.
 

Typedefs

typedef struct SDL_Libretro SDL_Libretro
 A libretro frontend context: one loaded core, its game, and the settings that carry across cores.
 
typedef enum SDL_LibretroAnalogToDigital SDL_LibretroAnalogToDigital
 Which analog stick, if any, also registers D-Pad presses for a controller port.
 
typedef struct SDL_LibretroCategory SDL_LibretroCategory
 A group of related core options.
 
typedef enum SDL_LibretroFitMode SDL_LibretroFitMode
 When rendering the libretro context, determine how to display within the destination.
 
typedef struct SDL_LibretroMenu SDL_LibretroMenu
 An in-app menu built on nuklear_console.
 
typedef void(* SDL_LibretroMenuCallback) (SDL_LibretroMenu *menu, void *userdata)
 A callback for menu entries added by the application.
 
typedef enum SDL_LibretroMenuStyle SDL_LibretroMenuStyle
 Color themes for the menu.
 
typedef struct SDL_LibretroOption SDL_LibretroOption
 A core option and its current state.
 
typedef struct SDL_LibretroOptionValue SDL_LibretroOptionValue
 One selectable value for a core option.
 

Enumerations

enum  SDL_LibretroAnalogToDigital { SDL_LIBRETRO_ANALOG_TO_DIGITAL_NONE = 0 , SDL_LIBRETRO_ANALOG_TO_DIGITAL_LEFT = 1 , SDL_LIBRETRO_ANALOG_TO_DIGITAL_RIGHT = 2 , SDL_LIBRETRO_ANALOG_TO_DIGITAL_COUNT = 3 }
 Which analog stick, if any, also registers D-Pad presses for a controller port. More...
 
enum  SDL_LibretroFitMode {
  SDL_LIBRETRO_FIT_FIRST = 0 , SDL_LIBRETRO_FIT_ASPECT = 0 , SDL_LIBRETRO_FIT_INTEGER = 1 , SDL_LIBRETRO_FIT_STRETCH = 2 ,
  SDL_LIBRETRO_FIT_COUNT = 3
}
 When rendering the libretro context, determine how to display within the destination. More...
 
enum  SDL_LibretroMenuStyle {
  SDL_LIBRETRO_MENU_STYLE_CATPPUCCIN_MOCHA = 0 , SDL_LIBRETRO_MENU_STYLE_CATPPUCCIN_LATTE , SDL_LIBRETRO_MENU_STYLE_CATPPUCCIN_FRAPPE , SDL_LIBRETRO_MENU_STYLE_CATPPUCCIN_MACCHIATO ,
  SDL_LIBRETRO_MENU_STYLE_DRACULA , SDL_LIBRETRO_MENU_STYLE_DARK , SDL_LIBRETRO_MENU_STYLE_COUNT
}
 Color themes for the menu. More...
 

Functions

bool SDL_Libretro_AddDiskImage (SDL_Libretro *lr, const char *path)
 Appends a new disk image from a file path.
 
bool SDL_Libretro_AddDiskImage_IO (SDL_Libretro *lr, SDL_IOStream *src, const char *path, bool closeio)
 Appends a new disk image from an SDL_IOStream.
 
bool SDL_Libretro_AddMenuButton (SDL_LibretroMenu *menu, const char *label, SDL_LibretroMenuCallback callback, void *userdata)
 Adds a button to the main menu, just above Quit.
 
bool SDL_Libretro_AddMenuCheckbox (SDL_LibretroMenu *menu, const char *label, bool *value, SDL_LibretroMenuCallback callback, void *userdata)
 Adds a checkbox to the main menu, just above Quit.
 
bool SDL_Libretro_AreOptionsDirty (SDL_Libretro *lr)
 Retrieves whether the options have been changed since the last time they were checked.
 
SDL_Libretro * SDL_Libretro_Create (void)
 Creates a new libretro context.
 
SDL_LibretroMenu * SDL_Libretro_CreateMenu (SDL_Libretro *lr)
 Creates the in-app menu for a libretro context.
 
SDL_Surface * SDL_Libretro_CreateSurface (const SDL_Libretro *lr)
 Creates a new surface from the current libretro context.
 
bool SDL_Libretro_CycleOptionValue (SDL_Libretro *lr, const char *key, int direction)
 Advance a core option to the next (+1) or previous (-1) value.
 
void SDL_Libretro_Destroy (SDL_Libretro *lr)
 Destroys the given libretro context.
 
void SDL_Libretro_DestroyMenu (SDL_LibretroMenu *menu)
 Destroys a menu created with SDL_Libretro_CreateMenu().
 
bool SDL_Libretro_EjectDisk (SDL_Libretro *lr)
 Ejects the disk tray, allowing the disk image to be changed.
 
SDL_LibretroAnalogToDigital SDL_Libretro_GetAnalogToDigital (const SDL_Libretro *lr, unsigned port)
 Get the analog stick that also registers D-Pad presses on a controller port.
 
float SDL_Libretro_GetAspectRatio (const SDL_Libretro *lr)
 Gets the aspect ratio for the libretro context.
 
unsigned SDL_Libretro_GetAudioLatency (const SDL_Libretro *lr)
 Get the minimum audio latency for the audio stream.
 
bool SDL_Libretro_GetBlockExtract (const SDL_Libretro *lr)
 Retrieves whether the core expects archives to be loaded directly.
 
const SDL_LibretroCategory * SDL_Libretro_GetCategory (const SDL_Libretro *lr, const char *key)
 Retrieve an option category by key.
 
const SDL_LibretroCategory * SDL_Libretro_GetCategoryByIndex (const SDL_Libretro *lr, unsigned index)
 Retrieve an option category by index.
 
unsigned SDL_Libretro_GetCategoryCount (const SDL_Libretro *lr)
 Get the number of option categories registered by the core.
 
const char * SDL_Libretro_GetContentExtension (const SDL_Libretro *lr)
 Get the extension of the loaded content, as it appears in the path.
 
const char * SDL_Libretro_GetCoreAssetsDirectory (SDL_Libretro *lr)
 Get the core assets directory.
 
const char * SDL_Libretro_GetCoreDirectory (SDL_Libretro *lr)
 Get the core directory.
 
const char * SDL_Libretro_GetCoreName (const SDL_Libretro *lr)
 Retrieve the name of the libretro core that's actively loaded.
 
const char * SDL_Libretro_GetCoreVersion (const SDL_Libretro *lr)
 Retrieves the version of the libretro core that's actively loaded.
 
unsigned SDL_Libretro_GetDiskCount (const SDL_Libretro *lr)
 Returns the number of disk images available to the loaded core.
 
unsigned SDL_Libretro_GetDiskIndex (const SDL_Libretro *lr)
 Returns the index of the currently inserted disk image.
 
bool SDL_Libretro_GetDiskLabel (const SDL_Libretro *lr, unsigned index, char *label, size_t len)
 Retrieves the human-readable label of a disk image.
 
size_t SDL_Libretro_GetFileName (char *dst, size_t dstSize, const char *path, bool withExtension)
 Copy the file name portion of a path into a caller-provided buffer.
 
SDL_LibretroFitMode SDL_Libretro_GetFitMode (const SDL_Libretro *lr)
 Gets how the frame is fit into the destination rectangle when rendered.
 
double SDL_Libretro_GetFPS (const SDL_Libretro *lr)
 Gets the frame rate the core expects to run at.
 
const char * SDL_Libretro_GetGameName (const SDL_Libretro *lr)
 Retrieve the human-readable name of the loaded game.
 
bool SDL_Libretro_GetInputDescriptor (const SDL_Libretro *lr, unsigned index, unsigned *port, unsigned *device, unsigned *id, const char **description)
 Retrieve an input descriptor by index.
 
unsigned SDL_Libretro_GetInputDescriptorCount (const SDL_Libretro *lr)
 Retrieve the number of input descriptors provided by a Libretro core.
 
int SDL_Libretro_GetLanguage (const SDL_Libretro *lr)
 Get the language reported to cores through RETRO_ENVIRONMENT_GET_LANGUAGE.
 
SDL_LogPriority SDL_Libretro_GetLogLevel (const SDL_Libretro *lr)
 Retrieve the threshold for logs that will be posted.
 
void * SDL_Libretro_GetMapAddress (const SDL_Libretro *lr, size_t address, size_t *regionRemaining)
 Translate an emulated (guest) address to a live host pointer via the memory map.
 
void * SDL_Libretro_GetMemoryData (const SDL_Libretro *lr, unsigned memoryType, size_t *size)
 Get a pointer to a core memory region and its size.
 
unsigned SDL_Libretro_GetMemoryMapCount (const SDL_Libretro *lr)
 Get the number of memory-map descriptors the core has published.
 
bool SDL_Libretro_GetMemoryMapDescriptor (const SDL_Libretro *lr, unsigned index, Uint64 *flags, void **ptr, size_t *offset, size_t *start, size_t *select, size_t *disconnect, size_t *len, const char **addrspace)
 Retrieve one memory-map descriptor by index.
 
SDL_Libretro * SDL_Libretro_GetMenuLibretro (const SDL_LibretroMenu *menu)
 Gets the libretro context the menu was created for.
 
SDL_LibretroMenuStyle SDL_Libretro_GetMenuStyle (const SDL_LibretroMenu *menu)
 Gets the menu's active color theme.
 
void * SDL_Libretro_GetMenuUserData (const SDL_LibretroMenu *menu)
 Gets the data attached with SDL_Libretro_SetMenuUserData().
 
const char * SDL_Libretro_GetMessage (SDL_Libretro *lr)
 Gets the most relevant libretro message to display from the queue.
 
bool SDL_Libretro_GetMessageByIndex (SDL_Libretro *lr, int index, const char **msg, int *progress, int *type)
 Retrieves all message details for the given message index.
 
unsigned SDL_Libretro_GetMessageCount (SDL_Libretro *lr)
 Gets the number of messages currently in the queue.
 
int SDL_Libretro_GetMessageProgress (SDL_Libretro *lr)
 Gets the progress of the message returned by SDL_Libretro_GetMessage().
 
int SDL_Libretro_GetMessageType (SDL_Libretro *lr)
 Gets the type of the message returned by SDL_Libretro_GetMessage().
 
unsigned SDL_Libretro_GetMousePort (const SDL_Libretro *lr)
 Get the controller port that the mouse drives.
 
const SDL_LibretroOption * SDL_Libretro_GetOption (const SDL_Libretro *lr, const char *key)
 Retrieve details about a given core option.
 
const SDL_LibretroOption * SDL_Libretro_GetOptionByIndex (const SDL_Libretro *lr, unsigned index)
 Retrieve a core option by its registration index.
 
unsigned SDL_Libretro_GetOptionCount (const SDL_Libretro *lr)
 Get the number of core options that have been set.
 
const char * SDL_Libretro_GetOptionValue (SDL_Libretro *lr, const char *key)
 Get a core option's current value.
 
const char * SDL_Libretro_GetOptionValueLabel (SDL_Libretro *lr, const char *key)
 Get the human-readable label for a core option's current value.
 
unsigned SDL_Libretro_GetPerformanceLevel (const SDL_Libretro *lr)
 Get the performance level the core requested via SET_PERFORMANCE_LEVEL.
 
unsigned SDL_Libretro_GetPortDevice (const SDL_Libretro *lr, unsigned port)
 Get the device type assigned to a controller port.
 
SDL_Renderer * SDL_Libretro_GetRenderer (const SDL_Libretro *lr)
 Get the renderer the context draws into.
 
bool SDL_Libretro_GetRewindEnabled (const SDL_Libretro *lr)
 Check whether the rewind system is enabled (independent of current direction).
 
size_t SDL_Libretro_GetRewindMemoryLimit (const SDL_Libretro *lr)
 Get the current rewind memory budget in bytes (0 if unbounded).
 
size_t SDL_Libretro_GetRewindMemoryUsage (const SDL_Libretro *lr)
 Get the approximate memory currently held by the rewind buffer, in bytes.
 
double SDL_Libretro_GetRewindRemaining (const SDL_Libretro *lr)
 Calculates the amount of rewind time remaining in the buffer.
 
int SDL_Libretro_GetRotation (const SDL_Libretro *lr)
 Gets the screen rotation requested by the core.
 
double SDL_Libretro_GetSampleRate (const SDL_Libretro *lr)
 Get the audio sample rate the loaded core outputs at.
 
const char * SDL_Libretro_GetSaveDirectory (SDL_Libretro *lr)
 Get the save directory.
 
size_t SDL_Libretro_GetSavePath (const SDL_Libretro *lr, const char *extension, char *dst, size_t dstSize)
 Build a path in the save directory for the currently loaded content.
 
enum retro_savestate_context SDL_Libretro_GetSavestateContext (const SDL_Libretro *lr)
 Get the savestate context reported to cores through RETRO_ENVIRONMENT_GET_SAVESTATE_CONTEXT.
 
SDL_ScaleMode SDL_Libretro_GetScaleMode (const SDL_Libretro *lr)
 Gets the texture scale mode used when the libretro frame is scaled.
 
void SDL_Libretro_GetSize (const SDL_Libretro *lr, int *w, int *h)
 Gets the width and height of the core's current video frame.
 
float SDL_Libretro_GetSpeed (const SDL_Libretro *lr)
 Get how fast the game runs, as a multiple of its normal speed.
 
bool SDL_Libretro_GetSRAMAutoSave (const SDL_Libretro *lr)
 Check whether SRAM is loaded and saved along with the game.
 
size_t SDL_Libretro_GetStateSize (const SDL_Libretro *lr)
 Retrieves the size of serialized states.
 
const char * SDL_Libretro_GetSystemDirectory (SDL_Libretro *lr)
 Get the system directory.
 
SDL_Texture * SDL_Libretro_GetTexture (const SDL_Libretro *lr)
 Get the streaming texture that holds the core's most recent video frame.
 
const char * SDL_Libretro_GetUsername (SDL_Libretro *lr)
 Get the username reported to cores.
 
const char * SDL_Libretro_GetValidExtensions (const SDL_Libretro *lr)
 Gets the default set of valid extensions associated with the core, seperated by a "|".
 
int SDL_Libretro_GetVersion (void)
 Get the version of SDL_libretro the implementation was compiled with.
 
float SDL_Libretro_GetVolume (const SDL_Libretro *lr)
 Get the audio volume.
 
void SDL_Libretro_HandleEvent (SDL_Libretro *lr, const SDL_Event *event)
 Call this function within the SDL_PollEvent() loop to ensure libretro knows of important events.
 
bool SDL_Libretro_HandleMenuEvent (SDL_LibretroMenu *menu, const SDL_Event *event)
 Routes an event to the menu; call this for every event, before SDL_Libretro_HandleEvent().
 
bool SDL_Libretro_InitConfig (SDL_Libretro *lr, const char *org, const char *app)
 Sets up the config file to be the default path, accoring to the organization and app name.
 
bool SDL_Libretro_InitConfigFile (SDL_Libretro *lr, const char *file)
 Initializes the config system based on the given file.
 
bool SDL_Libretro_InsertDisk (SDL_Libretro *lr)
 Closes the disk tray after a disk change.
 
bool SDL_Libretro_IsCoreReady (const SDL_Libretro *lr)
 Indicates whether a core is loaded.
 
bool SDL_Libretro_IsFastforwardOverrideActive (const SDL_Libretro *lr)
 Indicates whether the core is forcing fast-forward through RETRO_ENVIRONMENT_SET_FASTFORWARDING_OVERRIDE.
 
bool SDL_Libretro_IsGameReady (const SDL_Libretro *lr)
 Indicates whether a game is loaded and running.
 
bool SDL_Libretro_IsGameRequired (const SDL_Libretro *lr)
 Indicates whether the loaded core needs content to run.
 
bool SDL_Libretro_IsMenuOpen (const SDL_LibretroMenu *menu)
 Checks whether the menu is currently shown.
 
bool SDL_Libretro_LoadCore (SDL_Libretro *lr, const char *core)
 Loads a libretro core.
 
bool SDL_Libretro_LoadGame (SDL_Libretro *lr, const char *gamePath)
 Loads a game at the given path.
 
bool SDL_Libretro_LoadGame_IO (SDL_Libretro *lr, SDL_IOStream *src, const char *path, bool closeio)
 Loads a game from an SDL_IOStream.
 
bool SDL_Libretro_LoadGameSpecial (SDL_Libretro *lr, const char *subsystem, const char **paths, unsigned numPaths)
 Loads multi-ROM subsystem content (e.g.
 
bool SDL_Libretro_LoadGameSpecialById (SDL_Libretro *lr, unsigned subsystemId, const char **paths, unsigned numPaths)
 Load multi-ROM subsystem content by its numeric subsystem id.
 
bool SDL_Libretro_LoadMemory (SDL_Libretro *lr, unsigned memoryType, const char *file)
 Load a core memory region from a file.
 
bool SDL_Libretro_LoadMemory_IO (SDL_Libretro *lr, unsigned memoryType, SDL_IOStream *src, bool closeio)
 Load a core memory region from a stream.
 
bool SDL_Libretro_LoadSRAM (SDL_Libretro *lr, const char *file)
 Loads the SRAM from the given file.
 
bool SDL_Libretro_LoadSRAM_IO (SDL_Libretro *lr, SDL_IOStream *src, bool closeio)
 Load the core's battery-backed save RAM from a stream.
 
bool SDL_Libretro_LoadState (SDL_Libretro *lr, const char *file)
 Loads the libretro state from the given file.
 
bool SDL_Libretro_LoadState_IO (SDL_Libretro *lr, SDL_IOStream *src, bool closeio)
 Load a libretro state from the given SDL_IOStream.
 
void SDL_Libretro_MenuScreenshotClicked (SDL_LibretroMenu *menu, void *userdata)
 A ready-made menu callback that saves a PNG screenshot of the current frame, reporting the result in the menu.
 
bool SDL_Libretro_OpenMenuPath (SDL_LibretroMenu *menu, const char *path)
 Opens the menu and navigates to a page by its slash-separated label path, e.g.
 
bool SDL_Libretro_PhysFS_Init (SDL_Libretro *lr)
 Initialize PhysFS and route the libretro VFS through it.
 
bool SDL_Libretro_PhysFS_LoadGame (SDL_Libretro *lr, const char *gamePath)
 Archive-aware replacement for SDL_Libretro_LoadGame().
 
void SDL_Libretro_PhysFS_Quit (SDL_Libretro *lr)
 Tear down PhysFS, unmounting any active archive and restoring the plain SDL VFS on the given context.
 
bool SDL_Libretro_Render (SDL_Libretro *lr, SDL_Renderer *renderer, const SDL_FRect *dstRect)
 Render the libretro context in the given renderer.
 
void SDL_Libretro_RenderMenu (SDL_LibretroMenu *menu)
 Draws the menu laid out by SDL_Libretro_UpdateMenu() to the renderer.
 
bool SDL_Libretro_Reset (SDL_Libretro *lr)
 Resets the loaded game, like pressing the console's reset button.
 
void SDL_Libretro_ResetAllOptions (SDL_Libretro *lr)
 Reset every core option to its default value.
 
void SDL_Libretro_ResetCheats (SDL_Libretro *lr)
 Clears all cheats that were set on the core.
 
bool SDL_Libretro_ResetOption (SDL_Libretro *lr, const char *key)
 Reset a core option to its default value.
 
bool SDL_Libretro_SaveMemory (SDL_Libretro *lr, unsigned memoryType, const char *file)
 Write a core memory region to a file.
 
bool SDL_Libretro_SaveMemory_IO (SDL_Libretro *lr, unsigned memoryType, SDL_IOStream *dst, bool closeio)
 Write a core memory region to a stream.
 
bool SDL_Libretro_SaveScreenshot (const SDL_Libretro *lr, const char *path)
 Saves a PNG screenshot of the current frame.
 
bool SDL_Libretro_SaveSRAM (SDL_Libretro *lr, const char *file)
 Saves the current SRAM to the given file.
 
bool SDL_Libretro_SaveSRAM_IO (SDL_Libretro *lr, SDL_IOStream *dst, bool closeio)
 Write the core's battery-backed save RAM to a stream.
 
bool SDL_Libretro_SaveState (SDL_Libretro *lr, const char *file)
 Saves the current libretro state to a file.
 
bool SDL_Libretro_SaveState_IO (SDL_Libretro *lr, SDL_IOStream *dst, bool closeio)
 Save the current libretro state to the given SDL_IOStream.
 
void SDL_Libretro_SetAnalogToDigital (SDL_Libretro *lr, unsigned port, SDL_LibretroAnalogToDigital stick)
 Selects which analog stick, if any, also registers D-Pad presses on the given controller port, alongside the physical D-Pad.
 
void SDL_Libretro_SetAudioLatency (SDL_Libretro *lr, unsigned latencyMs)
 Set the desired minimum audio latency for the audio stream.
 
bool SDL_Libretro_SetCheat (SDL_Libretro *lr, unsigned index, bool enabled, const char *code)
 Set a cheat code either enabled or disabled within the libretro context.
 
bool SDL_Libretro_SetCoreAssetsDirectory (SDL_Libretro *lr, const char *path)
 Sets where cores look for their assets, reported through RETRO_ENVIRONMENT_GET_CORE_ASSETS_DIRECTORY.
 
bool SDL_Libretro_SetCoreDirectory (SDL_Libretro *lr, const char *path)
 Sets the associated libretro core directory, where the default set of cores will be loaded from.
 
bool SDL_Libretro_SetDiskIndex (SDL_Libretro *lr, unsigned index)
 Sets the disk image index to insert into the emulated drive.
 
bool SDL_Libretro_SetFitMode (SDL_Libretro *lr, SDL_LibretroFitMode mode)
 Sets how the frame is fit into the destination rectangle when rendered.
 
void SDL_Libretro_SetGamepadMapping (SDL_Libretro *lr, unsigned port, int retroButton, SDL_GamepadButton button)
 Maps an SDL gamepad button to a RETRO_DEVICE_ID_JOYPAD_* button on the given controller port.
 
bool SDL_Libretro_SetInitialDisk (SDL_Libretro *lr, unsigned index, const char *path)
 Sets the disk image to insert once content is loaded.
 
void SDL_Libretro_SetKeyboardMapping (SDL_Libretro *lr, int retroButton, SDL_Scancode scancode)
 Maps a keyboard key to a RETRO_DEVICE_ID_JOYPAD_* button for Player 1 (controller port 0).
 
void SDL_Libretro_SetLanguage (SDL_Libretro *lr, int language)
 Override the language reported to cores through RETRO_ENVIRONMENT_GET_LANGUAGE.
 
void SDL_Libretro_SetLogLevel (SDL_Libretro *lr, SDL_LogPriority level)
 Sets the threshold for logs to be posted.
 
bool SDL_Libretro_SetMemoryData (SDL_Libretro *lr, unsigned memoryType, const void *data, size_t size)
 Overwrite a core memory region with caller-provided bytes.
 
void SDL_Libretro_SetMenuOpen (SDL_LibretroMenu *menu, bool open)
 Opens or closes the menu.
 
bool SDL_Libretro_SetMenuStyle (SDL_LibretroMenu *menu, SDL_LibretroMenuStyle style)
 Applies a color theme to the menu.
 
void SDL_Libretro_SetMenuUserData (SDL_LibretroMenu *menu, void *userData)
 Attaches generic application data to the menu.
 
void SDL_Libretro_SetMessage (SDL_Libretro *lr, const char *msg, double duration)
 Add a message to be displayed within the libretro context.
 
void SDL_Libretro_SetMousePort (SDL_Libretro *lr, unsigned port)
 Selects the one controller port that the mouse drives.
 
bool SDL_Libretro_SetOptionValue (SDL_Libretro *lr, const char *key, const char *value)
 Set a core option's value; fails if the value isn't one the core declared.
 
bool SDL_Libretro_SetPortDevice (SDL_Libretro *lr, unsigned port, unsigned device)
 Assign a device type to a controller port.
 
bool SDL_Libretro_SetRenderer (SDL_Libretro *lr, SDL_Renderer *renderer)
 Set the renderer the libretro context draws into.
 
bool SDL_Libretro_SetRewindEnabled (SDL_Libretro *lr, bool enabled, unsigned bufferFrames, unsigned captureInterval)
 Enable or disable the rewind system.
 
bool SDL_Libretro_SetRewindMemoryDuration (SDL_Libretro *lr, double seconds)
 Set the rewind memory budget by target duration instead of raw bytes.
 
void SDL_Libretro_SetRewindMemoryLimit (SDL_Libretro *lr, size_t maxBytes)
 Set the maximum number of bytes of encoded delta history to retain.
 
bool SDL_Libretro_SetSaveDirectory (SDL_Libretro *lr, const char *path)
 Sets where content will be saved.
 
void SDL_Libretro_SetSavestateContext (SDL_Libretro *lr, enum retro_savestate_context context)
 Sets the savestate context reported to cores through RETRO_ENVIRONMENT_GET_SAVESTATE_CONTEXT.
 
bool SDL_Libretro_SetScaleMode (SDL_Libretro *lr, SDL_ScaleMode mode)
 Sets the texture scale mode used when the libretro frame is scaled.
 
void SDL_Libretro_SetSpeed (SDL_Libretro *lr, float speed)
 Sets how fast the game runs, as a multiple of its normal speed.
 
void SDL_Libretro_SetSRAMAutoSave (SDL_Libretro *lr, bool enabled)
 Load and save the core's battery-backed save RAM along with the game.
 
bool SDL_Libretro_SetSystemDirectory (SDL_Libretro *lr, const char *path)
 Sets where cores look for system files (BIOS, firmware, etc).
 
bool SDL_Libretro_SetUsername (SDL_Libretro *lr, const char *username)
 Sets the username reported to cores through RETRO_ENVIRONMENT_GET_USERNAME.
 
void SDL_Libretro_SetVFS (SDL_Libretro *lr, void *vfs)
 Set the Virtual File System the core uses for file access.
 
void SDL_Libretro_SetVirtualButton (SDL_Libretro *lr, unsigned port, int button, bool pressed)
 Press or release a joypad button from code, such as from an on-screen touch control.
 
void SDL_Libretro_SetVolume (SDL_Libretro *lr, float volume)
 Set the audio volume when playing sounds.
 
bool SDL_Libretro_ShouldQuit (const SDL_Libretro *lr)
 Indicates whether or not the core has requested to shutdown.
 
void SDL_Libretro_ToggleMenu (SDL_LibretroMenu *menu)
 Opens the menu when it is closed, or closes it when it is open.
 
void SDL_Libretro_UnloadCore (SDL_Libretro *lr)
 Unloads the actively loaded core.
 
void SDL_Libretro_UnloadGame (SDL_Libretro *lr)
 Unloads the actively loaded game.
 
void SDL_Libretro_Update (SDL_Libretro *lr)
 Runs the loaded game; call it once per frame of the application's loop.
 
void SDL_Libretro_UpdateMenu (SDL_LibretroMenu *menu)
 Processes input and lays out the menu for this frame.
 
bool SDL_Libretro_UpdateOptionVisibility (SDL_Libretro *lr)
 Ask the core to refresh which of its options should be displayed.
 

Detailed Description

Macro Definition Documentation

◆ SDL_EVENT_LIBRETRO

#define SDL_EVENT_LIBRETRO   (SDL_EVENT_USER + 0x1000)

The base SDL event type for SDL_libretro events.

SDL_libretro reports everything through the SDL event queue as SDL_UserEvent, with event->user.data1 the SDL_Libretro* that sent it.

Environment commands the library doesn't handle itself arrive as SDL_EVENT_LIBRETRO_ENVIRONMENT(RETRO_ENVIRONMENT_*), with the data pointer the core passed in event->user.data2.

The data pointer is only valid while the core waits inside the environment call, so to implement a command, handle the event from an SDL_AddEventWatch() callback — watches run synchronously during the push — and set event->user.code to a non-zero value there to tell the core the command succeeded. An SDL_SetEventFilter() filter can claim the same way, and may return false to drop the event. A claimed command is consumed and doesn't also reach the event queue; unclaimed commands arrive there once, with the data pointer already expired. user.reserved is used internally to tell queued copies of the same command apart.

The range is a fixed offset into the SDL user events, so the types work as case labels. The first SDL_Libretro_Create() in a process reserves SDL_EVENT_LIBRETRO through SDL_EVENT_LIBRETRO_LAST with SDL_RegisterEvents(), so events the application registers afterwards land past it. Applications registering events before then should keep below SDL_EVENT_LIBRETRO; a warning is logged when they've reached into it.

Definition at line 255 of file SDL_libretro.h.

◆ SDL_EVENT_LIBRETRO_CORE_LOADED

#define SDL_EVENT_LIBRETRO_CORE_LOADED   (SDL_EVENT_LIBRETRO | 0xF00)

A core finished loading; data2 is the core name, valid until the next load or unload.

See also
SDL_Libretro_GetCoreName()

Definition at line 300 of file SDL_libretro.h.

◆ SDL_EVENT_LIBRETRO_ENVIRONMENT

#define SDL_EVENT_LIBRETRO_ENVIRONMENT (   cmd)    (SDL_EVENT_LIBRETRO | ((cmd) & 0x3FF) | (((cmd) >> 6) & 0xC00))

The SDL event type a RETRO_ENVIRONMENT_* command arrives as, when SDL_libretro leaves the command to the application.

The command number takes the low ten bits, and the RETRO_ENVIRONMENT_EXPERIMENTAL and RETRO_ENVIRONMENT_PRIVATE flags each get a bit of their own, so commands that share a number, like RETRO_ENVIRONMENT_SET_SERIALIZATION_QUIRKS and the experimental RETRO_ENVIRONMENT_SET_HW_SHARED_CONTEXT, stay apart. Plain commands come out as SDL_EVENT_LIBRETRO | RETRO_ENVIRONMENT_*. It's a constant expression, so it works as a case label:

case SDL_EVENT_LIBRETRO_ENVIRONMENT(RETRO_ENVIRONMENT_GET_CAMERA_INTERFACE):

Commands numbered 0x400 and up, or carrying both flags, aren't reported.

See also
SDL_LIBRETRO_ENVIRONMENT_COMMAND()
SDL_EVENT_LIBRETRO_ENVIRONMENT_LAST

Definition at line 282 of file SDL_libretro.h.

◆ SDL_EVENT_LIBRETRO_ENVIRONMENT_LAST

#define SDL_EVENT_LIBRETRO_ENVIRONMENT_LAST   (SDL_EVENT_LIBRETRO | 0xBFF)

The last SDL event type an environment command can arrive as.

Events from SDL_EVENT_LIBRETRO to here are environment commands.

See also
SDL_EVENT_LIBRETRO_ENVIRONMENT()

Definition at line 290 of file SDL_libretro.h.

◆ SDL_EVENT_LIBRETRO_GAME_LOADED

#define SDL_EVENT_LIBRETRO_GAME_LOADED   (SDL_EVENT_LIBRETRO | 0xF01)

A game finished loading, whether directly or through the menu; data2 is the game name, valid until the next load or unload.

See also
SDL_Libretro_GetGameName()

Definition at line 301 of file SDL_libretro.h.

◆ SDL_EVENT_LIBRETRO_GEOMETRY_CHANGED

#define SDL_EVENT_LIBRETRO_GEOMETRY_CHANGED   (SDL_EVENT_LIBRETRO | 0xF07)

The video size, aspect ratio, or timing changed mid-game.

See also
SDL_Libretro_GetSize()

Definition at line 307 of file SDL_libretro.h.

◆ SDL_EVENT_LIBRETRO_LAST

#define SDL_EVENT_LIBRETRO_LAST   (SDL_EVENT_LIBRETRO | 0xFFF)

The last SDL event type in the SDL_libretro range.

Every SDL_libretro event falls within SDL_EVENT_LIBRETRO to SDL_EVENT_LIBRETRO_LAST.

Definition at line 261 of file SDL_libretro.h.

◆ SDL_EVENT_LIBRETRO_MENU_CLOSED

#define SDL_EVENT_LIBRETRO_MENU_CLOSED   (SDL_EVENT_LIBRETRO | 0xF03)

The menu was dismissed; the game resumes.

data2 is the SDL_LibretroMenu.

Definition at line 303 of file SDL_libretro.h.

◆ SDL_EVENT_LIBRETRO_MENU_OPENED

#define SDL_EVENT_LIBRETRO_MENU_OPENED   (SDL_EVENT_LIBRETRO | 0xF02)

The menu became visible; the game pauses.

data2 is the SDL_LibretroMenu.

Definition at line 302 of file SDL_libretro.h.

◆ SDL_EVENT_LIBRETRO_SHUTDOWN

#define SDL_EVENT_LIBRETRO_SHUTDOWN   (SDL_EVENT_LIBRETRO | 0xF06)

The core requested shutdown.

See also
SDL_Libretro_ShouldQuit()

Definition at line 306 of file SDL_libretro.h.

◆ SDL_LIBRETRO_ENVIRONMENT_COMMAND

#define SDL_LIBRETRO_ENVIRONMENT_COMMAND (   type)    ((((type) - SDL_EVENT_LIBRETRO) & 0x3FF) | ((((type) - SDL_EVENT_LIBRETRO) & 0xC00) << 6))

The RETRO_ENVIRONMENT_* command, flags included, that an environment event type stands for; the reverse of SDL_EVENT_LIBRETRO_ENVIRONMENT().

See also
SDL_EVENT_LIBRETRO_ENVIRONMENT()

Definition at line 298 of file SDL_libretro.h.

◆ SDL_LIBRETRO_MAJOR_VERSION

#define SDL_LIBRETRO_MAJOR_VERSION   0

The major version of SDL_Libretro.

See also
SDL_LIBRETRO_VERSION
SDL_LIBRETRO_VERSION_ATLEAST

Definition at line 53 of file SDL_libretro.h.

◆ SDL_LIBRETRO_MICRO_VERSION

#define SDL_LIBRETRO_MICRO_VERSION   0

The micro/patch version of SDL_Libretro.

See also
SDL_LIBRETRO_VERSION
SDL_LIBRETRO_VERSION_ATLEAST

Definition at line 69 of file SDL_libretro.h.

◆ SDL_LIBRETRO_MINOR_VERSION

#define SDL_LIBRETRO_MINOR_VERSION   1

The minor version of SDL_Libretro.

See also
SDL_LIBRETRO_VERSION
SDL_LIBRETRO_VERSION_ATLEAST

Definition at line 61 of file SDL_libretro.h.

Typedef Documentation

◆ SDL_Libretro

typedef struct SDL_Libretro SDL_Libretro

A libretro frontend context: one loaded core, its game, and the settings that carry across cores.

Treat it as an opaque handle. It is created with SDL_Libretro_Create() and freed with SDL_Libretro_Destroy(). Its fields are only visible in the translation unit that defines SDL_LIBRETRO_IMPLEMENTATION, and they are implementation details that may change at any time; applications should only use the SDL_Libretro_* functions to read or change its state.

See also
SDL_Libretro_Create()

Definition at line 93 of file SDL_libretro.h.

◆ SDL_LibretroAnalogToDigital

Which analog stick, if any, also registers D-Pad presses for a controller port.

See also
SDL_Libretro_SetAnalogToDigital()

◆ SDL_LibretroMenu

typedef struct SDL_LibretroMenu SDL_LibretroMenu

An in-app menu built on nuklear_console.

Only available when the implementation is compiled with SDL_LIBRETRO_ENABLE_MENU.

See also
SDL_Libretro_CreateMenu()

Definition at line 468 of file SDL_libretro.h.

◆ SDL_LibretroMenuCallback

typedef void(* SDL_LibretroMenuCallback) (SDL_LibretroMenu *menu, void *userdata)

A callback for menu entries added by the application.

See also
SDL_Libretro_AddMenuButton()
SDL_Libretro_AddMenuCheckbox()

Definition at line 506 of file SDL_libretro.h.

◆ SDL_LibretroMenuStyle

Color themes for the menu.

See also
SDL_Libretro_SetMenuStyle()

Enumeration Type Documentation

◆ SDL_LibretroAnalogToDigital

Which analog stick, if any, also registers D-Pad presses for a controller port.

See also
SDL_Libretro_SetAnalogToDigital()
Enumerator
SDL_LIBRETRO_ANALOG_TO_DIGITAL_NONE 

Only the D-Pad drives the retro joypad's directions.

SDL_LIBRETRO_ANALOG_TO_DIGITAL_LEFT 

The left analog stick also registers D-Pad presses.

SDL_LIBRETRO_ANALOG_TO_DIGITAL_RIGHT 

The right analog stick also registers D-Pad presses.

SDL_LIBRETRO_ANALOG_TO_DIGITAL_COUNT 

The number of possible modes.

Definition at line 111 of file SDL_libretro.h.

◆ SDL_LibretroFitMode

When rendering the libretro context, determine how to display within the destination.

Enumerator
SDL_LIBRETRO_FIT_FIRST 

The default fit mode to fit within the destination.

SDL_LIBRETRO_FIT_ASPECT 

Keep the same aspect ratio, and fit within the confines of the destination.

SDL_LIBRETRO_FIT_INTEGER 

Keep the same aspect ratio, while keeping integer scaling within the confines of the destination.

SDL_LIBRETRO_FIT_STRETCH 

Ignore the aspect ratio, and stretch the image to match the destination rectangle.

SDL_LIBRETRO_FIT_COUNT 

The number of possible fit modes.

Definition at line 98 of file SDL_libretro.h.

◆ SDL_LibretroMenuStyle

Color themes for the menu.

See also
SDL_Libretro_SetMenuStyle()
Enumerator
SDL_LIBRETRO_MENU_STYLE_CATPPUCCIN_MOCHA 

Catppuccin Mocha, the darkest Catppuccin flavor.

The default style.

SDL_LIBRETRO_MENU_STYLE_CATPPUCCIN_LATTE 

Catppuccin Latte, the light Catppuccin flavor.

SDL_LIBRETRO_MENU_STYLE_CATPPUCCIN_FRAPPE 

Catppuccin Frappe, a muted dark Catppuccin flavor.

SDL_LIBRETRO_MENU_STYLE_CATPPUCCIN_MACCHIATO 

Catppuccin Macchiato, a dark Catppuccin flavor between Frappe and Mocha.

SDL_LIBRETRO_MENU_STYLE_DRACULA 

The Dracula dark theme.

SDL_LIBRETRO_MENU_STYLE_DARK 

Nuklear's built-in default dark style.

SDL_LIBRETRO_MENU_STYLE_COUNT 

The number of menu styles.

Definition at line 475 of file SDL_libretro.h.

Function Documentation

◆ SDL_Libretro_AddDiskImage()

bool SDL_Libretro_AddDiskImage ( SDL_Libretro *  lr,
const char *  path 
)

Appends a new disk image from a file path.

The disk tray must be ejected before calling this function. Like SDL_Libretro_LoadGame(), need_fullpath handling is picked by the path's extension: a core that needs a full path gets just path, otherwise the file is read and the core gets its bytes along with path. The buffer is kept until the game unloads. If the core rejects the image, the slot added for it is removed again.

Parameters
lrThe libretro instance.
pathFile path to the disk image.
Returns
true on success, false on failure.
See also
SDL_Libretro_AddDiskImage_IO()

Definition at line 237 of file SDL_libretro_serialize.h.

References SDL_Libretro_AddDiskImage_IO(), and SDL_Libretro_IsGameReady().

◆ SDL_Libretro_AddDiskImage_IO()

bool SDL_Libretro_AddDiskImage_IO ( SDL_Libretro *  lr,
SDL_IOStream *  src,
const char *  path,
bool  closeio 
)

Appends a new disk image from an SDL_IOStream.

The disk tray must be ejected before calling this function. The path is the path the image is known by (e.g. a virtual path inside an archive); it picks need_fullpath handling by its extension and is passed to the core. When the core needs a full path, the stream is spilled to the temp directory and that file is passed instead. Otherwise the bytes are passed along with path. Either way, the file or buffer is kept until the game unloads. If the core rejects the image, the slot added for it is removed again.

Parameters
lrThe libretro instance.
srcIOStream containing the disk image data.
pathThe path the disk image is known by.
closeioIf true, close src before returning, even on failure.
Returns
true on success, false on failure.
See also
SDL_Libretro_LoadGame_IO()

Definition at line 280 of file SDL_libretro_serialize.h.

References SDL_Libretro_IsGameReady().

Referenced by SDL_Libretro_AddDiskImage().

◆ SDL_Libretro_AddMenuButton()

bool SDL_Libretro_AddMenuButton ( SDL_LibretroMenu *  menu,
const char *  label,
SDL_LibretroMenuCallback  callback,
void *  userdata 
)

Adds a button to the main menu, just above Quit.

The menu copies the label and frees the button in SDL_Libretro_DestroyMenu().

Parameters
menuthe menu to add to.
labelthe button text.
callbackcalled when the button is clicked, or NULL.
userdatapassed to the callback.
Returns
true on success, false when menu or label is NULL or the button could not be created; call SDL_GetError() for more information.
See also
SDL_Libretro_AddMenuCheckbox()
SDL_Libretro_MenuScreenshotClicked()

Definition at line 2894 of file SDL_libretro_menu.h.

◆ SDL_Libretro_AddMenuCheckbox()

bool SDL_Libretro_AddMenuCheckbox ( SDL_LibretroMenu *  menu,
const char *  label,
bool *  value,
SDL_LibretroMenuCallback  callback,
void *  userdata 
)

Adds a checkbox to the main menu, just above Quit.

The checkbox starts from the current value, and the value pointer is written on every toggle, so it must outlive the menu. The menu copies the label and frees the checkbox in SDL_Libretro_DestroyMenu().

Parameters
menuthe menu to add to.
labelthe checkbox text.
valuethe bool the checkbox mirrors, or NULL to keep the state internal.
callbackcalled after each toggle, once value is updated, or NULL.
userdatapassed to the callback.
Returns
true on success, false when menu or label is NULL or the checkbox could not be created; call SDL_GetError() for more information.
See also
SDL_Libretro_AddMenuButton()

Definition at line 2921 of file SDL_libretro_menu.h.

◆ SDL_Libretro_AreOptionsDirty()

bool SDL_Libretro_AreOptionsDirty ( SDL_Libretro *  lr)

Retrieves whether the options have been changed since the last time they were checked.

Checking clears the flag, so the next call returns false until an option changes again. Useful to know when to persist options.

Parameters
lrthe libretro context.
Returns
true if an option changed since the last call, false otherwise.

Definition at line 469 of file SDL_libretro_options.h.

◆ SDL_Libretro_Create()

SDL_Libretro * SDL_Libretro_Create ( void  )

Creates a new libretro context.

The context starts with default settings: full volume, normal speed, the default keyboard and gamepad mappings, and "SDL_libretro" as the username. The first call in a process also reserves the SDL_EVENT_LIBRETRO event range. Only one context can have a core loaded at a time.

Returns
the new context, or NULL on allocation failure; call SDL_GetError() for more information. Free it with SDL_Libretro_Destroy().
See also
SDL_Libretro_Destroy()
SDL_Libretro_LoadCore()

Definition at line 95 of file SDL_libretro_core.h.

References SDL_LIBRETRO_MAX_USERS, SDL_LIBRETRO_REWIND_DEFAULT_MAX_BYTES, SDL_Libretro_SetLanguage(), SDL_Libretro_SetSpeed(), SDL_Libretro_SetUsername(), SDL_Libretro_SetVFS(), and SDL_Libretro_SetVolume().

◆ SDL_Libretro_CreateMenu()

SDL_LibretroMenu * SDL_Libretro_CreateMenu ( SDL_Libretro *  lr)

Creates the in-app menu for a libretro context.

Sets up Nuklear on the context's window and renderer, restores the menu's persisted settings (style, UI scale, volume, and the like) from the config, and builds the menu pages. The menu starts closed, but SDL_Libretro_UpdateMenu() opens it whenever no game is running.

Requires the implementation to be compiled with SDL_LIBRETRO_ENABLE_MENU. Each frame, route events through SDL_Libretro_HandleMenuEvent(), then call SDL_Libretro_UpdateMenu() and SDL_Libretro_RenderMenu() after rendering the game and before presenting.

Parameters
lrthe libretro context. SDL_Libretro_SetRenderer() must have been called on it first, and it must outlive the menu.
Returns
the new menu, or NULL on failure; call SDL_GetError() for more information. Free it with SDL_Libretro_DestroyMenu().
See also
SDL_Libretro_DestroyMenu()
SDL_Libretro_UpdateMenu()
SDL_Libretro_RenderMenu()
SDL_Libretro_HandleMenuEvent()

Definition at line 2369 of file SDL_libretro_menu.h.

◆ SDL_Libretro_CreateSurface()

SDL_Surface * SDL_Libretro_CreateSurface ( const SDL_Libretro *  lr)

Creates a new surface from the current libretro context.

The frame is copied at its native size, unscaled and unrotated. The Surface must be destroyed after use with SDL_DestroySurface().

Parameters
lrthe libretro context.
Returns
a new surface holding the current frame, or NULL if there is no frame or renderer yet, or if reading the pixels back failed.
See also
SDL_Libretro_SaveScreenshot()

Definition at line 201 of file SDL_libretro_video.h.

Referenced by SDL_Libretro_SaveScreenshot().

◆ SDL_Libretro_CycleOptionValue()

bool SDL_Libretro_CycleOptionValue ( SDL_Libretro *  lr,
const char *  key,
int  direction 
)

Advance a core option to the next (+1) or previous (-1) value.

Wraps around at either end of the option's declared values.

Parameters
lrthe libretro context.
keythe option's key.
directiona positive number for the next value, or a negative number for the previous value.
Returns
true on success, false if direction is 0, there's no such option, or it has no declared values.
See also
SDL_Libretro_SetOptionValue()

Definition at line 388 of file SDL_libretro_options.h.

References SDL_Libretro_GetOption(), SDL_Libretro_SetOptionValue(), SDL_LibretroOptionValue::value, SDL_LibretroOption::value, SDL_LibretroOption::values, and SDL_LibretroOption::valuesCount.

◆ SDL_Libretro_Destroy()

void SDL_Libretro_Destroy ( SDL_Libretro *  lr)

Destroys the given libretro context.

Will also unload the active game and core if needed, save the config set up with SDL_Libretro_InitConfig(), and drop any SDL_libretro events still in the queue, since they point into the context.

Parameters
lrthe libretro context to destroy. NULL is ignored.
See also
SDL_Libretro_Create()

Definition at line 150 of file SDL_libretro_core.h.

References SDL_EVENT_LIBRETRO, SDL_EVENT_LIBRETRO_LAST, SDL_LIBRETRO_MAX_USERS, SDL_Libretro_PhysFS_Quit(), SDL_Libretro_UnloadCore(), and SDL_Libretro_UnloadGame().

◆ SDL_Libretro_DestroyMenu()

void SDL_Libretro_DestroyMenu ( SDL_LibretroMenu *  menu)

Destroys a menu created with SDL_Libretro_CreateMenu().

Writes any changed menu settings to the config, frees the Nuklear context and every widget, including the entries added with SDL_Libretro_AddMenuButton() and SDL_Libretro_AddMenuCheckbox(), and drops any queued SDL_EVENT_LIBRETRO_MENU_OPENED and SDL_EVENT_LIBRETRO_MENU_CLOSED events that still refer to it. The libretro context is left untouched; destroy the menu before destroying the context.

Parameters
menuthe menu to destroy. NULL is ignored.
See also
SDL_Libretro_CreateMenu()

Definition at line 2431 of file SDL_libretro_menu.h.

References SDL_EVENT_LIBRETRO_MENU_CLOSED, and SDL_EVENT_LIBRETRO_MENU_OPENED.

◆ SDL_Libretro_EjectDisk()

bool SDL_Libretro_EjectDisk ( SDL_Libretro *  lr)

Ejects the disk tray, allowing the disk image to be changed.

Parameters
lrThe libretro instance.
Returns
true on success, false on failure.

Definition at line 134 of file SDL_libretro_serialize.h.

References SDL_Libretro_IsGameReady().

◆ SDL_Libretro_GetAnalogToDigital()

SDL_LibretroAnalogToDigital SDL_Libretro_GetAnalogToDigital ( const SDL_Libretro *  lr,
unsigned  port 
)

Get the analog stick that also registers D-Pad presses on a controller port.

Invalid arguments return SDL_LIBRETRO_ANALOG_TO_DIGITAL_NONE.

Parameters
lrthe libretro context.
portthe controller port, at a max of SDL_LIBRETRO_MAX_USERS.
Returns
the stick that drives the D-Pad, or SDL_LIBRETRO_ANALOG_TO_DIGITAL_NONE.
See also
SDL_Libretro_SetAnalogToDigital()

Definition at line 853 of file SDL_libretro_input.h.

References SDL_LIBRETRO_ANALOG_TO_DIGITAL_NONE, and SDL_LIBRETRO_MAX_USERS.

◆ SDL_Libretro_GetAspectRatio()

float SDL_Libretro_GetAspectRatio ( const SDL_Libretro *  lr)

Gets the aspect ratio for the libretro context.

Parameters
lrthe libretro context.
Returns
the display aspect ratio reported by the core (width / height), or 0.0f or less when the core did not provide one, in which case the frame's width / height ratio applies.

Definition at line 371 of file SDL_libretro_video.h.

◆ SDL_Libretro_GetAudioLatency()

unsigned SDL_Libretro_GetAudioLatency ( const SDL_Libretro *  lr)

Get the minimum audio latency for the audio stream.

Parameters
lrthe libretro context.
Returns
the latency in milliseconds set with SDL_Libretro_SetAudioLatency(), SDL_LIBRETRO_AUDIO_DEFAULT_LATENCY_MS when none was set, or 0 when lr is NULL.
See also
SDL_Libretro_SetAudioLatency()

Definition at line 332 of file SDL_libretro_audio.h.

References SDL_LIBRETRO_AUDIO_DEFAULT_LATENCY_MS.

Referenced by SDL_Libretro_InitConfigFile().

◆ SDL_Libretro_GetBlockExtract()

bool SDL_Libretro_GetBlockExtract ( const SDL_Libretro *  lr)

Retrieves whether the core expects archives to be loaded directly.

Parameters
lrthe libretro context.
Returns
true if the core handles archive files itself.

Definition at line 2292 of file SDL_libretro_core.h.

References SDL_Libretro_IsCoreReady().

◆ SDL_Libretro_GetCategory()

const SDL_LibretroCategory * SDL_Libretro_GetCategory ( const SDL_Libretro *  lr,
const char *  key 
)

Retrieve an option category by key.

Parameters
lrthe libretro context.
keythe category's key, as found in SDL_LibretroOption's category.
Returns
the category, owned by the context, or NULL if there's no such category.
See also
SDL_Libretro_GetCategoryByIndex()

Definition at line 515 of file SDL_libretro_options.h.

◆ SDL_Libretro_GetCategoryByIndex()

const SDL_LibretroCategory * SDL_Libretro_GetCategoryByIndex ( const SDL_Libretro *  lr,
unsigned  index 
)

Retrieve an option category by index.

Parameters
lrthe libretro context.
indexthe category index, from 0 to SDL_Libretro_GetCategoryCount() - 1.
Returns
the category, owned by the context, or NULL if out of range.
See also
SDL_Libretro_GetCategoryCount()

Definition at line 534 of file SDL_libretro_options.h.

◆ SDL_Libretro_GetCategoryCount()

unsigned SDL_Libretro_GetCategoryCount ( const SDL_Libretro *  lr)

Get the number of option categories registered by the core.

Parameters
lrthe libretro context.
Returns
the number of categories, or 0 if none.
See also
SDL_Libretro_GetCategoryByIndex()

Definition at line 502 of file SDL_libretro_options.h.

◆ SDL_Libretro_GetContentExtension()

const char * SDL_Libretro_GetContentExtension ( const SDL_Libretro *  lr)

Get the extension of the loaded content, as it appears in the path.

Returns the text after the last '.' of the content path, in its original case (e.g. "SFC" for "game.SFC"), or "" when no content is loaded or the file has no extension. Note this is the raw-case extension; the lower-cased form handed to cores via GET_GAME_INFO_EXT (gameInfoExt.ext) may differ.

Parameters
lrthe libretro context.
Returns
the content extension (no leading dot), or "" if none.

Definition at line 2304 of file SDL_libretro_core.h.

◆ SDL_Libretro_GetCoreAssetsDirectory()

const char * SDL_Libretro_GetCoreAssetsDirectory ( SDL_Libretro *  lr)

Get the core assets directory.

Parameters
lrthe libretro context.
Returns
the core assets directory, or NULL when none is set or lr is NULL. The string is owned by the context and stays valid until the directory changes or the context is destroyed.
See also
SDL_Libretro_SetCoreAssetsDirectory()

Definition at line 2021 of file SDL_libretro_core.h.

Referenced by SDL_Libretro_InitConfigFile().

◆ SDL_Libretro_GetCoreDirectory()

const char * SDL_Libretro_GetCoreDirectory ( SDL_Libretro *  lr)

Get the core directory.

Parameters
lrthe libretro context.
Returns
the core directory, or NULL when none is set or lr is NULL. The string is owned by the context and stays valid until the directory changes or the context is destroyed.
See also
SDL_Libretro_SetCoreDirectory()

Definition at line 1982 of file SDL_libretro_core.h.

Referenced by SDL_Libretro_InitConfigFile().

◆ SDL_Libretro_GetCoreName()

const char * SDL_Libretro_GetCoreName ( const SDL_Libretro *  lr)

Retrieve the name of the libretro core that's actively loaded.

Parameters
lrthe libretro context.
Returns
the core's library name, or "" when no core is loaded. The string is owned by the context and stays valid until the core is unloaded.

Definition at line 2206 of file SDL_libretro_core.h.

References SDL_Libretro_IsCoreReady().

◆ SDL_Libretro_GetCoreVersion()

const char * SDL_Libretro_GetCoreVersion ( const SDL_Libretro *  lr)

Retrieves the version of the libretro core that's actively loaded.

Parameters
lrthe libretro context.
Returns
the core's library version, or "" when no core is loaded. The string is owned by the context and stays valid until the core is unloaded.

Definition at line 2229 of file SDL_libretro_core.h.

References SDL_Libretro_IsCoreReady().

◆ SDL_Libretro_GetDiskCount()

unsigned SDL_Libretro_GetDiskCount ( const SDL_Libretro *  lr)

Returns the number of disk images available to the loaded core.

Parameters
lrThe libretro instance.
Returns
The number of disk images, or 0 if disk control is not available.

Definition at line 91 of file SDL_libretro_serialize.h.

References SDL_Libretro_IsGameReady().

◆ SDL_Libretro_GetDiskIndex()

unsigned SDL_Libretro_GetDiskIndex ( const SDL_Libretro *  lr)

Returns the index of the currently inserted disk image.

Parameters
lrThe libretro instance.
Returns
The current disk index, or 0 if disk control is not available.

Definition at line 102 of file SDL_libretro_serialize.h.

References SDL_Libretro_IsGameReady().

◆ SDL_Libretro_GetDiskLabel()

bool SDL_Libretro_GetDiskLabel ( const SDL_Libretro *  lr,
unsigned  index,
char *  label,
size_t  len 
)

Retrieves the human-readable label of a disk image.

Requires a core that provides the extended disk control interface.

Parameters
lrThe libretro instance.
indexThe zero-based disk image index.
labelBuffer to receive the null-terminated label.
lenSize of the label buffer in bytes.
Returns
true on success, false if labels are not available.

Definition at line 349 of file SDL_libretro_serialize.h.

References SDL_Libretro_IsGameReady().

◆ SDL_Libretro_GetFileName()

size_t SDL_Libretro_GetFileName ( char *  dst,
size_t  dstSize,
const char *  path,
bool  withExtension 
)

Copy the file name portion of a path into a caller-provided buffer.

The leading directory components and (optionally) the trailing extension are stripped. Useful for deriving save/state file names from a content path.

Parameters
dstthe destination buffer to fill (always null-terminated).
dstSizethe size of dst in bytes.
paththe source path, may be NULL.
withExtensionif true, keep the file extension; if false, strip it.
Returns
the length of the resulting string in dst, excluding the null terminator (0 on invalid arguments).

Definition at line 388 of file SDL_libretro_core.h.

◆ SDL_Libretro_GetFitMode()

SDL_LibretroFitMode SDL_Libretro_GetFitMode ( const SDL_Libretro *  lr)

Gets how the frame is fit into the destination rectangle when rendered.

Parameters
lrthe libretro context.
Returns
the current fit mode, or SDL_LIBRETRO_FIT_ASPECT when lr is NULL.
See also
SDL_Libretro_SetFitMode()

Definition at line 424 of file SDL_libretro_video.h.

References SDL_LIBRETRO_FIT_ASPECT.

Referenced by SDL_Libretro_InitConfigFile().

◆ SDL_Libretro_GetFPS()

double SDL_Libretro_GetFPS ( const SDL_Libretro *  lr)

Gets the frame rate the core expects to run at.

Parameters
lrthe libretro context.
Returns
the core's reported frames per second, or 0.0 if unknown.

Definition at line 381 of file SDL_libretro_video.h.

◆ SDL_Libretro_GetGameName()

const char * SDL_Libretro_GetGameName ( const SDL_Libretro *  lr)

Retrieve the human-readable name of the loaded game.

This is the content file's base name without its extension. When the core runs without content, it falls back to the core's name.

Parameters
lrthe libretro context.
Returns
the game name, or "" when no game is loaded. The string is owned by the context and stays valid until the game is unloaded.

Definition at line 2219 of file SDL_libretro_core.h.

References SDL_Libretro_IsGameReady().

◆ SDL_Libretro_GetInputDescriptor()

bool SDL_Libretro_GetInputDescriptor ( const SDL_Libretro *  lr,
unsigned  index,
unsigned *  port,
unsigned *  device,
unsigned *  id,
const char **  description 
)

Retrieve an input descriptor by index.

This function can be used to enumerate all available input descriptors by calling it with incrementing index values starting at 0 until no descriptor is returned or an error is indicated.

Parameters
lrThe libretro context.
[in]indexZero-based index of the input descriptor to retrieve. The value should start at 0 and be incremented to enumerate successive descriptors.
[out]portZero-based port number to query (e.g., controller port).
[out]deviceDevice identifier within the port (if applicable).
[out]idThe ID of the descriptor.
[out]descriptionThe description of the input device.
Returns
true when a descriptor was written, or false when the core is not ready or index is out of range.
Note
The description string is owned by the libretro context; do not modify or free it. It stays valid until the core sets new descriptors or is unloaded.
See also
retro_input_descriptor

Definition at line 941 of file SDL_libretro_input.h.

References SDL_Libretro_IsCoreReady().

◆ SDL_Libretro_GetInputDescriptorCount()

unsigned SDL_Libretro_GetInputDescriptorCount ( const SDL_Libretro *  lr)

Retrieve the number of input descriptors provided by a Libretro core.

Parameters
lrthe libretro context.
Returns
the number of descriptors, or 0 if the core is not ready or provided none.
See also
SDL_Libretro_GetInputDescriptor()

Definition at line 916 of file SDL_libretro_input.h.

References SDL_Libretro_IsCoreReady().

◆ SDL_Libretro_GetLanguage()

int SDL_Libretro_GetLanguage ( const SDL_Libretro *  lr)

Get the language reported to cores through RETRO_ENVIRONMENT_GET_LANGUAGE.

Parameters
lrThe SDL_Libretro context.
Returns
The RETRO_LANGUAGE_* override set with SDL_Libretro_SetLanguage(), or the one detected from the system locale when there is none. RETRO_LANGUAGE_ENGLISH when lr is NULL.
See also
SDL_Libretro_SetLanguage()

Definition at line 323 of file SDL_libretro_env.h.

◆ SDL_Libretro_GetLogLevel()

SDL_LogPriority SDL_Libretro_GetLogLevel ( const SDL_Libretro *  lr)

Retrieve the threshold for logs that will be posted.

Parameters
lrthe libretro context.
Returns
the minimum priority of core log messages that are posted, or SDL_LOG_PRIORITY_INVALID when lr is NULL.
See also
SDL_Libretro_SetLogLevel()

Definition at line 2189 of file SDL_libretro_core.h.

◆ SDL_Libretro_GetMapAddress()

void * SDL_Libretro_GetMapAddress ( const SDL_Libretro *  lr,
size_t  address,
size_t *  regionRemaining 
)

Translate an emulated (guest) address to a live host pointer via the memory map.

Walks the descriptors published by the core (RETRO_ENVIRONMENT_SET_MEMORY_MAPS) and returns a pointer into the core's live memory for address, so debuggers, cheat finders, and RAM watchers don't have to reimplement the descriptor math.

Resolves an address that lies within a descriptor's primary mapped range ([start, start + len), after folding out disconnect bits). Mirror/aliased addresses that rely on a descriptor's select mask to wrap back into the region may return NULL rather than a guess; the result is always either a correct pointer or NULL, never a wrong one.

Parameters
lrthe libretro context.
addressthe emulated address to resolve.
regionRemainingif non-NULL, receives the number of contiguous bytes from address to the end of the matched region (0 when unmatched).
Returns
a host pointer into the core's live memory, or NULL if no descriptor maps the address (or no core/game/map is present). Do not free it.
See also
SDL_Libretro_GetMemoryMapDescriptor()
RETRO_ENVIRONMENT_SET_MEMORY_MAPS

Definition at line 704 of file SDL_libretro_serialize.h.

References SDL_Libretro_IsGameReady().

◆ SDL_Libretro_GetMemoryData()

void * SDL_Libretro_GetMemoryData ( const SDL_Libretro *  lr,
unsigned  memoryType,
size_t *  size 
)

Get a pointer to a core memory region and its size.

Returns the core's live buffer for the given RETRO_MEMORY_* type. The pointer is owned by the core: do not free it, it stays valid until the core is unloaded, and writing through it pokes the running game directly. Must not be called concurrently with SDL_Libretro_Update().

Parameters
lrthe libretro context.
memoryTypeone of the RETRO_MEMORY_* constants.
sizereceives the region size in bytes (set to 0 when unavailable), or NULL.
Returns
the live region pointer, or NULL if the core exposes no such memory.
See also
SDL_Libretro_SetMemoryData()

Definition at line 573 of file SDL_libretro_serialize.h.

References SDL_Libretro_IsGameReady().

Referenced by SDL_Libretro_LoadMemory_IO(), SDL_Libretro_SaveMemory(), SDL_Libretro_SaveMemory_IO(), and SDL_Libretro_SetMemoryData().

◆ SDL_Libretro_GetMemoryMapCount()

unsigned SDL_Libretro_GetMemoryMapCount ( const SDL_Libretro *  lr)

Get the number of memory-map descriptors the core has published.

Cores describe their address space via RETRO_ENVIRONMENT_SET_MEMORY_MAPS for the benefit of debuggers, cheat finders, and achievement runtimes. Returns 0 if the core published no map.

Parameters
lrthe libretro context.
Returns
the descriptor count.
See also
SDL_Libretro_GetMemoryMapDescriptor()
RETRO_ENVIRONMENT_SET_MEMORY_MAPS

Definition at line 641 of file SDL_libretro_serialize.h.

References SDL_Libretro_IsGameReady().

◆ SDL_Libretro_GetMemoryMapDescriptor()

bool SDL_Libretro_GetMemoryMapDescriptor ( const SDL_Libretro *  lr,
unsigned  index,
Uint64 *  flags,
void **  ptr,
size_t *  offset,
size_t *  start,
size_t *  select,
size_t *  disconnect,
size_t *  len,
const char **  addrspace 
)

Retrieve one memory-map descriptor by index.

Maps a region of the emulated address space onto a host pointer. To translate a guest address that falls in this descriptor to a host pointer:

host = (Uint8*)ptr + offset + ((guest & ~disconnect) - start)

Any out-parameter may be NULL if not needed. The returned ptr and addrspace are owned by the context and remain valid until the core is unloaded; do not free them.

Parameters
lrthe libretro context.
indexthe descriptor index, in [0, SDL_Libretro_GetMemoryMapCount()).
flagsreceives the RETRO_MEMDESC_* flag bits, or NULL.
ptrreceives the host base pointer of the region, or NULL.
offsetreceives the offset from ptr to the region start, or NULL.
startreceives the first emulated address mapped here, or NULL.
selectreceives the address-decode select mask, or NULL.
disconnectreceives the disconnect (ignored-bits) mask, or NULL.
lenreceives the region length in bytes, or NULL.
addrspacereceives the address-space label (may be NULL itself), or NULL.
Returns
true on success, false if the index is out of range or no core is loaded.

Definition at line 666 of file SDL_libretro_serialize.h.

References SDL_Libretro_IsGameReady().

◆ SDL_Libretro_GetMenuLibretro()

SDL_Libretro * SDL_Libretro_GetMenuLibretro ( const SDL_LibretroMenu *  menu)

Gets the libretro context the menu was created for.

Handy inside an SDL_LibretroMenuCallback.

Parameters
menuthe menu to query.
Returns
the SDL_Libretro context passed to SDL_Libretro_CreateMenu(), or NULL when menu is NULL.
See also
SDL_Libretro_CreateMenu()

Definition at line 2485 of file SDL_libretro_menu.h.

◆ SDL_Libretro_GetMenuStyle()

SDL_LibretroMenuStyle SDL_Libretro_GetMenuStyle ( const SDL_LibretroMenu *  menu)

Gets the menu's active color theme.

Parameters
menuthe menu to query.
Returns
the active style, or SDL_LIBRETRO_MENU_DEFAULT_STYLE when menu is NULL.
See also
SDL_Libretro_SetMenuStyle()

Definition at line 2061 of file SDL_libretro_menu.h.

References SDL_LIBRETRO_MENU_DEFAULT_STYLE.

◆ SDL_Libretro_GetMenuUserData()

void * SDL_Libretro_GetMenuUserData ( const SDL_LibretroMenu *  menu)

Gets the data attached with SDL_Libretro_SetMenuUserData().

Parameters
menuthe menu to query.
Returns
the stored data, or NULL when none was set or menu is NULL.
See also
SDL_Libretro_SetMenuUserData()

Definition at line 2513 of file SDL_libretro_menu.h.

◆ SDL_Libretro_GetMessage()

const char * SDL_Libretro_GetMessage ( SDL_Libretro *  lr)

Gets the most relevant libretro message to display from the queue.

This is the highest priority message that has not yet expired. The string is owned by the context and stays valid until the message expires or is replaced.

Parameters
lrthe libretro context.
Returns
a string for the message, or NULL if there isn't a message to display.
See also
SDL_Libretro_GetMessageProgress()
SDL_Libretro_GetMessageType()

Definition at line 153 of file SDL_libretro_messages.h.

Referenced by SDL_Libretro_UpdateMenu().

◆ SDL_Libretro_GetMessageByIndex()

bool SDL_Libretro_GetMessageByIndex ( SDL_Libretro *  lr,
int  index,
const char **  msg,
int *  progress,
int *  type 
)

Retrieves all message details for the given message index.

Parameters
lrthe libretro context.
indexthe index of the message to retrieve, from 0 to SDL_Libretro_GetMessageCount() - 1. If negative, gets the most relevant message.
msga pointer filled in with the message string, owned by the context, or NULL.
progressa pointer filled in with the progress percentage (0-100, or -1 for none), or NULL.
typea pointer filled in with the message's enum retro_message_type, or NULL.
Returns
true if the message exists, false otherwise.
See also
SDL_Libretro_GetMessageCount()

Definition at line 221 of file SDL_libretro_messages.h.

◆ SDL_Libretro_GetMessageCount()

unsigned SDL_Libretro_GetMessageCount ( SDL_Libretro *  lr)

Gets the number of messages currently in the queue.

Will expire any old messages to make sure the count is correct.

Parameters
lrthe libretro context.
Returns
the number of queued messages.
See also
SDL_Libretro_GetMessageByIndex()

Definition at line 203 of file SDL_libretro_messages.h.

◆ SDL_Libretro_GetMessageProgress()

int SDL_Libretro_GetMessageProgress ( SDL_Libretro *  lr)

Gets the progress of the message returned by SDL_Libretro_GetMessage().

Parameters
lrthe libretro context.
Returns
the progress as a percentage from 0 to 100, or -1 when the message has no progress indicator or there is no message to display.
See also
SDL_Libretro_GetMessage()

Definition at line 169 of file SDL_libretro_messages.h.

Referenced by SDL_Libretro_UpdateMenu().

◆ SDL_Libretro_GetMessageType()

int SDL_Libretro_GetMessageType ( SDL_Libretro *  lr)

Gets the type of the message returned by SDL_Libretro_GetMessage().

Parameters
lrthe libretro context.
Returns
the message's enum retro_message_type value, such as RETRO_MESSAGE_TYPE_NOTIFICATION or RETRO_MESSAGE_TYPE_PROGRESS; 0 (RETRO_MESSAGE_TYPE_NOTIFICATION) when there is no message.
See also
SDL_Libretro_GetMessage()

Definition at line 186 of file SDL_libretro_messages.h.

◆ SDL_Libretro_GetMousePort()

unsigned SDL_Libretro_GetMousePort ( const SDL_Libretro *  lr)

Get the controller port that the mouse drives.

NULL returns port 0.

Parameters
lrthe libretro context.
Returns
the controller port the mouse drives.
See also
SDL_Libretro_SetMousePort()

Definition at line 881 of file SDL_libretro_input.h.

Referenced by SDL_Libretro_InitConfigFile().

◆ SDL_Libretro_GetOption()

const SDL_LibretroOption * SDL_Libretro_GetOption ( const SDL_Libretro *  lr,
const char *  key 
)

Retrieve details about a given core option.

The returned option is owned by the context and stays valid until the core is unloaded or registers more options.

Parameters
lrthe libretro context.
keythe option's key.
Returns
the option, or NULL if there's no such option.
See also
SDL_Libretro_GetOptionByIndex()
SDL_Libretro_GetOptionValue()

Definition at line 265 of file SDL_libretro_options.h.

Referenced by SDL_Libretro_CycleOptionValue(), SDL_Libretro_GetOptionValue(), SDL_Libretro_GetOptionValueLabel(), SDL_Libretro_ResetOption(), and SDL_Libretro_SetOptionValue().

◆ SDL_Libretro_GetOptionByIndex()

const SDL_LibretroOption * SDL_Libretro_GetOptionByIndex ( const SDL_Libretro *  lr,
unsigned  index 
)

Retrieve a core option by its registration index.

The returned option is owned by the context and stays valid until the core is unloaded or registers more options.

Parameters
lrthe libretro context.
indexthe option index, from 0 to SDL_Libretro_GetOptionCount() - 1.
Returns
the option, or NULL if out of range.
See also
SDL_Libretro_GetOptionCount()

Definition at line 287 of file SDL_libretro_options.h.

◆ SDL_Libretro_GetOptionCount()

unsigned SDL_Libretro_GetOptionCount ( const SDL_Libretro *  lr)

Get the number of core options that have been set.

Parameters
lrthe libretro context.
Returns
the number of options the core registered, or 0 if none.
See also
SDL_Libretro_GetOptionByIndex()

Definition at line 248 of file SDL_libretro_options.h.

◆ SDL_Libretro_GetOptionValue()

const char * SDL_Libretro_GetOptionValue ( SDL_Libretro *  lr,
const char *  key 
)

Get a core option's current value.

The string is owned by the context and stays valid until the option's value changes.

Parameters
lrthe libretro context.
keythe option's key.
Returns
the current value, or NULL if there's no such option.
See also
SDL_Libretro_SetOptionValue()
SDL_Libretro_GetOptionValueLabel()

Definition at line 347 of file SDL_libretro_options.h.

References SDL_Libretro_GetOption(), and SDL_LibretroOption::value.

◆ SDL_Libretro_GetOptionValueLabel()

const char * SDL_Libretro_GetOptionValueLabel ( SDL_Libretro *  lr,
const char *  key 
)

Get the human-readable label for a core option's current value.

Falls back to the raw value when the core supplied no label, like in core option variables API version 0 or 1.

Parameters
lrthe libretro context.
keythe option's key.
Returns
the label for the current value, or NULL if there's no such option.
See also
SDL_Libretro_GetOptionValue()

Definition at line 365 of file SDL_libretro_options.h.

References SDL_LibretroOptionValue::label, SDL_Libretro_GetOption(), SDL_LibretroOptionValue::value, SDL_LibretroOption::value, SDL_LibretroOption::values, and SDL_LibretroOption::valuesCount.

◆ SDL_Libretro_GetPerformanceLevel()

unsigned SDL_Libretro_GetPerformanceLevel ( const SDL_Libretro *  lr)

Get the performance level the core requested via SET_PERFORMANCE_LEVEL.

Parameters
lrthe libretro context.
Returns
the requested performance level, or 0 if none/invalid.
See also
RETRO_ENVIRONMENT_SET_PERFORMANCE_LEVEL

Definition at line 2251 of file SDL_libretro_core.h.

◆ SDL_Libretro_GetPortDevice()

unsigned SDL_Libretro_GetPortDevice ( const SDL_Libretro *  lr,
unsigned  port 
)

Get the device type assigned to a controller port.

Returns the RETRO_DEVICE_* type last set via SDL_Libretro_SetPortDevice(). Ports default to RETRO_DEVICE_JOYPAD, per libretro convention, until a device is explicitly assigned. Invalid arguments return RETRO_DEVICE_NONE.

Parameters
lrthe libretro context.
portthe controller port, at a max of SDL_LIBRETRO_MAX_USERS.
Returns
the assigned RETRO_DEVICE_* type, or RETRO_DEVICE_NONE on invalid arguments.
See also
SDL_LIBRETRO_MAX_USERS

Definition at line 784 of file SDL_libretro_input.h.

References SDL_LIBRETRO_MAX_USERS.

◆ SDL_Libretro_GetRenderer()

SDL_Renderer * SDL_Libretro_GetRenderer ( const SDL_Libretro *  lr)

Get the renderer the context draws into.

Parameters
lrthe libretro context.
Returns
the renderer set via SDL_Libretro_SetRenderer(), or NULL if none.

Definition at line 168 of file SDL_libretro_video.h.

◆ SDL_Libretro_GetRewindEnabled()

bool SDL_Libretro_GetRewindEnabled ( const SDL_Libretro *  lr)

Check whether the rewind system is enabled (independent of current direction).

Parameters
lrthe libretro context.
Returns
true if rewind capture is enabled.

Definition at line 1265 of file SDL_libretro_serialize.h.

Referenced by SDL_Libretro_InitConfigFile().

◆ SDL_Libretro_GetRewindMemoryLimit()

size_t SDL_Libretro_GetRewindMemoryLimit ( const SDL_Libretro *  lr)

Get the current rewind memory budget in bytes (0 if unbounded).

Parameters
lrthe libretro context.
Returns
the byte budget, or 0 if unbounded.

Definition at line 1322 of file SDL_libretro_serialize.h.

Referenced by SDL_Libretro_InitConfigFile().

◆ SDL_Libretro_GetRewindMemoryUsage()

size_t SDL_Libretro_GetRewindMemoryUsage ( const SDL_Libretro *  lr)

Get the approximate memory currently held by the rewind buffer, in bytes.

Includes the encoded delta history plus the fixed reference/scratch buffers and the entry table. Useful for debug overlays and tuning the memory limit.

Parameters
lrthe libretro context.
Returns
total bytes held by the rewind subsystem, or 0 if disabled.
See also
SDL_Libretro_SetRewindMemoryLimit()

Definition at line 1290 of file SDL_libretro_serialize.h.

◆ SDL_Libretro_GetRewindRemaining()

double SDL_Libretro_GetRewindRemaining ( const SDL_Libretro *  lr)

Calculates the amount of rewind time remaining in the buffer.

Parameters
lrthe libretro context.
Returns
seconds of gameplay that can still be rewound, or 0.0 if rewind is disabled or the buffer is empty.

Definition at line 1275 of file SDL_libretro_serialize.h.

◆ SDL_Libretro_GetRotation()

int SDL_Libretro_GetRotation ( const SDL_Libretro *  lr)

Gets the screen rotation requested by the core.

SDL_Libretro_Render() applies this rotation automatically.

Parameters
lrthe libretro context.
Returns
the rotation in degrees counter-clockwise: 0, 90, 180 or 270.

Definition at line 393 of file SDL_libretro_video.h.

◆ SDL_Libretro_GetSampleRate()

double SDL_Libretro_GetSampleRate ( const SDL_Libretro *  lr)

Get the audio sample rate the loaded core outputs at.

Reported by the core through retro_get_system_av_info() when the game loads, and updated by RETRO_ENVIRONMENT_SET_SYSTEM_AV_INFO.

Parameters
lrthe libretro context.
Returns
the sample rate in Hz, or SDL_LIBRETRO_AUDIO_DEFAULT_SAMPLE_RATE when lr is NULL or the core hasn't reported one.

Definition at line 346 of file SDL_libretro_audio.h.

References SDL_LIBRETRO_AUDIO_DEFAULT_SAMPLE_RATE.

◆ SDL_Libretro_GetSaveDirectory()

const char * SDL_Libretro_GetSaveDirectory ( SDL_Libretro *  lr)

Get the save directory.

Parameters
lrthe libretro context.
Returns
the save directory, or NULL when none is set or lr is NULL. The string is owned by the context and stays valid until the directory changes or the context is destroyed.
See also
SDL_Libretro_SetSaveDirectory()

Definition at line 1995 of file SDL_libretro_core.h.

Referenced by SDL_Libretro_InitConfigFile().

◆ SDL_Libretro_GetSavePath()

size_t SDL_Libretro_GetSavePath ( const SDL_Libretro *  lr,
const char *  extension,
char *  dst,
size_t  dstSize 
)

Build a path in the save directory for the currently loaded content.

Produces "<saveDirectory>/<contentName><extension>" (or just "<contentName><extension>" when no save directory is set). Handy for deriving SRAM (".srm"), RTC (".rtc"), or save-state (".state") file names without hardcoding them.

Parameters
lrthe libretro context.
extensionthe extension to append, including the dot (NULL or "" for none).
dstthe destination buffer (always null-terminated when dstSize > 0).
dstSizethe size of dst in bytes.
Returns
the length of the resulting string, or 0 if no content is loaded or on invalid arguments.

Definition at line 428 of file SDL_libretro_core.h.

◆ SDL_Libretro_GetSavestateContext()

enum retro_savestate_context SDL_Libretro_GetSavestateContext ( const SDL_Libretro *  lr)

Get the savestate context reported to cores through RETRO_ENVIRONMENT_GET_SAVESTATE_CONTEXT.

Parameters
lrthe libretro context.
Returns
the context set with SDL_Libretro_SetSavestateContext(), or RETRO_SAVESTATE_CONTEXT_NORMAL when none was set or lr is NULL.
See also
SDL_Libretro_SetSavestateContext()

Definition at line 2263 of file SDL_libretro_core.h.

◆ SDL_Libretro_GetScaleMode()

SDL_ScaleMode SDL_Libretro_GetScaleMode ( const SDL_Libretro *  lr)

Gets the texture scale mode used when the libretro frame is scaled.

Parameters
lrthe libretro context.
Returns
the current scale mode, or SDL_SCALEMODE_NEAREST when lr is NULL.
See also
SDL_Libretro_SetScaleMode()

Definition at line 462 of file SDL_libretro_video.h.

Referenced by SDL_Libretro_InitConfigFile().

◆ SDL_Libretro_GetSize()

void SDL_Libretro_GetSize ( const SDL_Libretro *  lr,
int *  w,
int *  h 
)

Gets the width and height of the core's current video frame.

Parameters
lrthe libretro context.
wa pointer filled in with the frame width in pixels, or NULL; 0 when lr is NULL.
ha pointer filled in with the frame height in pixels, or NULL; 0 when lr is NULL.

Definition at line 358 of file SDL_libretro_video.h.

◆ SDL_Libretro_GetSpeed()

float SDL_Libretro_GetSpeed ( const SDL_Libretro *  lr)

Get how fast the game runs, as a multiple of its normal speed.

This includes a speed set by the core's fast-forward override.

Parameters
lrthe libretro context.
Returns
the speed multiplier (0.0f paused, negative rewinding), or 1.0f when lr is NULL.
See also
SDL_Libretro_SetSpeed()

Definition at line 2142 of file SDL_libretro_core.h.

◆ SDL_Libretro_GetSRAMAutoSave()

bool SDL_Libretro_GetSRAMAutoSave ( const SDL_Libretro *  lr)

Check whether SRAM is loaded and saved along with the game.

Parameters
lrthe libretro context.
Returns
true when enabled with SDL_Libretro_SetSRAMAutoSave().
See also
SDL_Libretro_SetSRAMAutoSave()

Definition at line 905 of file SDL_libretro_serialize.h.

◆ SDL_Libretro_GetStateSize()

size_t SDL_Libretro_GetStateSize ( const SDL_Libretro *  lr)

Retrieves the size of serialized states.

Parameters
lrthe libretro context.
Returns
the size in bytes of a save state, or 0 if no game is loaded or the core does not support save states.

Definition at line 431 of file SDL_libretro_serialize.h.

References SDL_Libretro_IsGameReady().

◆ SDL_Libretro_GetSystemDirectory()

const char * SDL_Libretro_GetSystemDirectory ( SDL_Libretro *  lr)

Get the system directory.

Parameters
lrthe libretro context.
Returns
the system directory, or NULL when none is set or lr is NULL. The string is owned by the context and stays valid until the directory changes or the context is destroyed.
See also
SDL_Libretro_SetSystemDirectory()

Definition at line 2008 of file SDL_libretro_core.h.

Referenced by SDL_Libretro_InitConfigFile().

◆ SDL_Libretro_GetTexture()

SDL_Texture * SDL_Libretro_GetTexture ( const SDL_Libretro *  lr)

Get the streaming texture that holds the core's most recent video frame.

The texture is owned by the libretro context; do not destroy it. It is recreated when the core's frame size changes, the renderer changes, or a new game is loaded, so fetch it again rather than caching the pointer.

Parameters
lrthe libretro context.
Returns
the frame texture, or NULL if no video has been initialized yet.
See also
SDL_Libretro_Render()
SDL_Libretro_CreateSurface()

Definition at line 185 of file SDL_libretro_video.h.

◆ SDL_Libretro_GetUsername()

const char * SDL_Libretro_GetUsername ( SDL_Libretro *  lr)

Get the username reported to cores.

Parameters
lrthe libretro context.
Returns
the username, or NULL when lr is NULL. The string is owned by the context and stays valid until the username changes or the context is destroyed.
See also
SDL_Libretro_SetUsername()

Definition at line 2051 of file SDL_libretro_core.h.

Referenced by SDL_Libretro_InitConfigFile().

◆ SDL_Libretro_GetValidExtensions()

const char * SDL_Libretro_GetValidExtensions ( const SDL_Libretro *  lr)

Gets the default set of valid extensions associated with the core, seperated by a "|".

Parameters
lrthe libretro context.
Returns
the extensions without leading dots (e.g. "nes|fds"), or "" when no core is loaded. The string is owned by the context and stays valid until the core is unloaded.

Definition at line 2239 of file SDL_libretro_core.h.

References SDL_Libretro_IsCoreReady().

◆ SDL_Libretro_GetVersion()

int SDL_Libretro_GetVersion ( void  )

Get the version of SDL_libretro the implementation was compiled with.

Returns
the version as SDL_LIBRETRO_VERSION, packed with SDL_VERSIONNUM().
See also
SDL_LIBRETRO_VERSION

Definition at line 1647 of file SDL_libretro_core.h.

References SDL_LIBRETRO_VERSION.

◆ SDL_Libretro_GetVolume()

float SDL_Libretro_GetVolume ( const SDL_Libretro *  lr)

Get the audio volume.

Parameters
lrthe libretro context.
Returns
the volume, from 0.0f (muted) to 1.0f (full), or 0.0f when lr is NULL.
See also
SDL_Libretro_SetVolume()

Definition at line 2082 of file SDL_libretro_core.h.

Referenced by SDL_Libretro_InitConfigFile().

◆ SDL_Libretro_HandleEvent()

void SDL_Libretro_HandleEvent ( SDL_Libretro *  lr,
const SDL_Event *  event 
)

Call this function within the SDL_PollEvent() loop to ensure libretro knows of important events.

Tracks the mouse, opens and closes gamepads as they're connected, and forwards keyboard events to cores that listen for them.

Parameters
lrthe libretro context.
eventthe event to handle.

Definition at line 663 of file SDL_libretro_input.h.

References SDL_LIBRETRO_MAX_USERS.

◆ SDL_Libretro_HandleMenuEvent()

bool SDL_Libretro_HandleMenuEvent ( SDL_LibretroMenu *  menu,
const SDL_Event *  event 
)

Routes an event to the menu; call this for every event, before SDL_Libretro_HandleEvent().

The toggle key (SDL_LIBRETRO_MENU_TOGGLE_KEY) and the gamepad Guide button flip the menu open or closed, and are always consumed. Gamepad connection changes are tracked even while the menu is closed.

Parameters
menuthe menu to feed.
eventthe event to handle; it is not modified.
Returns
true when the menu consumed the event: do not forward it to SDL_Libretro_HandleEvent(). This happens for the toggle inputs above, and for gameplay input swallowed while the menu is open. false when the event should be handled as usual: the menu is closed, menu or event is NULL, the event is an application event (SDL_EVENT_USER and above), or it is a lifecycle event (quit, drop-file, window, and gamepad/joystick add/remove) which always passes through so the application and frontend still see it. The release of a key that was already held when the menu opened passes through too, so the press it answers isn't left stuck down.
See also
SDL_Libretro_UpdateMenu()

Definition at line 2598 of file SDL_libretro_menu.h.

References SDL_LIBRETRO_MENU_TOGGLE_KEY, and SDL_Libretro_ToggleMenu().

◆ SDL_Libretro_InitConfig()

bool SDL_Libretro_InitConfig ( SDL_Libretro *  lr,
const char *  org,
const char *  app 
)

Sets up the config file to be the default path, accoring to the organization and app name.

The file is "<app>.cfg" inside SDL_GetPrefPath(org, app). Any previously initialized config is discarded without being saved.

Parameters
lrthe libretro context.
orgthe organization name, or NULL/empty for "SDL_libretro".
appthe application name, or NULL/empty for "SDL_libretro".
Returns
true when the config was set up, false when lr is NULL, no pref path is available, or SDL_Libretro_InitConfigFile() fails.
See also
SDL_Libretro_InitConfigFile()
SDL_GetPrefPath()
https://wiki.libsdl.org/SDL3/SDL_GetPrefPath

Definition at line 168 of file SDL_libretro_config.h.

References SDL_Libretro_InitConfigFile().

◆ SDL_Libretro_InitConfigFile()

bool SDL_Libretro_InitConfigFile ( SDL_Libretro *  lr,
const char *  file 
)

Initializes the config system based on the given file.

Will load the configuration from the file, and save it when destroying the instance. A missing file is not an error: it starts out empty and is created on save. A file that exists but can't be read or parsed is left untouched, and no config is set up, so it isn't overwritten with defaults. Any previously initialized config is discarded without being saved.

Parameters
lrthe libretro context.
filethe path of the .ini file to load from and save to. The string is copied.
Returns
true when the config was set up, false when lr or file is NULL, the existing file can't be loaded, or on allocation failure.
See also
SDL_Libretro_InitConfig()

Definition at line 39 of file SDL_libretro_config.h.

References SDL_LIBRETRO_ANALOG_TO_DIGITAL_COUNT, SDL_Libretro_GetAudioLatency(), SDL_Libretro_GetCoreAssetsDirectory(), SDL_Libretro_GetCoreDirectory(), SDL_Libretro_GetFitMode(), SDL_Libretro_GetMousePort(), SDL_Libretro_GetRewindEnabled(), SDL_Libretro_GetRewindMemoryLimit(), SDL_Libretro_GetSaveDirectory(), SDL_Libretro_GetScaleMode(), SDL_Libretro_GetSystemDirectory(), SDL_Libretro_GetUsername(), SDL_Libretro_GetVolume(), SDL_LIBRETRO_MAX_USERS, SDL_Libretro_SetAnalogToDigital(), SDL_Libretro_SetAudioLatency(), SDL_Libretro_SetCoreAssetsDirectory(), SDL_Libretro_SetCoreDirectory(), SDL_Libretro_SetFitMode(), SDL_Libretro_SetGamepadMapping(), SDL_Libretro_SetKeyboardMapping(), SDL_Libretro_SetLanguage(), SDL_Libretro_SetMousePort(), SDL_Libretro_SetRewindEnabled(), SDL_Libretro_SetRewindMemoryLimit(), SDL_Libretro_SetSaveDirectory(), SDL_Libretro_SetScaleMode(), SDL_Libretro_SetSystemDirectory(), SDL_Libretro_SetUsername(), and SDL_Libretro_SetVolume().

Referenced by SDL_Libretro_InitConfig().

◆ SDL_Libretro_InsertDisk()

bool SDL_Libretro_InsertDisk ( SDL_Libretro *  lr)

Closes the disk tray after a disk change.

Parameters
lrThe libretro instance.
Returns
true on success, false on failure.

Definition at line 148 of file SDL_libretro_serialize.h.

References SDL_Libretro_IsGameReady().

◆ SDL_Libretro_IsCoreReady()

bool SDL_Libretro_IsCoreReady ( const SDL_Libretro *  lr)

◆ SDL_Libretro_IsFastforwardOverrideActive()

bool SDL_Libretro_IsFastforwardOverrideActive ( const SDL_Libretro *  lr)

Indicates whether the core is forcing fast-forward through RETRO_ENVIRONMENT_SET_FASTFORWARDING_OVERRIDE.

While active, the core controls the speed; if it also inhibits toggling, SDL_Libretro_SetSpeed() is ignored.

Parameters
lrthe libretro context.
Returns
true while the core's fast-forward override is active, false otherwise or when lr is NULL.
See also
SDL_Libretro_SetSpeed()

Definition at line 2157 of file SDL_libretro_core.h.

◆ SDL_Libretro_IsGameReady()

bool SDL_Libretro_IsGameReady ( const SDL_Libretro *  lr)

◆ SDL_Libretro_IsGameRequired()

bool SDL_Libretro_IsGameRequired ( const SDL_Libretro *  lr)

Indicates whether the loaded core needs content to run.

Cores opt into running without content with RETRO_ENVIRONMENT_SET_SUPPORT_NO_GAME, after which SDL_Libretro_LoadGame() accepts a NULL path. The core's own report is used rather than the supports_no_game flag in its .info file.

Parameters
lrthe libretro context.
Returns
false when the loaded core can start without content, true otherwise (including when no core is loaded).
See also
SDL_Libretro_LoadGame()

Definition at line 1400 of file SDL_libretro_core.h.

◆ SDL_Libretro_IsMenuOpen()

bool SDL_Libretro_IsMenuOpen ( const SDL_LibretroMenu *  menu)

Checks whether the menu is currently shown.

While it is open, the application should skip SDL_Libretro_Update() so the game stays paused.

Parameters
menuthe menu to query.
Returns
true when the menu is open, false when it is closed or menu is NULL.
See also
SDL_Libretro_SetMenuOpen()
SDL_Libretro_ToggleMenu()

Definition at line 2470 of file SDL_libretro_menu.h.

◆ SDL_Libretro_LoadCore()

bool SDL_Libretro_LoadCore ( SDL_Libretro *  lr,
const char *  core 
)

Loads a libretro core.

Only one core may be loaded at a time, as the library keeps a single global active context, and the API is not thread-safe; call it from the main SDL thread.

Parameters
lrthe libretro context.
coreEither the path to the core to load, or a name of the core within the core directory.
Returns
true when the core was loaded and initialized, false on invalid arguments, when another context already has a core loaded, or when the core fails to load; call SDL_GetError() for more information.
See also
SDL_Libretro_Create()
SDL_Libretro_UnloadCore()

Definition at line 210 of file SDL_libretro_core.h.

References LOAD_SYM, SDL_EVENT_LIBRETRO_CORE_LOADED, and SDL_Libretro_UnloadCore().

Referenced by SDL_Libretro_PhysFS_LoadGame().

◆ SDL_Libretro_LoadGame()

bool SDL_Libretro_LoadGame ( SDL_Libretro *  lr,
const char *  gamePath 
)

Loads a game at the given path.

When SDL_LIBRETRO_ENABLE_PHYSFS is enabled, a .zip path is routed through SDL_Libretro_PhysFS_LoadGame() automatically.

Pass a NULL gamePath to start the loaded core without content. This only works for cores that report RETRO_ENVIRONMENT_SET_SUPPORT_NO_GAME (see SDL_Libretro_IsGameRequired()); otherwise it fails and SDL_GetError() says the core requires content. A core must already be loaded, as there is no extension to pick one by.

Parameters
lrthe libretro context.
gamePaththe path of the content to load, or NULL for no content.
Returns
true when the game is running; call SDL_GetError() for more information on failure.
See also
SDL_Libretro_IsGameRequired()
SDL_Libretro_UnloadGame()
SDL_Libretro_SetRenderer()
SDL_Libretro_PhysFS_LoadGame()

Definition at line 987 of file SDL_libretro_core.h.

References SDL_Libretro_PhysFS_LoadGame().

◆ SDL_Libretro_LoadGame_IO()

bool SDL_Libretro_LoadGame_IO ( SDL_Libretro *  lr,
SDL_IOStream *  src,
const char *  path,
bool  closeio 
)

Loads a game from an SDL_IOStream.

Stream content into memory, and hand it to the core. The path only provides the content identity (name, extension, save path, etc). When the core requires a full path (need_fullpath), the stream is saved to a temp directory ("<save directory>/tmp") and loaded from there, while the content keeps the identity of path. The file is removed when the game unloads.

Parameters
lrthe libretro context.
srcthe stream to read the content from.
paththe path the content is known by. Could be a virtual path if the loading from an archive.
closeioif true, close src before returning, even on failure.
Returns
true when the game is running; call SDL_GetError() for more information on failure.
See also
SDL_Libretro_LoadGame()

Definition at line 1131 of file SDL_libretro_core.h.

References SDL_Libretro_IsCoreReady().

Referenced by SDL_Libretro_PhysFS_LoadGame().

◆ SDL_Libretro_LoadGameSpecial()

bool SDL_Libretro_LoadGameSpecial ( SDL_Libretro *  lr,
const char *  subsystem,
const char **  paths,
unsigned  numPaths 
)

Loads multi-ROM subsystem content (e.g.

Super Game Boy, Sufami Turbo).

The subsystem is chosen by matching subsystem against each registered subsystem's ident or human-readable description. The paths map positionally to that subsystem's ROMs; each ROM whose descriptor sets need_fullpath is passed by path, otherwise the file is read into memory and handed to the core.

Parameters
lrthe libretro instance.
subsystemthe subsystem ident or description to load.
pathsthe content file paths, one per ROM the subsystem expects.
numPathsthe number of entries in paths; must be greater than 0.
Returns
true on success; false if the subsystem is unknown, the arguments are invalid, a file fails to load, or the core rejects the content.
See also
SDL_Libretro_LoadGameSpecialById

Definition at line 1330 of file SDL_libretro_core.h.

References SDL_Libretro_LoadGameSpecialById().

◆ SDL_Libretro_LoadGameSpecialById()

bool SDL_Libretro_LoadGameSpecialById ( SDL_Libretro *  lr,
unsigned  subsystemId,
const char **  paths,
unsigned  numPaths 
)

Load multi-ROM subsystem content by its numeric subsystem id.

Equivalent to SDL_Libretro_LoadGameSpecial() but selects the subsystem by the id the core assigned it rather than by ident or description.

Parameters
lrthe libretro instance.
subsystemIdthe id of the subsystem to load.
pathsthe content file paths, one per ROM the subsystem expects.
numPathsthe number of entries in paths; must be greater than 0.
Returns
true on success; false if the id is unknown, the arguments are invalid, the paths don't match the ROMs the subsystem expects, a file fails to load, or the core rejects the content. Only a rejection by the core unloads the game that was running.
See also
SDL_Libretro_LoadGameSpecial

Definition at line 1189 of file SDL_libretro_core.h.

References SDL_Libretro_IsCoreReady(), and SDL_Libretro_UnloadGame().

Referenced by SDL_Libretro_LoadGameSpecial().

◆ SDL_Libretro_LoadMemory()

bool SDL_Libretro_LoadMemory ( SDL_Libretro *  lr,
unsigned  memoryType,
const char *  file 
)

Load a core memory region from a file.

Convenience wrapper over SDL_Libretro_LoadMemory_IO().

Parameters
lrthe libretro context.
memoryTypeone of the RETRO_MEMORY_* constants.
filethe source file path.
Returns
true on success, false on error.

Definition at line 862 of file SDL_libretro_serialize.h.

References SDL_Libretro_LoadMemory_IO().

Referenced by SDL_Libretro_LoadSRAM().

◆ SDL_Libretro_LoadMemory_IO()

bool SDL_Libretro_LoadMemory_IO ( SDL_Libretro *  lr,
unsigned  memoryType,
SDL_IOStream *  src,
bool  closeio 
)

Load a core memory region from a stream.

Copies stream contents into the live memory region for the given type. When the stream and the region differ in size, only the overlapping bytes are copied, so a save from a slightly different revision still loads what it can.

Parameters
lrthe libretro context.
memoryTypeone of the RETRO_MEMORY_* constants.
srcthe source stream.
closeioif true, close src before returning (even on failure).
Returns
true on success, false if the core exposes no such memory, on a read error, or on invalid arguments.

Definition at line 822 of file SDL_libretro_serialize.h.

References SDL_Libretro_GetMemoryData(), and SDL_Libretro_SetMemoryData().

Referenced by SDL_Libretro_LoadMemory(), and SDL_Libretro_LoadSRAM_IO().

◆ SDL_Libretro_LoadSRAM()

bool SDL_Libretro_LoadSRAM ( SDL_Libretro *  lr,
const char *  file 
)

Loads the SRAM from the given file.

Shorthand for SDL_Libretro_LoadMemory() with RETRO_MEMORY_SAVE_RAM.

Parameters
lrthe libretro context.
filethe source file path.
Returns
true on success, false if the core has no save RAM or on error.
See also
SDL_Libretro_SaveSRAM()

Definition at line 991 of file SDL_libretro_serialize.h.

References SDL_Libretro_LoadMemory().

◆ SDL_Libretro_LoadSRAM_IO()

bool SDL_Libretro_LoadSRAM_IO ( SDL_Libretro *  lr,
SDL_IOStream *  src,
bool  closeio 
)

Load the core's battery-backed save RAM from a stream.

Shorthand for SDL_Libretro_LoadMemory_IO() with RETRO_MEMORY_SAVE_RAM.

Parameters
lrthe libretro context.
srcthe source stream.
closeioif true, close src before returning (even on failure).
Returns
true on success, false if the core has no save RAM, on a read error, or on invalid arguments.
See also
SDL_Libretro_SaveSRAM_IO()

Definition at line 976 of file SDL_libretro_serialize.h.

References SDL_Libretro_LoadMemory_IO().

◆ SDL_Libretro_LoadState()

bool SDL_Libretro_LoadState ( SDL_Libretro *  lr,
const char *  file 
)

Loads the libretro state from the given file.

Parameters
lrthe libretro context.
filethe source file path.
Returns
true on success, false on error.
See also
SDL_Libretro_LoadState_IO()
SDL_Libretro_SaveState()

Definition at line 549 of file SDL_libretro_serialize.h.

References SDL_Libretro_IsGameReady(), and SDL_Libretro_LoadState_IO().

◆ SDL_Libretro_LoadState_IO()

bool SDL_Libretro_LoadState_IO ( SDL_Libretro *  lr,
SDL_IOStream *  src,
bool  closeio 
)

Load a libretro state from the given SDL_IOStream.

Reads the whole stream and hands it to the core. A successful load clears the rewind history, since it can't be rewound across.

Parameters
lrthe libretro context.
srcthe source stream.
closeioif true, close src before returning (even on failure).
Returns
true on success, false if no game is loaded, the stream is empty or unreadable, or the core rejected the state.
See also
SDL_Libretro_SaveState_IO()
SDL_Libretro_LoadState()

Definition at line 514 of file SDL_libretro_serialize.h.

References SDL_Libretro_IsGameReady().

Referenced by SDL_Libretro_LoadState().

◆ SDL_Libretro_MenuScreenshotClicked()

void SDL_Libretro_MenuScreenshotClicked ( SDL_LibretroMenu *  menu,
void *  userdata 
)

A ready-made menu callback that saves a PNG screenshot of the current frame, reporting the result in the menu.

Pass it to SDL_Libretro_AddMenuButton(). The menu's own Screenshot entry uses it too.

Parameters
menuthe menu the callback fired for. NULL is ignored.
userdatathe destination path as a const char*, or NULL for "screenshot.png".
See also
SDL_Libretro_AddMenuButton()

Definition at line 462 of file SDL_libretro_menu.h.

References SDL_Libretro_SaveScreenshot().

◆ SDL_Libretro_OpenMenuPath()

bool SDL_Libretro_OpenMenuPath ( SDL_LibretroMenu *  menu,
const char *  path 
)

Opens the menu and navigates to a page by its slash-separated label path, e.g.

"Settings/Audio & Video", "Settings/Core Options" or "Disks".

The pages built from the loaded core are refreshed first, so their paths resolve before the next frame.

Parameters
menuthe menu to navigate.
paththe label path of the page to show.
Returns
true when the path resolved; the menu stays open either way. false when menu or path is NULL; call SDL_GetError() for more information.
See also
SDL_Libretro_SetMenuOpen()

Definition at line 2725 of file SDL_libretro_menu.h.

References SDL_Libretro_SetMenuOpen().

◆ SDL_Libretro_PhysFS_Init()

bool SDL_Libretro_PhysFS_Init ( SDL_Libretro *  lr)

Initialize PhysFS and route the libretro VFS through it.

This will be called automatically in SDL_Libretro_PhysFS_LoadGame() if PhysFS was not initialized. Cores can then read content directly from the mounted archive through the VFS, with anything outside PhysFS falling through to the SDL VFS. Safe to call repeatedly.

Requires the implementation to be compiled with SDL_LIBRETRO_ENABLE_PHYSFS; otherwise it always fails.

Parameters
lrthe libretro context to install the VFS overrides on.
Returns
true on success, false if lr is NULL or PhysFS failed to initialize; call SDL_GetError() for more information.
See also
SDL_Libretro_PhysFS_Quit()

Definition at line 178 of file SDL_libretro_physfs.h.

References SDL_Libretro_SetVFS().

Referenced by SDL_Libretro_PhysFS_LoadGame().

◆ SDL_Libretro_PhysFS_LoadGame()

bool SDL_Libretro_PhysFS_LoadGame ( SDL_Libretro *  lr,
const char *  gamePath 
)

Archive-aware replacement for SDL_Libretro_LoadGame().

Content that isn't a .zip loads exactly like SDL_Libretro_LoadGame(). For a .zip, the archive is mounted with PhysFS and the content inside is handed to the core: as a data buffer for byte-oriented cores, or by its virtual path in a PhysFS-backed VFS for full-path cores that use the libretro VFS. Full-path cores that read files from the OS get the whole archive extracted to a temp directory instead, so content like a .cue sheet finds its tracks; it's removed when the game unloads.

The raw .zip is handed over unextracted instead when the loaded core reports block_extract or lists "zip" in its valid extensions, or, with no core loaded, when the first core in the library that lists "zip" sets block_extract in its .info file.

Any running game is unloaded and any previous archive unmounted first. PhysFS is initialized on demand; if that or mounting the archive fails, the .zip falls back to a plain SDL_Libretro_LoadGame()-style load. Without a loaded core, the core is picked from the library based on the chosen content file.

SDL_Libretro_LoadGame() will call this automatically when loading an archive, so there is no need to call it directly. Requires the implementation to be compiled with SDL_LIBRETRO_ENABLE_PHYSFS; otherwise it always fails.

Parameters
lrthe libretro context.
gamePaththe OS path of the content or archive. May be NULL for a content-less core load.
Returns
true when the game loaded, false on failure, including when lr is NULL, no suitable content is found inside the archive, or no core can run it; call SDL_GetError() for more information.
See also
SDL_Libretro_LoadGame()

Definition at line 470 of file SDL_libretro_physfs.h.

References SDL_Libretro_IsCoreReady(), SDL_Libretro_LoadCore(), SDL_Libretro_LoadGame_IO(), SDL_Libretro_PhysFS_Init(), SDL_LIBRETRO_PHYSFS_MOUNT_POINT, and SDL_Libretro_UnloadGame().

Referenced by SDL_Libretro_LoadGame().

◆ SDL_Libretro_PhysFS_Quit()

void SDL_Libretro_PhysFS_Quit ( SDL_Libretro *  lr)

Tear down PhysFS, unmounting any active archive and restoring the plain SDL VFS on the given context.

Unload the game first, since a game loaded from an archive still reads from the mount. Safe to call when PhysFS was never initialized.

Parameters
lrthe libretro context. NULL is ignored.
See also
SDL_Libretro_PhysFS_Init()

Definition at line 208 of file SDL_libretro_physfs.h.

References SDL_Libretro_SetVFS().

Referenced by SDL_Libretro_Destroy().

◆ SDL_Libretro_Render()

bool SDL_Libretro_Render ( SDL_Libretro *  lr,
SDL_Renderer *  renderer,
const SDL_FRect *  dstRect 
)

Render the libretro context in the given renderer.

Parameters
lrthe libretro context.
rendererthe renderer to draw into; must not be NULL.
dstRectthe destination rectangle, or NULL to fit within the renderer's logical size, or its current output size when logical presentation is disabled.
Returns
true on success, false on invalid arguments or if there is nothing to draw yet.
See also
SDL_Libretro_SetRenderer()

Definition at line 304 of file SDL_libretro_video.h.

References SDL_Libretro_SetRenderer().

◆ SDL_Libretro_RenderMenu()

void SDL_Libretro_RenderMenu ( SDL_LibretroMenu *  menu)

Draws the menu laid out by SDL_Libretro_UpdateMenu() to the renderer.

Call once per frame, after SDL_Libretro_UpdateMenu() and before SDL_RenderPresent(). Draws nothing while the menu is closed, but must still be called every frame so input is collected for the next one.

Parameters
menuthe menu to draw. NULL is ignored.
See also
SDL_Libretro_UpdateMenu()

Definition at line 2848 of file SDL_libretro_menu.h.

◆ SDL_Libretro_Reset()

bool SDL_Libretro_Reset ( SDL_Libretro *  lr)

Resets the loaded game, like pressing the console's reset button.

Also clears the rewind buffer and any queued audio.

Parameters
lrthe libretro context.
Returns
true when the game was reset, false when no game is loaded; call SDL_GetError() for more information.

Definition at line 1412 of file SDL_libretro_core.h.

◆ SDL_Libretro_ResetAllOptions()

void SDL_Libretro_ResetAllOptions ( SDL_Libretro *  lr)

Reset every core option to its default value.

Parameters
lrthe libretro context.
See also
SDL_Libretro_ResetOption()

Definition at line 447 of file SDL_libretro_options.h.

References SDL_LibretroOption::defaultValue, and SDL_LibretroOption::value.

◆ SDL_Libretro_ResetCheats()

void SDL_Libretro_ResetCheats ( SDL_Libretro *  lr)

Clears all cheats that were set on the core.

Does nothing when no game is loaded.

Parameters
lrthe libretro context.
See also
SDL_Libretro_SetCheat()

Definition at line 418 of file SDL_libretro_serialize.h.

References SDL_Libretro_IsGameReady().

◆ SDL_Libretro_ResetOption()

bool SDL_Libretro_ResetOption ( SDL_Libretro *  lr,
const char *  key 
)

Reset a core option to its default value.

Parameters
lrthe libretro context.
keythe key to revert to the default value.
Returns
true on success, false if there's no such option or out of memory.
See also
SDL_Libretro_ResetAllOptions()

Definition at line 424 of file SDL_libretro_options.h.

References SDL_LibretroOption::defaultValue, SDL_Libretro_GetOption(), and SDL_LibretroOption::value.

◆ SDL_Libretro_SaveMemory()

bool SDL_Libretro_SaveMemory ( SDL_Libretro *  lr,
unsigned  memoryType,
const char *  file 
)

Write a core memory region to a file.

Convenience wrapper over SDL_Libretro_SaveMemory_IO(). No file is created when the core exposes no such memory region.

Parameters
lrthe libretro context.
memoryTypeone of the RETRO_MEMORY_* constants.
filethe destination file path.
Returns
true on success, false on error.

Definition at line 787 of file SDL_libretro_serialize.h.

References SDL_Libretro_GetMemoryData(), and SDL_Libretro_SaveMemory_IO().

Referenced by SDL_Libretro_SaveSRAM().

◆ SDL_Libretro_SaveMemory_IO()

bool SDL_Libretro_SaveMemory_IO ( SDL_Libretro *  lr,
unsigned  memoryType,
SDL_IOStream *  dst,
bool  closeio 
)

Write a core memory region to a stream.

Persists the live contents of the given libretro memory type (e.g. RETRO_MEMORY_SAVE_RAM for battery saves, RETRO_MEMORY_RTC for a real-time clock). A core that exposes no such region is treated as success with nothing written, so callers don't have to special-case it.

Parameters
lrthe libretro context.
memoryTypeone of the RETRO_MEMORY_* constants.
dstthe destination stream.
closeioif true, close dst before returning (even on failure).
Returns
true on success (including "core has no such memory"), false on a write error or invalid arguments.

Definition at line 757 of file SDL_libretro_serialize.h.

References SDL_Libretro_GetMemoryData().

Referenced by SDL_Libretro_SaveMemory(), and SDL_Libretro_SaveSRAM_IO().

◆ SDL_Libretro_SaveScreenshot()

bool SDL_Libretro_SaveScreenshot ( const SDL_Libretro *  lr,
const char *  path 
)

Saves a PNG screenshot of the current frame.

Parameters
lrthe libretro context.
paththe destination file, or NULL for "screenshot.png".
Returns
true when the file was written, false on failure.
See also
SDL_Libretro_CreateSurface()

Definition at line 236 of file SDL_libretro_video.h.

References SDL_Libretro_CreateSurface().

Referenced by SDL_Libretro_MenuScreenshotClicked().

◆ SDL_Libretro_SaveSRAM()

bool SDL_Libretro_SaveSRAM ( SDL_Libretro *  lr,
const char *  file 
)

Saves the current SRAM to the given file.

Shorthand for SDL_Libretro_SaveMemory() with RETRO_MEMORY_SAVE_RAM. No file is created when the core has no save RAM.

Parameters
lrthe libretro context.
filethe destination file path.
Returns
true on success (including when the core has no save RAM), false on error.
See also
SDL_Libretro_LoadSRAM()

Definition at line 960 of file SDL_libretro_serialize.h.

References SDL_Libretro_SaveMemory().

◆ SDL_Libretro_SaveSRAM_IO()

bool SDL_Libretro_SaveSRAM_IO ( SDL_Libretro *  lr,
SDL_IOStream *  dst,
bool  closeio 
)

Write the core's battery-backed save RAM to a stream.

Shorthand for SDL_Libretro_SaveMemory_IO() with RETRO_MEMORY_SAVE_RAM.

Parameters
lrthe libretro context.
dstthe destination stream.
closeioif true, close dst before returning (even on failure).
Returns
true on success (including when the core has no save RAM), false on a write error or invalid arguments.
See also
SDL_Libretro_LoadSRAM_IO()

Definition at line 945 of file SDL_libretro_serialize.h.

References SDL_Libretro_SaveMemory_IO().

◆ SDL_Libretro_SaveState()

bool SDL_Libretro_SaveState ( SDL_Libretro *  lr,
const char *  file 
)

Saves the current libretro state to a file.

Parameters
lrthe libretro context.
filethe destination file path.
Returns
true on success, false on error.
See also
SDL_Libretro_SaveState_IO()
SDL_Libretro_LoadState()

Definition at line 488 of file SDL_libretro_serialize.h.

References SDL_Libretro_IsGameReady(), and SDL_Libretro_SaveState_IO().

◆ SDL_Libretro_SaveState_IO()

bool SDL_Libretro_SaveState_IO ( SDL_Libretro *  lr,
SDL_IOStream *  dst,
bool  closeio 
)

Save the current libretro state to the given SDL_IOStream.

Parameters
lrthe libretro context.
dstthe destination stream.
closeioif true, close dst before returning (even on failure).
Returns
true on success, false if no game is loaded, the core does not support save states, or on a serialize or write error.
See also
SDL_Libretro_LoadState_IO()
SDL_Libretro_SaveState()

Definition at line 447 of file SDL_libretro_serialize.h.

References SDL_Libretro_IsGameReady().

Referenced by SDL_Libretro_SaveState().

◆ SDL_Libretro_SetAnalogToDigital()

void SDL_Libretro_SetAnalogToDigital ( SDL_Libretro *  lr,
unsigned  port,
SDL_LibretroAnalogToDigital  stick 
)

Selects which analog stick, if any, also registers D-Pad presses on the given controller port, alongside the physical D-Pad.

Parameters
lrthe libretro context.
portthe controller port, at a max of SDL_LIBRETRO_MAX_USERS.
stickthe stick that drives the D-Pad, or SDL_LIBRETRO_ANALOG_TO_DIGITAL_NONE for the D-Pad alone.
See also
SDL_Libretro_GetAnalogToDigital()

Definition at line 835 of file SDL_libretro_input.h.

References SDL_LIBRETRO_ANALOG_TO_DIGITAL_COUNT, and SDL_LIBRETRO_MAX_USERS.

Referenced by SDL_Libretro_InitConfigFile().

◆ SDL_Libretro_SetAudioLatency()

void SDL_Libretro_SetAudioLatency ( SDL_Libretro *  lr,
unsigned  latencyMs 
)

Set the desired minimum audio latency for the audio stream.

The setting carries across cores. A core asking for more latency through RETRO_ENVIRONMENT_SET_MINIMUM_AUDIO_LATENCY raises the latency in effect while it's loaded, without changing this setting.

Parameters
lrthe libretro context.
latencyMsthe minimum latency in milliseconds, or 0 for SDL_LIBRETRO_AUDIO_DEFAULT_LATENCY_MS.
See also
SDL_LIBRETRO_AUDIO_DEFAULT_LATENCY_MS
SDL_Libretro_GetAudioLatency()

Definition at line 314 of file SDL_libretro_audio.h.

Referenced by SDL_Libretro_InitConfigFile().

◆ SDL_Libretro_SetCheat()

bool SDL_Libretro_SetCheat ( SDL_Libretro *  lr,
unsigned  index,
bool  enabled,
const char *  code 
)

Set a cheat code either enabled or disabled within the libretro context.

Requires a loaded game. The code's format is specific to the core.

Parameters
lrthe libretro context.
indexthe cheat slot to set.
enabledtrue to enable the cheat, false to disable it.
codethe cheat code; must not be NULL.
Returns
true if the cheat was passed to the core, false if no game is loaded or code is NULL.
See also
SDL_Libretro_ResetCheats()

Definition at line 400 of file SDL_libretro_serialize.h.

References SDL_Libretro_IsGameReady().

◆ SDL_Libretro_SetCoreAssetsDirectory()

bool SDL_Libretro_SetCoreAssetsDirectory ( SDL_Libretro *  lr,
const char *  path 
)

Sets where cores look for their assets, reported through RETRO_ENVIRONMENT_GET_CORE_ASSETS_DIRECTORY.

Parameters
lrthe libretro context.
paththe core assets directory, or NULL/empty for none. The string is copied.
Returns
true when the directory was set, false when lr is NULL.
See also
SDL_Libretro_GetCoreAssetsDirectory()

Definition at line 1968 of file SDL_libretro_core.h.

Referenced by SDL_Libretro_InitConfigFile().

◆ SDL_Libretro_SetCoreDirectory()

bool SDL_Libretro_SetCoreDirectory ( SDL_Libretro *  lr,
const char *  path 
)

Sets the associated libretro core directory, where the default set of cores will be loaded from.

The discovered cores are sorted by case-insensitive core name, then by path, so lookups that take the first match (such as picking a core for a game's extension) behave the same on every machine.

The path is stored even when it can't be scanned, so it can still be shown or saved.

Parameters
lrthe libretro context.
paththe core directory, or NULL/empty to clear it.
Returns
true when the directory was scanned (or cleared), false when it doesn't exist, isn't a directory, or the scan failed; call SDL_GetError() for more information.

Definition at line 1844 of file SDL_libretro_core.h.

Referenced by SDL_Libretro_InitConfigFile().

◆ SDL_Libretro_SetDiskIndex()

bool SDL_Libretro_SetDiskIndex ( SDL_Libretro *  lr,
unsigned  index 
)

Sets the disk image index to insert into the emulated drive.

The disk tray must be ejected before calling this function.

Parameters
lrThe libretro instance.
indexThe zero-based disk image index.
Returns
true on success, false if the core rejected the change or disk control is not available.

Definition at line 116 of file SDL_libretro_serialize.h.

References SDL_Libretro_IsGameReady().

◆ SDL_Libretro_SetFitMode()

bool SDL_Libretro_SetFitMode ( SDL_Libretro *  lr,
SDL_LibretroFitMode  mode 
)

Sets how the frame is fit into the destination rectangle when rendered.

Parameters
lrthe libretro context.
modethe fit mode to use.
Returns
true on success, false on an invalid context or fit mode.
See also
SDL_Libretro_GetFitMode()
SDL_Libretro_Render()

Definition at line 407 of file SDL_libretro_video.h.

References SDL_LIBRETRO_FIT_COUNT, and SDL_LIBRETRO_FIT_FIRST.

Referenced by SDL_Libretro_InitConfigFile().

◆ SDL_Libretro_SetGamepadMapping()

void SDL_Libretro_SetGamepadMapping ( SDL_Libretro *  lr,
unsigned  port,
int  retroButton,
SDL_GamepadButton  button 
)

Maps an SDL gamepad button to a RETRO_DEVICE_ID_JOYPAD_* button on the given controller port.

The L2/R2 trigger axes keep working alongside any button bound to them.

Parameters
lrthe libretro context.
portthe controller port, at a max of SDL_LIBRETRO_MAX_USERS.
retroButtonthe RETRO_DEVICE_ID_JOYPAD_* button to rebind.
buttonthe SDL button that presses it.

Definition at line 816 of file SDL_libretro_input.h.

References SDL_LIBRETRO_MAX_USERS.

Referenced by SDL_Libretro_InitConfigFile().

◆ SDL_Libretro_SetInitialDisk()

bool SDL_Libretro_SetInitialDisk ( SDL_Libretro *  lr,
unsigned  index,
const char *  path 
)

Sets the disk image to insert once content is loaded.

This must be called before the game is loaded so the core can restore the correct disk, like a M3U playlist, or a save state.

Parameters
lrThe libretro instance.
indexThe zero-based disk image index.
pathFile path of the expected disk image, used by the core to verify the index.
Returns
true on success, false if the extended disk control interface is not available.

Definition at line 373 of file SDL_libretro_serialize.h.

◆ SDL_Libretro_SetKeyboardMapping()

void SDL_Libretro_SetKeyboardMapping ( SDL_Libretro *  lr,
int  retroButton,
SDL_Scancode  scancode 
)

Maps a keyboard key to a RETRO_DEVICE_ID_JOYPAD_* button for Player 1 (controller port 0).

The key works alongside any gamepad on that port. Invalid arguments are ignored.

Parameters
lrthe libretro context.
retroButtonthe RETRO_DEVICE_ID_JOYPAD_* button to rebind, from RETRO_DEVICE_ID_JOYPAD_B to RETRO_DEVICE_ID_JOYPAD_R3.
scancodethe physical key that presses it, or SDL_SCANCODE_UNKNOWN to unbind the button.
See also
SDL_Libretro_SetGamepadMapping()

Definition at line 801 of file SDL_libretro_input.h.

Referenced by SDL_Libretro_InitConfigFile().

◆ SDL_Libretro_SetLanguage()

void SDL_Libretro_SetLanguage ( SDL_Libretro *  lr,
int  language 
)

Override the language reported to cores through RETRO_ENVIRONMENT_GET_LANGUAGE.

By default the language is detected from the first of SDL_GetPreferredLocales(), falling back to RETRO_LANGUAGE_ENGLISH. Cores usually query the language while loading, so set it before SDL_Libretro_LoadCore().

Parameters
lrThe SDL_Libretro context.
languageA RETRO_LANGUAGE_* value. A negative value, or RETRO_LANGUAGE_LAST and above, drops the override and goes back to detecting it from the system locale.
See also
SDL_Libretro_GetLanguage()

Definition at line 318 of file SDL_libretro_env.h.

Referenced by SDL_Libretro_Create(), and SDL_Libretro_InitConfigFile().

◆ SDL_Libretro_SetLogLevel()

void SDL_Libretro_SetLogLevel ( SDL_Libretro *  lr,
SDL_LogPriority  level 
)

Sets the threshold for logs to be posted.

Parameters
lrthe libretro context.
levelthe minimum priority of core log messages to post. Priorities below SDL_LOG_PRIORITY_INFO (and unknown ones) post everything from debug up; SDL_LOG_PRIORITY_CRITICAL behaves like SDL_LOG_PRIORITY_ERROR.
See also
SDL_Libretro_GetLogLevel()
SDL_LOG_PRIORITY_INVALID

Definition at line 2170 of file SDL_libretro_core.h.

◆ SDL_Libretro_SetMemoryData()

bool SDL_Libretro_SetMemoryData ( SDL_Libretro *  lr,
unsigned  memoryType,
const void *  data,
size_t  size 
)

Overwrite a core memory region with caller-provided bytes.

Copies up to the region's capacity; any extra bytes are ignored. Writes to the core's live memory, so it must not race SDL_Libretro_Update().

Parameters
lrthe libretro context.
memoryTypeone of the RETRO_MEMORY_* constants.
datathe source bytes.
sizethe number of bytes available in data.
Returns
true on success, false on invalid arguments or if the core exposes no such memory.
See also
SDL_Libretro_GetMemoryData()

Definition at line 596 of file SDL_libretro_serialize.h.

References SDL_Libretro_GetMemoryData().

Referenced by SDL_Libretro_LoadMemory_IO().

◆ SDL_Libretro_SetMenuOpen()

void SDL_Libretro_SetMenuOpen ( SDL_LibretroMenu *  menu,
bool  open 
)

Opens or closes the menu.

When the state changes, pushes SDL_EVENT_LIBRETRO_MENU_OPENED or SDL_EVENT_LIBRETRO_MENU_CLOSED with the menu in data2, and closing stops text input on the window. Setting the current state again does nothing. Note that SDL_Libretro_UpdateMenu() reopens the menu while no game is running.

Parameters
menuthe menu to update. NULL is ignored.
opentrue to show the menu, false to hide it.
See also
SDL_Libretro_ToggleMenu()
SDL_Libretro_IsMenuOpen()

Definition at line 2532 of file SDL_libretro_menu.h.

References SDL_EVENT_LIBRETRO_MENU_CLOSED, and SDL_EVENT_LIBRETRO_MENU_OPENED.

Referenced by SDL_Libretro_OpenMenuPath(), SDL_Libretro_ToggleMenu(), and SDL_Libretro_UpdateMenu().

◆ SDL_Libretro_SetMenuStyle()

bool SDL_Libretro_SetMenuStyle ( SDL_LibretroMenu *  menu,
SDL_LibretroMenuStyle  style 
)

Applies a color theme to the menu.

The choice is saved to the config with the other menu settings, and restored by SDL_Libretro_CreateMenu(). The initial style is SDL_LIBRETRO_MENU_DEFAULT_STYLE.

Parameters
menuthe menu to style.
stylethe theme; must be below SDL_LIBRETRO_MENU_STYLE_COUNT.
Returns
true on success, false when menu is NULL or style is out of range.
See also
SDL_Libretro_GetMenuStyle()

Definition at line 2034 of file SDL_libretro_menu.h.

References SDL_LIBRETRO_MENU_STYLE_COUNT.

◆ SDL_Libretro_SetMenuUserData()

void SDL_Libretro_SetMenuUserData ( SDL_LibretroMenu *  menu,
void *  userData 
)

Attaches generic application data to the menu.

The menu never reads or frees it.

Parameters
menuthe menu to update. NULL is ignored.
userDatathe data to store, or NULL to clear it.
See also
SDL_Libretro_GetMenuUserData()

Definition at line 2499 of file SDL_libretro_menu.h.

◆ SDL_Libretro_SetMessage()

void SDL_Libretro_SetMessage ( SDL_Libretro *  lr,
const char *  msg,
double  duration 
)

Add a message to be displayed within the libretro context.

The message is copied. Setting a message that is already queued refreshes its duration instead of adding a duplicate.

Parameters
lrthe libretro context.
msgthe message to display, or NULL or an empty string to clear all queued messages.
durationthe amount of time in seconds to display the message.
See also
SDL_Libretro_GetMessage()

Definition at line 129 of file SDL_libretro_messages.h.

◆ SDL_Libretro_SetMousePort()

void SDL_Libretro_SetMousePort ( SDL_Libretro *  lr,
unsigned  port 
)

Selects the one controller port that the mouse drives.

Only this port answers RETRO_DEVICE_MOUSE, RETRO_DEVICE_POINTER and RETRO_DEVICE_LIGHTGUN, so a single mouse doesn't act as every player at once. Defaults to port 0.

Parameters
lrthe libretro context.
portthe controller port, at a max of SDL_LIBRETRO_MAX_USERS.
See also
SDL_Libretro_GetMousePort()

Definition at line 868 of file SDL_libretro_input.h.

References SDL_LIBRETRO_MAX_USERS.

Referenced by SDL_Libretro_InitConfigFile().

◆ SDL_Libretro_SetOptionValue()

bool SDL_Libretro_SetOptionValue ( SDL_Libretro *  lr,
const char *  key,
const char *  value 
)

Set a core option's value; fails if the value isn't one the core declared.

Options that declare no values accept any value. The value is copied, and the core sees the change the next time it checks for updated variables.

Parameters
lrthe libretro context.
keythe option's key.
valuethe new value.
Returns
true on success, false if there's no such option, the value isn't valid for it, or on invalid arguments.
See also
SDL_Libretro_GetOptionValue()
SDL_Libretro_CycleOptionValue()

Definition at line 306 of file SDL_libretro_options.h.

References SDL_Libretro_GetOption(), and SDL_LibretroOption::value.

Referenced by SDL_Libretro_CycleOptionValue().

◆ SDL_Libretro_SetPortDevice()

bool SDL_Libretro_SetPortDevice ( SDL_Libretro *  lr,
unsigned  port,
unsigned  device 
)

Assign a device type to a controller port.

The device is passed to the core right away when one is loaded, and applied again once a game finishes loading. Unloading the core resets every port back to RETRO_DEVICE_JOYPAD.

Parameters
lrthe libretro context.
portthe controller port, at a max of SDL_LIBRETRO_MAX_USERS.
devicethe RETRO_DEVICE_* type, or a subclass from RETRO_DEVICE_SUBCLASS(), such as one reported by the core's controller info.
Returns
true on success, false on an invalid context or port.
See also
SDL_Libretro_GetPortDevice()

Definition at line 762 of file SDL_libretro_input.h.

References SDL_Libretro_IsCoreReady(), and SDL_LIBRETRO_MAX_USERS.

◆ SDL_Libretro_SetRenderer()

bool SDL_Libretro_SetRenderer ( SDL_Libretro *  lr,
SDL_Renderer *  renderer 
)

Set the renderer the libretro context draws into.

If a game is already loaded, setting the renderer builds the video texture immediately.

Parameters
lrthe libretro context.
rendererthe renderer to draw into; must not be NULL.
Returns
true on success, false on invalid arguments or if the texture (re)build fails.

Definition at line 141 of file SDL_libretro_video.h.

Referenced by SDL_Libretro_Render().

◆ SDL_Libretro_SetRewindEnabled()

bool SDL_Libretro_SetRewindEnabled ( SDL_Libretro *  lr,
bool  enabled,
unsigned  bufferFrames,
unsigned  captureInterval 
)

Enable or disable the rewind system.

When enabled, a circular buffer of serialized core states is maintained so that setting a negative speed (via SDL_Libretro_SetSpeed()) rewinds gameplay. The buffer is allocated lazily once a game is loaded and the core's serialize size is known. The setting itself carries across games and cores: a core that reports no state size yet (see RETRO_SERIALIZATION_QUIRK_MUST_INITIALIZE) gets its buffer once it does.

History is bounded by two independent limits: the snapshot count (bufferFrames) and the delta memory budget (see SDL_Libretro_SetRewindMemoryLimit(), which defaults to SDL_LIBRETRO_REWIND_DEFAULT_MAX_BYTES at context creation). Whichever is reached first caps the rewind depth. This call does not change the memory budget, a budget you set beforehand, including 0 (unbounded), is preserved.

Enable SDL_LIBRETRO_ENABLE_REWIND_DELTA to use the XOR compression between frames to reduce memory at the expense of performance.

Parameters
lrthe libretro context.
enabledtrue to enable, false to disable.
bufferFramesmaximum number of state snapshots to keep (0 for a sensible default of 300, roughly 5 seconds at 60 fps).
captureIntervalcapture a snapshot every N frames (0 for the default of 1, i.e. every frame). Provide a larger number in order to allow a longer rewind duration.
Returns
true on success, false on allocation failure or if the loaded game reports no state size. Rewind stays enabled either way, and the buffer is allocated once it can be.
See also
SDL_Libretro_SetRewindMemoryLimit()

Definition at line 1227 of file SDL_libretro_serialize.h.

References SDL_Libretro_IsGameReady(), and SDL_Libretro_SetSpeed().

Referenced by SDL_Libretro_InitConfigFile().

◆ SDL_Libretro_SetRewindMemoryDuration()

bool SDL_Libretro_SetRewindMemoryDuration ( SDL_Libretro *  lr,
double  seconds 
)

Set the rewind memory budget by target duration instead of raw bytes.

Computes the worst-case bytes needed to retain seconds of rewindable gameplay and forwards it to SDL_Libretro_SetRewindMemoryLimit(). The estimate is the number of snapshots that span the duration (the core's frame rate divided by the capture interval, times seconds) multiplied by the per-snapshot state size. With delta compression enabled (SDL_LIBRETRO_ENABLE_REWIND_DELTA) snapshots usually store far less than the full state, so this is a conservative upper bound that will typically hold longer than requested.

The snapshot count (bufferFrames in SDL_Libretro_SetRewindEnabled()) is an independent limit; if it is smaller than the duration requires, it, not the byte budget, will cap the achievable rewind depth.

Requires the core's serialize size to be known, so a core must be loaded (or rewind already enabled with a game loaded). Roughly the inverse of SDL_Libretro_GetRewindRemaining().

Parameters
lrthe libretro context.
secondsthe desired rewind duration in seconds (must be positive).
Returns
true on success, false if lr or seconds is invalid or the core's serialize size is not yet available.
See also
SDL_Libretro_SetRewindEnabled()
SDL_Libretro_SetRewindMemoryLimit()
SDL_Libretro_GetRewindRemaining()

Definition at line 1342 of file SDL_libretro_serialize.h.

References SDL_Libretro_IsCoreReady(), and SDL_Libretro_SetRewindMemoryLimit().

◆ SDL_Libretro_SetRewindMemoryLimit()

void SDL_Libretro_SetRewindMemoryLimit ( SDL_Libretro *  lr,
size_t  maxBytes 
)

Set the maximum number of bytes of encoded delta history to retain.

When the stored history exceeds this budget the oldest snapshots are dropped until it fits (the most recent snapshot is always kept), trading rewind duration for bounded memory. Applies immediately. Pass 0 to remove the byte limit and rely solely on the frame-count capacity.

The budget defaults to SDL_LIBRETRO_REWIND_DEFAULT_MAX_BYTES at context creation. Whatever value is set here, including 0 (unbounded), persists across SDL_Libretro_SetRewindEnabled() calls.

Parameters
lrthe libretro context.
maxBytesthe budget in bytes, or 0 for unbounded.
See also
SDL_Libretro_SetRewindEnabled()

Definition at line 1310 of file SDL_libretro_serialize.h.

Referenced by SDL_Libretro_InitConfigFile(), and SDL_Libretro_SetRewindMemoryDuration().

◆ SDL_Libretro_SetSaveDirectory()

bool SDL_Libretro_SetSaveDirectory ( SDL_Libretro *  lr,
const char *  path 
)

Sets where content will be saved.

The directory is created when a core is loaded.

Parameters
lrThe libretro context.
pathThe path to where save data should be placed, NULL for the default ("saves" inside the app's pref path), or "" for none.
Returns
true when the directory was set, false when lr is NULL.
See also
SDL_Libretro_GetSaveDirectory()

Definition at line 1910 of file SDL_libretro_core.h.

Referenced by SDL_Libretro_InitConfigFile().

◆ SDL_Libretro_SetSavestateContext()

void SDL_Libretro_SetSavestateContext ( SDL_Libretro *  lr,
enum retro_savestate_context  context 
)

Sets the savestate context reported to cores through RETRO_ENVIRONMENT_GET_SAVESTATE_CONTEXT.

Tells the core what upcoming save states are for, such as RETRO_SAVESTATE_CONTEXT_RUNAHEAD_SAME_INSTANCE for run-ahead or RETRO_SAVESTATE_CONTEXT_ROLLBACK_NETPLAY for netplay, so it can skip work that isn't needed. It stays set until changed, and resets to RETRO_SAVESTATE_CONTEXT_NORMAL when the core is unloaded.

Parameters
lrthe libretro context. NULL is ignored.
contextthe savestate context.
See also
SDL_Libretro_GetSavestateContext()
SDL_Libretro_SaveState()

Definition at line 2282 of file SDL_libretro_core.h.

◆ SDL_Libretro_SetScaleMode()

bool SDL_Libretro_SetScaleMode ( SDL_Libretro *  lr,
SDL_ScaleMode  mode 
)

Sets the texture scale mode used when the libretro frame is scaled.

Applied immediately when a texture exists, and remembered for the next one otherwise. The setting persists across core loads.

Parameters
lrthe libretro context.
modeSDL_SCALEMODE_NEAREST, SDL_SCALEMODE_LINEAR, or SDL_SCALEMODE_PIXELART (SDL >= 3.4).
Returns
true on success, false on an invalid context or scale mode.

Definition at line 438 of file SDL_libretro_video.h.

Referenced by SDL_Libretro_InitConfigFile().

◆ SDL_Libretro_SetSpeed()

void SDL_Libretro_SetSpeed ( SDL_Libretro *  lr,
float  speed 
)

Sets how fast the game runs, as a multiple of its normal speed.

1.0f is normal speed, values above it fast-forward (e.g. 2.0f), values between 0 and 1 run in slow motion, and 0.0f pauses. A negative value rewinds at that rate (-1.0f is real time) when rewind is enabled with SDL_Libretro_SetRewindEnabled() and the game's state can be captured; otherwise it is clamped to 0.0f (paused). Audio is pitched to match. The speed resets to 1.0f whenever a core is loaded, and the call is ignored while the core has a fast-forward override active that inhibits toggling.

Parameters
lrthe libretro context.
speedthe speed multiplier.
See also
SDL_Libretro_GetSpeed()
SDL_Libretro_IsFastforwardOverrideActive()
SDL_Libretro_Update()

Definition at line 2105 of file SDL_libretro_core.h.

Referenced by SDL_Libretro_Create(), and SDL_Libretro_SetRewindEnabled().

◆ SDL_Libretro_SetSRAMAutoSave()

void SDL_Libretro_SetSRAMAutoSave ( SDL_Libretro *  lr,
bool  enabled 
)

Load and save the core's battery-backed save RAM along with the game.

When enabled, SRAM is loaded from "<save directory>/<content name>.srm" (see SDL_Libretro_GetSavePath()) once a game loads, before it first runs, and written back there before the game unloads: from SDL_Libretro_UnloadGame(), loading other content, unloading the core, or SDL_Libretro_Destroy(). Disabled by default.

Parameters
lrthe libretro context.
enabledtrue to load and save SRAM automatically.
See also
SDL_Libretro_GetSRAMAutoSave()
SDL_Libretro_SetSaveDirectory()

Definition at line 893 of file SDL_libretro_serialize.h.

◆ SDL_Libretro_SetSystemDirectory()

bool SDL_Libretro_SetSystemDirectory ( SDL_Libretro *  lr,
const char *  path 
)

Sets where cores look for system files (BIOS, firmware, etc).

The directory is created when a core is loaded.

Parameters
lrThe libretro context.
pathThe system directory, NULL for the default ("system" inside the app's pref path), or "" for none.
Returns
true when the directory was set, false when lr is NULL.
See also
SDL_Libretro_GetSystemDirectory()

Definition at line 1940 of file SDL_libretro_core.h.

Referenced by SDL_Libretro_InitConfigFile().

◆ SDL_Libretro_SetUsername()

bool SDL_Libretro_SetUsername ( SDL_Libretro *  lr,
const char *  username 
)

Sets the username reported to cores through RETRO_ENVIRONMENT_GET_USERNAME.

Defaults to "SDL_libretro". Names longer than 63 bytes are truncated.

Parameters
lrthe libretro context.
usernamethe username, or NULL for an empty one. The string is copied.
Returns
true when the username was set, false when lr is NULL.
See also
SDL_Libretro_GetUsername()

Definition at line 2037 of file SDL_libretro_core.h.

Referenced by SDL_Libretro_Create(), and SDL_Libretro_InitConfigFile().

◆ SDL_Libretro_SetVFS()

void SDL_Libretro_SetVFS ( SDL_Libretro *  lr,
void *  vfs_interface 
)

Set the Virtual File System the core uses for file access.

The interface is copied, so it doesn't need to outlive this call. With the built-in SDL VFS, any NULL member of the given interface falls back to the SDL3 implementation, and passing NULL restores the SDL3 VFS entirely. When built with SDL_LIBRETRO_DISABLE_VFS, the interface is used as-is and NULL leaves the core without a VFS.

Call this before loading a core, as cores request the VFS when loading.

Parameters
lrthe libretro context.
vfs_interfacea pointer to a struct retro_vfs_interface, or NULL for the default.
See also
SDL_LIBRETRO_DISABLE_VFS
retro_vfs_interface

Definition at line 562 of file SDL_libretro_vfs.h.

Referenced by SDL_Libretro_Create(), SDL_Libretro_PhysFS_Init(), and SDL_Libretro_PhysFS_Quit().

◆ SDL_Libretro_SetVirtualButton()

void SDL_Libretro_SetVirtualButton ( SDL_Libretro *  lr,
unsigned  port,
int  button,
bool  pressed 
)

Press or release a joypad button from code, such as from an on-screen touch control.

The button stays held until released with pressed set to false, and works alongside the keyboard and gamepad. All virtual buttons are released when the core is unloaded. Invalid arguments are ignored.

Parameters
lrthe libretro context.
portthe controller port, at a max of SDL_LIBRETRO_MAX_USERS.
buttonthe RETRO_DEVICE_ID_JOYPAD_* button, below SDL_LIBRETRO_MAX_JOYPAD_BUTTONS.
pressedtrue to hold the button down, false to release it.

Definition at line 898 of file SDL_libretro_input.h.

References SDL_LIBRETRO_MAX_USERS.

◆ SDL_Libretro_SetVolume()

void SDL_Libretro_SetVolume ( SDL_Libretro *  lr,
float  volume 
)

Set the audio volume when playing sounds.

The volume is kept across core and game loads, and applied to the audio stream as soon as one is open.

Parameters
lrthe libretro context. NULL is ignored.
volumethe volume, from 0.0 (silent) to 1.0 (full); values outside that range are clamped.
See also
SDL_Libretro_GetVolume()

Definition at line 2066 of file SDL_libretro_core.h.

Referenced by SDL_Libretro_Create(), and SDL_Libretro_InitConfigFile().

◆ SDL_Libretro_ShouldQuit()

bool SDL_Libretro_ShouldQuit ( const SDL_Libretro *  lr)

Indicates whether or not the core has requested to shutdown.

The request lasts until the game unloads, so loading another game clears it.

Parameters
lrthe libretro context.
Returns
true when the core requested to shut down, false otherwise or when lr is NULL.
See also
RETRO_ENVIRONMENT_SHUTDOWN
SDL_EVENT_LIBRETRO_SHUTDOWN

Definition at line 1636 of file SDL_libretro_core.h.

◆ SDL_Libretro_ToggleMenu()

void SDL_Libretro_ToggleMenu ( SDL_LibretroMenu *  menu)

Opens the menu when it is closed, or closes it when it is open.

This is what the toggle key (SDL_LIBRETRO_MENU_TOGGLE_KEY) and the gamepad Guide button do in SDL_Libretro_HandleMenuEvent().

Parameters
menuthe menu to toggle. NULL is ignored.
See also
SDL_Libretro_SetMenuOpen()

Definition at line 2569 of file SDL_libretro_menu.h.

References SDL_Libretro_SetMenuOpen().

Referenced by SDL_Libretro_HandleMenuEvent().

◆ SDL_Libretro_UnloadCore()

void SDL_Libretro_UnloadCore ( SDL_Libretro *  lr)

Unloads the actively loaded core.

Will also unload the game if it's still loaded.

Parameters
lrthe libretro context. NULL is ignored.
See also
SDL_Libretro_UnloadGame()

Definition at line 326 of file SDL_libretro_core.h.

References SDL_EVENT_LIBRETRO_CORE_UNLOADED, SDL_Libretro_IsCoreReady(), and SDL_Libretro_UnloadGame().

Referenced by SDL_Libretro_Destroy(), and SDL_Libretro_LoadCore().

◆ SDL_Libretro_UnloadGame()

void SDL_Libretro_UnloadGame ( SDL_Libretro *  lr)

Unloads the actively loaded game.

The core stays loaded.

Parameters
lrthe libretro context. NULL, or no game loaded, is ignored.
See also
SDL_Libretro_UnloadCore()

Definition at line 1349 of file SDL_libretro_core.h.

References SDL_EVENT_LIBRETRO_GAME_UNLOADED.

Referenced by SDL_Libretro_Destroy(), SDL_Libretro_LoadGameSpecialById(), SDL_Libretro_PhysFS_LoadGame(), and SDL_Libretro_UnloadCore().

◆ SDL_Libretro_Update()

void SDL_Libretro_Update ( SDL_Libretro *  lr)

Runs the loaded game; call it once per frame of the application's loop.

The core is paced to its own frame rate scaled by the speed, so this may run zero, one, or several core frames per call. Pending video and audio reinitializations happen here. Nothing runs while the speed is 0, or once the core has requested shutdown, and a negative speed steps backwards through the rewind buffer when rewind is enabled.

Parameters
lrthe libretro context. Does nothing when lr is NULL or no game is loaded.
See also
SDL_Libretro_SetSpeed()
SDL_Libretro_Render()

Definition at line 1501 of file SDL_libretro_core.h.

References SDL_LIBRETRO_GET_TICKS_NS, and SDL_LIBRETRO_MAX_USERS.

◆ SDL_Libretro_UpdateMenu()

void SDL_Libretro_UpdateMenu ( SDL_LibretroMenu *  menu)

Processes input and lays out the menu for this frame.

Call once per frame, after the frame's events went through SDL_Libretro_HandleMenuEvent() and after SDL_Libretro_Render(), then follow it with SDL_Libretro_RenderMenu(). Opens the menu whenever no game is running. While open, it refreshes the pages that depend on the loaded core, shows or hides the game-only entries, and writes changed menu settings to the config. Does nothing else while the menu is closed.

Parameters
menuthe menu to update. NULL is ignored.
See also
SDL_Libretro_RenderMenu()
SDL_Libretro_HandleMenuEvent()

Definition at line 2758 of file SDL_libretro_menu.h.

References SDL_Libretro_GetMessage(), SDL_Libretro_GetMessageProgress(), SDL_Libretro_IsGameReady(), and SDL_Libretro_SetMenuOpen().

◆ SDL_Libretro_UpdateOptionVisibility()

bool SDL_Libretro_UpdateOptionVisibility ( SDL_Libretro *  lr)

Ask the core to refresh which of its options should be displayed.

Calls the core's update display callback, which may update each option's visible flag based on the current option values. Call this before showing an options menu, or after changing a value while one is shown.

Parameters
lrthe libretro context.
Returns
true if the core reports that the visibility of any option changed, false if nothing changed or the core provides no such callback.
See also
SDL_Libretro_GetOptionByIndex()

Definition at line 489 of file SDL_libretro_options.h.