SDL_Libretro
SDL3-power libretro frontend.
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Enumerations | Functions
SDL_libretro.h File Reference

SDL_libretro - SDL3 libretro frontend library. More...

Go to the source code of this file.

Data Structures

struct  SDL_LibretroCategory
 A group of related core options. More...
 
struct  SDL_LibretroMicrophone
 
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_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_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_LibretroMicrophone SDL_LibretroMicrophone
 
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_LibretroFitMode { }
 When rendering the libretro context, determine how to display within the destination. More...
 

Functions

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)
 Builds 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.
 
float SDL_Libretro_GetAspectRatio (const SDL_Libretro *lr)
 Gets the aspect ratio for the libretro context.
 
const SDL_LibretroCategory * SDL_Libretro_GetCategory (const SDL_Libretro *lr, const char *key)
 Retrieve an option category by key, or NULL if there's no such category.
 
const SDL_LibretroCategory * SDL_Libretro_GetCategoryByIndex (const SDL_Libretro *lr, unsigned index)
 Retrieve an option category by index, or NULL if out of range.
 
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_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.
 
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.
 
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.
 
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.
 
const char * SDL_Libretro_GetMessage (SDL_Libretro *lr)
 Gets the most relevent libretro message to display from the queue.
 
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, or NULL if out of range.
 
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, or NULL if there's no such option.
 
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.
 
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.
 
void SDL_Libretro_GetSize (const SDL_Libretro *lr, int *w, int *h)
 Gets the width and heigh tof the given libretro context.
 
size_t SDL_Libretro_GetStateSize (const SDL_Libretro *lr)
 Retrieves the size of serialized states.
 
const char * SDL_Libretro_GetValidExtensions (const SDL_Libretro *lr)
 Gets the default set of valid extensions associated with the core, seperated by a "|".
 
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_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_LoadCore (SDL_Libretro *lr, const char *corePath)
 Loads a libretro core.
 
bool SDL_Libretro_LoadGame (SDL_Libretro *lr, const char *gamePath)
 Loads a game at the given path.
 
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 current SRAM to the given file.
 
bool SDL_Libretro_LoadState (SDL_Libretro *lr, const char *file)
 Loads the libretro state from the given file.
 
bool SDL_Libretro_Render (SDL_Renderer *renderer, SDL_Libretro *lr, const SDL_FRect *dstRect)
 Render the libretro context in the given renderer.
 
void SDL_Libretro_ResetAllOptions (SDL_Libretro *lr)
 Reset every core option to its default value.
 
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_SaveSRAM (SDL_Libretro *lr, const char *file)
 Saves the current SRAM to the given file.
 
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_SetAudioLatency (SDL_Libretro *lr, unsigned latencyMs)
 Set the desired minimum audio latency for the audio stream.
 
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.
 
void SDL_Libretro_SetFitMode (SDL_Libretro *lr, SDL_LibretroFitMode mode)
 Sets the desired scale mode for the libretro context when it's displayed.
 
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_SetMessage (SDL_Libretro *lr, const char *msg, double duration)
 Add a message to be displayed within the libretro context.
 
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_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.
 
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_UnloadCore (SDL_Libretro *lr)
 Unloads the actively loaded core.
 
void SDL_Libretro_UnloadGame (SDL_Libretro *lr)
 Unloads the actively loaded game.
 

Detailed Description

SDL_libretro - SDL3 libretro frontend library.

Single-header library. To compile the implementation, define SDL_LIBRETRO_IMPLEMENTATION in exactly ONE translation unit before including this header:

#define SDL_LIBRETRO_IMPLEMENTATION
#include "SDL_libretro.h"

Every other translation unit includes "SDL_libretro.h" normally.

Copyright (c) 2026 Rob Loach

This software is provided "as-is", without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.

Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:

  1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.

Definition in file SDL_libretro.h.

Typedef Documentation

◆ SDL_LibretroMicrophone

See also
SDL_Libretro_MicOpen()