plugins: Fix build of unai/neon
[pcsx_rearmed.git] / libretro-common / include / libretro.h
CommitLineData
8a60e610 1/* Copyright (C) 2010-2020 The RetroArch team
779692e4 2 *
3 * ---------------------------------------------------------------------------------------
4 * The following license statement only applies to this libretro API header (libretro.h).
5 * ---------------------------------------------------------------------------------------
6 *
7 * Permission is hereby granted, free of charge,
8 * to any person obtaining a copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation the rights to
10 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
11 * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
16 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 */
22
38c2028e 23#ifndef LIBRETRO_H__
24#define LIBRETRO_H__
25
26#include <stdint.h>
27#include <stddef.h>
c19aba43 28#include <limits.h>
38c2028e 29
30#ifdef __cplusplus
31extern "C" {
eae1ae02
A
32#endif
33
34#ifndef __cplusplus
6fbd15c8 35#if defined(_MSC_VER) && _MSC_VER < 1800 && !defined(SN_TARGET_PS3)
eae1ae02
A
36/* Hack applied for MSVC when compiling in C89 mode
37 * as it isn't C99-compliant. */
38c2028e 38#define bool unsigned char
39#define true 1
40#define false 0
41#else
42#include <stdbool.h>
43#endif
44#endif
45
65a0505f
FJGG
46#ifndef RETRO_CALLCONV
47# if defined(__GNUC__) && defined(__i386__) && !defined(__x86_64__)
48# define RETRO_CALLCONV __attribute__((cdecl))
49# elif defined(_MSC_VER) && defined(_M_X86) && !defined(_M_X64)
50# define RETRO_CALLCONV __cdecl
51# else
52# define RETRO_CALLCONV /* all other platforms only have one calling convention each */
53# endif
54#endif
55
56#ifndef RETRO_API
57# if defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__)
58# ifdef RETRO_IMPORT_SYMBOLS
59# ifdef __GNUC__
60# define RETRO_API RETRO_CALLCONV __attribute__((__dllimport__))
61# else
62# define RETRO_API RETRO_CALLCONV __declspec(dllimport)
63# endif
64# else
65# ifdef __GNUC__
66# define RETRO_API RETRO_CALLCONV __attribute__((__dllexport__))
67# else
68# define RETRO_API RETRO_CALLCONV __declspec(dllexport)
69# endif
70# endif
71# else
e007af22 72# if defined(__GNUC__) && __GNUC__ >= 4
65a0505f
FJGG
73# define RETRO_API RETRO_CALLCONV __attribute__((__visibility__("default")))
74# else
75# define RETRO_API RETRO_CALLCONV
76# endif
77# endif
78#endif
79
6fbd15c8 80/* Used for checking API/ABI mismatches that can break libretro
eae1ae02
A
81 * implementations.
82 * It is not incremented for compatible changes to the API.
83 */
38c2028e 84#define RETRO_API_VERSION 1
85
eae1ae02
A
86/*
87 * Libretro's fundamental device abstractions.
88 *
89 * Libretro's input system consists of some standardized device types,
6fbd15c8 90 * such as a joypad (with/without analog), mouse, keyboard, lightgun
eae1ae02
A
91 * and a pointer.
92 *
6fbd15c8 93 * The functionality of these devices are fixed, and individual cores
eae1ae02 94 * map their own concept of a controller to libretro's abstractions.
6fbd15c8 95 * This makes it possible for frontends to map the abstract types to a
96 * real input device, and not having to worry about binding input
eae1ae02
A
97 * correctly to arbitrary controller layouts.
98 */
99
100#define RETRO_DEVICE_TYPE_SHIFT 8
101#define RETRO_DEVICE_MASK ((1 << RETRO_DEVICE_TYPE_SHIFT) - 1)
102#define RETRO_DEVICE_SUBCLASS(base, id) (((id + 1) << RETRO_DEVICE_TYPE_SHIFT) | base)
103
104/* Input disabled. */
38c2028e 105#define RETRO_DEVICE_NONE 0
c19aba43 106
6fbd15c8 107/* The JOYPAD is called RetroPad. It is essentially a Super Nintendo
108 * controller, but with additional L2/R2/L3/R3 buttons, similar to a
eae1ae02 109 * PS1 DualShock. */
38c2028e 110#define RETRO_DEVICE_JOYPAD 1
c19aba43 111
eae1ae02
A
112/* The mouse is a simple mouse, similar to Super Nintendo's mouse.
113 * X and Y coordinates are reported relatively to last poll (poll callback).
6fbd15c8 114 * It is up to the libretro implementation to keep track of where the mouse
eae1ae02 115 * pointer is supposed to be on the screen.
6fbd15c8 116 * The frontend must make sure not to interfere with its own hardware
eae1ae02
A
117 * mouse pointer.
118 */
38c2028e 119#define RETRO_DEVICE_MOUSE 2
c19aba43 120
eae1ae02 121/* KEYBOARD device lets one poll for raw key pressed.
6fbd15c8 122 * It is poll based, so input callback will return with the current
eae1ae02
A
123 * pressed state.
124 * For event/text based keyboard input, see
125 * RETRO_ENVIRONMENT_SET_KEYBOARD_CALLBACK.
126 */
38c2028e 127#define RETRO_DEVICE_KEYBOARD 3
c19aba43 128
6fbd15c8 129/* LIGHTGUN device is similar to Guncon-2 for PlayStation 2.
130 * It reports X/Y coordinates in screen space (similar to the pointer)
131 * in the range [-0x8000, 0x7fff] in both axes, with zero being center and
132 * -0x8000 being out of bounds.
133 * As well as reporting on/off screen state. It features a trigger,
134 * start/select buttons, auxiliary action buttons and a
135 * directional pad. A forced off-screen shot can be requested for
136 * auto-reloading function in some games.
137 */
38c2028e 138#define RETRO_DEVICE_LIGHTGUN 4
c19aba43 139
eae1ae02 140/* The ANALOG device is an extension to JOYPAD (RetroPad).
6fbd15c8 141 * Similar to DualShock2 it adds two analog sticks and all buttons can
142 * be analog. This is treated as a separate device type as it returns
143 * axis values in the full analog range of [-0x7fff, 0x7fff],
144 * although some devices may return -0x8000.
145 * Positive X axis is right. Positive Y axis is down.
146 * Buttons are returned in the range [0, 0x7fff].
147 * Only use ANALOG type when polling for analog values.
eae1ae02 148 */
38c2028e 149#define RETRO_DEVICE_ANALOG 5
150
eae1ae02 151/* Abstracts the concept of a pointing mechanism, e.g. touch.
6fbd15c8 152 * This allows libretro to query in absolute coordinates where on the
eae1ae02
A
153 * screen a mouse (or something similar) is being placed.
154 * For a touch centric device, coordinates reported are the coordinates
155 * of the press.
156 *
157 * Coordinates in X and Y are reported as:
158 * [-0x7fff, 0x7fff]: -0x7fff corresponds to the far left/top of the screen,
159 * and 0x7fff corresponds to the far right/bottom of the screen.
6fbd15c8 160 * The "screen" is here defined as area that is passed to the frontend and
eae1ae02
A
161 * later displayed on the monitor.
162 *
163 * The frontend is free to scale/resize this screen as it sees fit, however,
6fbd15c8 164 * (X, Y) = (-0x7fff, -0x7fff) will correspond to the top-left pixel of the
eae1ae02
A
165 * game image, etc.
166 *
6fbd15c8 167 * To check if the pointer coordinates are valid (e.g. a touch display
eae1ae02
A
168 * actually being touched), PRESSED returns 1 or 0.
169 *
6fbd15c8 170 * If using a mouse on a desktop, PRESSED will usually correspond to the
eae1ae02
A
171 * left mouse button, but this is a frontend decision.
172 * PRESSED will only return 1 if the pointer is inside the game screen.
173 *
6fbd15c8 174 * For multi-touch, the index variable can be used to successively query
eae1ae02
A
175 * more presses.
176 * If index = 0 returns true for _PRESSED, coordinates can be extracted
6fbd15c8 177 * with _X, _Y for index = 0. One can then query _PRESSED, _X, _Y with
eae1ae02 178 * index = 1, and so on.
6fbd15c8 179 * Eventually _PRESSED will return false for an index. No further presses
eae1ae02 180 * are registered at this point. */
23ea11bd 181#define RETRO_DEVICE_POINTER 6
182
eae1ae02 183/* Buttons for the RetroPad (JOYPAD).
6fbd15c8 184 * The placement of these is equivalent to placements on the
eae1ae02 185 * Super Nintendo controller.
6fbd15c8 186 * L2/R2/L3/R3 buttons correspond to the PS1 DualShock.
187 * Also used as id values for RETRO_DEVICE_INDEX_ANALOG_BUTTON */
38c2028e 188#define RETRO_DEVICE_ID_JOYPAD_B 0
189#define RETRO_DEVICE_ID_JOYPAD_Y 1
190#define RETRO_DEVICE_ID_JOYPAD_SELECT 2
191#define RETRO_DEVICE_ID_JOYPAD_START 3
192#define RETRO_DEVICE_ID_JOYPAD_UP 4
193#define RETRO_DEVICE_ID_JOYPAD_DOWN 5
194#define RETRO_DEVICE_ID_JOYPAD_LEFT 6
195#define RETRO_DEVICE_ID_JOYPAD_RIGHT 7
196#define RETRO_DEVICE_ID_JOYPAD_A 8
197#define RETRO_DEVICE_ID_JOYPAD_X 9
198#define RETRO_DEVICE_ID_JOYPAD_L 10
199#define RETRO_DEVICE_ID_JOYPAD_R 11
200#define RETRO_DEVICE_ID_JOYPAD_L2 12
201#define RETRO_DEVICE_ID_JOYPAD_R2 13
202#define RETRO_DEVICE_ID_JOYPAD_L3 14
203#define RETRO_DEVICE_ID_JOYPAD_R3 15
204
6fbd15c8 205#define RETRO_DEVICE_ID_JOYPAD_MASK 256
206
eae1ae02 207/* Index / Id values for ANALOG device. */
6fbd15c8 208#define RETRO_DEVICE_INDEX_ANALOG_LEFT 0
209#define RETRO_DEVICE_INDEX_ANALOG_RIGHT 1
210#define RETRO_DEVICE_INDEX_ANALOG_BUTTON 2
211#define RETRO_DEVICE_ID_ANALOG_X 0
212#define RETRO_DEVICE_ID_ANALOG_Y 1
38c2028e 213
eae1ae02 214/* Id values for MOUSE. */
65a0505f
FJGG
215#define RETRO_DEVICE_ID_MOUSE_X 0
216#define RETRO_DEVICE_ID_MOUSE_Y 1
217#define RETRO_DEVICE_ID_MOUSE_LEFT 2
218#define RETRO_DEVICE_ID_MOUSE_RIGHT 3
219#define RETRO_DEVICE_ID_MOUSE_WHEELUP 4
220#define RETRO_DEVICE_ID_MOUSE_WHEELDOWN 5
221#define RETRO_DEVICE_ID_MOUSE_MIDDLE 6
222#define RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELUP 7
223#define RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELDOWN 8
6fbd15c8 224#define RETRO_DEVICE_ID_MOUSE_BUTTON_4 9
225#define RETRO_DEVICE_ID_MOUSE_BUTTON_5 10
226
227/* Id values for LIGHTGUN. */
228#define RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X 13 /*Absolute Position*/
229#define RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y 14 /*Absolute*/
230#define RETRO_DEVICE_ID_LIGHTGUN_IS_OFFSCREEN 15 /*Status Check*/
231#define RETRO_DEVICE_ID_LIGHTGUN_TRIGGER 2
232#define RETRO_DEVICE_ID_LIGHTGUN_RELOAD 16 /*Forced off-screen shot*/
233#define RETRO_DEVICE_ID_LIGHTGUN_AUX_A 3
234#define RETRO_DEVICE_ID_LIGHTGUN_AUX_B 4
235#define RETRO_DEVICE_ID_LIGHTGUN_START 6
236#define RETRO_DEVICE_ID_LIGHTGUN_SELECT 7
237#define RETRO_DEVICE_ID_LIGHTGUN_AUX_C 8
238#define RETRO_DEVICE_ID_LIGHTGUN_DPAD_UP 9
239#define RETRO_DEVICE_ID_LIGHTGUN_DPAD_DOWN 10
240#define RETRO_DEVICE_ID_LIGHTGUN_DPAD_LEFT 11
241#define RETRO_DEVICE_ID_LIGHTGUN_DPAD_RIGHT 12
242/* deprecated */
243#define RETRO_DEVICE_ID_LIGHTGUN_X 0 /*Relative Position*/
244#define RETRO_DEVICE_ID_LIGHTGUN_Y 1 /*Relative*/
245#define RETRO_DEVICE_ID_LIGHTGUN_CURSOR 3 /*Use Aux:A*/
246#define RETRO_DEVICE_ID_LIGHTGUN_TURBO 4 /*Use Aux:B*/
247#define RETRO_DEVICE_ID_LIGHTGUN_PAUSE 5 /*Use Start*/
38c2028e 248
eae1ae02 249/* Id values for POINTER. */
23ea11bd 250#define RETRO_DEVICE_ID_POINTER_X 0
251#define RETRO_DEVICE_ID_POINTER_Y 1
252#define RETRO_DEVICE_ID_POINTER_PRESSED 2
6fbd15c8 253#define RETRO_DEVICE_ID_POINTER_COUNT 3
23ea11bd 254
eae1ae02 255/* Returned from retro_get_region(). */
38c2028e 256#define RETRO_REGION_NTSC 0
257#define RETRO_REGION_PAL 1
258
eae1ae02
A
259/* Id values for LANGUAGE */
260enum retro_language
261{
6fbd15c8 262 RETRO_LANGUAGE_ENGLISH = 0,
263 RETRO_LANGUAGE_JAPANESE = 1,
264 RETRO_LANGUAGE_FRENCH = 2,
265 RETRO_LANGUAGE_SPANISH = 3,
266 RETRO_LANGUAGE_GERMAN = 4,
267 RETRO_LANGUAGE_ITALIAN = 5,
268 RETRO_LANGUAGE_DUTCH = 6,
269 RETRO_LANGUAGE_PORTUGUESE_BRAZIL = 7,
270 RETRO_LANGUAGE_PORTUGUESE_PORTUGAL = 8,
271 RETRO_LANGUAGE_RUSSIAN = 9,
272 RETRO_LANGUAGE_KOREAN = 10,
273 RETRO_LANGUAGE_CHINESE_TRADITIONAL = 11,
274 RETRO_LANGUAGE_CHINESE_SIMPLIFIED = 12,
275 RETRO_LANGUAGE_ESPERANTO = 13,
276 RETRO_LANGUAGE_POLISH = 14,
277 RETRO_LANGUAGE_VIETNAMESE = 15,
278 RETRO_LANGUAGE_ARABIC = 16,
279 RETRO_LANGUAGE_GREEK = 17,
280 RETRO_LANGUAGE_TURKISH = 18,
8a60e610 281 RETRO_LANGUAGE_SLOVAK = 19,
270c6dd1 282 RETRO_LANGUAGE_PERSIAN = 20,
283 RETRO_LANGUAGE_HEBREW = 21,
284 RETRO_LANGUAGE_ASTURIAN = 22,
285 RETRO_LANGUAGE_FINNISH = 23,
f3c6ae10 286 RETRO_LANGUAGE_INDONESIAN = 24,
287 RETRO_LANGUAGE_SWEDISH = 25,
288 RETRO_LANGUAGE_UKRAINIAN = 26,
289 RETRO_LANGUAGE_CZECH = 27,
290 RETRO_LANGUAGE_CATALAN_VALENCIA = 28,
291 RETRO_LANGUAGE_CATALAN = 29,
eae1ae02
A
292 RETRO_LANGUAGE_LAST,
293
294 /* Ensure sizeof(enum) == sizeof(int) */
6fbd15c8 295 RETRO_LANGUAGE_DUMMY = INT_MAX
eae1ae02
A
296};
297
298/* Passed to retro_get_memory_data/size().
6fbd15c8 299 * If the memory type doesn't apply to the
eae1ae02
A
300 * implementation NULL/0 can be returned.
301 */
38c2028e 302#define RETRO_MEMORY_MASK 0xff
c19aba43 303
eae1ae02
A
304/* Regular save RAM. This RAM is usually found on a game cartridge,
305 * backed up by a battery.
306 * If save game data is too complex for a single memory buffer,
307 * the SAVE_DIRECTORY (preferably) or SYSTEM_DIRECTORY environment
308 * callback can be used. */
38c2028e 309#define RETRO_MEMORY_SAVE_RAM 0
c19aba43 310
eae1ae02
A
311/* Some games have a built-in clock to keep track of time.
312 * This memory is usually just a couple of bytes to keep track of time.
313 */
38c2028e 314#define RETRO_MEMORY_RTC 1
c19aba43 315
eae1ae02 316/* System ram lets a frontend peek into a game systems main RAM. */
38c2028e 317#define RETRO_MEMORY_SYSTEM_RAM 2
c19aba43 318
eae1ae02 319/* Video ram lets a frontend peek into a game systems video RAM (VRAM). */
38c2028e 320#define RETRO_MEMORY_VIDEO_RAM 3
321
eae1ae02 322/* Keysyms used for ID in input state callback when polling RETRO_KEYBOARD. */
c19aba43
TK
323enum retro_key
324{
325 RETROK_UNKNOWN = 0,
326 RETROK_FIRST = 0,
327 RETROK_BACKSPACE = 8,
328 RETROK_TAB = 9,
329 RETROK_CLEAR = 12,
330 RETROK_RETURN = 13,
331 RETROK_PAUSE = 19,
332 RETROK_ESCAPE = 27,
333 RETROK_SPACE = 32,
334 RETROK_EXCLAIM = 33,
335 RETROK_QUOTEDBL = 34,
336 RETROK_HASH = 35,
337 RETROK_DOLLAR = 36,
338 RETROK_AMPERSAND = 38,
339 RETROK_QUOTE = 39,
340 RETROK_LEFTPAREN = 40,
341 RETROK_RIGHTPAREN = 41,
342 RETROK_ASTERISK = 42,
343 RETROK_PLUS = 43,
344 RETROK_COMMA = 44,
345 RETROK_MINUS = 45,
346 RETROK_PERIOD = 46,
347 RETROK_SLASH = 47,
348 RETROK_0 = 48,
349 RETROK_1 = 49,
350 RETROK_2 = 50,
351 RETROK_3 = 51,
352 RETROK_4 = 52,
353 RETROK_5 = 53,
354 RETROK_6 = 54,
355 RETROK_7 = 55,
356 RETROK_8 = 56,
357 RETROK_9 = 57,
358 RETROK_COLON = 58,
359 RETROK_SEMICOLON = 59,
360 RETROK_LESS = 60,
361 RETROK_EQUALS = 61,
362 RETROK_GREATER = 62,
363 RETROK_QUESTION = 63,
364 RETROK_AT = 64,
365 RETROK_LEFTBRACKET = 91,
366 RETROK_BACKSLASH = 92,
367 RETROK_RIGHTBRACKET = 93,
368 RETROK_CARET = 94,
369 RETROK_UNDERSCORE = 95,
370 RETROK_BACKQUOTE = 96,
371 RETROK_a = 97,
372 RETROK_b = 98,
373 RETROK_c = 99,
374 RETROK_d = 100,
375 RETROK_e = 101,
376 RETROK_f = 102,
377 RETROK_g = 103,
378 RETROK_h = 104,
379 RETROK_i = 105,
380 RETROK_j = 106,
381 RETROK_k = 107,
382 RETROK_l = 108,
383 RETROK_m = 109,
384 RETROK_n = 110,
385 RETROK_o = 111,
386 RETROK_p = 112,
387 RETROK_q = 113,
388 RETROK_r = 114,
389 RETROK_s = 115,
390 RETROK_t = 116,
391 RETROK_u = 117,
392 RETROK_v = 118,
393 RETROK_w = 119,
394 RETROK_x = 120,
395 RETROK_y = 121,
396 RETROK_z = 122,
6fbd15c8 397 RETROK_LEFTBRACE = 123,
398 RETROK_BAR = 124,
399 RETROK_RIGHTBRACE = 125,
400 RETROK_TILDE = 126,
c19aba43
TK
401 RETROK_DELETE = 127,
402
403 RETROK_KP0 = 256,
404 RETROK_KP1 = 257,
405 RETROK_KP2 = 258,
406 RETROK_KP3 = 259,
407 RETROK_KP4 = 260,
408 RETROK_KP5 = 261,
409 RETROK_KP6 = 262,
410 RETROK_KP7 = 263,
411 RETROK_KP8 = 264,
412 RETROK_KP9 = 265,
413 RETROK_KP_PERIOD = 266,
414 RETROK_KP_DIVIDE = 267,
415 RETROK_KP_MULTIPLY = 268,
416 RETROK_KP_MINUS = 269,
417 RETROK_KP_PLUS = 270,
418 RETROK_KP_ENTER = 271,
419 RETROK_KP_EQUALS = 272,
420
421 RETROK_UP = 273,
422 RETROK_DOWN = 274,
423 RETROK_RIGHT = 275,
424 RETROK_LEFT = 276,
425 RETROK_INSERT = 277,
426 RETROK_HOME = 278,
427 RETROK_END = 279,
428 RETROK_PAGEUP = 280,
429 RETROK_PAGEDOWN = 281,
430
431 RETROK_F1 = 282,
432 RETROK_F2 = 283,
433 RETROK_F3 = 284,
434 RETROK_F4 = 285,
435 RETROK_F5 = 286,
436 RETROK_F6 = 287,
437 RETROK_F7 = 288,
438 RETROK_F8 = 289,
439 RETROK_F9 = 290,
440 RETROK_F10 = 291,
441 RETROK_F11 = 292,
442 RETROK_F12 = 293,
443 RETROK_F13 = 294,
444 RETROK_F14 = 295,
445 RETROK_F15 = 296,
446
447 RETROK_NUMLOCK = 300,
448 RETROK_CAPSLOCK = 301,
449 RETROK_SCROLLOCK = 302,
450 RETROK_RSHIFT = 303,
451 RETROK_LSHIFT = 304,
452 RETROK_RCTRL = 305,
453 RETROK_LCTRL = 306,
454 RETROK_RALT = 307,
455 RETROK_LALT = 308,
456 RETROK_RMETA = 309,
457 RETROK_LMETA = 310,
458 RETROK_LSUPER = 311,
459 RETROK_RSUPER = 312,
460 RETROK_MODE = 313,
461 RETROK_COMPOSE = 314,
462
463 RETROK_HELP = 315,
464 RETROK_PRINT = 316,
465 RETROK_SYSREQ = 317,
466 RETROK_BREAK = 318,
467 RETROK_MENU = 319,
468 RETROK_POWER = 320,
469 RETROK_EURO = 321,
470 RETROK_UNDO = 322,
6fbd15c8 471 RETROK_OEM_102 = 323,
c19aba43 472
23ea11bd 473 RETROK_LAST,
474
eae1ae02 475 RETROK_DUMMY = INT_MAX /* Ensure sizeof(enum) == sizeof(int) */
23ea11bd 476};
477
478enum retro_mod
479{
480 RETROKMOD_NONE = 0x0000,
481
482 RETROKMOD_SHIFT = 0x01,
483 RETROKMOD_CTRL = 0x02,
484 RETROKMOD_ALT = 0x04,
485 RETROKMOD_META = 0x08,
486
487 RETROKMOD_NUMLOCK = 0x10,
488 RETROKMOD_CAPSLOCK = 0x20,
489 RETROKMOD_SCROLLOCK = 0x40,
490
eae1ae02 491 RETROKMOD_DUMMY = INT_MAX /* Ensure sizeof(enum) == sizeof(int) */
c19aba43 492};
38c2028e 493
6fbd15c8 494/* If set, this call is not part of the public libretro API yet. It can
eae1ae02 495 * change or be removed at any time. */
e56b1300 496#define RETRO_ENVIRONMENT_EXPERIMENTAL 0x10000
eae1ae02 497/* Environment callback to be used internally in frontend. */
779692e4 498#define RETRO_ENVIRONMENT_PRIVATE 0x20000
23ea11bd 499
eae1ae02
A
500/* Environment commands. */
501#define RETRO_ENVIRONMENT_SET_ROTATION 1 /* const unsigned * --
502 * Sets screen rotation of graphics.
6fbd15c8 503 * Valid values are 0, 1, 2, 3, which rotates screen by 0, 90, 180,
eae1ae02
A
504 * 270 degrees counter-clockwise respectively.
505 */
506#define RETRO_ENVIRONMENT_GET_OVERSCAN 2 /* bool * --
6fbd15c8 507 * NOTE: As of 2019 this callback is considered deprecated in favor of
508 * using core options to manage overscan in a more nuanced, core-specific way.
509 *
510 * Boolean value whether or not the implementation should use overscan,
eae1ae02
A
511 * or crop away overscan.
512 */
513#define RETRO_ENVIRONMENT_GET_CAN_DUPE 3 /* bool * --
514 * Boolean value whether or not frontend supports frame duping,
515 * passing NULL to video frame callback.
516 */
517
6fbd15c8 518 /* Environ 4, 5 are no longer supported (GET_VARIABLE / SET_VARIABLES),
eae1ae02
A
519 * and reserved to avoid possible ABI clash.
520 */
521
522#define RETRO_ENVIRONMENT_SET_MESSAGE 6 /* const struct retro_message * --
6fbd15c8 523 * Sets a message to be displayed in implementation-specific manner
eae1ae02 524 * for a certain amount of 'frames'.
6fbd15c8 525 * Should not be used for trivial messages, which should simply be
526 * logged via RETRO_ENVIRONMENT_GET_LOG_INTERFACE (or as a
eae1ae02
A
527 * fallback, stderr).
528 */
529#define RETRO_ENVIRONMENT_SHUTDOWN 7 /* N/A (NULL) --
530 * Requests the frontend to shutdown.
531 * Should only be used if game has a specific
532 * way to shutdown the game from a menu item or similar.
533 */
38c2028e 534#define RETRO_ENVIRONMENT_SET_PERFORMANCE_LEVEL 8
eae1ae02
A
535 /* const unsigned * --
536 * Gives a hint to the frontend how demanding this implementation
537 * is on a system. E.g. reporting a level of 2 means
538 * this implementation should run decently on all frontends
539 * of level 2 and up.
540 *
541 * It can be used by the frontend to potentially warn
542 * about too demanding implementations.
543 *
544 * The levels are "floating".
545 *
546 * This function can be called on a per-game basis,
547 * as certain games an implementation can play might be
548 * particularly demanding.
549 * If called, it should be called in retro_load_game().
550 */
38c2028e 551#define RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY 9
eae1ae02
A
552 /* const char ** --
553 * Returns the "system" directory of the frontend.
6fbd15c8 554 * This directory can be used to store system specific
eae1ae02
A
555 * content such as BIOSes, configuration data, etc.
556 * The returned value can be NULL.
557 * If so, no such directory is defined,
558 * and it's up to the implementation to find a suitable directory.
559 *
6fbd15c8 560 * NOTE: Some cores used this folder also for "save" data such as
eae1ae02 561 * memory cards, etc, for lack of a better place to put it.
6fbd15c8 562 * This is now discouraged, and if possible, cores should try to
eae1ae02
A
563 * use the new GET_SAVE_DIRECTORY.
564 */
38c2028e 565#define RETRO_ENVIRONMENT_SET_PIXEL_FORMAT 10
eae1ae02
A
566 /* const enum retro_pixel_format * --
567 * Sets the internal pixel format used by the implementation.
568 * The default pixel format is RETRO_PIXEL_FORMAT_0RGB1555.
569 * This pixel format however, is deprecated (see enum retro_pixel_format).
6fbd15c8 570 * If the call returns false, the frontend does not support this pixel
eae1ae02
A
571 * format.
572 *
6fbd15c8 573 * This function should be called inside retro_load_game() or
eae1ae02
A
574 * retro_get_system_av_info().
575 */
c19aba43 576#define RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS 11
eae1ae02
A
577 /* const struct retro_input_descriptor * --
578 * Sets an array of retro_input_descriptors.
579 * It is up to the frontend to present this in a usable way.
6fbd15c8 580 * The array is terminated by retro_input_descriptor::description
eae1ae02 581 * being set to NULL.
6fbd15c8 582 * This function can be called at any time, but it is recommended
eae1ae02
A
583 * to call it as early as possible.
584 */
23ea11bd 585#define RETRO_ENVIRONMENT_SET_KEYBOARD_CALLBACK 12
eae1ae02
A
586 /* const struct retro_keyboard_callback * --
587 * Sets a callback function used to notify core about keyboard events.
588 */
23ea11bd 589#define RETRO_ENVIRONMENT_SET_DISK_CONTROL_INTERFACE 13
eae1ae02 590 /* const struct retro_disk_control_callback * --
6fbd15c8 591 * Sets an interface which frontend can use to eject and insert
eae1ae02 592 * disk images.
6fbd15c8 593 * This is used for games which consist of multiple images and
eae1ae02
A
594 * must be manually swapped out by the user (e.g. PSX).
595 */
779692e4 596#define RETRO_ENVIRONMENT_SET_HW_RENDER 14
eae1ae02 597 /* struct retro_hw_render_callback * --
6fbd15c8 598 * Sets an interface to let a libretro core render with
eae1ae02
A
599 * hardware acceleration.
600 * Should be called in retro_load_game().
6fbd15c8 601 * If successful, libretro cores will be able to render to a
eae1ae02 602 * frontend-provided framebuffer.
6fbd15c8 603 * The size of this framebuffer will be at least as large as
eae1ae02 604 * max_width/max_height provided in get_av_info().
6fbd15c8 605 * If HW rendering is used, pass only RETRO_HW_FRAME_BUFFER_VALID or
eae1ae02
A
606 * NULL to retro_video_refresh_t.
607 */
e56b1300 608#define RETRO_ENVIRONMENT_GET_VARIABLE 15
eae1ae02
A
609 /* struct retro_variable * --
610 * Interface to acquire user-defined information from environment
611 * that cannot feasibly be supported in a multi-system way.
6fbd15c8 612 * 'key' should be set to a key which has already been set by
eae1ae02
A
613 * SET_VARIABLES.
614 * 'data' will be set to a value or NULL.
615 */
e56b1300 616#define RETRO_ENVIRONMENT_SET_VARIABLES 16
eae1ae02
A
617 /* const struct retro_variable * --
618 * Allows an implementation to signal the environment
6fbd15c8 619 * which variables it might want to check for later using
eae1ae02 620 * GET_VARIABLE.
6fbd15c8 621 * This allows the frontend to present these variables to
eae1ae02 622 * a user dynamically.
6fbd15c8 623 * This should be called the first time as early as
624 * possible (ideally in retro_set_environment).
625 * Afterward it may be called again for the core to communicate
626 * updated options to the frontend, but the number of core
627 * options must not change from the number in the initial call.
919cac88 628 *
6fbd15c8 629 * 'data' points to an array of retro_variable structs
eae1ae02 630 * terminated by a { NULL, NULL } element.
6fbd15c8 631 * retro_variable::key should be namespaced to not collide
632 * with other implementations' keys. E.g. A core called
eae1ae02 633 * 'foo' should use keys named as 'foo_option'.
6fbd15c8 634 * retro_variable::value should contain a human readable
635 * description of the key as well as a '|' delimited list
eae1ae02
A
636 * of expected values.
637 *
6fbd15c8 638 * The number of possible options should be very limited,
639 * i.e. it should be feasible to cycle through options
eae1ae02
A
640 * without a keyboard.
641 *
642 * First entry should be treated as a default.
643 *
644 * Example entry:
645 * { "foo_option", "Speed hack coprocessor X; false|true" }
646 *
6fbd15c8 647 * Text before first ';' is description. This ';' must be
648 * followed by a space, and followed by a list of possible
eae1ae02
A
649 * values split up with '|'.
650 *
6fbd15c8 651 * Only strings are operated on. The possible values will
eae1ae02
A
652 * generally be displayed and stored as-is by the frontend.
653 */
e56b1300 654#define RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE 17
eae1ae02
A
655 /* bool * --
656 * Result is set to true if some variables are updated by
657 * frontend since last call to RETRO_ENVIRONMENT_GET_VARIABLE.
658 * Variables should be queried with GET_VARIABLE.
659 */
6b5beb44 660#define RETRO_ENVIRONMENT_SET_SUPPORT_NO_GAME 18
eae1ae02 661 /* const bool * --
6fbd15c8 662 * If true, the libretro implementation supports calls to
eae1ae02
A
663 * retro_load_game() with NULL as argument.
664 * Used by cores which can run without particular game data.
665 * This should be called within retro_set_environment() only.
666 */
779692e4 667#define RETRO_ENVIRONMENT_GET_LIBRETRO_PATH 19
eae1ae02 668 /* const char ** --
6fbd15c8 669 * Retrieves the absolute path from where this libretro
eae1ae02 670 * implementation was loaded.
6fbd15c8 671 * NULL is returned if the libretro was loaded statically
672 * (i.e. linked statically to frontend), or if the path cannot be
eae1ae02 673 * determined.
6fbd15c8 674 * Mostly useful in cooperation with SET_SUPPORT_NO_GAME as assets can
eae1ae02
A
675 * be loaded without ugly hacks.
676 */
6fbd15c8 677
678 /* Environment 20 was an obsolete version of SET_AUDIO_CALLBACK.
eae1ae02
A
679 * It was not used by any known core at the time,
680 * and was removed from the API. */
6fbd15c8 681#define RETRO_ENVIRONMENT_SET_FRAME_TIME_CALLBACK 21
682 /* const struct retro_frame_time_callback * --
683 * Lets the core know how much time has passed since last
684 * invocation of retro_run().
685 * The frontend can tamper with the timing to fake fast-forward,
686 * slow-motion, frame stepping, etc.
687 * In this case the delta time will use the reference value
688 * in frame_time_callback..
689 */
779692e4 690#define RETRO_ENVIRONMENT_SET_AUDIO_CALLBACK 22
eae1ae02 691 /* const struct retro_audio_callback * --
6fbd15c8 692 * Sets an interface which is used to notify a libretro core about audio
eae1ae02 693 * being available for writing.
6fbd15c8 694 * The callback can be called from any thread, so a core using this must
eae1ae02 695 * have a thread safe audio implementation.
6fbd15c8 696 * It is intended for games where audio and video are completely
eae1ae02 697 * asynchronous and audio can be generated on the fly.
6fbd15c8 698 * This interface is not recommended for use with emulators which have
eae1ae02
A
699 * highly synchronous audio.
700 *
6fbd15c8 701 * The callback only notifies about writability; the libretro core still
eae1ae02 702 * has to call the normal audio callbacks
6fbd15c8 703 * to write audio. The audio callbacks must be called from within the
eae1ae02
A
704 * notification callback.
705 * The amount of audio data to write is up to the implementation.
706 * Generally, the audio callback will be called continously in a loop.
707 *
6fbd15c8 708 * Due to thread safety guarantees and lack of sync between audio and
709 * video, a frontend can selectively disallow this interface based on
710 * internal configuration. A core using this interface must also
eae1ae02
A
711 * implement the "normal" audio interface.
712 *
6fbd15c8 713 * A libretro core using SET_AUDIO_CALLBACK should also make use of
eae1ae02
A
714 * SET_FRAME_TIME_CALLBACK.
715 */
779692e4 716#define RETRO_ENVIRONMENT_GET_RUMBLE_INTERFACE 23
eae1ae02 717 /* struct retro_rumble_interface * --
6fbd15c8 718 * Gets an interface which is used by a libretro core to set
eae1ae02 719 * state of rumble motors in controllers.
6fbd15c8 720 * A strong and weak motor is supported, and they can be
eae1ae02 721 * controlled indepedently.
270c6dd1 722 * Should be called from either retro_init() or retro_load_game().
723 * Should not be called from retro_set_environment().
724 * Returns false if rumble functionality is unavailable.
eae1ae02 725 */
779692e4 726#define RETRO_ENVIRONMENT_GET_INPUT_DEVICE_CAPABILITIES 24
eae1ae02 727 /* uint64_t * --
6fbd15c8 728 * Gets a bitmask telling which device type are expected to be
eae1ae02 729 * handled properly in a call to retro_input_state_t.
6fbd15c8 730 * Devices which are not handled or recognized always return
eae1ae02
A
731 * 0 in retro_input_state_t.
732 * Example bitmask: caps = (1 << RETRO_DEVICE_JOYPAD) | (1 << RETRO_DEVICE_ANALOG).
733 * Should only be called in retro_run().
734 */
779692e4 735#define RETRO_ENVIRONMENT_GET_SENSOR_INTERFACE (25 | RETRO_ENVIRONMENT_EXPERIMENTAL)
eae1ae02
A
736 /* struct retro_sensor_interface * --
737 * Gets access to the sensor interface.
738 * The purpose of this interface is to allow
6fbd15c8 739 * setting state related to sensors such as polling rate,
eae1ae02 740 * enabling/disable it entirely, etc.
6fbd15c8 741 * Reading sensor state is done via the normal
eae1ae02
A
742 * input_state_callback API.
743 */
779692e4 744#define RETRO_ENVIRONMENT_GET_CAMERA_INTERFACE (26 | RETRO_ENVIRONMENT_EXPERIMENTAL)
eae1ae02
A
745 /* struct retro_camera_callback * --
746 * Gets an interface to a video camera driver.
6fbd15c8 747 * A libretro core can use this interface to get access to a
eae1ae02 748 * video camera.
6fbd15c8 749 * New video frames are delivered in a callback in same
eae1ae02
A
750 * thread as retro_run().
751 *
752 * GET_CAMERA_INTERFACE should be called in retro_load_game().
753 *
6fbd15c8 754 * Depending on the camera implementation used, camera frames
eae1ae02
A
755 * will be delivered as a raw framebuffer,
756 * or as an OpenGL texture directly.
757 *
6fbd15c8 758 * The core has to tell the frontend here which types of
eae1ae02 759 * buffers can be handled properly.
6fbd15c8 760 * An OpenGL texture can only be handled when using a
eae1ae02 761 * libretro GL core (SET_HW_RENDER).
6fbd15c8 762 * It is recommended to use a libretro GL core when
eae1ae02
A
763 * using camera interface.
764 *
6fbd15c8 765 * The camera is not started automatically. The retrieved start/stop
eae1ae02
A
766 * functions must be used to explicitly
767 * start and stop the camera driver.
768 */
779692e4 769#define RETRO_ENVIRONMENT_GET_LOG_INTERFACE 27
eae1ae02 770 /* struct retro_log_callback * --
6fbd15c8 771 * Gets an interface for logging. This is useful for
eae1ae02 772 * logging in a cross-platform way
6fbd15c8 773 * as certain platforms cannot use stderr for logging.
eae1ae02
A
774 * It also allows the frontend to
775 * show logging information in a more suitable way.
6fbd15c8 776 * If this interface is not used, libretro cores should
eae1ae02
A
777 * log to stderr as desired.
778 */
779692e4 779#define RETRO_ENVIRONMENT_GET_PERF_INTERFACE 28
eae1ae02 780 /* struct retro_perf_callback * --
6fbd15c8 781 * Gets an interface for performance counters. This is useful
782 * for performance logging in a cross-platform way and for detecting
eae1ae02
A
783 * architecture-specific features, such as SIMD support.
784 */
785#define RETRO_ENVIRONMENT_GET_LOCATION_INTERFACE 29
786 /* struct retro_location_callback * --
787 * Gets access to the location interface.
6fbd15c8 788 * The purpose of this interface is to be able to retrieve
eae1ae02
A
789 * location-based information from the host device,
790 * such as current latitude / longitude.
791 */
65a0505f
FJGG
792#define RETRO_ENVIRONMENT_GET_CONTENT_DIRECTORY 30 /* Old name, kept for compatibility. */
793#define RETRO_ENVIRONMENT_GET_CORE_ASSETS_DIRECTORY 30
eae1ae02 794 /* const char ** --
65a0505f 795 * Returns the "core assets" directory of the frontend.
6fbd15c8 796 * This directory can be used to store specific assets that the
eae1ae02
A
797 * core relies upon, such as art assets,
798 * input data, etc etc.
799 * The returned value can be NULL.
800 * If so, no such directory is defined,
801 * and it's up to the implementation to find a suitable directory.
802 */
803#define RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY 31
804 /* const char ** --
6fbd15c8 805 * Returns the "save" directory of the frontend, unless there is no
806 * save directory available. The save directory should be used to
807 * store SRAM, memory cards, high scores, etc, if the libretro core
eae1ae02
A
808 * cannot use the regular memory interface (retro_get_memory_data()).
809 *
6fbd15c8 810 * If the frontend cannot designate a save directory, it will return
811 * NULL to indicate that the core should attempt to operate without a
812 * save directory set.
813 *
814 * NOTE: early libretro cores used the system directory for save
815 * files. Cores that need to be backwards-compatible can still check
816 * GET_SYSTEM_DIRECTORY.
eae1ae02
A
817 */
818#define RETRO_ENVIRONMENT_SET_SYSTEM_AV_INFO 32
819 /* const struct retro_system_av_info * --
6fbd15c8 820 * Sets a new av_info structure. This can only be called from
eae1ae02 821 * within retro_run().
6fbd15c8 822 * This should *only* be used if the core is completely altering the
eae1ae02 823 * internal resolutions, aspect ratios, timings, sampling rate, etc.
6fbd15c8 824 * Calling this can require a full reinitialization of video/audio
eae1ae02
A
825 * drivers in the frontend,
826 *
6fbd15c8 827 * so it is important to call it very sparingly, and usually only with
eae1ae02 828 * the users explicit consent.
6fbd15c8 829 * An eventual driver reinitialize will happen so that video and
eae1ae02 830 * audio callbacks
6fbd15c8 831 * happening after this call within the same retro_run() call will
eae1ae02
A
832 * target the newly initialized driver.
833 *
6fbd15c8 834 * This callback makes it possible to support configurable resolutions
eae1ae02
A
835 * in games, which can be useful to
836 * avoid setting the "worst case" in max_width/max_height.
837 *
6fbd15c8 838 * ***HIGHLY RECOMMENDED*** Do not call this callback every time
eae1ae02 839 * resolution changes in an emulator core if it's
6fbd15c8 840 * expected to be a temporary change, for the reasons of possible
eae1ae02 841 * driver reinitialization.
6fbd15c8 842 * This call is not a free pass for not trying to provide
843 * correct values in retro_get_system_av_info(). If you need to change
844 * things like aspect ratio or nominal width/height,
845 * use RETRO_ENVIRONMENT_SET_GEOMETRY, which is a softer variant
eae1ae02
A
846 * of SET_SYSTEM_AV_INFO.
847 *
6fbd15c8 848 * If this returns false, the frontend does not acknowledge a
eae1ae02
A
849 * changed av_info struct.
850 */
851#define RETRO_ENVIRONMENT_SET_PROC_ADDRESS_CALLBACK 33
852 /* const struct retro_get_proc_address_interface * --
6fbd15c8 853 * Allows a libretro core to announce support for the
eae1ae02 854 * get_proc_address() interface.
6fbd15c8 855 * This interface allows for a standard way to extend libretro where
eae1ae02
A
856 * use of environment calls are too indirect,
857 * e.g. for cases where the frontend wants to call directly into the core.
858 *
6fbd15c8 859 * If a core wants to expose this interface, SET_PROC_ADDRESS_CALLBACK
eae1ae02
A
860 * **MUST** be called from within retro_set_environment().
861 */
862#define RETRO_ENVIRONMENT_SET_SUBSYSTEM_INFO 34
863 /* const struct retro_subsystem_info * --
864 * This environment call introduces the concept of libretro "subsystems".
6fbd15c8 865 * A subsystem is a variant of a libretro core which supports
eae1ae02 866 * different kinds of games.
6fbd15c8 867 * The purpose of this is to support e.g. emulators which might
eae1ae02 868 * have special needs, e.g. Super Nintendo's Super GameBoy, Sufami Turbo.
6fbd15c8 869 * It can also be used to pick among subsystems in an explicit way
eae1ae02
A
870 * if the libretro implementation is a multi-system emulator itself.
871 *
872 * Loading a game via a subsystem is done with retro_load_game_special(),
6fbd15c8 873 * and this environment call allows a libretro core to expose which
eae1ae02 874 * subsystems are supported for use with retro_load_game_special().
6fbd15c8 875 * A core passes an array of retro_game_special_info which is terminated
eae1ae02
A
876 * with a zeroed out retro_game_special_info struct.
877 *
878 * If a core wants to use this functionality, SET_SUBSYSTEM_INFO
879 * **MUST** be called from within retro_set_environment().
880 */
881#define RETRO_ENVIRONMENT_SET_CONTROLLER_INFO 35
882 /* const struct retro_controller_info * --
6fbd15c8 883 * This environment call lets a libretro core tell the frontend
884 * which controller subclasses are recognized in calls to
eae1ae02
A
885 * retro_set_controller_port_device().
886 *
6fbd15c8 887 * Some emulators such as Super Nintendo support multiple lightgun
888 * types which must be specifically selected from. It is therefore
889 * sometimes necessary for a frontend to be able to tell the core
890 * about a special kind of input device which is not specifcally
891 * provided by the Libretro API.
eae1ae02 892 *
6fbd15c8 893 * In order for a frontend to understand the workings of those devices,
894 * they must be defined as a specialized subclass of the generic device
895 * types already defined in the libretro API.
eae1ae02 896 *
6fbd15c8 897 * The core must pass an array of const struct retro_controller_info which
898 * is terminated with a blanked out struct. Each element of the
899 * retro_controller_info struct corresponds to the ascending port index
900 * that is passed to retro_set_controller_port_device() when that function
901 * is called to indicate to the core that the frontend has changed the
902 * active device subclass. SEE ALSO: retro_set_controller_port_device()
903 *
904 * The ascending input port indexes provided by the core in the struct
905 * are generally presented by frontends as ascending User # or Player #,
906 * such as Player 1, Player 2, Player 3, etc. Which device subclasses are
907 * supported can vary per input port.
908 *
909 * The first inner element of each entry in the retro_controller_info array
910 * is a retro_controller_description struct that specifies the names and
911 * codes of all device subclasses that are available for the corresponding
912 * User or Player, beginning with the generic Libretro device that the
913 * subclasses are derived from. The second inner element of each entry is the
914 * total number of subclasses that are listed in the retro_controller_description.
915 *
916 * NOTE: Even if special device types are set in the libretro core,
eae1ae02
A
917 * libretro should only poll input based on the base input device types.
918 */
919#define RETRO_ENVIRONMENT_SET_MEMORY_MAPS (36 | RETRO_ENVIRONMENT_EXPERIMENTAL)
920 /* const struct retro_memory_map * --
6fbd15c8 921 * This environment call lets a libretro core tell the frontend
eae1ae02
A
922 * about the memory maps this core emulates.
923 * This can be used to implement, for example, cheats in a core-agnostic way.
924 *
6fbd15c8 925 * Should only be used by emulators; it doesn't make much sense for
eae1ae02 926 * anything else.
6fbd15c8 927 * It is recommended to expose all relevant pointers through
eae1ae02
A
928 * retro_get_memory_* as well.
929 *
930 * Can be called from retro_init and retro_load_game.
931 */
932#define RETRO_ENVIRONMENT_SET_GEOMETRY 37
933 /* const struct retro_game_geometry * --
6fbd15c8 934 * This environment call is similar to SET_SYSTEM_AV_INFO for changing
935 * video parameters, but provides a guarantee that drivers will not be
eae1ae02
A
936 * reinitialized.
937 * This can only be called from within retro_run().
938 *
6fbd15c8 939 * The purpose of this call is to allow a core to alter nominal
940 * width/heights as well as aspect ratios on-the-fly, which can be
eae1ae02
A
941 * useful for some emulators to change in run-time.
942 *
943 * max_width/max_height arguments are ignored and cannot be changed
6fbd15c8 944 * with this call as this could potentially require a reinitialization or a
eae1ae02
A
945 * non-constant time operation.
946 * If max_width/max_height are to be changed, SET_SYSTEM_AV_INFO is required.
947 *
6fbd15c8 948 * A frontend must guarantee that this environment call completes in
eae1ae02
A
949 * constant time.
950 */
6fbd15c8 951#define RETRO_ENVIRONMENT_GET_USERNAME 38
eae1ae02
A
952 /* const char **
953 * Returns the specified username of the frontend, if specified by the user.
6fbd15c8 954 * This username can be used as a nickname for a core that has online facilities
eae1ae02
A
955 * or any other mode where personalization of the user is desirable.
956 * The returned value can be NULL.
6fbd15c8 957 * If this environ callback is used by a core that requires a valid username,
eae1ae02
A
958 * a default username should be specified by the core.
959 */
960#define RETRO_ENVIRONMENT_GET_LANGUAGE 39
961 /* unsigned * --
962 * Returns the specified language of the frontend, if specified by the user.
963 * It can be used by the core for localization purposes.
964 */
65a0505f
FJGG
965#define RETRO_ENVIRONMENT_GET_CURRENT_SOFTWARE_FRAMEBUFFER (40 | RETRO_ENVIRONMENT_EXPERIMENTAL)
966 /* struct retro_framebuffer * --
967 * Returns a preallocated framebuffer which the core can use for rendering
968 * the frame into when not using SET_HW_RENDER.
969 * The framebuffer returned from this call must not be used
970 * after the current call to retro_run() returns.
971 *
972 * The goal of this call is to allow zero-copy behavior where a core
973 * can render directly into video memory, avoiding extra bandwidth cost by copying
974 * memory from core to video memory.
975 *
976 * If this call succeeds and the core renders into it,
977 * the framebuffer pointer and pitch can be passed to retro_video_refresh_t.
978 * If the buffer from GET_CURRENT_SOFTWARE_FRAMEBUFFER is to be used,
979 * the core must pass the exact
980 * same pointer as returned by GET_CURRENT_SOFTWARE_FRAMEBUFFER;
981 * i.e. passing a pointer which is offset from the
982 * buffer is undefined. The width, height and pitch parameters
983 * must also match exactly to the values obtained from GET_CURRENT_SOFTWARE_FRAMEBUFFER.
984 *
985 * It is possible for a frontend to return a different pixel format
986 * than the one used in SET_PIXEL_FORMAT. This can happen if the frontend
987 * needs to perform conversion.
988 *
989 * It is still valid for a core to render to a different buffer
990 * even if GET_CURRENT_SOFTWARE_FRAMEBUFFER succeeds.
991 *
992 * A frontend must make sure that the pointer obtained from this function is
993 * writeable (and readable).
994 */
6fbd15c8 995#define RETRO_ENVIRONMENT_GET_HW_RENDER_INTERFACE (41 | RETRO_ENVIRONMENT_EXPERIMENTAL)
996 /* const struct retro_hw_render_interface ** --
997 * Returns an API specific rendering interface for accessing API specific data.
998 * Not all HW rendering APIs support or need this.
999 * The contents of the returned pointer is specific to the rendering API
1000 * being used. See the various headers like libretro_vulkan.h, etc.
1001 *
1002 * GET_HW_RENDER_INTERFACE cannot be called before context_reset has been called.
1003 * Similarly, after context_destroyed callback returns,
1004 * the contents of the HW_RENDER_INTERFACE are invalidated.
1005 */
1006#define RETRO_ENVIRONMENT_SET_SUPPORT_ACHIEVEMENTS (42 | RETRO_ENVIRONMENT_EXPERIMENTAL)
1007 /* const bool * --
1008 * If true, the libretro implementation supports achievements
1009 * either via memory descriptors set with RETRO_ENVIRONMENT_SET_MEMORY_MAPS
1010 * or via retro_get_memory_data/retro_get_memory_size.
1011 *
1012 * This must be called before the first call to retro_run.
1013 */
1014#define RETRO_ENVIRONMENT_SET_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE (43 | RETRO_ENVIRONMENT_EXPERIMENTAL)
1015 /* const struct retro_hw_render_context_negotiation_interface * --
1016 * Sets an interface which lets the libretro core negotiate with frontend how a context is created.
1017 * The semantics of this interface depends on which API is used in SET_HW_RENDER earlier.
1018 * This interface will be used when the frontend is trying to create a HW rendering context,
1019 * so it will be used after SET_HW_RENDER, but before the context_reset callback.
1020 */
1021#define RETRO_ENVIRONMENT_SET_SERIALIZATION_QUIRKS 44
1022 /* uint64_t * --
1023 * Sets quirk flags associated with serialization. The frontend will zero any flags it doesn't
1024 * recognize or support. Should be set in either retro_init or retro_load_game, but not both.
1025 */
1026#define RETRO_ENVIRONMENT_SET_HW_SHARED_CONTEXT (44 | RETRO_ENVIRONMENT_EXPERIMENTAL)
1027 /* N/A (null) * --
1028 * The frontend will try to use a 'shared' hardware context (mostly applicable
1029 * to OpenGL) when a hardware context is being set up.
1030 *
1031 * Returns true if the frontend supports shared hardware contexts and false
1032 * if the frontend does not support shared hardware contexts.
1033 *
1034 * This will do nothing on its own until SET_HW_RENDER env callbacks are
1035 * being used.
1036 */
1037#define RETRO_ENVIRONMENT_GET_VFS_INTERFACE (45 | RETRO_ENVIRONMENT_EXPERIMENTAL)
1038 /* struct retro_vfs_interface_info * --
1039 * Gets access to the VFS interface.
1040 * VFS presence needs to be queried prior to load_game or any
1041 * get_system/save/other_directory being called to let front end know
1042 * core supports VFS before it starts handing out paths.
1043 * It is recomended to do so in retro_set_environment
1044 */
1045#define RETRO_ENVIRONMENT_GET_LED_INTERFACE (46 | RETRO_ENVIRONMENT_EXPERIMENTAL)
1046 /* struct retro_led_interface * --
1047 * Gets an interface which is used by a libretro core to set
1048 * state of LEDs.
1049 */
1050#define RETRO_ENVIRONMENT_GET_AUDIO_VIDEO_ENABLE (47 | RETRO_ENVIRONMENT_EXPERIMENTAL)
1051 /* int * --
1052 * Tells the core if the frontend wants audio or video.
1053 * If disabled, the frontend will discard the audio or video,
1054 * so the core may decide to skip generating a frame or generating audio.
1055 * This is mainly used for increasing performance.
1056 * Bit 0 (value 1): Enable Video
1057 * Bit 1 (value 2): Enable Audio
1058 * Bit 2 (value 4): Use Fast Savestates.
1059 * Bit 3 (value 8): Hard Disable Audio
1060 * Other bits are reserved for future use and will default to zero.
1061 * If video is disabled:
1062 * * The frontend wants the core to not generate any video,
1063 * including presenting frames via hardware acceleration.
1064 * * The frontend's video frame callback will do nothing.
1065 * * After running the frame, the video output of the next frame should be
1066 * no different than if video was enabled, and saving and loading state
1067 * should have no issues.
1068 * If audio is disabled:
1069 * * The frontend wants the core to not generate any audio.
1070 * * The frontend's audio callbacks will do nothing.
1071 * * After running the frame, the audio output of the next frame should be
1072 * no different than if audio was enabled, and saving and loading state
1073 * should have no issues.
1074 * Fast Savestates:
1075 * * Guaranteed to be created by the same binary that will load them.
1076 * * Will not be written to or read from the disk.
1077 * * Suggest that the core assumes loading state will succeed.
1078 * * Suggest that the core updates its memory buffers in-place if possible.
1079 * * Suggest that the core skips clearing memory.
1080 * * Suggest that the core skips resetting the system.
1081 * * Suggest that the core may skip validation steps.
1082 * Hard Disable Audio:
1083 * * Used for a secondary core when running ahead.
1084 * * Indicates that the frontend will never need audio from the core.
1085 * * Suggests that the core may stop synthesizing audio, but this should not
1086 * compromise emulation accuracy.
1087 * * Audio output for the next frame does not matter, and the frontend will
1088 * never need an accurate audio state in the future.
1089 * * State will never be saved when using Hard Disable Audio.
1090 */
1091#define RETRO_ENVIRONMENT_GET_MIDI_INTERFACE (48 | RETRO_ENVIRONMENT_EXPERIMENTAL)
1092 /* struct retro_midi_interface ** --
1093 * Returns a MIDI interface that can be used for raw data I/O.
1094 */
1095
1096#define RETRO_ENVIRONMENT_GET_FASTFORWARDING (49 | RETRO_ENVIRONMENT_EXPERIMENTAL)
1097 /* bool * --
1098 * Boolean value that indicates whether or not the frontend is in
1099 * fastforwarding mode.
1100 */
1101
1102#define RETRO_ENVIRONMENT_GET_TARGET_REFRESH_RATE (50 | RETRO_ENVIRONMENT_EXPERIMENTAL)
1103 /* float * --
8a60e610 1104 * Float value that lets us know what target refresh rate
6fbd15c8 1105 * is curently in use by the frontend.
1106 *
8a60e610 1107 * The core can use the returned value to set an ideal
6fbd15c8 1108 * refresh rate/framerate.
1109 */
1110
1111#define RETRO_ENVIRONMENT_GET_INPUT_BITMASKS (51 | RETRO_ENVIRONMENT_EXPERIMENTAL)
1112 /* bool * --
1113 * Boolean value that indicates whether or not the frontend supports
1114 * input bitmasks being returned by retro_input_state_t. The advantage
8a60e610 1115 * of this is that retro_input_state_t has to be only called once to
6fbd15c8 1116 * grab all button states instead of multiple times.
1117 *
1118 * If it returns true, you can pass RETRO_DEVICE_ID_JOYPAD_MASK as 'id'
1119 * to retro_input_state_t (make sure 'device' is set to RETRO_DEVICE_JOYPAD).
1120 * It will return a bitmask of all the digital buttons.
1121 */
1122
919cac88 1123#define RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION 52
1124 /* unsigned * --
1125 * Unsigned value is the API version number of the core options
1126 * interface supported by the frontend. If callback return false,
1127 * API version is assumed to be 0.
1128 *
1129 * In legacy code, core options are set by passing an array of
1130 * retro_variable structs to RETRO_ENVIRONMENT_SET_VARIABLES.
1131 * This may be still be done regardless of the core options
1132 * interface version.
1133 *
fbe06628 1134 * If version is >= 1 however, core options may instead be set by
919cac88 1135 * passing an array of retro_core_option_definition structs to
1136 * RETRO_ENVIRONMENT_SET_CORE_OPTIONS, or a 2D array of
1137 * retro_core_option_definition structs to RETRO_ENVIRONMENT_SET_CORE_OPTIONS_INTL.
1138 * This allows the core to additionally set option sublabel information
1139 * and/or provide localisation support.
f3c6ae10 1140 *
1141 * If version is >= 2, core options may instead be set by passing
1142 * a retro_core_options_v2 struct to RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2,
1143 * or an array of retro_core_options_v2 structs to
1144 * RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2_INTL. This allows the core
1145 * to additionally set optional core option category information
1146 * for frontends with core option category support.
919cac88 1147 */
1148
1149#define RETRO_ENVIRONMENT_SET_CORE_OPTIONS 53
1150 /* const struct retro_core_option_definition ** --
1151 * Allows an implementation to signal the environment
1152 * which variables it might want to check for later using
1153 * GET_VARIABLE.
1154 * This allows the frontend to present these variables to
1155 * a user dynamically.
fbe06628 1156 * This should only be called if RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION
1157 * returns an API version of >= 1.
919cac88 1158 * This should be called instead of RETRO_ENVIRONMENT_SET_VARIABLES.
1159 * This should be called the first time as early as
1160 * possible (ideally in retro_set_environment).
1161 * Afterwards it may be called again for the core to communicate
1162 * updated options to the frontend, but the number of core
1163 * options must not change from the number in the initial call.
1164 *
1165 * 'data' points to an array of retro_core_option_definition structs
1166 * terminated by a { NULL, NULL, NULL, {{0}}, NULL } element.
1167 * retro_core_option_definition::key should be namespaced to not collide
1168 * with other implementations' keys. e.g. A core called
1169 * 'foo' should use keys named as 'foo_option'.
1170 * retro_core_option_definition::desc should contain a human readable
1171 * description of the key.
1172 * retro_core_option_definition::info should contain any additional human
1173 * readable information text that a typical user may need to
1174 * understand the functionality of the option.
1175 * retro_core_option_definition::values is an array of retro_core_option_value
1176 * structs terminated by a { NULL, NULL } element.
1177 * > retro_core_option_definition::values[index].value is an expected option
1178 * value.
1179 * > retro_core_option_definition::values[index].label is a human readable
1180 * label used when displaying the value on screen. If NULL,
1181 * the value itself is used.
1182 * retro_core_option_definition::default_value is the default core option
1183 * setting. It must match one of the expected option values in the
1184 * retro_core_option_definition::values array. If it does not, or the
1185 * default value is NULL, the first entry in the
1186 * retro_core_option_definition::values array is treated as the default.
1187 *
f3c6ae10 1188 * The number of possible option values should be very limited,
919cac88 1189 * and must be less than RETRO_NUM_CORE_OPTION_VALUES_MAX.
1190 * i.e. it should be feasible to cycle through options
1191 * without a keyboard.
1192 *
919cac88 1193 * Example entry:
1194 * {
1195 * "foo_option",
1196 * "Speed hack coprocessor X",
1197 * "Provides increased performance at the expense of reduced accuracy",
1198 * {
1199 * { "false", NULL },
1200 * { "true", NULL },
1201 * { "unstable", "Turbo (Unstable)" },
1202 * { NULL, NULL },
1203 * },
1204 * "false"
1205 * }
1206 *
1207 * Only strings are operated on. The possible values will
1208 * generally be displayed and stored as-is by the frontend.
1209 */
1210
1211#define RETRO_ENVIRONMENT_SET_CORE_OPTIONS_INTL 54
1212 /* const struct retro_core_options_intl * --
1213 * Allows an implementation to signal the environment
1214 * which variables it might want to check for later using
1215 * GET_VARIABLE.
1216 * This allows the frontend to present these variables to
1217 * a user dynamically.
fbe06628 1218 * This should only be called if RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION
1219 * returns an API version of >= 1.
919cac88 1220 * This should be called instead of RETRO_ENVIRONMENT_SET_VARIABLES.
f3c6ae10 1221 * This should be called instead of RETRO_ENVIRONMENT_SET_CORE_OPTIONS.
919cac88 1222 * This should be called the first time as early as
1223 * possible (ideally in retro_set_environment).
1224 * Afterwards it may be called again for the core to communicate
1225 * updated options to the frontend, but the number of core
1226 * options must not change from the number in the initial call.
1227 *
1228 * This is fundamentally the same as RETRO_ENVIRONMENT_SET_CORE_OPTIONS,
1229 * with the addition of localisation support. The description of the
1230 * RETRO_ENVIRONMENT_SET_CORE_OPTIONS callback should be consulted
1231 * for further details.
1232 *
1233 * 'data' points to a retro_core_options_intl struct.
1234 *
1235 * retro_core_options_intl::us is a pointer to an array of
1236 * retro_core_option_definition structs defining the US English
1237 * core options implementation. It must point to a valid array.
1238 *
1239 * retro_core_options_intl::local is a pointer to an array of
1240 * retro_core_option_definition structs defining core options for
1241 * the current frontend language. It may be NULL (in which case
1242 * retro_core_options_intl::us is used by the frontend). Any items
1243 * missing from this array will be read from retro_core_options_intl::us
1244 * instead.
1245 *
1246 * NOTE: Default core option values are always taken from the
1247 * retro_core_options_intl::us array. Any default values in
1248 * retro_core_options_intl::local array will be ignored.
1249 */
1250
1251#define RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY 55
1252 /* struct retro_core_option_display * --
1253 *
1254 * Allows an implementation to signal the environment to show
1255 * or hide a variable when displaying core options. This is
1256 * considered a *suggestion*. The frontend is free to ignore
1257 * this callback, and its implementation not considered mandatory.
1258 *
1259 * 'data' points to a retro_core_option_display struct
1260 *
1261 * retro_core_option_display::key is a variable identifier
1262 * which has already been set by SET_VARIABLES/SET_CORE_OPTIONS.
1263 *
1264 * retro_core_option_display::visible is a boolean, specifying
1265 * whether variable should be displayed
1266 *
1267 * Note that all core option variables will be set visible by
1268 * default when calling SET_VARIABLES/SET_CORE_OPTIONS.
1269 */
1270
144493e8 1271#define RETRO_ENVIRONMENT_GET_PREFERRED_HW_RENDER 56
1272 /* unsigned * --
1273 *
1274 * Allows an implementation to ask frontend preferred hardware
1275 * context to use. Core should use this information to deal
1276 * with what specific context to request with SET_HW_RENDER.
1277 *
1278 * 'data' points to an unsigned variable
1279 */
1280
1281#define RETRO_ENVIRONMENT_GET_DISK_CONTROL_INTERFACE_VERSION 57
1282 /* unsigned * --
1283 * Unsigned value is the API version number of the disk control
1284 * interface supported by the frontend. If callback return false,
1285 * API version is assumed to be 0.
1286 *
1287 * In legacy code, the disk control interface is defined by passing
1288 * a struct of type retro_disk_control_callback to
1289 * RETRO_ENVIRONMENT_SET_DISK_CONTROL_INTERFACE.
1290 * This may be still be done regardless of the disk control
1291 * interface version.
1292 *
1293 * If version is >= 1 however, the disk control interface may
1294 * instead be defined by passing a struct of type
1295 * retro_disk_control_ext_callback to
1296 * RETRO_ENVIRONMENT_SET_DISK_CONTROL_EXT_INTERFACE.
1297 * This allows the core to provide additional information about
1298 * disk images to the frontend and/or enables extra
1299 * disk control functionality by the frontend.
1300 */
1301
1302#define RETRO_ENVIRONMENT_SET_DISK_CONTROL_EXT_INTERFACE 58
1303 /* const struct retro_disk_control_ext_callback * --
1304 * Sets an interface which frontend can use to eject and insert
1305 * disk images, and also obtain information about individual
1306 * disk image files registered by the core.
1307 * This is used for games which consist of multiple images and
1308 * must be manually swapped out by the user (e.g. PSX, floppy disk
1309 * based systems).
1310 */
1311
8a60e610 1312#define RETRO_ENVIRONMENT_GET_MESSAGE_INTERFACE_VERSION 59
1313 /* unsigned * --
1314 * Unsigned value is the API version number of the message
1315 * interface supported by the frontend. If callback returns
1316 * false, API version is assumed to be 0.
1317 *
1318 * In legacy code, messages may be displayed in an
1319 * implementation-specific manner by passing a struct
1320 * of type retro_message to RETRO_ENVIRONMENT_SET_MESSAGE.
1321 * This may be still be done regardless of the message
1322 * interface version.
1323 *
1324 * If version is >= 1 however, messages may instead be
1325 * displayed by passing a struct of type retro_message_ext
1326 * to RETRO_ENVIRONMENT_SET_MESSAGE_EXT. This allows the
1327 * core to specify message logging level, priority and
1328 * destination (OSD, logging interface or both).
1329 */
1330
1331#define RETRO_ENVIRONMENT_SET_MESSAGE_EXT 60
1332 /* const struct retro_message_ext * --
1333 * Sets a message to be displayed in an implementation-specific
1334 * manner for a certain amount of 'frames'. Additionally allows
1335 * the core to specify message logging level, priority and
1336 * destination (OSD, logging interface or both).
1337 * Should not be used for trivial messages, which should simply be
1338 * logged via RETRO_ENVIRONMENT_GET_LOG_INTERFACE (or as a
1339 * fallback, stderr).
1340 */
1341
270c6dd1 1342#define RETRO_ENVIRONMENT_GET_INPUT_MAX_USERS 61
1343 /* unsigned * --
1344 * Unsigned value is the number of active input devices
1345 * provided by the frontend. This may change between
1346 * frames, but will remain constant for the duration
1347 * of each frame.
1348 * If callback returns true, a core need not poll any
1349 * input device with an index greater than or equal to
1350 * the number of active devices.
1351 * If callback returns false, the number of active input
1352 * devices is unknown. In this case, all input devices
1353 * should be considered active.
1354 */
1355
1356#define RETRO_ENVIRONMENT_SET_AUDIO_BUFFER_STATUS_CALLBACK 62
1357 /* const struct retro_audio_buffer_status_callback * --
1358 * Lets the core know the occupancy level of the frontend
1359 * audio buffer. Can be used by a core to attempt frame
1360 * skipping in order to avoid buffer under-runs.
1361 * A core may pass NULL to disable buffer status reporting
1362 * in the frontend.
1363 */
1364
1365#define RETRO_ENVIRONMENT_SET_MINIMUM_AUDIO_LATENCY 63
1366 /* const unsigned * --
1367 * Sets minimum frontend audio latency in milliseconds.
1368 * Resultant audio latency may be larger than set value,
1369 * or smaller if a hardware limit is encountered. A frontend
1370 * is expected to honour requests up to 512 ms.
1371 *
1372 * - If value is less than current frontend
1373 * audio latency, callback has no effect
1374 * - If value is zero, default frontend audio
1375 * latency is set
1376 *
1377 * May be used by a core to increase audio latency and
1378 * therefore decrease the probability of buffer under-runs
1379 * (crackling) when performing 'intensive' operations.
1380 * A core utilising RETRO_ENVIRONMENT_SET_AUDIO_BUFFER_STATUS_CALLBACK
1381 * to implement audio-buffer-based frame skipping may achieve
1382 * optimal results by setting the audio latency to a 'high'
1383 * (typically 6x or 8x) integer multiple of the expected
1384 * frame time.
1385 *
1386 * WARNING: This can only be called from within retro_run().
1387 * Calling this can require a full reinitialization of audio
1388 * drivers in the frontend, so it is important to call it very
1389 * sparingly, and usually only with the users explicit consent.
1390 * An eventual driver reinitialize will happen so that audio
1391 * callbacks happening after this call within the same retro_run()
1392 * call will target the newly initialized driver.
1393 */
1394
f3c6ae10 1395#define RETRO_ENVIRONMENT_SET_FASTFORWARDING_OVERRIDE 64
1396 /* const struct retro_fastforwarding_override * --
1397 * Used by a libretro core to override the current
1398 * fastforwarding mode of the frontend.
1399 * If NULL is passed to this function, the frontend
1400 * will return true if fastforwarding override
1401 * functionality is supported (no change in
1402 * fastforwarding state will occur in this case).
1403 */
1404
1405#define RETRO_ENVIRONMENT_SET_CONTENT_INFO_OVERRIDE 65
1406 /* const struct retro_system_content_info_override * --
1407 * Allows an implementation to override 'global' content
1408 * info parameters reported by retro_get_system_info().
1409 * Overrides also affect subsystem content info parameters
1410 * set via RETRO_ENVIRONMENT_SET_SUBSYSTEM_INFO.
1411 * This function must be called inside retro_set_environment().
1412 * If callback returns false, content info overrides
1413 * are unsupported by the frontend, and will be ignored.
1414 * If callback returns true, extended game info may be
1415 * retrieved by calling RETRO_ENVIRONMENT_GET_GAME_INFO_EXT
1416 * in retro_load_game() or retro_load_game_special().
1417 *
1418 * 'data' points to an array of retro_system_content_info_override
1419 * structs terminated by a { NULL, false, false } element.
1420 * If 'data' is NULL, no changes will be made to the frontend;
1421 * a core may therefore pass NULL in order to test whether
1422 * the RETRO_ENVIRONMENT_SET_CONTENT_INFO_OVERRIDE and
1423 * RETRO_ENVIRONMENT_GET_GAME_INFO_EXT callbacks are supported
1424 * by the frontend.
1425 *
1426 * For struct member descriptions, see the definition of
1427 * struct retro_system_content_info_override.
1428 *
1429 * Example:
1430 *
1431 * - struct retro_system_info:
1432 * {
1433 * "My Core", // library_name
1434 * "v1.0", // library_version
1435 * "m3u|md|cue|iso|chd|sms|gg|sg", // valid_extensions
1436 * true, // need_fullpath
1437 * false // block_extract
1438 * }
1439 *
1440 * - Array of struct retro_system_content_info_override:
1441 * {
1442 * {
1443 * "md|sms|gg", // extensions
1444 * false, // need_fullpath
1445 * true // persistent_data
1446 * },
1447 * {
1448 * "sg", // extensions
1449 * false, // need_fullpath
1450 * false // persistent_data
1451 * },
1452 * { NULL, false, false }
1453 * }
1454 *
1455 * Result:
1456 * - Files of type m3u, cue, iso, chd will not be
1457 * loaded by the frontend. Frontend will pass a
1458 * valid path to the core, and core will handle
1459 * loading internally
1460 * - Files of type md, sms, gg will be loaded by
1461 * the frontend. A valid memory buffer will be
1462 * passed to the core. This memory buffer will
1463 * remain valid until retro_deinit() returns
1464 * - Files of type sg will be loaded by the frontend.
1465 * A valid memory buffer will be passed to the core.
1466 * This memory buffer will remain valid until
1467 * retro_load_game() (or retro_load_game_special())
1468 * returns
1469 *
1470 * NOTE: If an extension is listed multiple times in
1471 * an array of retro_system_content_info_override
1472 * structs, only the first instance will be registered
1473 */
1474
1475#define RETRO_ENVIRONMENT_GET_GAME_INFO_EXT 66
1476 /* const struct retro_game_info_ext ** --
1477 * Allows an implementation to fetch extended game
1478 * information, providing additional content path
1479 * and memory buffer status details.
1480 * This function may only be called inside
1481 * retro_load_game() or retro_load_game_special().
1482 * If callback returns false, extended game information
1483 * is unsupported by the frontend. In this case, only
1484 * regular retro_game_info will be available.
1485 * RETRO_ENVIRONMENT_GET_GAME_INFO_EXT is guaranteed
1486 * to return true if RETRO_ENVIRONMENT_SET_CONTENT_INFO_OVERRIDE
1487 * returns true.
1488 *
1489 * 'data' points to an array of retro_game_info_ext structs.
1490 *
1491 * For struct member descriptions, see the definition of
1492 * struct retro_game_info_ext.
1493 *
1494 * - If function is called inside retro_load_game(),
1495 * the retro_game_info_ext array is guaranteed to
1496 * have a size of 1 - i.e. the returned pointer may
1497 * be used to access directly the members of the
1498 * first retro_game_info_ext struct, for example:
1499 *
1500 * struct retro_game_info_ext *game_info_ext;
1501 * if (environ_cb(RETRO_ENVIRONMENT_GET_GAME_INFO_EXT, &game_info_ext))
1502 * printf("Content Directory: %s\n", game_info_ext->dir);
1503 *
1504 * - If the function is called inside retro_load_game_special(),
1505 * the retro_game_info_ext array is guaranteed to have a
1506 * size equal to the num_info argument passed to
1507 * retro_load_game_special()
1508 */
1509
1510#define RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2 67
1511 /* const struct retro_core_options_v2 * --
1512 * Allows an implementation to signal the environment
1513 * which variables it might want to check for later using
1514 * GET_VARIABLE.
1515 * This allows the frontend to present these variables to
1516 * a user dynamically.
1517 * This should only be called if RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION
1518 * returns an API version of >= 2.
1519 * This should be called instead of RETRO_ENVIRONMENT_SET_VARIABLES.
1520 * This should be called instead of RETRO_ENVIRONMENT_SET_CORE_OPTIONS.
1521 * This should be called the first time as early as
1522 * possible (ideally in retro_set_environment).
1523 * Afterwards it may be called again for the core to communicate
1524 * updated options to the frontend, but the number of core
1525 * options must not change from the number in the initial call.
1526 * If RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION returns an API
1527 * version of >= 2, this callback is guaranteed to succeed
1528 * (i.e. callback return value does not indicate success)
1529 * If callback returns true, frontend has core option category
1530 * support.
1531 * If callback returns false, frontend does not have core option
1532 * category support.
1533 *
1534 * 'data' points to a retro_core_options_v2 struct, containing
1535 * of two pointers:
1536 * - retro_core_options_v2::categories is an array of
1537 * retro_core_option_v2_category structs terminated by a
1538 * { NULL, NULL, NULL } element. If retro_core_options_v2::categories
1539 * is NULL, all core options will have no category and will be shown
1540 * at the top level of the frontend core option interface. If frontend
1541 * does not have core option category support, categories array will
1542 * be ignored.
1543 * - retro_core_options_v2::definitions is an array of
1544 * retro_core_option_v2_definition structs terminated by a
1545 * { NULL, NULL, NULL, NULL, NULL, NULL, {{0}}, NULL }
1546 * element.
1547 *
1548 * >> retro_core_option_v2_category notes:
1549 *
1550 * - retro_core_option_v2_category::key should contain string
1551 * that uniquely identifies the core option category. Valid
1552 * key characters are [a-z, A-Z, 0-9, _, -]
1553 * Namespace collisions with other implementations' category
1554 * keys are permitted.
1555 * - retro_core_option_v2_category::desc should contain a human
1556 * readable description of the category key.
1557 * - retro_core_option_v2_category::info should contain any
1558 * additional human readable information text that a typical
1559 * user may need to understand the nature of the core option
1560 * category.
1561 *
1562 * Example entry:
1563 * {
1564 * "advanced_settings",
1565 * "Advanced",
1566 * "Options affecting low-level emulation performance and accuracy."
1567 * }
1568 *
1569 * >> retro_core_option_v2_definition notes:
1570 *
1571 * - retro_core_option_v2_definition::key should be namespaced to not
1572 * collide with other implementations' keys. e.g. A core called
1573 * 'foo' should use keys named as 'foo_option'. Valid key characters
1574 * are [a-z, A-Z, 0-9, _, -].
1575 * - retro_core_option_v2_definition::desc should contain a human readable
1576 * description of the key. Will be used when the frontend does not
1577 * have core option category support. Examples: "Aspect Ratio" or
1578 * "Video > Aspect Ratio".
1579 * - retro_core_option_v2_definition::desc_categorized should contain a
1580 * human readable description of the key, which will be used when
1581 * frontend has core option category support. Example: "Aspect Ratio",
1582 * where associated retro_core_option_v2_category::desc is "Video".
1583 * If empty or NULL, the string specified by
1584 * retro_core_option_v2_definition::desc will be used instead.
1585 * retro_core_option_v2_definition::desc_categorized will be ignored
1586 * if retro_core_option_v2_definition::category_key is empty or NULL.
1587 * - retro_core_option_v2_definition::info should contain any additional
1588 * human readable information text that a typical user may need to
1589 * understand the functionality of the option.
1590 * - retro_core_option_v2_definition::info_categorized should contain
1591 * any additional human readable information text that a typical user
1592 * may need to understand the functionality of the option, and will be
1593 * used when frontend has core option category support. This is provided
1594 * to accommodate the case where info text references an option by
1595 * name/desc, and the desc/desc_categorized text for that option differ.
1596 * If empty or NULL, the string specified by
1597 * retro_core_option_v2_definition::info will be used instead.
1598 * retro_core_option_v2_definition::info_categorized will be ignored
1599 * if retro_core_option_v2_definition::category_key is empty or NULL.
1600 * - retro_core_option_v2_definition::category_key should contain a
1601 * category identifier (e.g. "video" or "audio") that will be
1602 * assigned to the core option if frontend has core option category
1603 * support. A categorized option will be shown in a subsection/
1604 * submenu of the frontend core option interface. If key is empty
1605 * or NULL, or if key does not match one of the
1606 * retro_core_option_v2_category::key values in the associated
1607 * retro_core_option_v2_category array, option will have no category
1608 * and will be shown at the top level of the frontend core option
1609 * interface.
1610 * - retro_core_option_v2_definition::values is an array of
1611 * retro_core_option_value structs terminated by a { NULL, NULL }
1612 * element.
1613 * --> retro_core_option_v2_definition::values[index].value is an
1614 * expected option value.
1615 * --> retro_core_option_v2_definition::values[index].label is a
1616 * human readable label used when displaying the value on screen.
1617 * If NULL, the value itself is used.
1618 * - retro_core_option_v2_definition::default_value is the default
1619 * core option setting. It must match one of the expected option
1620 * values in the retro_core_option_v2_definition::values array. If
1621 * it does not, or the default value is NULL, the first entry in the
1622 * retro_core_option_v2_definition::values array is treated as the
1623 * default.
1624 *
1625 * The number of possible option values should be very limited,
1626 * and must be less than RETRO_NUM_CORE_OPTION_VALUES_MAX.
1627 * i.e. it should be feasible to cycle through options
1628 * without a keyboard.
1629 *
1630 * Example entries:
1631 *
1632 * - Uncategorized:
1633 *
1634 * {
1635 * "foo_option",
1636 * "Speed hack coprocessor X",
1637 * NULL,
1638 * "Provides increased performance at the expense of reduced accuracy.",
1639 * NULL,
1640 * NULL,
1641 * {
1642 * { "false", NULL },
1643 * { "true", NULL },
1644 * { "unstable", "Turbo (Unstable)" },
1645 * { NULL, NULL },
1646 * },
1647 * "false"
1648 * }
1649 *
1650 * - Categorized:
1651 *
1652 * {
1653 * "foo_option",
1654 * "Advanced > Speed hack coprocessor X",
1655 * "Speed hack coprocessor X",
1656 * "Setting 'Advanced > Speed hack coprocessor X' to 'true' or 'Turbo' provides increased performance at the expense of reduced accuracy",
1657 * "Setting 'Speed hack coprocessor X' to 'true' or 'Turbo' provides increased performance at the expense of reduced accuracy",
1658 * "advanced_settings",
1659 * {
1660 * { "false", NULL },
1661 * { "true", NULL },
1662 * { "unstable", "Turbo (Unstable)" },
1663 * { NULL, NULL },
1664 * },
1665 * "false"
1666 * }
1667 *
1668 * Only strings are operated on. The possible values will
1669 * generally be displayed and stored as-is by the frontend.
1670 */
1671
1672#define RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2_INTL 68
1673 /* const struct retro_core_options_v2_intl * --
1674 * Allows an implementation to signal the environment
1675 * which variables it might want to check for later using
1676 * GET_VARIABLE.
1677 * This allows the frontend to present these variables to
1678 * a user dynamically.
1679 * This should only be called if RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION
1680 * returns an API version of >= 2.
1681 * This should be called instead of RETRO_ENVIRONMENT_SET_VARIABLES.
1682 * This should be called instead of RETRO_ENVIRONMENT_SET_CORE_OPTIONS.
1683 * This should be called instead of RETRO_ENVIRONMENT_SET_CORE_OPTIONS_INTL.
1684 * This should be called instead of RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2.
1685 * This should be called the first time as early as
1686 * possible (ideally in retro_set_environment).
1687 * Afterwards it may be called again for the core to communicate
1688 * updated options to the frontend, but the number of core
1689 * options must not change from the number in the initial call.
1690 * If RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION returns an API
1691 * version of >= 2, this callback is guaranteed to succeed
1692 * (i.e. callback return value does not indicate success)
1693 * If callback returns true, frontend has core option category
1694 * support.
1695 * If callback returns false, frontend does not have core option
1696 * category support.
1697 *
1698 * This is fundamentally the same as RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2,
1699 * with the addition of localisation support. The description of the
1700 * RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2 callback should be consulted
1701 * for further details.
1702 *
1703 * 'data' points to a retro_core_options_v2_intl struct.
1704 *
1705 * - retro_core_options_v2_intl::us is a pointer to a
1706 * retro_core_options_v2 struct defining the US English
1707 * core options implementation. It must point to a valid struct.
1708 *
1709 * - retro_core_options_v2_intl::local is a pointer to a
1710 * retro_core_options_v2 struct defining core options for
1711 * the current frontend language. It may be NULL (in which case
1712 * retro_core_options_v2_intl::us is used by the frontend). Any items
1713 * missing from this struct will be read from
1714 * retro_core_options_v2_intl::us instead.
1715 *
1716 * NOTE: Default core option values are always taken from the
1717 * retro_core_options_v2_intl::us struct. Any default values in
1718 * the retro_core_options_v2_intl::local struct will be ignored.
1719 */
1720
1721#define RETRO_ENVIRONMENT_SET_CORE_OPTIONS_UPDATE_DISPLAY_CALLBACK 69
1722 /* const struct retro_core_options_update_display_callback * --
1723 * Allows a frontend to signal that a core must update
1724 * the visibility of any dynamically hidden core options,
1725 * and enables the frontend to detect visibility changes.
1726 * Used by the frontend to update the menu display status
1727 * of core options without requiring a call of retro_run().
1728 * Must be called in retro_set_environment().
1729 */
1730
1731#define RETRO_ENVIRONMENT_SET_VARIABLE 70
1732 /* const struct retro_variable * --
1733 * Allows an implementation to notify the frontend
1734 * that a core option value has changed.
1735 *
1736 * retro_variable::key and retro_variable::value
1737 * must match strings that have been set previously
1738 * via one of the following:
1739 *
1740 * - RETRO_ENVIRONMENT_SET_VARIABLES
1741 * - RETRO_ENVIRONMENT_SET_CORE_OPTIONS
1742 * - RETRO_ENVIRONMENT_SET_CORE_OPTIONS_INTL
1743 * - RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2
1744 * - RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2_INTL
1745 *
1746 * After changing a core option value via this
1747 * callback, RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE
1748 * will return true.
1749 *
1750 * If data is NULL, no changes will be registered
1751 * and the callback will return true; an
1752 * implementation may therefore pass NULL in order
1753 * to test whether the callback is supported.
1754 */
1755
1756#define RETRO_ENVIRONMENT_GET_THROTTLE_STATE (71 | RETRO_ENVIRONMENT_EXPERIMENTAL)
1757 /* struct retro_throttle_state * --
1758 * Allows an implementation to get details on the actual rate
1759 * the frontend is attempting to call retro_run().
1760 */
1761
6fbd15c8 1762/* VFS functionality */
1763
1764/* File paths:
1765 * File paths passed as parameters when using this API shall be well formed UNIX-style,
1766 * using "/" (unquoted forward slash) as directory separator regardless of the platform's native separator.
1767 * Paths shall also include at least one forward slash ("game.bin" is an invalid path, use "./game.bin" instead).
1768 * Other than the directory separator, cores shall not make assumptions about path format:
1769 * "C:/path/game.bin", "http://example.com/game.bin", "#game/game.bin", "./game.bin" (without quotes) are all valid paths.
1770 * Cores may replace the basename or remove path components from the end, and/or add new components;
1771 * however, cores shall not append "./", "../" or multiple consecutive forward slashes ("//") to paths they request to front end.
1772 * 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.
1773 * Frontends are encouraged, but not required, to support native file system paths (modulo replacing the directory separator, if applicable).
1774 * Cores are allowed to try using them, but must remain functional if the front rejects such requests.
1775 * Cores are encouraged to use the libretro-common filestream functions for file I/O,
1776 * as they seamlessly integrate with VFS, deal with directory separator replacement as appropriate
1777 * and provide platform-specific fallbacks in cases where front ends do not support VFS. */
1778
1779/* Opaque file handle
1780 * Introduced in VFS API v1 */
1781struct retro_vfs_file_handle;
1782
1783/* Opaque directory handle
1784 * Introduced in VFS API v3 */
1785struct retro_vfs_dir_handle;
1786
1787/* File open flags
1788 * Introduced in VFS API v1 */
1789#define RETRO_VFS_FILE_ACCESS_READ (1 << 0) /* Read only mode */
1790#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 */
1791#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*/
1792#define RETRO_VFS_FILE_ACCESS_UPDATE_EXISTING (1 << 2) /* Prevents discarding content of existing files opened for writing */
1793
1794/* These are only hints. The frontend may choose to ignore them. Other than RAM/CPU/etc use,
1795 and how they react to unlikely external interference (for example someone else writing to that file,
1796 or the file's server going down), behavior will not change. */
1797#define RETRO_VFS_FILE_ACCESS_HINT_NONE (0)
1798/* Indicate that the file will be accessed many times. The frontend should aggressively cache everything. */
1799#define RETRO_VFS_FILE_ACCESS_HINT_FREQUENT_ACCESS (1 << 0)
1800
1801/* Seek positions */
1802#define RETRO_VFS_SEEK_POSITION_START 0
1803#define RETRO_VFS_SEEK_POSITION_CURRENT 1
1804#define RETRO_VFS_SEEK_POSITION_END 2
1805
1806/* stat() result flags
1807 * Introduced in VFS API v3 */
1808#define RETRO_VFS_STAT_IS_VALID (1 << 0)
1809#define RETRO_VFS_STAT_IS_DIRECTORY (1 << 1)
1810#define RETRO_VFS_STAT_IS_CHARACTER_SPECIAL (1 << 2)
1811
1812/* Get path from opaque handle. Returns the exact same path passed to file_open when getting the handle
1813 * Introduced in VFS API v1 */
1814typedef const char *(RETRO_CALLCONV *retro_vfs_get_path_t)(struct retro_vfs_file_handle *stream);
1815
1816/* Open a file for reading or writing. If path points to a directory, this will
1817 * fail. Returns the opaque file handle, or NULL for error.
1818 * Introduced in VFS API v1 */
1819typedef struct retro_vfs_file_handle *(RETRO_CALLCONV *retro_vfs_open_t)(const char *path, unsigned mode, unsigned hints);
1820
1821/* Close the file and release its resources. Must be called if open_file returns non-NULL. Returns 0 on success, -1 on failure.
1822 * Whether the call succeeds ot not, the handle passed as parameter becomes invalid and should no longer be used.
1823 * Introduced in VFS API v1 */
1824typedef int (RETRO_CALLCONV *retro_vfs_close_t)(struct retro_vfs_file_handle *stream);
1825
1826/* Return the size of the file in bytes, or -1 for error.
1827 * Introduced in VFS API v1 */
1828typedef int64_t (RETRO_CALLCONV *retro_vfs_size_t)(struct retro_vfs_file_handle *stream);
1829
1830/* Truncate file to specified size. Returns 0 on success or -1 on error
1831 * Introduced in VFS API v2 */
1832typedef int64_t (RETRO_CALLCONV *retro_vfs_truncate_t)(struct retro_vfs_file_handle *stream, int64_t length);
1833
1834/* Get the current read / write position for the file. Returns -1 for error.
1835 * Introduced in VFS API v1 */
1836typedef int64_t (RETRO_CALLCONV *retro_vfs_tell_t)(struct retro_vfs_file_handle *stream);
1837
1838/* Set the current read/write position for the file. Returns the new position, -1 for error.
1839 * Introduced in VFS API v1 */
1840typedef int64_t (RETRO_CALLCONV *retro_vfs_seek_t)(struct retro_vfs_file_handle *stream, int64_t offset, int seek_position);
1841
1842/* Read data from a file. Returns the number of bytes read, or -1 for error.
1843 * Introduced in VFS API v1 */
1844typedef int64_t (RETRO_CALLCONV *retro_vfs_read_t)(struct retro_vfs_file_handle *stream, void *s, uint64_t len);
1845
1846/* Write data to a file. Returns the number of bytes written, or -1 for error.
1847 * Introduced in VFS API v1 */
1848typedef int64_t (RETRO_CALLCONV *retro_vfs_write_t)(struct retro_vfs_file_handle *stream, const void *s, uint64_t len);
1849
1850/* Flush pending writes to file, if using buffered IO. Returns 0 on sucess, or -1 on failure.
1851 * Introduced in VFS API v1 */
1852typedef int (RETRO_CALLCONV *retro_vfs_flush_t)(struct retro_vfs_file_handle *stream);
1853
1854/* Delete the specified file. Returns 0 on success, -1 on failure
1855 * Introduced in VFS API v1 */
1856typedef int (RETRO_CALLCONV *retro_vfs_remove_t)(const char *path);
1857
1858/* Rename the specified file. Returns 0 on success, -1 on failure
1859 * Introduced in VFS API v1 */
1860typedef int (RETRO_CALLCONV *retro_vfs_rename_t)(const char *old_path, const char *new_path);
1861
1862/* Stat the specified file. Retruns a bitmask of RETRO_VFS_STAT_* flags, none are set if path was not valid.
1863 * Additionally stores file size in given variable, unless NULL is given.
1864 * Introduced in VFS API v3 */
1865typedef int (RETRO_CALLCONV *retro_vfs_stat_t)(const char *path, int32_t *size);
1866
1867/* Create the specified directory. Returns 0 on success, -1 on unknown failure, -2 if already exists.
1868 * Introduced in VFS API v3 */
1869typedef int (RETRO_CALLCONV *retro_vfs_mkdir_t)(const char *dir);
1870
1871/* Open the specified directory for listing. Returns the opaque dir handle, or NULL for error.
1872 * Support for the include_hidden argument may vary depending on the platform.
1873 * Introduced in VFS API v3 */
1874typedef struct retro_vfs_dir_handle *(RETRO_CALLCONV *retro_vfs_opendir_t)(const char *dir, bool include_hidden);
1875
1876/* Read the directory entry at the current position, and move the read pointer to the next position.
1877 * Returns true on success, false if already on the last entry.
1878 * Introduced in VFS API v3 */
1879typedef bool (RETRO_CALLCONV *retro_vfs_readdir_t)(struct retro_vfs_dir_handle *dirstream);
1880
1881/* Get the name of the last entry read. Returns a string on success, or NULL for error.
1882 * The returned string pointer is valid until the next call to readdir or closedir.
1883 * Introduced in VFS API v3 */
1884typedef const char *(RETRO_CALLCONV *retro_vfs_dirent_get_name_t)(struct retro_vfs_dir_handle *dirstream);
1885
1886/* Check if the last entry read was a directory. Returns true if it was, false otherwise (or on error).
1887 * Introduced in VFS API v3 */
1888typedef bool (RETRO_CALLCONV *retro_vfs_dirent_is_dir_t)(struct retro_vfs_dir_handle *dirstream);
1889
1890/* Close the directory and release its resources. Must be called if opendir returns non-NULL. Returns 0 on success, -1 on failure.
1891 * Whether the call succeeds ot not, the handle passed as parameter becomes invalid and should no longer be used.
1892 * Introduced in VFS API v3 */
1893typedef int (RETRO_CALLCONV *retro_vfs_closedir_t)(struct retro_vfs_dir_handle *dirstream);
1894
1895struct retro_vfs_interface
1896{
1897 /* VFS API v1 */
1898 retro_vfs_get_path_t get_path;
1899 retro_vfs_open_t open;
1900 retro_vfs_close_t close;
1901 retro_vfs_size_t size;
1902 retro_vfs_tell_t tell;
1903 retro_vfs_seek_t seek;
1904 retro_vfs_read_t read;
1905 retro_vfs_write_t write;
1906 retro_vfs_flush_t flush;
1907 retro_vfs_remove_t remove;
1908 retro_vfs_rename_t rename;
1909 /* VFS API v2 */
1910 retro_vfs_truncate_t truncate;
1911 /* VFS API v3 */
1912 retro_vfs_stat_t stat;
1913 retro_vfs_mkdir_t mkdir;
1914 retro_vfs_opendir_t opendir;
1915 retro_vfs_readdir_t readdir;
1916 retro_vfs_dirent_get_name_t dirent_get_name;
1917 retro_vfs_dirent_is_dir_t dirent_is_dir;
1918 retro_vfs_closedir_t closedir;
1919};
1920
1921struct retro_vfs_interface_info
1922{
1923 /* Set by core: should this be higher than the version the front end supports,
1924 * front end will return false in the RETRO_ENVIRONMENT_GET_VFS_INTERFACE call
1925 * Introduced in VFS API v1 */
1926 uint32_t required_interface_version;
1927
1928 /* Frontend writes interface pointer here. The frontend also sets the actual
1929 * version, must be at least required_interface_version.
1930 * Introduced in VFS API v1 */
1931 struct retro_vfs_interface *iface;
1932};
65a0505f
FJGG
1933
1934enum retro_hw_render_interface_type
1935{
6fbd15c8 1936 RETRO_HW_RENDER_INTERFACE_VULKAN = 0,
1937 RETRO_HW_RENDER_INTERFACE_D3D9 = 1,
1938 RETRO_HW_RENDER_INTERFACE_D3D10 = 2,
1939 RETRO_HW_RENDER_INTERFACE_D3D11 = 3,
1940 RETRO_HW_RENDER_INTERFACE_D3D12 = 4,
1941 RETRO_HW_RENDER_INTERFACE_GSKIT_PS2 = 5,
1942 RETRO_HW_RENDER_INTERFACE_DUMMY = INT_MAX
65a0505f
FJGG
1943};
1944
1945/* Base struct. All retro_hw_render_interface_* types
1946 * contain at least these fields. */
1947struct retro_hw_render_interface
1948{
1949 enum retro_hw_render_interface_type interface_type;
1950 unsigned interface_version;
1951};
eae1ae02 1952
6fbd15c8 1953typedef void (RETRO_CALLCONV *retro_set_led_state_t)(int led, int state);
1954struct retro_led_interface
1955{
1956 retro_set_led_state_t set_led_state;
1957};
1958
1959/* Retrieves the current state of the MIDI input.
1960 * Returns true if it's enabled, false otherwise. */
1961typedef bool (RETRO_CALLCONV *retro_midi_input_enabled_t)(void);
1962
1963/* Retrieves the current state of the MIDI output.
1964 * Returns true if it's enabled, false otherwise */
1965typedef bool (RETRO_CALLCONV *retro_midi_output_enabled_t)(void);
1966
1967/* Reads next byte from the input stream.
1968 * Returns true if byte is read, false otherwise. */
1969typedef bool (RETRO_CALLCONV *retro_midi_read_t)(uint8_t *byte);
1970
1971/* Writes byte to the output stream.
1972 * 'delta_time' is in microseconds and represent time elapsed since previous write.
1973 * Returns true if byte is written, false otherwise. */
1974typedef bool (RETRO_CALLCONV *retro_midi_write_t)(uint8_t byte, uint32_t delta_time);
1975
1976/* Flushes previously written data.
1977 * Returns true if successful, false otherwise. */
1978typedef bool (RETRO_CALLCONV *retro_midi_flush_t)(void);
1979
1980struct retro_midi_interface
1981{
1982 retro_midi_input_enabled_t input_enabled;
1983 retro_midi_output_enabled_t output_enabled;
1984 retro_midi_read_t read;
1985 retro_midi_write_t write;
1986 retro_midi_flush_t flush;
1987};
1988
1989enum retro_hw_render_context_negotiation_interface_type
1990{
1991 RETRO_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE_VULKAN = 0,
1992 RETRO_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE_DUMMY = INT_MAX
1993};
1994
1995/* Base struct. All retro_hw_render_context_negotiation_interface_* types
1996 * contain at least these fields. */
1997struct retro_hw_render_context_negotiation_interface
1998{
1999 enum retro_hw_render_context_negotiation_interface_type interface_type;
2000 unsigned interface_version;
2001};
2002
2003/* Serialized state is incomplete in some way. Set if serialization is
2004 * usable in typical end-user cases but should not be relied upon to
2005 * implement frame-sensitive frontend features such as netplay or
2006 * rerecording. */
2007#define RETRO_SERIALIZATION_QUIRK_INCOMPLETE (1 << 0)
2008/* The core must spend some time initializing before serialization is
2009 * supported. retro_serialize() will initially fail; retro_unserialize()
2010 * and retro_serialize_size() may or may not work correctly either. */
2011#define RETRO_SERIALIZATION_QUIRK_MUST_INITIALIZE (1 << 1)
2012/* Serialization size may change within a session. */
2013#define RETRO_SERIALIZATION_QUIRK_CORE_VARIABLE_SIZE (1 << 2)
2014/* Set by the frontend to acknowledge that it supports variable-sized
2015 * states. */
2016#define RETRO_SERIALIZATION_QUIRK_FRONT_VARIABLE_SIZE (1 << 3)
2017/* Serialized state can only be loaded during the same session. */
2018#define RETRO_SERIALIZATION_QUIRK_SINGLE_SESSION (1 << 4)
2019/* Serialized state cannot be loaded on an architecture with a different
2020 * endianness from the one it was saved on. */
2021#define RETRO_SERIALIZATION_QUIRK_ENDIAN_DEPENDENT (1 << 5)
2022/* Serialized state cannot be loaded on a different platform from the one it
2023 * was saved on for reasons other than endianness, such as word size
2024 * dependence */
2025#define RETRO_SERIALIZATION_QUIRK_PLATFORM_DEPENDENT (1 << 6)
2026
2027#define RETRO_MEMDESC_CONST (1 << 0) /* The frontend will never change this memory area once retro_load_game has returned. */
2028#define RETRO_MEMDESC_BIGENDIAN (1 << 1) /* The memory area contains big endian data. Default is little endian. */
2029#define RETRO_MEMDESC_SYSTEM_RAM (1 << 2) /* The memory area is system RAM. This is main RAM of the gaming system. */
2030#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. */
2031#define RETRO_MEMDESC_VIDEO_RAM (1 << 4) /* The memory area is video RAM (VRAM) */
2032#define RETRO_MEMDESC_ALIGN_2 (1 << 16) /* All memory access in this area is aligned to their own size, or 2, whichever is smaller. */
2033#define RETRO_MEMDESC_ALIGN_4 (2 << 16)
2034#define RETRO_MEMDESC_ALIGN_8 (3 << 16)
2035#define RETRO_MEMDESC_MINSIZE_2 (1 << 24) /* All memory in this region is accessed at least 2 bytes at the time. */
2036#define RETRO_MEMDESC_MINSIZE_4 (2 << 24)
2037#define RETRO_MEMDESC_MINSIZE_8 (3 << 24)
eae1ae02
A
2038struct retro_memory_descriptor
2039{
2040 uint64_t flags;
2041
2042 /* Pointer to the start of the relevant ROM or RAM chip.
6fbd15c8 2043 * It's strongly recommended to use 'offset' if possible, rather than
eae1ae02
A
2044 * doing math on the pointer.
2045 *
6fbd15c8 2046 * If the same byte is mapped my multiple descriptors, their descriptors
eae1ae02 2047 * must have the same pointer.
6fbd15c8 2048 * If 'start' does not point to the first byte in the pointer, put the
eae1ae02
A
2049 * difference in 'offset' instead.
2050 *
6fbd15c8 2051 * May be NULL if there's nothing usable here (e.g. hardware registers and
eae1ae02
A
2052 * open bus). No flags should be set if the pointer is NULL.
2053 * It's recommended to minimize the number of descriptors if possible,
2054 * but not mandatory. */
2055 void *ptr;
2056 size_t offset;
2057
6fbd15c8 2058 /* This is the location in the emulated address space
eae1ae02
A
2059 * where the mapping starts. */
2060 size_t start;
2061
2062 /* Which bits must be same as in 'start' for this mapping to apply.
6fbd15c8 2063 * The first memory descriptor to claim a certain byte is the one
eae1ae02
A
2064 * that applies.
2065 * A bit which is set in 'start' must also be set in this.
6fbd15c8 2066 * Can be zero, in which case each byte is assumed mapped exactly once.
eae1ae02
A
2067 * In this case, 'len' must be a power of two. */
2068 size_t select;
2069
6fbd15c8 2070 /* If this is nonzero, the set bits are assumed not connected to the
eae1ae02
A
2071 * memory chip's address pins. */
2072 size_t disconnect;
2073
2074 /* This one tells the size of the current memory area.
6fbd15c8 2075 * If, after start+disconnect are applied, the address is higher than
eae1ae02
A
2076 * this, the highest bit of the address is cleared.
2077 *
2078 * If the address is still too high, the next highest bit is cleared.
6fbd15c8 2079 * Can be zero, in which case it's assumed to be infinite (as limited
eae1ae02
A
2080 * by 'select' and 'disconnect'). */
2081 size_t len;
2082
6fbd15c8 2083 /* To go from emulated address to physical address, the following
eae1ae02 2084 * order applies:
6fbd15c8 2085 * Subtract 'start', pick off 'disconnect', apply 'len', add 'offset'. */
2086
2087 /* The address space name must consist of only a-zA-Z0-9_-,
eae1ae02 2088 * should be as short as feasible (maximum length is 8 plus the NUL),
6fbd15c8 2089 * and may not be any other address space plus one or more 0-9A-F
eae1ae02 2090 * at the end.
6fbd15c8 2091 * However, multiple memory descriptors for the same address space is
2092 * allowed, and the address space name can be empty. NULL is treated
eae1ae02
A
2093 * as empty.
2094 *
2095 * Address space names are case sensitive, but avoid lowercase if possible.
2096 * The same pointer may exist in multiple address spaces.
2097 *
2098 * Examples:
2099 * blank+blank - valid (multiple things may be mapped in the same namespace)
2100 * 'Sp'+'Sp' - valid (multiple things may be mapped in the same namespace)
2101 * 'A'+'B' - valid (neither is a prefix of each other)
2102 * 'S'+blank - valid ('S' is not in 0-9A-F)
2103 * 'a'+blank - valid ('a' is not in 0-9A-F)
2104 * 'a'+'A' - valid (neither is a prefix of each other)
2105 * 'AR'+blank - valid ('R' is not in 0-9A-F)
6fbd15c8 2106 * 'ARB'+blank - valid (the B can't be part of the address either, because
2107 * there is no namespace 'AR')
2108 * blank+'B' - not valid, because it's ambigous which address space B1234
2109 * would refer to.
2110 * The length can't be used for that purpose; the frontend may want
eae1ae02
A
2111 * to append arbitrary data to an address, without a separator. */
2112 const char *addrspace;
6fbd15c8 2113
2114 /* TODO: When finalizing this one, add a description field, which should be
2115 * "WRAM" or something roughly equally long. */
2116
2117 /* TODO: When finalizing this one, replace 'select' with 'limit', which tells
2118 * which bits can vary and still refer to the same address (limit = ~select).
2119 * TODO: limit? range? vary? something else? */
2120
2121 /* TODO: When finalizing this one, if 'len' is above what 'select' (or
2122 * 'limit') allows, it's bankswitched. Bankswitched data must have both 'len'
2123 * and 'select' != 0, and the mappings don't tell how the system switches the
2124 * banks. */
2125
2126 /* TODO: When finalizing this one, fix the 'len' bit removal order.
2127 * For len=0x1800, pointer 0x1C00 should go to 0x1400, not 0x0C00.
2128 * Algorithm: Take bits highest to lowest, but if it goes above len, clear
2129 * the most recent addition and continue on the next bit.
2130 * TODO: Can the above be optimized? Is "remove the lowest bit set in both
2131 * pointer and 'len'" equivalent? */
2132
2133 /* TODO: Some emulators (MAME?) emulate big endian systems by only accessing
2134 * the emulated memory in 32-bit chunks, native endian. But that's nothing
2135 * compared to Darek Mihocka <http://www.emulators.com/docs/nx07_vm101.htm>
2136 * (section Emulation 103 - Nearly Free Byte Reversal) - he flips the ENTIRE
2137 * RAM backwards! I'll want to represent both of those, via some flags.
2138 *
2139 * I suspect MAME either didn't think of that idea, or don't want the #ifdef.
2140 * Not sure which, nor do I really care. */
2141
2142 /* TODO: Some of those flags are unused and/or don't really make sense. Clean
2143 * them up. */
eae1ae02
A
2144};
2145
6fbd15c8 2146/* The frontend may use the largest value of 'start'+'select' in a
eae1ae02
A
2147 * certain namespace to infer the size of the address space.
2148 *
6fbd15c8 2149 * If the address space is larger than that, a mapping with .ptr=NULL
2150 * should be at the end of the array, with .select set to all ones for
eae1ae02
A
2151 * as long as the address space is big.
2152 *
2153 * Sample descriptors (minus .ptr, and RETRO_MEMFLAG_ on the flags):
2154 * SNES WRAM:
2155 * .start=0x7E0000, .len=0x20000
6fbd15c8 2156 * (Note that this must be mapped before the ROM in most cases; some of the
2157 * ROM mappers
eae1ae02
A
2158 * try to claim $7E0000, or at least $7E8000.)
2159 * SNES SPC700 RAM:
2160 * .addrspace="S", .len=0x10000
2161 * SNES WRAM mirrors:
2162 * .flags=MIRROR, .start=0x000000, .select=0xC0E000, .len=0x2000
2163 * .flags=MIRROR, .start=0x800000, .select=0xC0E000, .len=0x2000
2164 * SNES WRAM mirrors, alternate equivalent descriptor:
2165 * .flags=MIRROR, .select=0x40E000, .disconnect=~0x1FFF
6fbd15c8 2166 * (Various similar constructions can be created by combining parts of
eae1ae02
A
2167 * the above two.)
2168 * SNES LoROM (512KB, mirrored a couple of times):
2169 * .flags=CONST, .start=0x008000, .select=0x408000, .disconnect=0x8000, .len=512*1024
2170 * .flags=CONST, .start=0x400000, .select=0x400000, .disconnect=0x8000, .len=512*1024
2171 * SNES HiROM (4MB):
2172 * .flags=CONST, .start=0x400000, .select=0x400000, .len=4*1024*1024
2173 * .flags=CONST, .offset=0x8000, .start=0x008000, .select=0x408000, .len=4*1024*1024
2174 * SNES ExHiROM (8MB):
2175 * .flags=CONST, .offset=0, .start=0xC00000, .select=0xC00000, .len=4*1024*1024
2176 * .flags=CONST, .offset=4*1024*1024, .start=0x400000, .select=0xC00000, .len=4*1024*1024
2177 * .flags=CONST, .offset=0x8000, .start=0x808000, .select=0xC08000, .len=4*1024*1024
2178 * .flags=CONST, .offset=4*1024*1024+0x8000, .start=0x008000, .select=0xC08000, .len=4*1024*1024
2179 * Clarify the size of the address space:
2180 * .ptr=NULL, .select=0xFFFFFF
2181 * .len can be implied by .select in many of them, but was included for clarity.
2182 */
2183
2184struct retro_memory_map
2185{
2186 const struct retro_memory_descriptor *descriptors;
2187 unsigned num_descriptors;
2188};
2189
2190struct retro_controller_description
2191{
6fbd15c8 2192 /* Human-readable description of the controller. Even if using a generic
2193 * input device type, this can be set to the particular device type the
eae1ae02
A
2194 * core uses. */
2195 const char *desc;
2196
6fbd15c8 2197 /* Device type passed to retro_set_controller_port_device(). If the device
2198 * type is a sub-class of a generic input device type, use the
eae1ae02
A
2199 * RETRO_DEVICE_SUBCLASS macro to create an ID.
2200 *
2201 * E.g. RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 1). */
2202 unsigned id;
2203};
2204
2205struct retro_controller_info
2206{
2207 const struct retro_controller_description *types;
2208 unsigned num_types;
2209};
2210
2211struct retro_subsystem_memory_info
2212{
2213 /* The extension associated with a memory type, e.g. "psram". */
2214 const char *extension;
2215
6fbd15c8 2216 /* The memory type for retro_get_memory(). This should be at
2217 * least 0x100 to avoid conflict with standardized
eae1ae02
A
2218 * libretro memory types. */
2219 unsigned type;
2220};
2221
2222struct retro_subsystem_rom_info
2223{
2224 /* Describes what the content is (SGB BIOS, GB ROM, etc). */
2225 const char *desc;
2226
2227 /* Same definition as retro_get_system_info(). */
2228 const char *valid_extensions;
2229
2230 /* Same definition as retro_get_system_info(). */
2231 bool need_fullpath;
2232
2233 /* Same definition as retro_get_system_info(). */
2234 bool block_extract;
2235
6fbd15c8 2236 /* This is set if the content is required to load a game.
eae1ae02
A
2237 * If this is set to false, a zeroed-out retro_game_info can be passed. */
2238 bool required;
2239
6fbd15c8 2240 /* Content can have multiple associated persistent
eae1ae02
A
2241 * memory types (retro_get_memory()). */
2242 const struct retro_subsystem_memory_info *memory;
2243 unsigned num_memory;
2244};
2245
2246struct retro_subsystem_info
2247{
2248 /* Human-readable string of the subsystem type, e.g. "Super GameBoy" */
2249 const char *desc;
2250
2251 /* A computer friendly short string identifier for the subsystem type.
2252 * This name must be [a-z].
2253 * E.g. if desc is "Super GameBoy", this can be "sgb".
2254 * This identifier can be used for command-line interfaces, etc.
2255 */
2256 const char *ident;
2257
6fbd15c8 2258 /* Infos for each content file. The first entry is assumed to be the
eae1ae02 2259 * "most significant" content for frontend purposes.
6fbd15c8 2260 * E.g. with Super GameBoy, the first content should be the GameBoy ROM,
eae1ae02 2261 * as it is the most "significant" content to a user.
6fbd15c8 2262 * If a frontend creates new file paths based on the content used
eae1ae02
A
2263 * (e.g. savestates), it should use the path for the first ROM to do so. */
2264 const struct retro_subsystem_rom_info *roms;
2265
2266 /* Number of content files associated with a subsystem. */
2267 unsigned num_roms;
6fbd15c8 2268
eae1ae02
A
2269 /* The type passed to retro_load_game_special(). */
2270 unsigned id;
2271};
2272
6fbd15c8 2273typedef void (RETRO_CALLCONV *retro_proc_address_t)(void);
eae1ae02
A
2274
2275/* libretro API extension functions:
2276 * (None here so far).
2277 *
2278 * Get a symbol from a libretro core.
6fbd15c8 2279 * Cores should only return symbols which are actual
eae1ae02
A
2280 * extensions to the libretro API.
2281 *
6fbd15c8 2282 * Frontends should not use this to obtain symbols to standard
eae1ae02
A
2283 * libretro entry points (static linking or dlsym).
2284 *
6fbd15c8 2285 * The symbol name must be equal to the function name,
eae1ae02
A
2286 * e.g. if void retro_foo(void); exists, the symbol must be called "retro_foo".
2287 * The returned function pointer must be cast to the corresponding type.
2288 */
6fbd15c8 2289typedef retro_proc_address_t (RETRO_CALLCONV *retro_get_proc_address_t)(const char *sym);
eae1ae02
A
2290
2291struct retro_get_proc_address_interface
2292{
2293 retro_get_proc_address_t get_proc_address;
2294};
779692e4 2295
2296enum retro_log_level
2297{
2298 RETRO_LOG_DEBUG = 0,
2299 RETRO_LOG_INFO,
2300 RETRO_LOG_WARN,
2301 RETRO_LOG_ERROR,
2302
2303 RETRO_LOG_DUMMY = INT_MAX
2304};
2305
eae1ae02 2306/* Logging function. Takes log level argument as well. */
6fbd15c8 2307typedef void (RETRO_CALLCONV *retro_log_printf_t)(enum retro_log_level level,
eae1ae02 2308 const char *fmt, ...);
779692e4 2309
2310struct retro_log_callback
2311{
2312 retro_log_printf_t log;
2313};
2314
eae1ae02
A
2315/* Performance related functions */
2316
2317/* ID values for SIMD CPU features */
779692e4 2318#define RETRO_SIMD_SSE (1 << 0)
2319#define RETRO_SIMD_SSE2 (1 << 1)
2320#define RETRO_SIMD_VMX (1 << 2)
2321#define RETRO_SIMD_VMX128 (1 << 3)
2322#define RETRO_SIMD_AVX (1 << 4)
2323#define RETRO_SIMD_NEON (1 << 5)
2324#define RETRO_SIMD_SSE3 (1 << 6)
2325#define RETRO_SIMD_SSSE3 (1 << 7)
eae1ae02
A
2326#define RETRO_SIMD_MMX (1 << 8)
2327#define RETRO_SIMD_MMXEXT (1 << 9)
2328#define RETRO_SIMD_SSE4 (1 << 10)
2329#define RETRO_SIMD_SSE42 (1 << 11)
2330#define RETRO_SIMD_AVX2 (1 << 12)
2331#define RETRO_SIMD_VFPU (1 << 13)
2332#define RETRO_SIMD_PS (1 << 14)
2333#define RETRO_SIMD_AES (1 << 15)
65a0505f
FJGG
2334#define RETRO_SIMD_VFPV3 (1 << 16)
2335#define RETRO_SIMD_VFPV4 (1 << 17)
2336#define RETRO_SIMD_POPCNT (1 << 18)
2337#define RETRO_SIMD_MOVBE (1 << 19)
6fbd15c8 2338#define RETRO_SIMD_CMOV (1 << 20)
2339#define RETRO_SIMD_ASIMD (1 << 21)
779692e4 2340
2341typedef uint64_t retro_perf_tick_t;
2342typedef int64_t retro_time_t;
2343
2344struct retro_perf_counter
2345{
2346 const char *ident;
2347 retro_perf_tick_t start;
2348 retro_perf_tick_t total;
2349 retro_perf_tick_t call_cnt;
2350
2351 bool registered;
2352};
2353
eae1ae02
A
2354/* Returns current time in microseconds.
2355 * Tries to use the most accurate timer available.
2356 */
6fbd15c8 2357typedef retro_time_t (RETRO_CALLCONV *retro_perf_get_time_usec_t)(void);
eae1ae02
A
2358
2359/* A simple counter. Usually nanoseconds, but can also be CPU cycles.
6fbd15c8 2360 * Can be used directly if desired (when creating a more sophisticated
eae1ae02
A
2361 * performance counter system).
2362 * */
6fbd15c8 2363typedef retro_perf_tick_t (RETRO_CALLCONV *retro_perf_get_counter_t)(void);
eae1ae02
A
2364
2365/* Returns a bit-mask of detected CPU features (RETRO_SIMD_*). */
6fbd15c8 2366typedef uint64_t (RETRO_CALLCONV *retro_get_cpu_features_t)(void);
eae1ae02
A
2367
2368/* Asks frontend to log and/or display the state of performance counters.
2369 * Performance counters can always be poked into manually as well.
2370 */
6fbd15c8 2371typedef void (RETRO_CALLCONV *retro_perf_log_t)(void);
eae1ae02
A
2372
2373/* Register a performance counter.
6fbd15c8 2374 * ident field must be set with a discrete value and other values in
eae1ae02 2375 * retro_perf_counter must be 0.
6fbd15c8 2376 * Registering can be called multiple times. To avoid calling to
eae1ae02 2377 * frontend redundantly, you can check registered field first. */
6fbd15c8 2378typedef void (RETRO_CALLCONV *retro_perf_register_t)(struct retro_perf_counter *counter);
eae1ae02
A
2379
2380/* Starts a registered counter. */
6fbd15c8 2381typedef void (RETRO_CALLCONV *retro_perf_start_t)(struct retro_perf_counter *counter);
eae1ae02
A
2382
2383/* Stops a registered counter. */
6fbd15c8 2384typedef void (RETRO_CALLCONV *retro_perf_stop_t)(struct retro_perf_counter *counter);
779692e4 2385
eae1ae02
A
2386/* For convenience it can be useful to wrap register, start and stop in macros.
2387 * E.g.:
2388 * #ifdef LOG_PERFORMANCE
2389 * #define RETRO_PERFORMANCE_INIT(perf_cb, name) static struct retro_perf_counter name = {#name}; if (!name.registered) perf_cb.perf_register(&(name))
2390 * #define RETRO_PERFORMANCE_START(perf_cb, name) perf_cb.perf_start(&(name))
2391 * #define RETRO_PERFORMANCE_STOP(perf_cb, name) perf_cb.perf_stop(&(name))
2392 * #else
2393 * ... Blank macros ...
2394 * #endif
2395 *
2396 * These can then be used mid-functions around code snippets.
2397 *
2398 * extern struct retro_perf_callback perf_cb; * Somewhere in the core.
2399 *
2400 * void do_some_heavy_work(void)
2401 * {
2402 * RETRO_PERFORMANCE_INIT(cb, work_1;
2403 * RETRO_PERFORMANCE_START(cb, work_1);
2404 * heavy_work_1();
2405 * RETRO_PERFORMANCE_STOP(cb, work_1);
2406 *
2407 * RETRO_PERFORMANCE_INIT(cb, work_2);
2408 * RETRO_PERFORMANCE_START(cb, work_2);
2409 * heavy_work_2();
2410 * RETRO_PERFORMANCE_STOP(cb, work_2);
2411 * }
2412 *
2413 * void retro_deinit(void)
2414 * {
2415 * perf_cb.perf_log(); * Log all perf counters here for example.
2416 * }
2417 */
779692e4 2418
2419struct retro_perf_callback
2420{
2421 retro_perf_get_time_usec_t get_time_usec;
2422 retro_get_cpu_features_t get_cpu_features;
2423
2424 retro_perf_get_counter_t get_perf_counter;
2425 retro_perf_register_t perf_register;
2426 retro_perf_start_t perf_start;
2427 retro_perf_stop_t perf_stop;
2428 retro_perf_log_t perf_log;
2429};
2430
eae1ae02
A
2431/* FIXME: Document the sensor API and work out behavior.
2432 * It will be marked as experimental until then.
2433 */
779692e4 2434enum retro_sensor_action
2435{
2436 RETRO_SENSOR_ACCELEROMETER_ENABLE = 0,
2437 RETRO_SENSOR_ACCELEROMETER_DISABLE,
144493e8 2438 RETRO_SENSOR_GYROSCOPE_ENABLE,
2439 RETRO_SENSOR_GYROSCOPE_DISABLE,
2440 RETRO_SENSOR_ILLUMINANCE_ENABLE,
2441 RETRO_SENSOR_ILLUMINANCE_DISABLE,
779692e4 2442
2443 RETRO_SENSOR_DUMMY = INT_MAX
2444};
2445
eae1ae02
A
2446/* Id values for SENSOR types. */
2447#define RETRO_SENSOR_ACCELEROMETER_X 0
2448#define RETRO_SENSOR_ACCELEROMETER_Y 1
2449#define RETRO_SENSOR_ACCELEROMETER_Z 2
144493e8 2450#define RETRO_SENSOR_GYROSCOPE_X 3
2451#define RETRO_SENSOR_GYROSCOPE_Y 4
2452#define RETRO_SENSOR_GYROSCOPE_Z 5
2453#define RETRO_SENSOR_ILLUMINANCE 6
eae1ae02 2454
6fbd15c8 2455typedef bool (RETRO_CALLCONV *retro_set_sensor_state_t)(unsigned port,
eae1ae02
A
2456 enum retro_sensor_action action, unsigned rate);
2457
6fbd15c8 2458typedef float (RETRO_CALLCONV *retro_sensor_get_input_t)(unsigned port, unsigned id);
eae1ae02 2459
779692e4 2460struct retro_sensor_interface
2461{
2462 retro_set_sensor_state_t set_sensor_state;
eae1ae02 2463 retro_sensor_get_input_t get_sensor_input;
779692e4 2464};
779692e4 2465
2466enum retro_camera_buffer
2467{
2468 RETRO_CAMERA_BUFFER_OPENGL_TEXTURE = 0,
2469 RETRO_CAMERA_BUFFER_RAW_FRAMEBUFFER,
2470
2471 RETRO_CAMERA_BUFFER_DUMMY = INT_MAX
2472};
2473
eae1ae02 2474/* Starts the camera driver. Can only be called in retro_run(). */
6fbd15c8 2475typedef bool (RETRO_CALLCONV *retro_camera_start_t)(void);
eae1ae02
A
2476
2477/* Stops the camera driver. Can only be called in retro_run(). */
6fbd15c8 2478typedef void (RETRO_CALLCONV *retro_camera_stop_t)(void);
eae1ae02 2479
6fbd15c8 2480/* Callback which signals when the camera driver is initialized
eae1ae02
A
2481 * and/or deinitialized.
2482 * retro_camera_start_t can be called in initialized callback.
2483 */
6fbd15c8 2484typedef void (RETRO_CALLCONV *retro_camera_lifetime_status_t)(void);
eae1ae02
A
2485
2486/* A callback for raw framebuffer data. buffer points to an XRGB8888 buffer.
2487 * Width, height and pitch are similar to retro_video_refresh_t.
2488 * First pixel is top-left origin.
2489 */
6fbd15c8 2490typedef void (RETRO_CALLCONV *retro_camera_frame_raw_framebuffer_t)(const uint32_t *buffer,
eae1ae02
A
2491 unsigned width, unsigned height, size_t pitch);
2492
2493/* A callback for when OpenGL textures are used.
2494 *
2495 * texture_id is a texture owned by camera driver.
6fbd15c8 2496 * Its state or content should be considered immutable, except for things like
eae1ae02
A
2497 * texture filtering and clamping.
2498 *
2499 * texture_target is the texture target for the GL texture.
6fbd15c8 2500 * These can include e.g. GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE, and possibly
eae1ae02
A
2501 * more depending on extensions.
2502 *
6fbd15c8 2503 * affine points to a packed 3x3 column-major matrix used to apply an affine
eae1ae02 2504 * transform to texture coordinates. (affine_matrix * vec3(coord_x, coord_y, 1.0))
6fbd15c8 2505 * After transform, normalized texture coord (0, 0) should be bottom-left
eae1ae02
A
2506 * and (1, 1) should be top-right (or (width, height) for RECTANGLE).
2507 *
6fbd15c8 2508 * GL-specific typedefs are avoided here to avoid relying on gl.h in
eae1ae02
A
2509 * the API definition.
2510 */
6fbd15c8 2511typedef void (RETRO_CALLCONV *retro_camera_frame_opengl_texture_t)(unsigned texture_id,
eae1ae02
A
2512 unsigned texture_target, const float *affine);
2513
779692e4 2514struct retro_camera_callback
2515{
6fbd15c8 2516 /* Set by libretro core.
eae1ae02
A
2517 * Example bitmask: caps = (1 << RETRO_CAMERA_BUFFER_OPENGL_TEXTURE) | (1 << RETRO_CAMERA_BUFFER_RAW_FRAMEBUFFER).
2518 */
6fbd15c8 2519 uint64_t caps;
779692e4 2520
6fbd15c8 2521 /* Desired resolution for camera. Is only used as a hint. */
2522 unsigned width;
779692e4 2523 unsigned height;
6fbd15c8 2524
2525 /* Set by frontend. */
2526 retro_camera_start_t start;
2527 retro_camera_stop_t stop;
eae1ae02
A
2528
2529 /* Set by libretro core if raw framebuffer callbacks will be used. */
2530 retro_camera_frame_raw_framebuffer_t frame_raw_framebuffer;
6fbd15c8 2531
eae1ae02 2532 /* Set by libretro core if OpenGL texture callbacks will be used. */
6fbd15c8 2533 retro_camera_frame_opengl_texture_t frame_opengl_texture;
eae1ae02 2534
6fbd15c8 2535 /* Set by libretro core. Called after camera driver is initialized and
eae1ae02
A
2536 * ready to be started.
2537 * Can be NULL, in which this callback is not called.
2538 */
779692e4 2539 retro_camera_lifetime_status_t initialized;
2540
6fbd15c8 2541 /* Set by libretro core. Called right before camera driver is
eae1ae02
A
2542 * deinitialized.
2543 * Can be NULL, in which this callback is not called.
2544 */
779692e4 2545 retro_camera_lifetime_status_t deinitialized;
2546};
2547
6fbd15c8 2548/* Sets the interval of time and/or distance at which to update/poll
eae1ae02
A
2549 * location-based data.
2550 *
2551 * To ensure compatibility with all location-based implementations,
2552 * values for both interval_ms and interval_distance should be provided.
2553 *
2554 * interval_ms is the interval expressed in milliseconds.
2555 * interval_distance is the distance interval expressed in meters.
2556 */
6fbd15c8 2557typedef void (RETRO_CALLCONV *retro_location_set_interval_t)(unsigned interval_ms,
eae1ae02
A
2558 unsigned interval_distance);
2559
2560/* Start location services. The device will start listening for changes to the
6fbd15c8 2561 * current location at regular intervals (which are defined with
eae1ae02 2562 * retro_location_set_interval_t). */
6fbd15c8 2563typedef bool (RETRO_CALLCONV *retro_location_start_t)(void);
eae1ae02 2564
6fbd15c8 2565/* Stop location services. The device will stop listening for changes
eae1ae02 2566 * to the current location. */
6fbd15c8 2567typedef void (RETRO_CALLCONV *retro_location_stop_t)(void);
eae1ae02 2568
6fbd15c8 2569/* Get the position of the current location. Will set parameters to
eae1ae02 2570 * 0 if no new location update has happened since the last time. */
6fbd15c8 2571typedef bool (RETRO_CALLCONV *retro_location_get_position_t)(double *lat, double *lon,
eae1ae02
A
2572 double *horiz_accuracy, double *vert_accuracy);
2573
6fbd15c8 2574/* Callback which signals when the location driver is initialized
eae1ae02
A
2575 * and/or deinitialized.
2576 * retro_location_start_t can be called in initialized callback.
2577 */
6fbd15c8 2578typedef void (RETRO_CALLCONV *retro_location_lifetime_status_t)(void);
eae1ae02
A
2579
2580struct retro_location_callback
2581{
2582 retro_location_start_t start;
2583 retro_location_stop_t stop;
2584 retro_location_get_position_t get_position;
2585 retro_location_set_interval_t set_interval;
2586
2587 retro_location_lifetime_status_t initialized;
2588 retro_location_lifetime_status_t deinitialized;
2589};
2590
779692e4 2591enum retro_rumble_effect
2592{
2593 RETRO_RUMBLE_STRONG = 0,
2594 RETRO_RUMBLE_WEAK = 1,
2595
2596 RETRO_RUMBLE_DUMMY = INT_MAX
2597};
2598
6fbd15c8 2599/* Sets rumble state for joypad plugged in port 'port'.
eae1ae02
A
2600 * Rumble effects are controlled independently,
2601 * and setting e.g. strong rumble does not override weak rumble.
2602 * Strength has a range of [0, 0xffff].
2603 *
6fbd15c8 2604 * Returns true if rumble state request was honored.
eae1ae02 2605 * Calling this before first retro_run() is likely to return false. */
6fbd15c8 2606typedef bool (RETRO_CALLCONV *retro_set_rumble_state_t)(unsigned port,
eae1ae02
A
2607 enum retro_rumble_effect effect, uint16_t strength);
2608
779692e4 2609struct retro_rumble_interface
2610{
2611 retro_set_rumble_state_t set_rumble_state;
2612};
2613
eae1ae02 2614/* Notifies libretro that audio data should be written. */
6fbd15c8 2615typedef void (RETRO_CALLCONV *retro_audio_callback_t)(void);
779692e4 2616
6fbd15c8 2617/* True: Audio driver in frontend is active, and callback is
eae1ae02 2618 * expected to be called regularily.
6fbd15c8 2619 * False: Audio driver in frontend is paused or inactive.
2620 * Audio callback will not be called until set_state has been
eae1ae02
A
2621 * called with true.
2622 * Initial state is false (inactive).
2623 */
6fbd15c8 2624typedef void (RETRO_CALLCONV *retro_audio_set_state_callback_t)(bool enabled);
eae1ae02 2625
779692e4 2626struct retro_audio_callback
2627{
2628 retro_audio_callback_t callback;
2629 retro_audio_set_state_callback_t set_state;
2630};
2631
6fbd15c8 2632/* Notifies a libretro core of time spent since last invocation
eae1ae02
A
2633 * of retro_run() in microseconds.
2634 *
2635 * It will be called right before retro_run() every frame.
6fbd15c8 2636 * The frontend can tamper with timing to support cases like
eae1ae02
A
2637 * fast-forward, slow-motion and framestepping.
2638 *
2639 * In those scenarios the reference frame time value will be used. */
779692e4 2640typedef int64_t retro_usec_t;
6fbd15c8 2641typedef void (RETRO_CALLCONV *retro_frame_time_callback_t)(retro_usec_t usec);
779692e4 2642struct retro_frame_time_callback
2643{
2644 retro_frame_time_callback_t callback;
6fbd15c8 2645 /* Represents the time of one frame. It is computed as
2646 * 1000000 / fps, but the implementation will resolve the
eae1ae02
A
2647 * rounding to ensure that framestepping, etc is exact. */
2648 retro_usec_t reference;
779692e4 2649};
e56b1300 2650
270c6dd1 2651/* Notifies a libretro core of the current occupancy
2652 * level of the frontend audio buffer.
2653 *
2654 * - active: 'true' if audio buffer is currently
2655 * in use. Will be 'false' if audio is
2656 * disabled in the frontend
2657 *
2658 * - occupancy: Given as a value in the range [0,100],
2659 * corresponding to the occupancy percentage
2660 * of the audio buffer
2661 *
2662 * - underrun_likely: 'true' if the frontend expects an
2663 * audio buffer underrun during the
2664 * next frame (indicates that a core
2665 * should attempt frame skipping)
2666 *
2667 * It will be called right before retro_run() every frame. */
2668typedef void (RETRO_CALLCONV *retro_audio_buffer_status_callback_t)(
2669 bool active, unsigned occupancy, bool underrun_likely);
2670struct retro_audio_buffer_status_callback
2671{
2672 retro_audio_buffer_status_callback_t callback;
2673};
2674
eae1ae02
A
2675/* Pass this to retro_video_refresh_t if rendering to hardware.
2676 * Passing NULL to retro_video_refresh_t is still a frame dupe as normal.
2677 * */
e56b1300 2678#define RETRO_HW_FRAME_BUFFER_VALID ((void*)-1)
2679
eae1ae02
A
2680/* Invalidates the current HW context.
2681 * Any GL state is lost, and must not be deinitialized explicitly.
2682 * If explicit deinitialization is desired by the libretro core,
2683 * it should implement context_destroy callback.
2684 * If called, all GPU resources must be reinitialized.
2685 * Usually called when frontend reinits video driver.
6fbd15c8 2686 * Also called first time video driver is initialized,
eae1ae02
A
2687 * allowing libretro core to initialize resources.
2688 */
6fbd15c8 2689typedef void (RETRO_CALLCONV *retro_hw_context_reset_t)(void);
eae1ae02
A
2690
2691/* Gets current framebuffer which is to be rendered to.
2692 * Could change every frame potentially.
2693 */
6fbd15c8 2694typedef uintptr_t (RETRO_CALLCONV *retro_hw_get_current_framebuffer_t)(void);
e56b1300 2695
eae1ae02 2696/* Get a symbol from HW context. */
6fbd15c8 2697typedef retro_proc_address_t (RETRO_CALLCONV *retro_hw_get_proc_address_t)(const char *sym);
e56b1300 2698
2699enum retro_hw_context_type
2700{
eae1ae02
A
2701 RETRO_HW_CONTEXT_NONE = 0,
2702 /* OpenGL 2.x. Driver can choose to use latest compatibility context. */
6fbd15c8 2703 RETRO_HW_CONTEXT_OPENGL = 1,
eae1ae02
A
2704 /* OpenGL ES 2.0. */
2705 RETRO_HW_CONTEXT_OPENGLES2 = 2,
2706 /* Modern desktop core GL context. Use version_major/
2707 * version_minor fields to set GL version. */
2708 RETRO_HW_CONTEXT_OPENGL_CORE = 3,
2709 /* OpenGL ES 3.0 */
2710 RETRO_HW_CONTEXT_OPENGLES3 = 4,
2711 /* OpenGL ES 3.1+. Set version_major/version_minor. For GLES2 and GLES3,
2712 * use the corresponding enums directly. */
2713 RETRO_HW_CONTEXT_OPENGLES_VERSION = 5,
e56b1300 2714
65a0505f
FJGG
2715 /* Vulkan, see RETRO_ENVIRONMENT_GET_HW_RENDER_INTERFACE. */
2716 RETRO_HW_CONTEXT_VULKAN = 6,
2717
6fbd15c8 2718 /* Direct3D, set version_major to select the type of interface
2719 * returned by RETRO_ENVIRONMENT_GET_HW_RENDER_INTERFACE */
2720 RETRO_HW_CONTEXT_DIRECT3D = 7,
2721
e56b1300 2722 RETRO_HW_CONTEXT_DUMMY = INT_MAX
2723};
23ea11bd 2724
e56b1300 2725struct retro_hw_render_callback
2726{
eae1ae02
A
2727 /* Which API to use. Set by libretro core. */
2728 enum retro_hw_context_type context_type;
2729
2730 /* Called when a context has been created or when it has been reset.
2731 * An OpenGL context is only valid after context_reset() has been called.
2732 *
6fbd15c8 2733 * When context_reset is called, OpenGL resources in the libretro
eae1ae02
A
2734 * implementation are guaranteed to be invalid.
2735 *
6fbd15c8 2736 * It is possible that context_reset is called multiple times during an
eae1ae02
A
2737 * application lifecycle.
2738 * If context_reset is called without any notification (context_destroy),
2739 * the OpenGL context was lost and resources should just be recreated
2740 * without any attempt to "free" old resources.
2741 */
2742 retro_hw_context_reset_t context_reset;
2743
65a0505f
FJGG
2744 /* Set by frontend.
2745 * TODO: This is rather obsolete. The frontend should not
2746 * be providing preallocated framebuffers. */
eae1ae02
A
2747 retro_hw_get_current_framebuffer_t get_current_framebuffer;
2748
6fbd15c8 2749 /* Set by frontend.
2750 * Can return all relevant functions, including glClear on Windows. */
eae1ae02
A
2751 retro_hw_get_proc_address_t get_proc_address;
2752
65a0505f
FJGG
2753 /* Set if render buffers should have depth component attached.
2754 * TODO: Obsolete. */
eae1ae02
A
2755 bool depth;
2756
65a0505f
FJGG
2757 /* Set if stencil buffers should be attached.
2758 * TODO: Obsolete. */
eae1ae02
A
2759 bool stencil;
2760
6fbd15c8 2761 /* If depth and stencil are true, a packed 24/8 buffer will be added.
eae1ae02
A
2762 * Only attaching stencil is invalid and will be ignored. */
2763
6fbd15c8 2764 /* Use conventional bottom-left origin convention. If false,
65a0505f
FJGG
2765 * standard libretro top-left origin semantics are used.
2766 * TODO: Move to GL specific interface. */
eae1ae02 2767 bool bottom_left_origin;
6fbd15c8 2768
eae1ae02
A
2769 /* Major version number for core GL context or GLES 3.1+. */
2770 unsigned version_major;
2771
2772 /* Minor version number for core GL context or GLES 3.1+. */
2773 unsigned version_minor;
2774
6fbd15c8 2775 /* If this is true, the frontend will go very far to avoid
eae1ae02 2776 * resetting context in scenarios like toggling fullscreen, etc.
65a0505f 2777 * TODO: Obsolete? Maybe frontend should just always assume this ...
eae1ae02
A
2778 */
2779 bool cache_context;
2780
6fbd15c8 2781 /* The reset callback might still be called in extreme situations
eae1ae02
A
2782 * such as if the context is lost beyond recovery.
2783 *
6fbd15c8 2784 * For optimal stability, set this to false, and allow context to be
eae1ae02
A
2785 * reset at any time.
2786 */
6fbd15c8 2787
2788 /* A callback to be called before the context is destroyed in a
eae1ae02
A
2789 * controlled way by the frontend. */
2790 retro_hw_context_reset_t context_destroy;
2791
2792 /* OpenGL resources can be deinitialized cleanly at this step.
6fbd15c8 2793 * context_destroy can be set to NULL, in which resources will
eae1ae02
A
2794 * just be destroyed without any notification.
2795 *
6fbd15c8 2796 * Even when context_destroy is non-NULL, it is possible that
eae1ae02 2797 * context_reset is called without any destroy notification.
6fbd15c8 2798 * This happens if context is lost by external factors (such as
eae1ae02
A
2799 * notified by GL_ARB_robustness).
2800 *
2801 * In this case, the context is assumed to be already dead,
6fbd15c8 2802 * and the libretro implementation must not try to free any OpenGL
eae1ae02
A
2803 * resources in the subsequent context_reset.
2804 */
2805
2806 /* Creates a debug context. */
2807 bool debug_context;
e56b1300 2808};
c19aba43 2809
6fbd15c8 2810/* Callback type passed in RETRO_ENVIRONMENT_SET_KEYBOARD_CALLBACK.
eae1ae02
A
2811 * Called by the frontend in response to keyboard events.
2812 * down is set if the key is being pressed, or false if it is being released.
2813 * keycode is the RETROK value of the char.
2814 * character is the text character of the pressed key. (UTF-32).
2815 * key_modifiers is a set of RETROKMOD values or'ed together.
2816 *
2817 * The pressed/keycode state can be indepedent of the character.
6fbd15c8 2818 * It is also possible that multiple characters are generated from a
eae1ae02
A
2819 * single keypress.
2820 * Keycode events should be treated separately from character events.
2821 * However, when possible, the frontend should try to synchronize these.
2822 * If only a character is posted, keycode should be RETROK_UNKNOWN.
2823 *
6fbd15c8 2824 * Similarily if only a keycode event is generated with no corresponding
eae1ae02
A
2825 * character, character should be 0.
2826 */
6fbd15c8 2827typedef void (RETRO_CALLCONV *retro_keyboard_event_t)(bool down, unsigned keycode,
eae1ae02 2828 uint32_t character, uint16_t key_modifiers);
23ea11bd 2829
2830struct retro_keyboard_callback
2831{
6b5beb44 2832 retro_keyboard_event_t callback;
23ea11bd 2833};
2834
144493e8 2835/* Callbacks for RETRO_ENVIRONMENT_SET_DISK_CONTROL_INTERFACE &
2836 * RETRO_ENVIRONMENT_SET_DISK_CONTROL_EXT_INTERFACE.
6fbd15c8 2837 * Should be set for implementations which can swap out multiple disk
eae1ae02
A
2838 * images in runtime.
2839 *
2840 * If the implementation can do this automatically, it should strive to do so.
2841 * However, there are cases where the user must manually do so.
2842 *
6fbd15c8 2843 * Overview: To swap a disk image, eject the disk image with
eae1ae02 2844 * set_eject_state(true).
6fbd15c8 2845 * Set the disk index with set_image_index(index). Insert the disk again
eae1ae02
A
2846 * with set_eject_state(false).
2847 */
23ea11bd 2848
eae1ae02
A
2849/* If ejected is true, "ejects" the virtual disk tray.
2850 * When ejected, the disk image index can be set.
2851 */
6fbd15c8 2852typedef bool (RETRO_CALLCONV *retro_set_eject_state_t)(bool ejected);
eae1ae02
A
2853
2854/* Gets current eject state. The initial state is 'not ejected'. */
6fbd15c8 2855typedef bool (RETRO_CALLCONV *retro_get_eject_state_t)(void);
eae1ae02
A
2856
2857/* Gets current disk index. First disk is index 0.
2858 * If return value is >= get_num_images(), no disk is currently inserted.
2859 */
6fbd15c8 2860typedef unsigned (RETRO_CALLCONV *retro_get_image_index_t)(void);
eae1ae02
A
2861
2862/* Sets image index. Can only be called when disk is ejected.
6fbd15c8 2863 * The implementation supports setting "no disk" by using an
eae1ae02
A
2864 * index >= get_num_images().
2865 */
6fbd15c8 2866typedef bool (RETRO_CALLCONV *retro_set_image_index_t)(unsigned index);
eae1ae02
A
2867
2868/* Gets total number of images which are available to use. */
6fbd15c8 2869typedef unsigned (RETRO_CALLCONV *retro_get_num_images_t)(void);
eae1ae02 2870
23ea11bd 2871struct retro_game_info;
eae1ae02
A
2872
2873/* Replaces the disk image associated with index.
2874 * Arguments to pass in info have same requirements as retro_load_game().
2875 * Virtual disk tray must be ejected when calling this.
2876 *
6fbd15c8 2877 * Replacing a disk image with info = NULL will remove the disk image
eae1ae02
A
2878 * from the internal list.
2879 * As a result, calls to get_image_index() can change.
2880 *
6fbd15c8 2881 * E.g. replace_image_index(1, NULL), and previous get_image_index()
eae1ae02
A
2882 * returned 4 before.
2883 * Index 1 will be removed, and the new index is 3.
2884 */
6fbd15c8 2885typedef bool (RETRO_CALLCONV *retro_replace_image_index_t)(unsigned index,
eae1ae02
A
2886 const struct retro_game_info *info);
2887
2888/* Adds a new valid index (get_num_images()) to the internal disk list.
2889 * This will increment subsequent return values from get_num_images() by 1.
6fbd15c8 2890 * This image index cannot be used until a disk image has been set
eae1ae02 2891 * with replace_image_index. */
6fbd15c8 2892typedef bool (RETRO_CALLCONV *retro_add_image_index_t)(void);
23ea11bd 2893
144493e8 2894/* Sets initial image to insert in drive when calling
2895 * core_load_game().
2896 * Since we cannot pass the initial index when loading
2897 * content (this would require a major API change), this
2898 * is set by the frontend *before* calling the core's
2899 * retro_load_game()/retro_load_game_special() implementation.
2900 * A core should therefore cache the index/path values and handle
2901 * them inside retro_load_game()/retro_load_game_special().
2902 * - If 'index' is invalid (index >= get_num_images()), the
2903 * core should ignore the set value and instead use 0
2904 * - 'path' is used purely for error checking - i.e. when
2905 * content is loaded, the core should verify that the
2906 * disk specified by 'index' has the specified file path.
2907 * This is to guard against auto selecting the wrong image
2908 * if (for example) the user should modify an existing M3U
2909 * playlist. We have to let the core handle this because
2910 * set_initial_image() must be called before loading content,
2911 * i.e. the frontend cannot access image paths in advance
2912 * and thus cannot perform the error check itself.
2913 * If set path and content path do not match, the core should
2914 * ignore the set 'index' value and instead use 0
2915 * Returns 'false' if index or 'path' are invalid, or core
2916 * does not support this functionality
2917 */
2918typedef bool (RETRO_CALLCONV *retro_set_initial_image_t)(unsigned index, const char *path);
2919
2920/* Fetches the path of the specified disk image file.
2921 * Returns 'false' if index is invalid (index >= get_num_images())
2922 * or path is otherwise unavailable.
2923 */
2924typedef bool (RETRO_CALLCONV *retro_get_image_path_t)(unsigned index, char *path, size_t len);
2925
2926/* Fetches a core-provided 'label' for the specified disk
2927 * image file. In the simplest case this may be a file name
2928 * (without extension), but for cores with more complex
2929 * content requirements information may be provided to
2930 * facilitate user disk swapping - for example, a core
2931 * running floppy-disk-based content may uniquely label
2932 * save disks, data disks, level disks, etc. with names
2933 * corresponding to in-game disk change prompts (so the
2934 * frontend can provide better user guidance than a 'dumb'
2935 * disk index value).
2936 * Returns 'false' if index is invalid (index >= get_num_images())
2937 * or label is otherwise unavailable.
2938 */
2939typedef bool (RETRO_CALLCONV *retro_get_image_label_t)(unsigned index, char *label, size_t len);
2940
23ea11bd 2941struct retro_disk_control_callback
2942{
2943 retro_set_eject_state_t set_eject_state;
2944 retro_get_eject_state_t get_eject_state;
2945
2946 retro_get_image_index_t get_image_index;
2947 retro_set_image_index_t set_image_index;
2948 retro_get_num_images_t get_num_images;
2949
2950 retro_replace_image_index_t replace_image_index;
2951 retro_add_image_index_t add_image_index;
2952};
38c2028e 2953
144493e8 2954struct retro_disk_control_ext_callback
2955{
2956 retro_set_eject_state_t set_eject_state;
2957 retro_get_eject_state_t get_eject_state;
2958
2959 retro_get_image_index_t get_image_index;
2960 retro_set_image_index_t set_image_index;
2961 retro_get_num_images_t get_num_images;
2962
2963 retro_replace_image_index_t replace_image_index;
2964 retro_add_image_index_t add_image_index;
2965
2966 /* NOTE: Frontend will only attempt to record/restore
2967 * last used disk index if both set_initial_image()
2968 * and get_image_path() are implemented */
2969 retro_set_initial_image_t set_initial_image; /* Optional - may be NULL */
2970
2971 retro_get_image_path_t get_image_path; /* Optional - may be NULL */
2972 retro_get_image_label_t get_image_label; /* Optional - may be NULL */
2973};
2974
38c2028e 2975enum retro_pixel_format
2976{
eae1ae02
A
2977 /* 0RGB1555, native endian.
2978 * 0 bit must be set to 0.
2979 * This pixel format is default for compatibility concerns only.
2980 * If a 15/16-bit pixel format is desired, consider using RGB565. */
c19aba43
TK
2981 RETRO_PIXEL_FORMAT_0RGB1555 = 0,
2982
eae1ae02
A
2983 /* XRGB8888, native endian.
2984 * X bits are ignored. */
c19aba43
TK
2985 RETRO_PIXEL_FORMAT_XRGB8888 = 1,
2986
eae1ae02
A
2987 /* RGB565, native endian.
2988 * This pixel format is the recommended format to use if a 15/16-bit
6fbd15c8 2989 * format is desired as it is the pixel format that is typically
eae1ae02
A
2990 * available on a wide range of low-power devices.
2991 *
2992 * It is also natively supported in APIs like OpenGL ES. */
c19aba43
TK
2993 RETRO_PIXEL_FORMAT_RGB565 = 2,
2994
eae1ae02 2995 /* Ensure sizeof() == sizeof(int). */
c19aba43 2996 RETRO_PIXEL_FORMAT_UNKNOWN = INT_MAX
38c2028e 2997};
2998
2999struct retro_message
3000{
eae1ae02
A
3001 const char *msg; /* Message to be displayed. */
3002 unsigned frames; /* Duration in frames of message. */
38c2028e 3003};
3004
8a60e610 3005enum retro_message_target
3006{
3007 RETRO_MESSAGE_TARGET_ALL = 0,
3008 RETRO_MESSAGE_TARGET_OSD,
3009 RETRO_MESSAGE_TARGET_LOG
3010};
3011
3012enum retro_message_type
3013{
3014 RETRO_MESSAGE_TYPE_NOTIFICATION = 0,
3015 RETRO_MESSAGE_TYPE_NOTIFICATION_ALT,
3016 RETRO_MESSAGE_TYPE_STATUS,
3017 RETRO_MESSAGE_TYPE_PROGRESS
3018};
3019
3020struct retro_message_ext
3021{
3022 /* Message string to be displayed/logged */
3023 const char *msg;
3024 /* Duration (in ms) of message when targeting the OSD */
3025 unsigned duration;
3026 /* Message priority when targeting the OSD
3027 * > When multiple concurrent messages are sent to
3028 * the frontend and the frontend does not have the
3029 * capacity to display them all, messages with the
3030 * *highest* priority value should be shown
3031 * > There is no upper limit to a message priority
3032 * value (within the bounds of the unsigned data type)
3033 * > In the reference frontend (RetroArch), the same
3034 * priority values are used for frontend-generated
3035 * notifications, which are typically assigned values
3036 * between 0 and 3 depending upon importance */
3037 unsigned priority;
3038 /* Message logging level (info, warn, error, etc.) */
3039 enum retro_log_level level;
3040 /* Message destination: OSD, logging interface or both */
3041 enum retro_message_target target;
3042 /* Message 'type' when targeting the OSD
3043 * > RETRO_MESSAGE_TYPE_NOTIFICATION: Specifies that a
3044 * message should be handled in identical fashion to
3045 * a standard frontend-generated notification
3046 * > RETRO_MESSAGE_TYPE_NOTIFICATION_ALT: Specifies that
3047 * message is a notification that requires user attention
3048 * or action, but that it should be displayed in a manner
3049 * that differs from standard frontend-generated notifications.
3050 * This would typically correspond to messages that should be
3051 * displayed immediately (independently from any internal
3052 * frontend message queue), and/or which should be visually
3053 * distinguishable from frontend-generated notifications.
3054 * For example, a core may wish to inform the user of
3055 * information related to a disk-change event. It is
3056 * expected that the frontend itself may provide a
3057 * notification in this case; if the core sends a
3058 * message of type RETRO_MESSAGE_TYPE_NOTIFICATION, an
3059 * uncomfortable 'double-notification' may occur. A message
3060 * of RETRO_MESSAGE_TYPE_NOTIFICATION_ALT should therefore
3061 * be presented such that visual conflict with regular
3062 * notifications does not occur
3063 * > RETRO_MESSAGE_TYPE_STATUS: Indicates that message
3064 * is not a standard notification. This typically
3065 * corresponds to 'status' indicators, such as a core's
3066 * internal FPS, which are intended to be displayed
3067 * either permanently while a core is running, or in
3068 * a manner that does not suggest user attention or action
3069 * is required. 'Status' type messages should therefore be
3070 * displayed in a different on-screen location and in a manner
3071 * easily distinguishable from both standard frontend-generated
3072 * notifications and messages of type RETRO_MESSAGE_TYPE_NOTIFICATION_ALT
3073 * > RETRO_MESSAGE_TYPE_PROGRESS: Indicates that message reports
3074 * the progress of an internal core task. For example, in cases
3075 * where a core itself handles the loading of content from a file,
3076 * this may correspond to the percentage of the file that has been
3077 * read. Alternatively, an audio/video playback core may use a
3078 * message of type RETRO_MESSAGE_TYPE_PROGRESS to display the current
3079 * playback position as a percentage of the runtime. 'Progress' type
3080 * messages should therefore be displayed as a literal progress bar,
3081 * where:
3082 * - 'retro_message_ext.msg' is the progress bar title/label
3083 * - 'retro_message_ext.progress' determines the length of
3084 * the progress bar
3085 * NOTE: Message type is a *hint*, and may be ignored
3086 * by the frontend. If a frontend lacks support for
3087 * displaying messages via alternate means than standard
3088 * frontend-generated notifications, it will treat *all*
3089 * messages as having the type RETRO_MESSAGE_TYPE_NOTIFICATION */
3090 enum retro_message_type type;
3091 /* Task progress when targeting the OSD and message is
3092 * of type RETRO_MESSAGE_TYPE_PROGRESS
3093 * > -1: Unmetered/indeterminate
3094 * > 0-100: Current progress percentage
3095 * NOTE: Since message type is a hint, a frontend may ignore
3096 * progress values. Where relevant, a core should therefore
3097 * include progress percentage within the message string,
3098 * such that the message intent remains clear when displayed
3099 * as a standard frontend-generated notification */
3100 int8_t progress;
3101};
3102
eae1ae02
A
3103/* Describes how the libretro implementation maps a libretro input bind
3104 * to its internal input system through a human readable string.
3105 * This string can be used to better let a user configure input. */
c19aba43
TK
3106struct retro_input_descriptor
3107{
eae1ae02 3108 /* Associates given parameters with a description. */
c19aba43
TK
3109 unsigned port;
3110 unsigned device;
3111 unsigned index;
3112 unsigned id;
3113
eae1ae02
A
3114 /* Human readable description for parameters.
3115 * The pointer must remain valid until
3116 * retro_unload_game() is called. */
6fbd15c8 3117 const char *description;
c19aba43
TK
3118};
3119
38c2028e 3120struct retro_system_info
3121{
6fbd15c8 3122 /* All pointers are owned by libretro implementation, and pointers must
270c6dd1 3123 * remain valid until it is unloaded. */
eae1ae02 3124
6fbd15c8 3125 const char *library_name; /* Descriptive name of library. Should not
eae1ae02
A
3126 * contain any version numbers, etc. */
3127 const char *library_version; /* Descriptive version of core. */
3128
6fbd15c8 3129 const char *valid_extensions; /* A string listing probably content
3130 * extensions the core will be able to
eae1ae02
A
3131 * load, separated with pipe.
3132 * I.e. "bin|rom|iso".
6fbd15c8 3133 * Typically used for a GUI to filter
eae1ae02
A
3134 * out extensions. */
3135
6fbd15c8 3136 /* Libretro cores that need to have direct access to their content
3137 * files, including cores which use the path of the content files to
3138 * determine the paths of other files, should set need_fullpath to true.
3139 *
3140 * Cores should strive for setting need_fullpath to false,
3141 * as it allows the frontend to perform patching, etc.
eae1ae02 3142 *
6fbd15c8 3143 * If need_fullpath is true and retro_load_game() is called:
3144 * - retro_game_info::path is guaranteed to have a valid path
3145 * - retro_game_info::data and retro_game_info::size are invalid
eae1ae02 3146 *
6fbd15c8 3147 * If need_fullpath is false and retro_load_game() is called:
3148 * - retro_game_info::path may be NULL
3149 * - retro_game_info::data and retro_game_info::size are guaranteed
3150 * to be valid
3151 *
3152 * See also:
3153 * - RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY
3154 * - RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY
3155 */
3156 bool need_fullpath;
eae1ae02 3157
6fbd15c8 3158 /* If true, the frontend is not allowed to extract any archives before
eae1ae02 3159 * loading the real content.
6fbd15c8 3160 * Necessary for certain libretro implementations that load games
eae1ae02 3161 * from zipped archives. */
6fbd15c8 3162 bool block_extract;
38c2028e 3163};
3164
f3c6ae10 3165/* Defines overrides which modify frontend handling of
3166 * specific content file types.
3167 * An array of retro_system_content_info_override is
3168 * passed to RETRO_ENVIRONMENT_SET_CONTENT_INFO_OVERRIDE
3169 * NOTE: In the following descriptions, references to
3170 * retro_load_game() may be replaced with
3171 * retro_load_game_special() */
3172struct retro_system_content_info_override
3173{
3174 /* A list of file extensions for which the override
3175 * should apply, delimited by a 'pipe' character
3176 * (e.g. "md|sms|gg")
3177 * Permitted file extensions are limited to those
3178 * included in retro_system_info::valid_extensions
3179 * and/or retro_subsystem_rom_info::valid_extensions */
3180 const char *extensions;
3181
3182 /* Overrides the need_fullpath value set in
3183 * retro_system_info and/or retro_subsystem_rom_info.
3184 * To reiterate:
3185 *
3186 * If need_fullpath is true and retro_load_game() is called:
3187 * - retro_game_info::path is guaranteed to contain a valid
3188 * path to an existent file
3189 * - retro_game_info::data and retro_game_info::size are invalid
3190 *
3191 * If need_fullpath is false and retro_load_game() is called:
3192 * - retro_game_info::path may be NULL
3193 * - retro_game_info::data and retro_game_info::size are guaranteed
3194 * to be valid
3195 *
3196 * In addition:
3197 *
3198 * If need_fullpath is true and retro_load_game() is called:
3199 * - retro_game_info_ext::full_path is guaranteed to contain a valid
3200 * path to an existent file
3201 * - retro_game_info_ext::archive_path may be NULL
3202 * - retro_game_info_ext::archive_file may be NULL
3203 * - retro_game_info_ext::dir is guaranteed to contain a valid path
3204 * to the directory in which the content file exists
3205 * - retro_game_info_ext::name is guaranteed to contain the
3206 * basename of the content file, without extension
3207 * - retro_game_info_ext::ext is guaranteed to contain the
3208 * extension of the content file in lower case format
3209 * - retro_game_info_ext::data and retro_game_info_ext::size
3210 * are invalid
3211 *
3212 * If need_fullpath is false and retro_load_game() is called:
3213 * - If retro_game_info_ext::file_in_archive is false:
3214 * - retro_game_info_ext::full_path is guaranteed to contain
3215 * a valid path to an existent file
3216 * - retro_game_info_ext::archive_path may be NULL
3217 * - retro_game_info_ext::archive_file may be NULL
3218 * - retro_game_info_ext::dir is guaranteed to contain a
3219 * valid path to the directory in which the content file exists
3220 * - retro_game_info_ext::name is guaranteed to contain the
3221 * basename of the content file, without extension
3222 * - retro_game_info_ext::ext is guaranteed to contain the
3223 * extension of the content file in lower case format
3224 * - If retro_game_info_ext::file_in_archive is true:
3225 * - retro_game_info_ext::full_path may be NULL
3226 * - retro_game_info_ext::archive_path is guaranteed to
3227 * contain a valid path to an existent compressed file
3228 * inside which the content file is located
3229 * - retro_game_info_ext::archive_file is guaranteed to
3230 * contain a valid path to an existent content file
3231 * inside the compressed file referred to by
3232 * retro_game_info_ext::archive_path
3233 * e.g. for a compressed file '/path/to/foo.zip'
3234 * containing 'bar.sfc'
3235 * > retro_game_info_ext::archive_path will be '/path/to/foo.zip'
3236 * > retro_game_info_ext::archive_file will be 'bar.sfc'
3237 * - retro_game_info_ext::dir is guaranteed to contain a
3238 * valid path to the directory in which the compressed file
3239 * (containing the content file) exists
3240 * - retro_game_info_ext::name is guaranteed to contain
3241 * EITHER
3242 * 1) the basename of the compressed file (containing
3243 * the content file), without extension
3244 * OR
3245 * 2) the basename of the content file inside the
3246 * compressed file, without extension
3247 * In either case, a core should consider 'name' to
3248 * be the canonical name/ID of the the content file
3249 * - retro_game_info_ext::ext is guaranteed to contain the
3250 * extension of the content file inside the compressed file,
3251 * in lower case format
3252 * - retro_game_info_ext::data and retro_game_info_ext::size are
3253 * guaranteed to be valid */
3254 bool need_fullpath;
3255
3256 /* If need_fullpath is false, specifies whether the content
3257 * data buffer available in retro_load_game() is 'persistent'
3258 *
3259 * If persistent_data is false and retro_load_game() is called:
3260 * - retro_game_info::data and retro_game_info::size
3261 * are valid only until retro_load_game() returns
3262 * - retro_game_info_ext::data and retro_game_info_ext::size
3263 * are valid only until retro_load_game() returns
3264 *
3265 * If persistent_data is true and retro_load_game() is called:
3266 * - retro_game_info::data and retro_game_info::size
3267 * are valid until retro_deinit() returns
3268 * - retro_game_info_ext::data and retro_game_info_ext::size
3269 * are valid until retro_deinit() returns */
3270 bool persistent_data;
3271};
3272
3273/* Similar to retro_game_info, but provides extended
3274 * information about the source content file and
3275 * game memory buffer status.
3276 * And array of retro_game_info_ext is returned by
3277 * RETRO_ENVIRONMENT_GET_GAME_INFO_EXT
3278 * NOTE: In the following descriptions, references to
3279 * retro_load_game() may be replaced with
3280 * retro_load_game_special() */
3281struct retro_game_info_ext
3282{
3283 /* - If file_in_archive is false, contains a valid
3284 * path to an existent content file (UTF-8 encoded)
3285 * - If file_in_archive is true, may be NULL */
3286 const char *full_path;
3287
3288 /* - If file_in_archive is false, may be NULL
3289 * - If file_in_archive is true, contains a valid path
3290 * to an existent compressed file inside which the
3291 * content file is located (UTF-8 encoded) */
3292 const char *archive_path;
3293
3294 /* - If file_in_archive is false, may be NULL
3295 * - If file_in_archive is true, contain a valid path
3296 * to an existent content file inside the compressed
3297 * file referred to by archive_path (UTF-8 encoded)
3298 * e.g. for a compressed file '/path/to/foo.zip'
3299 * containing 'bar.sfc'
3300 * > archive_path will be '/path/to/foo.zip'
3301 * > archive_file will be 'bar.sfc' */
3302 const char *archive_file;
3303
3304 /* - If file_in_archive is false, contains a valid path
3305 * to the directory in which the content file exists
3306 * (UTF-8 encoded)
3307 * - If file_in_archive is true, contains a valid path
3308 * to the directory in which the compressed file
3309 * (containing the content file) exists (UTF-8 encoded) */
3310 const char *dir;
3311
3312 /* Contains the canonical name/ID of the content file
3313 * (UTF-8 encoded). Intended for use when identifying
3314 * 'complementary' content named after the loaded file -
3315 * i.e. companion data of a different format (a CD image
3316 * required by a ROM), texture packs, internally handled
3317 * save files, etc.
3318 * - If file_in_archive is false, contains the basename
3319 * of the content file, without extension
3320 * - If file_in_archive is true, then string is
3321 * implementation specific. A frontend may choose to
3322 * set a name value of:
3323 * EITHER
3324 * 1) the basename of the compressed file (containing
3325 * the content file), without extension
3326 * OR
3327 * 2) the basename of the content file inside the
3328 * compressed file, without extension
3329 * RetroArch sets the 'name' value according to (1).
3330 * A frontend that supports routine loading of
3331 * content from archives containing multiple unrelated
3332 * content files may set the 'name' value according
3333 * to (2). */
3334 const char *name;
3335
3336 /* - If file_in_archive is false, contains the extension
3337 * of the content file in lower case format
3338 * - If file_in_archive is true, contains the extension
3339 * of the content file inside the compressed file,
3340 * in lower case format */
3341 const char *ext;
3342
3343 /* String of implementation specific meta-data. */
3344 const char *meta;
3345
3346 /* Memory buffer of loaded game content. Will be NULL:
3347 * IF
3348 * - retro_system_info::need_fullpath is true and
3349 * retro_system_content_info_override::need_fullpath
3350 * is unset
3351 * OR
3352 * - retro_system_content_info_override::need_fullpath
3353 * is true */
3354 const void *data;
3355
3356 /* Size of game content memory buffer, in bytes */
3357 size_t size;
3358
3359 /* True if loaded content file is inside a compressed
3360 * archive */
3361 bool file_in_archive;
3362
3363 /* - If data is NULL, value is unset/ignored
3364 * - If data is non-NULL:
3365 * - If persistent_data is false, data and size are
3366 * valid only until retro_load_game() returns
3367 * - If persistent_data is true, data and size are
3368 * are valid until retro_deinit() returns */
3369 bool persistent_data;
3370};
3371
38c2028e 3372struct retro_game_geometry
3373{
eae1ae02
A
3374 unsigned base_width; /* Nominal video width of game. */
3375 unsigned base_height; /* Nominal video height of game. */
3376 unsigned max_width; /* Maximum possible width of game. */
3377 unsigned max_height; /* Maximum possible height of game. */
3378
3379 float aspect_ratio; /* Nominal aspect ratio of game. If
3380 * aspect_ratio is <= 0.0, an aspect ratio
3381 * of base_width / base_height is assumed.
3382 * A frontend could override this setting,
3383 * if desired. */
38c2028e 3384};
3385
3386struct retro_system_timing
3387{
eae1ae02
A
3388 double fps; /* FPS of video content. */
3389 double sample_rate; /* Sampling rate of audio. */
38c2028e 3390};
3391
3392struct retro_system_av_info
3393{
3394 struct retro_game_geometry geometry;
3395 struct retro_system_timing timing;
3396};
3397
3398struct retro_variable
3399{
eae1ae02 3400 /* Variable to query in RETRO_ENVIRONMENT_GET_VARIABLE.
6fbd15c8 3401 * If NULL, obtains the complete environment string if more
eae1ae02 3402 * complex parsing is necessary.
6fbd15c8 3403 * The environment string is formatted as key-value pairs
eae1ae02
A
3404 * delimited by semicolons as so:
3405 * "key1=value1;key2=value2;..."
3406 */
3407 const char *key;
6fbd15c8 3408
eae1ae02
A
3409 /* Value to be obtained. If key does not exist, it is set to NULL. */
3410 const char *value;
38c2028e 3411};
3412
919cac88 3413struct retro_core_option_display
3414{
3415 /* Variable to configure in RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY */
3416 const char *key;
3417
3418 /* Specifies whether variable should be displayed
3419 * when presenting core options to the user */
3420 bool visible;
3421};
3422
3423/* Maximum number of values permitted for a core option
fbe06628 3424 * > Note: We have to set a maximum value due the limitations
3425 * of the C language - i.e. it is not possible to create an
3426 * array of structs each containing a variable sized array,
3427 * so the retro_core_option_definition values array must
3428 * have a fixed size. The size limit of 128 is a balancing
3429 * act - it needs to be large enough to support all 'sane'
3430 * core options, but setting it too large may impact low memory
3431 * platforms. In practise, if a core option has more than
3432 * 128 values then the implementation is likely flawed.
3433 * To quote the above API reference:
3434 * "The number of possible options should be very limited
3435 * i.e. it should be feasible to cycle through options
3436 * without a keyboard."
3437 */
919cac88 3438#define RETRO_NUM_CORE_OPTION_VALUES_MAX 128
3439
3440struct retro_core_option_value
3441{
3442 /* Expected option value */
3443 const char *value;
3444
3445 /* Human-readable value label. If NULL, value itself
3446 * will be displayed by the frontend */
3447 const char *label;
3448};
3449
3450struct retro_core_option_definition
3451{
3452 /* Variable to query in RETRO_ENVIRONMENT_GET_VARIABLE. */
3453 const char *key;
3454
3455 /* Human-readable core option description (used as menu label) */
3456 const char *desc;
3457
3458 /* Human-readable core option information (used as menu sublabel) */
3459 const char *info;
3460
3461 /* Array of retro_core_option_value structs, terminated by NULL */
3462 struct retro_core_option_value values[RETRO_NUM_CORE_OPTION_VALUES_MAX];
3463
3464 /* Default core option value. Must match one of the values
3465 * in the retro_core_option_value array, otherwise will be
3466 * ignored */
3467 const char *default_value;
3468};
3469
f3c6ae10 3470#ifdef __PS3__
3471#undef local
3472#endif
3473
919cac88 3474struct retro_core_options_intl
3475{
3476 /* Pointer to an array of retro_core_option_definition structs
3477 * - US English implementation
3478 * - Must point to a valid array */
3479 struct retro_core_option_definition *us;
3480
3481 /* Pointer to an array of retro_core_option_definition structs
3482 * - Implementation for current frontend language
3483 * - May be NULL */
3484 struct retro_core_option_definition *local;
3485};
3486
f3c6ae10 3487struct retro_core_option_v2_category
3488{
3489 /* Variable uniquely identifying the
3490 * option category. Valid key characters
3491 * are [a-z, A-Z, 0-9, _, -] */
3492 const char *key;
3493
3494 /* Human-readable category description
3495 * > Used as category menu label when
3496 * frontend has core option category
3497 * support */
3498 const char *desc;
3499
3500 /* Human-readable category information
3501 * > Used as category menu sublabel when
3502 * frontend has core option category
3503 * support
3504 * > Optional (may be NULL or an empty
3505 * string) */
3506 const char *info;
3507};
3508
3509struct retro_core_option_v2_definition
3510{
3511 /* Variable to query in RETRO_ENVIRONMENT_GET_VARIABLE.
3512 * Valid key characters are [a-z, A-Z, 0-9, _, -] */
3513 const char *key;
3514
3515 /* Human-readable core option description
3516 * > Used as menu label when frontend does
3517 * not have core option category support
3518 * e.g. "Video > Aspect Ratio" */
3519 const char *desc;
3520
3521 /* Human-readable core option description
3522 * > Used as menu label when frontend has
3523 * core option category support
3524 * e.g. "Aspect Ratio", where associated
3525 * retro_core_option_v2_category::desc
3526 * is "Video"
3527 * > If empty or NULL, the string specified by
3528 * desc will be used as the menu label
3529 * > Will be ignored (and may be set to NULL)
3530 * if category_key is empty or NULL */
3531 const char *desc_categorized;
3532
3533 /* Human-readable core option information
3534 * > Used as menu sublabel */
3535 const char *info;
3536
3537 /* Human-readable core option information
3538 * > Used as menu sublabel when frontend
3539 * has core option category support
3540 * (e.g. may be required when info text
3541 * references an option by name/desc,
3542 * and the desc/desc_categorized text
3543 * for that option differ)
3544 * > If empty or NULL, the string specified by
3545 * info will be used as the menu sublabel
3546 * > Will be ignored (and may be set to NULL)
3547 * if category_key is empty or NULL */
3548 const char *info_categorized;
3549
3550 /* Variable specifying category (e.g. "video",
3551 * "audio") that will be assigned to the option
3552 * if frontend has core option category support.
3553 * > Categorized options will be displayed in a
3554 * subsection/submenu of the frontend core
3555 * option interface
3556 * > Specified string must match one of the
3557 * retro_core_option_v2_category::key values
3558 * in the associated retro_core_option_v2_category
3559 * array; If no match is not found, specified
3560 * string will be considered as NULL
3561 * > If specified string is empty or NULL, option will
3562 * have no category and will be shown at the top
3563 * level of the frontend core option interface */
3564 const char *category_key;
3565
3566 /* Array of retro_core_option_value structs, terminated by NULL */
3567 struct retro_core_option_value values[RETRO_NUM_CORE_OPTION_VALUES_MAX];
3568
3569 /* Default core option value. Must match one of the values
3570 * in the retro_core_option_value array, otherwise will be
3571 * ignored */
3572 const char *default_value;
3573};
3574
3575struct retro_core_options_v2
3576{
3577 /* Array of retro_core_option_v2_category structs,
3578 * terminated by NULL
3579 * > If NULL, all entries in definitions array
3580 * will have no category and will be shown at
3581 * the top level of the frontend core option
3582 * interface
3583 * > Will be ignored if frontend does not have
3584 * core option category support */
3585 struct retro_core_option_v2_category *categories;
3586
3587 /* Array of retro_core_option_v2_definition structs,
3588 * terminated by NULL */
3589 struct retro_core_option_v2_definition *definitions;
3590};
3591
3592struct retro_core_options_v2_intl
3593{
3594 /* Pointer to a retro_core_options_v2 struct
3595 * > US English implementation
3596 * > Must point to a valid struct */
3597 struct retro_core_options_v2 *us;
3598
3599 /* Pointer to a retro_core_options_v2 struct
3600 * - Implementation for current frontend language
3601 * - May be NULL */
3602 struct retro_core_options_v2 *local;
3603};
3604
3605/* Used by the frontend to monitor changes in core option
3606 * visibility. May be called each time any core option
3607 * value is set via the frontend.
3608 * - On each invocation, the core must update the visibility
3609 * of any dynamically hidden options using the
3610 * RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY environment
3611 * callback.
3612 * - On the first invocation, returns 'true' if the visibility
3613 * of any core option has changed since the last call of
3614 * retro_load_game() or retro_load_game_special().
3615 * - On each subsequent invocation, returns 'true' if the
3616 * visibility of any core option has changed since the last
3617 * time the function was called. */
3618typedef bool (RETRO_CALLCONV *retro_core_options_update_display_callback_t)(void);
3619struct retro_core_options_update_display_callback
3620{
3621 retro_core_options_update_display_callback_t callback;
3622};
3623
38c2028e 3624struct retro_game_info
3625{
eae1ae02 3626 const char *path; /* Path to game, UTF-8 encoded.
6fbd15c8 3627 * Sometimes used as a reference for building other paths.
3628 * May be NULL if game was loaded from stdin or similar,
3629 * but in this case some cores will be unable to load `data`.
3630 * So, it is preferable to fabricate something here instead
3631 * of passing NULL, which will help more cores to succeed.
3632 * retro_system_info::need_fullpath requires
eae1ae02 3633 * that this path is valid. */
6fbd15c8 3634 const void *data; /* Memory buffer of loaded game. Will be NULL
eae1ae02
A
3635 * if need_fullpath was set. */
3636 size_t size; /* Size of memory buffer. */
3637 const char *meta; /* String of implementation specific meta-data. */
38c2028e 3638};
3639
65a0505f
FJGG
3640#define RETRO_MEMORY_ACCESS_WRITE (1 << 0)
3641 /* The core will write to the buffer provided by retro_framebuffer::data. */
3642#define RETRO_MEMORY_ACCESS_READ (1 << 1)
3643 /* The core will read from retro_framebuffer::data. */
3644#define RETRO_MEMORY_TYPE_CACHED (1 << 0)
3645 /* The memory in data is cached.
3646 * If not cached, random writes and/or reading from the buffer is expected to be very slow. */
3647struct retro_framebuffer
3648{
3649 void *data; /* The framebuffer which the core can render into.
3650 Set by frontend in GET_CURRENT_SOFTWARE_FRAMEBUFFER.
3651 The initial contents of data are unspecified. */
3652 unsigned width; /* The framebuffer width used by the core. Set by core. */
3653 unsigned height; /* The framebuffer height used by the core. Set by core. */
3654 size_t pitch; /* The number of bytes between the beginning of a scanline,
3655 and beginning of the next scanline.
3656 Set by frontend in GET_CURRENT_SOFTWARE_FRAMEBUFFER. */
3657 enum retro_pixel_format format; /* The pixel format the core must use to render into data.
3658 This format could differ from the format used in
3659 SET_PIXEL_FORMAT.
3660 Set by frontend in GET_CURRENT_SOFTWARE_FRAMEBUFFER. */
3661
3662 unsigned access_flags; /* How the core will access the memory in the framebuffer.
3663 RETRO_MEMORY_ACCESS_* flags.
3664 Set by core. */
3665 unsigned memory_flags; /* Flags telling core how the memory has been mapped.
3666 RETRO_MEMORY_TYPE_* flags.
3667 Set by frontend in GET_CURRENT_SOFTWARE_FRAMEBUFFER. */
3668};
3669
f3c6ae10 3670/* Used by a libretro core to override the current
3671 * fastforwarding mode of the frontend */
3672struct retro_fastforwarding_override
3673{
3674 /* Specifies the runtime speed multiplier that
3675 * will be applied when 'fastforward' is true.
3676 * For example, a value of 5.0 when running 60 FPS
3677 * content will cap the fast-forward rate at 300 FPS.
3678 * Note that the target multiplier may not be achieved
3679 * if the host hardware has insufficient processing
3680 * power.
3681 * Setting a value of 0.0 (or greater than 0.0 but
3682 * less than 1.0) will result in an uncapped
3683 * fast-forward rate (limited only by hardware
3684 * capacity).
3685 * If the value is negative, it will be ignored
3686 * (i.e. the frontend will use a runtime speed
3687 * multiplier of its own choosing) */
3688 float ratio;
3689
3690 /* If true, fastforwarding mode will be enabled.
3691 * If false, fastforwarding mode will be disabled. */
3692 bool fastforward;
3693
3694 /* If true, and if supported by the frontend, an
3695 * on-screen notification will be displayed while
3696 * 'fastforward' is true.
3697 * If false, and if supported by the frontend, any
3698 * on-screen fast-forward notifications will be
3699 * suppressed */
3700 bool notification;
3701
3702 /* If true, the core will have sole control over
3703 * when fastforwarding mode is enabled/disabled;
3704 * the frontend will not be able to change the
3705 * state set by 'fastforward' until either
3706 * 'inhibit_toggle' is set to false, or the core
3707 * is unloaded */
3708 bool inhibit_toggle;
3709};
3710
3711/* During normal operation. Rate will be equal to the core's internal FPS. */
3712#define RETRO_THROTTLE_NONE 0
3713
3714/* While paused or stepping single frames. Rate will be 0. */
3715#define RETRO_THROTTLE_FRAME_STEPPING 1
3716
3717/* During fast forwarding.
3718 * Rate will be 0 if not specifically limited to a maximum speed. */
3719#define RETRO_THROTTLE_FAST_FORWARD 2
3720
3721/* During slow motion. Rate will be less than the core's internal FPS. */
3722#define RETRO_THROTTLE_SLOW_MOTION 3
3723
3724/* While rewinding recorded save states. Rate can vary depending on the rewind
3725 * speed or be 0 if the frontend is not aiming for a specific rate. */
3726#define RETRO_THROTTLE_REWINDING 4
3727
3728/* While vsync is active in the video driver and the target refresh rate is
3729 * lower than the core's internal FPS. Rate is the target refresh rate. */
3730#define RETRO_THROTTLE_VSYNC 5
3731
3732/* When the frontend does not throttle in any way. Rate will be 0.
3733 * An example could be if no vsync or audio output is active. */
3734#define RETRO_THROTTLE_UNBLOCKED 6
3735
3736struct retro_throttle_state
3737{
3738 /* The current throttling mode. Should be one of the values above. */
3739 unsigned mode;
3740
3741 /* How many times per second the frontend aims to call retro_run.
3742 * Depending on the mode, it can be 0 if there is no known fixed rate.
3743 * This won't be accurate if the total processing time of the core and
3744 * the frontend is longer than what is available for one frame. */
3745 float rate;
3746};
3747
eae1ae02
A
3748/* Callbacks */
3749
6fbd15c8 3750/* Environment callback. Gives implementations a way of performing
eae1ae02 3751 * uncommon tasks. Extensible. */
6fbd15c8 3752typedef bool (RETRO_CALLCONV *retro_environment_t)(unsigned cmd, void *data);
38c2028e 3753
6fbd15c8 3754/* Render a frame. Pixel format is 15-bit 0RGB1555 native endian
eae1ae02
A
3755 * unless changed (see RETRO_ENVIRONMENT_SET_PIXEL_FORMAT).
3756 *
3757 * Width and height specify dimensions of buffer.
3758 * Pitch specifices length in bytes between two lines in buffer.
3759 *
6fbd15c8 3760 * For performance reasons, it is highly recommended to have a frame
eae1ae02 3761 * that is packed in memory, i.e. pitch == width * byte_per_pixel.
6fbd15c8 3762 * Certain graphic APIs, such as OpenGL ES, do not like textures
eae1ae02
A
3763 * that are not packed in memory.
3764 */
6fbd15c8 3765typedef void (RETRO_CALLCONV *retro_video_refresh_t)(const void *data, unsigned width,
eae1ae02 3766 unsigned height, size_t pitch);
38c2028e 3767
6fbd15c8 3768/* Renders a single audio frame. Should only be used if implementation
eae1ae02
A
3769 * generates a single sample at a time.
3770 * Format is signed 16-bit native endian.
3771 */
6fbd15c8 3772typedef void (RETRO_CALLCONV *retro_audio_sample_t)(int16_t left, int16_t right);
38c2028e 3773
eae1ae02
A
3774/* Renders multiple audio frames in one go.
3775 *
3776 * One frame is defined as a sample of left and right channels, interleaved.
3777 * I.e. int16_t buf[4] = { l, r, l, r }; would be 2 frames.
3778 * Only one of the audio callbacks must ever be used.
3779 */
6fbd15c8 3780typedef size_t (RETRO_CALLCONV *retro_audio_sample_batch_t)(const int16_t *data,
eae1ae02
A
3781 size_t frames);
3782
3783/* Polls input. */
6fbd15c8 3784typedef void (RETRO_CALLCONV *retro_input_poll_t)(void);
38c2028e 3785
6fbd15c8 3786/* Queries for input for player 'port'. device will be masked with
eae1ae02
A
3787 * RETRO_DEVICE_MASK.
3788 *
6fbd15c8 3789 * Specialization of devices such as RETRO_DEVICE_JOYPAD_MULTITAP that
eae1ae02
A
3790 * have been set with retro_set_controller_port_device()
3791 * will still use the higher level RETRO_DEVICE_JOYPAD to request input.
3792 */
6fbd15c8 3793typedef int16_t (RETRO_CALLCONV *retro_input_state_t)(unsigned port, unsigned device,
eae1ae02
A
3794 unsigned index, unsigned id);
3795
6fbd15c8 3796/* Sets callbacks. retro_set_environment() is guaranteed to be called
eae1ae02
A
3797 * before retro_init().
3798 *
6fbd15c8 3799 * The rest of the set_* functions are guaranteed to have been called
eae1ae02 3800 * before the first call to retro_run() is made. */
65a0505f
FJGG
3801RETRO_API void retro_set_environment(retro_environment_t);
3802RETRO_API void retro_set_video_refresh(retro_video_refresh_t);
3803RETRO_API void retro_set_audio_sample(retro_audio_sample_t);
3804RETRO_API void retro_set_audio_sample_batch(retro_audio_sample_batch_t);
3805RETRO_API void retro_set_input_poll(retro_input_poll_t);
3806RETRO_API void retro_set_input_state(retro_input_state_t);
38c2028e 3807
eae1ae02 3808/* Library global initialization/deinitialization. */
65a0505f
FJGG
3809RETRO_API void retro_init(void);
3810RETRO_API void retro_deinit(void);
38c2028e 3811
eae1ae02
A
3812/* Must return RETRO_API_VERSION. Used to validate ABI compatibility
3813 * when the API is revised. */
65a0505f 3814RETRO_API unsigned retro_api_version(void);
38c2028e 3815
6fbd15c8 3816/* Gets statically known system info. Pointers provided in *info
eae1ae02
A
3817 * must be statically allocated.
3818 * Can be called at any time, even before retro_init(). */
65a0505f 3819RETRO_API void retro_get_system_info(struct retro_system_info *info);
38c2028e 3820
eae1ae02
A
3821/* Gets information about system audio/video timings and geometry.
3822 * Can be called only after retro_load_game() has successfully completed.
6fbd15c8 3823 * NOTE: The implementation of this function might not initialize every
eae1ae02 3824 * variable if needed.
6fbd15c8 3825 * E.g. geom.aspect_ratio might not be initialized if core doesn't
eae1ae02 3826 * desire a particular aspect ratio. */
65a0505f 3827RETRO_API void retro_get_system_av_info(struct retro_system_av_info *info);
38c2028e 3828
eae1ae02 3829/* Sets device to be used for player 'port'.
6fbd15c8 3830 * By default, RETRO_DEVICE_JOYPAD is assumed to be plugged into all
eae1ae02 3831 * available ports.
6fbd15c8 3832 * Setting a particular device type is not a guarantee that libretro cores
3833 * will only poll input based on that particular device type. It is only a
3834 * hint to the libretro core when a core cannot automatically detect the
3835 * appropriate input device type on its own. It is also relevant when a
3836 * core can change its behavior depending on device type.
3837 *
3838 * As part of the core's implementation of retro_set_controller_port_device,
3839 * the core should call RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS to notify the
3840 * frontend if the descriptions for any controls have changed as a
3841 * result of changing the device type.
3842 */
65a0505f 3843RETRO_API void retro_set_controller_port_device(unsigned port, unsigned device);
38c2028e 3844
eae1ae02 3845/* Resets the current game. */
65a0505f 3846RETRO_API void retro_reset(void);
38c2028e 3847
eae1ae02
A
3848/* Runs the game for one video frame.
3849 * During retro_run(), input_poll callback must be called at least once.
6fbd15c8 3850 *
eae1ae02 3851 * If a frame is not rendered for reasons where a game "dropped" a frame,
6fbd15c8 3852 * this still counts as a frame, and retro_run() should explicitly dupe
eae1ae02
A
3853 * a frame if GET_CAN_DUPE returns true.
3854 * In this case, the video callback can take a NULL argument for data.
3855 */
65a0505f 3856RETRO_API void retro_run(void);
38c2028e 3857
6fbd15c8 3858/* Returns the amount of data the implementation requires to serialize
eae1ae02 3859 * internal state (save states).
6fbd15c8 3860 * Between calls to retro_load_game() and retro_unload_game(), the
3861 * returned size is never allowed to be larger than a previous returned
eae1ae02
A
3862 * value, to ensure that the frontend can allocate a save state buffer once.
3863 */
65a0505f 3864RETRO_API size_t retro_serialize_size(void);
38c2028e 3865
eae1ae02
A
3866/* Serializes internal state. If failed, or size is lower than
3867 * retro_serialize_size(), it should return false, true otherwise. */
65a0505f
FJGG
3868RETRO_API bool retro_serialize(void *data, size_t size);
3869RETRO_API bool retro_unserialize(const void *data, size_t size);
38c2028e 3870
65a0505f
FJGG
3871RETRO_API void retro_cheat_reset(void);
3872RETRO_API void retro_cheat_set(unsigned index, bool enabled, const char *code);
38c2028e 3873
6fbd15c8 3874/* Loads a game.
3875 * Return true to indicate successful loading and false to indicate load failure.
3876 */
65a0505f 3877RETRO_API bool retro_load_game(const struct retro_game_info *game);
38c2028e 3878
eae1ae02
A
3879/* Loads a "special" kind of game. Should not be used,
3880 * except in extreme cases. */
65a0505f 3881RETRO_API bool retro_load_game_special(
38c2028e 3882 unsigned game_type,
3883 const struct retro_game_info *info, size_t num_info
3884);
3885
6fbd15c8 3886/* Unloads the currently loaded game. Called before retro_deinit(void). */
65a0505f 3887RETRO_API void retro_unload_game(void);
38c2028e 3888
eae1ae02 3889/* Gets region of game. */
65a0505f 3890RETRO_API unsigned retro_get_region(void);
38c2028e 3891
eae1ae02 3892/* Gets region of memory. */
65a0505f
FJGG
3893RETRO_API void *retro_get_memory_data(unsigned id);
3894RETRO_API size_t retro_get_memory_size(unsigned id);
38c2028e 3895
3896#ifdef __cplusplus
3897}
3898#endif
3899
3900#endif