CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
Path: blob/master/libretro/libretro.h
Views: 1401
/* Copyright (C) 2010-2020 The RetroArch team1*2* ---------------------------------------------------------------------------------------3* The following license statement only applies to this libretro API header (libretro.h).4* ---------------------------------------------------------------------------------------5*6* Permission is hereby granted, free of charge,7* to any person obtaining a copy of this software and associated documentation files (the "Software"),8* to deal in the Software without restriction, including without limitation the rights to9* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,10* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:11*12* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,15* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.17* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,18* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,19* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.20*/2122#ifndef LIBRETRO_H__23#define LIBRETRO_H__2425#include <stdint.h>26#include <stddef.h>27#include <limits.h>2829#ifdef __cplusplus30extern "C" {31#endif3233#ifndef __cplusplus34#if defined(_MSC_VER) && _MSC_VER < 1800 && !defined(SN_TARGET_PS3)35/* Hack applied for MSVC when compiling in C89 mode36* as it isn't C99-compliant. */37#define bool unsigned char38#define true 139#define false 040#else41#include <stdbool.h>42#endif43#endif4445#ifndef RETRO_CALLCONV46# if defined(__GNUC__) && defined(__i386__) && !defined(__x86_64__)47# define RETRO_CALLCONV __attribute__((cdecl))48# elif defined(_MSC_VER) && defined(_M_X86) && !defined(_M_X64)49# define RETRO_CALLCONV __cdecl50# else51# define RETRO_CALLCONV /* all other platforms only have one calling convention each */52# endif53#endif5455#ifndef RETRO_API56# if defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__)57# ifdef RETRO_IMPORT_SYMBOLS58# ifdef __GNUC__59# define RETRO_API RETRO_CALLCONV __attribute__((__dllimport__))60# else61# define RETRO_API RETRO_CALLCONV __declspec(dllimport)62# endif63# else64# ifdef __GNUC__65# define RETRO_API RETRO_CALLCONV __attribute__((__dllexport__))66# else67# define RETRO_API RETRO_CALLCONV __declspec(dllexport)68# endif69# endif70# else71# if defined(__GNUC__) && __GNUC__ >= 472# define RETRO_API RETRO_CALLCONV __attribute__((__visibility__("default")))73# else74# define RETRO_API RETRO_CALLCONV75# endif76# endif77#endif7879/* Used for checking API/ABI mismatches that can break libretro80* implementations.81* It is not incremented for compatible changes to the API.82*/83#define RETRO_API_VERSION 18485/*86* Libretro's fundamental device abstractions.87*88* Libretro's input system consists of some standardized device types,89* such as a joypad (with/without analog), mouse, keyboard, lightgun90* and a pointer.91*92* The functionality of these devices are fixed, and individual cores93* map their own concept of a controller to libretro's abstractions.94* This makes it possible for frontends to map the abstract types to a95* real input device, and not having to worry about binding input96* correctly to arbitrary controller layouts.97*/9899#define RETRO_DEVICE_TYPE_SHIFT 8100#define RETRO_DEVICE_MASK ((1 << RETRO_DEVICE_TYPE_SHIFT) - 1)101#define RETRO_DEVICE_SUBCLASS(base, id) (((id + 1) << RETRO_DEVICE_TYPE_SHIFT) | base)102103/* Input disabled. */104#define RETRO_DEVICE_NONE 0105106/* The JOYPAD is called RetroPad. It is essentially a Super Nintendo107* controller, but with additional L2/R2/L3/R3 buttons, similar to a108* PS1 DualShock. */109#define RETRO_DEVICE_JOYPAD 1110111/* The mouse is a simple mouse, similar to Super Nintendo's mouse.112* X and Y coordinates are reported relatively to last poll (poll callback).113* It is up to the libretro implementation to keep track of where the mouse114* pointer is supposed to be on the screen.115* The frontend must make sure not to interfere with its own hardware116* mouse pointer.117*/118#define RETRO_DEVICE_MOUSE 2119120/* KEYBOARD device lets one poll for raw key pressed.121* It is poll based, so input callback will return with the current122* pressed state.123* For event/text based keyboard input, see124* RETRO_ENVIRONMENT_SET_KEYBOARD_CALLBACK.125*/126#define RETRO_DEVICE_KEYBOARD 3127128/* LIGHTGUN device is similar to Guncon-2 for PlayStation 2.129* It reports X/Y coordinates in screen space (similar to the pointer)130* in the range [-0x8000, 0x7fff] in both axes, with zero being center and131* -0x8000 being out of bounds.132* As well as reporting on/off screen state. It features a trigger,133* start/select buttons, auxiliary action buttons and a134* directional pad. A forced off-screen shot can be requested for135* auto-reloading function in some games.136*/137#define RETRO_DEVICE_LIGHTGUN 4138139/* The ANALOG device is an extension to JOYPAD (RetroPad).140* Similar to DualShock2 it adds two analog sticks and all buttons can141* be analog. This is treated as a separate device type as it returns142* axis values in the full analog range of [-0x7fff, 0x7fff],143* although some devices may return -0x8000.144* Positive X axis is right. Positive Y axis is down.145* Buttons are returned in the range [0, 0x7fff].146* Only use ANALOG type when polling for analog values.147*/148#define RETRO_DEVICE_ANALOG 5149150/* Abstracts the concept of a pointing mechanism, e.g. touch.151* This allows libretro to query in absolute coordinates where on the152* screen a mouse (or something similar) is being placed.153* For a touch centric device, coordinates reported are the coordinates154* of the press.155*156* Coordinates in X and Y are reported as:157* [-0x7fff, 0x7fff]: -0x7fff corresponds to the far left/top of the screen,158* and 0x7fff corresponds to the far right/bottom of the screen.159* The "screen" is here defined as area that is passed to the frontend and160* later displayed on the monitor.161*162* The frontend is free to scale/resize this screen as it sees fit, however,163* (X, Y) = (-0x7fff, -0x7fff) will correspond to the top-left pixel of the164* game image, etc.165*166* To check if the pointer coordinates are valid (e.g. a touch display167* actually being touched), PRESSED returns 1 or 0.168*169* If using a mouse on a desktop, PRESSED will usually correspond to the170* left mouse button, but this is a frontend decision.171* PRESSED will only return 1 if the pointer is inside the game screen.172*173* For multi-touch, the index variable can be used to successively query174* more presses.175* If index = 0 returns true for _PRESSED, coordinates can be extracted176* with _X, _Y for index = 0. One can then query _PRESSED, _X, _Y with177* index = 1, and so on.178* Eventually _PRESSED will return false for an index. No further presses179* are registered at this point. */180#define RETRO_DEVICE_POINTER 6181182/* Buttons for the RetroPad (JOYPAD).183* The placement of these is equivalent to placements on the184* Super Nintendo controller.185* L2/R2/L3/R3 buttons correspond to the PS1 DualShock.186* Also used as id values for RETRO_DEVICE_INDEX_ANALOG_BUTTON */187#define RETRO_DEVICE_ID_JOYPAD_B 0188#define RETRO_DEVICE_ID_JOYPAD_Y 1189#define RETRO_DEVICE_ID_JOYPAD_SELECT 2190#define RETRO_DEVICE_ID_JOYPAD_START 3191#define RETRO_DEVICE_ID_JOYPAD_UP 4192#define RETRO_DEVICE_ID_JOYPAD_DOWN 5193#define RETRO_DEVICE_ID_JOYPAD_LEFT 6194#define RETRO_DEVICE_ID_JOYPAD_RIGHT 7195#define RETRO_DEVICE_ID_JOYPAD_A 8196#define RETRO_DEVICE_ID_JOYPAD_X 9197#define RETRO_DEVICE_ID_JOYPAD_L 10198#define RETRO_DEVICE_ID_JOYPAD_R 11199#define RETRO_DEVICE_ID_JOYPAD_L2 12200#define RETRO_DEVICE_ID_JOYPAD_R2 13201#define RETRO_DEVICE_ID_JOYPAD_L3 14202#define RETRO_DEVICE_ID_JOYPAD_R3 15203204#define RETRO_DEVICE_ID_JOYPAD_MASK 256205206/* Index / Id values for ANALOG device. */207#define RETRO_DEVICE_INDEX_ANALOG_LEFT 0208#define RETRO_DEVICE_INDEX_ANALOG_RIGHT 1209#define RETRO_DEVICE_INDEX_ANALOG_BUTTON 2210#define RETRO_DEVICE_ID_ANALOG_X 0211#define RETRO_DEVICE_ID_ANALOG_Y 1212213/* Id values for MOUSE. */214#define RETRO_DEVICE_ID_MOUSE_X 0215#define RETRO_DEVICE_ID_MOUSE_Y 1216#define RETRO_DEVICE_ID_MOUSE_LEFT 2217#define RETRO_DEVICE_ID_MOUSE_RIGHT 3218#define RETRO_DEVICE_ID_MOUSE_WHEELUP 4219#define RETRO_DEVICE_ID_MOUSE_WHEELDOWN 5220#define RETRO_DEVICE_ID_MOUSE_MIDDLE 6221#define RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELUP 7222#define RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELDOWN 8223#define RETRO_DEVICE_ID_MOUSE_BUTTON_4 9224#define RETRO_DEVICE_ID_MOUSE_BUTTON_5 10225226/* Id values for LIGHTGUN. */227#define RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X 13 /*Absolute Position*/228#define RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y 14 /*Absolute*/229#define RETRO_DEVICE_ID_LIGHTGUN_IS_OFFSCREEN 15 /*Status Check*/230#define RETRO_DEVICE_ID_LIGHTGUN_TRIGGER 2231#define RETRO_DEVICE_ID_LIGHTGUN_RELOAD 16 /*Forced off-screen shot*/232#define RETRO_DEVICE_ID_LIGHTGUN_AUX_A 3233#define RETRO_DEVICE_ID_LIGHTGUN_AUX_B 4234#define RETRO_DEVICE_ID_LIGHTGUN_START 6235#define RETRO_DEVICE_ID_LIGHTGUN_SELECT 7236#define RETRO_DEVICE_ID_LIGHTGUN_AUX_C 8237#define RETRO_DEVICE_ID_LIGHTGUN_DPAD_UP 9238#define RETRO_DEVICE_ID_LIGHTGUN_DPAD_DOWN 10239#define RETRO_DEVICE_ID_LIGHTGUN_DPAD_LEFT 11240#define RETRO_DEVICE_ID_LIGHTGUN_DPAD_RIGHT 12241/* deprecated */242#define RETRO_DEVICE_ID_LIGHTGUN_X 0 /*Relative Position*/243#define RETRO_DEVICE_ID_LIGHTGUN_Y 1 /*Relative*/244#define RETRO_DEVICE_ID_LIGHTGUN_CURSOR 3 /*Use Aux:A*/245#define RETRO_DEVICE_ID_LIGHTGUN_TURBO 4 /*Use Aux:B*/246#define RETRO_DEVICE_ID_LIGHTGUN_PAUSE 5 /*Use Start*/247248/* Id values for POINTER. */249#define RETRO_DEVICE_ID_POINTER_X 0250#define RETRO_DEVICE_ID_POINTER_Y 1251#define RETRO_DEVICE_ID_POINTER_PRESSED 2252#define RETRO_DEVICE_ID_POINTER_COUNT 3253254/* Returned from retro_get_region(). */255#define RETRO_REGION_NTSC 0256#define RETRO_REGION_PAL 1257258/* Id values for LANGUAGE */259enum retro_language260{261RETRO_LANGUAGE_ENGLISH = 0,262RETRO_LANGUAGE_JAPANESE = 1,263RETRO_LANGUAGE_FRENCH = 2,264RETRO_LANGUAGE_SPANISH = 3,265RETRO_LANGUAGE_GERMAN = 4,266RETRO_LANGUAGE_ITALIAN = 5,267RETRO_LANGUAGE_DUTCH = 6,268RETRO_LANGUAGE_PORTUGUESE_BRAZIL = 7,269RETRO_LANGUAGE_PORTUGUESE_PORTUGAL = 8,270RETRO_LANGUAGE_RUSSIAN = 9,271RETRO_LANGUAGE_KOREAN = 10,272RETRO_LANGUAGE_CHINESE_TRADITIONAL = 11,273RETRO_LANGUAGE_CHINESE_SIMPLIFIED = 12,274RETRO_LANGUAGE_ESPERANTO = 13,275RETRO_LANGUAGE_POLISH = 14,276RETRO_LANGUAGE_VIETNAMESE = 15,277RETRO_LANGUAGE_ARABIC = 16,278RETRO_LANGUAGE_GREEK = 17,279RETRO_LANGUAGE_TURKISH = 18,280RETRO_LANGUAGE_SLOVAK = 19,281RETRO_LANGUAGE_PERSIAN = 20,282RETRO_LANGUAGE_HEBREW = 21,283RETRO_LANGUAGE_ASTURIAN = 22,284RETRO_LANGUAGE_FINNISH = 23,285RETRO_LANGUAGE_INDONESIAN = 24,286RETRO_LANGUAGE_SWEDISH = 25,287RETRO_LANGUAGE_UKRAINIAN = 26,288RETRO_LANGUAGE_CZECH = 27,289RETRO_LANGUAGE_CATALAN_VALENCIA = 28,290RETRO_LANGUAGE_CATALAN = 29,291RETRO_LANGUAGE_LAST,292293/* Ensure sizeof(enum) == sizeof(int) */294RETRO_LANGUAGE_DUMMY = INT_MAX295};296297/* Passed to retro_get_memory_data/size().298* If the memory type doesn't apply to the299* implementation NULL/0 can be returned.300*/301#define RETRO_MEMORY_MASK 0xff302303/* Regular save RAM. This RAM is usually found on a game cartridge,304* backed up by a battery.305* If save game data is too complex for a single memory buffer,306* the SAVE_DIRECTORY (preferably) or SYSTEM_DIRECTORY environment307* callback can be used. */308#define RETRO_MEMORY_SAVE_RAM 0309310/* Some games have a built-in clock to keep track of time.311* This memory is usually just a couple of bytes to keep track of time.312*/313#define RETRO_MEMORY_RTC 1314315/* System ram lets a frontend peek into a game systems main RAM. */316#define RETRO_MEMORY_SYSTEM_RAM 2317318/* Video ram lets a frontend peek into a game systems video RAM (VRAM). */319#define RETRO_MEMORY_VIDEO_RAM 3320321/* Keysyms used for ID in input state callback when polling RETRO_KEYBOARD. */322enum retro_key323{324RETROK_UNKNOWN = 0,325RETROK_FIRST = 0,326RETROK_BACKSPACE = 8,327RETROK_TAB = 9,328RETROK_CLEAR = 12,329RETROK_RETURN = 13,330RETROK_PAUSE = 19,331RETROK_ESCAPE = 27,332RETROK_SPACE = 32,333RETROK_EXCLAIM = 33,334RETROK_QUOTEDBL = 34,335RETROK_HASH = 35,336RETROK_DOLLAR = 36,337RETROK_AMPERSAND = 38,338RETROK_QUOTE = 39,339RETROK_LEFTPAREN = 40,340RETROK_RIGHTPAREN = 41,341RETROK_ASTERISK = 42,342RETROK_PLUS = 43,343RETROK_COMMA = 44,344RETROK_MINUS = 45,345RETROK_PERIOD = 46,346RETROK_SLASH = 47,347RETROK_0 = 48,348RETROK_1 = 49,349RETROK_2 = 50,350RETROK_3 = 51,351RETROK_4 = 52,352RETROK_5 = 53,353RETROK_6 = 54,354RETROK_7 = 55,355RETROK_8 = 56,356RETROK_9 = 57,357RETROK_COLON = 58,358RETROK_SEMICOLON = 59,359RETROK_LESS = 60,360RETROK_EQUALS = 61,361RETROK_GREATER = 62,362RETROK_QUESTION = 63,363RETROK_AT = 64,364RETROK_LEFTBRACKET = 91,365RETROK_BACKSLASH = 92,366RETROK_RIGHTBRACKET = 93,367RETROK_CARET = 94,368RETROK_UNDERSCORE = 95,369RETROK_BACKQUOTE = 96,370RETROK_a = 97,371RETROK_b = 98,372RETROK_c = 99,373RETROK_d = 100,374RETROK_e = 101,375RETROK_f = 102,376RETROK_g = 103,377RETROK_h = 104,378RETROK_i = 105,379RETROK_j = 106,380RETROK_k = 107,381RETROK_l = 108,382RETROK_m = 109,383RETROK_n = 110,384RETROK_o = 111,385RETROK_p = 112,386RETROK_q = 113,387RETROK_r = 114,388RETROK_s = 115,389RETROK_t = 116,390RETROK_u = 117,391RETROK_v = 118,392RETROK_w = 119,393RETROK_x = 120,394RETROK_y = 121,395RETROK_z = 122,396RETROK_LEFTBRACE = 123,397RETROK_BAR = 124,398RETROK_RIGHTBRACE = 125,399RETROK_TILDE = 126,400RETROK_DELETE = 127,401402RETROK_KP0 = 256,403RETROK_KP1 = 257,404RETROK_KP2 = 258,405RETROK_KP3 = 259,406RETROK_KP4 = 260,407RETROK_KP5 = 261,408RETROK_KP6 = 262,409RETROK_KP7 = 263,410RETROK_KP8 = 264,411RETROK_KP9 = 265,412RETROK_KP_PERIOD = 266,413RETROK_KP_DIVIDE = 267,414RETROK_KP_MULTIPLY = 268,415RETROK_KP_MINUS = 269,416RETROK_KP_PLUS = 270,417RETROK_KP_ENTER = 271,418RETROK_KP_EQUALS = 272,419420RETROK_UP = 273,421RETROK_DOWN = 274,422RETROK_RIGHT = 275,423RETROK_LEFT = 276,424RETROK_INSERT = 277,425RETROK_HOME = 278,426RETROK_END = 279,427RETROK_PAGEUP = 280,428RETROK_PAGEDOWN = 281,429430RETROK_F1 = 282,431RETROK_F2 = 283,432RETROK_F3 = 284,433RETROK_F4 = 285,434RETROK_F5 = 286,435RETROK_F6 = 287,436RETROK_F7 = 288,437RETROK_F8 = 289,438RETROK_F9 = 290,439RETROK_F10 = 291,440RETROK_F11 = 292,441RETROK_F12 = 293,442RETROK_F13 = 294,443RETROK_F14 = 295,444RETROK_F15 = 296,445446RETROK_NUMLOCK = 300,447RETROK_CAPSLOCK = 301,448RETROK_SCROLLOCK = 302,449RETROK_RSHIFT = 303,450RETROK_LSHIFT = 304,451RETROK_RCTRL = 305,452RETROK_LCTRL = 306,453RETROK_RALT = 307,454RETROK_LALT = 308,455RETROK_RMETA = 309,456RETROK_LMETA = 310,457RETROK_LSUPER = 311,458RETROK_RSUPER = 312,459RETROK_MODE = 313,460RETROK_COMPOSE = 314,461462RETROK_HELP = 315,463RETROK_PRINT = 316,464RETROK_SYSREQ = 317,465RETROK_BREAK = 318,466RETROK_MENU = 319,467RETROK_POWER = 320,468RETROK_EURO = 321,469RETROK_UNDO = 322,470RETROK_OEM_102 = 323,471472RETROK_LAST,473474RETROK_DUMMY = INT_MAX /* Ensure sizeof(enum) == sizeof(int) */475};476477enum retro_mod478{479RETROKMOD_NONE = 0x0000,480481RETROKMOD_SHIFT = 0x01,482RETROKMOD_CTRL = 0x02,483RETROKMOD_ALT = 0x04,484RETROKMOD_META = 0x08,485486RETROKMOD_NUMLOCK = 0x10,487RETROKMOD_CAPSLOCK = 0x20,488RETROKMOD_SCROLLOCK = 0x40,489490RETROKMOD_DUMMY = INT_MAX /* Ensure sizeof(enum) == sizeof(int) */491};492493/* If set, this call is not part of the public libretro API yet. It can494* change or be removed at any time. */495#define RETRO_ENVIRONMENT_EXPERIMENTAL 0x10000496/* Environment callback to be used internally in frontend. */497#define RETRO_ENVIRONMENT_PRIVATE 0x20000498499/* Environment commands. */500#define RETRO_ENVIRONMENT_SET_ROTATION 1 /* const unsigned * --501* Sets screen rotation of graphics.502* Valid values are 0, 1, 2, 3, which rotates screen by 0, 90, 180,503* 270 degrees counter-clockwise respectively.504*/505#define RETRO_ENVIRONMENT_GET_OVERSCAN 2 /* bool * --506* NOTE: As of 2019 this callback is considered deprecated in favor of507* using core options to manage overscan in a more nuanced, core-specific way.508*509* Boolean value whether or not the implementation should use overscan,510* or crop away overscan.511*/512#define RETRO_ENVIRONMENT_GET_CAN_DUPE 3 /* bool * --513* Boolean value whether or not frontend supports frame duping,514* passing NULL to video frame callback.515*/516517/* Environ 4, 5 are no longer supported (GET_VARIABLE / SET_VARIABLES),518* and reserved to avoid possible ABI clash.519*/520521#define RETRO_ENVIRONMENT_SET_MESSAGE 6 /* const struct retro_message * --522* Sets a message to be displayed in implementation-specific manner523* for a certain amount of 'frames'.524* Should not be used for trivial messages, which should simply be525* logged via RETRO_ENVIRONMENT_GET_LOG_INTERFACE (or as a526* fallback, stderr).527*/528#define RETRO_ENVIRONMENT_SHUTDOWN 7 /* N/A (NULL) --529* Requests the frontend to shutdown.530* Should only be used if game has a specific531* way to shutdown the game from a menu item or similar.532*/533#define RETRO_ENVIRONMENT_SET_PERFORMANCE_LEVEL 8534/* const unsigned * --535* Gives a hint to the frontend how demanding this implementation536* is on a system. E.g. reporting a level of 2 means537* this implementation should run decently on all frontends538* of level 2 and up.539*540* It can be used by the frontend to potentially warn541* about too demanding implementations.542*543* The levels are "floating".544*545* This function can be called on a per-game basis,546* as certain games an implementation can play might be547* particularly demanding.548* If called, it should be called in retro_load_game().549*/550#define RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY 9551/* const char ** --552* Returns the "system" directory of the frontend.553* This directory can be used to store system specific554* content such as BIOSes, configuration data, etc.555* The returned value can be NULL.556* If so, no such directory is defined,557* and it's up to the implementation to find a suitable directory.558*559* NOTE: Some cores used this folder also for "save" data such as560* memory cards, etc, for lack of a better place to put it.561* This is now discouraged, and if possible, cores should try to562* use the new GET_SAVE_DIRECTORY.563*/564#define RETRO_ENVIRONMENT_SET_PIXEL_FORMAT 10565/* const enum retro_pixel_format * --566* Sets the internal pixel format used by the implementation.567* The default pixel format is RETRO_PIXEL_FORMAT_0RGB1555.568* This pixel format however, is deprecated (see enum retro_pixel_format).569* If the call returns false, the frontend does not support this pixel570* format.571*572* This function should be called inside retro_load_game() or573* retro_get_system_av_info().574*/575#define RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS 11576/* const struct retro_input_descriptor * --577* Sets an array of retro_input_descriptors.578* It is up to the frontend to present this in a usable way.579* The array is terminated by retro_input_descriptor::description580* being set to NULL.581* This function can be called at any time, but it is recommended582* to call it as early as possible.583*/584#define RETRO_ENVIRONMENT_SET_KEYBOARD_CALLBACK 12585/* const struct retro_keyboard_callback * --586* Sets a callback function used to notify core about keyboard events.587*/588#define RETRO_ENVIRONMENT_SET_DISK_CONTROL_INTERFACE 13589/* const struct retro_disk_control_callback * --590* Sets an interface which frontend can use to eject and insert591* disk images.592* This is used for games which consist of multiple images and593* must be manually swapped out by the user (e.g. PSX).594*/595#define RETRO_ENVIRONMENT_SET_HW_RENDER 14596/* struct retro_hw_render_callback * --597* Sets an interface to let a libretro core render with598* hardware acceleration.599* Should be called in retro_load_game().600* If successful, libretro cores will be able to render to a601* frontend-provided framebuffer.602* The size of this framebuffer will be at least as large as603* max_width/max_height provided in get_av_info().604* If HW rendering is used, pass only RETRO_HW_FRAME_BUFFER_VALID or605* NULL to retro_video_refresh_t.606*/607#define RETRO_ENVIRONMENT_GET_VARIABLE 15608/* struct retro_variable * --609* Interface to acquire user-defined information from environment610* that cannot feasibly be supported in a multi-system way.611* 'key' should be set to a key which has already been set by612* SET_VARIABLES.613* 'data' will be set to a value or NULL.614*/615#define RETRO_ENVIRONMENT_SET_VARIABLES 16616/* const struct retro_variable * --617* Allows an implementation to signal the environment618* which variables it might want to check for later using619* GET_VARIABLE.620* This allows the frontend to present these variables to621* a user dynamically.622* This should be called the first time as early as623* possible (ideally in retro_set_environment).624* Afterward it may be called again for the core to communicate625* updated options to the frontend, but the number of core626* options must not change from the number in the initial call.627*628* 'data' points to an array of retro_variable structs629* terminated by a { NULL, NULL } element.630* retro_variable::key should be namespaced to not collide631* with other implementations' keys. E.g. A core called632* 'foo' should use keys named as 'foo_option'.633* retro_variable::value should contain a human readable634* description of the key as well as a '|' delimited list635* of expected values.636*637* The number of possible options should be very limited,638* i.e. it should be feasible to cycle through options639* without a keyboard.640*641* First entry should be treated as a default.642*643* Example entry:644* { "foo_option", "Speed hack coprocessor X; false|true" }645*646* Text before first ';' is description. This ';' must be647* followed by a space, and followed by a list of possible648* values split up with '|'.649*650* Only strings are operated on. The possible values will651* generally be displayed and stored as-is by the frontend.652*/653#define RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE 17654/* bool * --655* Result is set to true if some variables are updated by656* frontend since last call to RETRO_ENVIRONMENT_GET_VARIABLE.657* Variables should be queried with GET_VARIABLE.658*/659#define RETRO_ENVIRONMENT_SET_SUPPORT_NO_GAME 18660/* const bool * --661* If true, the libretro implementation supports calls to662* retro_load_game() with NULL as argument.663* Used by cores which can run without particular game data.664* This should be called within retro_set_environment() only.665*/666#define RETRO_ENVIRONMENT_GET_LIBRETRO_PATH 19667/* const char ** --668* Retrieves the absolute path from where this libretro669* implementation was loaded.670* NULL is returned if the libretro was loaded statically671* (i.e. linked statically to frontend), or if the path cannot be672* determined.673* Mostly useful in cooperation with SET_SUPPORT_NO_GAME as assets can674* be loaded without ugly hacks.675*/676677/* Environment 20 was an obsolete version of SET_AUDIO_CALLBACK.678* It was not used by any known core at the time,679* and was removed from the API. */680#define RETRO_ENVIRONMENT_SET_FRAME_TIME_CALLBACK 21681/* const struct retro_frame_time_callback * --682* Lets the core know how much time has passed since last683* invocation of retro_run().684* The frontend can tamper with the timing to fake fast-forward,685* slow-motion, frame stepping, etc.686* In this case the delta time will use the reference value687* in frame_time_callback..688*/689#define RETRO_ENVIRONMENT_SET_AUDIO_CALLBACK 22690/* const struct retro_audio_callback * --691* Sets an interface which is used to notify a libretro core about audio692* being available for writing.693* The callback can be called from any thread, so a core using this must694* have a thread safe audio implementation.695* It is intended for games where audio and video are completely696* asynchronous and audio can be generated on the fly.697* This interface is not recommended for use with emulators which have698* highly synchronous audio.699*700* The callback only notifies about writability; the libretro core still701* has to call the normal audio callbacks702* to write audio. The audio callbacks must be called from within the703* notification callback.704* The amount of audio data to write is up to the implementation.705* Generally, the audio callback will be called continously in a loop.706*707* Due to thread safety guarantees and lack of sync between audio and708* video, a frontend can selectively disallow this interface based on709* internal configuration. A core using this interface must also710* implement the "normal" audio interface.711*712* A libretro core using SET_AUDIO_CALLBACK should also make use of713* SET_FRAME_TIME_CALLBACK.714*/715#define RETRO_ENVIRONMENT_GET_RUMBLE_INTERFACE 23716/* struct retro_rumble_interface * --717* Gets an interface which is used by a libretro core to set718* state of rumble motors in controllers.719* A strong and weak motor is supported, and they can be720* controlled indepedently.721* Should be called from either retro_init() or retro_load_game().722* Should not be called from retro_set_environment().723* Returns false if rumble functionality is unavailable.724*/725#define RETRO_ENVIRONMENT_GET_INPUT_DEVICE_CAPABILITIES 24726/* uint64_t * --727* Gets a bitmask telling which device type are expected to be728* handled properly in a call to retro_input_state_t.729* Devices which are not handled or recognized always return730* 0 in retro_input_state_t.731* Example bitmask: caps = (1 << RETRO_DEVICE_JOYPAD) | (1 << RETRO_DEVICE_ANALOG).732* Should only be called in retro_run().733*/734#define RETRO_ENVIRONMENT_GET_SENSOR_INTERFACE (25 | RETRO_ENVIRONMENT_EXPERIMENTAL)735/* struct retro_sensor_interface * --736* Gets access to the sensor interface.737* The purpose of this interface is to allow738* setting state related to sensors such as polling rate,739* enabling/disable it entirely, etc.740* Reading sensor state is done via the normal741* input_state_callback API.742*/743#define RETRO_ENVIRONMENT_GET_CAMERA_INTERFACE (26 | RETRO_ENVIRONMENT_EXPERIMENTAL)744/* struct retro_camera_callback * --745* Gets an interface to a video camera driver.746* A libretro core can use this interface to get access to a747* video camera.748* New video frames are delivered in a callback in same749* thread as retro_run().750*751* GET_CAMERA_INTERFACE should be called in retro_load_game().752*753* Depending on the camera implementation used, camera frames754* will be delivered as a raw framebuffer,755* or as an OpenGL texture directly.756*757* The core has to tell the frontend here which types of758* buffers can be handled properly.759* An OpenGL texture can only be handled when using a760* libretro GL core (SET_HW_RENDER).761* It is recommended to use a libretro GL core when762* using camera interface.763*764* The camera is not started automatically. The retrieved start/stop765* functions must be used to explicitly766* start and stop the camera driver.767*/768#define RETRO_ENVIRONMENT_GET_LOG_INTERFACE 27769/* struct retro_log_callback * --770* Gets an interface for logging. This is useful for771* logging in a cross-platform way772* as certain platforms cannot use stderr for logging.773* It also allows the frontend to774* show logging information in a more suitable way.775* If this interface is not used, libretro cores should776* log to stderr as desired.777*/778#define RETRO_ENVIRONMENT_GET_PERF_INTERFACE 28779/* struct retro_perf_callback * --780* Gets an interface for performance counters. This is useful781* for performance logging in a cross-platform way and for detecting782* architecture-specific features, such as SIMD support.783*/784#define RETRO_ENVIRONMENT_GET_LOCATION_INTERFACE 29785/* struct retro_location_callback * --786* Gets access to the location interface.787* The purpose of this interface is to be able to retrieve788* location-based information from the host device,789* such as current latitude / longitude.790*/791#define RETRO_ENVIRONMENT_GET_CONTENT_DIRECTORY 30 /* Old name, kept for compatibility. */792#define RETRO_ENVIRONMENT_GET_CORE_ASSETS_DIRECTORY 30793/* const char ** --794* Returns the "core assets" directory of the frontend.795* This directory can be used to store specific assets that the796* core relies upon, such as art assets,797* input data, etc etc.798* The returned value can be NULL.799* If so, no such directory is defined,800* and it's up to the implementation to find a suitable directory.801*/802#define RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY 31803/* const char ** --804* Returns the "save" directory of the frontend, unless there is no805* save directory available. The save directory should be used to806* store SRAM, memory cards, high scores, etc, if the libretro core807* cannot use the regular memory interface (retro_get_memory_data()).808*809* If the frontend cannot designate a save directory, it will return810* NULL to indicate that the core should attempt to operate without a811* save directory set.812*813* NOTE: early libretro cores used the system directory for save814* files. Cores that need to be backwards-compatible can still check815* GET_SYSTEM_DIRECTORY.816*/817#define RETRO_ENVIRONMENT_SET_SYSTEM_AV_INFO 32818/* const struct retro_system_av_info * --819* Sets a new av_info structure. This can only be called from820* within retro_run().821* This should *only* be used if the core is completely altering the822* internal resolutions, aspect ratios, timings, sampling rate, etc.823* Calling this can require a full reinitialization of video/audio824* drivers in the frontend,825*826* so it is important to call it very sparingly, and usually only with827* the users explicit consent.828* An eventual driver reinitialize will happen so that video and829* audio callbacks830* happening after this call within the same retro_run() call will831* target the newly initialized driver.832*833* This callback makes it possible to support configurable resolutions834* in games, which can be useful to835* avoid setting the "worst case" in max_width/max_height.836*837* ***HIGHLY RECOMMENDED*** Do not call this callback every time838* resolution changes in an emulator core if it's839* expected to be a temporary change, for the reasons of possible840* driver reinitialization.841* This call is not a free pass for not trying to provide842* correct values in retro_get_system_av_info(). If you need to change843* things like aspect ratio or nominal width/height,844* use RETRO_ENVIRONMENT_SET_GEOMETRY, which is a softer variant845* of SET_SYSTEM_AV_INFO.846*847* If this returns false, the frontend does not acknowledge a848* changed av_info struct.849*/850#define RETRO_ENVIRONMENT_SET_PROC_ADDRESS_CALLBACK 33851/* const struct retro_get_proc_address_interface * --852* Allows a libretro core to announce support for the853* get_proc_address() interface.854* This interface allows for a standard way to extend libretro where855* use of environment calls are too indirect,856* e.g. for cases where the frontend wants to call directly into the core.857*858* If a core wants to expose this interface, SET_PROC_ADDRESS_CALLBACK859* **MUST** be called from within retro_set_environment().860*/861#define RETRO_ENVIRONMENT_SET_SUBSYSTEM_INFO 34862/* const struct retro_subsystem_info * --863* This environment call introduces the concept of libretro "subsystems".864* A subsystem is a variant of a libretro core which supports865* different kinds of games.866* The purpose of this is to support e.g. emulators which might867* have special needs, e.g. Super Nintendo's Super GameBoy, Sufami Turbo.868* It can also be used to pick among subsystems in an explicit way869* if the libretro implementation is a multi-system emulator itself.870*871* Loading a game via a subsystem is done with retro_load_game_special(),872* and this environment call allows a libretro core to expose which873* subsystems are supported for use with retro_load_game_special().874* A core passes an array of retro_game_special_info which is terminated875* with a zeroed out retro_game_special_info struct.876*877* If a core wants to use this functionality, SET_SUBSYSTEM_INFO878* **MUST** be called from within retro_set_environment().879*/880#define RETRO_ENVIRONMENT_SET_CONTROLLER_INFO 35881/* const struct retro_controller_info * --882* This environment call lets a libretro core tell the frontend883* which controller subclasses are recognized in calls to884* retro_set_controller_port_device().885*886* Some emulators such as Super Nintendo support multiple lightgun887* types which must be specifically selected from. It is therefore888* sometimes necessary for a frontend to be able to tell the core889* about a special kind of input device which is not specifcally890* provided by the Libretro API.891*892* In order for a frontend to understand the workings of those devices,893* they must be defined as a specialized subclass of the generic device894* types already defined in the libretro API.895*896* The core must pass an array of const struct retro_controller_info which897* is terminated with a blanked out struct. Each element of the898* retro_controller_info struct corresponds to the ascending port index899* that is passed to retro_set_controller_port_device() when that function900* is called to indicate to the core that the frontend has changed the901* active device subclass. SEE ALSO: retro_set_controller_port_device()902*903* The ascending input port indexes provided by the core in the struct904* are generally presented by frontends as ascending User # or Player #,905* such as Player 1, Player 2, Player 3, etc. Which device subclasses are906* supported can vary per input port.907*908* The first inner element of each entry in the retro_controller_info array909* is a retro_controller_description struct that specifies the names and910* codes of all device subclasses that are available for the corresponding911* User or Player, beginning with the generic Libretro device that the912* subclasses are derived from. The second inner element of each entry is the913* total number of subclasses that are listed in the retro_controller_description.914*915* NOTE: Even if special device types are set in the libretro core,916* libretro should only poll input based on the base input device types.917*/918#define RETRO_ENVIRONMENT_SET_MEMORY_MAPS (36 | RETRO_ENVIRONMENT_EXPERIMENTAL)919/* const struct retro_memory_map * --920* This environment call lets a libretro core tell the frontend921* about the memory maps this core emulates.922* This can be used to implement, for example, cheats in a core-agnostic way.923*924* Should only be used by emulators; it doesn't make much sense for925* anything else.926* It is recommended to expose all relevant pointers through927* retro_get_memory_* as well.928*929* Can be called from retro_init and retro_load_game.930*/931#define RETRO_ENVIRONMENT_SET_GEOMETRY 37932/* const struct retro_game_geometry * --933* This environment call is similar to SET_SYSTEM_AV_INFO for changing934* video parameters, but provides a guarantee that drivers will not be935* reinitialized.936* This can only be called from within retro_run().937*938* The purpose of this call is to allow a core to alter nominal939* width/heights as well as aspect ratios on-the-fly, which can be940* useful for some emulators to change in run-time.941*942* max_width/max_height arguments are ignored and cannot be changed943* with this call as this could potentially require a reinitialization or a944* non-constant time operation.945* If max_width/max_height are to be changed, SET_SYSTEM_AV_INFO is required.946*947* A frontend must guarantee that this environment call completes in948* constant time.949*/950#define RETRO_ENVIRONMENT_GET_USERNAME 38951/* const char **952* Returns the specified username of the frontend, if specified by the user.953* This username can be used as a nickname for a core that has online facilities954* or any other mode where personalization of the user is desirable.955* The returned value can be NULL.956* If this environ callback is used by a core that requires a valid username,957* a default username should be specified by the core.958*/959#define RETRO_ENVIRONMENT_GET_LANGUAGE 39960/* unsigned * --961* Returns the specified language of the frontend, if specified by the user.962* It can be used by the core for localization purposes.963*/964#define RETRO_ENVIRONMENT_GET_CURRENT_SOFTWARE_FRAMEBUFFER (40 | RETRO_ENVIRONMENT_EXPERIMENTAL)965/* struct retro_framebuffer * --966* Returns a preallocated framebuffer which the core can use for rendering967* the frame into when not using SET_HW_RENDER.968* The framebuffer returned from this call must not be used969* after the current call to retro_run() returns.970*971* The goal of this call is to allow zero-copy behavior where a core972* can render directly into video memory, avoiding extra bandwidth cost by copying973* memory from core to video memory.974*975* If this call succeeds and the core renders into it,976* the framebuffer pointer and pitch can be passed to retro_video_refresh_t.977* If the buffer from GET_CURRENT_SOFTWARE_FRAMEBUFFER is to be used,978* the core must pass the exact979* same pointer as returned by GET_CURRENT_SOFTWARE_FRAMEBUFFER;980* i.e. passing a pointer which is offset from the981* buffer is undefined. The width, height and pitch parameters982* must also match exactly to the values obtained from GET_CURRENT_SOFTWARE_FRAMEBUFFER.983*984* It is possible for a frontend to return a different pixel format985* than the one used in SET_PIXEL_FORMAT. This can happen if the frontend986* needs to perform conversion.987*988* It is still valid for a core to render to a different buffer989* even if GET_CURRENT_SOFTWARE_FRAMEBUFFER succeeds.990*991* A frontend must make sure that the pointer obtained from this function is992* writeable (and readable).993*/994#define RETRO_ENVIRONMENT_GET_HW_RENDER_INTERFACE (41 | RETRO_ENVIRONMENT_EXPERIMENTAL)995/* const struct retro_hw_render_interface ** --996* Returns an API specific rendering interface for accessing API specific data.997* Not all HW rendering APIs support or need this.998* The contents of the returned pointer is specific to the rendering API999* being used. See the various headers like libretro_vulkan.h, etc.1000*1001* GET_HW_RENDER_INTERFACE cannot be called before context_reset has been called.1002* Similarly, after context_destroyed callback returns,1003* the contents of the HW_RENDER_INTERFACE are invalidated.1004*/1005#define RETRO_ENVIRONMENT_SET_SUPPORT_ACHIEVEMENTS (42 | RETRO_ENVIRONMENT_EXPERIMENTAL)1006/* const bool * --1007* If true, the libretro implementation supports achievements1008* either via memory descriptors set with RETRO_ENVIRONMENT_SET_MEMORY_MAPS1009* or via retro_get_memory_data/retro_get_memory_size.1010*1011* This must be called before the first call to retro_run.1012*/1013#define RETRO_ENVIRONMENT_SET_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE (43 | RETRO_ENVIRONMENT_EXPERIMENTAL)1014/* const struct retro_hw_render_context_negotiation_interface * --1015* Sets an interface which lets the libretro core negotiate with frontend how a context is created.1016* The semantics of this interface depends on which API is used in SET_HW_RENDER earlier.1017* This interface will be used when the frontend is trying to create a HW rendering context,1018* so it will be used after SET_HW_RENDER, but before the context_reset callback.1019*/1020#define RETRO_ENVIRONMENT_SET_SERIALIZATION_QUIRKS 441021/* uint64_t * --1022* Sets quirk flags associated with serialization. The frontend will zero any flags it doesn't1023* recognize or support. Should be set in either retro_init or retro_load_game, but not both.1024*/1025#define RETRO_ENVIRONMENT_SET_HW_SHARED_CONTEXT (44 | RETRO_ENVIRONMENT_EXPERIMENTAL)1026/* N/A (null) * --1027* The frontend will try to use a 'shared' hardware context (mostly applicable1028* to OpenGL) when a hardware context is being set up.1029*1030* Returns true if the frontend supports shared hardware contexts and false1031* if the frontend does not support shared hardware contexts.1032*1033* This will do nothing on its own until SET_HW_RENDER env callbacks are1034* being used.1035*/1036#define RETRO_ENVIRONMENT_GET_VFS_INTERFACE (45 | RETRO_ENVIRONMENT_EXPERIMENTAL)1037/* struct retro_vfs_interface_info * --1038* Gets access to the VFS interface.1039* VFS presence needs to be queried prior to load_game or any1040* get_system/save/other_directory being called to let front end know1041* core supports VFS before it starts handing out paths.1042* It is recomended to do so in retro_set_environment1043*/1044#define RETRO_ENVIRONMENT_GET_LED_INTERFACE (46 | RETRO_ENVIRONMENT_EXPERIMENTAL)1045/* struct retro_led_interface * --1046* Gets an interface which is used by a libretro core to set1047* state of LEDs.1048*/1049#define RETRO_ENVIRONMENT_GET_AUDIO_VIDEO_ENABLE (47 | RETRO_ENVIRONMENT_EXPERIMENTAL)1050/* int * --1051* Tells the core if the frontend wants audio or video.1052* If disabled, the frontend will discard the audio or video,1053* so the core may decide to skip generating a frame or generating audio.1054* This is mainly used for increasing performance.1055* Bit 0 (value 1): Enable Video1056* Bit 1 (value 2): Enable AUDIO1057* Bit 2 (value 4): Use Fast Savestates.1058* Bit 3 (value 8): Hard Disable AUDIO1059* Other bits are reserved for future use and will default to zero.1060* If video is disabled:1061* * The frontend wants the core to not generate any video,1062* including presenting frames via hardware acceleration.1063* * The frontend's video frame callback will do nothing.1064* * After running the frame, the video output of the next frame should be1065* no different than if video was enabled, and saving and loading state1066* should have no issues.1067* If audio is disabled:1068* * The frontend wants the core to not generate any audio.1069* * The frontend's audio callbacks will do nothing.1070* * After running the frame, the audio output of the next frame should be1071* no different than if audio was enabled, and saving and loading state1072* should have no issues.1073* Fast Savestates:1074* * Guaranteed to be created by the same binary that will load them.1075* * Will not be written to or read from the disk.1076* * Suggest that the core assumes loading state will succeed.1077* * Suggest that the core updates its memory buffers in-place if possible.1078* * Suggest that the core skips clearing memory.1079* * Suggest that the core skips resetting the system.1080* * Suggest that the core may skip validation steps.1081* Hard Disable AUDIO:1082* * Used for a secondary core when running ahead.1083* * Indicates that the frontend will never need audio from the core.1084* * Suggests that the core may stop synthesizing audio, but this should not1085* compromise emulation accuracy.1086* * AUDIO output for the next frame does not matter, and the frontend will1087* never need an accurate audio state in the future.1088* * State will never be saved when using Hard Disable AUDIO.1089*/1090#define RETRO_ENVIRONMENT_GET_MIDI_INTERFACE (48 | RETRO_ENVIRONMENT_EXPERIMENTAL)1091/* struct retro_midi_interface ** --1092* Returns a MIDI interface that can be used for raw data I/O.1093*/10941095#define RETRO_ENVIRONMENT_GET_FASTFORWARDING (49 | RETRO_ENVIRONMENT_EXPERIMENTAL)1096/* bool * --1097* Boolean value that indicates whether or not the frontend is in1098* fastforwarding mode.1099*/11001101#define RETRO_ENVIRONMENT_GET_TARGET_REFRESH_RATE (50 | RETRO_ENVIRONMENT_EXPERIMENTAL)1102/* float * --1103* Float value that lets us know what target refresh rate1104* is curently in use by the frontend.1105*1106* The core can use the returned value to set an ideal1107* refresh rate/framerate.1108*/11091110#define RETRO_ENVIRONMENT_GET_INPUT_BITMASKS (51 | RETRO_ENVIRONMENT_EXPERIMENTAL)1111/* bool * --1112* Boolean value that indicates whether or not the frontend supports1113* input bitmasks being returned by retro_input_state_t. The advantage1114* of this is that retro_input_state_t has to be only called once to1115* grab all button states instead of multiple times.1116*1117* If it returns true, you can pass RETRO_DEVICE_ID_JOYPAD_MASK as 'id'1118* to retro_input_state_t (make sure 'device' is set to RETRO_DEVICE_JOYPAD).1119* It will return a bitmask of all the digital buttons.1120*/11211122#define RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION 521123/* unsigned * --1124* Unsigned value is the API version number of the core options1125* interface supported by the frontend. If callback return false,1126* API version is assumed to be 0.1127*1128* In legacy code, core options are set by passing an array of1129* retro_variable structs to RETRO_ENVIRONMENT_SET_VARIABLES.1130* This may be still be done regardless of the core options1131* interface version.1132*1133* If version is >= 1 however, core options may instead be set by1134* passing an array of retro_core_option_definition structs to1135* RETRO_ENVIRONMENT_SET_CORE_OPTIONS, or a 2D array of1136* retro_core_option_definition structs to RETRO_ENVIRONMENT_SET_CORE_OPTIONS_INTL.1137* This allows the core to additionally set option sublabel information1138* and/or provide localisation support.1139*1140* If version is >= 2, core options may instead be set by passing1141* a retro_core_options_v2 struct to RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2,1142* or an array of retro_core_options_v2 structs to1143* RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2_INTL. This allows the core1144* to additionally set optional core option category information1145* for frontends with core option category support.1146*/11471148#define RETRO_ENVIRONMENT_SET_CORE_OPTIONS 531149/* const struct retro_core_option_definition ** --1150* Allows an implementation to signal the environment1151* which variables it might want to check for later using1152* GET_VARIABLE.1153* This allows the frontend to present these variables to1154* a user dynamically.1155* This should only be called if RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION1156* returns an API version of >= 1.1157* This should be called instead of RETRO_ENVIRONMENT_SET_VARIABLES.1158* This should be called the first time as early as1159* possible (ideally in retro_set_environment).1160* Afterwards it may be called again for the core to communicate1161* updated options to the frontend, but the number of core1162* options must not change from the number in the initial call.1163*1164* 'data' points to an array of retro_core_option_definition structs1165* terminated by a { NULL, NULL, NULL, {{0}}, NULL } element.1166* retro_core_option_definition::key should be namespaced to not collide1167* with other implementations' keys. e.g. A core called1168* 'foo' should use keys named as 'foo_option'.1169* retro_core_option_definition::desc should contain a human readable1170* description of the key.1171* retro_core_option_definition::info should contain any additional human1172* readable information text that a typical user may need to1173* understand the functionality of the option.1174* retro_core_option_definition::values is an array of retro_core_option_value1175* structs terminated by a { NULL, NULL } element.1176* > retro_core_option_definition::values[index].value is an expected option1177* value.1178* > retro_core_option_definition::values[index].label is a human readable1179* label used when displaying the value on screen. If NULL,1180* the value itself is used.1181* retro_core_option_definition::default_value is the default core option1182* setting. It must match one of the expected option values in the1183* retro_core_option_definition::values array. If it does not, or the1184* default value is NULL, the first entry in the1185* retro_core_option_definition::values array is treated as the default.1186*1187* The number of possible option values should be very limited,1188* and must be less than RETRO_NUM_CORE_OPTION_VALUES_MAX.1189* i.e. it should be feasible to cycle through options1190* without a keyboard.1191*1192* Example entry:1193* {1194* "foo_option",1195* "Speed hack coprocessor X",1196* "Provides increased performance at the expense of reduced accuracy",1197* {1198* { "false", NULL },1199* { "true", NULL },1200* { "unstable", "Turbo (Unstable)" },1201* { NULL, NULL },1202* },1203* "false"1204* }1205*1206* Only strings are operated on. The possible values will1207* generally be displayed and stored as-is by the frontend.1208*/12091210#define RETRO_ENVIRONMENT_SET_CORE_OPTIONS_INTL 541211/* const struct retro_core_options_intl * --1212* Allows an implementation to signal the environment1213* which variables it might want to check for later using1214* GET_VARIABLE.1215* This allows the frontend to present these variables to1216* a user dynamically.1217* This should only be called if RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION1218* returns an API version of >= 1.1219* This should be called instead of RETRO_ENVIRONMENT_SET_VARIABLES.1220* This should be called instead of RETRO_ENVIRONMENT_SET_CORE_OPTIONS.1221* This should be called the first time as early as1222* possible (ideally in retro_set_environment).1223* Afterwards it may be called again for the core to communicate1224* updated options to the frontend, but the number of core1225* options must not change from the number in the initial call.1226*1227* This is fundamentally the same as RETRO_ENVIRONMENT_SET_CORE_OPTIONS,1228* with the addition of localisation support. The description of the1229* RETRO_ENVIRONMENT_SET_CORE_OPTIONS callback should be consulted1230* for further details.1231*1232* 'data' points to a retro_core_options_intl struct.1233*1234* retro_core_options_intl::us is a pointer to an array of1235* retro_core_option_definition structs defining the US English1236* core options implementation. It must point to a valid array.1237*1238* retro_core_options_intl::local is a pointer to an array of1239* retro_core_option_definition structs defining core options for1240* the current frontend language. It may be NULL (in which case1241* retro_core_options_intl::us is used by the frontend). Any items1242* missing from this array will be read from retro_core_options_intl::us1243* instead.1244*1245* NOTE: Default core option values are always taken from the1246* retro_core_options_intl::us array. Any default values in1247* retro_core_options_intl::local array will be ignored.1248*/12491250#define RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY 551251/* struct retro_core_option_display * --1252*1253* Allows an implementation to signal the environment to show1254* or hide a variable when displaying core options. This is1255* considered a *suggestion*. The frontend is free to ignore1256* this callback, and its implementation not considered mandatory.1257*1258* 'data' points to a retro_core_option_display struct1259*1260* retro_core_option_display::key is a variable identifier1261* which has already been set by SET_VARIABLES/SET_CORE_OPTIONS.1262*1263* retro_core_option_display::visible is a boolean, specifying1264* whether variable should be displayed1265*1266* Note that all core option variables will be set visible by1267* default when calling SET_VARIABLES/SET_CORE_OPTIONS.1268*/12691270#define RETRO_ENVIRONMENT_GET_PREFERRED_HW_RENDER 561271/* unsigned * --1272*1273* Allows an implementation to ask frontend preferred hardware1274* context to use. Core should use this information to deal1275* with what specific context to request with SET_HW_RENDER.1276*1277* 'data' points to an unsigned variable1278*/12791280#define RETRO_ENVIRONMENT_GET_DISK_CONTROL_INTERFACE_VERSION 571281/* unsigned * --1282* Unsigned value is the API version number of the disk control1283* interface supported by the frontend. If callback return false,1284* API version is assumed to be 0.1285*1286* In legacy code, the disk control interface is defined by passing1287* a struct of type retro_disk_control_callback to1288* RETRO_ENVIRONMENT_SET_DISK_CONTROL_INTERFACE.1289* This may be still be done regardless of the disk control1290* interface version.1291*1292* If version is >= 1 however, the disk control interface may1293* instead be defined by passing a struct of type1294* retro_disk_control_ext_callback to1295* RETRO_ENVIRONMENT_SET_DISK_CONTROL_EXT_INTERFACE.1296* This allows the core to provide additional information about1297* disk images to the frontend and/or enables extra1298* disk control functionality by the frontend.1299*/13001301#define RETRO_ENVIRONMENT_SET_DISK_CONTROL_EXT_INTERFACE 581302/* const struct retro_disk_control_ext_callback * --1303* Sets an interface which frontend can use to eject and insert1304* disk images, and also obtain information about individual1305* disk image files registered by the core.1306* This is used for games which consist of multiple images and1307* must be manually swapped out by the user (e.g. PSX, floppy disk1308* based systems).1309*/13101311#define RETRO_ENVIRONMENT_GET_MESSAGE_INTERFACE_VERSION 591312/* unsigned * --1313* Unsigned value is the API version number of the message1314* interface supported by the frontend. If callback returns1315* false, API version is assumed to be 0.1316*1317* In legacy code, messages may be displayed in an1318* implementation-specific manner by passing a struct1319* of type retro_message to RETRO_ENVIRONMENT_SET_MESSAGE.1320* This may be still be done regardless of the message1321* interface version.1322*1323* If version is >= 1 however, messages may instead be1324* displayed by passing a struct of type retro_message_ext1325* to RETRO_ENVIRONMENT_SET_MESSAGE_EXT. This allows the1326* core to specify message logging level, priority and1327* destination (OSD, logging interface or both).1328*/13291330#define RETRO_ENVIRONMENT_SET_MESSAGE_EXT 601331/* const struct retro_message_ext * --1332* Sets a message to be displayed in an implementation-specific1333* manner for a certain amount of 'frames'. Additionally allows1334* the core to specify message logging level, priority and1335* destination (OSD, logging interface or both).1336* Should not be used for trivial messages, which should simply be1337* logged via RETRO_ENVIRONMENT_GET_LOG_INTERFACE (or as a1338* fallback, stderr).1339*/13401341#define RETRO_ENVIRONMENT_GET_INPUT_MAX_USERS 611342/* unsigned * --1343* Unsigned value is the number of active input devices1344* provided by the frontend. This may change between1345* frames, but will remain constant for the duration1346* of each frame.1347* If callback returns true, a core need not poll any1348* input device with an index greater than or equal to1349* the number of active devices.1350* If callback returns false, the number of active input1351* devices is unknown. In this case, all input devices1352* should be considered active.1353*/13541355#define RETRO_ENVIRONMENT_SET_AUDIO_BUFFER_STATUS_CALLBACK 621356/* const struct retro_audio_buffer_status_callback * --1357* Lets the core know the occupancy level of the frontend1358* audio buffer. Can be used by a core to attempt frame1359* skipping in order to avoid buffer under-runs.1360* A core may pass NULL to disable buffer status reporting1361* in the frontend.1362*/13631364#define RETRO_ENVIRONMENT_SET_MINIMUM_AUDIO_LATENCY 631365/* const unsigned * --1366* Sets minimum frontend audio latency in milliseconds.1367* Resultant audio latency may be larger than set value,1368* or smaller if a hardware limit is encountered. A frontend1369* is expected to honour requests up to 512 ms.1370*1371* - If value is less than current frontend1372* audio latency, callback has no effect1373* - If value is zero, default frontend audio1374* latency is set1375*1376* May be used by a core to increase audio latency and1377* therefore decrease the probability of buffer under-runs1378* (crackling) when performing 'intensive' operations.1379* A core utilising RETRO_ENVIRONMENT_SET_AUDIO_BUFFER_STATUS_CALLBACK1380* to implement audio-buffer-based frame skipping may achieve1381* optimal results by setting the audio latency to a 'high'1382* (typically 6x or 8x) integer multiple of the expected1383* frame time.1384*1385* WARNING: This can only be called from within retro_run().1386* Calling this can require a full reinitialization of audio1387* drivers in the frontend, so it is important to call it very1388* sparingly, and usually only with the users explicit consent.1389* An eventual driver reinitialize will happen so that audio1390* callbacks happening after this call within the same retro_run()1391* call will target the newly initialized driver.1392*/13931394#define RETRO_ENVIRONMENT_SET_FASTFORWARDING_OVERRIDE 641395/* const struct retro_fastforwarding_override * --1396* Used by a libretro core to override the current1397* fastforwarding mode of the frontend.1398* If NULL is passed to this function, the frontend1399* will return true if fastforwarding override1400* functionality is supported (no change in1401* fastforwarding state will occur in this case).1402*/14031404#define RETRO_ENVIRONMENT_SET_CONTENT_INFO_OVERRIDE 651405/* const struct retro_system_content_info_override * --1406* Allows an implementation to override 'global' content1407* info parameters reported by retro_get_system_info().1408* Overrides also affect subsystem content info parameters1409* set via RETRO_ENVIRONMENT_SET_SUBSYSTEM_INFO.1410* This function must be called inside retro_set_environment().1411* If callback returns false, content info overrides1412* are unsupported by the frontend, and will be ignored.1413* If callback returns true, extended game info may be1414* retrieved by calling RETRO_ENVIRONMENT_GET_GAME_INFO_EXT1415* in retro_load_game() or retro_load_game_special().1416*1417* 'data' points to an array of retro_system_content_info_override1418* structs terminated by a { NULL, false, false } element.1419* If 'data' is NULL, no changes will be made to the frontend;1420* a core may therefore pass NULL in order to test whether1421* the RETRO_ENVIRONMENT_SET_CONTENT_INFO_OVERRIDE and1422* RETRO_ENVIRONMENT_GET_GAME_INFO_EXT callbacks are supported1423* by the frontend.1424*1425* For struct member descriptions, see the definition of1426* struct retro_system_content_info_override.1427*1428* Example:1429*1430* - struct retro_system_info:1431* {1432* "My Core", // library_name1433* "v1.0", // library_version1434* "m3u|md|cue|iso|chd|sms|gg|sg", // valid_extensions1435* true, // need_fullpath1436* false // block_extract1437* }1438*1439* - Array of struct retro_system_content_info_override:1440* {1441* {1442* "md|sms|gg", // extensions1443* false, // need_fullpath1444* true // persistent_data1445* },1446* {1447* "sg", // extensions1448* false, // need_fullpath1449* false // persistent_data1450* },1451* { NULL, false, false }1452* }1453*1454* Result:1455* - Files of type m3u, cue, iso, chd will not be1456* loaded by the frontend. Frontend will pass a1457* valid path to the core, and core will handle1458* loading internally1459* - Files of type md, sms, gg will be loaded by1460* the frontend. A valid memory buffer will be1461* passed to the core. This memory buffer will1462* remain valid until retro_deinit() returns1463* - Files of type sg will be loaded by the frontend.1464* A valid memory buffer will be passed to the core.1465* This memory buffer will remain valid until1466* retro_load_game() (or retro_load_game_special())1467* returns1468*1469* NOTE: If an extension is listed multiple times in1470* an array of retro_system_content_info_override1471* structs, only the first instance will be registered1472*/14731474#define RETRO_ENVIRONMENT_GET_GAME_INFO_EXT 661475/* const struct retro_game_info_ext ** --1476* Allows an implementation to fetch extended game1477* information, providing additional content path1478* and memory buffer status details.1479* This function may only be called inside1480* retro_load_game() or retro_load_game_special().1481* If callback returns false, extended game information1482* is unsupported by the frontend. In this case, only1483* regular retro_game_info will be available.1484* RETRO_ENVIRONMENT_GET_GAME_INFO_EXT is guaranteed1485* to return true if RETRO_ENVIRONMENT_SET_CONTENT_INFO_OVERRIDE1486* returns true.1487*1488* 'data' points to an array of retro_game_info_ext structs.1489*1490* For struct member descriptions, see the definition of1491* struct retro_game_info_ext.1492*1493* - If function is called inside retro_load_game(),1494* the retro_game_info_ext array is guaranteed to1495* have a size of 1 - i.e. the returned pointer may1496* be used to access directly the members of the1497* first retro_game_info_ext struct, for example:1498*1499* struct retro_game_info_ext *game_info_ext;1500* if (environ_cb(RETRO_ENVIRONMENT_GET_GAME_INFO_EXT, &game_info_ext))1501* printf("Content Directory: %s\n", game_info_ext->dir);1502*1503* - If the function is called inside retro_load_game_special(),1504* the retro_game_info_ext array is guaranteed to have a1505* size equal to the num_info argument passed to1506* retro_load_game_special()1507*/15081509#define RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2 671510/* const struct retro_core_options_v2 * --1511* Allows an implementation to signal the environment1512* which variables it might want to check for later using1513* GET_VARIABLE.1514* This allows the frontend to present these variables to1515* a user dynamically.1516* This should only be called if RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION1517* returns an API version of >= 2.1518* This should be called instead of RETRO_ENVIRONMENT_SET_VARIABLES.1519* This should be called instead of RETRO_ENVIRONMENT_SET_CORE_OPTIONS.1520* This should be called the first time as early as1521* possible (ideally in retro_set_environment).1522* Afterwards it may be called again for the core to communicate1523* updated options to the frontend, but the number of core1524* options must not change from the number in the initial call.1525* If RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION returns an API1526* version of >= 2, this callback is guaranteed to succeed1527* (i.e. callback return value does not indicate success)1528* If callback returns true, frontend has core option category1529* support.1530* If callback returns false, frontend does not have core option1531* category support.1532*1533* 'data' points to a retro_core_options_v2 struct, containing1534* of two pointers:1535* - retro_core_options_v2::categories is an array of1536* retro_core_option_v2_category structs terminated by a1537* { NULL, NULL, NULL } element. If retro_core_options_v2::categories1538* is NULL, all core options will have no category and will be shown1539* at the top level of the frontend core option interface. If frontend1540* does not have core option category support, categories array will1541* be ignored.1542* - retro_core_options_v2::definitions is an array of1543* retro_core_option_v2_definition structs terminated by a1544* { NULL, NULL, NULL, NULL, NULL, NULL, {{0}}, NULL }1545* element.1546*1547* >> retro_core_option_v2_category notes:1548*1549* - retro_core_option_v2_category::key should contain string1550* that uniquely identifies the core option category. Valid1551* key characters are [a-z, A-Z, 0-9, _, -]1552* Namespace collisions with other implementations' category1553* keys are permitted.1554* - retro_core_option_v2_category::desc should contain a human1555* readable description of the category key.1556* - retro_core_option_v2_category::info should contain any1557* additional human readable information text that a typical1558* user may need to understand the nature of the core option1559* category.1560*1561* Example entry:1562* {1563* "advanced_settings",1564* "Advanced",1565* "Options affecting low-level emulation performance and accuracy."1566* }1567*1568* >> retro_core_option_v2_definition notes:1569*1570* - retro_core_option_v2_definition::key should be namespaced to not1571* collide with other implementations' keys. e.g. A core called1572* 'foo' should use keys named as 'foo_option'. Valid key characters1573* are [a-z, A-Z, 0-9, _, -].1574* - retro_core_option_v2_definition::desc should contain a human readable1575* description of the key. Will be used when the frontend does not1576* have core option category support. Examples: "Aspect Ratio" or1577* "Video > Aspect Ratio".1578* - retro_core_option_v2_definition::desc_categorized should contain a1579* human readable description of the key, which will be used when1580* frontend has core option category support. Example: "Aspect Ratio",1581* where associated retro_core_option_v2_category::desc is "Video".1582* If empty or NULL, the string specified by1583* retro_core_option_v2_definition::desc will be used instead.1584* retro_core_option_v2_definition::desc_categorized will be ignored1585* if retro_core_option_v2_definition::category_key is empty or NULL.1586* - retro_core_option_v2_definition::info should contain any additional1587* human readable information text that a typical user may need to1588* understand the functionality of the option.1589* - retro_core_option_v2_definition::info_categorized should contain1590* any additional human readable information text that a typical user1591* may need to understand the functionality of the option, and will be1592* used when frontend has core option category support. This is provided1593* to accommodate the case where info text references an option by1594* name/desc, and the desc/desc_categorized text for that option differ.1595* If empty or NULL, the string specified by1596* retro_core_option_v2_definition::info will be used instead.1597* retro_core_option_v2_definition::info_categorized will be ignored1598* if retro_core_option_v2_definition::category_key is empty or NULL.1599* - retro_core_option_v2_definition::category_key should contain a1600* category identifier (e.g. "video" or "audio") that will be1601* assigned to the core option if frontend has core option category1602* support. A categorized option will be shown in a subsection/1603* submenu of the frontend core option interface. If key is empty1604* or NULL, or if key does not match one of the1605* retro_core_option_v2_category::key values in the associated1606* retro_core_option_v2_category array, option will have no category1607* and will be shown at the top level of the frontend core option1608* interface.1609* - retro_core_option_v2_definition::values is an array of1610* retro_core_option_value structs terminated by a { NULL, NULL }1611* element.1612* --> retro_core_option_v2_definition::values[index].value is an1613* expected option value.1614* --> retro_core_option_v2_definition::values[index].label is a1615* human readable label used when displaying the value on screen.1616* If NULL, the value itself is used.1617* - retro_core_option_v2_definition::default_value is the default1618* core option setting. It must match one of the expected option1619* values in the retro_core_option_v2_definition::values array. If1620* it does not, or the default value is NULL, the first entry in the1621* retro_core_option_v2_definition::values array is treated as the1622* default.1623*1624* The number of possible option values should be very limited,1625* and must be less than RETRO_NUM_CORE_OPTION_VALUES_MAX.1626* i.e. it should be feasible to cycle through options1627* without a keyboard.1628*1629* Example entries:1630*1631* - Uncategorized:1632*1633* {1634* "foo_option",1635* "Speed hack coprocessor X",1636* NULL,1637* "Provides increased performance at the expense of reduced accuracy.",1638* NULL,1639* NULL,1640* {1641* { "false", NULL },1642* { "true", NULL },1643* { "unstable", "Turbo (Unstable)" },1644* { NULL, NULL },1645* },1646* "false"1647* }1648*1649* - Categorized:1650*1651* {1652* "foo_option",1653* "Advanced > Speed hack coprocessor X",1654* "Speed hack coprocessor X",1655* "Setting 'Advanced > Speed hack coprocessor X' to 'true' or 'Turbo' provides increased performance at the expense of reduced accuracy",1656* "Setting 'Speed hack coprocessor X' to 'true' or 'Turbo' provides increased performance at the expense of reduced accuracy",1657* "advanced_settings",1658* {1659* { "false", NULL },1660* { "true", NULL },1661* { "unstable", "Turbo (Unstable)" },1662* { NULL, NULL },1663* },1664* "false"1665* }1666*1667* Only strings are operated on. The possible values will1668* generally be displayed and stored as-is by the frontend.1669*/16701671#define RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2_INTL 681672/* const struct retro_core_options_v2_intl * --1673* Allows an implementation to signal the environment1674* which variables it might want to check for later using1675* GET_VARIABLE.1676* This allows the frontend to present these variables to1677* a user dynamically.1678* This should only be called if RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION1679* returns an API version of >= 2.1680* This should be called instead of RETRO_ENVIRONMENT_SET_VARIABLES.1681* This should be called instead of RETRO_ENVIRONMENT_SET_CORE_OPTIONS.1682* This should be called instead of RETRO_ENVIRONMENT_SET_CORE_OPTIONS_INTL.1683* This should be called instead of RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2.1684* This should be called the first time as early as1685* possible (ideally in retro_set_environment).1686* Afterwards it may be called again for the core to communicate1687* updated options to the frontend, but the number of core1688* options must not change from the number in the initial call.1689* If RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION returns an API1690* version of >= 2, this callback is guaranteed to succeed1691* (i.e. callback return value does not indicate success)1692* If callback returns true, frontend has core option category1693* support.1694* If callback returns false, frontend does not have core option1695* category support.1696*1697* This is fundamentally the same as RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2,1698* with the addition of localisation support. The description of the1699* RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2 callback should be consulted1700* for further details.1701*1702* 'data' points to a retro_core_options_v2_intl struct.1703*1704* - retro_core_options_v2_intl::us is a pointer to a1705* retro_core_options_v2 struct defining the US English1706* core options implementation. It must point to a valid struct.1707*1708* - retro_core_options_v2_intl::local is a pointer to a1709* retro_core_options_v2 struct defining core options for1710* the current frontend language. It may be NULL (in which case1711* retro_core_options_v2_intl::us is used by the frontend). Any items1712* missing from this struct will be read from1713* retro_core_options_v2_intl::us instead.1714*1715* NOTE: Default core option values are always taken from the1716* retro_core_options_v2_intl::us struct. Any default values in1717* the retro_core_options_v2_intl::local struct will be ignored.1718*/17191720#define RETRO_ENVIRONMENT_SET_CORE_OPTIONS_UPDATE_DISPLAY_CALLBACK 691721/* const struct retro_core_options_update_display_callback * --1722* Allows a frontend to signal that a core must update1723* the visibility of any dynamically hidden core options,1724* and enables the frontend to detect visibility changes.1725* Used by the frontend to update the menu display status1726* of core options without requiring a call of retro_run().1727* Must be called in retro_set_environment().1728*/17291730#define RETRO_ENVIRONMENT_SET_VARIABLE 701731/* const struct retro_variable * --1732* Allows an implementation to notify the frontend1733* that a core option value has changed.1734*1735* retro_variable::key and retro_variable::value1736* must match strings that have been set previously1737* via one of the following:1738*1739* - RETRO_ENVIRONMENT_SET_VARIABLES1740* - RETRO_ENVIRONMENT_SET_CORE_OPTIONS1741* - RETRO_ENVIRONMENT_SET_CORE_OPTIONS_INTL1742* - RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V21743* - RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2_INTL1744*1745* After changing a core option value via this1746* callback, RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE1747* will return true.1748*1749* If data is NULL, no changes will be registered1750* and the callback will return true; an1751* implementation may therefore pass NULL in order1752* to test whether the callback is supported.1753*/17541755#define RETRO_ENVIRONMENT_GET_THROTTLE_STATE (71 | RETRO_ENVIRONMENT_EXPERIMENTAL)1756/* struct retro_throttle_state * --1757* Allows an implementation to get details on the actual rate1758* the frontend is attempting to call retro_run().1759*/17601761#define RETRO_ENVIRONMENT_GET_SAVESTATE_CONTEXT (72 | RETRO_ENVIRONMENT_EXPERIMENTAL)1762/* int * --1763* Tells the core about the context the frontend is asking for savestate.1764* (see enum retro_savestate_context)1765*/17661767#define RETRO_ENVIRONMENT_GET_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE_SUPPORT (73 | RETRO_ENVIRONMENT_EXPERIMENTAL)1768/* struct retro_hw_render_context_negotiation_interface * --1769* Before calling SET_HW_RNEDER_CONTEXT_NEGOTIATION_INTERFACE, a core can query1770* which version of the interface is supported.1771*1772* Frontend looks at interface_type and returns the maximum supported1773* context negotiation interface version.1774* If the interface_type is not supported or recognized by the frontend, a version of 01775* must be returned in interface_version and true is returned by frontend.1776*1777* If this environment call returns true with interface_version greater than 0,1778* a core can always use a negotiation interface version larger than what the frontend returns, but only1779* earlier versions of the interface will be used by the frontend.1780* A frontend must not reject a negotiation interface version that is larger than1781* what the frontend supports. Instead, the frontend will use the older entry points that it recognizes.1782* If this is incompatible with a particular core's requirements, it can error out early.1783*1784* Backwards compatibility note:1785* This environment call was introduced after Vulkan v1 context negotiation.1786* If this environment call is not supported by frontend - i.e. the environment call returns false -1787* only Vulkan v1 context negotiation is supported (if Vulkan HW rendering is supported at all).1788* If a core uses Vulkan negotiation interface with version > 1, negotiation may fail unexpectedly.1789* All future updates to the context negotiation interface implies that frontend must support1790* this environment call to query support.1791*/17921793#define RETRO_ENVIRONMENT_GET_JIT_CAPABLE 741794/* bool * --1795* Result is set to true if the frontend has already verified JIT can be1796* used, mainly for use iOS/tvOS. On other platforms the result is true.1797*/179817991800/* VFS functionality */18011802/* File paths:1803* File paths passed as parameters when using this API shall be well formed UNIX-style,1804* using "/" (unquoted forward slash) as directory separator regardless of the platform's native separator.1805* Paths shall also include at least one forward slash ("game.bin" is an invalid path, use "./game.bin" instead).1806* Other than the directory separator, cores shall not make assumptions about path format:1807* "C:/path/game.bin", "http://example.com/game.bin", "#game/game.bin", "./game.bin" (without quotes) are all valid paths.1808* Cores may replace the basename or remove path components from the end, and/or add new components;1809* however, cores shall not append "./", "../" or multiple consecutive forward slashes ("//") to paths they request to front end.1810* The frontend is encouraged to make such paths work as well as it can, but is allowed to give up if the core alters paths too much.1811* Frontends are encouraged, but not required, to support native file system paths (modulo replacing the directory separator, if applicable).1812* Cores are allowed to try using them, but must remain functional if the front rejects such requests.1813* Cores are encouraged to use the libretro-common filestream functions for file I/O,1814* as they seamlessly integrate with VFS, deal with directory separator replacement as appropriate1815* and provide platform-specific fallbacks in cases where front ends do not support VFS. */18161817/* Opaque file handle1818* Introduced in VFS API v1 */1819struct retro_vfs_file_handle;18201821/* Opaque directory handle1822* Introduced in VFS API v3 */1823struct retro_vfs_dir_handle;18241825/* File open flags1826* Introduced in VFS API v1 */1827#define RETRO_VFS_FILE_ACCESS_READ (1 << 0) /* Read only mode */1828#define RETRO_VFS_FILE_ACCESS_WRITE (1 << 1) /* Write only mode, discard contents and overwrites existing file unless RETRO_VFS_FILE_ACCESS_UPDATE is also specified */1829#define RETRO_VFS_FILE_ACCESS_READ_WRITE (RETRO_VFS_FILE_ACCESS_READ | RETRO_VFS_FILE_ACCESS_WRITE) /* Read-write mode, discard contents and overwrites existing file unless RETRO_VFS_FILE_ACCESS_UPDATE is also specified*/1830#define RETRO_VFS_FILE_ACCESS_UPDATE_EXISTING (1 << 2) /* Prevents discarding content of existing files opened for writing */18311832/* These are only hints. The frontend may choose to ignore them. Other than RAM/CPU/etc use,1833and how they react to unlikely external interference (for example someone else writing to that file,1834or the file's server going down), behavior will not change. */1835#define RETRO_VFS_FILE_ACCESS_HINT_NONE (0)1836/* Indicate that the file will be accessed many times. The frontend should aggressively cache everything. */1837#define RETRO_VFS_FILE_ACCESS_HINT_FREQUENT_ACCESS (1 << 0)18381839/* Seek positions */1840#define RETRO_VFS_SEEK_POSITION_START 01841#define RETRO_VFS_SEEK_POSITION_CURRENT 11842#define RETRO_VFS_SEEK_POSITION_END 218431844/* stat() result flags1845* Introduced in VFS API v3 */1846#define RETRO_VFS_STAT_IS_VALID (1 << 0)1847#define RETRO_VFS_STAT_IS_DIRECTORY (1 << 1)1848#define RETRO_VFS_STAT_IS_CHARACTER_SPECIAL (1 << 2)18491850/* Get path from opaque handle. Returns the exact same path passed to file_open when getting the handle1851* Introduced in VFS API v1 */1852typedef const char *(RETRO_CALLCONV *retro_vfs_get_path_t)(struct retro_vfs_file_handle *stream);18531854/* Open a file for reading or writing. If path points to a directory, this will1855* fail. Returns the opaque file handle, or NULL for error.1856* Introduced in VFS API v1 */1857typedef struct retro_vfs_file_handle *(RETRO_CALLCONV *retro_vfs_open_t)(const char *path, unsigned mode, unsigned hints);18581859/* Close the file and release its resources. Must be called if open_file returns non-NULL. Returns 0 on success, -1 on failure.1860* Whether the call succeeds ot not, the handle passed as parameter becomes invalid and should no longer be used.1861* Introduced in VFS API v1 */1862typedef int (RETRO_CALLCONV *retro_vfs_close_t)(struct retro_vfs_file_handle *stream);18631864/* Return the size of the file in bytes, or -1 for error.1865* Introduced in VFS API v1 */1866typedef int64_t (RETRO_CALLCONV *retro_vfs_size_t)(struct retro_vfs_file_handle *stream);18671868/* Truncate file to specified size. Returns 0 on success or -1 on error1869* Introduced in VFS API v2 */1870typedef int64_t (RETRO_CALLCONV *retro_vfs_truncate_t)(struct retro_vfs_file_handle *stream, int64_t length);18711872/* Get the current read / write position for the file. Returns -1 for error.1873* Introduced in VFS API v1 */1874typedef int64_t (RETRO_CALLCONV *retro_vfs_tell_t)(struct retro_vfs_file_handle *stream);18751876/* Set the current read/write position for the file. Returns the new position, -1 for error.1877* Introduced in VFS API v1 */1878typedef int64_t (RETRO_CALLCONV *retro_vfs_seek_t)(struct retro_vfs_file_handle *stream, int64_t offset, int seek_position);18791880/* Read data from a file. Returns the number of bytes read, or -1 for error.1881* Introduced in VFS API v1 */1882typedef int64_t (RETRO_CALLCONV *retro_vfs_read_t)(struct retro_vfs_file_handle *stream, void *s, uint64_t len);18831884/* Write data to a file. Returns the number of bytes written, or -1 for error.1885* Introduced in VFS API v1 */1886typedef int64_t (RETRO_CALLCONV *retro_vfs_write_t)(struct retro_vfs_file_handle *stream, const void *s, uint64_t len);18871888/* Flush pending writes to file, if using buffered IO. Returns 0 on sucess, or -1 on failure.1889* Introduced in VFS API v1 */1890typedef int (RETRO_CALLCONV *retro_vfs_flush_t)(struct retro_vfs_file_handle *stream);18911892/* Delete the specified file. Returns 0 on success, -1 on failure1893* Introduced in VFS API v1 */1894typedef int (RETRO_CALLCONV *retro_vfs_remove_t)(const char *path);18951896/* Rename the specified file. Returns 0 on success, -1 on failure1897* Introduced in VFS API v1 */1898typedef int (RETRO_CALLCONV *retro_vfs_rename_t)(const char *old_path, const char *new_path);18991900/* Stat the specified file. Retruns a bitmask of RETRO_VFS_STAT_* flags, none are set if path was not valid.1901* Additionally stores file size in given variable, unless NULL is given.1902* Introduced in VFS API v3 */1903typedef int (RETRO_CALLCONV *retro_vfs_stat_t)(const char *path, int32_t *size);19041905/* Create the specified directory. Returns 0 on success, -1 on unknown failure, -2 if already exists.1906* Introduced in VFS API v3 */1907typedef int (RETRO_CALLCONV *retro_vfs_mkdir_t)(const char *dir);19081909/* Open the specified directory for listing. Returns the opaque dir handle, or NULL for error.1910* Support for the include_hidden argument may vary depending on the platform.1911* Introduced in VFS API v3 */1912typedef struct retro_vfs_dir_handle *(RETRO_CALLCONV *retro_vfs_opendir_t)(const char *dir, bool include_hidden);19131914/* Read the directory entry at the current position, and move the read pointer to the next position.1915* Returns true on success, false if already on the last entry.1916* Introduced in VFS API v3 */1917typedef bool (RETRO_CALLCONV *retro_vfs_readdir_t)(struct retro_vfs_dir_handle *dirstream);19181919/* Get the name of the last entry read. Returns a string on success, or NULL for error.1920* The returned string pointer is valid until the next call to readdir or closedir.1921* Introduced in VFS API v3 */1922typedef const char *(RETRO_CALLCONV *retro_vfs_dirent_get_name_t)(struct retro_vfs_dir_handle *dirstream);19231924/* Check if the last entry read was a directory. Returns true if it was, false otherwise (or on error).1925* Introduced in VFS API v3 */1926typedef bool (RETRO_CALLCONV *retro_vfs_dirent_is_dir_t)(struct retro_vfs_dir_handle *dirstream);19271928/* Close the directory and release its resources. Must be called if opendir returns non-NULL. Returns 0 on success, -1 on failure.1929* Whether the call succeeds ot not, the handle passed as parameter becomes invalid and should no longer be used.1930* Introduced in VFS API v3 */1931typedef int (RETRO_CALLCONV *retro_vfs_closedir_t)(struct retro_vfs_dir_handle *dirstream);19321933struct retro_vfs_interface1934{1935/* VFS API v1 */1936retro_vfs_get_path_t get_path;1937retro_vfs_open_t open;1938retro_vfs_close_t close;1939retro_vfs_size_t size;1940retro_vfs_tell_t tell;1941retro_vfs_seek_t seek;1942retro_vfs_read_t read;1943retro_vfs_write_t write;1944retro_vfs_flush_t flush;1945retro_vfs_remove_t remove;1946retro_vfs_rename_t rename;1947/* VFS API v2 */1948retro_vfs_truncate_t truncate;1949/* VFS API v3 */1950retro_vfs_stat_t stat;1951retro_vfs_mkdir_t mkdir;1952retro_vfs_opendir_t opendir;1953retro_vfs_readdir_t readdir;1954retro_vfs_dirent_get_name_t dirent_get_name;1955retro_vfs_dirent_is_dir_t dirent_is_dir;1956retro_vfs_closedir_t closedir;1957};19581959struct retro_vfs_interface_info1960{1961/* Set by core: should this be higher than the version the front end supports,1962* front end will return false in the RETRO_ENVIRONMENT_GET_VFS_INTERFACE call1963* Introduced in VFS API v1 */1964uint32_t required_interface_version;19651966/* Frontend writes interface pointer here. The frontend also sets the actual1967* version, must be at least required_interface_version.1968* Introduced in VFS API v1 */1969struct retro_vfs_interface *iface;1970};19711972enum retro_hw_render_interface_type1973{1974RETRO_HW_RENDER_INTERFACE_VULKAN = 0,1975RETRO_HW_RENDER_INTERFACE_D3D9 = 1,1976RETRO_HW_RENDER_INTERFACE_D3D10 = 2,1977RETRO_HW_RENDER_INTERFACE_D3D11 = 3,1978RETRO_HW_RENDER_INTERFACE_D3D12 = 4,1979RETRO_HW_RENDER_INTERFACE_GSKIT_PS2 = 5,1980RETRO_HW_RENDER_INTERFACE_DUMMY = INT_MAX1981};19821983/* Base struct. All retro_hw_render_interface_* types1984* contain at least these fields. */1985struct retro_hw_render_interface1986{1987enum retro_hw_render_interface_type interface_type;1988unsigned interface_version;1989};19901991typedef void (RETRO_CALLCONV *retro_set_led_state_t)(int led, int state);1992struct retro_led_interface1993{1994retro_set_led_state_t set_led_state;1995};19961997/* Retrieves the current state of the MIDI input.1998* Returns true if it's enabled, false otherwise. */1999typedef bool (RETRO_CALLCONV *retro_midi_input_enabled_t)(void);20002001/* Retrieves the current state of the MIDI output.2002* Returns true if it's enabled, false otherwise */2003typedef bool (RETRO_CALLCONV *retro_midi_output_enabled_t)(void);20042005/* Reads next byte from the input stream.2006* Returns true if byte is read, false otherwise. */2007typedef bool (RETRO_CALLCONV *retro_midi_read_t)(uint8_t *byte);20082009/* Writes byte to the output stream.2010* 'delta_time' is in microseconds and represent time elapsed since previous write.2011* Returns true if byte is written, false otherwise. */2012typedef bool (RETRO_CALLCONV *retro_midi_write_t)(uint8_t byte, uint32_t delta_time);20132014/* Flushes previously written data.2015* Returns true if successful, false otherwise. */2016typedef bool (RETRO_CALLCONV *retro_midi_flush_t)(void);20172018struct retro_midi_interface2019{2020retro_midi_input_enabled_t input_enabled;2021retro_midi_output_enabled_t output_enabled;2022retro_midi_read_t read;2023retro_midi_write_t write;2024retro_midi_flush_t flush;2025};20262027enum retro_hw_render_context_negotiation_interface_type2028{2029RETRO_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE_VULKAN = 0,2030RETRO_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE_DUMMY = INT_MAX2031};20322033/* Base struct. All retro_hw_render_context_negotiation_interface_* types2034* contain at least these fields. */2035struct retro_hw_render_context_negotiation_interface2036{2037enum retro_hw_render_context_negotiation_interface_type interface_type;2038unsigned interface_version;2039};20402041/* Serialized state is incomplete in some way. Set if serialization is2042* usable in typical end-user cases but should not be relied upon to2043* implement frame-sensitive frontend features such as netplay or2044* rerecording. */2045#define RETRO_SERIALIZATION_QUIRK_INCOMPLETE (1 << 0)2046/* The core must spend some time initializing before serialization is2047* supported. retro_serialize() will initially fail; retro_unserialize()2048* and retro_serialize_size() may or may not work correctly either. */2049#define RETRO_SERIALIZATION_QUIRK_MUST_INITIALIZE (1 << 1)2050/* Serialization size may change within a session. */2051#define RETRO_SERIALIZATION_QUIRK_CORE_VARIABLE_SIZE (1 << 2)2052/* Set by the frontend to acknowledge that it supports variable-sized2053* states. */2054#define RETRO_SERIALIZATION_QUIRK_FRONT_VARIABLE_SIZE (1 << 3)2055/* Serialized state can only be loaded during the same session. */2056#define RETRO_SERIALIZATION_QUIRK_SINGLE_SESSION (1 << 4)2057/* Serialized state cannot be loaded on an architecture with a different2058* endianness from the one it was saved on. */2059#define RETRO_SERIALIZATION_QUIRK_ENDIAN_DEPENDENT (1 << 5)2060/* Serialized state cannot be loaded on a different platform from the one it2061* was saved on for reasons other than endianness, such as word size2062* dependence */2063#define RETRO_SERIALIZATION_QUIRK_PLATFORM_DEPENDENT (1 << 6)20642065#define RETRO_MEMDESC_CONST (1 << 0) /* The frontend will never change this memory area once retro_load_game has returned. */2066#define RETRO_MEMDESC_BIGENDIAN (1 << 1) /* The memory area contains big endian data. Default is little endian. */2067#define RETRO_MEMDESC_SYSTEM_RAM (1 << 2) /* The memory area is system RAM. This is main RAM of the gaming system. */2068#define RETRO_MEMDESC_SAVE_RAM (1 << 3) /* The memory area is save RAM. This RAM is usually found on a game cartridge, backed up by a battery. */2069#define RETRO_MEMDESC_VIDEO_RAM (1 << 4) /* The memory area is video RAM (VRAM) */2070#define RETRO_MEMDESC_ALIGN_2 (1 << 16) /* All memory access in this area is aligned to their own size, or 2, whichever is smaller. */2071#define RETRO_MEMDESC_ALIGN_4 (2 << 16)2072#define RETRO_MEMDESC_ALIGN_8 (3 << 16)2073#define RETRO_MEMDESC_MINSIZE_2 (1 << 24) /* All memory in this region is accessed at least 2 bytes at the time. */2074#define RETRO_MEMDESC_MINSIZE_4 (2 << 24)2075#define RETRO_MEMDESC_MINSIZE_8 (3 << 24)2076struct retro_memory_descriptor2077{2078uint64_t flags;20792080/* Pointer to the start of the relevant ROM or RAM chip.2081* It's strongly recommended to use 'offset' if possible, rather than2082* doing math on the pointer.2083*2084* If the same byte is mapped my multiple descriptors, their descriptors2085* must have the same pointer.2086* If 'start' does not point to the first byte in the pointer, put the2087* difference in 'offset' instead.2088*2089* May be NULL if there's nothing usable here (e.g. hardware registers and2090* open bus). No flags should be set if the pointer is NULL.2091* It's recommended to minimize the number of descriptors if possible,2092* but not mandatory. */2093void *ptr;2094size_t offset;20952096/* This is the location in the emulated address space2097* where the mapping starts. */2098size_t start;20992100/* Which bits must be same as in 'start' for this mapping to apply.2101* The first memory descriptor to claim a certain byte is the one2102* that applies.2103* A bit which is set in 'start' must also be set in this.2104* Can be zero, in which case each byte is assumed mapped exactly once.2105* In this case, 'len' must be a power of two. */2106size_t select;21072108/* If this is nonzero, the set bits are assumed not connected to the2109* memory chip's address pins. */2110size_t disconnect;21112112/* This one tells the size of the current memory area.2113* If, after start+disconnect are applied, the address is higher than2114* this, the highest bit of the address is cleared.2115*2116* If the address is still too high, the next highest bit is cleared.2117* Can be zero, in which case it's assumed to be infinite (as limited2118* by 'select' and 'disconnect'). */2119size_t len;21202121/* To go from emulated address to physical address, the following2122* order applies:2123* Subtract 'start', pick off 'disconnect', apply 'len', add 'offset'. */21242125/* The address space name must consist of only a-zA-Z0-9_-,2126* should be as short as feasible (maximum length is 8 plus the NUL),2127* and may not be any other address space plus one or more 0-9A-F2128* at the end.2129* However, multiple memory descriptors for the same address space is2130* allowed, and the address space name can be empty. NULL is treated2131* as empty.2132*2133* Address space names are case sensitive, but avoid lowercase if possible.2134* The same pointer may exist in multiple address spaces.2135*2136* Examples:2137* blank+blank - valid (multiple things may be mapped in the same namespace)2138* 'Sp'+'Sp' - valid (multiple things may be mapped in the same namespace)2139* 'A'+'B' - valid (neither is a prefix of each other)2140* 'S'+blank - valid ('S' is not in 0-9A-F)2141* 'a'+blank - valid ('a' is not in 0-9A-F)2142* 'a'+'A' - valid (neither is a prefix of each other)2143* 'AR'+blank - valid ('R' is not in 0-9A-F)2144* 'ARB'+blank - valid (the B can't be part of the address either, because2145* there is no namespace 'AR')2146* blank+'B' - not valid, because it's ambigous which address space B12342147* would refer to.2148* The length can't be used for that purpose; the frontend may want2149* to append arbitrary data to an address, without a separator. */2150const char *addrspace;21512152/* TODO: When finalizing this one, add a description field, which should be2153* "WRAM" or something roughly equally long. */21542155/* TODO: When finalizing this one, replace 'select' with 'limit', which tells2156* which bits can vary and still refer to the same address (limit = ~select).2157* TODO: limit? range? vary? something else? */21582159/* TODO: When finalizing this one, if 'len' is above what 'select' (or2160* 'limit') allows, it's bankswitched. Bankswitched data must have both 'len'2161* and 'select' != 0, and the mappings don't tell how the system switches the2162* banks. */21632164/* TODO: When finalizing this one, fix the 'len' bit removal order.2165* For len=0x1800, pointer 0x1C00 should go to 0x1400, not 0x0C00.2166* Algorithm: Take bits highest to lowest, but if it goes above len, clear2167* the most recent addition and continue on the next bit.2168* TODO: Can the above be optimized? Is "remove the lowest bit set in both2169* pointer and 'len'" equivalent? */21702171/* TODO: Some emulators (MAME?) emulate big endian systems by only accessing2172* the emulated memory in 32-bit chunks, native endian. But that's nothing2173* compared to Darek Mihocka <http://www.emulators.com/docs/nx07_vm101.htm>2174* (section Emulation 103 - Nearly Free Byte Reversal) - he flips the ENTIRE2175* RAM backwards! I'll want to represent both of those, via some flags.2176*2177* I suspect MAME either didn't think of that idea, or don't want the #ifdef.2178* Not sure which, nor do I really care. */21792180/* TODO: Some of those flags are unused and/or don't really make sense. Clean2181* them up. */2182};21832184/* The frontend may use the largest value of 'start'+'select' in a2185* certain namespace to infer the size of the address space.2186*2187* If the address space is larger than that, a mapping with .ptr=NULL2188* should be at the end of the array, with .select set to all ones for2189* as long as the address space is big.2190*2191* Sample descriptors (minus .ptr, and RETRO_MEMFLAG_ on the flags):2192* SNES WRAM:2193* .start=0x7E0000, .len=0x200002194* (Note that this must be mapped before the ROM in most cases; some of the2195* ROM mappers2196* try to claim $7E0000, or at least $7E8000.)2197* SNES SPC700 RAM:2198* .addrspace="S", .len=0x100002199* SNES WRAM mirrors:2200* .flags=MIRROR, .start=0x000000, .select=0xC0E000, .len=0x20002201* .flags=MIRROR, .start=0x800000, .select=0xC0E000, .len=0x20002202* SNES WRAM mirrors, alternate equivalent descriptor:2203* .flags=MIRROR, .select=0x40E000, .disconnect=~0x1FFF2204* (Various similar constructions can be created by combining parts of2205* the above two.)2206* SNES LoROM (512KB, mirrored a couple of times):2207* .flags=CONST, .start=0x008000, .select=0x408000, .disconnect=0x8000, .len=512*10242208* .flags=CONST, .start=0x400000, .select=0x400000, .disconnect=0x8000, .len=512*10242209* SNES HiROM (4MB):2210* .flags=CONST, .start=0x400000, .select=0x400000, .len=4*1024*10242211* .flags=CONST, .offset=0x8000, .start=0x008000, .select=0x408000, .len=4*1024*10242212* SNES ExHiROM (8MB):2213* .flags=CONST, .offset=0, .start=0xC00000, .select=0xC00000, .len=4*1024*10242214* .flags=CONST, .offset=4*1024*1024, .start=0x400000, .select=0xC00000, .len=4*1024*10242215* .flags=CONST, .offset=0x8000, .start=0x808000, .select=0xC08000, .len=4*1024*10242216* .flags=CONST, .offset=4*1024*1024+0x8000, .start=0x008000, .select=0xC08000, .len=4*1024*10242217* Clarify the size of the address space:2218* .ptr=NULL, .select=0xFFFFFF2219* .len can be implied by .select in many of them, but was included for clarity.2220*/22212222struct retro_memory_map2223{2224const struct retro_memory_descriptor *descriptors;2225unsigned num_descriptors;2226};22272228struct retro_controller_description2229{2230/* Human-readable description of the controller. Even if using a generic2231* input device type, this can be set to the particular device type the2232* core uses. */2233const char *desc;22342235/* Device type passed to retro_set_controller_port_device(). If the device2236* type is a sub-class of a generic input device type, use the2237* RETRO_DEVICE_SUBCLASS macro to create an ID.2238*2239* E.g. RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 1). */2240unsigned id;2241};22422243struct retro_controller_info2244{2245const struct retro_controller_description *types;2246unsigned num_types;2247};22482249struct retro_subsystem_memory_info2250{2251/* The extension associated with a memory type, e.g. "psram". */2252const char *extension;22532254/* The memory type for retro_get_memory(). This should be at2255* least 0x100 to avoid conflict with standardized2256* libretro memory types. */2257unsigned type;2258};22592260struct retro_subsystem_rom_info2261{2262/* Describes what the content is (SGB BIOS, GB ROM, etc). */2263const char *desc;22642265/* Same definition as retro_get_system_info(). */2266const char *valid_extensions;22672268/* Same definition as retro_get_system_info(). */2269bool need_fullpath;22702271/* Same definition as retro_get_system_info(). */2272bool block_extract;22732274/* This is set if the content is required to load a game.2275* If this is set to false, a zeroed-out retro_game_info can be passed. */2276bool required;22772278/* Content can have multiple associated persistent2279* memory types (retro_get_memory()). */2280const struct retro_subsystem_memory_info *memory;2281unsigned num_memory;2282};22832284struct retro_subsystem_info2285{2286/* Human-readable string of the subsystem type, e.g. "Super GameBoy" */2287const char *desc;22882289/* A computer friendly short string identifier for the subsystem type.2290* This name must be [a-z].2291* E.g. if desc is "Super GameBoy", this can be "sgb".2292* This identifier can be used for command-line interfaces, etc.2293*/2294const char *ident;22952296/* Infos for each content file. The first entry is assumed to be the2297* "most significant" content for frontend purposes.2298* E.g. with Super GameBoy, the first content should be the GameBoy ROM,2299* as it is the most "significant" content to a user.2300* If a frontend creates new file paths based on the content used2301* (e.g. savestates), it should use the path for the first ROM to do so. */2302const struct retro_subsystem_rom_info *roms;23032304/* Number of content files associated with a subsystem. */2305unsigned num_roms;23062307/* The type passed to retro_load_game_special(). */2308unsigned id;2309};23102311typedef void (RETRO_CALLCONV *retro_proc_address_t)(void);23122313/* libretro API extension functions:2314* (None here so far).2315*2316* Get a symbol from a libretro core.2317* Cores should only return symbols which are actual2318* extensions to the libretro API.2319*2320* Frontends should not use this to obtain symbols to standard2321* libretro entry points (static linking or dlsym).2322*2323* The symbol name must be equal to the function name,2324* e.g. if void retro_foo(void); exists, the symbol must be called "retro_foo".2325* The returned function pointer must be cast to the corresponding type.2326*/2327typedef retro_proc_address_t (RETRO_CALLCONV *retro_get_proc_address_t)(const char *sym);23282329struct retro_get_proc_address_interface2330{2331retro_get_proc_address_t get_proc_address;2332};23332334enum retro_log_level2335{2336RETRO_LOG_DEBUG = 0,2337RETRO_LOG_INFO,2338RETRO_LOG_WARN,2339RETRO_LOG_ERROR,23402341RETRO_LOG_DUMMY = INT_MAX2342};23432344/* Logging function. Takes log level argument as well. */2345typedef void (RETRO_CALLCONV *retro_log_printf_t)(enum retro_log_level level,2346const char *fmt, ...);23472348struct retro_log_callback2349{2350retro_log_printf_t log;2351};23522353/* Performance related functions */23542355/* ID values for SIMD CPU features */2356#define RETRO_SIMD_SSE (1 << 0)2357#define RETRO_SIMD_SSE2 (1 << 1)2358#define RETRO_SIMD_VMX (1 << 2)2359#define RETRO_SIMD_VMX128 (1 << 3)2360#define RETRO_SIMD_AVX (1 << 4)2361#define RETRO_SIMD_NEON (1 << 5)2362#define RETRO_SIMD_SSE3 (1 << 6)2363#define RETRO_SIMD_SSSE3 (1 << 7)2364#define RETRO_SIMD_MMX (1 << 8)2365#define RETRO_SIMD_MMXEXT (1 << 9)2366#define RETRO_SIMD_SSE4 (1 << 10)2367#define RETRO_SIMD_SSE42 (1 << 11)2368#define RETRO_SIMD_AVX2 (1 << 12)2369#define RETRO_SIMD_VFPU (1 << 13)2370#define RETRO_SIMD_PS (1 << 14)2371#define RETRO_SIMD_AES (1 << 15)2372#define RETRO_SIMD_VFPV3 (1 << 16)2373#define RETRO_SIMD_VFPV4 (1 << 17)2374#define RETRO_SIMD_POPCNT (1 << 18)2375#define RETRO_SIMD_MOVBE (1 << 19)2376#define RETRO_SIMD_CMOV (1 << 20)2377#define RETRO_SIMD_ASIMD (1 << 21)23782379typedef uint64_t retro_perf_tick_t;2380typedef int64_t retro_time_t;23812382struct retro_perf_counter2383{2384const char *ident;2385retro_perf_tick_t start;2386retro_perf_tick_t total;2387retro_perf_tick_t call_cnt;23882389bool registered;2390};23912392/* Returns current time in microseconds.2393* Tries to use the most accurate timer available.2394*/2395typedef retro_time_t (RETRO_CALLCONV *retro_perf_get_time_usec_t)(void);23962397/* A simple counter. Usually nanoseconds, but can also be CPU cycles.2398* Can be used directly if desired (when creating a more sophisticated2399* performance counter system).2400* */2401typedef retro_perf_tick_t (RETRO_CALLCONV *retro_perf_get_counter_t)(void);24022403/* Returns a bit-mask of detected CPU features (RETRO_SIMD_*). */2404typedef uint64_t (RETRO_CALLCONV *retro_get_cpu_features_t)(void);24052406/* Asks frontend to log and/or display the state of performance counters.2407* Performance counters can always be poked into manually as well.2408*/2409typedef void (RETRO_CALLCONV *retro_perf_log_t)(void);24102411/* Register a performance counter.2412* ident field must be set with a discrete value and other values in2413* retro_perf_counter must be 0.2414* Registering can be called multiple times. To avoid calling to2415* frontend redundantly, you can check registered field first. */2416typedef void (RETRO_CALLCONV *retro_perf_register_t)(struct retro_perf_counter *counter);24172418/* Starts a registered counter. */2419typedef void (RETRO_CALLCONV *retro_perf_start_t)(struct retro_perf_counter *counter);24202421/* Stops a registered counter. */2422typedef void (RETRO_CALLCONV *retro_perf_stop_t)(struct retro_perf_counter *counter);24232424/* For convenience it can be useful to wrap register, start and stop in macros.2425* E.g.:2426* #ifdef LOG_PERFORMANCE2427* #define RETRO_PERFORMANCE_INIT(perf_cb, name) static struct retro_perf_counter name = {#name}; if (!name.registered) perf_cb.perf_register(&(name))2428* #define RETRO_PERFORMANCE_START(perf_cb, name) perf_cb.perf_start(&(name))2429* #define RETRO_PERFORMANCE_STOP(perf_cb, name) perf_cb.perf_stop(&(name))2430* #else2431* ... Blank macros ...2432* #endif2433*2434* These can then be used mid-functions around code snippets.2435*2436* extern struct retro_perf_callback perf_cb; * Somewhere in the core.2437*2438* void do_some_heavy_work(void)2439* {2440* RETRO_PERFORMANCE_INIT(cb, work_1;2441* RETRO_PERFORMANCE_START(cb, work_1);2442* heavy_work_1();2443* RETRO_PERFORMANCE_STOP(cb, work_1);2444*2445* RETRO_PERFORMANCE_INIT(cb, work_2);2446* RETRO_PERFORMANCE_START(cb, work_2);2447* heavy_work_2();2448* RETRO_PERFORMANCE_STOP(cb, work_2);2449* }2450*2451* void retro_deinit(void)2452* {2453* perf_cb.perf_log(); * Log all perf counters here for example.2454* }2455*/24562457struct retro_perf_callback2458{2459retro_perf_get_time_usec_t get_time_usec;2460retro_get_cpu_features_t get_cpu_features;24612462retro_perf_get_counter_t get_perf_counter;2463retro_perf_register_t perf_register;2464retro_perf_start_t perf_start;2465retro_perf_stop_t perf_stop;2466retro_perf_log_t perf_log;2467};24682469/* FIXME: Document the sensor API and work out behavior.2470* It will be marked as experimental until then.2471*/2472enum retro_sensor_action2473{2474RETRO_SENSOR_ACCELEROMETER_ENABLE = 0,2475RETRO_SENSOR_ACCELEROMETER_DISABLE,2476RETRO_SENSOR_GYROSCOPE_ENABLE,2477RETRO_SENSOR_GYROSCOPE_DISABLE,2478RETRO_SENSOR_ILLUMINANCE_ENABLE,2479RETRO_SENSOR_ILLUMINANCE_DISABLE,24802481RETRO_SENSOR_DUMMY = INT_MAX2482};24832484/* Id values for SENSOR types. */2485#define RETRO_SENSOR_ACCELEROMETER_X 02486#define RETRO_SENSOR_ACCELEROMETER_Y 12487#define RETRO_SENSOR_ACCELEROMETER_Z 22488#define RETRO_SENSOR_GYROSCOPE_X 32489#define RETRO_SENSOR_GYROSCOPE_Y 42490#define RETRO_SENSOR_GYROSCOPE_Z 52491#define RETRO_SENSOR_ILLUMINANCE 624922493typedef bool (RETRO_CALLCONV *retro_set_sensor_state_t)(unsigned port,2494enum retro_sensor_action action, unsigned rate);24952496typedef float (RETRO_CALLCONV *retro_sensor_get_input_t)(unsigned port, unsigned id);24972498struct retro_sensor_interface2499{2500retro_set_sensor_state_t set_sensor_state;2501retro_sensor_get_input_t get_sensor_input;2502};25032504enum retro_camera_buffer2505{2506RETRO_CAMERA_BUFFER_OPENGL_TEXTURE = 0,2507RETRO_CAMERA_BUFFER_RAW_FRAMEBUFFER,25082509RETRO_CAMERA_BUFFER_DUMMY = INT_MAX2510};25112512/* Starts the camera driver. Can only be called in retro_run(). */2513typedef bool (RETRO_CALLCONV *retro_camera_start_t)(void);25142515/* Stops the camera driver. Can only be called in retro_run(). */2516typedef void (RETRO_CALLCONV *retro_camera_stop_t)(void);25172518/* Callback which signals when the camera driver is initialized2519* and/or deinitialized.2520* retro_camera_start_t can be called in initialized callback.2521*/2522typedef void (RETRO_CALLCONV *retro_camera_lifetime_status_t)(void);25232524/* A callback for raw framebuffer data. buffer points to an XRGB8888 buffer.2525* Width, height and pitch are similar to retro_video_refresh_t.2526* First pixel is top-left origin.2527*/2528typedef void (RETRO_CALLCONV *retro_camera_frame_raw_framebuffer_t)(const uint32_t *buffer,2529unsigned width, unsigned height, size_t pitch);25302531/* A callback for when OpenGL textures are used.2532*2533* texture_id is a texture owned by camera driver.2534* Its state or content should be considered immutable, except for things like2535* texture filtering and clamping.2536*2537* texture_target is the texture target for the GL texture.2538* These can include e.g. GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE, and possibly2539* more depending on extensions.2540*2541* affine points to a packed 3x3 column-major matrix used to apply an affine2542* transform to texture coordinates. (affine_matrix * vec3(coord_x, coord_y, 1.0))2543* After transform, normalized texture coord (0, 0) should be bottom-left2544* and (1, 1) should be top-right (or (width, height) for RECTANGLE).2545*2546* GL-specific typedefs are avoided here to avoid relying on gl.h in2547* the API definition.2548*/2549typedef void (RETRO_CALLCONV *retro_camera_frame_opengl_texture_t)(unsigned texture_id,2550unsigned texture_target, const float *affine);25512552struct retro_camera_callback2553{2554/* Set by libretro core.2555* Example bitmask: caps = (1 << RETRO_CAMERA_BUFFER_OPENGL_TEXTURE) | (1 << RETRO_CAMERA_BUFFER_RAW_FRAMEBUFFER).2556*/2557uint64_t caps;25582559/* Desired resolution for camera. Is only used as a hint. */2560unsigned width;2561unsigned height;25622563/* Set by frontend. */2564retro_camera_start_t start;2565retro_camera_stop_t stop;25662567/* Set by libretro core if raw framebuffer callbacks will be used. */2568retro_camera_frame_raw_framebuffer_t frame_raw_framebuffer;25692570/* Set by libretro core if OpenGL texture callbacks will be used. */2571retro_camera_frame_opengl_texture_t frame_opengl_texture;25722573/* Set by libretro core. Called after camera driver is initialized and2574* ready to be started.2575* Can be NULL, in which this callback is not called.2576*/2577retro_camera_lifetime_status_t initialized;25782579/* Set by libretro core. Called right before camera driver is2580* deinitialized.2581* Can be NULL, in which this callback is not called.2582*/2583retro_camera_lifetime_status_t deinitialized;2584};25852586/* Sets the interval of time and/or distance at which to update/poll2587* location-based data.2588*2589* To ensure compatibility with all location-based implementations,2590* values for both interval_ms and interval_distance should be provided.2591*2592* interval_ms is the interval expressed in milliseconds.2593* interval_distance is the distance interval expressed in meters.2594*/2595typedef void (RETRO_CALLCONV *retro_location_set_interval_t)(unsigned interval_ms,2596unsigned interval_distance);25972598/* Start location services. The device will start listening for changes to the2599* current location at regular intervals (which are defined with2600* retro_location_set_interval_t). */2601typedef bool (RETRO_CALLCONV *retro_location_start_t)(void);26022603/* Stop location services. The device will stop listening for changes2604* to the current location. */2605typedef void (RETRO_CALLCONV *retro_location_stop_t)(void);26062607/* Get the position of the current location. Will set parameters to2608* 0 if no new location update has happened since the last time. */2609typedef bool (RETRO_CALLCONV *retro_location_get_position_t)(double *lat, double *lon,2610double *horiz_accuracy, double *vert_accuracy);26112612/* Callback which signals when the location driver is initialized2613* and/or deinitialized.2614* retro_location_start_t can be called in initialized callback.2615*/2616typedef void (RETRO_CALLCONV *retro_location_lifetime_status_t)(void);26172618struct retro_location_callback2619{2620retro_location_start_t start;2621retro_location_stop_t stop;2622retro_location_get_position_t get_position;2623retro_location_set_interval_t set_interval;26242625retro_location_lifetime_status_t initialized;2626retro_location_lifetime_status_t deinitialized;2627};26282629enum retro_rumble_effect2630{2631RETRO_RUMBLE_STRONG = 0,2632RETRO_RUMBLE_WEAK = 1,26332634RETRO_RUMBLE_DUMMY = INT_MAX2635};26362637/* Sets rumble state for joypad plugged in port 'port'.2638* Rumble effects are controlled independently,2639* and setting e.g. strong rumble does not override weak rumble.2640* Strength has a range of [0, 0xffff].2641*2642* Returns true if rumble state request was honored.2643* Calling this before first retro_run() is likely to return false. */2644typedef bool (RETRO_CALLCONV *retro_set_rumble_state_t)(unsigned port,2645enum retro_rumble_effect effect, uint16_t strength);26462647struct retro_rumble_interface2648{2649retro_set_rumble_state_t set_rumble_state;2650};26512652/* Notifies libretro that audio data should be written. */2653typedef void (RETRO_CALLCONV *retro_audio_callback_t)(void);26542655/* True: AUDIO driver in frontend is active, and callback is2656* expected to be called regularily.2657* False: AUDIO driver in frontend is paused or inactive.2658* AUDIO callback will not be called until set_state has been2659* called with true.2660* Initial state is false (inactive).2661*/2662typedef void (RETRO_CALLCONV *retro_audio_set_state_callback_t)(bool enabled);26632664struct retro_audio_callback2665{2666retro_audio_callback_t callback;2667retro_audio_set_state_callback_t set_state;2668};26692670/* Notifies a libretro core of time spent since last invocation2671* of retro_run() in microseconds.2672*2673* It will be called right before retro_run() every frame.2674* The frontend can tamper with timing to support cases like2675* fast-forward, slow-motion and framestepping.2676*2677* In those scenarios the reference frame time value will be used. */2678typedef int64_t retro_usec_t;2679typedef void (RETRO_CALLCONV *retro_frame_time_callback_t)(retro_usec_t usec);2680struct retro_frame_time_callback2681{2682retro_frame_time_callback_t callback;2683/* Represents the time of one frame. It is computed as2684* 1000000 / fps, but the implementation will resolve the2685* rounding to ensure that framestepping, etc is exact. */2686retro_usec_t reference;2687};26882689/* Notifies a libretro core of the current occupancy2690* level of the frontend audio buffer.2691*2692* - active: 'true' if audio buffer is currently2693* in use. Will be 'false' if audio is2694* disabled in the frontend2695*2696* - occupancy: Given as a value in the range [0,100],2697* corresponding to the occupancy percentage2698* of the audio buffer2699*2700* - underrun_likely: 'true' if the frontend expects an2701* audio buffer underrun during the2702* next frame (indicates that a core2703* should attempt frame skipping)2704*2705* It will be called right before retro_run() every frame. */2706typedef void (RETRO_CALLCONV *retro_audio_buffer_status_callback_t)(2707bool active, unsigned occupancy, bool underrun_likely);2708struct retro_audio_buffer_status_callback2709{2710retro_audio_buffer_status_callback_t callback;2711};27122713/* Pass this to retro_video_refresh_t if rendering to hardware.2714* Passing NULL to retro_video_refresh_t is still a frame dupe as normal.2715* */2716#define RETRO_HW_FRAME_BUFFER_VALID ((void*)-1)27172718/* Invalidates the current HW context.2719* Any GL state is lost, and must not be deinitialized explicitly.2720* If explicit deinitialization is desired by the libretro core,2721* it should implement context_destroy callback.2722* If called, all GPU resources must be reinitialized.2723* Usually called when frontend reinits video driver.2724* Also called first time video driver is initialized,2725* allowing libretro core to initialize resources.2726*/2727typedef void (RETRO_CALLCONV *retro_hw_context_reset_t)(void);27282729/* Gets current framebuffer which is to be rendered to.2730* Could change every frame potentially.2731*/2732typedef uintptr_t (RETRO_CALLCONV *retro_hw_get_current_framebuffer_t)(void);27332734/* Get a symbol from HW context. */2735typedef retro_proc_address_t (RETRO_CALLCONV *retro_hw_get_proc_address_t)(const char *sym);27362737enum retro_hw_context_type2738{2739RETRO_HW_CONTEXT_NONE = 0,2740/* OpenGL 2.x. Driver can choose to use latest compatibility context. */2741RETRO_HW_CONTEXT_OPENGL = 1,2742/* OpenGL ES 2.0. */2743RETRO_HW_CONTEXT_OPENGLES2 = 2,2744/* Modern desktop core GL context. Use version_major/2745* version_minor fields to set GL version. */2746RETRO_HW_CONTEXT_OPENGL_CORE = 3,2747/* OpenGL ES 3.0 */2748RETRO_HW_CONTEXT_OPENGLES3 = 4,2749/* OpenGL ES 3.1+. Set version_major/version_minor. For GLES2 and GLES3,2750* use the corresponding enums directly. */2751RETRO_HW_CONTEXT_OPENGLES_VERSION = 5,27522753/* Vulkan, see RETRO_ENVIRONMENT_GET_HW_RENDER_INTERFACE. */2754RETRO_HW_CONTEXT_VULKAN = 6,27552756/* Direct3D, set version_major to select the type of interface2757* returned by RETRO_ENVIRONMENT_GET_HW_RENDER_INTERFACE */2758RETRO_HW_CONTEXT_DIRECT3D = 7,27592760RETRO_HW_CONTEXT_DUMMY = INT_MAX2761};27622763struct retro_hw_render_callback2764{2765/* Which API to use. Set by libretro core. */2766enum retro_hw_context_type context_type;27672768/* Called when a context has been created or when it has been reset.2769* An OpenGL context is only valid after context_reset() has been called.2770*2771* When context_reset is called, OpenGL resources in the libretro2772* implementation are guaranteed to be invalid.2773*2774* It is possible that context_reset is called multiple times during an2775* application lifecycle.2776* If context_reset is called without any notification (context_destroy),2777* the OpenGL context was lost and resources should just be recreated2778* without any attempt to "free" old resources.2779*/2780retro_hw_context_reset_t context_reset;27812782/* Set by frontend.2783* TODO: This is rather obsolete. The frontend should not2784* be providing preallocated framebuffers. */2785retro_hw_get_current_framebuffer_t get_current_framebuffer;27862787/* Set by frontend.2788* Can return all relevant functions, including glClear on Windows. */2789retro_hw_get_proc_address_t get_proc_address;27902791/* Set if render buffers should have depth component attached.2792* TODO: Obsolete. */2793bool depth;27942795/* Set if stencil buffers should be attached.2796* TODO: Obsolete. */2797bool stencil;27982799/* If depth and stencil are true, a packed 24/8 buffer will be added.2800* Only attaching stencil is invalid and will be ignored. */28012802/* Use conventional bottom-left origin convention. If false,2803* standard libretro top-left origin semantics are used.2804* TODO: Move to GL specific interface. */2805bool bottom_left_origin;28062807/* Major version number for core GL context or GLES 3.1+. */2808unsigned version_major;28092810/* Minor version number for core GL context or GLES 3.1+. */2811unsigned version_minor;28122813/* If this is true, the frontend will go very far to avoid2814* resetting context in scenarios like toggling fullscreen, etc.2815* TODO: Obsolete? Maybe frontend should just always assume this ...2816*/2817bool cache_context;28182819/* The reset callback might still be called in extreme situations2820* such as if the context is lost beyond recovery.2821*2822* For optimal stability, set this to false, and allow context to be2823* reset at any time.2824*/28252826/* A callback to be called before the context is destroyed in a2827* controlled way by the frontend. */2828retro_hw_context_reset_t context_destroy;28292830/* OpenGL resources can be deinitialized cleanly at this step.2831* context_destroy can be set to NULL, in which resources will2832* just be destroyed without any notification.2833*2834* Even when context_destroy is non-NULL, it is possible that2835* context_reset is called without any destroy notification.2836* This happens if context is lost by external factors (such as2837* notified by GL_ARB_robustness).2838*2839* In this case, the context is assumed to be already dead,2840* and the libretro implementation must not try to free any OpenGL2841* resources in the subsequent context_reset.2842*/28432844/* Creates a debug context. */2845bool debug_context;2846};28472848/* Callback type passed in RETRO_ENVIRONMENT_SET_KEYBOARD_CALLBACK.2849* Called by the frontend in response to keyboard events.2850* down is set if the key is being pressed, or false if it is being released.2851* keycode is the RETROK value of the char.2852* character is the text character of the pressed key. (UTF-32).2853* key_modifiers is a set of RETROKMOD values or'ed together.2854*2855* The pressed/keycode state can be indepedent of the character.2856* It is also possible that multiple characters are generated from a2857* single keypress.2858* Keycode events should be treated separately from character events.2859* However, when possible, the frontend should try to synchronize these.2860* If only a character is posted, keycode should be RETROK_UNKNOWN.2861*2862* Similarily if only a keycode event is generated with no corresponding2863* character, character should be 0.2864*/2865typedef void (RETRO_CALLCONV *retro_keyboard_event_t)(bool down, unsigned keycode,2866uint32_t character, uint16_t key_modifiers);28672868struct retro_keyboard_callback2869{2870retro_keyboard_event_t callback;2871};28722873/* Callbacks for RETRO_ENVIRONMENT_SET_DISK_CONTROL_INTERFACE &2874* RETRO_ENVIRONMENT_SET_DISK_CONTROL_EXT_INTERFACE.2875* Should be set for implementations which can swap out multiple disk2876* images in runtime.2877*2878* If the implementation can do this automatically, it should strive to do so.2879* However, there are cases where the user must manually do so.2880*2881* Overview: To swap a disk image, eject the disk image with2882* set_eject_state(true).2883* Set the disk index with set_image_index(index). Insert the disk again2884* with set_eject_state(false).2885*/28862887/* If ejected is true, "ejects" the virtual disk tray.2888* When ejected, the disk image index can be set.2889*/2890typedef bool (RETRO_CALLCONV *retro_set_eject_state_t)(bool ejected);28912892/* Gets current eject state. The initial state is 'not ejected'. */2893typedef bool (RETRO_CALLCONV *retro_get_eject_state_t)(void);28942895/* Gets current disk index. First disk is index 0.2896* If return value is >= get_num_images(), no disk is currently inserted.2897*/2898typedef unsigned (RETRO_CALLCONV *retro_get_image_index_t)(void);28992900/* Sets image index. Can only be called when disk is ejected.2901* The implementation supports setting "no disk" by using an2902* index >= get_num_images().2903*/2904typedef bool (RETRO_CALLCONV *retro_set_image_index_t)(unsigned index);29052906/* Gets total number of images which are available to use. */2907typedef unsigned (RETRO_CALLCONV *retro_get_num_images_t)(void);29082909struct retro_game_info;29102911/* Replaces the disk image associated with index.2912* Arguments to pass in info have same requirements as retro_load_game().2913* Virtual disk tray must be ejected when calling this.2914*2915* Replacing a disk image with info = NULL will remove the disk image2916* from the internal list.2917* As a result, calls to get_image_index() can change.2918*2919* E.g. replace_image_index(1, NULL), and previous get_image_index()2920* returned 4 before.2921* Index 1 will be removed, and the new index is 3.2922*/2923typedef bool (RETRO_CALLCONV *retro_replace_image_index_t)(unsigned index,2924const struct retro_game_info *info);29252926/* Adds a new valid index (get_num_images()) to the internal disk list.2927* This will increment subsequent return values from get_num_images() by 1.2928* This image index cannot be used until a disk image has been set2929* with replace_image_index. */2930typedef bool (RETRO_CALLCONV *retro_add_image_index_t)(void);29312932/* Sets initial image to insert in drive when calling2933* core_load_game().2934* Since we cannot pass the initial index when loading2935* content (this would require a major API change), this2936* is set by the frontend *before* calling the core's2937* retro_load_game()/retro_load_game_special() implementation.2938* A core should therefore cache the index/path values and handle2939* them inside retro_load_game()/retro_load_game_special().2940* - If 'index' is invalid (index >= get_num_images()), the2941* core should ignore the set value and instead use 02942* - 'path' is used purely for error checking - i.e. when2943* content is loaded, the core should verify that the2944* disk specified by 'index' has the specified file path.2945* This is to guard against auto selecting the wrong image2946* if (for example) the user should modify an existing M3U2947* playlist. We have to let the core handle this because2948* set_initial_image() must be called before loading content,2949* i.e. the frontend cannot access image paths in advance2950* and thus cannot perform the error check itself.2951* If set path and content path do not match, the core should2952* ignore the set 'index' value and instead use 02953* Returns 'false' if index or 'path' are invalid, or core2954* does not support this functionality2955*/2956typedef bool (RETRO_CALLCONV *retro_set_initial_image_t)(unsigned index, const char *path);29572958/* Fetches the path of the specified disk image file.2959* Returns 'false' if index is invalid (index >= get_num_images())2960* or path is otherwise unavailable.2961*/2962typedef bool (RETRO_CALLCONV *retro_get_image_path_t)(unsigned index, char *path, size_t len);29632964/* Fetches a core-provided 'label' for the specified disk2965* image file. In the simplest case this may be a file name2966* (without extension), but for cores with more complex2967* content requirements information may be provided to2968* facilitate user disk swapping - for example, a core2969* running floppy-disk-based content may uniquely label2970* save disks, data disks, level disks, etc. with names2971* corresponding to in-game disk change prompts (so the2972* frontend can provide better user guidance than a 'dumb'2973* disk index value).2974* Returns 'false' if index is invalid (index >= get_num_images())2975* or label is otherwise unavailable.2976*/2977typedef bool (RETRO_CALLCONV *retro_get_image_label_t)(unsigned index, char *label, size_t len);29782979struct retro_disk_control_callback2980{2981retro_set_eject_state_t set_eject_state;2982retro_get_eject_state_t get_eject_state;29832984retro_get_image_index_t get_image_index;2985retro_set_image_index_t set_image_index;2986retro_get_num_images_t get_num_images;29872988retro_replace_image_index_t replace_image_index;2989retro_add_image_index_t add_image_index;2990};29912992struct retro_disk_control_ext_callback2993{2994retro_set_eject_state_t set_eject_state;2995retro_get_eject_state_t get_eject_state;29962997retro_get_image_index_t get_image_index;2998retro_set_image_index_t set_image_index;2999retro_get_num_images_t get_num_images;30003001retro_replace_image_index_t replace_image_index;3002retro_add_image_index_t add_image_index;30033004/* NOTE: Frontend will only attempt to record/restore3005* last used disk index if both set_initial_image()3006* and get_image_path() are implemented */3007retro_set_initial_image_t set_initial_image; /* Optional - may be NULL */30083009retro_get_image_path_t get_image_path; /* Optional - may be NULL */3010retro_get_image_label_t get_image_label; /* Optional - may be NULL */3011};30123013enum retro_pixel_format3014{3015/* 0RGB1555, native endian.3016* 0 bit must be set to 0.3017* This pixel format is default for compatibility concerns only.3018* If a 15/16-bit pixel format is desired, consider using RGB565. */3019RETRO_PIXEL_FORMAT_0RGB1555 = 0,30203021/* XRGB8888, native endian.3022* X bits are ignored. */3023RETRO_PIXEL_FORMAT_XRGB8888 = 1,30243025/* RGB565, native endian.3026* This pixel format is the recommended format to use if a 15/16-bit3027* format is desired as it is the pixel format that is typically3028* available on a wide range of low-power devices.3029*3030* It is also natively supported in APIs like OpenGL ES. */3031RETRO_PIXEL_FORMAT_RGB565 = 2,30323033/* Ensure sizeof() == sizeof(int). */3034RETRO_PIXEL_FORMAT_UNKNOWN = INT_MAX3035};30363037enum retro_savestate_context3038{3039/* Standard savestate written to disk. */3040RETRO_SAVESTATE_CONTEXT_NORMAL = 0,30413042/* Savestate where you are guaranteed that the same instance will load the save state.3043* You can store internal pointers to code or data.3044* It's still a full serialization and deserialization, and could be loaded or saved at any time.3045* It won't be written to disk or sent over the network.3046*/3047RETRO_SAVESTATE_CONTEXT_RUNAHEAD_SAME_INSTANCE = 1,30483049/* Savestate where you are guaranteed that the same emulator binary will load that savestate.3050* You can skip anything that would slow down saving or loading state but you can not store internal pointers.3051* It won't be written to disk or sent over the network.3052* Example: "Second Instance" runahead3053*/3054RETRO_SAVESTATE_CONTEXT_RUNAHEAD_SAME_BINARY = 2,30553056/* Savestate used within a rollback netplay feature.3057* You should skip anything that would unnecessarily increase bandwidth usage.3058* It won't be written to disk but it will be sent over the network.3059*/3060RETRO_SAVESTATE_CONTEXT_ROLLBACK_NETPLAY = 3,30613062/* Ensure sizeof() == sizeof(int). */3063RETRO_SAVESTATE_CONTEXT_UNKNOWN = INT_MAX3064};30653066struct retro_message3067{3068const char *msg; /* Message to be displayed. */3069unsigned frames; /* Duration in frames of message. */3070};30713072enum retro_message_target3073{3074RETRO_MESSAGE_TARGET_ALL = 0,3075RETRO_MESSAGE_TARGET_OSD,3076RETRO_MESSAGE_TARGET_LOG3077};30783079enum retro_message_type3080{3081RETRO_MESSAGE_TYPE_NOTIFICATION = 0,3082RETRO_MESSAGE_TYPE_NOTIFICATION_ALT,3083RETRO_MESSAGE_TYPE_STATUS,3084RETRO_MESSAGE_TYPE_PROGRESS3085};30863087struct retro_message_ext3088{3089/* Message string to be displayed/logged */3090const char *msg;3091/* Duration (in ms) of message when targeting the OSD */3092unsigned duration;3093/* Message priority when targeting the OSD3094* > When multiple concurrent messages are sent to3095* the frontend and the frontend does not have the3096* capacity to display them all, messages with the3097* *highest* priority value should be shown3098* > There is no upper limit to a message priority3099* value (within the bounds of the unsigned data type)3100* > In the reference frontend (RetroArch), the same3101* priority values are used for frontend-generated3102* notifications, which are typically assigned values3103* between 0 and 3 depending upon importance */3104unsigned priority;3105/* Message logging level (info, warn, error, etc.) */3106enum retro_log_level level;3107/* Message destination: OSD, logging interface or both */3108enum retro_message_target target;3109/* Message 'type' when targeting the OSD3110* > RETRO_MESSAGE_TYPE_NOTIFICATION: Specifies that a3111* message should be handled in identical fashion to3112* a standard frontend-generated notification3113* > RETRO_MESSAGE_TYPE_NOTIFICATION_ALT: Specifies that3114* message is a notification that requires user attention3115* or action, but that it should be displayed in a manner3116* that differs from standard frontend-generated notifications.3117* This would typically correspond to messages that should be3118* displayed immediately (independently from any internal3119* frontend message queue), and/or which should be visually3120* distinguishable from frontend-generated notifications.3121* For example, a core may wish to inform the user of3122* information related to a disk-change event. It is3123* expected that the frontend itself may provide a3124* notification in this case; if the core sends a3125* message of type RETRO_MESSAGE_TYPE_NOTIFICATION, an3126* uncomfortable 'double-notification' may occur. A message3127* of RETRO_MESSAGE_TYPE_NOTIFICATION_ALT should therefore3128* be presented such that visual conflict with regular3129* notifications does not occur3130* > RETRO_MESSAGE_TYPE_STATUS: Indicates that message3131* is not a standard notification. This typically3132* corresponds to 'status' indicators, such as a core's3133* internal FPS, which are intended to be displayed3134* either permanently while a core is running, or in3135* a manner that does not suggest user attention or action3136* is required. 'Status' type messages should therefore be3137* displayed in a different on-screen location and in a manner3138* easily distinguishable from both standard frontend-generated3139* notifications and messages of type RETRO_MESSAGE_TYPE_NOTIFICATION_ALT3140* > RETRO_MESSAGE_TYPE_PROGRESS: Indicates that message reports3141* the progress of an internal core task. For example, in cases3142* where a core itself handles the loading of content from a file,3143* this may correspond to the percentage of the file that has been3144* read. Alternatively, an audio/video playback core may use a3145* message of type RETRO_MESSAGE_TYPE_PROGRESS to display the current3146* playback position as a percentage of the runtime. 'Progress' type3147* messages should therefore be displayed as a literal progress bar,3148* where:3149* - 'retro_message_ext.msg' is the progress bar title/label3150* - 'retro_message_ext.progress' determines the length of3151* the progress bar3152* NOTE: Message type is a *hint*, and may be ignored3153* by the frontend. If a frontend lacks support for3154* displaying messages via alternate means than standard3155* frontend-generated notifications, it will treat *all*3156* messages as having the type RETRO_MESSAGE_TYPE_NOTIFICATION */3157enum retro_message_type type;3158/* Task progress when targeting the OSD and message is3159* of type RETRO_MESSAGE_TYPE_PROGRESS3160* > -1: Unmetered/indeterminate3161* > 0-100: Current progress percentage3162* NOTE: Since message type is a hint, a frontend may ignore3163* progress values. Where relevant, a core should therefore3164* include progress percentage within the message string,3165* such that the message intent remains clear when displayed3166* as a standard frontend-generated notification */3167int8_t progress;3168};31693170/* Describes how the libretro implementation maps a libretro input bind3171* to its internal input system through a human readable string.3172* This string can be used to better let a user configure input. */3173struct retro_input_descriptor3174{3175/* Associates given parameters with a description. */3176unsigned port;3177unsigned device;3178unsigned index;3179unsigned id;31803181/* Human readable description for parameters.3182* The pointer must remain valid until3183* retro_unload_game() is called. */3184const char *description;3185};31863187struct retro_system_info3188{3189/* All pointers are owned by libretro implementation, and pointers must3190* remain valid until it is unloaded. */31913192const char *library_name; /* Descriptive name of library. Should not3193* contain any version numbers, etc. */3194const char *library_version; /* Descriptive version of core. */31953196const char *valid_extensions; /* A string listing probably content3197* extensions the core will be able to3198* load, separated with pipe.3199* I.e. "bin|rom|iso".3200* Typically used for a GUI to filter3201* out extensions. */32023203/* Libretro cores that need to have direct access to their content3204* files, including cores which use the path of the content files to3205* determine the paths of other files, should set need_fullpath to true.3206*3207* Cores should strive for setting need_fullpath to false,3208* as it allows the frontend to perform patching, etc.3209*3210* If need_fullpath is true and retro_load_game() is called:3211* - retro_game_info::path is guaranteed to have a valid path3212* - retro_game_info::data and retro_game_info::size are invalid3213*3214* If need_fullpath is false and retro_load_game() is called:3215* - retro_game_info::path may be NULL3216* - retro_game_info::data and retro_game_info::size are guaranteed3217* to be valid3218*3219* See also:3220* - RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY3221* - RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY3222*/3223bool need_fullpath;32243225/* If true, the frontend is not allowed to extract any archives before3226* loading the real content.3227* Necessary for certain libretro implementations that load games3228* from zipped archives. */3229bool block_extract;3230};32313232/* Defines overrides which modify frontend handling of3233* specific content file types.3234* An array of retro_system_content_info_override is3235* passed to RETRO_ENVIRONMENT_SET_CONTENT_INFO_OVERRIDE3236* NOTE: In the following descriptions, references to3237* retro_load_game() may be replaced with3238* retro_load_game_special() */3239struct retro_system_content_info_override3240{3241/* A list of file extensions for which the override3242* should apply, delimited by a 'pipe' character3243* (e.g. "md|sms|gg")3244* Permitted file extensions are limited to those3245* included in retro_system_info::valid_extensions3246* and/or retro_subsystem_rom_info::valid_extensions */3247const char *extensions;32483249/* Overrides the need_fullpath value set in3250* retro_system_info and/or retro_subsystem_rom_info.3251* To reiterate:3252*3253* If need_fullpath is true and retro_load_game() is called:3254* - retro_game_info::path is guaranteed to contain a valid3255* path to an existent file3256* - retro_game_info::data and retro_game_info::size are invalid3257*3258* If need_fullpath is false and retro_load_game() is called:3259* - retro_game_info::path may be NULL3260* - retro_game_info::data and retro_game_info::size are guaranteed3261* to be valid3262*3263* In addition:3264*3265* If need_fullpath is true and retro_load_game() is called:3266* - retro_game_info_ext::full_path is guaranteed to contain a valid3267* path to an existent file3268* - retro_game_info_ext::archive_path may be NULL3269* - retro_game_info_ext::archive_file may be NULL3270* - retro_game_info_ext::dir is guaranteed to contain a valid path3271* to the directory in which the content file exists3272* - retro_game_info_ext::name is guaranteed to contain the3273* basename of the content file, without extension3274* - retro_game_info_ext::ext is guaranteed to contain the3275* extension of the content file in lower case format3276* - retro_game_info_ext::data and retro_game_info_ext::size3277* are invalid3278*3279* If need_fullpath is false and retro_load_game() is called:3280* - If retro_game_info_ext::file_in_archive is false:3281* - retro_game_info_ext::full_path is guaranteed to contain3282* a valid path to an existent file3283* - retro_game_info_ext::archive_path may be NULL3284* - retro_game_info_ext::archive_file may be NULL3285* - retro_game_info_ext::dir is guaranteed to contain a3286* valid path to the directory in which the content file exists3287* - retro_game_info_ext::name is guaranteed to contain the3288* basename of the content file, without extension3289* - retro_game_info_ext::ext is guaranteed to contain the3290* extension of the content file in lower case format3291* - If retro_game_info_ext::file_in_archive is true:3292* - retro_game_info_ext::full_path may be NULL3293* - retro_game_info_ext::archive_path is guaranteed to3294* contain a valid path to an existent compressed file3295* inside which the content file is located3296* - retro_game_info_ext::archive_file is guaranteed to3297* contain a valid path to an existent content file3298* inside the compressed file referred to by3299* retro_game_info_ext::archive_path3300* e.g. for a compressed file '/path/to/foo.zip'3301* containing 'bar.sfc'3302* > retro_game_info_ext::archive_path will be '/path/to/foo.zip'3303* > retro_game_info_ext::archive_file will be 'bar.sfc'3304* - retro_game_info_ext::dir is guaranteed to contain a3305* valid path to the directory in which the compressed file3306* (containing the content file) exists3307* - retro_game_info_ext::name is guaranteed to contain3308* EITHER3309* 1) the basename of the compressed file (containing3310* the content file), without extension3311* OR3312* 2) the basename of the content file inside the3313* compressed file, without extension3314* In either case, a core should consider 'name' to3315* be the canonical name/ID of the the content file3316* - retro_game_info_ext::ext is guaranteed to contain the3317* extension of the content file inside the compressed file,3318* in lower case format3319* - retro_game_info_ext::data and retro_game_info_ext::size are3320* guaranteed to be valid */3321bool need_fullpath;33223323/* If need_fullpath is false, specifies whether the content3324* data buffer available in retro_load_game() is 'persistent'3325*3326* If persistent_data is false and retro_load_game() is called:3327* - retro_game_info::data and retro_game_info::size3328* are valid only until retro_load_game() returns3329* - retro_game_info_ext::data and retro_game_info_ext::size3330* are valid only until retro_load_game() returns3331*3332* If persistent_data is true and retro_load_game() is called:3333* - retro_game_info::data and retro_game_info::size3334* are valid until retro_deinit() returns3335* - retro_game_info_ext::data and retro_game_info_ext::size3336* are valid until retro_deinit() returns */3337bool persistent_data;3338};33393340/* Similar to retro_game_info, but provides extended3341* information about the source content file and3342* game memory buffer status.3343* And array of retro_game_info_ext is returned by3344* RETRO_ENVIRONMENT_GET_GAME_INFO_EXT3345* NOTE: In the following descriptions, references to3346* retro_load_game() may be replaced with3347* retro_load_game_special() */3348struct retro_game_info_ext3349{3350/* - If file_in_archive is false, contains a valid3351* path to an existent content file (UTF-8 encoded)3352* - If file_in_archive is true, may be NULL */3353const char *full_path;33543355/* - If file_in_archive is false, may be NULL3356* - If file_in_archive is true, contains a valid path3357* to an existent compressed file inside which the3358* content file is located (UTF-8 encoded) */3359const char *archive_path;33603361/* - If file_in_archive is false, may be NULL3362* - If file_in_archive is true, contain a valid path3363* to an existent content file inside the compressed3364* file referred to by archive_path (UTF-8 encoded)3365* e.g. for a compressed file '/path/to/foo.zip'3366* containing 'bar.sfc'3367* > archive_path will be '/path/to/foo.zip'3368* > archive_file will be 'bar.sfc' */3369const char *archive_file;33703371/* - If file_in_archive is false, contains a valid path3372* to the directory in which the content file exists3373* (UTF-8 encoded)3374* - If file_in_archive is true, contains a valid path3375* to the directory in which the compressed file3376* (containing the content file) exists (UTF-8 encoded) */3377const char *dir;33783379/* Contains the canonical name/ID of the content file3380* (UTF-8 encoded). Intended for use when identifying3381* 'complementary' content named after the loaded file -3382* i.e. companion data of a different format (a CD image3383* required by a ROM), texture packs, internally handled3384* save files, etc.3385* - If file_in_archive is false, contains the basename3386* of the content file, without extension3387* - If file_in_archive is true, then string is3388* implementation specific. A frontend may choose to3389* set a name value of:3390* EITHER3391* 1) the basename of the compressed file (containing3392* the content file), without extension3393* OR3394* 2) the basename of the content file inside the3395* compressed file, without extension3396* RetroArch sets the 'name' value according to (1).3397* A frontend that supports routine loading of3398* content from archives containing multiple unrelated3399* content files may set the 'name' value according3400* to (2). */3401const char *name;34023403/* - If file_in_archive is false, contains the extension3404* of the content file in lower case format3405* - If file_in_archive is true, contains the extension3406* of the content file inside the compressed file,3407* in lower case format */3408const char *ext;34093410/* String of implementation specific meta-data. */3411const char *meta;34123413/* Memory buffer of loaded game content. Will be NULL:3414* IF3415* - retro_system_info::need_fullpath is true and3416* retro_system_content_info_override::need_fullpath3417* is unset3418* OR3419* - retro_system_content_info_override::need_fullpath3420* is true */3421const void *data;34223423/* Size of game content memory buffer, in bytes */3424size_t size;34253426/* True if loaded content file is inside a compressed3427* archive */3428bool file_in_archive;34293430/* - If data is NULL, value is unset/ignored3431* - If data is non-NULL:3432* - If persistent_data is false, data and size are3433* valid only until retro_load_game() returns3434* - If persistent_data is true, data and size are3435* are valid until retro_deinit() returns */3436bool persistent_data;3437};34383439struct retro_game_geometry3440{3441unsigned base_width; /* Nominal video width of game. */3442unsigned base_height; /* Nominal video height of game. */3443unsigned max_width; /* Maximum possible width of game. */3444unsigned max_height; /* Maximum possible height of game. */34453446float aspect_ratio; /* Nominal aspect ratio of game. If3447* aspect_ratio is <= 0.0, an aspect ratio3448* of base_width / base_height is assumed.3449* A frontend could override this setting,3450* if desired. */3451};34523453struct retro_system_timing3454{3455double fps; /* FPS of video content. */3456double sample_rate; /* Sampling rate of audio. */3457};34583459struct retro_system_av_info3460{3461struct retro_game_geometry geometry;3462struct retro_system_timing timing;3463};34643465struct retro_variable3466{3467/* Variable to query in RETRO_ENVIRONMENT_GET_VARIABLE.3468* If NULL, obtains the complete environment string if more3469* complex parsing is necessary.3470* The environment string is formatted as key-value pairs3471* delimited by semicolons as so:3472* "key1=value1;key2=value2;..."3473*/3474const char *key;34753476/* Value to be obtained. If key does not exist, it is set to NULL. */3477const char *value;3478};34793480struct retro_core_option_display3481{3482/* Variable to configure in RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY */3483const char *key;34843485/* Specifies whether variable should be displayed3486* when presenting core options to the user */3487bool visible;3488};34893490/* Maximum number of values permitted for a core option3491* > Note: We have to set a maximum value due the limitations3492* of the C language - i.e. it is not possible to create an3493* array of structs each containing a variable sized array,3494* so the retro_core_option_definition values array must3495* have a fixed size. The size limit of 128 is a balancing3496* act - it needs to be large enough to support all 'sane'3497* core options, but setting it too large may impact low memory3498* platforms. In practise, if a core option has more than3499* 128 values then the implementation is likely flawed.3500* To quote the above API reference:3501* "The number of possible options should be very limited3502* i.e. it should be feasible to cycle through options3503* without a keyboard."3504*/3505#define RETRO_NUM_CORE_OPTION_VALUES_MAX 12835063507struct retro_core_option_value3508{3509/* Expected option value */3510const char *value;35113512/* Human-readable value label. If NULL, value itself3513* will be displayed by the frontend */3514const char *label;3515};35163517struct retro_core_option_definition3518{3519/* Variable to query in RETRO_ENVIRONMENT_GET_VARIABLE. */3520const char *key;35213522/* Human-readable core option description (used as menu label) */3523const char *desc;35243525/* Human-readable core option information (used as menu sublabel) */3526const char *info;35273528/* Array of retro_core_option_value structs, terminated by NULL */3529struct retro_core_option_value values[RETRO_NUM_CORE_OPTION_VALUES_MAX];35303531/* Default core option value. Must match one of the values3532* in the retro_core_option_value array, otherwise will be3533* ignored */3534const char *default_value;3535};35363537#ifdef __PS3__3538#undef local3539#endif35403541struct retro_core_options_intl3542{3543/* Pointer to an array of retro_core_option_definition structs3544* - US English implementation3545* - Must point to a valid array */3546struct retro_core_option_definition *us;35473548/* Pointer to an array of retro_core_option_definition structs3549* - Implementation for current frontend language3550* - May be NULL */3551struct retro_core_option_definition *local;3552};35533554struct retro_core_option_v2_category3555{3556/* Variable uniquely identifying the3557* option category. Valid key characters3558* are [a-z, A-Z, 0-9, _, -] */3559const char *key;35603561/* Human-readable category description3562* > Used as category menu label when3563* frontend has core option category3564* support */3565const char *desc;35663567/* Human-readable category information3568* > Used as category menu sublabel when3569* frontend has core option category3570* support3571* > Optional (may be NULL or an empty3572* string) */3573const char *info;3574};35753576struct retro_core_option_v2_definition3577{3578/* Variable to query in RETRO_ENVIRONMENT_GET_VARIABLE.3579* Valid key characters are [a-z, A-Z, 0-9, _, -] */3580const char *key;35813582/* Human-readable core option description3583* > Used as menu label when frontend does3584* not have core option category support3585* e.g. "Video > Aspect Ratio" */3586const char *desc;35873588/* Human-readable core option description3589* > Used as menu label when frontend has3590* core option category support3591* e.g. "Aspect Ratio", where associated3592* retro_core_option_v2_category::desc3593* is "Video"3594* > If empty or NULL, the string specified by3595* desc will be used as the menu label3596* > Will be ignored (and may be set to NULL)3597* if category_key is empty or NULL */3598const char *desc_categorized;35993600/* Human-readable core option information3601* > Used as menu sublabel */3602const char *info;36033604/* Human-readable core option information3605* > Used as menu sublabel when frontend3606* has core option category support3607* (e.g. may be required when info text3608* references an option by name/desc,3609* and the desc/desc_categorized text3610* for that option differ)3611* > If empty or NULL, the string specified by3612* info will be used as the menu sublabel3613* > Will be ignored (and may be set to NULL)3614* if category_key is empty or NULL */3615const char *info_categorized;36163617/* Variable specifying category (e.g. "video",3618* "audio") that will be assigned to the option3619* if frontend has core option category support.3620* > Categorized options will be displayed in a3621* subsection/submenu of the frontend core3622* option interface3623* > Specified string must match one of the3624* retro_core_option_v2_category::key values3625* in the associated retro_core_option_v2_category3626* array; If no match is not found, specified3627* string will be considered as NULL3628* > If specified string is empty or NULL, option will3629* have no category and will be shown at the top3630* level of the frontend core option interface */3631const char *category_key;36323633/* Array of retro_core_option_value structs, terminated by NULL */3634struct retro_core_option_value values[RETRO_NUM_CORE_OPTION_VALUES_MAX];36353636/* Default core option value. Must match one of the values3637* in the retro_core_option_value array, otherwise will be3638* ignored */3639const char *default_value;3640};36413642struct retro_core_options_v23643{3644/* Array of retro_core_option_v2_category structs,3645* terminated by NULL3646* > If NULL, all entries in definitions array3647* will have no category and will be shown at3648* the top level of the frontend core option3649* interface3650* > Will be ignored if frontend does not have3651* core option category support */3652struct retro_core_option_v2_category *categories;36533654/* Array of retro_core_option_v2_definition structs,3655* terminated by NULL */3656struct retro_core_option_v2_definition *definitions;3657};36583659struct retro_core_options_v2_intl3660{3661/* Pointer to a retro_core_options_v2 struct3662* > US English implementation3663* > Must point to a valid struct */3664struct retro_core_options_v2 *us;36653666/* Pointer to a retro_core_options_v2 struct3667* - Implementation for current frontend language3668* - May be NULL */3669struct retro_core_options_v2 *local;3670};36713672/* Used by the frontend to monitor changes in core option3673* visibility. May be called each time any core option3674* value is set via the frontend.3675* - On each invocation, the core must update the visibility3676* of any dynamically hidden options using the3677* RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY environment3678* callback.3679* - On the first invocation, returns 'true' if the visibility3680* of any core option has changed since the last call of3681* retro_load_game() or retro_load_game_special().3682* - On each subsequent invocation, returns 'true' if the3683* visibility of any core option has changed since the last3684* time the function was called. */3685typedef bool (RETRO_CALLCONV *retro_core_options_update_display_callback_t)(void);3686struct retro_core_options_update_display_callback3687{3688retro_core_options_update_display_callback_t callback;3689};36903691struct retro_game_info3692{3693const char *path; /* Path to game, UTF-8 encoded.3694* Sometimes used as a reference for building other paths.3695* May be NULL if game was loaded from stdin or similar,3696* but in this case some cores will be unable to load `data`.3697* So, it is preferable to fabricate something here instead3698* of passing NULL, which will help more cores to succeed.3699* retro_system_info::need_fullpath requires3700* that this path is valid. */3701const void *data; /* Memory buffer of loaded game. Will be NULL3702* if need_fullpath was set. */3703size_t size; /* Size of memory buffer. */3704const char *meta; /* String of implementation specific meta-data. */3705};37063707#define RETRO_MEMORY_ACCESS_WRITE (1 << 0)3708/* The core will write to the buffer provided by retro_framebuffer::data. */3709#define RETRO_MEMORY_ACCESS_READ (1 << 1)3710/* The core will read from retro_framebuffer::data. */3711#define RETRO_MEMORY_TYPE_CACHED (1 << 0)3712/* The memory in data is cached.3713* If not cached, random writes and/or reading from the buffer is expected to be very slow. */3714struct retro_framebuffer3715{3716void *data; /* The framebuffer which the core can render into.3717Set by frontend in GET_CURRENT_SOFTWARE_FRAMEBUFFER.3718The initial contents of data are unspecified. */3719unsigned width; /* The framebuffer width used by the core. Set by core. */3720unsigned height; /* The framebuffer height used by the core. Set by core. */3721size_t pitch; /* The number of bytes between the beginning of a scanline,3722and beginning of the next scanline.3723Set by frontend in GET_CURRENT_SOFTWARE_FRAMEBUFFER. */3724enum retro_pixel_format format; /* The pixel format the core must use to render into data.3725This format could differ from the format used in3726SET_PIXEL_FORMAT.3727Set by frontend in GET_CURRENT_SOFTWARE_FRAMEBUFFER. */37283729unsigned access_flags; /* How the core will access the memory in the framebuffer.3730RETRO_MEMORY_ACCESS_* flags.3731Set by core. */3732unsigned memory_flags; /* Flags telling core how the memory has been mapped.3733RETRO_MEMORY_TYPE_* flags.3734Set by frontend in GET_CURRENT_SOFTWARE_FRAMEBUFFER. */3735};37363737/* Used by a libretro core to override the current3738* fastforwarding mode of the frontend */3739struct retro_fastforwarding_override3740{3741/* Specifies the runtime speed multiplier that3742* will be applied when 'fastforward' is true.3743* For example, a value of 5.0 when running 60 FPS3744* content will cap the fast-forward rate at 300 FPS.3745* Note that the target multiplier may not be achieved3746* if the host hardware has insufficient processing3747* power.3748* Setting a value of 0.0 (or greater than 0.0 but3749* less than 1.0) will result in an uncapped3750* fast-forward rate (limited only by hardware3751* capacity).3752* If the value is negative, it will be ignored3753* (i.e. the frontend will use a runtime speed3754* multiplier of its own choosing) */3755float ratio;37563757/* If true, fastforwarding mode will be enabled.3758* If false, fastforwarding mode will be disabled. */3759bool fastforward;37603761/* If true, and if supported by the frontend, an3762* on-screen notification will be displayed while3763* 'fastforward' is true.3764* If false, and if supported by the frontend, any3765* on-screen fast-forward notifications will be3766* suppressed */3767bool notification;37683769/* If true, the core will have sole control over3770* when fastforwarding mode is enabled/disabled;3771* the frontend will not be able to change the3772* state set by 'fastforward' until either3773* 'inhibit_toggle' is set to false, or the core3774* is unloaded */3775bool inhibit_toggle;3776};37773778/* During normal operation. Rate will be equal to the core's internal FPS. */3779#define RETRO_THROTTLE_NONE 037803781/* While paused or stepping single frames. Rate will be 0. */3782#define RETRO_THROTTLE_FRAME_STEPPING 137833784/* During fast forwarding.3785* Rate will be 0 if not specifically limited to a maximum speed. */3786#define RETRO_THROTTLE_FAST_FORWARD 237873788/* During slow motion. Rate will be less than the core's internal FPS. */3789#define RETRO_THROTTLE_SLOW_MOTION 337903791/* While rewinding recorded save states. Rate can vary depending on the rewind3792* speed or be 0 if the frontend is not aiming for a specific rate. */3793#define RETRO_THROTTLE_REWINDING 437943795/* While vsync is active in the video driver and the target refresh rate is3796* lower than the core's internal FPS. Rate is the target refresh rate. */3797#define RETRO_THROTTLE_VSYNC 537983799/* When the frontend does not throttle in any way. Rate will be 0.3800* An example could be if no vsync or audio output is active. */3801#define RETRO_THROTTLE_UNBLOCKED 638023803struct retro_throttle_state3804{3805/* The current throttling mode. Should be one of the values above. */3806unsigned mode;38073808/* How many times per second the frontend aims to call retro_run.3809* Depending on the mode, it can be 0 if there is no known fixed rate.3810* This won't be accurate if the total processing time of the core and3811* the frontend is longer than what is available for one frame. */3812float rate;3813};38143815/* Callbacks */38163817/* Environment callback. Gives implementations a way of performing3818* uncommon tasks. Extensible. */3819typedef bool (RETRO_CALLCONV *retro_environment_t)(unsigned cmd, void *data);38203821/* Render a frame. Pixel format is 15-bit 0RGB1555 native endian3822* unless changed (see RETRO_ENVIRONMENT_SET_PIXEL_FORMAT).3823*3824* Width and height specify dimensions of buffer.3825* Pitch specifices length in bytes between two lines in buffer.3826*3827* For performance reasons, it is highly recommended to have a frame3828* that is packed in memory, i.e. pitch == width * byte_per_pixel.3829* Certain graphic APIs, such as OpenGL ES, do not like textures3830* that are not packed in memory.3831*/3832typedef void (RETRO_CALLCONV *retro_video_refresh_t)(const void *data, unsigned width,3833unsigned height, size_t pitch);38343835/* Renders a single audio frame. Should only be used if implementation3836* generates a single sample at a time.3837* Format is signed 16-bit native endian.3838*/3839typedef void (RETRO_CALLCONV *retro_audio_sample_t)(int16_t left, int16_t right);38403841/* Renders multiple audio frames in one go.3842*3843* One frame is defined as a sample of left and right channels, interleaved.3844* I.e. int16_t buf[4] = { l, r, l, r }; would be 2 frames.3845* Only one of the audio callbacks must ever be used.3846*/3847typedef size_t (RETRO_CALLCONV *retro_audio_sample_batch_t)(const int16_t *data,3848size_t frames);38493850/* Polls input. */3851typedef void (RETRO_CALLCONV *retro_input_poll_t)(void);38523853/* Queries for input for player 'port'. device will be masked with3854* RETRO_DEVICE_MASK.3855*3856* Specialization of devices such as RETRO_DEVICE_JOYPAD_MULTITAP that3857* have been set with retro_set_controller_port_device()3858* will still use the higher level RETRO_DEVICE_JOYPAD to request input.3859*/3860typedef int16_t (RETRO_CALLCONV *retro_input_state_t)(unsigned port, unsigned device,3861unsigned index, unsigned id);38623863/* Sets callbacks. retro_set_environment() is guaranteed to be called3864* before retro_init().3865*3866* The rest of the set_* functions are guaranteed to have been called3867* before the first call to retro_run() is made. */3868RETRO_API void retro_set_environment(retro_environment_t);3869RETRO_API void retro_set_video_refresh(retro_video_refresh_t);3870RETRO_API void retro_set_audio_sample(retro_audio_sample_t);3871RETRO_API void retro_set_audio_sample_batch(retro_audio_sample_batch_t);3872RETRO_API void retro_set_input_poll(retro_input_poll_t);3873RETRO_API void retro_set_input_state(retro_input_state_t);38743875/* Library global initialization/deinitialization. */3876RETRO_API void retro_init(void);3877RETRO_API void retro_deinit(void);38783879/* Must return RETRO_API_VERSION. Used to validate ABI compatibility3880* when the API is revised. */3881RETRO_API unsigned retro_api_version(void);38823883/* Gets statically known system info. Pointers provided in *info3884* must be statically allocated.3885* Can be called at any time, even before retro_init(). */3886RETRO_API void retro_get_system_info(struct retro_system_info *info);38873888/* Gets information about system audio/video timings and geometry.3889* Can be called only after retro_load_game() has successfully completed.3890* NOTE: The implementation of this function might not initialize every3891* variable if needed.3892* E.g. geom.aspect_ratio might not be initialized if core doesn't3893* desire a particular aspect ratio. */3894RETRO_API void retro_get_system_av_info(struct retro_system_av_info *info);38953896/* Sets device to be used for player 'port'.3897* By default, RETRO_DEVICE_JOYPAD is assumed to be plugged into all3898* available ports.3899* Setting a particular device type is not a guarantee that libretro cores3900* will only poll input based on that particular device type. It is only a3901* hint to the libretro core when a core cannot automatically detect the3902* appropriate input device type on its own. It is also relevant when a3903* core can change its behavior depending on device type.3904*3905* As part of the core's implementation of retro_set_controller_port_device,3906* the core should call RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS to notify the3907* frontend if the descriptions for any controls have changed as a3908* result of changing the device type.3909*/3910RETRO_API void retro_set_controller_port_device(unsigned port, unsigned device);39113912/* Resets the current game. */3913RETRO_API void retro_reset(void);39143915/* Runs the game for one video frame.3916* During retro_run(), input_poll callback must be called at least once.3917*3918* If a frame is not rendered for reasons where a game "dropped" a frame,3919* this still counts as a frame, and retro_run() should explicitly dupe3920* a frame if GET_CAN_DUPE returns true.3921* In this case, the video callback can take a NULL argument for data.3922*/3923RETRO_API void retro_run(void);39243925/* Returns the amount of data the implementation requires to serialize3926* internal state (save states).3927* Between calls to retro_load_game() and retro_unload_game(), the3928* returned size is never allowed to be larger than a previous returned3929* value, to ensure that the frontend can allocate a save state buffer once.3930*/3931RETRO_API size_t retro_serialize_size(void);39323933/* Serializes internal state. If failed, or size is lower than3934* retro_serialize_size(), it should return false, true otherwise. */3935RETRO_API bool retro_serialize(void *data, size_t size);3936RETRO_API bool retro_unserialize(const void *data, size_t size);39373938RETRO_API void retro_cheat_reset(void);3939RETRO_API void retro_cheat_set(unsigned index, bool enabled, const char *code);39403941/* Loads a game.3942* Return true to indicate successful loading and false to indicate load failure.3943*/3944RETRO_API bool retro_load_game(const struct retro_game_info *game);39453946/* Loads a "special" kind of game. Should not be used,3947* except in extreme cases. */3948RETRO_API bool retro_load_game_special(3949unsigned game_type,3950const struct retro_game_info *info, size_t num_info3951);39523953/* Unloads the currently loaded game. Called before retro_deinit(void). */3954RETRO_API void retro_unload_game(void);39553956/* Gets region of game. */3957RETRO_API unsigned retro_get_region(void);39583959/* Gets region of memory. */3960RETRO_API void *retro_get_memory_data(unsigned id);3961RETRO_API size_t retro_get_memory_size(unsigned id);39623963#ifdef __cplusplus3964}3965#endif39663967#endif396839693970