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