Debian Codegraph @

libretro-common/include/libretro.h

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