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