+ /* Same definition as retro_get_system_info(). */
+ const char *valid_extensions;
+
+ /* Same definition as retro_get_system_info(). */
+ bool need_fullpath;
+
+ /* Same definition as retro_get_system_info(). */
+ bool block_extract;
+
+ /* This is set if the content is required to load a game.
+ * If this is set to false, a zeroed-out retro_game_info can be passed. */
+ bool required;
+
+ /* Content can have multiple associated persistent
+ * memory types (retro_get_memory()). */
+ const struct retro_subsystem_memory_info *memory;
+ unsigned num_memory;
+};
+
+struct retro_subsystem_info
+{
+ /* Human-readable string of the subsystem type, e.g. "Super GameBoy" */
+ const char *desc;
+
+ /* A computer friendly short string identifier for the subsystem type.
+ * This name must be [a-z].
+ * E.g. if desc is "Super GameBoy", this can be "sgb".
+ * This identifier can be used for command-line interfaces, etc.
+ */
+ const char *ident;
+
+ /* Infos for each content file. The first entry is assumed to be the
+ * "most significant" content for frontend purposes.
+ * E.g. with Super GameBoy, the first content should be the GameBoy ROM,
+ * as it is the most "significant" content to a user.
+ * If a frontend creates new file paths based on the content used
+ * (e.g. savestates), it should use the path for the first ROM to do so. */
+ const struct retro_subsystem_rom_info *roms;
+
+ /* Number of content files associated with a subsystem. */
+ unsigned num_roms;
+
+ /* The type passed to retro_load_game_special(). */
+ unsigned id;
+};
+
+typedef void (*retro_proc_address_t)(void);
+
+/* libretro API extension functions:
+ * (None here so far).
+ *
+ * Get a symbol from a libretro core.
+ * Cores should only return symbols which are actual
+ * extensions to the libretro API.
+ *
+ * Frontends should not use this to obtain symbols to standard
+ * libretro entry points (static linking or dlsym).
+ *
+ * The symbol name must be equal to the function name,
+ * e.g. if void retro_foo(void); exists, the symbol must be called "retro_foo".
+ * The returned function pointer must be cast to the corresponding type.
+ */
+typedef retro_proc_address_t (*retro_get_proc_address_t)(const char *sym);
+
+struct retro_get_proc_address_interface
+{
+ retro_get_proc_address_t get_proc_address;
+};
+
+enum retro_log_level
+{
+ RETRO_LOG_DEBUG = 0,
+ RETRO_LOG_INFO,
+ RETRO_LOG_WARN,
+ RETRO_LOG_ERROR,
+
+ RETRO_LOG_DUMMY = INT_MAX
+};
+
+/* Logging function. Takes log level argument as well. */
+typedef void (*retro_log_printf_t)(enum retro_log_level level,
+ const char *fmt, ...);
+
+struct retro_log_callback
+{
+ retro_log_printf_t log;
+};
+
+/* Performance related functions */
+
+/* ID values for SIMD CPU features */
+#define RETRO_SIMD_SSE (1 << 0)
+#define RETRO_SIMD_SSE2 (1 << 1)
+#define RETRO_SIMD_VMX (1 << 2)
+#define RETRO_SIMD_VMX128 (1 << 3)
+#define RETRO_SIMD_AVX (1 << 4)
+#define RETRO_SIMD_NEON (1 << 5)
+#define RETRO_SIMD_SSE3 (1 << 6)
+#define RETRO_SIMD_SSSE3 (1 << 7)
+#define RETRO_SIMD_MMX (1 << 8)
+#define RETRO_SIMD_MMXEXT (1 << 9)
+#define RETRO_SIMD_SSE4 (1 << 10)
+#define RETRO_SIMD_SSE42 (1 << 11)
+#define RETRO_SIMD_AVX2 (1 << 12)
+#define RETRO_SIMD_VFPU (1 << 13)
+#define RETRO_SIMD_PS (1 << 14)
+#define RETRO_SIMD_AES (1 << 15)
+#define RETRO_SIMD_VFPV3 (1 << 16)
+#define RETRO_SIMD_VFPV4 (1 << 17)
+#define RETRO_SIMD_POPCNT (1 << 18)
+#define RETRO_SIMD_MOVBE (1 << 19)
+
+typedef uint64_t retro_perf_tick_t;
+typedef int64_t retro_time_t;
+
+struct retro_perf_counter
+{
+ const char *ident;
+ retro_perf_tick_t start;
+ retro_perf_tick_t total;
+ retro_perf_tick_t call_cnt;
+
+ bool registered;
+};
+
+/* Returns current time in microseconds.
+ * Tries to use the most accurate timer available.
+ */
+typedef retro_time_t (*retro_perf_get_time_usec_t)(void);
+
+/* A simple counter. Usually nanoseconds, but can also be CPU cycles.
+ * Can be used directly if desired (when creating a more sophisticated
+ * performance counter system).
+ * */
+typedef retro_perf_tick_t (*retro_perf_get_counter_t)(void);
+
+/* Returns a bit-mask of detected CPU features (RETRO_SIMD_*). */
+typedef uint64_t (*retro_get_cpu_features_t)(void);
+
+/* Asks frontend to log and/or display the state of performance counters.
+ * Performance counters can always be poked into manually as well.
+ */
+typedef void (*retro_perf_log_t)(void);
+
+/* Register a performance counter.
+ * ident field must be set with a discrete value and other values in
+ * retro_perf_counter must be 0.
+ * Registering can be called multiple times. To avoid calling to
+ * frontend redundantly, you can check registered field first. */
+typedef void (*retro_perf_register_t)(struct retro_perf_counter *counter);
+
+/* Starts a registered counter. */
+typedef void (*retro_perf_start_t)(struct retro_perf_counter *counter);
+
+/* Stops a registered counter. */
+typedef void (*retro_perf_stop_t)(struct retro_perf_counter *counter);
+
+/* For convenience it can be useful to wrap register, start and stop in macros.
+ * E.g.:
+ * #ifdef LOG_PERFORMANCE
+ * #define RETRO_PERFORMANCE_INIT(perf_cb, name) static struct retro_perf_counter name = {#name}; if (!name.registered) perf_cb.perf_register(&(name))
+ * #define RETRO_PERFORMANCE_START(perf_cb, name) perf_cb.perf_start(&(name))
+ * #define RETRO_PERFORMANCE_STOP(perf_cb, name) perf_cb.perf_stop(&(name))
+ * #else
+ * ... Blank macros ...
+ * #endif
+ *
+ * These can then be used mid-functions around code snippets.
+ *
+ * extern struct retro_perf_callback perf_cb; * Somewhere in the core.
+ *
+ * void do_some_heavy_work(void)
+ * {
+ * RETRO_PERFORMANCE_INIT(cb, work_1;
+ * RETRO_PERFORMANCE_START(cb, work_1);
+ * heavy_work_1();
+ * RETRO_PERFORMANCE_STOP(cb, work_1);
+ *
+ * RETRO_PERFORMANCE_INIT(cb, work_2);
+ * RETRO_PERFORMANCE_START(cb, work_2);
+ * heavy_work_2();
+ * RETRO_PERFORMANCE_STOP(cb, work_2);
+ * }
+ *
+ * void retro_deinit(void)
+ * {
+ * perf_cb.perf_log(); * Log all perf counters here for example.
+ * }
+ */
+
+struct retro_perf_callback
+{
+ retro_perf_get_time_usec_t get_time_usec;
+ retro_get_cpu_features_t get_cpu_features;
+
+ retro_perf_get_counter_t get_perf_counter;
+ retro_perf_register_t perf_register;
+ retro_perf_start_t perf_start;
+ retro_perf_stop_t perf_stop;
+ retro_perf_log_t perf_log;
+};
+
+/* FIXME: Document the sensor API and work out behavior.
+ * It will be marked as experimental until then.
+ */
+enum retro_sensor_action
+{
+ RETRO_SENSOR_ACCELEROMETER_ENABLE = 0,
+ RETRO_SENSOR_ACCELEROMETER_DISABLE,
+
+ RETRO_SENSOR_DUMMY = INT_MAX
+};
+
+/* Id values for SENSOR types. */
+#define RETRO_SENSOR_ACCELEROMETER_X 0
+#define RETRO_SENSOR_ACCELEROMETER_Y 1
+#define RETRO_SENSOR_ACCELEROMETER_Z 2
+
+typedef bool (*retro_set_sensor_state_t)(unsigned port,
+ enum retro_sensor_action action, unsigned rate);
+
+typedef float (*retro_sensor_get_input_t)(unsigned port, unsigned id);
+
+struct retro_sensor_interface
+{
+ retro_set_sensor_state_t set_sensor_state;
+ retro_sensor_get_input_t get_sensor_input;
+};
+
+enum retro_camera_buffer
+{
+ RETRO_CAMERA_BUFFER_OPENGL_TEXTURE = 0,
+ RETRO_CAMERA_BUFFER_RAW_FRAMEBUFFER,
+
+ RETRO_CAMERA_BUFFER_DUMMY = INT_MAX
+};
+
+/* Starts the camera driver. Can only be called in retro_run(). */
+typedef bool (*retro_camera_start_t)(void);
+
+/* Stops the camera driver. Can only be called in retro_run(). */
+typedef void (*retro_camera_stop_t)(void);
+
+/* Callback which signals when the camera driver is initialized
+ * and/or deinitialized.
+ * retro_camera_start_t can be called in initialized callback.
+ */
+typedef void (*retro_camera_lifetime_status_t)(void);
+
+/* A callback for raw framebuffer data. buffer points to an XRGB8888 buffer.
+ * Width, height and pitch are similar to retro_video_refresh_t.
+ * First pixel is top-left origin.
+ */
+typedef void (*retro_camera_frame_raw_framebuffer_t)(const uint32_t *buffer,
+ unsigned width, unsigned height, size_t pitch);
+
+/* A callback for when OpenGL textures are used.
+ *
+ * texture_id is a texture owned by camera driver.
+ * Its state or content should be considered immutable, except for things like
+ * texture filtering and clamping.
+ *
+ * texture_target is the texture target for the GL texture.
+ * These can include e.g. GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE, and possibly
+ * more depending on extensions.
+ *
+ * affine points to a packed 3x3 column-major matrix used to apply an affine
+ * transform to texture coordinates. (affine_matrix * vec3(coord_x, coord_y, 1.0))
+ * After transform, normalized texture coord (0, 0) should be bottom-left
+ * and (1, 1) should be top-right (or (width, height) for RECTANGLE).
+ *
+ * GL-specific typedefs are avoided here to avoid relying on gl.h in
+ * the API definition.
+ */
+typedef void (*retro_camera_frame_opengl_texture_t)(unsigned texture_id,
+ unsigned texture_target, const float *affine);
+
+struct retro_camera_callback
+{
+ /* Set by libretro core.
+ * Example bitmask: caps = (1 << RETRO_CAMERA_BUFFER_OPENGL_TEXTURE) | (1 << RETRO_CAMERA_BUFFER_RAW_FRAMEBUFFER).
+ */
+ uint64_t caps;
+
+ unsigned width; /* Desired resolution for camera. Is only used as a hint. */
+ unsigned height;
+ retro_camera_start_t start; /* Set by frontend. */
+ retro_camera_stop_t stop; /* Set by frontend. */
+
+ /* Set by libretro core if raw framebuffer callbacks will be used. */
+ retro_camera_frame_raw_framebuffer_t frame_raw_framebuffer;
+ /* Set by libretro core if OpenGL texture callbacks will be used. */
+ retro_camera_frame_opengl_texture_t frame_opengl_texture;
+
+ /* Set by libretro core. Called after camera driver is initialized and
+ * ready to be started.
+ * Can be NULL, in which this callback is not called.
+ */
+ retro_camera_lifetime_status_t initialized;
+
+ /* Set by libretro core. Called right before camera driver is
+ * deinitialized.
+ * Can be NULL, in which this callback is not called.
+ */
+ retro_camera_lifetime_status_t deinitialized;
+};
+
+/* Sets the interval of time and/or distance at which to update/poll
+ * location-based data.
+ *
+ * To ensure compatibility with all location-based implementations,
+ * values for both interval_ms and interval_distance should be provided.
+ *
+ * interval_ms is the interval expressed in milliseconds.
+ * interval_distance is the distance interval expressed in meters.
+ */
+typedef void (*retro_location_set_interval_t)(unsigned interval_ms,
+ unsigned interval_distance);
+
+/* Start location services. The device will start listening for changes to the
+ * current location at regular intervals (which are defined with
+ * retro_location_set_interval_t). */
+typedef bool (*retro_location_start_t)(void);
+
+/* Stop location services. The device will stop listening for changes
+ * to the current location. */
+typedef void (*retro_location_stop_t)(void);
+
+/* Get the position of the current location. Will set parameters to
+ * 0 if no new location update has happened since the last time. */
+typedef bool (*retro_location_get_position_t)(double *lat, double *lon,
+ double *horiz_accuracy, double *vert_accuracy);
+
+/* Callback which signals when the location driver is initialized
+ * and/or deinitialized.
+ * retro_location_start_t can be called in initialized callback.
+ */
+typedef void (*retro_location_lifetime_status_t)(void);
+
+struct retro_location_callback
+{
+ retro_location_start_t start;
+ retro_location_stop_t stop;
+ retro_location_get_position_t get_position;
+ retro_location_set_interval_t set_interval;
+
+ retro_location_lifetime_status_t initialized;
+ retro_location_lifetime_status_t deinitialized;
+};
+
+enum retro_rumble_effect
+{
+ RETRO_RUMBLE_STRONG = 0,
+ RETRO_RUMBLE_WEAK = 1,
+
+ RETRO_RUMBLE_DUMMY = INT_MAX
+};
+
+/* Sets rumble state for joypad plugged in port 'port'.
+ * Rumble effects are controlled independently,
+ * and setting e.g. strong rumble does not override weak rumble.
+ * Strength has a range of [0, 0xffff].
+ *
+ * Returns true if rumble state request was honored.
+ * Calling this before first retro_run() is likely to return false. */
+typedef bool (*retro_set_rumble_state_t)(unsigned port,
+ enum retro_rumble_effect effect, uint16_t strength);
+
+struct retro_rumble_interface
+{
+ retro_set_rumble_state_t set_rumble_state;
+};
+
+/* Notifies libretro that audio data should be written. */
+typedef void (*retro_audio_callback_t)(void);
+
+/* True: Audio driver in frontend is active, and callback is
+ * expected to be called regularily.
+ * False: Audio driver in frontend is paused or inactive.
+ * Audio callback will not be called until set_state has been
+ * called with true.
+ * Initial state is false (inactive).
+ */
+typedef void (*retro_audio_set_state_callback_t)(bool enabled);
+
+struct retro_audio_callback
+{
+ retro_audio_callback_t callback;
+ retro_audio_set_state_callback_t set_state;
+};
+
+/* Notifies a libretro core of time spent since last invocation
+ * of retro_run() in microseconds.
+ *
+ * It will be called right before retro_run() every frame.
+ * The frontend can tamper with timing to support cases like
+ * fast-forward, slow-motion and framestepping.
+ *
+ * In those scenarios the reference frame time value will be used. */
+typedef int64_t retro_usec_t;
+typedef void (*retro_frame_time_callback_t)(retro_usec_t usec);
+struct retro_frame_time_callback
+{
+ retro_frame_time_callback_t callback;
+ /* Represents the time of one frame. It is computed as
+ * 1000000 / fps, but the implementation will resolve the
+ * rounding to ensure that framestepping, etc is exact. */
+ retro_usec_t reference;
+};
+
+/* Pass this to retro_video_refresh_t if rendering to hardware.
+ * Passing NULL to retro_video_refresh_t is still a frame dupe as normal.
+ * */
+#define RETRO_HW_FRAME_BUFFER_VALID ((void*)-1)
+
+/* Invalidates the current HW context.
+ * Any GL state is lost, and must not be deinitialized explicitly.
+ * If explicit deinitialization is desired by the libretro core,
+ * it should implement context_destroy callback.
+ * If called, all GPU resources must be reinitialized.
+ * Usually called when frontend reinits video driver.
+ * Also called first time video driver is initialized,
+ * allowing libretro core to initialize resources.
+ */
+typedef void (*retro_hw_context_reset_t)(void);
+
+/* Gets current framebuffer which is to be rendered to.
+ * Could change every frame potentially.
+ */
+typedef uintptr_t (*retro_hw_get_current_framebuffer_t)(void);
+
+/* Get a symbol from HW context. */
+typedef retro_proc_address_t (*retro_hw_get_proc_address_t)(const char *sym);
+
+enum retro_hw_context_type
+{
+ RETRO_HW_CONTEXT_NONE = 0,
+ /* OpenGL 2.x. Driver can choose to use latest compatibility context. */
+ RETRO_HW_CONTEXT_OPENGL = 1,
+ /* OpenGL ES 2.0. */
+ RETRO_HW_CONTEXT_OPENGLES2 = 2,
+ /* Modern desktop core GL context. Use version_major/
+ * version_minor fields to set GL version. */
+ RETRO_HW_CONTEXT_OPENGL_CORE = 3,
+ /* OpenGL ES 3.0 */
+ RETRO_HW_CONTEXT_OPENGLES3 = 4,
+ /* OpenGL ES 3.1+. Set version_major/version_minor. For GLES2 and GLES3,
+ * use the corresponding enums directly. */
+ RETRO_HW_CONTEXT_OPENGLES_VERSION = 5,
+
+ /* Vulkan, see RETRO_ENVIRONMENT_GET_HW_RENDER_INTERFACE. */
+ RETRO_HW_CONTEXT_VULKAN = 6,
+
+ RETRO_HW_CONTEXT_DUMMY = INT_MAX
+};
+
+struct retro_hw_render_callback
+{
+ /* Which API to use. Set by libretro core. */
+ enum retro_hw_context_type context_type;
+
+ /* Called when a context has been created or when it has been reset.
+ * An OpenGL context is only valid after context_reset() has been called.
+ *
+ * When context_reset is called, OpenGL resources in the libretro
+ * implementation are guaranteed to be invalid.
+ *
+ * It is possible that context_reset is called multiple times during an
+ * application lifecycle.
+ * If context_reset is called without any notification (context_destroy),
+ * the OpenGL context was lost and resources should just be recreated
+ * without any attempt to "free" old resources.
+ */
+ retro_hw_context_reset_t context_reset;
+
+ /* Set by frontend.
+ * TODO: This is rather obsolete. The frontend should not
+ * be providing preallocated framebuffers. */
+ retro_hw_get_current_framebuffer_t get_current_framebuffer;
+
+ /* Set by frontend. */
+ retro_hw_get_proc_address_t get_proc_address;
+
+ /* Set if render buffers should have depth component attached.
+ * TODO: Obsolete. */
+ bool depth;
+
+ /* Set if stencil buffers should be attached.
+ * TODO: Obsolete. */
+ bool stencil;
+
+ /* If depth and stencil are true, a packed 24/8 buffer will be added.
+ * Only attaching stencil is invalid and will be ignored. */
+
+ /* Use conventional bottom-left origin convention. If false,
+ * standard libretro top-left origin semantics are used.
+ * TODO: Move to GL specific interface. */
+ bool bottom_left_origin;
+
+ /* Major version number for core GL context or GLES 3.1+. */
+ unsigned version_major;
+
+ /* Minor version number for core GL context or GLES 3.1+. */
+ unsigned version_minor;
+
+ /* If this is true, the frontend will go very far to avoid
+ * resetting context in scenarios like toggling fullscreen, etc.
+ * TODO: Obsolete? Maybe frontend should just always assume this ...
+ */
+ bool cache_context;
+
+ /* The reset callback might still be called in extreme situations
+ * such as if the context is lost beyond recovery.
+ *
+ * For optimal stability, set this to false, and allow context to be
+ * reset at any time.
+ */
+
+ /* A callback to be called before the context is destroyed in a
+ * controlled way by the frontend. */
+ retro_hw_context_reset_t context_destroy;
+
+ /* OpenGL resources can be deinitialized cleanly at this step.
+ * context_destroy can be set to NULL, in which resources will
+ * just be destroyed without any notification.
+ *
+ * Even when context_destroy is non-NULL, it is possible that
+ * context_reset is called without any destroy notification.
+ * This happens if context is lost by external factors (such as
+ * notified by GL_ARB_robustness).
+ *
+ * In this case, the context is assumed to be already dead,
+ * and the libretro implementation must not try to free any OpenGL
+ * resources in the subsequent context_reset.
+ */
+
+ /* Creates a debug context. */
+ bool debug_context;
+};
+
+/* Callback type passed in RETRO_ENVIRONMENT_SET_KEYBOARD_CALLBACK.
+ * Called by the frontend in response to keyboard events.
+ * down is set if the key is being pressed, or false if it is being released.
+ * keycode is the RETROK value of the char.
+ * character is the text character of the pressed key. (UTF-32).
+ * key_modifiers is a set of RETROKMOD values or'ed together.
+ *
+ * The pressed/keycode state can be indepedent of the character.
+ * It is also possible that multiple characters are generated from a
+ * single keypress.
+ * Keycode events should be treated separately from character events.
+ * However, when possible, the frontend should try to synchronize these.
+ * If only a character is posted, keycode should be RETROK_UNKNOWN.
+ *
+ * Similarily if only a keycode event is generated with no corresponding
+ * character, character should be 0.
+ */
+typedef void (*retro_keyboard_event_t)(bool down, unsigned keycode,
+ uint32_t character, uint16_t key_modifiers);
+
+struct retro_keyboard_callback
+{
+ retro_keyboard_event_t callback;
+};
+
+/* Callbacks for RETRO_ENVIRONMENT_SET_DISK_CONTROL_INTERFACE.
+ * Should be set for implementations which can swap out multiple disk
+ * images in runtime.
+ *
+ * If the implementation can do this automatically, it should strive to do so.
+ * However, there are cases where the user must manually do so.
+ *
+ * Overview: To swap a disk image, eject the disk image with
+ * set_eject_state(true).
+ * Set the disk index with set_image_index(index). Insert the disk again
+ * with set_eject_state(false).
+ */
+
+/* If ejected is true, "ejects" the virtual disk tray.
+ * When ejected, the disk image index can be set.
+ */