CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
hrydgard

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

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