Mercurial > repos > blastem
comparison libretro.h @ 2545:c076a96f1668
Get CD titles sort of working in libretro target
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Thu, 02 Jan 2025 23:02:52 -0800 |
parents | 6c54bb5fe3b3 |
children |
comparison
equal
deleted
inserted
replaced
2543:9a07d299604b | 2545:c076a96f1668 |
---|---|
1 /* Copyright (C) 2010-2017 The RetroArch team | 1 /*! |
2 * | 2 * libretro.h is a simple API that allows for the creation of games and emulators. |
3 * --------------------------------------------------------------------------------------- | 3 * |
4 * @file libretro.h | |
5 * @version 1 | |
6 * @author libretro | |
7 * @copyright Copyright (C) 2010-2024 The RetroArch team | |
8 * | |
9 * @paragraph LICENSE | |
4 * The following license statement only applies to this libretro API header (libretro.h). | 10 * The following license statement only applies to this libretro API header (libretro.h). |
5 * --------------------------------------------------------------------------------------- | 11 * |
12 * Copyright (C) 2010-2024 The RetroArch team | |
6 * | 13 * |
7 * Permission is hereby granted, free of charge, | 14 * Permission is hereby granted, free of charge, |
8 * to any person obtaining a copy of this software and associated documentation files (the "Software"), | 15 * 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 | 16 * 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, | 17 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, |
67 # else | 74 # else |
68 # define RETRO_API RETRO_CALLCONV __declspec(dllexport) | 75 # define RETRO_API RETRO_CALLCONV __declspec(dllexport) |
69 # endif | 76 # endif |
70 # endif | 77 # endif |
71 # else | 78 # else |
72 # if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__CELLOS_LV2__) | 79 # if defined(__GNUC__) && __GNUC__ >= 4 |
73 # define RETRO_API RETRO_CALLCONV __attribute__((__visibility__("default"))) | 80 # define RETRO_API RETRO_CALLCONV __attribute__((__visibility__("default"))) |
74 # else | 81 # else |
75 # define RETRO_API RETRO_CALLCONV | 82 # define RETRO_API RETRO_CALLCONV |
76 # endif | 83 # endif |
77 # endif | 84 # endif |
78 #endif | 85 #endif |
79 | 86 |
80 /* Used for checking API/ABI mismatches that can break libretro | 87 /** |
81 * implementations. | 88 * The major version of the libretro API and ABI. |
82 * It is not incremented for compatible changes to the API. | 89 * Cores may support multiple versions, |
90 * or they may reject cores with unsupported versions. | |
91 * It is only incremented for incompatible API/ABI changes; | |
92 * this generally implies a function was removed or changed, | |
93 * or that a \c struct had fields removed or changed. | |
94 * @note A design goal of libretro is to avoid having to increase this value at all costs. | |
95 * This is why there are APIs that are "extended" or "V2". | |
83 */ | 96 */ |
84 #define RETRO_API_VERSION 1 | 97 #define RETRO_API_VERSION 1 |
85 | 98 |
86 /* | 99 /** |
87 * Libretro's fundamental device abstractions. | 100 * @defgroup RETRO_DEVICE Input Devices |
88 * | 101 * @brief Libretro's fundamental device abstractions. |
89 * Libretro's input system consists of some standardized device types, | 102 * |
90 * such as a joypad (with/without analog), mouse, keyboard, lightgun | 103 * Libretro's input system consists of abstractions over standard device types, |
91 * and a pointer. | 104 * such as a joypad (with or without analog), mouse, keyboard, light gun, or an abstract pointer. |
92 * | 105 * Instead of managing input devices themselves, |
93 * The functionality of these devices are fixed, and individual cores | 106 * cores need only to map their own concept of a controller to libretro's abstractions. |
94 * map their own concept of a controller to libretro's abstractions. | 107 * This makes it possible for frontends to map the abstract types to a real input device |
95 * This makes it possible for frontends to map the abstract types to a | 108 * without having to worry about the correct use of arbitrary (real) controller layouts. |
96 * real input device, and not having to worry about binding input | 109 * @{ |
97 * correctly to arbitrary controller layouts. | |
98 */ | 110 */ |
99 | 111 |
100 #define RETRO_DEVICE_TYPE_SHIFT 8 | 112 #define RETRO_DEVICE_TYPE_SHIFT 8 |
101 #define RETRO_DEVICE_MASK ((1 << RETRO_DEVICE_TYPE_SHIFT) - 1) | 113 #define RETRO_DEVICE_MASK ((1 << RETRO_DEVICE_TYPE_SHIFT) - 1) |
114 | |
115 /** | |
116 * Defines an ID for a subclass of a known device type. | |
117 * | |
118 * To define a subclass ID, use this macro like so: | |
119 * @code{c} | |
120 * #define RETRO_DEVICE_SUPER_SCOPE RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_LIGHTGUN, 1) | |
121 * #define RETRO_DEVICE_JUSTIFIER RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_LIGHTGUN, 2) | |
122 * @endcode | |
123 * | |
124 * Correct use of this macro allows a frontend to select a suitable physical device | |
125 * to map to the emulated device. | |
126 * | |
127 * @note Cores must use the base ID when polling for input, | |
128 * and frontends must only accept the base ID for this purpose. | |
129 * Polling for input using subclass IDs is reserved for future definition. | |
130 * | |
131 * @param base One of the \ref RETRO_DEVICE "base device types". | |
132 * @param id A unique ID, with respect to \c base. | |
133 * Must be a non-negative integer. | |
134 * @return A unique subclass ID. | |
135 * @see retro_controller_description | |
136 * @see retro_set_controller_port_device | |
137 */ | |
102 #define RETRO_DEVICE_SUBCLASS(base, id) (((id + 1) << RETRO_DEVICE_TYPE_SHIFT) | base) | 138 #define RETRO_DEVICE_SUBCLASS(base, id) (((id + 1) << RETRO_DEVICE_TYPE_SHIFT) | base) |
103 | 139 |
104 /* Input disabled. */ | 140 /** |
141 * @defgroup RETRO_DEVICE Input Device Classes | |
142 * @{ | |
143 */ | |
144 | |
145 /** | |
146 * Indicates no input. | |
147 * | |
148 * When provided as the \c device argument to \c retro_input_state_t, | |
149 * all other arguments are ignored and zero is returned. | |
150 * | |
151 * @see retro_input_state_t | |
152 */ | |
105 #define RETRO_DEVICE_NONE 0 | 153 #define RETRO_DEVICE_NONE 0 |
106 | 154 |
107 /* The JOYPAD is called RetroPad. It is essentially a Super Nintendo | 155 /** |
108 * controller, but with additional L2/R2/L3/R3 buttons, similar to a | 156 * An abstraction around a game controller, known as a "RetroPad". |
109 * PS1 DualShock. */ | 157 * |
158 * The RetroPad is modelled after a SNES controller, | |
159 * but with additional L2/R2/L3/R3 buttons | |
160 * (similar to a PlayStation controller). | |
161 * | |
162 * When provided as the \c device argument to \c retro_input_state_t, | |
163 * the \c id argument denotes the button (including D-Pad directions) to query. | |
164 * The result of said query will be 1 if the button is down, 0 if not. | |
165 * | |
166 * There is one exception; if \c RETRO_DEVICE_ID_JOYPAD_MASK is queried | |
167 * (and the frontend supports this query), | |
168 * the result will be a bitmask of all pressed buttons. | |
169 * | |
170 * @see retro_input_state_t | |
171 * @see RETRO_DEVICE_ANALOG | |
172 * @see RETRO_DEVICE_ID_JOYPAD | |
173 * @see RETRO_DEVICE_ID_JOYPAD_MASK | |
174 * @see RETRO_ENVIRONMENT_GET_INPUT_BITMASKS | |
175 */ | |
110 #define RETRO_DEVICE_JOYPAD 1 | 176 #define RETRO_DEVICE_JOYPAD 1 |
111 | 177 |
112 /* The mouse is a simple mouse, similar to Super Nintendo's mouse. | 178 /** |
113 * X and Y coordinates are reported relatively to last poll (poll callback). | 179 * An abstraction around a mouse, similar to the SNES Mouse but with more buttons. |
114 * It is up to the libretro implementation to keep track of where the mouse | 180 * |
115 * pointer is supposed to be on the screen. | 181 * When provided as the \c device argument to \c retro_input_state_t, |
116 * The frontend must make sure not to interfere with its own hardware | 182 * the \c id argument denotes the button or axis to query. |
117 * mouse pointer. | 183 * For buttons, the result of said query |
184 * will be 1 if the button is down or 0 if not. | |
185 * For mouse wheel axes, the result | |
186 * will be 1 if the wheel was rotated in that direction and 0 if not. | |
187 * For the mouse pointer axis, the result will be thee mouse's movement | |
188 * relative to the last poll. | |
189 * The core is responsible for tracking the mouse's position, | |
190 * and the frontend is responsible for preventing interference | |
191 * by the real hardware pointer (if applicable). | |
192 * | |
193 * @note This should only be used for cores that emulate mouse input, | |
194 * such as for home computers | |
195 * or consoles with mouse attachments. | |
196 * Cores that emulate light guns should use \c RETRO_DEVICE_LIGHTGUN, | |
197 * and cores that emulate touch screens should use \c RETRO_DEVICE_POINTER. | |
198 * | |
199 * @see RETRO_DEVICE_POINTER | |
200 * @see RETRO_DEVICE_LIGHTGUN | |
118 */ | 201 */ |
119 #define RETRO_DEVICE_MOUSE 2 | 202 #define RETRO_DEVICE_MOUSE 2 |
120 | 203 |
121 /* KEYBOARD device lets one poll for raw key pressed. | 204 /** |
122 * It is poll based, so input callback will return with the current | 205 * An abstraction around a keyboard. |
123 * pressed state. | 206 * |
124 * For event/text based keyboard input, see | 207 * When provided as the \c device argument to \c retro_input_state_t, |
125 * RETRO_ENVIRONMENT_SET_KEYBOARD_CALLBACK. | 208 * the \c id argument denotes the key to poll. |
209 * | |
210 * @note This should only be used for cores that emulate keyboard input, | |
211 * such as for home computers | |
212 * or consoles with keyboard attachments. | |
213 * Cores that emulate gamepads should use \c RETRO_DEVICE_JOYPAD or \c RETRO_DEVICE_ANALOG, | |
214 * and leave keyboard compatibility to the frontend. | |
215 * | |
216 * @see RETRO_ENVIRONMENT_SET_KEYBOARD_CALLBACK | |
217 * @see retro_key | |
126 */ | 218 */ |
127 #define RETRO_DEVICE_KEYBOARD 3 | 219 #define RETRO_DEVICE_KEYBOARD 3 |
128 | 220 |
129 /* LIGHTGUN device is similar to Guncon-2 for PlayStation 2. | 221 /** |
130 * It reports X/Y coordinates in screen space (similar to the pointer) | 222 * An abstraction around a light gun, similar to the PlayStation's Guncon. |
131 * in the range [-0x8000, 0x7fff] in both axes, with zero being center. | 223 * |
132 * As well as reporting on/off screen state. It features a trigger, | 224 * When provided as the \c device argument to \c retro_input_state_t, |
133 * start/select buttons, auxiliary action buttons and a | 225 * the \c id argument denotes one of several possible inputs. |
134 * directional pad. A forced off-screen shot can be requested for | 226 * |
135 * auto-reloading function in some games. | 227 * The gun's coordinates are reported in screen space (similar to the pointer) |
228 * in the range of [-0x8000, 0x7fff]. | |
229 * Zero is the center of the game's screen | |
230 * and -0x8000 represents out-of-bounds. | |
231 * The trigger and various auxiliary buttons are also reported. | |
232 * | |
233 * @note A forced off-screen shot can be requested for auto-reloading | |
234 * function in some games. | |
235 * | |
236 * @see RETRO_DEVICE_POINTER | |
136 */ | 237 */ |
137 #define RETRO_DEVICE_LIGHTGUN 4 | 238 #define RETRO_DEVICE_LIGHTGUN 4 |
138 | 239 |
139 /* The ANALOG device is an extension to JOYPAD (RetroPad). | 240 /** |
140 * Similar to DualShock2 it adds two analog sticks and all buttons can | 241 * An extension of the RetroPad that supports analog input. |
141 * be analog. This is treated as a separate device type as it returns | 242 * |
142 * axis values in the full analog range of [-0x8000, 0x7fff]. | 243 * The analog RetroPad provides two virtual analog sticks (similar to DualShock controllers) |
143 * Positive X axis is right. Positive Y axis is down. | 244 * and allows any button to be treated as analog (similar to Xbox shoulder triggers). |
144 * Buttons are returned in the range [0, 0x7fff]. | 245 * |
145 * Only use ANALOG type when polling for analog values. | 246 * When provided as the \c device argument to \c retro_input_state_t, |
247 * the \c id argument denotes an analog axis or an analog button. | |
248 * | |
249 * Analog axes are reported in the range of [-0x8000, 0x7fff], | |
250 * with the X axis being positive towards the right | |
251 * and the Y axis being positive towards the bottom. | |
252 * | |
253 * Analog buttons are reported in the range of [0, 0x7fff], | |
254 * where 0 is unpressed and 0x7fff is fully pressed. | |
255 * | |
256 * @note Cores should only use this type if they need analog input. | |
257 * Otherwise, \c RETRO_DEVICE_JOYPAD should be used. | |
258 * @see RETRO_DEVICE_JOYPAD | |
146 */ | 259 */ |
147 #define RETRO_DEVICE_ANALOG 5 | 260 #define RETRO_DEVICE_ANALOG 5 |
148 | 261 |
149 /* Abstracts the concept of a pointing mechanism, e.g. touch. | 262 /** |
263 * Input Device: Pointer. | |
264 * | |
265 * Abstracts the concept of a pointing mechanism, e.g. touch. | |
150 * This allows libretro to query in absolute coordinates where on the | 266 * This allows libretro to query in absolute coordinates where on the |
151 * screen a mouse (or something similar) is being placed. | 267 * screen a mouse (or something similar) is being placed. |
152 * For a touch centric device, coordinates reported are the coordinates | 268 * For a touch centric device, coordinates reported are the coordinates |
153 * of the press. | 269 * of the press. |
154 * | 270 * |
155 * Coordinates in X and Y are reported as: | 271 * Coordinates in X and Y are reported as: |
156 * [-0x7fff, 0x7fff]: -0x7fff corresponds to the far left/top of the screen, | 272 * [-0x7fff, 0x7fff]: -0x7fff corresponds to the far left/top of the screen, |
157 * and 0x7fff corresponds to the far right/bottom of the screen. | 273 * 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 | 274 * The "screen" is here defined as area that is passed to the frontend and |
159 * later displayed on the monitor. | 275 * later displayed on the monitor. If the pointer is outside this screen, |
276 * such as in the black surrounding areas when actual display is larger, | |
277 * edge position is reported. An explicit edge detection is also provided, | |
278 * that will return 1 if the pointer is near the screen edge or actually outside it. | |
160 * | 279 * |
161 * The frontend is free to scale/resize this screen as it sees fit, however, | 280 * 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 | 281 * (X, Y) = (-0x7fff, -0x7fff) will correspond to the top-left pixel of the |
163 * game image, etc. | 282 * game image, etc. |
164 * | 283 * |
165 * To check if the pointer coordinates are valid (e.g. a touch display | 284 * To check if the pointer coordinates are valid (e.g. a touch display |
166 * actually being touched), PRESSED returns 1 or 0. | 285 * actually being touched), \c RETRO_DEVICE_ID_POINTER_PRESSED returns 1 or 0. |
167 * | 286 * |
168 * If using a mouse on a desktop, PRESSED will usually correspond to the | 287 * If using a mouse on a desktop, \c RETRO_DEVICE_ID_POINTER_PRESSED will |
169 * left mouse button, but this is a frontend decision. | 288 * usually correspond to the left mouse button, but this is a frontend decision. |
170 * PRESSED will only return 1 if the pointer is inside the game screen. | 289 * \c RETRO_DEVICE_ID_POINTER_PRESSED will only return 1 if the pointer is |
290 * inside the game screen. | |
171 * | 291 * |
172 * For multi-touch, the index variable can be used to successively query | 292 * For multi-touch, the index variable can be used to successively query |
173 * more presses. | 293 * more presses. |
174 * If index = 0 returns true for _PRESSED, coordinates can be extracted | 294 * If index = 0 returns true for \c _PRESSED, coordinates can be extracted |
175 * with _X, _Y for index = 0. One can then query _PRESSED, _X, _Y with | 295 * with \c _X, \c _Y for index = 0. One can then query \c _PRESSED, \c _X, \c _Y with |
176 * index = 1, and so on. | 296 * index = 1, and so on. |
177 * Eventually _PRESSED will return false for an index. No further presses | 297 * Eventually \c _PRESSED will return false for an index. No further presses |
178 * are registered at this point. */ | 298 * are registered at this point. |
299 * | |
300 * @see RETRO_DEVICE_MOUSE | |
301 * @see RETRO_DEVICE_ID_POINTER_X | |
302 * @see RETRO_DEVICE_ID_POINTER_Y | |
303 * @see RETRO_DEVICE_ID_POINTER_PRESSED | |
304 */ | |
179 #define RETRO_DEVICE_POINTER 6 | 305 #define RETRO_DEVICE_POINTER 6 |
180 | 306 |
181 /* Buttons for the RetroPad (JOYPAD). | 307 /** @} */ |
182 * The placement of these is equivalent to placements on the | 308 |
183 * Super Nintendo controller. | 309 /** @defgroup RETRO_DEVICE_ID_JOYPAD RetroPad Input |
184 * L2/R2/L3/R3 buttons correspond to the PS1 DualShock. | 310 * @brief Digital buttons for the RetroPad. |
185 * Also used as id values for RETRO_DEVICE_INDEX_ANALOG_BUTTON */ | 311 * |
312 * Button placement is comparable to that of a SNES controller, | |
313 * combined with the shoulder buttons of a PlayStation controller. | |
314 * These values can also be used for the \c id field of \c RETRO_DEVICE_INDEX_ANALOG_BUTTON | |
315 * to represent analog buttons (usually shoulder triggers). | |
316 * @{ | |
317 */ | |
318 | |
319 /** The equivalent of the SNES controller's south face button. */ | |
186 #define RETRO_DEVICE_ID_JOYPAD_B 0 | 320 #define RETRO_DEVICE_ID_JOYPAD_B 0 |
321 | |
322 /** The equivalent of the SNES controller's west face button. */ | |
187 #define RETRO_DEVICE_ID_JOYPAD_Y 1 | 323 #define RETRO_DEVICE_ID_JOYPAD_Y 1 |
324 | |
325 /** The equivalent of the SNES controller's left-center button. */ | |
188 #define RETRO_DEVICE_ID_JOYPAD_SELECT 2 | 326 #define RETRO_DEVICE_ID_JOYPAD_SELECT 2 |
327 | |
328 /** The equivalent of the SNES controller's right-center button. */ | |
189 #define RETRO_DEVICE_ID_JOYPAD_START 3 | 329 #define RETRO_DEVICE_ID_JOYPAD_START 3 |
330 | |
331 /** Up on the RetroPad's D-pad. */ | |
190 #define RETRO_DEVICE_ID_JOYPAD_UP 4 | 332 #define RETRO_DEVICE_ID_JOYPAD_UP 4 |
333 | |
334 /** Down on the RetroPad's D-pad. */ | |
191 #define RETRO_DEVICE_ID_JOYPAD_DOWN 5 | 335 #define RETRO_DEVICE_ID_JOYPAD_DOWN 5 |
336 | |
337 /** Left on the RetroPad's D-pad. */ | |
192 #define RETRO_DEVICE_ID_JOYPAD_LEFT 6 | 338 #define RETRO_DEVICE_ID_JOYPAD_LEFT 6 |
339 | |
340 /** Right on the RetroPad's D-pad. */ | |
193 #define RETRO_DEVICE_ID_JOYPAD_RIGHT 7 | 341 #define RETRO_DEVICE_ID_JOYPAD_RIGHT 7 |
342 | |
343 /** The equivalent of the SNES controller's east face button. */ | |
194 #define RETRO_DEVICE_ID_JOYPAD_A 8 | 344 #define RETRO_DEVICE_ID_JOYPAD_A 8 |
345 | |
346 /** The equivalent of the SNES controller's north face button. */ | |
195 #define RETRO_DEVICE_ID_JOYPAD_X 9 | 347 #define RETRO_DEVICE_ID_JOYPAD_X 9 |
348 | |
349 /** The equivalent of the SNES controller's left shoulder button. */ | |
196 #define RETRO_DEVICE_ID_JOYPAD_L 10 | 350 #define RETRO_DEVICE_ID_JOYPAD_L 10 |
351 | |
352 /** The equivalent of the SNES controller's right shoulder button. */ | |
197 #define RETRO_DEVICE_ID_JOYPAD_R 11 | 353 #define RETRO_DEVICE_ID_JOYPAD_R 11 |
354 | |
355 /** The equivalent of the PlayStation's rear left shoulder button. */ | |
198 #define RETRO_DEVICE_ID_JOYPAD_L2 12 | 356 #define RETRO_DEVICE_ID_JOYPAD_L2 12 |
357 | |
358 /** The equivalent of the PlayStation's rear right shoulder button. */ | |
199 #define RETRO_DEVICE_ID_JOYPAD_R2 13 | 359 #define RETRO_DEVICE_ID_JOYPAD_R2 13 |
360 | |
361 /** | |
362 * The equivalent of the PlayStation's left analog stick button, | |
363 * although the actual button need not be in this position. | |
364 */ | |
200 #define RETRO_DEVICE_ID_JOYPAD_L3 14 | 365 #define RETRO_DEVICE_ID_JOYPAD_L3 14 |
366 | |
367 /** | |
368 * The equivalent of the PlayStation's right analog stick button, | |
369 * although the actual button need not be in this position. | |
370 */ | |
201 #define RETRO_DEVICE_ID_JOYPAD_R3 15 | 371 #define RETRO_DEVICE_ID_JOYPAD_R3 15 |
372 | |
373 /** | |
374 * Represents a bitmask that describes the state of all \c RETRO_DEVICE_ID_JOYPAD button constants, | |
375 * rather than the state of a single button. | |
376 * | |
377 * @see RETRO_ENVIRONMENT_GET_INPUT_BITMASKS | |
378 * @see RETRO_DEVICE_JOYPAD | |
379 */ | |
380 #define RETRO_DEVICE_ID_JOYPAD_MASK 256 | |
381 | |
382 /** @} */ | |
383 | |
384 /** @defgroup RETRO_DEVICE_ID_ANALOG Analog RetroPad Input | |
385 * @{ | |
386 */ | |
202 | 387 |
203 /* Index / Id values for ANALOG device. */ | 388 /* Index / Id values for ANALOG device. */ |
204 #define RETRO_DEVICE_INDEX_ANALOG_LEFT 0 | 389 #define RETRO_DEVICE_INDEX_ANALOG_LEFT 0 |
205 #define RETRO_DEVICE_INDEX_ANALOG_RIGHT 1 | 390 #define RETRO_DEVICE_INDEX_ANALOG_RIGHT 1 |
206 #define RETRO_DEVICE_INDEX_ANALOG_BUTTON 2 | 391 #define RETRO_DEVICE_INDEX_ANALOG_BUTTON 2 |
207 #define RETRO_DEVICE_ID_ANALOG_X 0 | 392 #define RETRO_DEVICE_ID_ANALOG_X 0 |
208 #define RETRO_DEVICE_ID_ANALOG_Y 1 | 393 #define RETRO_DEVICE_ID_ANALOG_Y 1 |
394 | |
395 /** @} */ | |
209 | 396 |
210 /* Id values for MOUSE. */ | 397 /* Id values for MOUSE. */ |
211 #define RETRO_DEVICE_ID_MOUSE_X 0 | 398 #define RETRO_DEVICE_ID_MOUSE_X 0 |
212 #define RETRO_DEVICE_ID_MOUSE_Y 1 | 399 #define RETRO_DEVICE_ID_MOUSE_Y 1 |
213 #define RETRO_DEVICE_ID_MOUSE_LEFT 2 | 400 #define RETRO_DEVICE_ID_MOUSE_LEFT 2 |
220 #define RETRO_DEVICE_ID_MOUSE_BUTTON_4 9 | 407 #define RETRO_DEVICE_ID_MOUSE_BUTTON_4 9 |
221 #define RETRO_DEVICE_ID_MOUSE_BUTTON_5 10 | 408 #define RETRO_DEVICE_ID_MOUSE_BUTTON_5 10 |
222 | 409 |
223 /* Id values for LIGHTGUN. */ | 410 /* Id values for LIGHTGUN. */ |
224 #define RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X 13 /*Absolute Position*/ | 411 #define RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X 13 /*Absolute Position*/ |
225 #define RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y 14 /*Absolute*/ | 412 #define RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y 14 /*Absolute Position*/ |
413 /** Indicates if lightgun points off the screen or near the edge */ | |
226 #define RETRO_DEVICE_ID_LIGHTGUN_IS_OFFSCREEN 15 /*Status Check*/ | 414 #define RETRO_DEVICE_ID_LIGHTGUN_IS_OFFSCREEN 15 /*Status Check*/ |
227 #define RETRO_DEVICE_ID_LIGHTGUN_TRIGGER 2 | 415 #define RETRO_DEVICE_ID_LIGHTGUN_TRIGGER 2 |
228 #define RETRO_DEVICE_ID_LIGHTGUN_RELOAD 16 /*Forced off-screen shot*/ | 416 #define RETRO_DEVICE_ID_LIGHTGUN_RELOAD 16 /*Forced off-screen shot*/ |
229 #define RETRO_DEVICE_ID_LIGHTGUN_AUX_A 3 | 417 #define RETRO_DEVICE_ID_LIGHTGUN_AUX_A 3 |
230 #define RETRO_DEVICE_ID_LIGHTGUN_AUX_B 4 | 418 #define RETRO_DEVICE_ID_LIGHTGUN_AUX_B 4 |
235 #define RETRO_DEVICE_ID_LIGHTGUN_DPAD_DOWN 10 | 423 #define RETRO_DEVICE_ID_LIGHTGUN_DPAD_DOWN 10 |
236 #define RETRO_DEVICE_ID_LIGHTGUN_DPAD_LEFT 11 | 424 #define RETRO_DEVICE_ID_LIGHTGUN_DPAD_LEFT 11 |
237 #define RETRO_DEVICE_ID_LIGHTGUN_DPAD_RIGHT 12 | 425 #define RETRO_DEVICE_ID_LIGHTGUN_DPAD_RIGHT 12 |
238 /* deprecated */ | 426 /* deprecated */ |
239 #define RETRO_DEVICE_ID_LIGHTGUN_X 0 /*Relative Position*/ | 427 #define RETRO_DEVICE_ID_LIGHTGUN_X 0 /*Relative Position*/ |
240 #define RETRO_DEVICE_ID_LIGHTGUN_Y 1 /*Relative*/ | 428 #define RETRO_DEVICE_ID_LIGHTGUN_Y 1 /*Relative Position*/ |
241 #define RETRO_DEVICE_ID_LIGHTGUN_CURSOR 3 /*Use Aux:A*/ | 429 #define RETRO_DEVICE_ID_LIGHTGUN_CURSOR 3 /*Use Aux:A instead*/ |
242 #define RETRO_DEVICE_ID_LIGHTGUN_TURBO 4 /*Use Aux:B*/ | 430 #define RETRO_DEVICE_ID_LIGHTGUN_TURBO 4 /*Use Aux:B instead*/ |
243 #define RETRO_DEVICE_ID_LIGHTGUN_PAUSE 5 /*Use Start*/ | 431 #define RETRO_DEVICE_ID_LIGHTGUN_PAUSE 5 /*Use Start instead*/ |
244 | 432 |
245 /* Id values for POINTER. */ | 433 /* Id values for POINTER. */ |
246 #define RETRO_DEVICE_ID_POINTER_X 0 | 434 #define RETRO_DEVICE_ID_POINTER_X 0 |
247 #define RETRO_DEVICE_ID_POINTER_Y 1 | 435 #define RETRO_DEVICE_ID_POINTER_Y 1 |
248 #define RETRO_DEVICE_ID_POINTER_PRESSED 2 | 436 #define RETRO_DEVICE_ID_POINTER_PRESSED 2 |
437 #define RETRO_DEVICE_ID_POINTER_COUNT 3 | |
438 /** Indicates if pointer is off the screen or near the edge */ | |
439 #define RETRO_DEVICE_ID_POINTER_IS_OFFSCREEN 15 | |
440 /** @} */ | |
249 | 441 |
250 /* Returned from retro_get_region(). */ | 442 /* Returned from retro_get_region(). */ |
251 #define RETRO_REGION_NTSC 0 | 443 #define RETRO_REGION_NTSC 0 |
252 #define RETRO_REGION_PAL 1 | 444 #define RETRO_REGION_PAL 1 |
253 | 445 |
254 /* Id values for LANGUAGE */ | 446 /** |
447 * Identifiers for supported languages. | |
448 * @see RETRO_ENVIRONMENT_GET_LANGUAGE | |
449 */ | |
255 enum retro_language | 450 enum retro_language |
256 { | 451 { |
257 RETRO_LANGUAGE_ENGLISH = 0, | 452 RETRO_LANGUAGE_ENGLISH = 0, |
258 RETRO_LANGUAGE_JAPANESE = 1, | 453 RETRO_LANGUAGE_JAPANESE = 1, |
259 RETRO_LANGUAGE_FRENCH = 2, | 454 RETRO_LANGUAGE_FRENCH = 2, |
269 RETRO_LANGUAGE_CHINESE_SIMPLIFIED = 12, | 464 RETRO_LANGUAGE_CHINESE_SIMPLIFIED = 12, |
270 RETRO_LANGUAGE_ESPERANTO = 13, | 465 RETRO_LANGUAGE_ESPERANTO = 13, |
271 RETRO_LANGUAGE_POLISH = 14, | 466 RETRO_LANGUAGE_POLISH = 14, |
272 RETRO_LANGUAGE_VIETNAMESE = 15, | 467 RETRO_LANGUAGE_VIETNAMESE = 15, |
273 RETRO_LANGUAGE_ARABIC = 16, | 468 RETRO_LANGUAGE_ARABIC = 16, |
469 RETRO_LANGUAGE_GREEK = 17, | |
470 RETRO_LANGUAGE_TURKISH = 18, | |
471 RETRO_LANGUAGE_SLOVAK = 19, | |
472 RETRO_LANGUAGE_PERSIAN = 20, | |
473 RETRO_LANGUAGE_HEBREW = 21, | |
474 RETRO_LANGUAGE_ASTURIAN = 22, | |
475 RETRO_LANGUAGE_FINNISH = 23, | |
476 RETRO_LANGUAGE_INDONESIAN = 24, | |
477 RETRO_LANGUAGE_SWEDISH = 25, | |
478 RETRO_LANGUAGE_UKRAINIAN = 26, | |
479 RETRO_LANGUAGE_CZECH = 27, | |
480 RETRO_LANGUAGE_CATALAN_VALENCIA = 28, | |
481 RETRO_LANGUAGE_CATALAN = 29, | |
482 RETRO_LANGUAGE_BRITISH_ENGLISH = 30, | |
483 RETRO_LANGUAGE_HUNGARIAN = 31, | |
484 RETRO_LANGUAGE_BELARUSIAN = 32, | |
485 RETRO_LANGUAGE_GALICIAN = 33, | |
486 RETRO_LANGUAGE_NORWEGIAN = 34, | |
274 RETRO_LANGUAGE_LAST, | 487 RETRO_LANGUAGE_LAST, |
275 | 488 |
276 /* Ensure sizeof(enum) == sizeof(int) */ | 489 /** Defined to ensure that <tt>sizeof(retro_language) == sizeof(int)</tt>. Do not use. */ |
277 RETRO_LANGUAGE_DUMMY = INT_MAX | 490 RETRO_LANGUAGE_DUMMY = INT_MAX |
278 }; | 491 }; |
492 | |
493 /** @defgroup RETRO_MEMORY Memory Types | |
494 * @{ | |
495 */ | |
279 | 496 |
280 /* Passed to retro_get_memory_data/size(). | 497 /* Passed to retro_get_memory_data/size(). |
281 * If the memory type doesn't apply to the | 498 * If the memory type doesn't apply to the |
282 * implementation NULL/0 can be returned. | 499 * implementation NULL/0 can be returned. |
283 */ | 500 */ |
298 /* System ram lets a frontend peek into a game systems main RAM. */ | 515 /* System ram lets a frontend peek into a game systems main RAM. */ |
299 #define RETRO_MEMORY_SYSTEM_RAM 2 | 516 #define RETRO_MEMORY_SYSTEM_RAM 2 |
300 | 517 |
301 /* Video ram lets a frontend peek into a game systems video RAM (VRAM). */ | 518 /* Video ram lets a frontend peek into a game systems video RAM (VRAM). */ |
302 #define RETRO_MEMORY_VIDEO_RAM 3 | 519 #define RETRO_MEMORY_VIDEO_RAM 3 |
520 | |
521 /** @} */ | |
303 | 522 |
304 /* Keysyms used for ID in input state callback when polling RETRO_KEYBOARD. */ | 523 /* Keysyms used for ID in input state callback when polling RETRO_KEYBOARD. */ |
305 enum retro_key | 524 enum retro_key |
306 { | 525 { |
307 RETROK_UNKNOWN = 0, | 526 RETROK_UNKNOWN = 0, |
448 RETROK_BREAK = 318, | 667 RETROK_BREAK = 318, |
449 RETROK_MENU = 319, | 668 RETROK_MENU = 319, |
450 RETROK_POWER = 320, | 669 RETROK_POWER = 320, |
451 RETROK_EURO = 321, | 670 RETROK_EURO = 321, |
452 RETROK_UNDO = 322, | 671 RETROK_UNDO = 322, |
672 RETROK_OEM_102 = 323, | |
673 | |
674 RETROK_BROWSER_BACK = 324, | |
675 RETROK_BROWSER_FORWARD = 325, | |
676 RETROK_BROWSER_REFRESH = 326, | |
677 RETROK_BROWSER_STOP = 327, | |
678 RETROK_BROWSER_SEARCH = 328, | |
679 RETROK_BROWSER_FAVORITES = 329, | |
680 RETROK_BROWSER_HOME = 330, | |
681 RETROK_VOLUME_MUTE = 331, | |
682 RETROK_VOLUME_DOWN = 332, | |
683 RETROK_VOLUME_UP = 333, | |
684 RETROK_MEDIA_NEXT = 334, | |
685 RETROK_MEDIA_PREV = 335, | |
686 RETROK_MEDIA_STOP = 336, | |
687 RETROK_MEDIA_PLAY_PAUSE = 337, | |
688 RETROK_LAUNCH_MAIL = 338, | |
689 RETROK_LAUNCH_MEDIA = 339, | |
690 RETROK_LAUNCH_APP1 = 340, | |
691 RETROK_LAUNCH_APP2 = 341, | |
453 | 692 |
454 RETROK_LAST, | 693 RETROK_LAST, |
455 | 694 |
456 RETROK_DUMMY = INT_MAX /* Ensure sizeof(enum) == sizeof(int) */ | 695 RETROK_DUMMY = INT_MAX /* Ensure sizeof(enum) == sizeof(int) */ |
457 }; | 696 }; |
470 RETROKMOD_SCROLLOCK = 0x40, | 709 RETROKMOD_SCROLLOCK = 0x40, |
471 | 710 |
472 RETROKMOD_DUMMY = INT_MAX /* Ensure sizeof(enum) == sizeof(int) */ | 711 RETROKMOD_DUMMY = INT_MAX /* Ensure sizeof(enum) == sizeof(int) */ |
473 }; | 712 }; |
474 | 713 |
475 /* If set, this call is not part of the public libretro API yet. It can | 714 /** |
476 * change or be removed at any time. */ | 715 * @defgroup RETRO_ENVIRONMENT Environment Callbacks |
716 * @{ | |
717 */ | |
718 | |
719 /** | |
720 * This bit indicates that the associated environment call is experimental, | |
721 * and may be changed or removed in the future. | |
722 * Frontends should mask out this bit before handling the environment call. | |
723 */ | |
477 #define RETRO_ENVIRONMENT_EXPERIMENTAL 0x10000 | 724 #define RETRO_ENVIRONMENT_EXPERIMENTAL 0x10000 |
478 /* Environment callback to be used internally in frontend. */ | 725 |
726 /** Frontend-internal environment callbacks should include this bit. */ | |
479 #define RETRO_ENVIRONMENT_PRIVATE 0x20000 | 727 #define RETRO_ENVIRONMENT_PRIVATE 0x20000 |
480 | 728 |
481 /* Environment commands. */ | 729 /* Environment commands. */ |
482 #define RETRO_ENVIRONMENT_SET_ROTATION 1 /* const unsigned * -- | 730 /** |
483 * Sets screen rotation of graphics. | 731 * Requests the frontend to set the screen rotation. |
484 * Is only implemented if rotation can be accelerated by hardware. | 732 * |
485 * Valid values are 0, 1, 2, 3, which rotates screen by 0, 90, 180, | 733 * @param[in] data <tt>const unsigned*</tt>. |
486 * 270 degrees counter-clockwise respectively. | 734 * Valid values are 0, 1, 2, and 3. |
735 * These numbers respectively set the screen rotation to 0, 90, 180, and 270 degrees counter-clockwise. | |
736 * @returns \c true if the screen rotation was set successfully. | |
737 */ | |
738 #define RETRO_ENVIRONMENT_SET_ROTATION 1 | |
739 | |
740 /** | |
741 * Queries whether the core should use overscan or not. | |
742 * | |
743 * @param[out] data <tt>bool*</tt>. | |
744 * Set to \c true if the core should use overscan, | |
745 * \c false if it should be cropped away. | |
746 * @returns \c true if the environment call is available. | |
747 * Does \em not indicate whether overscan should be used. | |
748 * @deprecated As of 2019 this callback is considered deprecated in favor of | |
749 * using core options to manage overscan in a more nuanced, core-specific way. | |
750 */ | |
751 #define RETRO_ENVIRONMENT_GET_OVERSCAN 2 | |
752 | |
753 /** | |
754 * Queries whether the frontend supports frame duping, | |
755 * in the form of passing \c NULL to the video frame callback. | |
756 * | |
757 * @param[out] data <tt>bool*</tt>. | |
758 * Set to \c true if the frontend supports frame duping. | |
759 * @returns \c true if the environment call is available. | |
760 * @see retro_video_refresh_t | |
761 */ | |
762 #define RETRO_ENVIRONMENT_GET_CAN_DUPE 3 | |
763 | |
764 /* | |
765 * Environ 4, 5 are no longer supported (GET_VARIABLE / SET_VARIABLES), | |
766 * and reserved to avoid possible ABI clash. | |
767 */ | |
768 | |
769 /** | |
770 * @brief Displays a user-facing message for a short time. | |
771 * | |
772 * Use this callback to convey important status messages, | |
773 * such as errors or the result of long-running operations. | |
774 * For trivial messages or logging, use \c RETRO_ENVIRONMENT_GET_LOG_INTERFACE or \c stderr. | |
775 * | |
776 * \code{.c} | |
777 * void set_message_example(void) | |
778 * { | |
779 * struct retro_message msg; | |
780 * msg.frames = 60 * 5; // 5 seconds | |
781 * msg.msg = "Hello world!"; | |
782 * | |
783 * environ_cb(RETRO_ENVIRONMENT_SET_MESSAGE, &msg); | |
784 * } | |
785 * \endcode | |
786 * | |
787 * @deprecated Prefer using \c RETRO_ENVIRONMENT_SET_MESSAGE_EXT for new code, | |
788 * as it offers more features. | |
789 * Only use this environment call for compatibility with older cores or frontends. | |
790 * | |
791 * @param[in] data <tt>const struct retro_message*</tt>. | |
792 * Details about the message to show to the user. | |
793 * Behavior is undefined if <tt>NULL</tt>. | |
794 * @returns \c true if the environment call is available. | |
795 * @see retro_message | |
796 * @see RETRO_ENVIRONMENT_GET_LOG_INTERFACE | |
797 * @see RETRO_ENVIRONMENT_SET_MESSAGE_EXT | |
798 * @see RETRO_ENVIRONMENT_SET_MESSAGE | |
799 * @see RETRO_ENVIRONMENT_GET_MESSAGE_INTERFACE_VERSION | |
800 * @note The frontend must make its own copy of the message and the underlying string. | |
801 */ | |
802 #define RETRO_ENVIRONMENT_SET_MESSAGE 6 | |
803 | |
804 /** | |
805 * Requests the frontend to shutdown the core. | |
806 * Should only be used if the core can exit on its own, | |
807 * such as from a menu item in a game | |
808 * or an emulated power-off in an emulator. | |
809 * | |
810 * @param data Ignored. | |
811 * @returns \c true if the environment call is available. | |
812 */ | |
813 #define RETRO_ENVIRONMENT_SHUTDOWN 7 | |
814 | |
815 /** | |
816 * Gives a hint to the frontend of how demanding this core is on the system. | |
817 * For example, reporting a level of 2 means that | |
818 * this implementation should run decently on frontends | |
819 * of level 2 and above. | |
820 * | |
821 * It can be used by the frontend to potentially warn | |
822 * about too demanding implementations. | |
823 * | |
824 * The levels are "floating". | |
825 * | |
826 * This function can be called on a per-game basis, | |
827 * as a core may have different demands for different games or settings. | |
828 * If called, it should be called in <tt>retro_load_game()</tt>. | |
829 * @param[in] data <tt>const unsigned*</tt>. | |
830 */ | |
831 #define RETRO_ENVIRONMENT_SET_PERFORMANCE_LEVEL 8 | |
832 | |
833 /** | |
834 * Returns the path to the frontend's system directory, | |
835 * which can be used to store system-specific configuration | |
836 * such as BIOS files or cached data. | |
837 * | |
838 * @param[out] data <tt>const char**</tt>. | |
839 * Pointer to the \c char* in which the system directory will be saved. | |
840 * The string is managed by the frontend and must not be modified or freed by the core. | |
841 * May be \c NULL if no system directory is defined, | |
842 * in which case the core should find an alternative directory. | |
843 * @return \c true if the environment call is available, | |
844 * even if the value returned in \c data is <tt>NULL</tt>. | |
845 * @note Historically, some cores would use this folder for save data such as memory cards or SRAM. | |
846 * This is now discouraged in favor of \c RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY. | |
847 * @see RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY | |
848 */ | |
849 #define RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY 9 | |
850 | |
851 /** | |
852 * Sets the internal pixel format used by the frontend for rendering. | |
853 * The default pixel format is \c RETRO_PIXEL_FORMAT_0RGB1555 for compatibility reasons, | |
854 * although it's considered deprecated and shouldn't be used by new code. | |
855 * | |
856 * @param[in] data <tt>const enum retro_pixel_format *</tt>. | |
857 * Pointer to the pixel format to use. | |
858 * @returns \c true if the pixel format was set successfully, | |
859 * \c false if it's not supported or this callback is unavailable. | |
860 * @note This function should be called inside \c retro_load_game() | |
861 * or <tt>retro_get_system_av_info()</tt>. | |
862 * @see retro_pixel_format | |
863 */ | |
864 #define RETRO_ENVIRONMENT_SET_PIXEL_FORMAT 10 | |
865 | |
866 /** | |
867 * Sets an array of input descriptors for the frontend | |
868 * to present to the user for configuring the core's controls. | |
869 * | |
870 * This function can be called at any time, | |
871 * preferably early in the core's life cycle. | |
872 * Ideally, no later than \c retro_load_game(). | |
873 * | |
874 * @param[in] data <tt>const struct retro_input_descriptor *</tt>. | |
875 * An array of input descriptors terminated by one whose | |
876 * \c retro_input_descriptor::description field is set to \c NULL. | |
877 * Behavior is undefined if \c NULL. | |
878 * @return \c true if the environment call is recognized. | |
879 * @see retro_input_descriptor | |
880 */ | |
881 #define RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS 11 | |
882 | |
883 /** | |
884 * Sets a callback function used to notify the core about keyboard events. | |
885 * This should only be used for cores that specifically need keyboard input, | |
886 * such as for home computer emulators or games with text entry. | |
887 * | |
888 * @param[in] data <tt>const struct retro_keyboard_callback *</tt>. | |
889 * Pointer to the callback function. | |
890 * Behavior is undefined if <tt>NULL</tt>. | |
891 * @return \c true if the environment call is recognized. | |
892 * @see retro_keyboard_callback | |
893 * @see retro_key | |
894 */ | |
895 #define RETRO_ENVIRONMENT_SET_KEYBOARD_CALLBACK 12 | |
896 | |
897 /** | |
898 * Sets an interface that the frontend can use to insert and remove disks | |
899 * from the emulated console's disk drive. | |
900 * Can be used for optical disks, floppy disks, or any other game storage medium | |
901 * that can be swapped at runtime. | |
902 * | |
903 * This is intended for multi-disk games that expect the player | |
904 * to manually swap disks at certain points in the game. | |
905 * | |
906 * @deprecated Prefer using \c RETRO_ENVIRONMENT_SET_DISK_CONTROL_EXT_INTERFACE | |
907 * over this environment call, as it supports additional features. | |
908 * Only use this callback to maintain compatibility | |
909 * with older cores or frontends. | |
910 * | |
911 * @param[in] data <tt>const struct retro_disk_control_callback *</tt>. | |
912 * Pointer to the callback functions to use. | |
913 * May be \c NULL, in which case the existing disk callback is deregistered. | |
914 * @return \c true if this environment call is available, | |
915 * even if \c data is \c NULL. | |
916 * @see retro_disk_control_callback | |
917 * @see RETRO_ENVIRONMENT_SET_DISK_CONTROL_EXT_INTERFACE | |
918 */ | |
919 #define RETRO_ENVIRONMENT_SET_DISK_CONTROL_INTERFACE 13 | |
920 | |
921 /** | |
922 * Requests that a frontend enable a particular hardware rendering API. | |
923 * | |
924 * If successful, the frontend will create a context (and other related resources) | |
925 * that the core can use for rendering. | |
926 * The framebuffer will be at least as large as | |
927 * the maximum dimensions provided in <tt>retro_get_system_av_info</tt>. | |
928 * | |
929 * @param[in, out] data <tt>struct retro_hw_render_callback *</tt>. | |
930 * Pointer to the hardware render callback struct. | |
931 * Used to define callbacks for the hardware-rendering life cycle, | |
932 * as well as to request a particular rendering API. | |
933 * @return \c true if the environment call is recognized | |
934 * and the requested rendering API is supported. | |
935 * \c false if \c data is \c NULL | |
936 * or the frontend can't provide the requested rendering API. | |
937 * @see retro_hw_render_callback | |
938 * @see retro_video_refresh_t | |
939 * @see RETRO_ENVIRONMENT_GET_PREFERRED_HW_RENDER | |
940 * @note Should be called in <tt>retro_load_game()</tt>. | |
941 * @note If HW rendering is used, pass only \c RETRO_HW_FRAME_BUFFER_VALID or | |
942 * \c NULL to <tt>retro_video_refresh_t</tt>. | |
943 */ | |
944 #define RETRO_ENVIRONMENT_SET_HW_RENDER 14 | |
945 | |
946 /** | |
947 * Retrieves a core option's value from the frontend. | |
948 * \c retro_variable::key should be set to an option key | |
949 * that was previously set in \c RETRO_ENVIRONMENT_SET_VARIABLES | |
950 * (or a similar environment call). | |
951 * | |
952 * @param[in,out] data <tt>struct retro_variable *</tt>. | |
953 * Pointer to a single \c retro_variable struct. | |
954 * See the documentation for \c retro_variable for details | |
955 * on which fields are set by the frontend or core. | |
956 * May be \c NULL. | |
957 * @returns \c true if the environment call is available, | |
958 * even if \c data is \c NULL or the key it specifies is not found. | |
959 * @note Passing \c NULL in to \c data can be useful to | |
960 * test for support of this environment call without looking up any variables. | |
961 * @see retro_variable | |
962 * @see RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2 | |
963 * @see RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE | |
964 */ | |
965 #define RETRO_ENVIRONMENT_GET_VARIABLE 15 | |
966 | |
967 /** | |
968 * Notifies the frontend of the core's available options. | |
969 * | |
970 * The core may check these options later using \c RETRO_ENVIRONMENT_GET_VARIABLE. | |
971 * The frontend may also present these options to the user | |
972 * in its own configuration UI. | |
973 * | |
974 * This should be called the first time as early as possible, | |
975 * ideally in \c retro_set_environment. | |
976 * The core may later call this function again | |
977 * to communicate updated options to the frontend, | |
978 * but the number of core options must not change. | |
979 * | |
980 * Here's an example that sets two options. | |
981 * | |
982 * @code | |
983 * void set_variables_example(void) | |
984 * { | |
985 * struct retro_variable options[] = { | |
986 * { "foo_speedhack", "Speed hack; false|true" }, // false by default | |
987 * { "foo_displayscale", "Display scale factor; 1|2|3|4" }, // 1 by default | |
988 * { NULL, NULL }, | |
989 * }; | |
990 * | |
991 * environ_cb(RETRO_ENVIRONMENT_SET_VARIABLES, &options); | |
992 * } | |
993 * @endcode | |
994 * | |
995 * The possible values will generally be displayed and stored as-is by the frontend. | |
996 * | |
997 * @deprecated Prefer using \c RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2 for new code, | |
998 * as it offers more features such as categories and translation. | |
999 * Only use this environment call to maintain compatibility | |
1000 * with older frontends or cores. | |
1001 * @note Keep the available options (and their possible values) as low as possible; | |
1002 * it should be feasible to cycle through them without a keyboard. | |
1003 * @param[in] data <tt>const struct retro_variable *</tt>. | |
1004 * Pointer to an array of \c retro_variable structs that define available core options, | |
1005 * terminated by a <tt>{ NULL, NULL }</tt> element. | |
1006 * The frontend must maintain its own copy of this array. | |
1007 * | |
1008 * @returns \c true if the environment call is available, | |
1009 * even if \c data is <tt>NULL</tt>. | |
1010 * @see retro_variable | |
1011 * @see RETRO_ENVIRONMENT_GET_VARIABLE | |
1012 * @see RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE | |
1013 * @see RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2 | |
1014 */ | |
1015 #define RETRO_ENVIRONMENT_SET_VARIABLES 16 | |
1016 | |
1017 /** | |
1018 * Queries whether at least one core option was updated by the frontend | |
1019 * since the last call to \ref RETRO_ENVIRONMENT_GET_VARIABLE. | |
1020 * This typically means that the user opened the core options menu and made some changes. | |
1021 * | |
1022 * Cores usually call this each frame before the core's main emulation logic. | |
1023 * Specific options can then be queried with \ref RETRO_ENVIRONMENT_GET_VARIABLE. | |
1024 * | |
1025 * @param[out] data <tt>bool *</tt>. | |
1026 * Set to \c true if at least one core option was updated | |
1027 * since the last call to \ref RETRO_ENVIRONMENT_GET_VARIABLE. | |
1028 * Behavior is undefined if this pointer is \c NULL. | |
1029 * @returns \c true if the environment call is available. | |
1030 * @see RETRO_ENVIRONMENT_GET_VARIABLE | |
1031 * @see RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2 | |
1032 */ | |
1033 #define RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE 17 | |
1034 | |
1035 /** | |
1036 * Notifies the frontend that this core can run without loading any content, | |
1037 * such as when emulating a console that has built-in software. | |
1038 * When a core is loaded without content, | |
1039 * \c retro_load_game receives an argument of <tt>NULL</tt>. | |
1040 * This should be called within \c retro_set_environment() only. | |
1041 * | |
1042 * @param[in] data <tt>const bool *</tt>. | |
1043 * Pointer to a single \c bool that indicates whether this frontend can run without content. | |
1044 * Can point to a value of \c false but this isn't necessary, | |
1045 * as contentless support is opt-in. | |
1046 * The behavior is undefined if \c data is <tt>NULL</tt>. | |
1047 * @returns \c true if the environment call is available. | |
1048 * @see retro_load_game | |
1049 */ | |
1050 #define RETRO_ENVIRONMENT_SET_SUPPORT_NO_GAME 18 | |
1051 | |
1052 /** | |
1053 * Retrieves the absolute path from which this core was loaded. | |
1054 * Useful when loading assets from paths relative to the core, | |
1055 * as is sometimes the case when using <tt>RETRO_ENVIRONMENT_SET_SUPPORT_NO_GAME</tt>. | |
1056 * | |
1057 * @param[out] data <tt>const char **</tt>. | |
1058 * Pointer to a string in which the core's path will be saved. | |
1059 * The string is managed by the frontend and must not be modified or freed by the core. | |
1060 * May be \c NULL if the core is statically linked to the frontend | |
1061 * or if the core's path otherwise cannot be determined. | |
1062 * Behavior is undefined if \c data is <tt>NULL</tt>. | |
1063 * @returns \c true if the environment call is available. | |
1064 */ | |
1065 #define RETRO_ENVIRONMENT_GET_LIBRETRO_PATH 19 | |
1066 | |
1067 /* Environment call 20 was an obsolete version of SET_AUDIO_CALLBACK. | |
1068 * It was not used by any known core at the time, and was removed from the API. | |
1069 * The number 20 is reserved to prevent ABI clashes. | |
1070 */ | |
1071 | |
1072 /** | |
1073 * Sets a callback that notifies the core of how much time has passed | |
1074 * since the last iteration of <tt>retro_run</tt>. | |
1075 * If the frontend is not running the core in real time | |
1076 * (e.g. it's frame-stepping or running in slow motion), | |
1077 * then the reference value will be provided to the callback instead. | |
1078 * | |
1079 * @param[in] data <tt>const struct retro_frame_time_callback *</tt>. | |
1080 * Pointer to a single \c retro_frame_time_callback struct. | |
1081 * Behavior is undefined if \c data is <tt>NULL</tt>. | |
1082 * @returns \c true if the environment call is available. | |
1083 * @note Frontends may disable this environment call in certain situations. | |
1084 * It will return \c false in those cases. | |
1085 * @see retro_frame_time_callback | |
1086 */ | |
1087 #define RETRO_ENVIRONMENT_SET_FRAME_TIME_CALLBACK 21 | |
1088 | |
1089 /** | |
1090 * Registers a set of functions that the frontend can use | |
1091 * to tell the core it's ready for audio output. | |
1092 * | |
1093 * It is intended for games that feature asynchronous audio. | |
1094 * It should not be used for emulators unless their audio is asynchronous. | |
1095 * | |
1096 * | |
1097 * The callback only notifies about writability; the libretro core still | |
1098 * has to call the normal audio callbacks | |
1099 * to write audio. The audio callbacks must be called from within the | |
1100 * notification callback. | |
1101 * The amount of audio data to write is up to the core. | |
1102 * Generally, the audio callback will be called continuously in a loop. | |
1103 * | |
1104 * A frontend may disable this callback in certain situations. | |
1105 * The core must be able to render audio with the "normal" interface. | |
1106 * | |
1107 * @param[in] data <tt>const struct retro_audio_callback *</tt>. | |
1108 * Pointer to a set of functions that the frontend will call to notify the core | |
1109 * when it's ready to receive audio data. | |
1110 * May be \c NULL, in which case the frontend will return | |
1111 * whether this environment callback is available. | |
1112 * @return \c true if this environment call is available, | |
1113 * even if \c data is \c NULL. | |
1114 * @warning The provided callbacks can be invoked from any thread, | |
1115 * so their implementations \em must be thread-safe. | |
1116 * @note If a core uses this callback, | |
1117 * it should also use <tt>RETRO_ENVIRONMENT_SET_FRAME_TIME_CALLBACK</tt>. | |
1118 * @see retro_audio_callback | |
1119 * @see retro_audio_sample_t | |
1120 * @see retro_audio_sample_batch_t | |
1121 * @see RETRO_ENVIRONMENT_SET_FRAME_TIME_CALLBACK | |
1122 */ | |
1123 #define RETRO_ENVIRONMENT_SET_AUDIO_CALLBACK 22 | |
1124 | |
1125 /** | |
1126 * Gets an interface that a core can use to access a controller's rumble motors. | |
1127 * | |
1128 * The interface supports two independently-controlled motors, | |
1129 * one strong and one weak. | |
1130 * | |
1131 * Should be called from either \c retro_init() or \c retro_load_game(), | |
1132 * but not from \c retro_set_environment(). | |
1133 * | |
1134 * @param[out] data <tt>struct retro_rumble_interface *</tt>. | |
1135 * Pointer to the interface struct. | |
1136 * Behavior is undefined if \c NULL. | |
1137 * @returns \c true if the environment call is available, | |
1138 * even if the current device doesn't support vibration. | |
1139 * @see retro_rumble_interface | |
1140 * @defgroup GET_RUMBLE_INTERFACE Rumble Interface | |
1141 */ | |
1142 #define RETRO_ENVIRONMENT_GET_RUMBLE_INTERFACE 23 | |
1143 | |
1144 /** | |
1145 * Returns the frontend's supported input device types. | |
1146 * | |
1147 * The supported device types are returned as a bitmask, | |
1148 * with each value of \ref RETRO_DEVICE corresponding to a bit. | |
1149 * | |
1150 * Should only be called in \c retro_run(). | |
1151 * | |
1152 * @code | |
1153 * #define REQUIRED_DEVICES ((1 << RETRO_DEVICE_JOYPAD) | (1 << RETRO_DEVICE_ANALOG)) | |
1154 * void get_input_device_capabilities_example(void) | |
1155 * { | |
1156 * uint64_t capabilities; | |
1157 * environ_cb(RETRO_ENVIRONMENT_GET_INPUT_DEVICE_CAPABILITIES, &capabilities); | |
1158 * if ((capabilities & REQUIRED_DEVICES) == REQUIRED_DEVICES) | |
1159 * printf("Joypad and analog device types are supported"); | |
1160 * } | |
1161 * @endcode | |
1162 * | |
1163 * @param[out] data <tt>uint64_t *</tt>. | |
1164 * Pointer to a bitmask of supported input device types. | |
1165 * If the frontend supports a particular \c RETRO_DEVICE_* type, | |
1166 * then the bit <tt>(1 << RETRO_DEVICE_*)</tt> will be set. | |
1167 * | |
1168 * Each bit represents a \c RETRO_DEVICE constant, | |
1169 * e.g. bit 1 represents \c RETRO_DEVICE_JOYPAD, | |
1170 * bit 2 represents \c RETRO_DEVICE_MOUSE, and so on. | |
1171 * | |
1172 * Bits that do not correspond to known device types will be set to zero | |
1173 * and are reserved for future use. | |
1174 * | |
1175 * Behavior is undefined if \c NULL. | |
1176 * @returns \c true if the environment call is available. | |
1177 * @note If the frontend supports multiple input drivers, | |
1178 * availability of this environment call (and the reported capabilities) | |
1179 * may depend on the active driver. | |
1180 * @see RETRO_DEVICE | |
1181 */ | |
1182 #define RETRO_ENVIRONMENT_GET_INPUT_DEVICE_CAPABILITIES 24 | |
1183 | |
1184 /** | |
1185 * Returns an interface that the core can use to access and configure available sensors, | |
1186 * such as an accelerometer or gyroscope. | |
1187 * | |
1188 * @param[out] data <tt>struct retro_sensor_interface *</tt>. | |
1189 * Pointer to the sensor interface that the frontend will populate. | |
1190 * Behavior is undefined if is \c NULL. | |
1191 * @returns \c true if the environment call is available, | |
1192 * even if the device doesn't have any supported sensors. | |
1193 * @see retro_sensor_interface | |
1194 * @see retro_sensor_action | |
1195 * @see RETRO_SENSOR | |
1196 * @addtogroup RETRO_SENSOR | |
1197 */ | |
1198 #define RETRO_ENVIRONMENT_GET_SENSOR_INTERFACE (25 | RETRO_ENVIRONMENT_EXPERIMENTAL) | |
1199 | |
1200 /** | |
1201 * Gets an interface to the device's video camera. | |
1202 * | |
1203 * The frontend delivers new video frames via a user-defined callback | |
1204 * that runs in the same thread as \c retro_run(). | |
1205 * Should be called in \c retro_load_game(). | |
1206 * | |
1207 * @param[in,out] data <tt>struct retro_camera_callback *</tt>. | |
1208 * Pointer to the camera driver interface. | |
1209 * Some fields in the struct must be filled in by the core, | |
1210 * others are provided by the frontend. | |
1211 * Behavior is undefined if \c NULL. | |
1212 * @returns \c true if this environment call is available, | |
1213 * even if an actual camera isn't. | |
1214 * @note This API only supports one video camera at a time. | |
1215 * If the device provides multiple cameras (e.g. inner/outer cameras on a phone), | |
1216 * the frontend will choose one to use. | |
1217 * @see retro_camera_callback | |
1218 * @see RETRO_ENVIRONMENT_SET_HW_RENDER | |
1219 */ | |
1220 #define RETRO_ENVIRONMENT_GET_CAMERA_INTERFACE (26 | RETRO_ENVIRONMENT_EXPERIMENTAL) | |
1221 | |
1222 /** | |
1223 * Gets an interface that the core can use for cross-platform logging. | |
1224 * Certain platforms don't have a console or <tt>stderr</tt>, | |
1225 * or they have their own preferred logging methods. | |
1226 * The frontend itself may also display log output. | |
1227 * | |
1228 * @attention This should not be used for information that the player must immediately see, | |
1229 * such as major errors or warnings. | |
1230 * In most cases, this is best for information that will help you (the developer) | |
1231 * identify problems when debugging or providing support. | |
1232 * Unless a core or frontend is intended for advanced users, | |
1233 * the player might not check (or even know about) their logs. | |
1234 * | |
1235 * @param[out] data <tt>struct retro_log_callback *</tt>. | |
1236 * Pointer to the callback where the function pointer will be saved. | |
1237 * Behavior is undefined if \c data is <tt>NULL</tt>. | |
1238 * @returns \c true if the environment call is available. | |
1239 * @see retro_log_callback | |
1240 * @note Cores can fall back to \c stderr if this interface is not available. | |
1241 */ | |
1242 #define RETRO_ENVIRONMENT_GET_LOG_INTERFACE 27 | |
1243 | |
1244 /** | |
1245 * Returns an interface that the core can use for profiling code | |
1246 * and to access performance-related information. | |
1247 * | |
1248 * This callback supports performance counters, a high-resolution timer, | |
1249 * and listing available CPU features (mostly SIMD instructions). | |
1250 * | |
1251 * @param[out] data <tt>struct retro_perf_callback *</tt>. | |
1252 * Pointer to the callback interface. | |
1253 * Behavior is undefined if \c NULL. | |
1254 * @returns \c true if the environment call is available. | |
1255 * @see retro_perf_callback | |
1256 */ | |
1257 #define RETRO_ENVIRONMENT_GET_PERF_INTERFACE 28 | |
1258 | |
1259 /** | |
1260 * Returns an interface that the core can use to retrieve the device's location, | |
1261 * including its current latitude and longitude. | |
1262 * | |
1263 * @param[out] data <tt>struct retro_location_callback *</tt>. | |
1264 * Pointer to the callback interface. | |
1265 * Behavior is undefined if \c NULL. | |
1266 * @return \c true if the environment call is available, | |
1267 * even if there's no location information available. | |
1268 * @see retro_location_callback | |
1269 */ | |
1270 #define RETRO_ENVIRONMENT_GET_LOCATION_INTERFACE 29 | |
1271 | |
1272 /** | |
1273 * @deprecated An obsolete alias to \c RETRO_ENVIRONMENT_GET_CORE_ASSETS_DIRECTORY kept for compatibility. | |
1274 * @see RETRO_ENVIRONMENT_GET_CORE_ASSETS_DIRECTORY | |
1275 **/ | |
1276 #define RETRO_ENVIRONMENT_GET_CONTENT_DIRECTORY 30 | |
1277 | |
1278 /** | |
1279 * Returns the frontend's "core assets" directory, | |
1280 * which can be used to store assets that the core needs | |
1281 * such as art assets or level data. | |
1282 * | |
1283 * @param[out] data <tt>const char **</tt>. | |
1284 * Pointer to a string in which the core assets directory will be saved. | |
1285 * This string is managed by the frontend and must not be modified or freed by the core. | |
1286 * May be \c NULL if no core assets directory is defined, | |
1287 * in which case the core should find an alternative directory. | |
1288 * Behavior is undefined if \c data is <tt>NULL</tt>. | |
1289 * @returns \c true if the environment call is available, | |
1290 * even if the value returned in \c data is <tt>NULL</tt>. | |
1291 */ | |
1292 #define RETRO_ENVIRONMENT_GET_CORE_ASSETS_DIRECTORY 30 | |
1293 | |
1294 /** | |
1295 * Returns the frontend's save data directory, if available. | |
1296 * This directory should be used to store game-specific save data, | |
1297 * including memory card images. | |
1298 * | |
1299 * Although libretro provides an interface for cores to expose SRAM to the frontend, | |
1300 * not all cores can support it correctly. | |
1301 * In this case, cores should use this environment callback | |
1302 * to save their game data to disk manually. | |
1303 * | |
1304 * Cores that use this environment callback | |
1305 * should flush their save data to disk periodically and when unloading. | |
1306 * | |
1307 * @param[out] data <tt>const char **</tt>. | |
1308 * Pointer to the string in which the save data directory will be saved. | |
1309 * This string is managed by the frontend and must not be modified or freed by the core. | |
1310 * May return \c NULL if no save data directory is defined. | |
1311 * Behavior is undefined if \c data is <tt>NULL</tt>. | |
1312 * @returns \c true if the environment call is available, | |
1313 * even if the value returned in \c data is <tt>NULL</tt>. | |
1314 * @note Early libretro cores used \c RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY for save data. | |
1315 * This is still supported for backwards compatibility, | |
1316 * but new cores should use this environment call instead. | |
1317 * \c RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY should be used for game-agnostic data | |
1318 * such as BIOS files or core-specific configuration. | |
1319 * @note The returned directory may or may not be the same | |
1320 * as the one used for \c retro_get_memory_data. | |
1321 * | |
1322 * @see retro_get_memory_data | |
1323 * @see RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY | |
1324 */ | |
1325 #define RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY 31 | |
1326 | |
1327 /** | |
1328 * Sets new video and audio parameters for the core. | |
1329 * This can only be called from within <tt>retro_run</tt>. | |
1330 * | |
1331 * This environment call may entail a full reinitialization of the frontend's audio/video drivers, | |
1332 * hence it should \em only be used if the core needs to make drastic changes | |
1333 * to audio/video parameters. | |
1334 * | |
1335 * This environment call should \em not be used when: | |
1336 * <ul> | |
1337 * <li>Changing the emulated system's internal resolution, | |
1338 * within the limits defined by the existing values of \c max_width and \c max_height. | |
1339 * Use \c RETRO_ENVIRONMENT_SET_GEOMETRY instead, | |
1340 * and adjust \c retro_get_system_av_info to account for | |
1341 * supported scale factors and screen layouts | |
1342 * when computing \c max_width and \c max_height. | |
1343 * Only use this environment call if \c max_width or \c max_height needs to increase. | |
1344 * <li>Adjusting the screen's aspect ratio, | |
1345 * e.g. when changing the layout of the screen(s). | |
1346 * Use \c RETRO_ENVIRONMENT_SET_GEOMETRY or \c RETRO_ENVIRONMENT_SET_ROTATION instead. | |
1347 * </ul> | |
1348 * | |
1349 * The frontend will reinitialize its audio and video drivers within this callback; | |
1350 * after that happens, audio and video callbacks will target the newly-initialized driver, | |
1351 * even within the same \c retro_run call. | |
1352 * | |
1353 * This callback makes it possible to support configurable resolutions | |
1354 * while avoiding the need to compute the "worst case" values of \c max_width and \c max_height. | |
1355 * | |
1356 * @param[in] data <tt>const struct retro_system_av_info *</tt>. | |
1357 * Pointer to the new video and audio parameters that the frontend should adopt. | |
1358 * @returns \c true if the environment call is available | |
1359 * and the new av_info struct was accepted. | |
1360 * \c false if the environment call is unavailable or \c data is <tt>NULL</tt>. | |
1361 * @see retro_system_av_info | |
1362 * @see RETRO_ENVIRONMENT_SET_GEOMETRY | |
1363 */ | |
1364 #define RETRO_ENVIRONMENT_SET_SYSTEM_AV_INFO 32 | |
1365 | |
1366 /** | |
1367 * Provides an interface that a frontend can use | |
1368 * to get function pointers from the core. | |
1369 * | |
1370 * This allows cores to define their own extensions to the libretro API, | |
1371 * or to expose implementations of a frontend's libretro extensions. | |
1372 * | |
1373 * @param[in] data <tt>const struct retro_get_proc_address_interface *</tt>. | |
1374 * Pointer to the interface that the frontend can use to get function pointers from the core. | |
1375 * The frontend must maintain its own copy of this interface. | |
1376 * @returns \c true if the environment call is available | |
1377 * and the returned interface was accepted. | |
1378 * @note The provided interface may be called at any time, | |
1379 * even before this environment call returns. | |
1380 * @note Extensions should be prefixed with the name of the frontend or core that defines them. | |
1381 * For example, a frontend named "foo" that defines a debugging extension | |
1382 * should expect the core to define functions prefixed with "foo_debug_". | |
1383 * @warning If a core wants to use this environment call, | |
1384 * it \em must do so from within \c retro_set_environment(). | |
1385 * @see retro_get_proc_address_interface | |
1386 */ | |
1387 #define RETRO_ENVIRONMENT_SET_PROC_ADDRESS_CALLBACK 33 | |
1388 | |
1389 /** | |
1390 * Registers a core's ability to handle "subsystems", | |
1391 * which are secondary platforms that augment a core's primary emulated hardware. | |
1392 * | |
1393 * A core doesn't need to emulate a secondary platform | |
1394 * in order to use it as a subsystem; | |
1395 * as long as it can load a secondary file for some practical use, | |
1396 * then this environment call is most likely suitable. | |
1397 * | |
1398 * Possible use cases of a subsystem include: | |
1399 * | |
1400 * \li Installing software onto an emulated console's internal storage, | |
1401 * such as the Nintendo DSi. | |
1402 * \li Emulating accessories that are used to support another console's games, | |
1403 * such as the Super Game Boy or the N64 Transfer Pak. | |
1404 * \li Inserting a secondary ROM into a console | |
1405 * that features multiple cartridge ports, | |
1406 * such as the Nintendo DS's Slot-2. | |
1407 * \li Loading a save data file created and used by another core. | |
1408 * | |
1409 * Cores should \em not use subsystems for: | |
1410 * | |
1411 * \li Emulators that support multiple "primary" platforms, | |
1412 * such as a Game Boy/Game Boy Advance core | |
1413 * or a Sega Genesis/Sega CD/32X core. | |
1414 * Use \c retro_system_content_info_override, \c retro_system_info, | |
1415 * and/or runtime detection instead. | |
1416 * \li Selecting different memory card images. | |
1417 * Use dynamically-populated core options instead. | |
1418 * \li Different variants of a single console, | |
1419 * such the Game Boy vs. the Game Boy Color. | |
1420 * Use core options or runtime detection instead. | |
1421 * \li Games that span multiple disks. | |
1422 * Use \c RETRO_ENVIRONMENT_SET_DISK_CONTROL_EXT_INTERFACE | |
1423 * and m3u-formatted playlists instead. | |
1424 * \li Console system files (BIOS, firmware, etc.). | |
1425 * Use \c RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY | |
1426 * and a common naming convention instead. | |
1427 * | |
1428 * When the frontend loads a game via a subsystem, | |
1429 * it must call \c retro_load_game_special() instead of \c retro_load_game(). | |
1430 * | |
1431 * @param[in] data <tt>const struct retro_subsystem_info *</tt>. | |
1432 * Pointer to an array of subsystem descriptors, | |
1433 * terminated by a zeroed-out \c retro_subsystem_info struct. | |
1434 * The frontend should maintain its own copy | |
1435 * of this array and the strings within it. | |
1436 * Behavior is undefined if \c NULL. | |
1437 * @returns \c true if this environment call is available. | |
1438 * @note This environment call \em must be called from within \c retro_set_environment(), | |
1439 * as frontends may need the registered information before loading a game. | |
1440 * @see retro_subsystem_info | |
1441 * @see retro_load_game_special | |
1442 */ | |
1443 #define RETRO_ENVIRONMENT_SET_SUBSYSTEM_INFO 34 | |
1444 | |
1445 /** | |
1446 * Declares one or more types of controllers supported by this core. | |
1447 * The frontend may then allow the player to select one of these controllers in its menu. | |
1448 * | |
1449 * Many consoles had controllers that came in different versions, | |
1450 * were extensible with peripherals, | |
1451 * or could be held in multiple ways; | |
1452 * this environment call can be used to represent these differences | |
1453 * and adjust the core's behavior to match. | |
1454 * | |
1455 * Possible use cases include: | |
1456 * | |
1457 * \li Supporting different classes of a single controller that supported their own sets of games. | |
1458 * For example, the SNES had two different lightguns (the Super Scope and the Justifier) | |
1459 * whose games were incompatible with each other. | |
1460 * \li Representing a platform's alternative controllers. | |
1461 * For example, several platforms had music/rhythm games that included controllers | |
1462 * shaped like musical instruments. | |
1463 * \li Representing variants of a standard controller with additional inputs. | |
1464 * For example, numerous consoles in the 90's introduced 6-button controllers for fighting games, | |
1465 * steering wheels for racing games, | |
1466 * or analog sticks for 3D platformers. | |
1467 * \li Representing add-ons for consoles or standard controllers. | |
1468 * For example, the 3DS had a Circle Pad Pro attachment that added a second analog stick. | |
1469 * \li Selecting different configurations for a single controller. | |
1470 * For example, the Wii Remote could be held sideways like a traditional game pad | |
1471 * or in one hand like a wand. | |
1472 * \li Providing multiple ways to simulate the experience of using a particular controller. | |
1473 * For example, the Game Boy Advance featured several games | |
1474 * with motion or light sensors in their cartridges; | |
1475 * a core could provide controller configurations | |
1476 * that allow emulating the sensors with either analog axes | |
1477 * or with their host device's sensors. | |
1478 * | |
1479 * Should be called in retro_load_game. | |
1480 * The frontend must maintain its own copy of the provided array, | |
1481 * including all strings and subobjects. | |
1482 * A core may exclude certain controllers for known incompatible games. | |
1483 * | |
1484 * When the frontend changes the active device for a particular port, | |
1485 * it must call \c retro_set_controller_port_device() with that port's index | |
1486 * and one of the IDs defined in its retro_controller_info::types field. | |
1487 * | |
1488 * Input ports are generally associated with different players | |
1489 * (and the frontend's UI may reflect this with "Player 1" labels), | |
1490 * but this is not required. | |
1491 * Some games use multiple controllers for a single player, | |
1492 * or some cores may use port indexes to represent an emulated console's | |
1493 * alternative input peripherals. | |
1494 * | |
1495 * @param[in] data <tt>const struct retro_controller_info *</tt>. | |
1496 * Pointer to an array of controller types defined by this core, | |
1497 * terminated by a zeroed-out \c retro_controller_info. | |
1498 * Each element of this array represents a controller port on the emulated device. | |
1499 * Behavior is undefined if \c NULL. | |
1500 * @returns \c true if this environment call is available. | |
1501 * @see retro_controller_info | |
1502 * @see retro_set_controller_port_device | |
1503 * @see RETRO_DEVICE_SUBCLASS | |
1504 */ | |
1505 #define RETRO_ENVIRONMENT_SET_CONTROLLER_INFO 35 | |
1506 | |
1507 /** | |
1508 * Notifies the frontend of the address spaces used by the core's emulated hardware, | |
1509 * and of the memory maps within these spaces. | |
1510 * This can be used by the frontend to provide cheats, achievements, or debugging capabilities. | |
1511 * Should only be used by emulators, as it makes little sense for game engines. | |
1512 * | |
1513 * @note Cores should also expose these address spaces | |
1514 * through retro_get_memory_data and \c retro_get_memory_size if applicable; | |
1515 * this environment call is not intended to replace those two functions, | |
1516 * as the emulated hardware may feature memory regions outside of its own address space | |
1517 * that are nevertheless useful for the frontend. | |
1518 * | |
1519 * @param[in] data <tt>const struct retro_memory_map *</tt>. | |
1520 * Pointer to a single memory-map listing. | |
1521 * The frontend must maintain its own copy of this object and its contents, | |
1522 * including strings and nested objects. | |
1523 * Behavior is undefined if \c NULL. | |
1524 * @returns \c true if this environment call is available. | |
1525 * @see retro_memory_map | |
1526 * @see retro_get_memory_data | |
1527 * @see retro_memory_descriptor | |
1528 */ | |
1529 #define RETRO_ENVIRONMENT_SET_MEMORY_MAPS (36 | RETRO_ENVIRONMENT_EXPERIMENTAL) | |
1530 | |
1531 /** | |
1532 * Resizes the viewport without reinitializing the video driver. | |
1533 * | |
1534 * Similar to \c RETRO_ENVIRONMENT_SET_SYSTEM_AV_INFO, | |
1535 * but any changes that would require video reinitialization will not be performed. | |
1536 * Can only be called from within \c retro_run(). | |
1537 * | |
1538 * This environment call allows a core to revise the size of the viewport at will, | |
1539 * which can be useful for emulated platforms that support dynamic resolution changes | |
1540 * or for cores that support multiple screen layouts. | |
1541 * | |
1542 * A frontend must guarantee that this environment call completes in | |
1543 * constant time. | |
1544 * | |
1545 * @param[in] data <tt>const struct retro_game_geometry *</tt>. | |
1546 * Pointer to the new video parameters that the frontend should adopt. | |
1547 * \c retro_game_geometry::max_width and \c retro_game_geometry::max_height | |
1548 * will be ignored. | |
1549 * Behavior is undefined if \c data is <tt>NULL</tt>. | |
1550 * @return \c true if the environment call is available. | |
1551 * @see RETRO_ENVIRONMENT_SET_SYSTEM_AV_INFO | |
1552 */ | |
1553 #define RETRO_ENVIRONMENT_SET_GEOMETRY 37 | |
1554 | |
1555 /** | |
1556 * Returns the name of the user, if possible. | |
1557 * This callback is suitable for cores that offer personalization, | |
1558 * such as online facilities or user profiles on the emulated system. | |
1559 * @param[out] data <tt>const char **</tt>. | |
1560 * Pointer to the user name string. | |
1561 * May be \c NULL, in which case the core should use a default name. | |
1562 * The returned pointer is owned by the frontend and must not be modified or freed by the core. | |
1563 * Behavior is undefined if \c NULL. | |
1564 * @returns \c true if the environment call is available, | |
1565 * even if the frontend couldn't provide a name. | |
1566 */ | |
1567 #define RETRO_ENVIRONMENT_GET_USERNAME 38 | |
1568 | |
1569 /** | |
1570 * Returns the frontend's configured language. | |
1571 * It can be used to localize the core's UI, | |
1572 * or to customize the emulated firmware if applicable. | |
1573 * | |
1574 * @param[out] data <tt>retro_language *</tt>. | |
1575 * Pointer to the language identifier. | |
1576 * Behavior is undefined if \c NULL. | |
1577 * @returns \c true if the environment call is available. | |
1578 * @note The returned language may not be the same as the operating system's language. | |
1579 * Cores should fall back to the operating system's language (or to English) | |
1580 * if the environment call is unavailable or the returned language is unsupported. | |
1581 * @see retro_language | |
1582 * @see RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2_INTL | |
1583 */ | |
1584 #define RETRO_ENVIRONMENT_GET_LANGUAGE 39 | |
1585 | |
1586 /** | |
1587 * Returns a frontend-managed framebuffer | |
1588 * that the core may render directly into | |
1589 * | |
1590 * This environment call is provided as an optimization | |
1591 * for cores that use software rendering | |
1592 * (i.e. that don't use \refitem RETRO_ENVIRONMENT_SET_HW_RENDER "a graphics hardware API"); | |
1593 * specifically, the intended use case is to allow a core | |
1594 * to render directly into frontend-managed video memory, | |
1595 * avoiding the bandwidth use that copying a whole framebuffer from core to video memory entails. | |
1596 * | |
1597 * Must be called every frame if used, | |
1598 * as this may return a different framebuffer each frame | |
1599 * (e.g. for swap chains). | |
1600 * However, a core may render to a different buffer even if this call succeeds. | |
1601 * | |
1602 * @param[in,out] data <tt>struct retro_framebuffer *</tt>. | |
1603 * Pointer to a frontend's frame buffer and accompanying data. | |
1604 * Some fields are set by the core, others are set by the frontend. | |
1605 * Only guaranteed to be valid for the duration of the current \c retro_run call, | |
1606 * and must not be used afterwards. | |
1607 * Behavior is undefined if \c NULL. | |
1608 * @return \c true if the environment call was recognized | |
1609 * and the framebuffer was successfully returned. | |
1610 * @see retro_framebuffer | |
1611 */ | |
1612 #define RETRO_ENVIRONMENT_GET_CURRENT_SOFTWARE_FRAMEBUFFER (40 | RETRO_ENVIRONMENT_EXPERIMENTAL) | |
1613 | |
1614 /** | |
1615 * Returns an interface for accessing the data of specific rendering APIs. | |
1616 * Not all hardware rendering APIs support or need this. | |
1617 * | |
1618 * The details of these interfaces are specific to each rendering API. | |
1619 * | |
1620 * @note \c retro_hw_render_callback::context_reset must be called by the frontend | |
1621 * before this environment call can be used. | |
1622 * Additionally, the contents of the returned interface are invalidated | |
1623 * after \c retro_hw_render_callback::context_destroyed has been called. | |
1624 * @param[out] data <tt>const struct retro_hw_render_interface **</tt>. | |
1625 * The render interface for the currently-enabled hardware rendering API, if any. | |
1626 * The frontend will store a pointer to the interface at the address provided here. | |
1627 * The returned interface is owned by the frontend and must not be modified or freed by the core. | |
1628 * Behavior is undefined if \c NULL. | |
1629 * @return \c true if this environment call is available, | |
1630 * the active graphics API has a libretro rendering interface, | |
1631 * and the frontend is able to return said interface. | |
1632 * \c false otherwise. | |
1633 * @see RETRO_ENVIRONMENT_SET_HW_RENDER | |
1634 * @see retro_hw_render_interface | |
1635 * @note Since not every libretro-supported hardware rendering API | |
1636 * has a \c retro_hw_render_interface implementation, | |
1637 * a result of \c false is not necessarily an error. | |
1638 */ | |
1639 #define RETRO_ENVIRONMENT_GET_HW_RENDER_INTERFACE (41 | RETRO_ENVIRONMENT_EXPERIMENTAL) | |
1640 | |
1641 /** | |
1642 * Explicitly notifies the frontend of whether this core supports achievements. | |
1643 * The core must expose its emulated address space via | |
1644 * \c retro_get_memory_data or \c RETRO_ENVIRONMENT_GET_MEMORY_MAPS. | |
1645 * Must be called before the first call to <tt>retro_run</tt>. | |
1646 * | |
1647 * If \ref retro_get_memory_data returns a valid address | |
1648 * but this environment call is not used, | |
1649 * the frontend (at its discretion) may or may not opt in the core to its achievements support. | |
1650 * whether this core is opted in to the frontend's achievement support | |
1651 * is left to the frontend's discretion. | |
1652 * @param[in] data <tt>const bool *</tt>. | |
1653 * Pointer to a single \c bool that indicates whether this core supports achievements. | |
1654 * Behavior is undefined if \c data is <tt>NULL</tt>. | |
1655 * @returns \c true if the environment call is available. | |
1656 * @see RETRO_ENVIRONMENT_SET_MEMORY_MAPS | |
1657 * @see retro_get_memory_data | |
1658 */ | |
1659 #define RETRO_ENVIRONMENT_SET_SUPPORT_ACHIEVEMENTS (42 | RETRO_ENVIRONMENT_EXPERIMENTAL) | |
1660 | |
1661 /** | |
1662 * Defines an interface that the frontend can use | |
1663 * to ask the core for the parameters it needs for a hardware rendering context. | |
1664 * The exact semantics depend on \ref RETRO_ENVIRONMENT_SET_HW_RENDER "the active rendering API". | |
1665 * Will be used some time after \c RETRO_ENVIRONMENT_SET_HW_RENDER is called, | |
1666 * but before \c retro_hw_render_callback::context_reset is called. | |
1667 * | |
1668 * @param[in] data <tt>const struct retro_hw_render_context_negotiation_interface *</tt>. | |
1669 * Pointer to the context negotiation interface. | |
1670 * Will be populated by the frontend. | |
1671 * Behavior is undefined if \c NULL. | |
1672 * @return \c true if this environment call is supported, | |
1673 * even if the current graphics API doesn't use | |
1674 * a context negotiation interface (in which case the argument is ignored). | |
1675 * @see retro_hw_render_context_negotiation_interface | |
1676 * @see RETRO_ENVIRONMENT_GET_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE_SUPPORT | |
1677 * @see RETRO_ENVIRONMENT_SET_HW_RENDER | |
1678 */ | |
1679 #define RETRO_ENVIRONMENT_SET_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE (43 | RETRO_ENVIRONMENT_EXPERIMENTAL) | |
1680 | |
1681 /** | |
1682 * Notifies the frontend of any quirks associated with serialization. | |
1683 * | |
1684 * Should be set in either \c retro_init or \c retro_load_game, but not both. | |
1685 * @param[in, out] data <tt>uint64_t *</tt>. | |
1686 * Pointer to the core's serialization quirks. | |
1687 * The frontend will set the flags of the quirks it supports | |
1688 * and clear the flags of those it doesn't. | |
1689 * Behavior is undefined if \c NULL. | |
1690 * @return \c true if this environment call is supported. | |
1691 * @see retro_serialize | |
1692 * @see retro_unserialize | |
1693 * @see RETRO_SERIALIZATION_QUIRK | |
1694 */ | |
1695 #define RETRO_ENVIRONMENT_SET_SERIALIZATION_QUIRKS 44 | |
1696 | |
1697 /** | |
1698 * The frontend will try to use a "shared" context when setting up a hardware context. | |
1699 * Mostly applicable to OpenGL. | |
1700 * | |
1701 * In order for this to have any effect, | |
1702 * the core must call \c RETRO_ENVIRONMENT_SET_HW_RENDER at some point | |
1703 * if it hasn't already. | |
1704 * | |
1705 * @param data Ignored. | |
1706 * @returns \c true if the environment call is available | |
1707 * and the frontend supports shared hardware contexts. | |
1708 */ | |
1709 #define RETRO_ENVIRONMENT_SET_HW_SHARED_CONTEXT (44 | RETRO_ENVIRONMENT_EXPERIMENTAL) | |
1710 | |
1711 /** | |
1712 * Returns an interface that the core can use to access the file system. | |
1713 * Should be called as early as possible. | |
1714 * | |
1715 * @param[in,out] data <tt>struct retro_vfs_interface_info *</tt>. | |
1716 * Information about the desired VFS interface, | |
1717 * as well as the interface itself. | |
1718 * Behavior is undefined if \c NULL. | |
1719 * @return \c true if this environment call is available | |
1720 * and the frontend can provide a VFS interface of the requested version or newer. | |
1721 * @see retro_vfs_interface_info | |
1722 * @see file_path | |
1723 * @see retro_dirent | |
1724 * @see file_stream | |
1725 */ | |
1726 #define RETRO_ENVIRONMENT_GET_VFS_INTERFACE (45 | RETRO_ENVIRONMENT_EXPERIMENTAL) | |
1727 | |
1728 /** | |
1729 * Returns an interface that the core can use | |
1730 * to set the state of any accessible device LEDs. | |
1731 * | |
1732 * @param[out] data <tt>struct retro_led_interface *</tt>. | |
1733 * Pointer to the LED interface that the frontend will populate. | |
1734 * May be \c NULL, in which case the frontend will only return | |
1735 * whether this environment callback is available. | |
1736 * @returns \c true if the environment call is available, | |
1737 * even if \c data is \c NULL | |
1738 * or no LEDs are accessible. | |
1739 * @see retro_led_interface | |
1740 */ | |
1741 #define RETRO_ENVIRONMENT_GET_LED_INTERFACE (46 | RETRO_ENVIRONMENT_EXPERIMENTAL) | |
1742 | |
1743 /** | |
1744 * Returns hints about certain steps that the core may skip for this frame. | |
1745 * | |
1746 * A frontend may not need a core to generate audio or video in certain situations; | |
1747 * this environment call sets a bitmask that indicates | |
1748 * which steps the core may skip for this frame. | |
1749 * | |
1750 * This can be used to increase performance for some frontend features. | |
1751 * | |
1752 * @note Emulation accuracy should not be compromised; | |
1753 * for example, if a core emulates a platform that supports display capture | |
1754 * (i.e. looking at its own VRAM), then it should perform its rendering as normal | |
1755 * unless it can prove that the emulated game is not using display capture. | |
1756 * | |
1757 * @param[out] data <tt>retro_av_enable_flags *</tt>. | |
1758 * Pointer to the bitmask of steps that the frontend will skip. | |
1759 * Other bits are set to zero and are reserved for future use. | |
1760 * If \c NULL, the frontend will only return whether this environment callback is available. | |
1761 * @returns \c true if the environment call is available, | |
1762 * regardless of the value output to \c data. | |
1763 * If \c false, the core should assume that the frontend will not skip any steps. | |
1764 * @see retro_av_enable_flags | |
1765 */ | |
1766 #define RETRO_ENVIRONMENT_GET_AUDIO_VIDEO_ENABLE (47 | RETRO_ENVIRONMENT_EXPERIMENTAL) | |
1767 | |
1768 /** | |
1769 * Gets an interface that the core can use for raw MIDI I/O. | |
1770 * | |
1771 * @param[out] data <tt>struct retro_midi_interface *</tt>. | |
1772 * Pointer to the MIDI interface. | |
1773 * May be \c NULL. | |
1774 * @return \c true if the environment call is available, | |
1775 * even if \c data is \c NULL. | |
1776 * @see retro_midi_interface | |
1777 */ | |
1778 #define RETRO_ENVIRONMENT_GET_MIDI_INTERFACE (48 | RETRO_ENVIRONMENT_EXPERIMENTAL) | |
1779 | |
1780 /** | |
1781 * Asks the frontend if it's currently in fast-forward mode. | |
1782 * @param[out] data <tt>bool *</tt>. | |
1783 * Set to \c true if the frontend is currently fast-forwarding its main loop. | |
1784 * Behavior is undefined if \c data is <tt>NULL</tt>. | |
1785 * @returns \c true if this environment call is available, | |
1786 * regardless of the value returned in \c data. | |
1787 * | |
1788 * @see RETRO_ENVIRONMENT_SET_FASTFORWARDING_OVERRIDE | |
1789 */ | |
1790 #define RETRO_ENVIRONMENT_GET_FASTFORWARDING (49 | RETRO_ENVIRONMENT_EXPERIMENTAL) | |
1791 | |
1792 /** | |
1793 * Returns the refresh rate the frontend is targeting, in Hz. | |
1794 * The intended use case is for the core to use the result to select an ideal refresh rate. | |
1795 * | |
1796 * @param[out] data <tt>float *</tt>. | |
1797 * Pointer to the \c float in which the frontend will store its target refresh rate. | |
1798 * Behavior is undefined if \c data is <tt>NULL</tt>. | |
1799 * @return \c true if this environment call is available, | |
1800 * regardless of the value returned in \c data. | |
1801 */ | |
1802 #define RETRO_ENVIRONMENT_GET_TARGET_REFRESH_RATE (50 | RETRO_ENVIRONMENT_EXPERIMENTAL) | |
1803 | |
1804 /** | |
1805 * Returns whether the frontend can return the state of all buttons at once as a bitmask, | |
1806 * rather than requiring a series of individual calls to \c retro_input_state_t. | |
1807 * | |
1808 * If this callback returns \c true, | |
1809 * you can get the state of all buttons by passing \c RETRO_DEVICE_ID_JOYPAD_MASK | |
1810 * as the \c id parameter to \c retro_input_state_t. | |
1811 * Bit #N represents the RETRO_DEVICE_ID_JOYPAD constant of value N, | |
1812 * e.g. <tt>(1 << RETRO_DEVICE_ID_JOYPAD_A)</tt> represents the A button. | |
1813 * | |
1814 * @param data Ignored. | |
1815 * @returns \c true if the frontend can report the complete digital joypad state as a bitmask. | |
1816 * @see retro_input_state_t | |
1817 * @see RETRO_DEVICE_JOYPAD | |
1818 * @see RETRO_DEVICE_ID_JOYPAD_MASK | |
1819 */ | |
1820 #define RETRO_ENVIRONMENT_GET_INPUT_BITMASKS (51 | RETRO_ENVIRONMENT_EXPERIMENTAL) | |
1821 | |
1822 /** | |
1823 * Returns the version of the core options API supported by the frontend. | |
1824 * | |
1825 * Over the years, libretro has used several interfaces | |
1826 * for allowing cores to define customizable options. | |
1827 * \ref SET_CORE_OPTIONS_V2 "Version 2 of the interface" | |
1828 * is currently preferred due to its extra features, | |
1829 * but cores and frontends should strive to support | |
1830 * versions \ref RETRO_ENVIRONMENT_SET_CORE_OPTIONS "1" | |
1831 * and \ref RETRO_ENVIRONMENT_SET_VARIABLES "0" as well. | |
1832 * This environment call provides the information that cores need for that purpose. | |
1833 * | |
1834 * If this environment call returns \c false, | |
1835 * then the core should assume version 0 of the core options API. | |
1836 * | |
1837 * @param[out] data <tt>unsigned *</tt>. | |
1838 * Pointer to the integer that will store the frontend's | |
1839 * supported core options API version. | |
1840 * Behavior is undefined if \c NULL. | |
1841 * @returns \c true if the environment call is available, | |
1842 * \c false otherwise. | |
1843 * @see RETRO_ENVIRONMENT_SET_VARIABLES | |
1844 * @see RETRO_ENVIRONMENT_SET_CORE_OPTIONS | |
1845 * @see RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2 | |
1846 */ | |
1847 #define RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION 52 | |
1848 | |
1849 /** | |
1850 * @copybrief RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2 | |
1851 * | |
1852 * @deprecated This environment call has been superseded | |
1853 * by RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2, | |
1854 * which supports categorizing options into groups. | |
1855 * This environment call should only be used to maintain compatibility | |
1856 * with older cores and frontends. | |
1857 * | |
1858 * This environment call is intended to replace \c RETRO_ENVIRONMENT_SET_VARIABLES, | |
1859 * and should only be called if \c RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION | |
1860 * returns an API version of at least 1. | |
1861 * | |
1862 * This should be called the first time as early as possible, | |
1863 * ideally in \c retro_set_environment (but \c retro_load_game is acceptable). | |
1864 * It may then be called again later to update | |
1865 * the core's options and their associated values, | |
1866 * as long as the number of options doesn't change | |
1867 * from the number given in the first call. | |
1868 * | |
1869 * The core can retrieve option values at any time with \c RETRO_ENVIRONMENT_GET_VARIABLE. | |
1870 * If a saved value for a core option doesn't match the option definition's values, | |
1871 * the frontend may treat it as incorrect and revert to the default. | |
1872 * | |
1873 * Core options and their values are usually defined in a large static array, | |
1874 * but they may be generated at runtime based on the loaded game or system state. | |
1875 * Here are some use cases for that: | |
1876 * | |
1877 * @li Selecting a particular file from one of the | |
1878 * \ref RETRO_ENVIRONMENT_GET_ASSET_DIRECTORY "frontend's" | |
1879 * \ref RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY "content" | |
1880 * \ref RETRO_ENVIRONMENT_GET_CORE_ASSETS_DIRECTORY "directories", | |
1881 * such as a memory card image or figurine data file. | |
1882 * @li Excluding options that are not relevant to the current game, | |
1883 * for cores that define a large number of possible options. | |
1884 * @li Choosing a default value at runtime for a specific game, | |
1885 * such as a BIOS file whose region matches that of the loaded content. | |
1886 * | |
1887 * @note A guiding principle of libretro's API design is that | |
1888 * all common interactions (gameplay, menu navigation, etc.) | |
1889 * should be possible without a keyboard. | |
1890 * This implies that cores should keep the number of options and values | |
1891 * as low as possible. | |
1892 * | |
1893 * Example entry: | |
1894 * @code | |
1895 * { | |
1896 * "foo_option", | |
1897 * "Speed hack coprocessor X", | |
1898 * "Provides increased performance at the expense of reduced accuracy", | |
1899 * { | |
1900 * { "false", NULL }, | |
1901 * { "true", NULL }, | |
1902 * { "unstable", "Turbo (Unstable)" }, | |
1903 * { NULL, NULL }, | |
1904 * }, | |
1905 * "false" | |
1906 * } | |
1907 * @endcode | |
1908 * | |
1909 * @param[in] data <tt>const struct retro_core_option_definition *</tt>. | |
1910 * Pointer to one or more core option definitions, | |
1911 * terminated by a \ref retro_core_option_definition whose values are all zero. | |
1912 * May be \c NULL, in which case the frontend will remove all existing core options. | |
1913 * The frontend must maintain its own copy of this object, | |
1914 * including all strings and subobjects. | |
1915 * @return \c true if this environment call is available. | |
1916 * | |
1917 * @see retro_core_option_definition | |
1918 * @see RETRO_ENVIRONMENT_GET_VARIABLE | |
1919 * @see RETRO_ENVIRONMENT_SET_CORE_OPTIONS_INTL | |
1920 */ | |
1921 #define RETRO_ENVIRONMENT_SET_CORE_OPTIONS 53 | |
1922 | |
1923 /** | |
1924 * A variant of \ref RETRO_ENVIRONMENT_SET_CORE_OPTIONS | |
1925 * that supports internationalization. | |
1926 * | |
1927 * @deprecated This environment call has been superseded | |
1928 * by \ref RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2_INTL, | |
1929 * which supports categorizing options into groups | |
1930 * (plus translating the groups themselves). | |
1931 * Only use this environment call to maintain compatibility | |
1932 * with older cores and frontends. | |
1933 * | |
1934 * This should be called instead of \c RETRO_ENVIRONMENT_SET_CORE_OPTIONS | |
1935 * if the core provides translations for its options. | |
1936 * General use is largely the same, | |
1937 * but see \ref retro_core_options_intl for some important details. | |
1938 * | |
1939 * @param[in] data <tt>const struct retro_core_options_intl *</tt>. | |
1940 * Pointer to a core's option values and their translations. | |
1941 * @see retro_core_options_intl | |
1942 * @see RETRO_ENVIRONMENT_SET_CORE_OPTIONS | |
1943 */ | |
1944 #define RETRO_ENVIRONMENT_SET_CORE_OPTIONS_INTL 54 | |
1945 | |
1946 /** | |
1947 * Notifies the frontend that it should show or hide the named core option. | |
1948 * | |
1949 * Some core options aren't relevant in all scenarios, | |
1950 * such as a submenu for hardware rendering flags | |
1951 * when the software renderer is configured. | |
1952 * This environment call asks the frontend to stop (or start) | |
1953 * showing the named core option to the player. | |
1954 * This is only a hint, not a requirement; | |
1955 * the frontend may ignore this environment call. | |
1956 * By default, all core options are visible. | |
1957 * | |
1958 * @note This environment call must \em only affect a core option's visibility, | |
1959 * not its functionality or availability. | |
1960 * \ref RETRO_ENVIRONMENT_GET_VARIABLE "Getting an invisible core option" | |
1961 * must behave normally. | |
1962 * | |
1963 * @param[in] data <tt>const struct retro_core_option_display *</tt>. | |
1964 * Pointer to a descriptor for the option that the frontend should show or hide. | |
1965 * May be \c NULL, in which case the frontend will only return | |
1966 * whether this environment callback is available. | |
1967 * @return \c true if this environment call is available, | |
1968 * even if \c data is \c NULL | |
1969 * or the specified option doesn't exist. | |
1970 * @see retro_core_option_display | |
1971 * @see RETRO_ENVIRONMENT_SET_CORE_OPTIONS_UPDATE_DISPLAY_CALLBACK | |
1972 */ | |
1973 #define RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY 55 | |
1974 | |
1975 /** | |
1976 * Returns the frontend's preferred hardware rendering API. | |
1977 * Cores should use this information to decide which API to use with \c RETRO_ENVIRONMENT_SET_HW_RENDER. | |
1978 * @param[out] data <tt>retro_hw_context_type *</tt>. | |
1979 * Pointer to the hardware context type. | |
1980 * Behavior is undefined if \c data is <tt>NULL</tt>. | |
1981 * This value will be set even if the environment call returns <tt>false</tt>, | |
1982 * unless the frontend doesn't implement it. | |
1983 * @returns \c true if the environment call is available | |
1984 * and the frontend is able to use a hardware rendering API besides the one returned. | |
1985 * If \c false is returned and the core cannot use the preferred rendering API, | |
1986 * then it should exit or fall back to software rendering. | |
1987 * @note The returned value does not indicate which API is currently in use. | |
1988 * For example, the frontend may return \c RETRO_HW_CONTEXT_OPENGL | |
1989 * while a Direct3D context from a previous session is active; | |
1990 * this would signal that the frontend's current preference is for OpenGL, | |
1991 * possibly because the user changed their frontend's video driver while a game is running. | |
1992 * @see retro_hw_context_type | |
1993 * @see RETRO_ENVIRONMENT_GET_HW_RENDER_INTERFACE | |
1994 * @see RETRO_ENVIRONMENT_SET_HW_RENDER | |
1995 */ | |
1996 #define RETRO_ENVIRONMENT_GET_PREFERRED_HW_RENDER 56 | |
1997 | |
1998 /** | |
1999 * Returns the minimum version of the disk control interface supported by the frontend. | |
2000 * | |
2001 * If this environment call returns \c false or \c data is 0 or greater, | |
2002 * then cores may use disk control callbacks | |
2003 * with \c RETRO_ENVIRONMENT_SET_DISK_CONTROL_INTERFACE. | |
2004 * If the reported version is 1 or greater, | |
2005 * then cores should use \c RETRO_ENVIRONMENT_SET_DISK_CONTROL_EXT_INTERFACE instead. | |
2006 * | |
2007 * @param[out] data <tt>unsigned *</tt>. | |
2008 * Pointer to the unsigned integer that the frontend's supported disk control interface version will be stored in. | |
2009 * Behavior is undefined if \c NULL. | |
2010 * @return \c true if this environment call is available. | |
2011 * @see RETRO_ENVIRONMENT_SET_DISK_CONTROL_EXT_INTERFACE | |
2012 */ | |
2013 #define RETRO_ENVIRONMENT_GET_DISK_CONTROL_INTERFACE_VERSION 57 | |
2014 | |
2015 /** | |
2016 * @copybrief RETRO_ENVIRONMENT_SET_DISK_CONTROL_INTERFACE | |
2017 * | |
2018 * This is intended for multi-disk games that expect the player | |
2019 * to manually swap disks at certain points in the game. | |
2020 * This version of the disk control interface provides | |
2021 * more information about disk images. | |
2022 * Should be called in \c retro_init. | |
2023 * | |
2024 * @param[in] data <tt>const struct retro_disk_control_ext_callback *</tt>. | |
2025 * Pointer to the callback functions to use. | |
2026 * May be \c NULL, in which case the existing disk callback is deregistered. | |
2027 * @return \c true if this environment call is available, | |
2028 * even if \c data is \c NULL. | |
2029 * @see retro_disk_control_ext_callback | |
2030 */ | |
2031 #define RETRO_ENVIRONMENT_SET_DISK_CONTROL_EXT_INTERFACE 58 | |
2032 | |
2033 /** | |
2034 * Returns the version of the message interface supported by the frontend. | |
2035 * | |
2036 * A version of 0 indicates that the frontend | |
2037 * only supports the legacy \c RETRO_ENVIRONMENT_SET_MESSAGE interface. | |
2038 * A version of 1 indicates that the frontend | |
2039 * supports \c RETRO_ENVIRONMENT_SET_MESSAGE_EXT as well. | |
2040 * If this environment call returns \c false, | |
2041 * the core should behave as if it had returned 0. | |
2042 * | |
2043 * @param[out] data <tt>unsigned *</tt>. | |
2044 * Pointer to the result returned by the frontend. | |
2045 * Behavior is undefined if \c NULL. | |
2046 * @return \c true if this environment call is available. | |
2047 * @see RETRO_ENVIRONMENT_SET_MESSAGE_EXT | |
2048 * @see RETRO_ENVIRONMENT_SET_MESSAGE | |
2049 */ | |
2050 #define RETRO_ENVIRONMENT_GET_MESSAGE_INTERFACE_VERSION 59 | |
2051 | |
2052 /** | |
2053 * Displays a user-facing message for a short time. | |
2054 * | |
2055 * Use this callback to convey important status messages, | |
2056 * such as errors or the result of long-running operations. | |
2057 * For trivial messages or logging, use \c RETRO_ENVIRONMENT_GET_LOG_INTERFACE or \c stderr. | |
2058 * | |
2059 * This environment call supersedes \c RETRO_ENVIRONMENT_SET_MESSAGE, | |
2060 * as it provides many more ways to customize | |
2061 * how a message is presented to the player. | |
2062 * However, a frontend that supports this environment call | |
2063 * must still support \c RETRO_ENVIRONMENT_SET_MESSAGE. | |
2064 * | |
2065 * @param[in] data <tt>const struct retro_message_ext *</tt>. | |
2066 * Pointer to the message to display to the player. | |
2067 * Behavior is undefined if \c NULL. | |
2068 * @returns \c true if this environment call is available. | |
2069 * @see retro_message_ext | |
2070 * @see RETRO_ENVIRONMENT_GET_MESSAGE_INTERFACE_VERSION | |
2071 */ | |
2072 #define RETRO_ENVIRONMENT_SET_MESSAGE_EXT 60 | |
2073 | |
2074 /** | |
2075 * Returns the number of active input devices currently provided by the frontend. | |
2076 * | |
2077 * This may change between frames, | |
2078 * but will remain constant for the duration of each frame. | |
2079 * | |
2080 * If this callback returns \c true, | |
2081 * a core need not poll any input device | |
2082 * with an index greater than or equal to the returned value. | |
2083 * | |
2084 * If callback returns \c false, | |
2085 * the number of active input devices is unknown. | |
2086 * In this case, all input devices should be considered active. | |
2087 * | |
2088 * @param[out] data <tt>unsigned *</tt>. | |
2089 * Pointer to the result returned by the frontend. | |
2090 * Behavior is undefined if \c NULL. | |
2091 * @return \c true if this environment call is available. | |
2092 */ | |
2093 #define RETRO_ENVIRONMENT_GET_INPUT_MAX_USERS 61 | |
2094 | |
2095 /** | |
2096 * Registers a callback that the frontend can use to notify the core | |
2097 * of the audio output buffer's occupancy. | |
2098 * Can be used by a core to attempt frame-skipping to avoid buffer under-runs | |
2099 * (i.e. "crackling" sounds). | |
2100 * | |
2101 * @param[in] data <tt>const struct retro_audio_buffer_status_callback *</tt>. | |
2102 * Pointer to the the buffer status callback, | |
2103 * or \c NULL to unregister any existing callback. | |
2104 * @return \c true if this environment call is available, | |
2105 * even if \c data is \c NULL. | |
2106 * | |
2107 * @see retro_audio_buffer_status_callback | |
2108 */ | |
2109 #define RETRO_ENVIRONMENT_SET_AUDIO_BUFFER_STATUS_CALLBACK 62 | |
2110 | |
2111 /** | |
2112 * Requests a minimum frontend audio latency in milliseconds. | |
2113 * | |
2114 * This is a hint; the frontend may assign a different audio latency | |
2115 * to accommodate hardware limits, | |
2116 * although it should try to honor requests up to 512ms. | |
2117 * | |
2118 * This callback has no effect if the requested latency | |
2119 * is less than the frontend's current audio latency. | |
2120 * If value is zero or \c data is \c NULL, | |
2121 * the frontend should set its default audio latency. | |
2122 * | |
2123 * May be used by a core to increase audio latency and | |
2124 * reduce the risk of buffer under-runs (crackling) | |
2125 * when performing 'intensive' operations. | |
2126 * | |
2127 * A core using RETRO_ENVIRONMENT_SET_AUDIO_BUFFER_STATUS_CALLBACK | |
2128 * to implement audio-buffer-based frame skipping can get good results | |
2129 * by setting the audio latency to a high (typically 6x or 8x) | |
2130 * integer multiple of the expected frame time. | |
2131 * | |
2132 * This can only be called from within \c retro_run(). | |
2133 * | |
2134 * @warning This environment call may require the frontend to reinitialize its audio system. | |
2135 * This environment call should be used sparingly. | |
2136 * If the driver is reinitialized, | |
2137 * \ref retro_audio_callback_t "all audio callbacks" will be updated | |
2138 * to target the newly-initialized driver. | |
2139 * | |
2140 * @param[in] data <tt>const unsigned *</tt>. | |
2141 * Minimum audio latency, in milliseconds. | |
2142 * @return \c true if this environment call is available, | |
2143 * even if \c data is \c NULL. | |
2144 * | |
2145 * @see RETRO_ENVIRONMENT_SET_AUDIO_BUFFER_STATUS_CALLBACK | |
2146 */ | |
2147 #define RETRO_ENVIRONMENT_SET_MINIMUM_AUDIO_LATENCY 63 | |
2148 | |
2149 /** | |
2150 * Allows the core to tell the frontend when it should enable fast-forwarding, | |
2151 * rather than relying solely on the frontend and user interaction. | |
2152 * | |
2153 * Possible use cases include: | |
2154 * | |
2155 * \li Temporarily disabling a core's fastforward support | |
2156 * while investigating a related bug. | |
2157 * \li Disabling fastforward during netplay sessions, | |
2158 * or when using an emulated console's network features. | |
2159 * \li Automatically speeding up the game when in a loading screen | |
2160 * that cannot be shortened with high-level emulation. | |
2161 * | |
2162 * @param[in] data <tt>const struct retro_fastforwarding_override *</tt>. | |
2163 * Pointer to the parameters that decide when and how | |
2164 * the frontend is allowed to enable fast-forward mode. | |
2165 * May be \c NULL, in which case the frontend will return \c true | |
2166 * without updating the fastforward state, | |
2167 * which can be used to detect support for this environment call. | |
2168 * @return \c true if this environment call is available, | |
2169 * even if \c data is \c NULL. | |
2170 * | |
2171 * @see retro_fastforwarding_override | |
2172 * @see RETRO_ENVIRONMENT_GET_FASTFORWARDING | |
2173 */ | |
2174 #define RETRO_ENVIRONMENT_SET_FASTFORWARDING_OVERRIDE 64 | |
2175 | |
2176 #define RETRO_ENVIRONMENT_SET_CONTENT_INFO_OVERRIDE 65 | |
2177 /* const struct retro_system_content_info_override * -- | |
2178 * Allows an implementation to override 'global' content | |
2179 * info parameters reported by retro_get_system_info(). | |
2180 * Overrides also affect subsystem content info parameters | |
2181 * set via RETRO_ENVIRONMENT_SET_SUBSYSTEM_INFO. | |
2182 * This function must be called inside retro_set_environment(). | |
2183 * If callback returns false, content info overrides | |
2184 * are unsupported by the frontend, and will be ignored. | |
2185 * If callback returns true, extended game info may be | |
2186 * retrieved by calling RETRO_ENVIRONMENT_GET_GAME_INFO_EXT | |
2187 * in retro_load_game() or retro_load_game_special(). | |
2188 * | |
2189 * 'data' points to an array of retro_system_content_info_override | |
2190 * structs terminated by a { NULL, false, false } element. | |
2191 * If 'data' is NULL, no changes will be made to the frontend; | |
2192 * a core may therefore pass NULL in order to test whether | |
2193 * the RETRO_ENVIRONMENT_SET_CONTENT_INFO_OVERRIDE and | |
2194 * RETRO_ENVIRONMENT_GET_GAME_INFO_EXT callbacks are supported | |
2195 * by the frontend. | |
2196 * | |
2197 * For struct member descriptions, see the definition of | |
2198 * struct retro_system_content_info_override. | |
2199 * | |
2200 * Example: | |
2201 * | |
2202 * - struct retro_system_info: | |
2203 * { | |
2204 * "My Core", // library_name | |
2205 * "v1.0", // library_version | |
2206 * "m3u|md|cue|iso|chd|sms|gg|sg", // valid_extensions | |
2207 * true, // need_fullpath | |
2208 * false // block_extract | |
2209 * } | |
2210 * | |
2211 * - Array of struct retro_system_content_info_override: | |
2212 * { | |
2213 * { | |
2214 * "md|sms|gg", // extensions | |
2215 * false, // need_fullpath | |
2216 * true // persistent_data | |
2217 * }, | |
2218 * { | |
2219 * "sg", // extensions | |
2220 * false, // need_fullpath | |
2221 * false // persistent_data | |
2222 * }, | |
2223 * { NULL, false, false } | |
2224 * } | |
2225 * | |
2226 * Result: | |
2227 * - Files of type m3u, cue, iso, chd will not be | |
2228 * loaded by the frontend. Frontend will pass a | |
2229 * valid path to the core, and core will handle | |
2230 * loading internally | |
2231 * - Files of type md, sms, gg will be loaded by | |
2232 * the frontend. A valid memory buffer will be | |
2233 * passed to the core. This memory buffer will | |
2234 * remain valid until retro_deinit() returns | |
2235 * - Files of type sg will be loaded by the frontend. | |
2236 * A valid memory buffer will be passed to the core. | |
2237 * This memory buffer will remain valid until | |
2238 * retro_load_game() (or retro_load_game_special()) | |
2239 * returns | |
2240 * | |
2241 * NOTE: If an extension is listed multiple times in | |
2242 * an array of retro_system_content_info_override | |
2243 * structs, only the first instance will be registered | |
487 */ | 2244 */ |
488 #define RETRO_ENVIRONMENT_GET_OVERSCAN 2 /* bool * -- | 2245 |
489 * Boolean value whether or not the implementation should use overscan, | 2246 #define RETRO_ENVIRONMENT_GET_GAME_INFO_EXT 66 |
490 * or crop away overscan. | 2247 /* const struct retro_game_info_ext ** -- |
2248 * Allows an implementation to fetch extended game | |
2249 * information, providing additional content path | |
2250 * and memory buffer status details. | |
2251 * This function may only be called inside | |
2252 * retro_load_game() or retro_load_game_special(). | |
2253 * If callback returns false, extended game information | |
2254 * is unsupported by the frontend. In this case, only | |
2255 * regular retro_game_info will be available. | |
2256 * RETRO_ENVIRONMENT_GET_GAME_INFO_EXT is guaranteed | |
2257 * to return true if RETRO_ENVIRONMENT_SET_CONTENT_INFO_OVERRIDE | |
2258 * returns true. | |
2259 * | |
2260 * 'data' points to an array of retro_game_info_ext structs. | |
2261 * | |
2262 * For struct member descriptions, see the definition of | |
2263 * struct retro_game_info_ext. | |
2264 * | |
2265 * - If function is called inside retro_load_game(), | |
2266 * the retro_game_info_ext array is guaranteed to | |
2267 * have a size of 1 - i.e. the returned pointer may | |
2268 * be used to access directly the members of the | |
2269 * first retro_game_info_ext struct, for example: | |
2270 * | |
2271 * struct retro_game_info_ext *game_info_ext; | |
2272 * if (environ_cb(RETRO_ENVIRONMENT_GET_GAME_INFO_EXT, &game_info_ext)) | |
2273 * printf("Content Directory: %s\n", game_info_ext->dir); | |
2274 * | |
2275 * - If the function is called inside retro_load_game_special(), | |
2276 * the retro_game_info_ext array is guaranteed to have a | |
2277 * size equal to the num_info argument passed to | |
2278 * retro_load_game_special() | |
491 */ | 2279 */ |
492 #define RETRO_ENVIRONMENT_GET_CAN_DUPE 3 /* bool * -- | 2280 |
493 * Boolean value whether or not frontend supports frame duping, | 2281 /** |
494 * passing NULL to video frame callback. | 2282 * Defines a set of core options that can be shown and configured by the frontend, |
2283 * so that the player may customize their gameplay experience to their liking. | |
2284 * | |
2285 * @note This environment call is intended to replace | |
2286 * \c RETRO_ENVIRONMENT_SET_VARIABLES and \c RETRO_ENVIRONMENT_SET_CORE_OPTIONS, | |
2287 * and should only be called if \c RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION | |
2288 * returns an API version of at least 2. | |
2289 * | |
2290 * This should be called the first time as early as possible, | |
2291 * ideally in \c retro_set_environment (but \c retro_load_game is acceptable). | |
2292 * It may then be called again later to update | |
2293 * the core's options and their associated values, | |
2294 * as long as the number of options doesn't change | |
2295 * from the number given in the first call. | |
2296 * | |
2297 * The core can retrieve option values at any time with \c RETRO_ENVIRONMENT_GET_VARIABLE. | |
2298 * If a saved value for a core option doesn't match the option definition's values, | |
2299 * the frontend may treat it as incorrect and revert to the default. | |
2300 * | |
2301 * Core options and their values are usually defined in a large static array, | |
2302 * but they may be generated at runtime based on the loaded game or system state. | |
2303 * Here are some use cases for that: | |
2304 * | |
2305 * @li Selecting a particular file from one of the | |
2306 * \ref RETRO_ENVIRONMENT_GET_ASSET_DIRECTORY "frontend's" | |
2307 * \ref RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY "content" | |
2308 * \ref RETRO_ENVIRONMENT_GET_CORE_ASSETS_DIRECTORY "directories", | |
2309 * such as a memory card image or figurine data file. | |
2310 * @li Excluding options that are not relevant to the current game, | |
2311 * for cores that define a large number of possible options. | |
2312 * @li Choosing a default value at runtime for a specific game, | |
2313 * such as a BIOS file whose region matches that of the loaded content. | |
2314 * | |
2315 * @note A guiding principle of libretro's API design is that | |
2316 * all common interactions (gameplay, menu navigation, etc.) | |
2317 * should be possible without a keyboard. | |
2318 * This implies that cores should keep the number of options and values | |
2319 * as low as possible. | |
2320 * | |
2321 * @param[in] data <tt>const struct retro_core_options_v2 *</tt>. | |
2322 * Pointer to a core's options and their associated categories. | |
2323 * May be \c NULL, in which case the frontend will remove all existing core options. | |
2324 * The frontend must maintain its own copy of this object, | |
2325 * including all strings and subobjects. | |
2326 * @return \c true if this environment call is available | |
2327 * and the frontend supports categories. | |
2328 * Note that this environment call is guaranteed to successfully register | |
2329 * the provided core options, | |
2330 * so the return value does not indicate success or failure. | |
2331 * | |
2332 * @see retro_core_options_v2 | |
2333 * @see retro_core_option_v2_category | |
2334 * @see retro_core_option_v2_definition | |
2335 * @see RETRO_ENVIRONMENT_GET_VARIABLE | |
2336 * @see RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2_INTL | |
2337 */ | |
2338 #define RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2 67 | |
2339 | |
2340 /** | |
2341 * A variant of \ref RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2 | |
2342 * that supports internationalization. | |
2343 * | |
2344 * This should be called instead of \c RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2 | |
2345 * if the core provides translations for its options. | |
2346 * General use is largely the same, | |
2347 * but see \ref retro_core_options_v2_intl for some important details. | |
2348 * | |
2349 * @param[in] data <tt>const struct retro_core_options_v2_intl *</tt>. | |
2350 * Pointer to a core's option values and categories, | |
2351 * plus a translation for each option and category. | |
2352 * @see retro_core_options_v2_intl | |
2353 * @see RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2 | |
2354 */ | |
2355 #define RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2_INTL 68 | |
2356 | |
2357 /** | |
2358 * Registers a callback that the frontend can use | |
2359 * to notify the core that at least one core option | |
2360 * should be made hidden or visible. | |
2361 * Allows a frontend to signal that a core must update | |
2362 * the visibility of any dynamically hidden core options, | |
2363 * and enables the frontend to detect visibility changes. | |
2364 * Used by the frontend to update the menu display status | |
2365 * of core options without requiring a call of retro_run(). | |
2366 * Must be called in retro_set_environment(). | |
2367 * | |
2368 * @param[in] data <tt>const struct retro_core_options_update_display_callback *</tt>. | |
2369 * The callback that the frontend should use. | |
2370 * May be \c NULL, in which case the frontend will unset any existing callback. | |
2371 * Can be used to query visibility support. | |
2372 * @return \c true if this environment call is available, | |
2373 * even if \c data is \c NULL. | |
2374 * @see retro_core_options_update_display_callback | |
2375 */ | |
2376 #define RETRO_ENVIRONMENT_SET_CORE_OPTIONS_UPDATE_DISPLAY_CALLBACK 69 | |
2377 | |
2378 /** | |
2379 * Forcibly sets a core option's value. | |
2380 * | |
2381 * After changing a core option value with this callback, | |
2382 * it will be reflected in the frontend | |
2383 * and \ref RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE will return \c true. | |
2384 * \ref retro_variable::key must match | |
2385 * a \ref RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2 "previously-set core option", | |
2386 * and \ref retro_variable::value must match one of its defined values. | |
2387 * | |
2388 * Possible use cases include: | |
2389 * | |
2390 * @li Allowing the player to set certain core options | |
2391 * without entering the frontend's option menu, | |
2392 * using an in-core hotkey. | |
2393 * @li Adjusting invalid combinations of settings. | |
2394 * @li Migrating settings from older releases of a core. | |
2395 * | |
2396 * @param[in] data <tt>const struct retro_variable *</tt>. | |
2397 * Pointer to a single option that the core is changing. | |
2398 * May be \c NULL, in which case the frontend will return \c true | |
2399 * to indicate that this environment call is available. | |
2400 * @return \c true if this environment call is available | |
2401 * and the option named by \c key was successfully | |
2402 * set to the given \c value. | |
2403 * \c false if the \c key or \c value fields are \c NULL, empty, | |
2404 * or don't match a previously set option. | |
2405 * | |
2406 * @see RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2 | |
2407 * @see RETRO_ENVIRONMENT_GET_VARIABLE | |
2408 * @see RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE | |
2409 */ | |
2410 #define RETRO_ENVIRONMENT_SET_VARIABLE 70 | |
2411 | |
2412 #define RETRO_ENVIRONMENT_GET_THROTTLE_STATE (71 | RETRO_ENVIRONMENT_EXPERIMENTAL) | |
2413 /* struct retro_throttle_state * -- | |
2414 * Allows an implementation to get details on the actual rate | |
2415 * the frontend is attempting to call retro_run(). | |
495 */ | 2416 */ |
496 | 2417 |
497 /* Environ 4, 5 are no longer supported (GET_VARIABLE / SET_VARIABLES), | 2418 /** |
498 * and reserved to avoid possible ABI clash. | 2419 * Returns information about how the frontend will use savestates. |
2420 * | |
2421 * @param[out] data <tt>retro_savestate_context *</tt>. | |
2422 * Pointer to the current savestate context. | |
2423 * May be \c NULL, in which case the environment call | |
2424 * will return \c true to indicate its availability. | |
2425 * @returns \c true if the environment call is available, | |
2426 * even if \c data is \c NULL. | |
2427 * @see retro_savestate_context | |
2428 */ | |
2429 #define RETRO_ENVIRONMENT_GET_SAVESTATE_CONTEXT (72 | RETRO_ENVIRONMENT_EXPERIMENTAL) | |
2430 | |
2431 /** | |
2432 * Before calling \c SET_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE, will query which interface is supported. | |
2433 * | |
2434 * Frontend looks at \c retro_hw_render_interface_type and returns the maximum supported | |
2435 * context negotiation interface version. If the \c retro_hw_render_interface_type is not | |
2436 * supported or recognized by the frontend, a version of 0 must be returned in | |
2437 * \c retro_hw_render_interface's \c interface_version and \c true is returned by frontend. | |
2438 * | |
2439 * If this environment call returns true with a \c interface_version greater than 0, | |
2440 * a core can always use a negotiation interface version larger than what the frontend returns, | |
2441 * but only earlier versions of the interface will be used by the frontend. | |
2442 * | |
2443 * A frontend must not reject a negotiation interface version that is larger than what the | |
2444 * frontend supports. Instead, the frontend will use the older entry points that it recognizes. | |
2445 * If this is incompatible with a particular core's requirements, it can error out early. | |
2446 * | |
2447 * @note Regarding backwards compatibility, this environment call was introduced after Vulkan v1 | |
2448 * context negotiation. If this environment call is not supported by frontend, i.e. the environment | |
2449 * call returns \c false , only Vulkan v1 context negotiation is supported (if Vulkan HW rendering | |
2450 * is supported at all). If a core uses Vulkan negotiation interface with version > 1, negotiation | |
2451 * may fail unexpectedly. All future updates to the context negotiation interface implies that | |
2452 * frontend must support this environment call to query support. | |
2453 * | |
2454 * @param[out] data <tt>struct retro_hw_render_context_negotiation_interface *</tt>. | |
2455 * @return \c true if the environment call is available. | |
2456 * @see SET_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE | |
2457 * @see retro_hw_render_interface_type | |
2458 * @see retro_hw_render_context_negotiation_interface | |
2459 */ | |
2460 #define RETRO_ENVIRONMENT_GET_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE_SUPPORT (73 | RETRO_ENVIRONMENT_EXPERIMENTAL) | |
2461 | |
2462 /** | |
2463 * Asks the frontend whether JIT compilation can be used. | |
2464 * Primarily used by iOS and tvOS. | |
2465 * @param[out] data <tt>bool *</tt>. | |
2466 * Set to \c true if the frontend has verified that JIT compilation is possible. | |
2467 * @return \c true if the environment call is available. | |
2468 */ | |
2469 #define RETRO_ENVIRONMENT_GET_JIT_CAPABLE 74 | |
2470 | |
2471 /** | |
2472 * Returns an interface that the core can use to receive microphone input. | |
2473 * | |
2474 * @param[out] data <tt>retro_microphone_interface *</tt>. | |
2475 * Pointer to the microphone interface. | |
2476 * @return \true if microphone support is available, | |
2477 * even if no microphones are plugged in. | |
2478 * \c false if microphone support is disabled unavailable, | |
2479 * or if \c data is \c NULL. | |
2480 * @see retro_microphone_interface | |
2481 */ | |
2482 #define RETRO_ENVIRONMENT_GET_MICROPHONE_INTERFACE (75 | RETRO_ENVIRONMENT_EXPERIMENTAL) | |
2483 | |
2484 /* Environment 76 was an obsolete version of RETRO_ENVIRONMENT_SET_NETPACKET_INTERFACE. | |
2485 * It was not used by any known core at the time, and was removed from the API. */ | |
2486 | |
2487 /** | |
2488 * Returns the device's current power state as reported by the frontend. | |
2489 * | |
2490 * This is useful for emulating the battery level in handheld consoles, | |
2491 * or for reducing power consumption when on battery power. | |
2492 * | |
2493 * @note This environment call describes the power state for the entire device, | |
2494 * not for individual peripherals like controllers. | |
2495 * | |
2496 * @param[out] data <struct retro_device_power *>. | |
2497 * Indicates whether the frontend can provide this information, even if the parameter | |
2498 * is \c NULL. If the frontend does not support this functionality, then the provided | |
2499 * argument will remain unchanged. | |
2500 * @return \c true if the environment call is available. | |
2501 * @see retro_device_power | |
2502 */ | |
2503 #define RETRO_ENVIRONMENT_GET_DEVICE_POWER (77 | RETRO_ENVIRONMENT_EXPERIMENTAL) | |
2504 | |
2505 #define RETRO_ENVIRONMENT_SET_NETPACKET_INTERFACE 78 | |
2506 /* const struct retro_netpacket_callback * -- | |
2507 * When set, a core gains control over network packets sent and | |
2508 * received during a multiplayer session. This can be used to | |
2509 * emulate multiplayer games that were originally played on two | |
2510 * or more separate consoles or computers connected together. | |
2511 * | |
2512 * The frontend will take care of connecting players together, | |
2513 * and the core only needs to send the actual data as needed for | |
2514 * the emulation, while handshake and connection management happen | |
2515 * in the background. | |
2516 * | |
2517 * When two or more players are connected and this interface has | |
2518 * been set, time manipulation features (such as pausing, slow motion, | |
2519 * fast forward, rewinding, save state loading, etc.) are disabled to | |
2520 * avoid interrupting communication. | |
2521 * | |
2522 * Should be set in either retro_init or retro_load_game, but not both. | |
2523 * | |
2524 * When not set, a frontend may use state serialization-based | |
2525 * multiplayer, where a deterministic core supporting multiple | |
2526 * input devices does not need to take any action on its own. | |
499 */ | 2527 */ |
500 | 2528 |
501 #define RETRO_ENVIRONMENT_SET_MESSAGE 6 /* const struct retro_message * -- | 2529 /** |
502 * Sets a message to be displayed in implementation-specific manner | 2530 * Returns the device's current power state as reported by the frontend. |
503 * for a certain amount of 'frames'. | 2531 * This is useful for emulating the battery level in handheld consoles, |
504 * Should not be used for trivial messages, which should simply be | 2532 * or for reducing power consumption when on battery power. |
505 * logged via RETRO_ENVIRONMENT_GET_LOG_INTERFACE (or as a | 2533 * |
506 * fallback, stderr). | 2534 * The return value indicates whether the frontend can provide this information, |
507 */ | 2535 * even if the parameter is \c NULL. |
508 #define RETRO_ENVIRONMENT_SHUTDOWN 7 /* N/A (NULL) -- | 2536 * |
509 * Requests the frontend to shutdown. | 2537 * If the frontend does not support this functionality, |
510 * Should only be used if game has a specific | 2538 * then the provided argument will remain unchanged. |
511 * way to shutdown the game from a menu item or similar. | 2539 * @param[out] data <tt>retro_device_power *</tt>. |
512 */ | 2540 * Pointer to the information that the frontend returns about its power state. |
513 #define RETRO_ENVIRONMENT_SET_PERFORMANCE_LEVEL 8 | 2541 * May be \c NULL. |
514 /* const unsigned * -- | 2542 * @return \c true if the environment call is available, |
515 * Gives a hint to the frontend how demanding this implementation | 2543 * even if \c data is \c NULL. |
516 * is on a system. E.g. reporting a level of 2 means | 2544 * @see retro_device_power |
517 * this implementation should run decently on all frontends | 2545 * @note This environment call describes the power state for the entire device, |
518 * of level 2 and up. | 2546 * not for individual peripherals like controllers. |
519 * | 2547 */ |
520 * It can be used by the frontend to potentially warn | 2548 #define RETRO_ENVIRONMENT_GET_DEVICE_POWER (77 | RETRO_ENVIRONMENT_EXPERIMENTAL) |
521 * about too demanding implementations. | 2549 |
522 * | 2550 /** |
523 * The levels are "floating". | 2551 * Returns the "playlist" directory of the frontend. |
524 * | 2552 * |
525 * This function can be called on a per-game basis, | 2553 * This directory can be used to store core generated playlists, in case |
526 * as certain games an implementation can play might be | 2554 * this internal functionality is available (e.g. internal core game detection |
527 * particularly demanding. | 2555 * engine). |
528 * If called, it should be called in retro_load_game(). | 2556 * |
529 */ | 2557 * @param[out] data <tt>const char **</tt>. |
530 #define RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY 9 | 2558 * May be \c NULL. If so, no such directory is defined, and it's up to the |
531 /* const char ** -- | 2559 * implementation to find a suitable directory. |
532 * Returns the "system" directory of the frontend. | 2560 * @return \c true if the environment call is available. |
533 * This directory can be used to store system specific | 2561 */ |
534 * content such as BIOSes, configuration data, etc. | 2562 #define RETRO_ENVIRONMENT_GET_PLAYLIST_DIRECTORY 79 |
535 * The returned value can be NULL. | 2563 |
536 * If so, no such directory is defined, | 2564 /** |
537 * and it's up to the implementation to find a suitable directory. | 2565 * Returns the "file browser" start directory of the frontend. |
538 * | 2566 * |
539 * NOTE: Some cores used this folder also for "save" data such as | 2567 * This directory can serve as a start directory for the core in case it |
540 * memory cards, etc, for lack of a better place to put it. | 2568 * provides an internal way of loading content. |
541 * This is now discouraged, and if possible, cores should try to | 2569 * |
542 * use the new GET_SAVE_DIRECTORY. | 2570 * @param[out] data <tt>const char **</tt>. |
543 */ | 2571 * May be \c NULL. If so, no such directory is defined, and it's up to the |
544 #define RETRO_ENVIRONMENT_SET_PIXEL_FORMAT 10 | 2572 * implementation to find a suitable directory. |
545 /* const enum retro_pixel_format * -- | 2573 * @return \c true if the environment call is available. |
546 * Sets the internal pixel format used by the implementation. | 2574 */ |
547 * The default pixel format is RETRO_PIXEL_FORMAT_0RGB1555. | 2575 #define RETRO_ENVIRONMENT_GET_FILE_BROWSER_START_DIRECTORY 80 |
548 * This pixel format however, is deprecated (see enum retro_pixel_format). | 2576 |
549 * If the call returns false, the frontend does not support this pixel | 2577 /**@}*/ |
550 * format. | 2578 |
551 * | 2579 /** |
552 * This function should be called inside retro_load_game() or | 2580 * @defgroup GET_VFS_INTERFACE File System Interface |
553 * retro_get_system_av_info(). | 2581 * @brief File system functionality. |
554 */ | 2582 * |
555 #define RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS 11 | 2583 * @section File Paths |
556 /* const struct retro_input_descriptor * -- | 2584 * File paths passed to all libretro filesystem APIs shall be well formed UNIX-style, |
557 * Sets an array of retro_input_descriptors. | 2585 * using "/" (unquoted forward slash) as the directory separator |
558 * It is up to the frontend to present this in a usable way. | 2586 * regardless of the platform's native separator. |
559 * The array is terminated by retro_input_descriptor::description | 2587 * |
560 * being set to NULL. | 2588 * Paths shall also include at least one forward slash |
561 * This function can be called at any time, but it is recommended | 2589 * (e.g. use "./game.bin" instead of "game.bin"). |
562 * to call it as early as possible. | 2590 * |
563 */ | 2591 * Other than the directory separator, cores shall not make assumptions about path format. |
564 #define RETRO_ENVIRONMENT_SET_KEYBOARD_CALLBACK 12 | 2592 * The following paths are all valid: |
565 /* const struct retro_keyboard_callback * -- | 2593 * @li \c C:/path/game.bin |
566 * Sets a callback function used to notify core about keyboard events. | 2594 * @li \c http://example.com/game.bin |
567 */ | 2595 * @li \c #game/game.bin |
568 #define RETRO_ENVIRONMENT_SET_DISK_CONTROL_INTERFACE 13 | 2596 * @li \c ./game.bin |
569 /* const struct retro_disk_control_callback * -- | 2597 * |
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; | 2598 * 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. | 2599 * however, cores shall not append "./", "../" or multiple consecutive forward slashes ("//") to paths they request from the 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. | 2600 * |
986 * Frontends are encouraged, but not required, to support native file system paths (modulo replacing the directory separator, if applicable). | 2601 * The frontend is encouraged to do the best it can when given an ill-formed path, |
987 * Cores are allowed to try using them, but must remain functional if the front rejects such requests. | 2602 * but it is allowed to give up. |
2603 * | |
2604 * Frontends are encouraged, but not required, to support native file system paths | |
2605 * (including replacing the directory separator, if applicable). | |
2606 * | |
2607 * Cores are allowed to try using them, but must remain functional if the frontend rejects such requests. | |
2608 * | |
988 * Cores are encouraged to use the libretro-common filestream functions for file I/O, | 2609 * 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 | 2610 * as they seamlessly integrate with VFS, |
990 * and provide platform-specific fallbacks in cases where front ends do not support VFS. */ | 2611 * deal with directory separator replacement as appropriate |
991 | 2612 * and provide platform-specific fallbacks |
992 /* Opaque file handle | 2613 * in cases where front ends do not provide their own VFS interface. |
993 * Introduced in VFS API v1 */ | 2614 * |
2615 * @see RETRO_ENVIRONMENT_GET_VFS_INTERFACE | |
2616 * @see retro_vfs_interface_info | |
2617 * @see file_path | |
2618 * @see retro_dirent | |
2619 * @see file_stream | |
2620 * | |
2621 * @{ | |
2622 */ | |
2623 | |
2624 /** | |
2625 * Opaque file handle. | |
2626 * @since VFS API v1 | |
2627 */ | |
994 struct retro_vfs_file_handle; | 2628 struct retro_vfs_file_handle; |
995 | 2629 |
996 /* File open flags | 2630 /** |
997 * Introduced in VFS API v1 */ | 2631 * Opaque directory handle. |
998 #define RETRO_VFS_FILE_ACCESS_READ (1 << 0) /* Read only mode */ | 2632 * @since VFS API v3 |
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 */ | 2633 */ |
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*/ | 2634 struct retro_vfs_dir_handle; |
2635 | |
2636 /** @defgroup RETRO_VFS_FILE_ACCESS File Access Flags | |
2637 * File access flags. | |
2638 * @since VFS API v1 | |
2639 * @{ | |
2640 */ | |
2641 | |
2642 /** Opens a file for read-only access. */ | |
2643 #define RETRO_VFS_FILE_ACCESS_READ (1 << 0) | |
2644 | |
2645 /** | |
2646 * Opens a file for write-only access. | |
2647 * Any existing file at this path will be discarded and overwritten | |
2648 * unless \c RETRO_VFS_FILE_ACCESS_UPDATE_EXISTING is also specified. | |
2649 */ | |
2650 #define RETRO_VFS_FILE_ACCESS_WRITE (1 << 1) | |
2651 | |
2652 /** | |
2653 * Opens a file for reading and writing. | |
2654 * Any existing file at this path will be discarded and overwritten | |
2655 * unless \c RETRO_VFS_FILE_ACCESS_UPDATE_EXISTING is also specified. | |
2656 */ | |
2657 #define RETRO_VFS_FILE_ACCESS_READ_WRITE (RETRO_VFS_FILE_ACCESS_READ | RETRO_VFS_FILE_ACCESS_WRITE) | |
2658 | |
2659 /** | |
2660 * Opens a file without discarding its existing contents. | |
2661 * Only meaningful if \c RETRO_VFS_FILE_ACCESS_WRITE is specified. | |
2662 */ | |
1001 #define RETRO_VFS_FILE_ACCESS_UPDATE_EXISTING (1 << 2) /* Prevents discarding content of existing files opened for writing */ | 2663 #define RETRO_VFS_FILE_ACCESS_UPDATE_EXISTING (1 << 2) /* Prevents discarding content of existing files opened for writing */ |
1002 | 2664 |
1003 /* These are only hints. The frontend may choose to ignore them. Other than RAM/CPU/etc use, | 2665 /** @} */ |
1004 and how they react to unlikely external interference (for example someone else writing to that file, | 2666 |
1005 or the file's server going down), behavior will not change. */ | 2667 /** @defgroup RETRO_VFS_FILE_ACCESS_HINT File Access Hints |
2668 * | |
2669 * Hints to the frontend for how a file will be accessed. | |
2670 * The VFS implementation may use these to optimize performance, | |
2671 * react to external interference (such as concurrent writes), | |
2672 * or it may ignore them entirely. | |
2673 * | |
2674 * Hint flags do not change the behavior of each VFS function | |
2675 * unless otherwise noted. | |
2676 * @{ | |
2677 */ | |
2678 | |
2679 /** No particular hints are given. */ | |
1006 #define RETRO_VFS_FILE_ACCESS_HINT_NONE (0) | 2680 #define RETRO_VFS_FILE_ACCESS_HINT_NONE (0) |
1007 /* Indicate that the file will be accessed many times. The frontend should aggressively cache everything. */ | 2681 |
2682 /** | |
2683 * Indicates that the file will be accessed frequently. | |
2684 * | |
2685 * The frontend should cache it or map it into memory. | |
2686 */ | |
1008 #define RETRO_VFS_FILE_ACCESS_HINT_FREQUENT_ACCESS (1 << 0) | 2687 #define RETRO_VFS_FILE_ACCESS_HINT_FREQUENT_ACCESS (1 << 0) |
1009 | 2688 |
1010 /* Seek positions */ | 2689 /** @} */ |
2690 | |
2691 /** @defgroup RETRO_VFS_SEEK_POSITION File Seek Positions | |
2692 * File access flags and hints. | |
2693 * @{ | |
2694 */ | |
2695 | |
2696 /** | |
2697 * Indicates a seek relative to the start of the file. | |
2698 */ | |
1011 #define RETRO_VFS_SEEK_POSITION_START 0 | 2699 #define RETRO_VFS_SEEK_POSITION_START 0 |
2700 | |
2701 /** | |
2702 * Indicates a seek relative to the current stream position. | |
2703 */ | |
1012 #define RETRO_VFS_SEEK_POSITION_CURRENT 1 | 2704 #define RETRO_VFS_SEEK_POSITION_CURRENT 1 |
2705 | |
2706 /** | |
2707 * Indicates a seek relative to the end of the file. | |
2708 * @note The offset passed to \c retro_vfs_seek_t should be negative. | |
2709 */ | |
1013 #define RETRO_VFS_SEEK_POSITION_END 2 | 2710 #define RETRO_VFS_SEEK_POSITION_END 2 |
1014 | 2711 |
1015 /* Get path from opaque handle. Returns the exact same path passed to file_open when getting the handle | 2712 /** @} */ |
1016 * Introduced in VFS API v1 */ | 2713 |
2714 /** @defgroup RETRO_VFS_STAT File Status Flags | |
2715 * File stat flags. | |
2716 * @see retro_vfs_stat_t | |
2717 * @since VFS API v3 | |
2718 * @{ | |
2719 */ | |
2720 | |
2721 /** Indicates that the given path refers to a valid file. */ | |
2722 #define RETRO_VFS_STAT_IS_VALID (1 << 0) | |
2723 | |
2724 /** Indicates that the given path refers to a directory. */ | |
2725 #define RETRO_VFS_STAT_IS_DIRECTORY (1 << 1) | |
2726 | |
2727 /** | |
2728 * Indicates that the given path refers to a character special file, | |
2729 * such as \c /dev/null. | |
2730 */ | |
2731 #define RETRO_VFS_STAT_IS_CHARACTER_SPECIAL (1 << 2) | |
2732 | |
2733 /** @} */ | |
2734 | |
2735 /** | |
2736 * Returns the path that was used to open this file. | |
2737 * | |
2738 * @param stream The opened file handle to get the path of. | |
2739 * Behavior is undefined if \c NULL or closed. | |
2740 * @return The path that was used to open \c stream. | |
2741 * The string is owned by \c stream and must not be modified. | |
2742 * @since VFS API v1 | |
2743 * @see filestream_get_path | |
2744 */ | |
1017 typedef const char *(RETRO_CALLCONV *retro_vfs_get_path_t)(struct retro_vfs_file_handle *stream); | 2745 typedef const char *(RETRO_CALLCONV *retro_vfs_get_path_t)(struct retro_vfs_file_handle *stream); |
1018 | 2746 |
1019 /* Open a file for reading or writing. If path points to a directory, this will | 2747 /** |
1020 * fail. Returns the opaque file handle, or NULL for error. | 2748 * Open a file for reading or writing. |
1021 * Introduced in VFS API v1 */ | 2749 * |
2750 * @param path The path to open. | |
2751 * @param mode A bitwise combination of \c RETRO_VFS_FILE_ACCESS flags. | |
2752 * At a minimum, one of \c RETRO_VFS_FILE_ACCESS_READ or \c RETRO_VFS_FILE_ACCESS_WRITE must be specified. | |
2753 * @param hints A bitwise combination of \c RETRO_VFS_FILE_ACCESS_HINT flags. | |
2754 * @return A handle to the opened file, | |
2755 * or \c NULL upon failure. | |
2756 * Note that this will return \c NULL if \c path names a directory. | |
2757 * The returned file handle must be closed with \c retro_vfs_close_t. | |
2758 * @since VFS API v1 | |
2759 * @see File Paths | |
2760 * @see RETRO_VFS_FILE_ACCESS | |
2761 * @see RETRO_VFS_FILE_ACCESS_HINT | |
2762 * @see retro_vfs_close_t | |
2763 * @see filestream_open | |
2764 */ | |
1022 typedef struct retro_vfs_file_handle *(RETRO_CALLCONV *retro_vfs_open_t)(const char *path, unsigned mode, unsigned hints); | 2765 typedef struct retro_vfs_file_handle *(RETRO_CALLCONV *retro_vfs_open_t)(const char *path, unsigned mode, unsigned hints); |
1023 | 2766 |
1024 /* Close the file and release its resources. Must be called if open_file returns non-NULL. Returns 0 on succes, -1 on failure. | 2767 /** |
1025 * Whether the call succeeds ot not, the handle passed as parameter becomes invalid and should no longer be used. | 2768 * Close the file and release its resources. |
1026 * Introduced in VFS API v1 */ | 2769 * All files returned by \c retro_vfs_open_t must be closed with this function. |
2770 * | |
2771 * @param stream The file handle to close. | |
2772 * Behavior is undefined if already closed. | |
2773 * Upon completion of this function, \c stream is no longer valid | |
2774 * (even if it returns failure). | |
2775 * @return 0 on success, -1 on failure or if \c stream is \c NULL. | |
2776 * @see retro_vfs_open_t | |
2777 * @see filestream_close | |
2778 * @since VFS API v1 | |
2779 */ | |
1027 typedef int (RETRO_CALLCONV *retro_vfs_close_t)(struct retro_vfs_file_handle *stream); | 2780 typedef int (RETRO_CALLCONV *retro_vfs_close_t)(struct retro_vfs_file_handle *stream); |
1028 | 2781 |
1029 /* Return the size of the file in bytes, or -1 for error. | 2782 /** |
1030 * Introduced in VFS API v1 */ | 2783 * Return the size of the file in bytes. |
2784 * | |
2785 * @param stream The file to query the size of. | |
2786 * @return Size of the file in bytes, or -1 if there was an error. | |
2787 * @see filestream_get_size | |
2788 * @since VFS API v1 | |
2789 */ | |
1031 typedef int64_t (RETRO_CALLCONV *retro_vfs_size_t)(struct retro_vfs_file_handle *stream); | 2790 typedef int64_t (RETRO_CALLCONV *retro_vfs_size_t)(struct retro_vfs_file_handle *stream); |
1032 | 2791 |
1033 /* Get the current read / write position for the file. Returns - 1 for error. | 2792 /** |
1034 * Introduced in VFS API v1 */ | 2793 * Set the file's length. |
2794 * | |
2795 * @param stream The file whose length will be adjusted. | |
2796 * @param length The new length of the file, in bytes. | |
2797 * If shorter than the original length, the extra bytes will be discarded. | |
2798 * If longer, the file's padding is unspecified (and likely platform-dependent). | |
2799 * @return 0 on success, | |
2800 * -1 on failure. | |
2801 * @see filestream_truncate | |
2802 * @since VFS API v2 | |
2803 */ | |
2804 typedef int64_t (RETRO_CALLCONV *retro_vfs_truncate_t)(struct retro_vfs_file_handle *stream, int64_t length); | |
2805 | |
2806 /** | |
2807 * Gets the given file's current read/write position. | |
2808 * This position is advanced with each call to \c retro_vfs_read_t or \c retro_vfs_write_t. | |
2809 * | |
2810 * @param stream The file to query the position of. | |
2811 * @return The current stream position in bytes | |
2812 * or -1 if there was an error. | |
2813 * @see filestream_tell | |
2814 * @since VFS API v1 | |
2815 */ | |
1035 typedef int64_t (RETRO_CALLCONV *retro_vfs_tell_t)(struct retro_vfs_file_handle *stream); | 2816 typedef int64_t (RETRO_CALLCONV *retro_vfs_tell_t)(struct retro_vfs_file_handle *stream); |
1036 | 2817 |
1037 /* Set the current read/write position for the file. Returns the new position, -1 for error. | 2818 /** |
1038 * Introduced in VFS API v1 */ | 2819 * Sets the given file handle's current read/write position. |
2820 * | |
2821 * @param stream The file to set the position of. | |
2822 * @param offset The new position, in bytes. | |
2823 * @param seek_position The position to seek from. | |
2824 * @return The new position, | |
2825 * or -1 if there was an error. | |
2826 * @since VFS API v1 | |
2827 * @see File Seek Positions | |
2828 * @see filestream_seek | |
2829 */ | |
1039 typedef int64_t (RETRO_CALLCONV *retro_vfs_seek_t)(struct retro_vfs_file_handle *stream, int64_t offset, int seek_position); | 2830 typedef int64_t (RETRO_CALLCONV *retro_vfs_seek_t)(struct retro_vfs_file_handle *stream, int64_t offset, int seek_position); |
1040 | 2831 |
1041 /* Read data from a file. Returns the number of bytes read, or -1 for error. | 2832 /** |
1042 * Introduced in VFS API v1 */ | 2833 * Read data from a file, if it was opened for reading. |
2834 * | |
2835 * @param stream The file to read from. | |
2836 * @param s The buffer to read into. | |
2837 * @param len The number of bytes to read. | |
2838 * The buffer pointed to by \c s must be this large. | |
2839 * @return The number of bytes read, | |
2840 * or -1 if there was an error. | |
2841 * @since VFS API v1 | |
2842 * @see filestream_read | |
2843 */ | |
1043 typedef int64_t (RETRO_CALLCONV *retro_vfs_read_t)(struct retro_vfs_file_handle *stream, void *s, uint64_t len); | 2844 typedef int64_t (RETRO_CALLCONV *retro_vfs_read_t)(struct retro_vfs_file_handle *stream, void *s, uint64_t len); |
1044 | 2845 |
1045 /* Write data to a file. Returns the number of bytes written, or -1 for error. | 2846 /** |
1046 * Introduced in VFS API v1 */ | 2847 * Write data to a file, if it was opened for writing. |
2848 * | |
2849 * @param stream The file handle to write to. | |
2850 * @param s The buffer to write from. | |
2851 * @param len The number of bytes to write. | |
2852 * The buffer pointed to by \c s must be this large. | |
2853 * @return The number of bytes written, | |
2854 * or -1 if there was an error. | |
2855 * @since VFS API v1 | |
2856 * @see filestream_write | |
2857 */ | |
1047 typedef int64_t (RETRO_CALLCONV *retro_vfs_write_t)(struct retro_vfs_file_handle *stream, const void *s, uint64_t len); | 2858 typedef int64_t (RETRO_CALLCONV *retro_vfs_write_t)(struct retro_vfs_file_handle *stream, const void *s, uint64_t len); |
1048 | 2859 |
1049 /* Flush pending writes to file, if using buffered IO. Returns 0 on sucess, or -1 on failure. | 2860 /** |
1050 * Introduced in VFS API v1 */ | 2861 * Flush pending writes to the file, if applicable. |
2862 * | |
2863 * This does not mean that the changes will be immediately persisted to disk; | |
2864 * that may be scheduled for later, depending on the platform. | |
2865 * | |
2866 * @param stream The file handle to flush. | |
2867 * @return 0 on success, -1 on failure. | |
2868 * @since VFS API v1 | |
2869 * @see filestream_flush | |
2870 */ | |
1051 typedef int (RETRO_CALLCONV *retro_vfs_flush_t)(struct retro_vfs_file_handle *stream); | 2871 typedef int (RETRO_CALLCONV *retro_vfs_flush_t)(struct retro_vfs_file_handle *stream); |
1052 | 2872 |
1053 /* Delete the specified file. Returns 0 on success, -1 on failure | 2873 /** |
1054 * Introduced in VFS API v1 */ | 2874 * Deletes the file at the given path. |
2875 * | |
2876 * @param path The path to the file that will be deleted. | |
2877 * @return 0 on success, -1 on failure. | |
2878 * @see filestream_delete | |
2879 * @since VFS API v1 | |
2880 */ | |
1055 typedef int (RETRO_CALLCONV *retro_vfs_remove_t)(const char *path); | 2881 typedef int (RETRO_CALLCONV *retro_vfs_remove_t)(const char *path); |
1056 | 2882 |
1057 /* Rename the specified file. Returns 0 on success, -1 on failure | 2883 /** |
1058 * Introduced in VFS API v1 */ | 2884 * Rename the specified file. |
2885 * | |
2886 * @param old_path Path to an existing file. | |
2887 * @param new_path The destination path. | |
2888 * Must not name an existing file. | |
2889 * @return 0 on success, -1 on failure | |
2890 * @see filestream_rename | |
2891 * @since VFS API v1 | |
2892 */ | |
1059 typedef int (RETRO_CALLCONV *retro_vfs_rename_t)(const char *old_path, const char *new_path); | 2893 typedef int (RETRO_CALLCONV *retro_vfs_rename_t)(const char *old_path, const char *new_path); |
1060 | 2894 |
2895 /** | |
2896 * Gets information about the given file. | |
2897 * | |
2898 * @param path The path to the file to query. | |
2899 * @param[out] size The reported size of the file in bytes. | |
2900 * May be \c NULL, in which case this value is ignored. | |
2901 * @return A bitmask of \c RETRO_VFS_STAT flags, | |
2902 * or 0 if \c path doesn't refer to a valid file. | |
2903 * @see path_stat | |
2904 * @see path_get_size | |
2905 * @see RETRO_VFS_STAT | |
2906 * @since VFS API v3 | |
2907 */ | |
2908 typedef int (RETRO_CALLCONV *retro_vfs_stat_t)(const char *path, int32_t *size); | |
2909 | |
2910 /** | |
2911 * Creates a directory at the given path. | |
2912 * | |
2913 * @param dir The desired location of the new directory. | |
2914 * @return 0 if the directory was created, | |
2915 * -2 if the directory already exists, | |
2916 * or -1 if some other error occurred. | |
2917 * @see path_mkdir | |
2918 * @since VFS API v3 | |
2919 */ | |
2920 typedef int (RETRO_CALLCONV *retro_vfs_mkdir_t)(const char *dir); | |
2921 | |
2922 /** | |
2923 * Opens a handle to a directory so its contents can be inspected. | |
2924 * | |
2925 * @param dir The path to the directory to open. | |
2926 * Must be an existing directory. | |
2927 * @param include_hidden Whether to include hidden files in the directory listing. | |
2928 * The exact semantics of this flag will depend on the platform. | |
2929 * @return A handle to the opened directory, | |
2930 * or \c NULL if there was an error. | |
2931 * @see retro_opendir | |
2932 * @since VFS API v3 | |
2933 */ | |
2934 typedef struct retro_vfs_dir_handle *(RETRO_CALLCONV *retro_vfs_opendir_t)(const char *dir, bool include_hidden); | |
2935 | |
2936 /** | |
2937 * Gets the next dirent ("directory entry") | |
2938 * within the given directory. | |
2939 * | |
2940 * @param[in,out] dirstream The directory to read from. | |
2941 * Updated to point to the next file, directory, or other path. | |
2942 * @return \c true when the next dirent was retrieved, | |
2943 * \c false if there are no more dirents to read. | |
2944 * @note This API iterates over all files and directories within \c dirstream. | |
2945 * Remember to check what the type of the current dirent is. | |
2946 * @note This function does not recurse, | |
2947 * i.e. it does not return the contents of subdirectories. | |
2948 * @note This may include "." and ".." on Unix-like platforms. | |
2949 * @see retro_readdir | |
2950 * @see retro_vfs_dirent_is_dir_t | |
2951 * @since VFS API v3 | |
2952 */ | |
2953 typedef bool (RETRO_CALLCONV *retro_vfs_readdir_t)(struct retro_vfs_dir_handle *dirstream); | |
2954 | |
2955 /** | |
2956 * Gets the filename of the current dirent. | |
2957 * | |
2958 * The returned string pointer is valid | |
2959 * until the next call to \c retro_vfs_readdir_t or \c retro_vfs_closedir_t. | |
2960 * | |
2961 * @param dirstream The directory to read from. | |
2962 * @return The current dirent's name, | |
2963 * or \c NULL if there was an error. | |
2964 * @note This function only returns the file's \em name, | |
2965 * not a complete path to it. | |
2966 * @see retro_dirent_get_name | |
2967 * @since VFS API v3 | |
2968 */ | |
2969 typedef const char *(RETRO_CALLCONV *retro_vfs_dirent_get_name_t)(struct retro_vfs_dir_handle *dirstream); | |
2970 | |
2971 /** | |
2972 * Checks whether the current dirent names a directory. | |
2973 * | |
2974 * @param dirstream The directory to read from. | |
2975 * @return \c true if \c dirstream's current dirent points to a directory, | |
2976 * \c false if not or if there was an error. | |
2977 * @see retro_dirent_is_dir | |
2978 * @since VFS API v3 | |
2979 */ | |
2980 typedef bool (RETRO_CALLCONV *retro_vfs_dirent_is_dir_t)(struct retro_vfs_dir_handle *dirstream); | |
2981 | |
2982 /** | |
2983 * Closes the given directory and release its resources. | |
2984 * | |
2985 * Must be called on any \c retro_vfs_dir_handle returned by \c retro_vfs_open_t. | |
2986 * | |
2987 * @param dirstream The directory to close. | |
2988 * When this function returns (even failure), | |
2989 * \c dirstream will no longer be valid and must not be used. | |
2990 * @return 0 on success, -1 on failure. | |
2991 * @see retro_closedir | |
2992 * @since VFS API v3 | |
2993 */ | |
2994 typedef int (RETRO_CALLCONV *retro_vfs_closedir_t)(struct retro_vfs_dir_handle *dirstream); | |
2995 | |
2996 /** | |
2997 * File system interface exposed by the frontend. | |
2998 * | |
2999 * @see dirent_vfs_init | |
3000 * @see filestream_vfs_init | |
3001 * @see path_vfs_init | |
3002 * @see RETRO_ENVIRONMENT_GET_VFS_INTERFACE | |
3003 */ | |
1061 struct retro_vfs_interface | 3004 struct retro_vfs_interface |
1062 { | 3005 { |
3006 /* VFS API v1 */ | |
3007 /** @copydoc retro_vfs_get_path_t */ | |
1063 retro_vfs_get_path_t get_path; | 3008 retro_vfs_get_path_t get_path; |
3009 | |
3010 /** @copydoc retro_vfs_open_t */ | |
1064 retro_vfs_open_t open; | 3011 retro_vfs_open_t open; |
3012 | |
3013 /** @copydoc retro_vfs_close_t */ | |
1065 retro_vfs_close_t close; | 3014 retro_vfs_close_t close; |
3015 | |
3016 /** @copydoc retro_vfs_size_t */ | |
1066 retro_vfs_size_t size; | 3017 retro_vfs_size_t size; |
3018 | |
3019 /** @copydoc retro_vfs_tell_t */ | |
1067 retro_vfs_tell_t tell; | 3020 retro_vfs_tell_t tell; |
3021 | |
3022 /** @copydoc retro_vfs_seek_t */ | |
1068 retro_vfs_seek_t seek; | 3023 retro_vfs_seek_t seek; |
3024 | |
3025 /** @copydoc retro_vfs_read_t */ | |
1069 retro_vfs_read_t read; | 3026 retro_vfs_read_t read; |
3027 | |
3028 /** @copydoc retro_vfs_write_t */ | |
1070 retro_vfs_write_t write; | 3029 retro_vfs_write_t write; |
3030 | |
3031 /** @copydoc retro_vfs_flush_t */ | |
1071 retro_vfs_flush_t flush; | 3032 retro_vfs_flush_t flush; |
3033 | |
3034 /** @copydoc retro_vfs_remove_t */ | |
1072 retro_vfs_remove_t remove; | 3035 retro_vfs_remove_t remove; |
3036 | |
3037 /** @copydoc retro_vfs_rename_t */ | |
1073 retro_vfs_rename_t rename; | 3038 retro_vfs_rename_t rename; |
3039 /* VFS API v2 */ | |
3040 | |
3041 /** @copydoc retro_vfs_truncate_t */ | |
3042 retro_vfs_truncate_t truncate; | |
3043 /* VFS API v3 */ | |
3044 | |
3045 /** @copydoc retro_vfs_stat_t */ | |
3046 retro_vfs_stat_t stat; | |
3047 | |
3048 /** @copydoc retro_vfs_mkdir_t */ | |
3049 retro_vfs_mkdir_t mkdir; | |
3050 | |
3051 /** @copydoc retro_vfs_opendir_t */ | |
3052 retro_vfs_opendir_t opendir; | |
3053 | |
3054 /** @copydoc retro_vfs_readdir_t */ | |
3055 retro_vfs_readdir_t readdir; | |
3056 | |
3057 /** @copydoc retro_vfs_dirent_get_name_t */ | |
3058 retro_vfs_dirent_get_name_t dirent_get_name; | |
3059 | |
3060 /** @copydoc retro_vfs_dirent_is_dir_t */ | |
3061 retro_vfs_dirent_is_dir_t dirent_is_dir; | |
3062 | |
3063 /** @copydoc retro_vfs_closedir_t */ | |
3064 retro_vfs_closedir_t closedir; | |
1074 }; | 3065 }; |
1075 | 3066 |
3067 /** | |
3068 * Represents a request by the core for the frontend's file system interface, | |
3069 * as well as the interface itself returned by the frontend. | |
3070 * | |
3071 * You do not need to use these functions directly; | |
3072 * you may pass this struct to \c dirent_vfs_init, | |
3073 * \c filestream_vfs_init, or \c path_vfs_init | |
3074 * so that you can use the wrappers provided by these modules. | |
3075 * | |
3076 * @see dirent_vfs_init | |
3077 * @see filestream_vfs_init | |
3078 * @see path_vfs_init | |
3079 * @see RETRO_ENVIRONMENT_GET_VFS_INTERFACE | |
3080 */ | |
1076 struct retro_vfs_interface_info | 3081 struct retro_vfs_interface_info |
1077 { | 3082 { |
1078 /* Set by core: should this be higher than the version the front end supports, | 3083 /** |
1079 * front end will return false in the RETRO_ENVIRONMENT_GET_VFS_INTERFACE call | 3084 * The minimum version of the VFS API that the core requires. |
1080 * Introduced in VFS API v1 */ | 3085 * libretro-common's wrapper API initializers will check this value as well. |
3086 * | |
3087 * Set to the core's desired VFS version when requesting an interface, | |
3088 * and set by the frontend to indicate its actual API version. | |
3089 * | |
3090 * If the core asks for a newer VFS API version than the frontend supports, | |
3091 * the frontend must return \c false within the \c RETRO_ENVIRONMENT_GET_VFS_INTERFACE call. | |
3092 * @since VFS API v1 | |
3093 */ | |
1081 uint32_t required_interface_version; | 3094 uint32_t required_interface_version; |
1082 | 3095 |
1083 /* Frontend writes interface pointer here. The frontend also sets the actual | 3096 /** |
1084 * version, must be at least required_interface_version. | 3097 * Set by the frontend. |
1085 * Introduced in VFS API v1 */ | 3098 * The frontend will set this to the VFS interface it provides. |
3099 * | |
3100 * The interface is owned by the frontend | |
3101 * and must not be modified or freed by the core. | |
3102 * @since VFS API v1 */ | |
1086 struct retro_vfs_interface *iface; | 3103 struct retro_vfs_interface *iface; |
1087 }; | 3104 }; |
1088 | 3105 |
3106 /** @} */ | |
3107 | |
3108 /** @defgroup GET_HW_RENDER_INTERFACE Hardware Rendering Interface | |
3109 * @{ | |
3110 */ | |
3111 | |
3112 /** | |
3113 * Describes the hardware rendering API supported by | |
3114 * a particular subtype of \c retro_hw_render_interface. | |
3115 * | |
3116 * Not every rendering API supported by libretro has its own interface, | |
3117 * or even needs one. | |
3118 * | |
3119 * @see RETRO_ENVIRONMENT_SET_HW_RENDER | |
3120 * @see RETRO_ENVIRONMENT_GET_HW_RENDER_INTERFACE | |
3121 */ | |
1089 enum retro_hw_render_interface_type | 3122 enum retro_hw_render_interface_type |
1090 { | 3123 { |
1091 RETRO_HW_RENDER_INTERFACE_VULKAN = 0, | 3124 /** |
1092 RETRO_HW_RENDER_INTERFACE_DUMMY = INT_MAX | 3125 * Indicates a \c retro_hw_render_interface for Vulkan. |
3126 * @see retro_hw_render_interface_vulkan | |
3127 */ | |
3128 RETRO_HW_RENDER_INTERFACE_VULKAN = 0, | |
3129 | |
3130 /** Indicates a \c retro_hw_render_interface for Direct3D 9. */ | |
3131 RETRO_HW_RENDER_INTERFACE_D3D9 = 1, | |
3132 | |
3133 /** Indicates a \c retro_hw_render_interface for Direct3D 10. */ | |
3134 RETRO_HW_RENDER_INTERFACE_D3D10 = 2, | |
3135 | |
3136 /** | |
3137 * Indicates a \c retro_hw_render_interface for Direct3D 11. | |
3138 * @see retro_hw_render_interface_d3d11 | |
3139 */ | |
3140 RETRO_HW_RENDER_INTERFACE_D3D11 = 3, | |
3141 | |
3142 /** | |
3143 * Indicates a \c retro_hw_render_interface for Direct3D 12. | |
3144 * @see retro_hw_render_interface_d3d12 | |
3145 */ | |
3146 RETRO_HW_RENDER_INTERFACE_D3D12 = 4, | |
3147 | |
3148 /** | |
3149 * Indicates a \c retro_hw_render_interface for | |
3150 * the PlayStation's 2 PSKit API. | |
3151 * @see retro_hw_render_interface_gskit_ps2 | |
3152 */ | |
3153 RETRO_HW_RENDER_INTERFACE_GSKIT_PS2 = 5, | |
3154 | |
3155 /** @private Defined to ensure <tt>sizeof(retro_hw_render_interface_type) == sizeof(int)</tt>. | |
3156 * Do not use. */ | |
3157 RETRO_HW_RENDER_INTERFACE_DUMMY = INT_MAX | |
1093 }; | 3158 }; |
1094 | 3159 |
1095 /* Base struct. All retro_hw_render_interface_* types | 3160 /** |
1096 * contain at least these fields. */ | 3161 * Base render interface type. |
3162 * All \c retro_hw_render_interface implementations | |
3163 * will start with these two fields set to particular values. | |
3164 * | |
3165 * @see retro_hw_render_interface_type | |
3166 * @see RETRO_ENVIRONMENT_SET_HW_RENDER | |
3167 * @see RETRO_ENVIRONMENT_GET_HW_RENDER_INTERFACE | |
3168 */ | |
1097 struct retro_hw_render_interface | 3169 struct retro_hw_render_interface |
1098 { | 3170 { |
3171 /** | |
3172 * Denotes the particular rendering API that this interface is for. | |
3173 * Each interface requires this field to be set to a particular value. | |
3174 * Use it to cast this interface to the appropriate pointer. | |
3175 */ | |
1099 enum retro_hw_render_interface_type interface_type; | 3176 enum retro_hw_render_interface_type interface_type; |
3177 | |
3178 /** | |
3179 * The version of this rendering interface. | |
3180 * @note This is not related to the version of the API itself. | |
3181 */ | |
1100 unsigned interface_version; | 3182 unsigned interface_version; |
1101 }; | 3183 }; |
1102 | 3184 |
1103 | 3185 /** @} */ |
1104 #define RETRO_ENVIRONMENT_GET_LED_INTERFACE (46 | RETRO_ENVIRONMENT_EXPERIMENTAL) | 3186 |
1105 /* struct retro_led_interface * -- | 3187 /** |
1106 * Gets an interface which is used by a libretro core to set | 3188 * @defgroup GET_LED_INTERFACE LED Interface |
1107 * state of LEDs. | 3189 * @{ |
1108 */ | 3190 */ |
1109 | 3191 |
3192 /** @copydoc retro_led_interface::set_led_state */ | |
1110 typedef void (RETRO_CALLCONV *retro_set_led_state_t)(int led, int state); | 3193 typedef void (RETRO_CALLCONV *retro_set_led_state_t)(int led, int state); |
3194 | |
3195 /** | |
3196 * Interface that the core can use to set the state of available LEDs. | |
3197 * @see RETRO_ENVIRONMENT_GET_LED_INTERFACE | |
3198 */ | |
1111 struct retro_led_interface | 3199 struct retro_led_interface |
1112 { | 3200 { |
1113 retro_set_led_state_t set_led_state; | 3201 /** |
3202 * Sets the state of an LED. | |
3203 * | |
3204 * @param led The LED to set the state of. | |
3205 * @param state The state to set the LED to. | |
3206 * \c true to enable, \c false to disable. | |
3207 */ | |
3208 retro_set_led_state_t set_led_state; | |
1114 }; | 3209 }; |
1115 | 3210 |
1116 | 3211 /** @} */ |
1117 #define RETRO_ENVIRONMENT_GET_HW_RENDER_INTERFACE (41 | RETRO_ENVIRONMENT_EXPERIMENTAL) | 3212 |
1118 /* const struct retro_hw_render_interface ** -- | 3213 /** @defgroup GET_AUDIO_VIDEO_ENABLE Skipped A/V Steps |
1119 * Returns an API specific rendering interface for accessing API specific data. | 3214 * @{ |
1120 * Not all HW rendering APIs support or need this. | 3215 */ |
1121 * The contents of the returned pointer is specific to the rendering API | 3216 |
1122 * being used. See the various headers like libretro_vulkan.h, etc. | 3217 /** |
1123 * | 3218 * Flags that define A/V steps that the core may skip for this frame. |
1124 * GET_HW_RENDER_INTERFACE cannot be called before context_reset has been called. | 3219 * |
1125 * Similarly, after context_destroyed callback returns, | 3220 * @see RETRO_ENVIRONMENT_GET_AUDIO_VIDEO_ENABLE |
1126 * the contents of the HW_RENDER_INTERFACE are invalidated. | 3221 */ |
1127 */ | 3222 enum retro_av_enable_flags |
1128 | 3223 { |
1129 #define RETRO_ENVIRONMENT_SET_SUPPORT_ACHIEVEMENTS (42 | RETRO_ENVIRONMENT_EXPERIMENTAL) | 3224 /** |
1130 /* const bool * -- | 3225 * If set, the core should render video output with \c retro_video_refresh_t as normal. |
1131 * If true, the libretro implementation supports achievements | 3226 * |
1132 * either via memory descriptors set with RETRO_ENVIRONMENT_SET_MEMORY_MAPS | 3227 * Otherwise, the frontend will discard any video data received this frame, |
1133 * or via retro_get_memory_data/retro_get_memory_size. | 3228 * including frames presented via hardware acceleration. |
1134 * | 3229 * \c retro_video_refresh_t will do nothing. |
1135 * This must be called before the first call to retro_run. | 3230 * |
1136 */ | 3231 * @note After running the frame, the video output of the next frame |
1137 | 3232 * should be no different than if video was enabled, |
3233 * and saving and loading state should have no issues. | |
3234 * This implies that the emulated console's graphics pipeline state | |
3235 * should not be affected by this flag. | |
3236 * | |
3237 * @note If emulating a platform that supports display capture | |
3238 * (i.e. reading its own VRAM), | |
3239 * the core may not be able to completely skip rendering, | |
3240 * as the VRAM is part of the graphics pipeline's state. | |
3241 */ | |
3242 RETRO_AV_ENABLE_VIDEO = (1 << 0), | |
3243 | |
3244 /** | |
3245 * If set, the core should render audio output | |
3246 * with \c retro_audio_sample_t or \c retro_audio_sample_batch_t as normal. | |
3247 * | |
3248 * Otherwise, the frontend will discard any audio data received this frame. | |
3249 * The core should skip audio rendering if possible. | |
3250 * | |
3251 * @note After running the frame, the audio output of the next frame | |
3252 * should be no different than if audio was enabled, | |
3253 * and saving and loading state should have no issues. | |
3254 * This implies that the emulated console's audio pipeline state | |
3255 * should not be affected by this flag. | |
3256 */ | |
3257 RETRO_AV_ENABLE_AUDIO = (1 << 1), | |
3258 | |
3259 /** | |
3260 * If set, indicates that any savestates taken this frame | |
3261 * are guaranteed to be created by the same binary that will load them, | |
3262 * and will not be written to or read from the disk. | |
3263 * | |
3264 * The core may use these guarantees to: | |
3265 * | |
3266 * @li Assume that loading state will succeed. | |
3267 * @li Update its memory buffers in-place if possible. | |
3268 * @li Skip clearing memory. | |
3269 * @li Skip resetting the system. | |
3270 * @li Skip validation steps. | |
3271 * | |
3272 * @deprecated Use \c RETRO_ENVIRONMENT_GET_SAVESTATE_CONTEXT instead, | |
3273 * except for compatibility purposes. | |
3274 */ | |
3275 RETRO_AV_ENABLE_FAST_SAVESTATES = (1 << 2), | |
3276 | |
3277 /** | |
3278 * If set, indicates that the frontend will never need audio from the core. | |
3279 * Used by a frontend for implementing runahead via a secondary core instance. | |
3280 * | |
3281 * The core may stop synthesizing audio if it can do so | |
3282 * without compromising emulation accuracy. | |
3283 * | |
3284 * Audio output for the next frame does not matter, | |
3285 * and the frontend will never need an accurate audio state in the future. | |
3286 * | |
3287 * State will never be saved while this flag is set. | |
3288 */ | |
3289 RETRO_AV_ENABLE_HARD_DISABLE_AUDIO = (1 << 3), | |
3290 | |
3291 /** | |
3292 * @private Defined to ensure <tt>sizeof(retro_av_enable_flags) == sizeof(int)</tt>. | |
3293 * Do not use. | |
3294 */ | |
3295 RETRO_AV_ENABLE_DUMMY = INT_MAX | |
3296 }; | |
3297 | |
3298 /** @} */ | |
3299 | |
3300 /** | |
3301 * @defgroup GET_MIDI_INTERFACE MIDI Interface | |
3302 * @{ | |
3303 */ | |
3304 | |
3305 /** @copydoc retro_midi_interface::input_enabled */ | |
3306 typedef bool (RETRO_CALLCONV *retro_midi_input_enabled_t)(void); | |
3307 | |
3308 /** @copydoc retro_midi_interface::output_enabled */ | |
3309 typedef bool (RETRO_CALLCONV *retro_midi_output_enabled_t)(void); | |
3310 | |
3311 /** @copydoc retro_midi_interface::read */ | |
3312 typedef bool (RETRO_CALLCONV *retro_midi_read_t)(uint8_t *byte); | |
3313 | |
3314 /** @copydoc retro_midi_interface::write */ | |
3315 typedef bool (RETRO_CALLCONV *retro_midi_write_t)(uint8_t byte, uint32_t delta_time); | |
3316 | |
3317 /** @copydoc retro_midi_interface::flush */ | |
3318 typedef bool (RETRO_CALLCONV *retro_midi_flush_t)(void); | |
3319 | |
3320 /** | |
3321 * Interface that the core can use for raw MIDI I/O. | |
3322 */ | |
3323 struct retro_midi_interface | |
3324 { | |
3325 /** | |
3326 * Retrieves the current state of MIDI input. | |
3327 * | |
3328 * @return \c true if MIDI input is enabled. | |
3329 */ | |
3330 retro_midi_input_enabled_t input_enabled; | |
3331 | |
3332 /** | |
3333 * Retrieves the current state of MIDI output. | |
3334 * @return \c true if MIDI output is enabled. | |
3335 */ | |
3336 retro_midi_output_enabled_t output_enabled; | |
3337 | |
3338 /** | |
3339 * Reads a byte from the MIDI input stream. | |
3340 * | |
3341 * @param[out] byte The byte received from the input stream. | |
3342 * @return \c true if a byte was read, | |
3343 * \c false if MIDI input is disabled or \c byte is \c NULL. | |
3344 */ | |
3345 retro_midi_read_t read; | |
3346 | |
3347 /** | |
3348 * Writes a byte to the output stream. | |
3349 * | |
3350 * @param byte The byte to write to the output stream. | |
3351 * @param delta_time Time since the previous write, in microseconds. | |
3352 * @return \c true if c\ byte was written, false otherwise. | |
3353 */ | |
3354 retro_midi_write_t write; | |
3355 | |
3356 /** | |
3357 * Flushes previously-written data. | |
3358 * | |
3359 * @return \c true if successful. | |
3360 */ | |
3361 retro_midi_flush_t flush; | |
3362 }; | |
3363 | |
3364 /** @} */ | |
3365 | |
3366 /** @defgroup SET_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE Render Context Negotiation | |
3367 * @{ | |
3368 */ | |
3369 | |
3370 /** | |
3371 * Describes the hardware rendering API used by | |
3372 * a particular subtype of \c retro_hw_render_context_negotiation_interface. | |
3373 * | |
3374 * Not every rendering API supported by libretro has a context negotiation interface, | |
3375 * or even needs one. | |
3376 * | |
3377 * @see RETRO_ENVIRONMENT_SET_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE | |
3378 * @see RETRO_ENVIRONMENT_SET_HW_RENDER | |
3379 * @see RETRO_ENVIRONMENT_GET_HW_RENDER_INTERFACE | |
3380 */ | |
1138 enum retro_hw_render_context_negotiation_interface_type | 3381 enum retro_hw_render_context_negotiation_interface_type |
1139 { | 3382 { |
3383 /** | |
3384 * Denotes a context negotiation interface for Vulkan. | |
3385 * @see retro_hw_render_context_negotiation_interface_vulkan | |
3386 */ | |
1140 RETRO_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE_VULKAN = 0, | 3387 RETRO_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE_VULKAN = 0, |
3388 | |
3389 /** | |
3390 * @private Defined to ensure <tt>sizeof(retro_hw_render_context_negotiation_interface_type) == sizeof(int)</tt>. | |
3391 * Do not use. | |
3392 */ | |
1141 RETRO_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE_DUMMY = INT_MAX | 3393 RETRO_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE_DUMMY = INT_MAX |
1142 }; | 3394 }; |
1143 | 3395 |
1144 /* Base struct. All retro_hw_render_context_negotiation_interface_* types | 3396 /** |
1145 * contain at least these fields. */ | 3397 * Base context negotiation interface type. |
3398 * All \c retro_hw_render_context_negotiation_interface implementations | |
3399 * will start with these two fields set to particular values. | |
3400 * | |
3401 * @see retro_hw_render_interface_type | |
3402 * @see RETRO_ENVIRONMENT_SET_HW_RENDER | |
3403 * @see RETRO_ENVIRONMENT_GET_HW_RENDER_INTERFACE | |
3404 * @see RETRO_ENVIRONMENT_SET_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE | |
3405 */ | |
1146 struct retro_hw_render_context_negotiation_interface | 3406 struct retro_hw_render_context_negotiation_interface |
1147 { | 3407 { |
3408 /** | |
3409 * Denotes the particular rendering API that this interface is for. | |
3410 * Each interface requires this field to be set to a particular value. | |
3411 * Use it to cast this interface to the appropriate pointer. | |
3412 */ | |
1148 enum retro_hw_render_context_negotiation_interface_type interface_type; | 3413 enum retro_hw_render_context_negotiation_interface_type interface_type; |
3414 | |
3415 /** | |
3416 * The version of this negotiation interface. | |
3417 * @note This is not related to the version of the API itself. | |
3418 */ | |
1149 unsigned interface_version; | 3419 unsigned interface_version; |
1150 }; | 3420 }; |
1151 #define RETRO_ENVIRONMENT_SET_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE (43 | RETRO_ENVIRONMENT_EXPERIMENTAL) | 3421 |
1152 /* const struct retro_hw_render_context_negotiation_interface * -- | 3422 /** @} */ |
1153 * Sets an interface which lets the libretro core negotiate with frontend how a context is created. | 3423 |
1154 * The semantics of this interface depends on which API is used in SET_HW_RENDER earlier. | 3424 /** @defgroup RETRO_SERIALIZATION_QUIRK Serialization Quirks |
1155 * This interface will be used when the frontend is trying to create a HW rendering context, | 3425 * @{ |
1156 * so it will be used after SET_HW_RENDER, but before the context_reset callback. | 3426 */ |
1157 */ | 3427 |
1158 | 3428 /** |
1159 /* Serialized state is incomplete in some way. Set if serialization is | 3429 * Indicates that serialized state is incomplete in some way. |
1160 * usable in typical end-user cases but should not be relied upon to | 3430 * |
1161 * implement frame-sensitive frontend features such as netplay or | 3431 * Set if serialization is usable for the common case of saving and loading game state, |
1162 * rerecording. */ | 3432 * but should not be relied upon for frame-sensitive frontend features |
3433 * such as netplay or rerecording. | |
3434 */ | |
1163 #define RETRO_SERIALIZATION_QUIRK_INCOMPLETE (1 << 0) | 3435 #define RETRO_SERIALIZATION_QUIRK_INCOMPLETE (1 << 0) |
1164 /* The core must spend some time initializing before serialization is | 3436 |
1165 * supported. retro_serialize() will initially fail; retro_unserialize() | 3437 /** |
1166 * and retro_serialize_size() may or may not work correctly either. */ | 3438 * Indicates that core must spend some time initializing before serialization can be done. |
3439 * | |
3440 * \c retro_serialize(), \c retro_unserialize(), and \c retro_serialize_size() will initially fail. | |
3441 */ | |
1167 #define RETRO_SERIALIZATION_QUIRK_MUST_INITIALIZE (1 << 1) | 3442 #define RETRO_SERIALIZATION_QUIRK_MUST_INITIALIZE (1 << 1) |
1168 /* Serialization size may change within a session. */ | 3443 |
3444 /** Set by the core to indicate that serialization size may change within a session. */ | |
1169 #define RETRO_SERIALIZATION_QUIRK_CORE_VARIABLE_SIZE (1 << 2) | 3445 #define RETRO_SERIALIZATION_QUIRK_CORE_VARIABLE_SIZE (1 << 2) |
1170 /* Set by the frontend to acknowledge that it supports variable-sized | 3446 |
1171 * states. */ | 3447 /** Set by the frontend to acknowledge that it supports variable-sized states. */ |
1172 #define RETRO_SERIALIZATION_QUIRK_FRONT_VARIABLE_SIZE (1 << 3) | 3448 #define RETRO_SERIALIZATION_QUIRK_FRONT_VARIABLE_SIZE (1 << 3) |
1173 /* Serialized state can only be loaded during the same session. */ | 3449 |
3450 /** Serialized state can only be loaded during the same session. */ | |
1174 #define RETRO_SERIALIZATION_QUIRK_SINGLE_SESSION (1 << 4) | 3451 #define RETRO_SERIALIZATION_QUIRK_SINGLE_SESSION (1 << 4) |
1175 /* Serialized state cannot be loaded on an architecture with a different | 3452 |
1176 * endianness from the one it was saved on. */ | 3453 /** |
3454 * Serialized state cannot be loaded on an architecture | |
3455 * with a different endianness from the one it was saved on. | |
3456 */ | |
1177 #define RETRO_SERIALIZATION_QUIRK_ENDIAN_DEPENDENT (1 << 5) | 3457 #define RETRO_SERIALIZATION_QUIRK_ENDIAN_DEPENDENT (1 << 5) |
1178 /* Serialized state cannot be loaded on a different platform from the one it | 3458 |
1179 * was saved on for reasons other than endianness, such as word size | 3459 /** |
1180 * dependence */ | 3460 * Serialized state cannot be loaded on a different platform |
3461 * from the one it was saved on for reasons other than endianness, | |
3462 * such as word size dependence. | |
3463 */ | |
1181 #define RETRO_SERIALIZATION_QUIRK_PLATFORM_DEPENDENT (1 << 6) | 3464 #define RETRO_SERIALIZATION_QUIRK_PLATFORM_DEPENDENT (1 << 6) |
1182 | 3465 |
1183 #define RETRO_ENVIRONMENT_SET_SERIALIZATION_QUIRKS 44 | 3466 /** @} */ |
1184 /* uint64_t * -- | 3467 |
1185 * Sets quirk flags associated with serialization. The frontend will zero any flags it doesn't | 3468 /** @defgroup SET_MEMORY_MAPS Memory Descriptors |
1186 * recognize or support. Should be set in either retro_init or retro_load_game, but not both. | 3469 * @{ |
1187 */ | 3470 */ |
1188 | 3471 |
1189 #define RETRO_MEMDESC_CONST (1 << 0) /* The frontend will never change this memory area once retro_load_game has returned. */ | 3472 /** @defgroup RETRO_MEMDESC Memory Descriptor Flags |
1190 #define RETRO_MEMDESC_BIGENDIAN (1 << 1) /* The memory area contains big endian data. Default is little endian. */ | 3473 * Information about how the emulated hardware uses this portion of its address space. |
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. */ | 3474 * @{ |
1192 #define RETRO_MEMDESC_ALIGN_4 (2 << 16) | 3475 */ |
1193 #define RETRO_MEMDESC_ALIGN_8 (3 << 16) | 3476 |
1194 #define RETRO_MEMDESC_MINSIZE_2 (1 << 24) /* All memory in this region is accessed at least 2 bytes at the time. */ | 3477 /** |
1195 #define RETRO_MEMDESC_MINSIZE_4 (2 << 24) | 3478 * Indicates that this memory area won't be modified |
1196 #define RETRO_MEMDESC_MINSIZE_8 (3 << 24) | 3479 * once \c retro_load_game has returned. |
3480 */ | |
3481 #define RETRO_MEMDESC_CONST (1 << 0) | |
3482 | |
3483 /** | |
3484 * Indicates a memory area with big-endian byte ordering, | |
3485 * as opposed to the default of little-endian. | |
3486 */ | |
3487 #define RETRO_MEMDESC_BIGENDIAN (1 << 1) | |
3488 | |
3489 /** | |
3490 * Indicates a memory area that is used for the emulated system's main RAM. | |
3491 */ | |
3492 #define RETRO_MEMDESC_SYSTEM_RAM (1 << 2) | |
3493 | |
3494 /** | |
3495 * Indicates a memory area that is used for the emulated system's save RAM, | |
3496 * usually found on a game cartridge as battery-backed RAM or flash memory. | |
3497 */ | |
3498 #define RETRO_MEMDESC_SAVE_RAM (1 << 3) | |
3499 | |
3500 /** | |
3501 * Indicates a memory area that is used for the emulated system's video RAM, | |
3502 * usually found on a console's GPU (or local equivalent). | |
3503 */ | |
3504 #define RETRO_MEMDESC_VIDEO_RAM (1 << 4) | |
3505 | |
3506 /** | |
3507 * Indicates a memory area that requires all accesses | |
3508 * to be aligned to 2 bytes or their own size | |
3509 * (whichever is smaller). | |
3510 */ | |
3511 #define RETRO_MEMDESC_ALIGN_2 (1 << 16) | |
3512 | |
3513 /** | |
3514 * Indicates a memory area that requires all accesses | |
3515 * to be aligned to 4 bytes or their own size | |
3516 * (whichever is smaller). | |
3517 */ | |
3518 #define RETRO_MEMDESC_ALIGN_4 (2 << 16) | |
3519 | |
3520 /** | |
3521 * Indicates a memory area that requires all accesses | |
3522 * to be aligned to 8 bytes or their own size | |
3523 * (whichever is smaller). | |
3524 */ | |
3525 #define RETRO_MEMDESC_ALIGN_8 (3 << 16) | |
3526 | |
3527 /** | |
3528 * Indicates a memory area that requires all accesses | |
3529 * to be at least 2 bytes long. | |
3530 */ | |
3531 #define RETRO_MEMDESC_MINSIZE_2 (1 << 24) | |
3532 | |
3533 /** | |
3534 * Indicates a memory area that requires all accesses | |
3535 * to be at least 4 bytes long. | |
3536 */ | |
3537 #define RETRO_MEMDESC_MINSIZE_4 (2 << 24) | |
3538 | |
3539 /** | |
3540 * Indicates a memory area that requires all accesses | |
3541 * to be at least 8 bytes long. | |
3542 */ | |
3543 #define RETRO_MEMDESC_MINSIZE_8 (3 << 24) | |
3544 | |
3545 /** @} */ | |
3546 | |
3547 /** | |
3548 * A mapping from a region of the emulated console's address space | |
3549 * to the host's address space. | |
3550 * | |
3551 * Can be used to map an address in the console's address space | |
3552 * to the host's address space, like so: | |
3553 * | |
3554 * @code | |
3555 * void* emu_to_host(void* addr, struct retro_memory_descriptor* descriptor) | |
3556 * { | |
3557 * return descriptor->ptr + (addr & ~descriptor->disconnect) - descriptor->start; | |
3558 * } | |
3559 * @endcode | |
3560 * | |
3561 * @see RETRO_ENVIRONMENT_SET_MEMORY_MAPS | |
3562 */ | |
1197 struct retro_memory_descriptor | 3563 struct retro_memory_descriptor |
1198 { | 3564 { |
3565 /** | |
3566 * A bitwise \c OR of one or more \ref RETRO_MEMDESC "flags" | |
3567 * that describe how the emulated system uses this descriptor's address range. | |
3568 * | |
3569 * @note If \c ptr is \c NULL, | |
3570 * then no flags should be set. | |
3571 * @see RETRO_MEMDESC | |
3572 */ | |
1199 uint64_t flags; | 3573 uint64_t flags; |
1200 | 3574 |
1201 /* Pointer to the start of the relevant ROM or RAM chip. | 3575 /** |
1202 * It's strongly recommended to use 'offset' if possible, rather than | 3576 * Pointer to the start of this memory region's buffer |
1203 * doing math on the pointer. | 3577 * within the \em host's address space. |
1204 * | 3578 * The address listed here must be valid for the duration of the session; |
1205 * If the same byte is mapped my multiple descriptors, their descriptors | 3579 * it must not be freed or modified by the frontend |
1206 * must have the same pointer. | 3580 * and it must not be moved by the core. |
1207 * If 'start' does not point to the first byte in the pointer, put the | 3581 * |
1208 * difference in 'offset' instead. | 3582 * May be \c NULL to indicate a lack of accessible memory |
1209 * | 3583 * at the emulated address given in \c start. |
1210 * May be NULL if there's nothing usable here (e.g. hardware registers and | 3584 * |
1211 * open bus). No flags should be set if the pointer is NULL. | 3585 * @note Overlapping descriptors that include the same byte |
1212 * It's recommended to minimize the number of descriptors if possible, | 3586 * must have the same \c ptr value. |
1213 * but not mandatory. */ | 3587 */ |
1214 void *ptr; | 3588 void *ptr; |
3589 | |
3590 /** | |
3591 * The offset of this memory region, | |
3592 * relative to the address given by \c ptr. | |
3593 * | |
3594 * @note It is recommended to use this field for address calculations | |
3595 * instead of performing arithmetic on \c ptr. | |
3596 */ | |
1215 size_t offset; | 3597 size_t offset; |
1216 | 3598 |
1217 /* This is the location in the emulated address space | 3599 /** |
1218 * where the mapping starts. */ | 3600 * The starting address of this memory region |
3601 * <em>within the emulated hardware's address space</em>. | |
3602 * | |
3603 * @note Not represented as a pointer | |
3604 * because it's unlikely to be valid on the host device. | |
3605 */ | |
1219 size_t start; | 3606 size_t start; |
1220 | 3607 |
1221 /* Which bits must be same as in 'start' for this mapping to apply. | 3608 /** |
1222 * The first memory descriptor to claim a certain byte is the one | 3609 * A bitmask that specifies which bits of an address must match |
1223 * that applies. | 3610 * the bits of the \ref start address. |
1224 * A bit which is set in 'start' must also be set in this. | 3611 * |
1225 * Can be zero, in which case each byte is assumed mapped exactly once. | 3612 * Combines with \c disconnect to map an address to a memory block. |
1226 * In this case, 'len' must be a power of two. */ | 3613 * |
3614 * If multiple memory descriptors can claim a particular byte, | |
3615 * the first one defined in the \ref retro_memory_descriptor array applies. | |
3616 * A bit which is set in \c start must also be set in this. | |
3617 * | |
3618 * Can be zero, in which case \c start and \c len represent | |
3619 * the complete mapping for this region of memory | |
3620 * (i.e. each byte is mapped exactly once). | |
3621 * In this case, \c len must be a power of two. | |
3622 */ | |
1227 size_t select; | 3623 size_t select; |
1228 | 3624 |
1229 /* If this is nonzero, the set bits are assumed not connected to the | 3625 /** |
1230 * memory chip's address pins. */ | 3626 * A bitmask of bits that are \em not used for addressing. |
3627 * | |
3628 * Any set bits are assumed to be disconnected from | |
3629 * the emulated memory chip's address pins, | |
3630 * and are therefore ignored when memory-mapping. | |
3631 */ | |
1231 size_t disconnect; | 3632 size_t disconnect; |
1232 | 3633 |
1233 /* This one tells the size of the current memory area. | 3634 /** |
1234 * If, after start+disconnect are applied, the address is higher than | 3635 * The length of this memory region, in bytes. |
1235 * this, the highest bit of the address is cleared. | 3636 * |
3637 * If applying \ref start and \ref disconnect to an address | |
3638 * results in a value higher than this, | |
3639 * the highest bit of the address is cleared. | |
1236 * | 3640 * |
1237 * If the address is still too high, the next highest bit is cleared. | 3641 * 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 | 3642 * Can be zero, in which case it's assumed to be |
1239 * by 'select' and 'disconnect'). */ | 3643 * bounded only by \ref select and \ref disconnect. |
3644 */ | |
1240 size_t len; | 3645 size_t len; |
1241 | 3646 |
1242 /* To go from emulated address to physical address, the following | 3647 /** |
1243 * order applies: | 3648 * A short name for this address space. |
1244 * Subtract 'start', pick off 'disconnect', apply 'len', add 'offset'. */ | 3649 * |
1245 | 3650 * Names must meet the following requirements: |
1246 /* The address space name must consist of only a-zA-Z0-9_-, | 3651 * |
1247 * should be as short as feasible (maximum length is 8 plus the NUL), | 3652 * \li Characters must be in the set <tt>[a-zA-Z0-9_-]</tt>. |
1248 * and may not be any other address space plus one or more 0-9A-F | 3653 * \li No more than 8 characters, plus a \c NULL terminator. |
1249 * at the end. | 3654 * \li Names are case-sensitive, but lowercase characters are discouraged. |
1250 * However, multiple memory descriptors for the same address space is | 3655 * \li A name must not be the same as another name plus a character in the set \c [A-F0-9] |
1251 * allowed, and the address space name can be empty. NULL is treated | 3656 * (i.e. if an address space named "RAM" exists, |
1252 * as empty. | 3657 * then the names "RAM0", "RAM1", ..., "RAMF" are forbidden). |
1253 * | 3658 * This is to allow addresses to be named by each descriptor unambiguously, |
1254 * Address space names are case sensitive, but avoid lowercase if possible. | 3659 * even if the areas overlap. |
1255 * The same pointer may exist in multiple address spaces. | 3660 * \li May be \c NULL or empty (both are considered equivalent). |
1256 * | 3661 * |
1257 * Examples: | 3662 * Here are some examples of pairs of address space names: |
1258 * blank+blank - valid (multiple things may be mapped in the same namespace) | 3663 * |
1259 * 'Sp'+'Sp' - valid (multiple things may be mapped in the same namespace) | 3664 * \li \em blank + \em blank: valid (multiple things may be mapped in the same namespace) |
1260 * 'A'+'B' - valid (neither is a prefix of each other) | 3665 * \li \c Sp + \c Sp: valid (multiple things may be mapped in the same namespace) |
1261 * 'S'+blank - valid ('S' is not in 0-9A-F) | 3666 * \li \c SRAM + \c VRAM: valid (neither is a prefix of the other) |
1262 * 'a'+blank - valid ('a' is not in 0-9A-F) | 3667 * \li \c V + \em blank: valid (\c V is not in \c [A-F0-9]) |
1263 * 'a'+'A' - valid (neither is a prefix of each other) | 3668 * \li \c a + \em blank: valid but discouraged (\c a is not in \c [A-F0-9]) |
1264 * 'AR'+blank - valid ('R' is not in 0-9A-F) | 3669 * \li \c a + \c A: valid but discouraged (neither is a prefix of the other) |
1265 * 'ARB'+blank - valid (the B can't be part of the address either, because | 3670 * \li \c AR + \em blank: valid (\c R is not in \c [A-F0-9]) |
1266 * there is no namespace 'AR') | 3671 * \li \c ARB + \em blank: valid (there's no \c AR namespace, |
1267 * blank+'B' - not valid, because it's ambigous which address space B1234 | 3672 * so the \c B doesn't cause ambiguity). |
1268 * would refer to. | 3673 * \li \em blank + \c B: invalid, because it's ambiguous which address space \c B1234 would refer to. |
1269 * The length can't be used for that purpose; the frontend may want | 3674 * |
1270 * to append arbitrary data to an address, without a separator. */ | 3675 * The length of the address space's name can't be used to disambugiate, |
3676 * as extra information may be appended to it without a separator. | |
3677 */ | |
1271 const char *addrspace; | 3678 const char *addrspace; |
1272 | 3679 |
1273 /* TODO: When finalizing this one, add a description field, which should be | 3680 /* TODO: When finalizing this one, add a description field, which should be |
1274 * "WRAM" or something roughly equally long. */ | 3681 * "WRAM" or something roughly equally long. */ |
1275 | 3682 |
1300 | 3707 |
1301 /* TODO: Some of those flags are unused and/or don't really make sense. Clean | 3708 /* TODO: Some of those flags are unused and/or don't really make sense. Clean |
1302 * them up. */ | 3709 * them up. */ |
1303 }; | 3710 }; |
1304 | 3711 |
1305 /* The frontend may use the largest value of 'start'+'select' in a | 3712 /** |
1306 * certain namespace to infer the size of the address space. | 3713 * A list of regions within the emulated console's address space. |
1307 * | 3714 * |
1308 * If the address space is larger than that, a mapping with .ptr=NULL | 3715 * The frontend may use the largest value of |
1309 * should be at the end of the array, with .select set to all ones for | 3716 * \ref retro_memory_descriptor::start + \ref retro_memory_descriptor::select |
1310 * as long as the address space is big. | 3717 * in a certain namespace to infer the overall size of the address space. |
1311 * | 3718 * If the address space is larger than that, |
1312 * Sample descriptors (minus .ptr, and RETRO_MEMFLAG_ on the flags): | 3719 * the last mapping in \ref descriptors should have \ref retro_memory_descriptor::ptr set to \c NULL |
1313 * SNES WRAM: | 3720 * and \ref retro_memory_descriptor::select should have all bits used in the address space set to 1. |
1314 * .start=0x7E0000, .len=0x20000 | 3721 * |
1315 * (Note that this must be mapped before the ROM in most cases; some of the | 3722 * Here's an example set of descriptors for the SNES. |
1316 * ROM mappers | 3723 * |
1317 * try to claim $7E0000, or at least $7E8000.) | 3724 * @code{.c} |
1318 * SNES SPC700 RAM: | 3725 * struct retro_memory_map snes_descriptors = retro_memory_map |
1319 * .addrspace="S", .len=0x10000 | 3726 * { |
1320 * SNES WRAM mirrors: | 3727 * .descriptors = (struct retro_memory_descriptor[]) |
1321 * .flags=MIRROR, .start=0x000000, .select=0xC0E000, .len=0x2000 | 3728 * { |
1322 * .flags=MIRROR, .start=0x800000, .select=0xC0E000, .len=0x2000 | 3729 * // WRAM; must usually be mapped before the ROM, |
1323 * SNES WRAM mirrors, alternate equivalent descriptor: | 3730 * // as some SNES ROM mappers try to claim 0x7E0000 |
1324 * .flags=MIRROR, .select=0x40E000, .disconnect=~0x1FFF | 3731 * { .addrspace="WRAM", .start=0x7E0000, .len=0x20000 }, |
1325 * (Various similar constructions can be created by combining parts of | 3732 * |
1326 * the above two.) | 3733 * // SPC700 RAM |
1327 * SNES LoROM (512KB, mirrored a couple of times): | 3734 * { .addrspace="SPC700", .len=0x10000 }, |
1328 * .flags=CONST, .start=0x008000, .select=0x408000, .disconnect=0x8000, .len=512*1024 | 3735 * |
1329 * .flags=CONST, .start=0x400000, .select=0x400000, .disconnect=0x8000, .len=512*1024 | 3736 * // WRAM mirrors |
1330 * SNES HiROM (4MB): | 3737 * { .addrspace="WRAM", .start=0x000000, .select=0xC0E000, .len=0x2000 }, |
1331 * .flags=CONST, .start=0x400000, .select=0x400000, .len=4*1024*1024 | 3738 * { .addrspace="WRAM", .start=0x800000, .select=0xC0E000, .len=0x2000 }, |
1332 * .flags=CONST, .offset=0x8000, .start=0x008000, .select=0x408000, .len=4*1024*1024 | 3739 * |
1333 * SNES ExHiROM (8MB): | 3740 * // WRAM mirror, alternate equivalent descriptor |
1334 * .flags=CONST, .offset=0, .start=0xC00000, .select=0xC00000, .len=4*1024*1024 | 3741 * // (Various similar constructions can be created by combining parts of the above two.) |
1335 * .flags=CONST, .offset=4*1024*1024, .start=0x400000, .select=0xC00000, .len=4*1024*1024 | 3742 * { .addrspace="WRAM", .select=0x40E000, .disconnect=~0x1FFF }, |
1336 * .flags=CONST, .offset=0x8000, .start=0x808000, .select=0xC08000, .len=4*1024*1024 | 3743 * |
1337 * .flags=CONST, .offset=4*1024*1024+0x8000, .start=0x008000, .select=0xC08000, .len=4*1024*1024 | 3744 * // LoROM (512KB, mirrored a couple of times) |
1338 * Clarify the size of the address space: | 3745 * { .addrspace="LoROM", .start=0x008000, .select=0x408000, .disconnect=0x8000, .len=512*1024, .flags=RETRO_MEMDESC_CONST }, |
1339 * .ptr=NULL, .select=0xFFFFFF | 3746 * { .addrspace="LoROM", .start=0x400000, .select=0x400000, .disconnect=0x8000, .len=512*1024, .flags=RETRO_MEMDESC_CONST }, |
1340 * .len can be implied by .select in many of them, but was included for clarity. | 3747 * |
1341 */ | 3748 * // HiROM (4MB) |
1342 | 3749 * { .addrspace="HiROM", .start=0x400000, .select=0x400000, .len=4*1024*1024, .flags=RETRO_MEMDESC_CONST }, |
3750 * { .addrspace="HiROM", .start=0x008000, .select=0x408000, .len=4*1024*1024, .offset=0x8000, .flags=RETRO_MEMDESC_CONST }, | |
3751 * | |
3752 * // ExHiROM (8MB) | |
3753 * { .addrspace="ExHiROM", .start=0xC00000, .select=0xC00000, .len=4*1024*1024, .offset=0, .flags=RETRO_MEMDESC_CONST }, | |
3754 * { .addrspace="ExHiROM", .start=0x400000, .select=0xC00000, .len=4*1024*1024, .offset=4*1024*1024, .flags=RETRO_MEMDESC_CONST }, | |
3755 * { .addrspace="ExHiROM", .start=0x808000, .select=0xC08000, .len=4*1024*1024, .offset=0x8000, .flags=RETRO_MEMDESC_CONST }, | |
3756 * { .addrspace="ExHiROM", .start=0x008000, .select=0xC08000, .len=4*1024*1024, .offset=4*1024*1024+0x8000, .flags=RETRO_MEMDESC_CONST }, | |
3757 * | |
3758 * // Clarifying the full size of the address space | |
3759 * { .select=0xFFFFFF, .ptr=NULL }, | |
3760 * }, | |
3761 * .num_descriptors = 14, | |
3762 * }; | |
3763 * @endcode | |
3764 * | |
3765 * @see RETRO_ENVIRONMENT_SET_MEMORY_MAPS | |
3766 */ | |
1343 struct retro_memory_map | 3767 struct retro_memory_map |
1344 { | 3768 { |
3769 /** | |
3770 * Pointer to an array of memory descriptors, | |
3771 * each of which describes part of the emulated console's address space. | |
3772 */ | |
1345 const struct retro_memory_descriptor *descriptors; | 3773 const struct retro_memory_descriptor *descriptors; |
3774 | |
3775 /** The number of descriptors in \c descriptors. */ | |
1346 unsigned num_descriptors; | 3776 unsigned num_descriptors; |
1347 }; | 3777 }; |
1348 | 3778 |
3779 /** @} */ | |
3780 | |
3781 /** @defgroup SET_CONTROLLER_INFO Controller Info | |
3782 * @{ | |
3783 */ | |
3784 | |
3785 /** | |
3786 * Details about a controller (or controller configuration) | |
3787 * supported by one of a core's emulated input ports. | |
3788 * | |
3789 * @see RETRO_ENVIRONMENT_SET_CONTROLLER_INFO | |
3790 */ | |
1349 struct retro_controller_description | 3791 struct retro_controller_description |
1350 { | 3792 { |
1351 /* Human-readable description of the controller. Even if using a generic | 3793 /** |
1352 * input device type, this can be set to the particular device type the | 3794 * A human-readable label for the controller or configuration |
1353 * core uses. */ | 3795 * represented by this device type. |
3796 * Most likely the device's original brand name. | |
3797 */ | |
1354 const char *desc; | 3798 const char *desc; |
1355 | 3799 |
1356 /* Device type passed to retro_set_controller_port_device(). If the device | 3800 /** |
1357 * type is a sub-class of a generic input device type, use the | 3801 * A unique identifier that will be passed to \c retro_set_controller_port_device()'s \c device parameter. |
1358 * RETRO_DEVICE_SUBCLASS macro to create an ID. | 3802 * May be the ID of one of \ref RETRO_DEVICE "the generic controller types", |
1359 * | 3803 * or a subclass ID defined with \c RETRO_DEVICE_SUBCLASS. |
1360 * E.g. RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 1). */ | 3804 * |
3805 * @see RETRO_DEVICE_SUBCLASS | |
3806 */ | |
1361 unsigned id; | 3807 unsigned id; |
1362 }; | 3808 }; |
1363 | 3809 |
3810 /** | |
3811 * Lists the types of controllers supported by | |
3812 * one of core's emulated input ports. | |
3813 * | |
3814 * @see RETRO_ENVIRONMENT_SET_CONTROLLER_INFO | |
3815 */ | |
1364 struct retro_controller_info | 3816 struct retro_controller_info |
1365 { | 3817 { |
3818 | |
3819 /** | |
3820 * A pointer to an array of device types supported by this controller port. | |
3821 * | |
3822 * @note Ports that support the same devices | |
3823 * may share the same underlying array. | |
3824 */ | |
1366 const struct retro_controller_description *types; | 3825 const struct retro_controller_description *types; |
3826 | |
3827 /** The number of elements in \c types. */ | |
1367 unsigned num_types; | 3828 unsigned num_types; |
1368 }; | 3829 }; |
1369 | 3830 |
3831 /** @} */ | |
3832 | |
3833 /** @defgroup SET_SUBSYSTEM_INFO Subsystems | |
3834 * @{ | |
3835 */ | |
3836 | |
3837 /** | |
3838 * Information about a type of memory associated with a subsystem. | |
3839 * Usually used for SRAM (save RAM). | |
3840 * | |
3841 * @see RETRO_ENVIRONMENT_SET_SUBSYSTEM_INFO | |
3842 * @see retro_get_memory_data | |
3843 * @see retro_get_memory_size | |
3844 */ | |
1370 struct retro_subsystem_memory_info | 3845 struct retro_subsystem_memory_info |
1371 { | 3846 { |
1372 /* The extension associated with a memory type, e.g. "psram". */ | 3847 /** |
3848 * The file extension the frontend should use | |
3849 * to save this memory region to disk, e.g. "srm" or "sav". | |
3850 */ | |
1373 const char *extension; | 3851 const char *extension; |
1374 | 3852 |
1375 /* The memory type for retro_get_memory(). This should be at | 3853 /** |
1376 * least 0x100 to avoid conflict with standardized | 3854 * A constant that identifies this type of memory. |
1377 * libretro memory types. */ | 3855 * Should be at least 0x100 (256) to avoid conflict |
3856 * with the standard libretro memory types, | |
3857 * unless a subsystem uses the main platform's memory region. | |
3858 * @see RETRO_MEMORY | |
3859 */ | |
1378 unsigned type; | 3860 unsigned type; |
1379 }; | 3861 }; |
1380 | 3862 |
3863 /** | |
3864 * Information about a type of ROM that a subsystem may use. | |
3865 * Subsystems may use one or more ROMs at once, | |
3866 * possibly of different types. | |
3867 * | |
3868 * @see RETRO_ENVIRONMENT_SET_SUBSYSTEM_INFO | |
3869 * @see retro_subsystem_info | |
3870 */ | |
1381 struct retro_subsystem_rom_info | 3871 struct retro_subsystem_rom_info |
1382 { | 3872 { |
1383 /* Describes what the content is (SGB BIOS, GB ROM, etc). */ | 3873 /** |
3874 * Human-readable description of what the content represents, | |
3875 * e.g. "Game Boy ROM". | |
3876 */ | |
1384 const char *desc; | 3877 const char *desc; |
1385 | 3878 |
1386 /* Same definition as retro_get_system_info(). */ | 3879 /** @copydoc retro_system_info::valid_extensions */ |
1387 const char *valid_extensions; | 3880 const char *valid_extensions; |
1388 | 3881 |
1389 /* Same definition as retro_get_system_info(). */ | 3882 /** @copydoc retro_system_info::need_fullpath */ |
1390 bool need_fullpath; | 3883 bool need_fullpath; |
1391 | 3884 |
1392 /* Same definition as retro_get_system_info(). */ | 3885 /** @copydoc retro_system_info::block_extract */ |
1393 bool block_extract; | 3886 bool block_extract; |
1394 | 3887 |
1395 /* This is set if the content is required to load a game. | 3888 /** |
1396 * If this is set to false, a zeroed-out retro_game_info can be passed. */ | 3889 * Indicates whether this particular subsystem ROM is required. |
3890 * If \c true and the user doesn't provide a ROM, | |
3891 * the frontend should not load the core. | |
3892 * If \c false and the user doesn't provide a ROM, | |
3893 * the frontend should pass a zeroed-out \c retro_game_info | |
3894 * to the corresponding entry in \c retro_load_game_special(). | |
3895 */ | |
1397 bool required; | 3896 bool required; |
1398 | 3897 |
1399 /* Content can have multiple associated persistent | 3898 /** |
1400 * memory types (retro_get_memory()). */ | 3899 * Pointer to an array of memory descriptors that this subsystem ROM type uses. |
3900 * Useful for secondary cartridges that have their own save data. | |
3901 * May be \c NULL, in which case this subsystem ROM's memory is not persisted by the frontend | |
3902 * and \c num_memory should be zero. | |
3903 */ | |
1401 const struct retro_subsystem_memory_info *memory; | 3904 const struct retro_subsystem_memory_info *memory; |
3905 | |
3906 /** The number of elements in the array pointed to by \c memory. */ | |
1402 unsigned num_memory; | 3907 unsigned num_memory; |
1403 }; | 3908 }; |
1404 | 3909 |
3910 /** | |
3911 * Information about a secondary platform that a core supports. | |
3912 * @see RETRO_ENVIRONMENT_SET_SUBSYSTEM_INFO | |
3913 */ | |
1405 struct retro_subsystem_info | 3914 struct retro_subsystem_info |
1406 { | 3915 { |
1407 /* Human-readable string of the subsystem type, e.g. "Super GameBoy" */ | 3916 /** |
3917 * A human-readable description of the subsystem type, | |
3918 * usually the brand name of the original platform | |
3919 * (e.g. "Super Game Boy"). | |
3920 */ | |
1408 const char *desc; | 3921 const char *desc; |
1409 | 3922 |
1410 /* A computer friendly short string identifier for the subsystem type. | 3923 /** |
1411 * This name must be [a-z]. | 3924 * A short machine-friendly identifier for the subsystem, |
1412 * E.g. if desc is "Super GameBoy", this can be "sgb". | 3925 * usually an abbreviation of the platform name. |
1413 * This identifier can be used for command-line interfaces, etc. | 3926 * For example, a Super Game Boy subsystem for a SNES core |
3927 * might use an identifier of "sgb". | |
3928 * This identifier can be used for command-line interfaces, | |
3929 * configuration, or other purposes. | |
3930 * Must use lower-case alphabetical characters only (i.e. from a-z). | |
1414 */ | 3931 */ |
1415 const char *ident; | 3932 const char *ident; |
1416 | 3933 |
1417 /* Infos for each content file. The first entry is assumed to be the | 3934 /** |
1418 * "most significant" content for frontend purposes. | 3935 * The list of ROM types that this subsystem may use. |
3936 * | |
3937 * The first entry is considered to be the "most significant" content, | |
3938 * for the purposes of the frontend's categorization. | |
1419 * E.g. with Super GameBoy, the first content should be the GameBoy ROM, | 3939 * E.g. with Super GameBoy, the first content should be the GameBoy ROM, |
1420 * as it is the most "significant" content to a user. | 3940 * as it is the most "significant" content to a user. |
1421 * If a frontend creates new file paths based on the content used | 3941 * |
1422 * (e.g. savestates), it should use the path for the first ROM to do so. */ | 3942 * If a frontend creates new files based on the content used (e.g. for savestates), |
3943 * it should derive the filenames from the name of the first ROM in this list. | |
3944 * | |
3945 * @note \c roms can have a single element, | |
3946 * but this is usually a sign that the core should broaden its | |
3947 * primary system info instead. | |
3948 * | |
3949 * @see \c retro_system_info | |
3950 */ | |
1423 const struct retro_subsystem_rom_info *roms; | 3951 const struct retro_subsystem_rom_info *roms; |
1424 | 3952 |
1425 /* Number of content files associated with a subsystem. */ | 3953 /** The length of the array given in \c roms. */ |
1426 unsigned num_roms; | 3954 unsigned num_roms; |
1427 | 3955 |
1428 /* The type passed to retro_load_game_special(). */ | 3956 /** A unique identifier passed to retro_load_game_special(). */ |
1429 unsigned id; | 3957 unsigned id; |
1430 }; | 3958 }; |
1431 | 3959 |
3960 /** @} */ | |
3961 | |
3962 /** @defgroup SET_PROC_ADDRESS_CALLBACK Core Function Pointers | |
3963 * @{ */ | |
3964 | |
3965 /** | |
3966 * The function pointer type that \c retro_get_proc_address_t returns. | |
3967 * | |
3968 * Despite the signature shown here, the original function may include any parameters and return type | |
3969 * that respects the calling convention and C ABI. | |
3970 * | |
3971 * The frontend is expected to cast the function pointer to the correct type. | |
3972 */ | |
1432 typedef void (RETRO_CALLCONV *retro_proc_address_t)(void); | 3973 typedef void (RETRO_CALLCONV *retro_proc_address_t)(void); |
1433 | 3974 |
1434 /* libretro API extension functions: | 3975 /** |
1435 * (None here so far). | |
1436 * | |
1437 * Get a symbol from a libretro core. | 3976 * Get a symbol from a libretro core. |
1438 * Cores should only return symbols which are actual | 3977 * |
1439 * extensions to the libretro API. | 3978 * Cores should only return symbols that serve as libretro extensions. |
1440 * | 3979 * Frontends should not use this to obtain symbols to standard libretro entry points; |
1441 * Frontends should not use this to obtain symbols to standard | 3980 * instead, they should link to the core statically or use \c dlsym (or local equivalent). |
1442 * libretro entry points (static linking or dlsym). | 3981 * |
1443 * | 3982 * The symbol name must be equal to the function name. |
1444 * The symbol name must be equal to the function name, | 3983 * e.g. if <tt>void retro_foo(void);</tt> exists, the symbol in the compiled library must be called \c retro_foo. |
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. | 3984 * The returned function pointer must be cast to the corresponding type. |
3985 * | |
3986 * @param \c sym The name of the symbol to look up. | |
3987 * @return Pointer to the exposed function with the name given in \c sym, | |
3988 * or \c NULL if one couldn't be found. | |
3989 * @note The frontend is expected to know the returned pointer's type in advance | |
3990 * so that it can be cast correctly. | |
3991 * @note The core doesn't need to expose every possible function through this interface. | |
3992 * It's enough to only expose the ones that it expects the frontend to use. | |
3993 * @note The functions exposed through this interface | |
3994 * don't need to be publicly exposed in the compiled library | |
3995 * (e.g. via \c __declspec(dllexport)). | |
3996 * @see RETRO_ENVIRONMENT_SET_PROC_ADDRESS_CALLBACK | |
1447 */ | 3997 */ |
1448 typedef retro_proc_address_t (RETRO_CALLCONV *retro_get_proc_address_t)(const char *sym); | 3998 typedef retro_proc_address_t (RETRO_CALLCONV *retro_get_proc_address_t)(const char *sym); |
1449 | 3999 |
4000 /** | |
4001 * An interface that the frontend can use to get function pointers from the core. | |
4002 * | |
4003 * @note The returned function pointer will be invalidated once the core is unloaded. | |
4004 * How and when that happens is up to the frontend. | |
4005 * | |
4006 * @see retro_get_proc_address_t | |
4007 * @see RETRO_ENVIRONMENT_SET_PROC_ADDRESS_CALLBACK | |
4008 */ | |
1450 struct retro_get_proc_address_interface | 4009 struct retro_get_proc_address_interface |
1451 { | 4010 { |
4011 /** Set by the core. */ | |
1452 retro_get_proc_address_t get_proc_address; | 4012 retro_get_proc_address_t get_proc_address; |
1453 }; | 4013 }; |
1454 | 4014 |
4015 /** @} */ | |
4016 | |
4017 /** @defgroup GET_LOG_INTERFACE Logging | |
4018 * @{ | |
4019 */ | |
4020 | |
4021 /** | |
4022 * The severity of a given message. | |
4023 * The frontend may log messages differently depending on the level. | |
4024 * It may also ignore log messages of a certain level. | |
4025 * @see retro_log_callback | |
4026 */ | |
1455 enum retro_log_level | 4027 enum retro_log_level |
1456 { | 4028 { |
4029 /** The logged message is most likely not interesting to the user. */ | |
1457 RETRO_LOG_DEBUG = 0, | 4030 RETRO_LOG_DEBUG = 0, |
4031 | |
4032 /** Information about the core operating normally. */ | |
1458 RETRO_LOG_INFO, | 4033 RETRO_LOG_INFO, |
4034 | |
4035 /** Indicates a potential problem, possibly one that the core can recover from. */ | |
1459 RETRO_LOG_WARN, | 4036 RETRO_LOG_WARN, |
4037 | |
4038 /** Indicates a degraded experience, if not failure. */ | |
1460 RETRO_LOG_ERROR, | 4039 RETRO_LOG_ERROR, |
1461 | 4040 |
4041 /** Defined to ensure that sizeof(enum retro_log_level) == sizeof(int). Do not use. */ | |
1462 RETRO_LOG_DUMMY = INT_MAX | 4042 RETRO_LOG_DUMMY = INT_MAX |
1463 }; | 4043 }; |
1464 | 4044 |
1465 /* Logging function. Takes log level argument as well. */ | 4045 /** |
4046 * Logs a message to the frontend. | |
4047 * | |
4048 * @param level The log level of the message. | |
4049 * @param fmt The format string to log. | |
4050 * Same format as \c printf. | |
4051 * Behavior is undefined if this is \c NULL. | |
4052 * @param ... Zero or more arguments used by the format string. | |
4053 * Behavior is undefined if these don't match the ones expected by \c fmt. | |
4054 * @see retro_log_level | |
4055 * @see retro_log_callback | |
4056 * @see RETRO_ENVIRONMENT_GET_LOG_INTERFACE | |
4057 * @see printf | |
4058 */ | |
1466 typedef void (RETRO_CALLCONV *retro_log_printf_t)(enum retro_log_level level, | 4059 typedef void (RETRO_CALLCONV *retro_log_printf_t)(enum retro_log_level level, |
1467 const char *fmt, ...); | 4060 const char *fmt, ...); |
1468 | 4061 |
4062 /** | |
4063 * Details about how to make log messages. | |
4064 * | |
4065 * @see retro_log_printf_t | |
4066 * @see RETRO_ENVIRONMENT_GET_LOG_INTERFACE | |
4067 */ | |
1469 struct retro_log_callback | 4068 struct retro_log_callback |
1470 { | 4069 { |
4070 /** | |
4071 * Called when logging a message. | |
4072 * | |
4073 * @note Set by the frontend. | |
4074 */ | |
1471 retro_log_printf_t log; | 4075 retro_log_printf_t log; |
1472 }; | 4076 }; |
1473 | 4077 |
1474 /* Performance related functions */ | 4078 /** @} */ |
1475 | 4079 |
1476 /* ID values for SIMD CPU features */ | 4080 /** @defgroup GET_PERF_INTERFACE Performance Interface |
4081 * @{ | |
4082 */ | |
4083 | |
4084 /** @defgroup RETRO_SIMD CPU Features | |
4085 * @{ | |
4086 */ | |
4087 | |
4088 /** | |
4089 * Indicates CPU support for the SSE instruction set. | |
4090 * | |
4091 * @see https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#ssetechs=SSE | |
4092 */ | |
1477 #define RETRO_SIMD_SSE (1 << 0) | 4093 #define RETRO_SIMD_SSE (1 << 0) |
4094 | |
4095 /** | |
4096 * Indicates CPU support for the SSE2 instruction set. | |
4097 * | |
4098 * @see https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#ssetechs=SSE2 | |
4099 */ | |
1478 #define RETRO_SIMD_SSE2 (1 << 1) | 4100 #define RETRO_SIMD_SSE2 (1 << 1) |
4101 | |
4102 /** Indicates CPU support for the AltiVec (aka VMX or Velocity Engine) instruction set. */ | |
1479 #define RETRO_SIMD_VMX (1 << 2) | 4103 #define RETRO_SIMD_VMX (1 << 2) |
4104 | |
4105 /** Indicates CPU support for the VMX128 instruction set. Xbox 360 only. */ | |
1480 #define RETRO_SIMD_VMX128 (1 << 3) | 4106 #define RETRO_SIMD_VMX128 (1 << 3) |
4107 | |
4108 /** | |
4109 * Indicates CPU support for the AVX instruction set. | |
4110 * | |
4111 * @see https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#avxnewtechs=AVX | |
4112 */ | |
1481 #define RETRO_SIMD_AVX (1 << 4) | 4113 #define RETRO_SIMD_AVX (1 << 4) |
4114 | |
4115 /** | |
4116 * Indicates CPU support for the NEON instruction set. | |
4117 * @see https://developer.arm.com/architectures/instruction-sets/intrinsics/#f:@navigationhierarchiessimdisa=[Neon] | |
4118 */ | |
1482 #define RETRO_SIMD_NEON (1 << 5) | 4119 #define RETRO_SIMD_NEON (1 << 5) |
4120 | |
4121 /** | |
4122 * Indicates CPU support for the SSE3 instruction set. | |
4123 * | |
4124 * @see https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#ssetechs=SSE3 | |
4125 */ | |
1483 #define RETRO_SIMD_SSE3 (1 << 6) | 4126 #define RETRO_SIMD_SSE3 (1 << 6) |
4127 | |
4128 /** | |
4129 * Indicates CPU support for the SSSE3 instruction set. | |
4130 * | |
4131 * @see https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#ssetechs=SSSE3 | |
4132 */ | |
1484 #define RETRO_SIMD_SSSE3 (1 << 7) | 4133 #define RETRO_SIMD_SSSE3 (1 << 7) |
4134 | |
4135 /** | |
4136 * Indicates CPU support for the MMX instruction set. | |
4137 * @see https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#techs=MMX | |
4138 */ | |
1485 #define RETRO_SIMD_MMX (1 << 8) | 4139 #define RETRO_SIMD_MMX (1 << 8) |
4140 | |
4141 /** Indicates CPU support for the MMXEXT instruction set. */ | |
1486 #define RETRO_SIMD_MMXEXT (1 << 9) | 4142 #define RETRO_SIMD_MMXEXT (1 << 9) |
4143 | |
4144 /** | |
4145 * Indicates CPU support for the SSE4 instruction set. | |
4146 * | |
4147 * @see https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#ssetechs=SSE4_1 | |
4148 */ | |
1487 #define RETRO_SIMD_SSE4 (1 << 10) | 4149 #define RETRO_SIMD_SSE4 (1 << 10) |
4150 | |
4151 /** | |
4152 * Indicates CPU support for the SSE4.2 instruction set. | |
4153 * | |
4154 * @see https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#ssetechs=SSE4_2 | |
4155 */ | |
1488 #define RETRO_SIMD_SSE42 (1 << 11) | 4156 #define RETRO_SIMD_SSE42 (1 << 11) |
4157 | |
4158 /** | |
4159 * Indicates CPU support for the AVX2 instruction set. | |
4160 * | |
4161 * @see https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#avxnewtechs=AVX2 | |
4162 */ | |
1489 #define RETRO_SIMD_AVX2 (1 << 12) | 4163 #define RETRO_SIMD_AVX2 (1 << 12) |
4164 | |
4165 /** Indicates CPU support for the VFPU instruction set. PS2 and PSP only. | |
4166 * | |
4167 * @see https://pspdev.github.io/vfpu-docs | |
4168 */ | |
1490 #define RETRO_SIMD_VFPU (1 << 13) | 4169 #define RETRO_SIMD_VFPU (1 << 13) |
4170 | |
4171 /** | |
4172 * Indicates CPU support for Gekko SIMD extensions. GameCube only. | |
4173 */ | |
1491 #define RETRO_SIMD_PS (1 << 14) | 4174 #define RETRO_SIMD_PS (1 << 14) |
4175 | |
4176 /** | |
4177 * Indicates CPU support for AES instructions. | |
4178 * | |
4179 * @see https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#aestechs=AES&othertechs=AES | |
4180 */ | |
1492 #define RETRO_SIMD_AES (1 << 15) | 4181 #define RETRO_SIMD_AES (1 << 15) |
4182 | |
4183 /** | |
4184 * Indicates CPU support for the VFPv3 instruction set. | |
4185 */ | |
1493 #define RETRO_SIMD_VFPV3 (1 << 16) | 4186 #define RETRO_SIMD_VFPV3 (1 << 16) |
4187 | |
4188 /** | |
4189 * Indicates CPU support for the VFPv4 instruction set. | |
4190 */ | |
1494 #define RETRO_SIMD_VFPV4 (1 << 17) | 4191 #define RETRO_SIMD_VFPV4 (1 << 17) |
4192 | |
4193 /** Indicates CPU support for the POPCNT instruction. */ | |
1495 #define RETRO_SIMD_POPCNT (1 << 18) | 4194 #define RETRO_SIMD_POPCNT (1 << 18) |
4195 | |
4196 /** Indicates CPU support for the MOVBE instruction. */ | |
1496 #define RETRO_SIMD_MOVBE (1 << 19) | 4197 #define RETRO_SIMD_MOVBE (1 << 19) |
4198 | |
4199 /** Indicates CPU support for the CMOV instruction. */ | |
1497 #define RETRO_SIMD_CMOV (1 << 20) | 4200 #define RETRO_SIMD_CMOV (1 << 20) |
4201 | |
4202 /** Indicates CPU support for the ASIMD instruction set. */ | |
1498 #define RETRO_SIMD_ASIMD (1 << 21) | 4203 #define RETRO_SIMD_ASIMD (1 << 21) |
1499 | 4204 |
4205 /** @} */ | |
4206 | |
4207 /** | |
4208 * An abstract unit of ticks. | |
4209 * | |
4210 * Usually nanoseconds or CPU cycles, | |
4211 * but it depends on the platform and the frontend. | |
4212 */ | |
1500 typedef uint64_t retro_perf_tick_t; | 4213 typedef uint64_t retro_perf_tick_t; |
4214 | |
4215 /** Time in microseconds. */ | |
1501 typedef int64_t retro_time_t; | 4216 typedef int64_t retro_time_t; |
1502 | 4217 |
4218 /** | |
4219 * A performance counter. | |
4220 * | |
4221 * Use this to measure the execution time of a region of code. | |
4222 * @see retro_perf_callback | |
4223 */ | |
1503 struct retro_perf_counter | 4224 struct retro_perf_counter |
1504 { | 4225 { |
4226 /** | |
4227 * A human-readable identifier for the counter. | |
4228 * | |
4229 * May be displayed by the frontend. | |
4230 * Behavior is undefined if this is \c NULL. | |
4231 */ | |
1505 const char *ident; | 4232 const char *ident; |
4233 | |
4234 /** | |
4235 * The time of the most recent call to \c retro_perf_callback::perf_start | |
4236 * on this performance counter. | |
4237 * | |
4238 * @see retro_perf_start_t | |
4239 */ | |
1506 retro_perf_tick_t start; | 4240 retro_perf_tick_t start; |
4241 | |
4242 /** | |
4243 * The total time spent within this performance counter's measured code, | |
4244 * i.e. between calls to \c retro_perf_callback::perf_start and \c retro_perf_callback::perf_stop. | |
4245 * | |
4246 * Updated after each call to \c retro_perf_callback::perf_stop. | |
4247 * @see retro_perf_stop_t | |
4248 */ | |
1507 retro_perf_tick_t total; | 4249 retro_perf_tick_t total; |
4250 | |
4251 /** | |
4252 * The number of times this performance counter has been started. | |
4253 * | |
4254 * Updated after each call to \c retro_perf_callback::perf_start. | |
4255 * @see retro_perf_start_t | |
4256 */ | |
1508 retro_perf_tick_t call_cnt; | 4257 retro_perf_tick_t call_cnt; |
1509 | 4258 |
4259 /** | |
4260 * \c true if this performance counter has been registered by the frontend. | |
4261 * Must be initialized to \c false by the core before registering it. | |
4262 * @see retro_perf_register_t | |
4263 */ | |
1510 bool registered; | 4264 bool registered; |
1511 }; | 4265 }; |
1512 | 4266 |
1513 /* Returns current time in microseconds. | 4267 /** |
1514 * Tries to use the most accurate timer available. | 4268 * @returns The current system time in microseconds. |
4269 * @note Accuracy may vary by platform. | |
4270 * The frontend should use the most accurate timer possible. | |
4271 * @see RETRO_ENVIRONMENT_GET_PERF_INTERFACE | |
1515 */ | 4272 */ |
1516 typedef retro_time_t (RETRO_CALLCONV *retro_perf_get_time_usec_t)(void); | 4273 typedef retro_time_t (RETRO_CALLCONV *retro_perf_get_time_usec_t)(void); |
1517 | 4274 |
1518 /* A simple counter. Usually nanoseconds, but can also be CPU cycles. | 4275 /** |
1519 * Can be used directly if desired (when creating a more sophisticated | 4276 * @returns The number of ticks since some unspecified epoch. |
1520 * performance counter system). | 4277 * The exact meaning of a "tick" depends on the platform, |
1521 * */ | 4278 * but it usually refers to nanoseconds or CPU cycles. |
4279 * @see RETRO_ENVIRONMENT_GET_PERF_INTERFACE | |
4280 */ | |
1522 typedef retro_perf_tick_t (RETRO_CALLCONV *retro_perf_get_counter_t)(void); | 4281 typedef retro_perf_tick_t (RETRO_CALLCONV *retro_perf_get_counter_t)(void); |
1523 | 4282 |
1524 /* Returns a bit-mask of detected CPU features (RETRO_SIMD_*). */ | 4283 /** |
4284 * Returns a bitmask of detected CPU features. | |
4285 * | |
4286 * Use this for runtime dispatching of CPU-specific code. | |
4287 * | |
4288 * @returns A bitmask of detected CPU features. | |
4289 * @see RETRO_ENVIRONMENT_GET_PERF_INTERFACE | |
4290 * @see RETRO_SIMD | |
4291 */ | |
1525 typedef uint64_t (RETRO_CALLCONV *retro_get_cpu_features_t)(void); | 4292 typedef uint64_t (RETRO_CALLCONV *retro_get_cpu_features_t)(void); |
1526 | 4293 |
1527 /* Asks frontend to log and/or display the state of performance counters. | 4294 /** |
1528 * Performance counters can always be poked into manually as well. | 4295 * Asks the frontend to log or display the state of performance counters. |
4296 * How this is done depends on the frontend. | |
4297 * Performance counters can be reviewed manually as well. | |
4298 * | |
4299 * @see RETRO_ENVIRONMENT_GET_PERF_INTERFACE | |
4300 * @see retro_perf_counter | |
1529 */ | 4301 */ |
1530 typedef void (RETRO_CALLCONV *retro_perf_log_t)(void); | 4302 typedef void (RETRO_CALLCONV *retro_perf_log_t)(void); |
1531 | 4303 |
1532 /* Register a performance counter. | 4304 /** |
1533 * ident field must be set with a discrete value and other values in | 4305 * Registers a new performance counter. |
1534 * retro_perf_counter must be 0. | 4306 * |
1535 * Registering can be called multiple times. To avoid calling to | 4307 * If \c counter has already been registered beforehand, |
1536 * frontend redundantly, you can check registered field first. */ | 4308 * this function does nothing. |
4309 * | |
4310 * @param counter The counter to register. | |
4311 * \c counter::ident must be set to a unique identifier, | |
4312 * and all other values in \c counter must be set to zero or \c false. | |
4313 * Behavior is undefined if \c NULL. | |
4314 * @post If \c counter is successfully registered, | |
4315 * then \c counter::registered will be set to \c true. | |
4316 * Otherwise, it will be set to \c false. | |
4317 * Registration may fail if the frontend's maximum number of counters (if any) has been reached. | |
4318 * @note The counter is owned by the core and must not be freed by the frontend. | |
4319 * The frontend must also clean up any references to a core's performance counters | |
4320 * before unloading it, otherwise undefined behavior may occur. | |
4321 * @see retro_perf_start_t | |
4322 * @see retro_perf_stop_t | |
4323 */ | |
1537 typedef void (RETRO_CALLCONV *retro_perf_register_t)(struct retro_perf_counter *counter); | 4324 typedef void (RETRO_CALLCONV *retro_perf_register_t)(struct retro_perf_counter *counter); |
1538 | 4325 |
1539 /* Starts a registered counter. */ | 4326 /** |
4327 * Starts a registered performance counter. | |
4328 * | |
4329 * Call this just before the code you want to measure. | |
4330 * | |
4331 * @param counter The counter to start. | |
4332 * Behavior is undefined if \c NULL. | |
4333 * @see retro_perf_stop_t | |
4334 */ | |
1540 typedef void (RETRO_CALLCONV *retro_perf_start_t)(struct retro_perf_counter *counter); | 4335 typedef void (RETRO_CALLCONV *retro_perf_start_t)(struct retro_perf_counter *counter); |
1541 | 4336 |
1542 /* Stops a registered counter. */ | 4337 /** |
4338 * Stops a registered performance counter. | |
4339 * | |
4340 * Call this just after the code you want to measure. | |
4341 * | |
4342 * @param counter The counter to stop. | |
4343 * Behavior is undefined if \c NULL. | |
4344 * @see retro_perf_start_t | |
4345 * @see retro_perf_stop_t | |
4346 */ | |
1543 typedef void (RETRO_CALLCONV *retro_perf_stop_t)(struct retro_perf_counter *counter); | 4347 typedef void (RETRO_CALLCONV *retro_perf_stop_t)(struct retro_perf_counter *counter); |
1544 | 4348 |
1545 /* For convenience it can be useful to wrap register, start and stop in macros. | 4349 /** |
1546 * E.g.: | 4350 * An interface that the core can use to get performance information. |
1547 * #ifdef LOG_PERFORMANCE | 4351 * |
4352 * Here's a usage example: | |
4353 * | |
4354 * @code{.c} | |
4355 * #ifdef PROFILING | |
4356 * // Wrapper macros to simplify using performance counters. | |
4357 * // Optional; tailor these to your project's needs. | |
1548 * #define RETRO_PERFORMANCE_INIT(perf_cb, name) static struct retro_perf_counter name = {#name}; if (!name.registered) perf_cb.perf_register(&(name)) | 4358 * #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)) | 4359 * #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)) | 4360 * #define RETRO_PERFORMANCE_STOP(perf_cb, name) perf_cb.perf_stop(&(name)) |
1551 * #else | 4361 * #else |
1552 * ... Blank macros ... | 4362 * // Exclude the performance counters if profiling is disabled. |
4363 * #define RETRO_PERFORMANCE_INIT(perf_cb, name) ((void)0) | |
4364 * #define RETRO_PERFORMANCE_START(perf_cb, name) ((void)0) | |
4365 * #define RETRO_PERFORMANCE_STOP(perf_cb, name) ((void)0) | |
1553 * #endif | 4366 * #endif |
1554 * | 4367 * |
1555 * These can then be used mid-functions around code snippets. | 4368 * // Defined somewhere else in the core. |
1556 * | 4369 * extern struct retro_perf_callback perf_cb; |
1557 * extern struct retro_perf_callback perf_cb; * Somewhere in the core. | 4370 * |
1558 * | 4371 * void retro_run(void) |
1559 * void do_some_heavy_work(void) | |
1560 * { | 4372 * { |
1561 * RETRO_PERFORMANCE_INIT(cb, work_1; | 4373 * RETRO_PERFORMANCE_INIT(cb, interesting); |
1562 * RETRO_PERFORMANCE_START(cb, work_1); | 4374 * RETRO_PERFORMANCE_START(cb, interesting); |
1563 * heavy_work_1(); | 4375 * interesting_work(); |
1564 * RETRO_PERFORMANCE_STOP(cb, work_1); | 4376 * RETRO_PERFORMANCE_STOP(cb, interesting); |
1565 * | 4377 * |
1566 * RETRO_PERFORMANCE_INIT(cb, work_2); | 4378 * RETRO_PERFORMANCE_INIT(cb, maybe_slow); |
1567 * RETRO_PERFORMANCE_START(cb, work_2); | 4379 * RETRO_PERFORMANCE_START(cb, maybe_slow); |
1568 * heavy_work_2(); | 4380 * more_interesting_work(); |
1569 * RETRO_PERFORMANCE_STOP(cb, work_2); | 4381 * RETRO_PERFORMANCE_STOP(cb, maybe_slow); |
1570 * } | 4382 * } |
1571 * | 4383 * |
1572 * void retro_deinit(void) | 4384 * void retro_deinit(void) |
1573 * { | 4385 * { |
1574 * perf_cb.perf_log(); * Log all perf counters here for example. | 4386 * // Asks the frontend to log the results of all performance counters. |
4387 * perf_cb.perf_log(); | |
1575 * } | 4388 * } |
1576 */ | 4389 * @endcode |
1577 | 4390 * |
4391 * All functions are set by the frontend. | |
4392 * | |
4393 * @see RETRO_ENVIRONMENT_GET_PERF_INTERFACE | |
4394 */ | |
1578 struct retro_perf_callback | 4395 struct retro_perf_callback |
1579 { | 4396 { |
4397 /** @copydoc retro_perf_get_time_usec_t */ | |
1580 retro_perf_get_time_usec_t get_time_usec; | 4398 retro_perf_get_time_usec_t get_time_usec; |
4399 | |
4400 /** @copydoc retro_perf_get_counter_t */ | |
1581 retro_get_cpu_features_t get_cpu_features; | 4401 retro_get_cpu_features_t get_cpu_features; |
1582 | 4402 |
4403 /** @copydoc retro_perf_get_counter_t */ | |
1583 retro_perf_get_counter_t get_perf_counter; | 4404 retro_perf_get_counter_t get_perf_counter; |
4405 | |
4406 /** @copydoc retro_perf_register_t */ | |
1584 retro_perf_register_t perf_register; | 4407 retro_perf_register_t perf_register; |
4408 | |
4409 /** @copydoc retro_perf_start_t */ | |
1585 retro_perf_start_t perf_start; | 4410 retro_perf_start_t perf_start; |
4411 | |
4412 /** @copydoc retro_perf_stop_t */ | |
1586 retro_perf_stop_t perf_stop; | 4413 retro_perf_stop_t perf_stop; |
4414 | |
4415 /** @copydoc retro_perf_log_t */ | |
1587 retro_perf_log_t perf_log; | 4416 retro_perf_log_t perf_log; |
1588 }; | 4417 }; |
1589 | 4418 |
1590 /* FIXME: Document the sensor API and work out behavior. | 4419 /** @} */ |
1591 * It will be marked as experimental until then. | 4420 |
4421 /** | |
4422 * @defgroup RETRO_SENSOR Sensor Interface | |
4423 * @{ | |
4424 */ | |
4425 | |
4426 /** | |
4427 * Defines actions that can be performed on sensors. | |
4428 * @note Cores should only enable sensors while they're actively being used; | |
4429 * depending on the frontend and platform, | |
4430 * enabling these sensors may impact battery life. | |
4431 * | |
4432 * @see RETRO_ENVIRONMENT_GET_SENSOR_INTERFACE | |
4433 * @see retro_sensor_interface | |
4434 * @see retro_set_sensor_state_t | |
1592 */ | 4435 */ |
1593 enum retro_sensor_action | 4436 enum retro_sensor_action |
1594 { | 4437 { |
4438 /** Enables accelerometer input, if one exists. */ | |
1595 RETRO_SENSOR_ACCELEROMETER_ENABLE = 0, | 4439 RETRO_SENSOR_ACCELEROMETER_ENABLE = 0, |
4440 | |
4441 /** Disables accelerometer input, if one exists. */ | |
1596 RETRO_SENSOR_ACCELEROMETER_DISABLE, | 4442 RETRO_SENSOR_ACCELEROMETER_DISABLE, |
1597 | 4443 |
4444 /** Enables gyroscope input, if one exists. */ | |
4445 RETRO_SENSOR_GYROSCOPE_ENABLE, | |
4446 | |
4447 /** Disables gyroscope input, if one exists. */ | |
4448 RETRO_SENSOR_GYROSCOPE_DISABLE, | |
4449 | |
4450 /** Enables ambient light input, if a luminance sensor exists. */ | |
4451 RETRO_SENSOR_ILLUMINANCE_ENABLE, | |
4452 | |
4453 /** Disables ambient light input, if a luminance sensor exists. */ | |
4454 RETRO_SENSOR_ILLUMINANCE_DISABLE, | |
4455 | |
4456 /** @private Defined to ensure <tt>sizeof(enum retro_sensor_action) == sizeof(int)</tt>. Do not use. */ | |
1598 RETRO_SENSOR_DUMMY = INT_MAX | 4457 RETRO_SENSOR_DUMMY = INT_MAX |
1599 }; | 4458 }; |
1600 | 4459 |
4460 /** @defgroup RETRO_SENSOR_ID Sensor Value IDs | |
4461 * @{ | |
4462 */ | |
1601 /* Id values for SENSOR types. */ | 4463 /* Id values for SENSOR types. */ |
4464 | |
4465 /** | |
4466 * Returns the device's acceleration along its local X axis minus the effect of gravity, in m/s^2. | |
4467 * | |
4468 * Positive values mean that the device is accelerating to the right. | |
4469 * assuming the user is looking at it head-on. | |
4470 */ | |
1602 #define RETRO_SENSOR_ACCELEROMETER_X 0 | 4471 #define RETRO_SENSOR_ACCELEROMETER_X 0 |
4472 | |
4473 /** | |
4474 * Returns the device's acceleration along its local Y axis minus the effect of gravity, in m/s^2. | |
4475 * | |
4476 * Positive values mean that the device is accelerating upwards, | |
4477 * assuming the user is looking at it head-on. | |
4478 */ | |
1603 #define RETRO_SENSOR_ACCELEROMETER_Y 1 | 4479 #define RETRO_SENSOR_ACCELEROMETER_Y 1 |
4480 | |
4481 /** | |
4482 * Returns the the device's acceleration along its local Z axis minus the effect of gravity, in m/s^2. | |
4483 * | |
4484 * Positive values indicate forward acceleration towards the user, | |
4485 * assuming the user is looking at the device head-on. | |
4486 */ | |
1604 #define RETRO_SENSOR_ACCELEROMETER_Z 2 | 4487 #define RETRO_SENSOR_ACCELEROMETER_Z 2 |
1605 | 4488 |
4489 /** | |
4490 * Returns the angular velocity of the device around its local X axis, in radians per second. | |
4491 * | |
4492 * Positive values indicate counter-clockwise rotation. | |
4493 * | |
4494 * @note A radian is about 57 degrees, and a full 360-degree rotation is 2*pi radians. | |
4495 * @see https://developer.android.com/reference/android/hardware/SensorEvent#sensor.type_gyroscope | |
4496 * for guidance on using this value to derive a device's orientation. | |
4497 */ | |
4498 #define RETRO_SENSOR_GYROSCOPE_X 3 | |
4499 | |
4500 /** | |
4501 * Returns the angular velocity of the device around its local Z axis, in radians per second. | |
4502 * | |
4503 * Positive values indicate counter-clockwise rotation. | |
4504 * | |
4505 * @note A radian is about 57 degrees, and a full 360-degree rotation is 2*pi radians. | |
4506 * @see https://developer.android.com/reference/android/hardware/SensorEvent#sensor.type_gyroscope | |
4507 * for guidance on using this value to derive a device's orientation. | |
4508 */ | |
4509 #define RETRO_SENSOR_GYROSCOPE_Y 4 | |
4510 | |
4511 /** | |
4512 * Returns the angular velocity of the device around its local Z axis, in radians per second. | |
4513 * | |
4514 * Positive values indicate counter-clockwise rotation. | |
4515 * | |
4516 * @note A radian is about 57 degrees, and a full 360-degree rotation is 2*pi radians. | |
4517 * @see https://developer.android.com/reference/android/hardware/SensorEvent#sensor.type_gyroscope | |
4518 * for guidance on using this value to derive a device's orientation. | |
4519 */ | |
4520 #define RETRO_SENSOR_GYROSCOPE_Z 5 | |
4521 | |
4522 /** | |
4523 * Returns the ambient illuminance (light intensity) of the device's environment, in lux. | |
4524 * | |
4525 * @see https://en.wikipedia.org/wiki/Lux for a table of common lux values. | |
4526 */ | |
4527 #define RETRO_SENSOR_ILLUMINANCE 6 | |
4528 /** @} */ | |
4529 | |
4530 /** | |
4531 * Adjusts the state of a sensor. | |
4532 * | |
4533 * @param port The device port of the controller that owns the sensor given in \c action. | |
4534 * @param action The action to perform on the sensor. | |
4535 * Different devices support different sensors. | |
4536 * @param rate The rate at which the underlying sensor should be updated, in Hz. | |
4537 * This should be treated as a hint, | |
4538 * as some device sensors may not support the requested rate | |
4539 * (if it's configurable at all). | |
4540 * @returns \c true if the sensor state was successfully adjusted, \c false otherwise. | |
4541 * @note If one of the \c RETRO_SENSOR_*_ENABLE actions fails, | |
4542 * this likely means that the given sensor is not available | |
4543 * on the provided \c port. | |
4544 * @see retro_sensor_action | |
4545 */ | |
1606 typedef bool (RETRO_CALLCONV *retro_set_sensor_state_t)(unsigned port, | 4546 typedef bool (RETRO_CALLCONV *retro_set_sensor_state_t)(unsigned port, |
1607 enum retro_sensor_action action, unsigned rate); | 4547 enum retro_sensor_action action, unsigned rate); |
1608 | 4548 |
4549 /** | |
4550 * Retrieves the current value reported by sensor. | |
4551 * @param port The device port of the controller that owns the sensor given in \c id. | |
4552 * @param id The sensor value to query. | |
4553 * @returns The current sensor value. | |
4554 * Exact semantics depend on the value given in \c id, | |
4555 * but will return 0 for invalid arguments. | |
4556 * | |
4557 * @see RETRO_SENSOR_ID | |
4558 */ | |
1609 typedef float (RETRO_CALLCONV *retro_sensor_get_input_t)(unsigned port, unsigned id); | 4559 typedef float (RETRO_CALLCONV *retro_sensor_get_input_t)(unsigned port, unsigned id); |
1610 | 4560 |
4561 /** | |
4562 * An interface that cores can use to access device sensors. | |
4563 * | |
4564 * All function pointers are set by the frontend. | |
4565 */ | |
1611 struct retro_sensor_interface | 4566 struct retro_sensor_interface |
1612 { | 4567 { |
4568 /** @copydoc retro_set_sensor_state_t */ | |
1613 retro_set_sensor_state_t set_sensor_state; | 4569 retro_set_sensor_state_t set_sensor_state; |
4570 | |
4571 /** @copydoc retro_sensor_get_input_t */ | |
1614 retro_sensor_get_input_t get_sensor_input; | 4572 retro_sensor_get_input_t get_sensor_input; |
1615 }; | 4573 }; |
1616 | 4574 |
4575 /** @} */ | |
4576 | |
4577 /** @defgroup GET_CAMERA_INTERFACE Camera Interface | |
4578 * @{ | |
4579 */ | |
4580 | |
4581 /** | |
4582 * Denotes the type of buffer in which the camera will store its input. | |
4583 * | |
4584 * Different camera drivers may support different buffer types. | |
4585 * | |
4586 * @see RETRO_ENVIRONMENT_GET_CAMERA_INTERFACE | |
4587 * @see retro_camera_callback | |
4588 */ | |
1617 enum retro_camera_buffer | 4589 enum retro_camera_buffer |
1618 { | 4590 { |
4591 /** | |
4592 * Indicates that camera frames should be delivered to the core as an OpenGL texture. | |
4593 * | |
4594 * Requires that the core is using an OpenGL context via \c RETRO_ENVIRONMENT_SET_HW_RENDER. | |
4595 * | |
4596 * @see retro_camera_frame_opengl_texture_t | |
4597 */ | |
1619 RETRO_CAMERA_BUFFER_OPENGL_TEXTURE = 0, | 4598 RETRO_CAMERA_BUFFER_OPENGL_TEXTURE = 0, |
4599 | |
4600 /** | |
4601 * Indicates that camera frames should be delivered to the core as a raw buffer in memory. | |
4602 * | |
4603 * @see retro_camera_frame_raw_framebuffer_t | |
4604 */ | |
1620 RETRO_CAMERA_BUFFER_RAW_FRAMEBUFFER, | 4605 RETRO_CAMERA_BUFFER_RAW_FRAMEBUFFER, |
1621 | 4606 |
4607 /** | |
4608 * @private Defined to ensure <tt>sizeof(enum retro_camera_buffer) == sizeof(int)</tt>. | |
4609 * Do not use. | |
4610 */ | |
1622 RETRO_CAMERA_BUFFER_DUMMY = INT_MAX | 4611 RETRO_CAMERA_BUFFER_DUMMY = INT_MAX |
1623 }; | 4612 }; |
1624 | 4613 |
1625 /* Starts the camera driver. Can only be called in retro_run(). */ | 4614 /** |
4615 * Starts an initialized camera. | |
4616 * The camera is disabled by default, | |
4617 * and must be enabled with this function before being used. | |
4618 * | |
4619 * Set by the frontend. | |
4620 * | |
4621 * @returns \c true if the camera was successfully started, \c false otherwise. | |
4622 * Failure may occur if no actual camera is available, | |
4623 * or if the frontend doesn't have permission to access it. | |
4624 * @note Must be called in \c retro_run(). | |
4625 * @see retro_camera_callback | |
4626 */ | |
1626 typedef bool (RETRO_CALLCONV *retro_camera_start_t)(void); | 4627 typedef bool (RETRO_CALLCONV *retro_camera_start_t)(void); |
1627 | 4628 |
1628 /* Stops the camera driver. Can only be called in retro_run(). */ | 4629 /** |
4630 * Stops the running camera. | |
4631 * | |
4632 * Set by the frontend. | |
4633 * | |
4634 * @note Must be called in \c retro_run(). | |
4635 * @warning The frontend may close the camera on its own when unloading the core, | |
4636 * but this behavior is not guaranteed. | |
4637 * Cores should clean up the camera before exiting. | |
4638 * @see retro_camera_callback | |
4639 */ | |
1629 typedef void (RETRO_CALLCONV *retro_camera_stop_t)(void); | 4640 typedef void (RETRO_CALLCONV *retro_camera_stop_t)(void); |
1630 | 4641 |
1631 /* Callback which signals when the camera driver is initialized | 4642 /** |
1632 * and/or deinitialized. | 4643 * Called by the frontend to report the state of the camera driver. |
1633 * retro_camera_start_t can be called in initialized callback. | 4644 * |
4645 * @see retro_camera_callback | |
1634 */ | 4646 */ |
1635 typedef void (RETRO_CALLCONV *retro_camera_lifetime_status_t)(void); | 4647 typedef void (RETRO_CALLCONV *retro_camera_lifetime_status_t)(void); |
1636 | 4648 |
1637 /* A callback for raw framebuffer data. buffer points to an XRGB8888 buffer. | 4649 /** |
1638 * Width, height and pitch are similar to retro_video_refresh_t. | 4650 * Called by the frontend to report a new camera frame, |
1639 * First pixel is top-left origin. | 4651 * delivered as a raw buffer in memory. |
4652 * | |
4653 * Set by the core. | |
4654 * | |
4655 * @param buffer Pointer to the camera's most recent video frame. | |
4656 * Each pixel is in XRGB8888 format. | |
4657 * The first pixel represents the top-left corner of the image | |
4658 * (i.e. the Y axis goes downward). | |
4659 * @param width The width of the frame given in \c buffer, in pixels. | |
4660 * @param height The height of the frame given in \c buffer, in pixels. | |
4661 * @param pitch The width of the frame given in \c buffer, in bytes. | |
4662 * @warning \c buffer may be invalidated when this function returns, | |
4663 * so the core should make its own copy of \c buffer if necessary. | |
4664 * @see RETRO_CAMERA_BUFFER_RAW_FRAMEBUFFER | |
1640 */ | 4665 */ |
1641 typedef void (RETRO_CALLCONV *retro_camera_frame_raw_framebuffer_t)(const uint32_t *buffer, | 4666 typedef void (RETRO_CALLCONV *retro_camera_frame_raw_framebuffer_t)(const uint32_t *buffer, |
1642 unsigned width, unsigned height, size_t pitch); | 4667 unsigned width, unsigned height, size_t pitch); |
1643 | 4668 |
1644 /* A callback for when OpenGL textures are used. | 4669 /** |
1645 * | 4670 * Called by the frontend to report a new camera frame, |
1646 * texture_id is a texture owned by camera driver. | 4671 * delivered as an OpenGL texture. |
1647 * Its state or content should be considered immutable, except for things like | 4672 * |
1648 * texture filtering and clamping. | 4673 * @param texture_id The ID of the OpenGL texture that represents the camera's most recent frame. |
1649 * | 4674 * Owned by the frontend, and must not be modified by the core. |
1650 * texture_target is the texture target for the GL texture. | 4675 * @param texture_target The type of the texture given in \c texture_id. |
1651 * These can include e.g. GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE, and possibly | 4676 * Usually either \c GL_TEXTURE_2D or \c GL_TEXTURE_RECTANGLE, |
1652 * more depending on extensions. | 4677 * but other types are allowed. |
1653 * | 4678 * @param affine A pointer to a 3x3 column-major affine matrix |
1654 * affine points to a packed 3x3 column-major matrix used to apply an affine | 4679 * that can be used to transform pixel coordinates to texture coordinates. |
1655 * transform to texture coordinates. (affine_matrix * vec3(coord_x, coord_y, 1.0)) | 4680 * After transformation, the bottom-left corner should have coordinates of <tt>(0, 0)</tt> |
1656 * After transform, normalized texture coord (0, 0) should be bottom-left | 4681 * and the top-right corner should have coordinates of <tt>(1, 1)</tt> |
1657 * and (1, 1) should be top-right (or (width, height) for RECTANGLE). | 4682 * (or <tt>(width, height)</tt> for \c GL_TEXTURE_RECTANGLE). |
1658 * | 4683 * |
1659 * GL-specific typedefs are avoided here to avoid relying on gl.h in | 4684 * @note GL-specific typedefs (e.g. \c GLfloat and \c GLuint) are avoided here |
1660 * the API definition. | 4685 * so that the API doesn't rely on gl.h. |
4686 * @warning \c texture_id and \c affine may be invalidated when this function returns, | |
4687 * so the core should make its own copy of them if necessary. | |
1661 */ | 4688 */ |
1662 typedef void (RETRO_CALLCONV *retro_camera_frame_opengl_texture_t)(unsigned texture_id, | 4689 typedef void (RETRO_CALLCONV *retro_camera_frame_opengl_texture_t)(unsigned texture_id, |
1663 unsigned texture_target, const float *affine); | 4690 unsigned texture_target, const float *affine); |
1664 | 4691 |
4692 /** | |
4693 * An interface that the core can use to access a device's camera. | |
4694 * | |
4695 * @see RETRO_ENVIRONMENT_GET_CAMERA_INTERFACE | |
4696 */ | |
1665 struct retro_camera_callback | 4697 struct retro_camera_callback |
1666 { | 4698 { |
1667 /* Set by libretro core. | 4699 /** |
1668 * Example bitmask: caps = (1 << RETRO_CAMERA_BUFFER_OPENGL_TEXTURE) | (1 << RETRO_CAMERA_BUFFER_RAW_FRAMEBUFFER). | 4700 * Requested camera capabilities, |
4701 * given as a bitmask of \c retro_camera_buffer values. | |
4702 * Set by the core. | |
4703 * | |
4704 * Here's a usage example: | |
4705 * @code | |
4706 * // Requesting support for camera data delivered as both an OpenGL texture and a pixel buffer: | |
4707 * struct retro_camera_callback callback; | |
4708 * callback.caps = (1 << RETRO_CAMERA_BUFFER_OPENGL_TEXTURE) | (1 << RETRO_CAMERA_BUFFER_RAW_FRAMEBUFFER); | |
4709 * @endcode | |
1669 */ | 4710 */ |
1670 uint64_t caps; | 4711 uint64_t caps; |
1671 | 4712 |
1672 /* Desired resolution for camera. Is only used as a hint. */ | 4713 /** |
4714 * The desired width of the camera frame, in pixels. | |
4715 * This is only a hint; the frontend may provide a different size. | |
4716 * Set by the core. | |
4717 * Use zero to let the frontend decide. | |
4718 */ | |
1673 unsigned width; | 4719 unsigned width; |
4720 | |
4721 /** | |
4722 * The desired height of the camera frame, in pixels. | |
4723 * This is only a hint; the frontend may provide a different size. | |
4724 * Set by the core. | |
4725 * Use zero to let the frontend decide. | |
4726 */ | |
1674 unsigned height; | 4727 unsigned height; |
1675 | 4728 |
1676 /* Set by frontend. */ | 4729 /** |
4730 * @copydoc retro_camera_start_t | |
4731 * @see retro_camera_callback | |
4732 */ | |
1677 retro_camera_start_t start; | 4733 retro_camera_start_t start; |
4734 | |
4735 /** | |
4736 * @copydoc retro_camera_stop_t | |
4737 * @see retro_camera_callback | |
4738 */ | |
1678 retro_camera_stop_t stop; | 4739 retro_camera_stop_t stop; |
1679 | 4740 |
1680 /* Set by libretro core if raw framebuffer callbacks will be used. */ | 4741 /** |
4742 * @copydoc retro_camera_frame_raw_framebuffer_t | |
4743 * @note If \c NULL, this function will not be called. | |
4744 */ | |
1681 retro_camera_frame_raw_framebuffer_t frame_raw_framebuffer; | 4745 retro_camera_frame_raw_framebuffer_t frame_raw_framebuffer; |
1682 | 4746 |
1683 /* Set by libretro core if OpenGL texture callbacks will be used. */ | 4747 /** |
4748 * @copydoc retro_camera_frame_opengl_texture_t | |
4749 * @note If \c NULL, this function will not be called. | |
4750 */ | |
1684 retro_camera_frame_opengl_texture_t frame_opengl_texture; | 4751 retro_camera_frame_opengl_texture_t frame_opengl_texture; |
1685 | 4752 |
1686 /* Set by libretro core. Called after camera driver is initialized and | 4753 /** |
1687 * ready to be started. | 4754 * Core-defined callback invoked by the frontend right after the camera driver is initialized |
1688 * Can be NULL, in which this callback is not called. | 4755 * (\em not when calling \c start). |
4756 * May be \c NULL, in which case this function is skipped. | |
1689 */ | 4757 */ |
1690 retro_camera_lifetime_status_t initialized; | 4758 retro_camera_lifetime_status_t initialized; |
1691 | 4759 |
1692 /* Set by libretro core. Called right before camera driver is | 4760 /** |
1693 * deinitialized. | 4761 * Core-defined callback invoked by the frontend |
1694 * Can be NULL, in which this callback is not called. | 4762 * right before the video camera driver is deinitialized |
4763 * (\em not when calling \c stop). | |
4764 * May be \c NULL, in which case this function is skipped. | |
1695 */ | 4765 */ |
1696 retro_camera_lifetime_status_t deinitialized; | 4766 retro_camera_lifetime_status_t deinitialized; |
1697 }; | 4767 }; |
1698 | 4768 |
1699 /* Sets the interval of time and/or distance at which to update/poll | 4769 /** @} */ |
1700 * location-based data. | 4770 |
1701 * | 4771 /** @defgroup GET_LOCATION_INTERFACE Location Interface |
1702 * To ensure compatibility with all location-based implementations, | 4772 * @{ |
1703 * values for both interval_ms and interval_distance should be provided. | 4773 */ |
1704 * | 4774 |
1705 * interval_ms is the interval expressed in milliseconds. | 4775 /** @copydoc retro_location_callback::set_interval */ |
1706 * interval_distance is the distance interval expressed in meters. | |
1707 */ | |
1708 typedef void (RETRO_CALLCONV *retro_location_set_interval_t)(unsigned interval_ms, | 4776 typedef void (RETRO_CALLCONV *retro_location_set_interval_t)(unsigned interval_ms, |
1709 unsigned interval_distance); | 4777 unsigned interval_distance); |
1710 | 4778 |
1711 /* Start location services. The device will start listening for changes to the | 4779 /** @copydoc retro_location_callback::start */ |
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); | 4780 typedef bool (RETRO_CALLCONV *retro_location_start_t)(void); |
1715 | 4781 |
1716 /* Stop location services. The device will stop listening for changes | 4782 /** @copydoc retro_location_callback::stop */ |
1717 * to the current location. */ | |
1718 typedef void (RETRO_CALLCONV *retro_location_stop_t)(void); | 4783 typedef void (RETRO_CALLCONV *retro_location_stop_t)(void); |
1719 | 4784 |
1720 /* Get the position of the current location. Will set parameters to | 4785 /** @copydoc retro_location_callback::get_position */ |
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, | 4786 typedef bool (RETRO_CALLCONV *retro_location_get_position_t)(double *lat, double *lon, |
1723 double *horiz_accuracy, double *vert_accuracy); | 4787 double *horiz_accuracy, double *vert_accuracy); |
1724 | 4788 |
1725 /* Callback which signals when the location driver is initialized | 4789 /** Function type that reports the status of the location service. */ |
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); | 4790 typedef void (RETRO_CALLCONV *retro_location_lifetime_status_t)(void); |
1730 | 4791 |
4792 /** | |
4793 * An interface that the core can use to access a device's location. | |
4794 * | |
4795 * @note It is the frontend's responsibility to request the necessary permissions | |
4796 * from the operating system. | |
4797 * @see RETRO_ENVIRONMENT_GET_LOCATION_INTERFACE | |
4798 */ | |
1731 struct retro_location_callback | 4799 struct retro_location_callback |
1732 { | 4800 { |
4801 /** | |
4802 * Starts listening the device's location service. | |
4803 * | |
4804 * The frontend will report changes to the device's location | |
4805 * at the interval defined by \c set_interval. | |
4806 * Set by the frontend. | |
4807 * | |
4808 * @return true if location services were successfully started, false otherwise. | |
4809 * Note that this will return \c false if location services are disabled | |
4810 * or the frontend doesn't have permission to use them. | |
4811 * @note The device's location service may or may not have been enabled | |
4812 * before the core calls this function. | |
4813 */ | |
1733 retro_location_start_t start; | 4814 retro_location_start_t start; |
4815 | |
4816 /** | |
4817 * Stop listening to the device's location service. | |
4818 * | |
4819 * Set by the frontend. | |
4820 * | |
4821 * @note The location service itself may or may not | |
4822 * be turned off by this function, | |
4823 * depending on the platform and the frontend. | |
4824 * @post The core will stop receiving location service updates. | |
4825 */ | |
1734 retro_location_stop_t stop; | 4826 retro_location_stop_t stop; |
4827 | |
4828 /** | |
4829 * Returns the device's current coordinates. | |
4830 * | |
4831 * Set by the frontend. | |
4832 * | |
4833 * @param[out] lat Pointer to latitude, in degrees. | |
4834 * Will be set to 0 if no change has occurred since the last call. | |
4835 * Behavior is undefined if \c NULL. | |
4836 * @param[out] lon Pointer to longitude, in degrees. | |
4837 * Will be set to 0 if no change has occurred since the last call. | |
4838 * Behavior is undefined if \c NULL. | |
4839 * @param[out] horiz_accuracy Pointer to horizontal accuracy. | |
4840 * Will be set to 0 if no change has occurred since the last call. | |
4841 * Behavior is undefined if \c NULL. | |
4842 * @param[out] vert_accuracy Pointer to vertical accuracy. | |
4843 * Will be set to 0 if no change has occurred since the last call. | |
4844 * Behavior is undefined if \c NULL. | |
4845 */ | |
1735 retro_location_get_position_t get_position; | 4846 retro_location_get_position_t get_position; |
4847 | |
4848 /** | |
4849 * Sets the rate at which the location service should report updates. | |
4850 * | |
4851 * This is only a hint; the actual rate may differ. | |
4852 * Sets the interval of time and/or distance at which to update/poll | |
4853 * location-based data. | |
4854 * | |
4855 * Some platforms may only support one of the two parameters; | |
4856 * cores should provide both to ensure compatibility. | |
4857 * | |
4858 * Set by the frontend. | |
4859 * | |
4860 * @param interval_ms The desired period of time between location updates, in milliseconds. | |
4861 * @param interval_distance The desired distance between location updates, in meters. | |
4862 */ | |
1736 retro_location_set_interval_t set_interval; | 4863 retro_location_set_interval_t set_interval; |
1737 | 4864 |
4865 /** Called when the location service is initialized. Set by the core. Optional. */ | |
1738 retro_location_lifetime_status_t initialized; | 4866 retro_location_lifetime_status_t initialized; |
4867 | |
4868 /** Called when the location service is deinitialized. Set by the core. Optional. */ | |
1739 retro_location_lifetime_status_t deinitialized; | 4869 retro_location_lifetime_status_t deinitialized; |
1740 }; | 4870 }; |
1741 | 4871 |
4872 /** @} */ | |
4873 | |
4874 /** @addtogroup GET_RUMBLE_INTERFACE | |
4875 * @{ */ | |
4876 | |
4877 /** | |
4878 * The type of rumble motor in a controller. | |
4879 * | |
4880 * Both motors can be controlled independently, | |
4881 * and the strong motor does not override the weak motor. | |
4882 * @see RETRO_ENVIRONMENT_GET_RUMBLE_INTERFACE | |
4883 */ | |
1742 enum retro_rumble_effect | 4884 enum retro_rumble_effect |
1743 { | 4885 { |
1744 RETRO_RUMBLE_STRONG = 0, | 4886 RETRO_RUMBLE_STRONG = 0, |
1745 RETRO_RUMBLE_WEAK = 1, | 4887 RETRO_RUMBLE_WEAK = 1, |
1746 | 4888 |
4889 /** @private Defined to ensure <tt>sizeof(enum retro_rumble_effect) == sizeof(int)</tt>. Do not use. */ | |
1747 RETRO_RUMBLE_DUMMY = INT_MAX | 4890 RETRO_RUMBLE_DUMMY = INT_MAX |
1748 }; | 4891 }; |
1749 | 4892 |
1750 /* Sets rumble state for joypad plugged in port 'port'. | 4893 /** |
1751 * Rumble effects are controlled independently, | 4894 * Requests a rumble state change for a controller. |
1752 * and setting e.g. strong rumble does not override weak rumble. | 4895 * Set by the frontend. |
1753 * Strength has a range of [0, 0xffff]. | 4896 * |
1754 * | 4897 * @param port The controller port to set the rumble state for. |
1755 * Returns true if rumble state request was honored. | 4898 * @param effect The rumble motor to set the strength of. |
1756 * Calling this before first retro_run() is likely to return false. */ | 4899 * @param strength The desired intensity of the rumble motor, ranging from \c 0 to \c 0xffff (inclusive). |
4900 * @return \c true if the requested rumble state was honored. | |
4901 * If the controller doesn't support rumble, will return \c false. | |
4902 * @note Calling this before the first \c retro_run() may return \c false. | |
4903 * @see RETRO_ENVIRONMENT_GET_RUMBLE_INTERFACE | |
4904 */ | |
1757 typedef bool (RETRO_CALLCONV *retro_set_rumble_state_t)(unsigned port, | 4905 typedef bool (RETRO_CALLCONV *retro_set_rumble_state_t)(unsigned port, |
1758 enum retro_rumble_effect effect, uint16_t strength); | 4906 enum retro_rumble_effect effect, uint16_t strength); |
1759 | 4907 |
4908 /** | |
4909 * An interface that the core can use to set the rumble state of a controller. | |
4910 * @see RETRO_ENVIRONMENT_GET_RUMBLE_INTERFACE | |
4911 */ | |
1760 struct retro_rumble_interface | 4912 struct retro_rumble_interface |
1761 { | 4913 { |
4914 /** @copydoc retro_set_rumble_state_t */ | |
1762 retro_set_rumble_state_t set_rumble_state; | 4915 retro_set_rumble_state_t set_rumble_state; |
1763 }; | 4916 }; |
1764 | 4917 |
1765 /* Notifies libretro that audio data should be written. */ | 4918 /** @} */ |
4919 | |
4920 /** | |
4921 * Called by the frontend to request audio samples. | |
4922 * The core should render audio within this function | |
4923 * using the callback provided by \c retro_set_audio_sample or \c retro_set_audio_sample_batch. | |
4924 * | |
4925 * @warning This function may be called by any thread, | |
4926 * therefore it must be thread-safe. | |
4927 * @see RETRO_ENVIRONMENT_SET_AUDIO_CALLBACK | |
4928 * @see retro_audio_callback | |
4929 * @see retro_audio_sample_batch_t | |
4930 * @see retro_audio_sample_t | |
4931 */ | |
1766 typedef void (RETRO_CALLCONV *retro_audio_callback_t)(void); | 4932 typedef void (RETRO_CALLCONV *retro_audio_callback_t)(void); |
1767 | 4933 |
1768 /* True: Audio driver in frontend is active, and callback is | 4934 /** |
1769 * expected to be called regularily. | 4935 * Called by the frontend to notify the core that it should pause or resume audio rendering. |
1770 * False: Audio driver in frontend is paused or inactive. | 4936 * The initial state of the audio driver after registering this callback is \c false (inactive). |
1771 * Audio callback will not be called until set_state has been | 4937 * |
1772 * called with true. | 4938 * @param enabled \c true if the frontend's audio driver is active. |
1773 * Initial state is false (inactive). | 4939 * If so, the registered audio callback will be called regularly. |
4940 * If not, the audio callback will not be invoked until the next time | |
4941 * the frontend calls this function with \c true. | |
4942 * @warning This function may be called by any thread, | |
4943 * therefore it must be thread-safe. | |
4944 * @note Even if no audio samples are rendered, | |
4945 * the core should continue to update its emulated platform's audio engine if necessary. | |
4946 * @see RETRO_ENVIRONMENT_SET_AUDIO_CALLBACK | |
4947 * @see retro_audio_callback | |
4948 * @see retro_audio_callback_t | |
1774 */ | 4949 */ |
1775 typedef void (RETRO_CALLCONV *retro_audio_set_state_callback_t)(bool enabled); | 4950 typedef void (RETRO_CALLCONV *retro_audio_set_state_callback_t)(bool enabled); |
1776 | 4951 |
4952 /** | |
4953 * An interface that the frontend uses to request audio samples from the core. | |
4954 * @note To unregister a callback, pass a \c retro_audio_callback_t | |
4955 * with both fields set to <tt>NULL</tt>. | |
4956 * @see RETRO_ENVIRONMENT_SET_AUDIO_CALLBACK | |
4957 */ | |
1777 struct retro_audio_callback | 4958 struct retro_audio_callback |
1778 { | 4959 { |
4960 /** @see retro_audio_callback_t */ | |
1779 retro_audio_callback_t callback; | 4961 retro_audio_callback_t callback; |
4962 | |
4963 /** @see retro_audio_set_state_callback_t */ | |
1780 retro_audio_set_state_callback_t set_state; | 4964 retro_audio_set_state_callback_t set_state; |
1781 }; | 4965 }; |
1782 | 4966 |
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; | 4967 typedef int64_t retro_usec_t; |
4968 | |
4969 /** | |
4970 * Called right before each iteration of \c retro_run | |
4971 * if registered via <tt>RETRO_ENVIRONMENT_SET_FRAME_TIME_CALLBACK</tt>. | |
4972 * | |
4973 * @param usec Time since the last call to <tt>retro_run</tt>, in microseconds. | |
4974 * If the frontend is manipulating the frame time | |
4975 * (e.g. via fast-forward or slow motion), | |
4976 * this value will be the reference value initially provided to the environment call. | |
4977 * @see RETRO_ENVIRONMENT_SET_FRAME_TIME_CALLBACK | |
4978 * @see retro_frame_time_callback | |
4979 */ | |
1792 typedef void (RETRO_CALLCONV *retro_frame_time_callback_t)(retro_usec_t usec); | 4980 typedef void (RETRO_CALLCONV *retro_frame_time_callback_t)(retro_usec_t usec); |
4981 | |
4982 /** | |
4983 * @see RETRO_ENVIRONMENT_SET_FRAME_TIME_CALLBACK | |
4984 */ | |
1793 struct retro_frame_time_callback | 4985 struct retro_frame_time_callback |
1794 { | 4986 { |
4987 /** | |
4988 * Called to notify the core of the current frame time. | |
4989 * If <tt>NULL</tt>, the frontend will clear its registered callback. | |
4990 */ | |
1795 retro_frame_time_callback_t callback; | 4991 retro_frame_time_callback_t callback; |
1796 /* Represents the time of one frame. It is computed as | 4992 |
1797 * 1000000 / fps, but the implementation will resolve the | 4993 /** |
1798 * rounding to ensure that framestepping, etc is exact. */ | 4994 * The ideal duration of one frame, in microseconds. |
4995 * Compute it as <tt>1000000 / fps</tt>. | |
4996 * The frontend will resolve rounding to ensure that framestepping, etc is exact. | |
4997 */ | |
1799 retro_usec_t reference; | 4998 retro_usec_t reference; |
1800 }; | 4999 }; |
5000 | |
5001 /** @defgroup SET_AUDIO_BUFFER_STATUS_CALLBACK Audio Buffer Occupancy | |
5002 * @{ | |
5003 */ | |
5004 | |
5005 /** | |
5006 * Notifies a libretro core of how full the frontend's audio buffer is. | |
5007 * Set by the core, called by the frontend. | |
5008 * It will be called right before \c retro_run() every frame. | |
5009 * | |
5010 * @param active \c true if the frontend's audio buffer is currently in use, | |
5011 * \c false if audio is disabled in the frontend. | |
5012 * @param occupancy A value between 0 and 100 (inclusive), | |
5013 * corresponding to the frontend's audio buffer occupancy percentage. | |
5014 * @param underrun_likely \c true if the frontend expects an audio buffer underrun | |
5015 * during the next frame, which indicates that a core should attempt frame-skipping. | |
5016 */ | |
5017 typedef void (RETRO_CALLCONV *retro_audio_buffer_status_callback_t)( | |
5018 bool active, unsigned occupancy, bool underrun_likely); | |
5019 | |
5020 /** | |
5021 * A callback to register with the frontend to receive audio buffer occupancy information. | |
5022 */ | |
5023 struct retro_audio_buffer_status_callback | |
5024 { | |
5025 /** @copydoc retro_audio_buffer_status_callback_t */ | |
5026 retro_audio_buffer_status_callback_t callback; | |
5027 }; | |
5028 | |
5029 /** @} */ | |
1801 | 5030 |
1802 /* Pass this to retro_video_refresh_t if rendering to hardware. | 5031 /* 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. | 5032 * Passing NULL to retro_video_refresh_t is still a frame dupe as normal. |
1804 * */ | 5033 * */ |
1805 #define RETRO_HW_FRAME_BUFFER_VALID ((void*)-1) | 5034 #define RETRO_HW_FRAME_BUFFER_VALID ((void*)-1) |
1840 RETRO_HW_CONTEXT_OPENGLES_VERSION = 5, | 5069 RETRO_HW_CONTEXT_OPENGLES_VERSION = 5, |
1841 | 5070 |
1842 /* Vulkan, see RETRO_ENVIRONMENT_GET_HW_RENDER_INTERFACE. */ | 5071 /* Vulkan, see RETRO_ENVIRONMENT_GET_HW_RENDER_INTERFACE. */ |
1843 RETRO_HW_CONTEXT_VULKAN = 6, | 5072 RETRO_HW_CONTEXT_VULKAN = 6, |
1844 | 5073 |
5074 /* Direct3D11, see RETRO_ENVIRONMENT_GET_HW_RENDER_INTERFACE */ | |
5075 RETRO_HW_CONTEXT_D3D11 = 7, | |
5076 | |
5077 /* Direct3D10, see RETRO_ENVIRONMENT_GET_HW_RENDER_INTERFACE */ | |
5078 RETRO_HW_CONTEXT_D3D10 = 8, | |
5079 | |
5080 /* Direct3D12, see RETRO_ENVIRONMENT_GET_HW_RENDER_INTERFACE */ | |
5081 RETRO_HW_CONTEXT_D3D12 = 9, | |
5082 | |
5083 /* Direct3D9, see RETRO_ENVIRONMENT_GET_HW_RENDER_INTERFACE */ | |
5084 RETRO_HW_CONTEXT_D3D9 = 10, | |
5085 | |
5086 /** Dummy value to ensure sizeof(enum retro_hw_context_type) == sizeof(int). Do not use. */ | |
1845 RETRO_HW_CONTEXT_DUMMY = INT_MAX | 5087 RETRO_HW_CONTEXT_DUMMY = INT_MAX |
1846 }; | 5088 }; |
1847 | 5089 |
1848 struct retro_hw_render_callback | 5090 struct retro_hw_render_callback |
1849 { | 5091 { |
1935 * down is set if the key is being pressed, or false if it is being released. | 5177 * 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. | 5178 * keycode is the RETROK value of the char. |
1937 * character is the text character of the pressed key. (UTF-32). | 5179 * character is the text character of the pressed key. (UTF-32). |
1938 * key_modifiers is a set of RETROKMOD values or'ed together. | 5180 * key_modifiers is a set of RETROKMOD values or'ed together. |
1939 * | 5181 * |
1940 * The pressed/keycode state can be indepedent of the character. | 5182 * The pressed/keycode state can be independent of the character. |
1941 * It is also possible that multiple characters are generated from a | 5183 * It is also possible that multiple characters are generated from a |
1942 * single keypress. | 5184 * single keypress. |
1943 * Keycode events should be treated separately from character events. | 5185 * Keycode events should be treated separately from character events. |
1944 * However, when possible, the frontend should try to synchronize these. | 5186 * However, when possible, the frontend should try to synchronize these. |
1945 * If only a character is posted, keycode should be RETROK_UNKNOWN. | 5187 * If only a character is posted, keycode should be RETROK_UNKNOWN. |
1946 * | 5188 * |
1947 * Similarily if only a keycode event is generated with no corresponding | 5189 * Similarly if only a keycode event is generated with no corresponding |
1948 * character, character should be 0. | 5190 * character, character should be 0. |
1949 */ | 5191 */ |
1950 typedef void (RETRO_CALLCONV *retro_keyboard_event_t)(bool down, unsigned keycode, | 5192 typedef void (RETRO_CALLCONV *retro_keyboard_event_t)(bool down, unsigned keycode, |
1951 uint32_t character, uint16_t key_modifiers); | 5193 uint32_t character, uint16_t key_modifiers); |
1952 | 5194 |
1953 struct retro_keyboard_callback | 5195 struct retro_keyboard_callback |
1954 { | 5196 { |
1955 retro_keyboard_event_t callback; | 5197 retro_keyboard_event_t callback; |
1956 }; | 5198 }; |
1957 | 5199 |
1958 /* Callbacks for RETRO_ENVIRONMENT_SET_DISK_CONTROL_INTERFACE. | 5200 /** @defgroup SET_DISK_CONTROL_INTERFACE Disk Control |
1959 * Should be set for implementations which can swap out multiple disk | 5201 * |
1960 * images in runtime. | 5202 * Callbacks for inserting and removing disks from the emulated console at runtime. |
1961 * | 5203 * Should be provided by cores that support doing so. |
1962 * If the implementation can do this automatically, it should strive to do so. | 5204 * Cores should automate this process if possible, |
1963 * However, there are cases where the user must manually do so. | 5205 * but some cases require the player's manual input. |
1964 * | 5206 * |
1965 * Overview: To swap a disk image, eject the disk image with | 5207 * The steps for swapping disk images are generally as follows: |
1966 * set_eject_state(true). | 5208 * |
1967 * Set the disk index with set_image_index(index). Insert the disk again | 5209 * \li Eject the emulated console's disk drive with \c set_eject_state(true). |
1968 * with set_eject_state(false). | 5210 * \li Insert the new disk image with \c set_image_index(index). |
1969 */ | 5211 * \li Close the virtual disk tray with \c set_eject_state(false). |
1970 | 5212 * |
1971 /* If ejected is true, "ejects" the virtual disk tray. | 5213 * @{ |
1972 * When ejected, the disk image index can be set. | 5214 */ |
5215 | |
5216 /** | |
5217 * Called by the frontend to open or close the emulated console's virtual disk tray. | |
5218 * | |
5219 * The frontend may only set the disk image index | |
5220 * while the emulated tray is opened. | |
5221 * | |
5222 * If the emulated console's disk tray is already in the state given by \c ejected, | |
5223 * then this function should return \c true without doing anything. | |
5224 * The core should return \c false if it couldn't change the disk tray's state; | |
5225 * this may happen if the console itself limits when the disk tray can be open or closed | |
5226 * (e.g. to wait for the disc to stop spinning). | |
5227 * | |
5228 * @param ejected \c true if the virtual disk tray should be "ejected", | |
5229 * \c false if it should be "closed". | |
5230 * @return \c true if the virtual disk tray's state has been set to the given state, | |
5231 * false if there was an error. | |
5232 * @see retro_get_eject_state_t | |
1973 */ | 5233 */ |
1974 typedef bool (RETRO_CALLCONV *retro_set_eject_state_t)(bool ejected); | 5234 typedef bool (RETRO_CALLCONV *retro_set_eject_state_t)(bool ejected); |
1975 | 5235 |
1976 /* Gets current eject state. The initial state is 'not ejected'. */ | 5236 /** |
5237 * Gets the current ejected state of the disk drive. | |
5238 * The initial state is closed, i.e. \c false. | |
5239 * | |
5240 * @return \c true if the virtual disk tray is "ejected", | |
5241 * i.e. it's open and a disk can be inserted. | |
5242 * @see retro_set_eject_state_t | |
5243 */ | |
1977 typedef bool (RETRO_CALLCONV *retro_get_eject_state_t)(void); | 5244 typedef bool (RETRO_CALLCONV *retro_get_eject_state_t)(void); |
1978 | 5245 |
1979 /* Gets current disk index. First disk is index 0. | 5246 /** |
1980 * If return value is >= get_num_images(), no disk is currently inserted. | 5247 * Gets the index of the current disk image, |
5248 * as determined by however the frontend orders disk images | |
5249 * (such as m3u-formatted playlists or special directories). | |
5250 * | |
5251 * @return The index of the current disk image | |
5252 * (starting with 0 for the first disk), | |
5253 * or a value greater than or equal to \c get_num_images() if no disk is inserted. | |
5254 * @see retro_get_num_images_t | |
1981 */ | 5255 */ |
1982 typedef unsigned (RETRO_CALLCONV *retro_get_image_index_t)(void); | 5256 typedef unsigned (RETRO_CALLCONV *retro_get_image_index_t)(void); |
1983 | 5257 |
1984 /* Sets image index. Can only be called when disk is ejected. | 5258 /** |
1985 * The implementation supports setting "no disk" by using an | 5259 * Inserts the disk image at the given index into the emulated console's drive. |
1986 * index >= get_num_images(). | 5260 * Can only be called while the disk tray is ejected |
5261 * (i.e. \c retro_get_eject_state_t returns \c true). | |
5262 * | |
5263 * If the emulated disk tray is ejected | |
5264 * and already contains the disk image named by \c index, | |
5265 * then this function should do nothing and return \c true. | |
5266 * | |
5267 * @param index The index of the disk image to insert, | |
5268 * starting from 0 for the first disk. | |
5269 * A value greater than or equal to \c get_num_images() | |
5270 * represents the frontend removing the disk without inserting a new one. | |
5271 * @return \c true if the disk image was successfully set. | |
5272 * \c false if the disk tray isn't ejected or there was another error | |
5273 * inserting a new disk image. | |
1987 */ | 5274 */ |
1988 typedef bool (RETRO_CALLCONV *retro_set_image_index_t)(unsigned index); | 5275 typedef bool (RETRO_CALLCONV *retro_set_image_index_t)(unsigned index); |
1989 | 5276 |
1990 /* Gets total number of images which are available to use. */ | 5277 /** |
5278 * @return The number of disk images which are available to use. | |
5279 * These are most likely defined in a playlist file. | |
5280 */ | |
1991 typedef unsigned (RETRO_CALLCONV *retro_get_num_images_t)(void); | 5281 typedef unsigned (RETRO_CALLCONV *retro_get_num_images_t)(void); |
1992 | 5282 |
1993 struct retro_game_info; | 5283 struct retro_game_info; |
1994 | 5284 |
1995 /* Replaces the disk image associated with index. | 5285 /** |
5286 * Replaces the disk image at the given index with a new disk. | |
5287 * | |
5288 * Replaces the disk image associated with index. | |
1996 * Arguments to pass in info have same requirements as retro_load_game(). | 5289 * Arguments to pass in info have same requirements as retro_load_game(). |
1997 * Virtual disk tray must be ejected when calling this. | 5290 * Virtual disk tray must be ejected when calling this. |
1998 * | 5291 * |
1999 * Replacing a disk image with info = NULL will remove the disk image | 5292 * Passing \c NULL to this function indicates |
2000 * from the internal list. | 5293 * that the frontend has removed this disk image from its internal list. |
2001 * As a result, calls to get_image_index() can change. | 5294 * As a result, calls to this function can change the number of available disk indexes. |
2002 * | 5295 * |
2003 * E.g. replace_image_index(1, NULL), and previous get_image_index() | 5296 * For example, calling <tt>replace_image_index(1, NULL)</tt> |
2004 * returned 4 before. | 5297 * will remove the disk image at index 1, |
2005 * Index 1 will be removed, and the new index is 3. | 5298 * and the disk image at index 2 (if any) |
5299 * will be moved to the newly-available index 1. | |
5300 * | |
5301 * @param index The index of the disk image to replace. | |
5302 * @param info Details about the new disk image, | |
5303 * or \c NULL if the disk image at the given index should be discarded. | |
5304 * The semantics of each field are the same as in \c retro_load_game. | |
5305 * @return \c true if the disk image was successfully replaced | |
5306 * or removed from the playlist, | |
5307 * \c false if the tray is not ejected | |
5308 * or if there was an error. | |
2006 */ | 5309 */ |
2007 typedef bool (RETRO_CALLCONV *retro_replace_image_index_t)(unsigned index, | 5310 typedef bool (RETRO_CALLCONV *retro_replace_image_index_t)(unsigned index, |
2008 const struct retro_game_info *info); | 5311 const struct retro_game_info *info); |
2009 | 5312 |
2010 /* Adds a new valid index (get_num_images()) to the internal disk list. | 5313 /** |
2011 * This will increment subsequent return values from get_num_images() by 1. | 5314 * Adds a new index to the core's internal disk list. |
5315 * This will increment the return value from \c get_num_images() by 1. | |
2012 * This image index cannot be used until a disk image has been set | 5316 * This image index cannot be used until a disk image has been set |
2013 * with replace_image_index. */ | 5317 * with \c replace_image_index. |
5318 * | |
5319 * @return \c true if the core has added space for a new disk image | |
5320 * and is ready to receive one. | |
5321 */ | |
2014 typedef bool (RETRO_CALLCONV *retro_add_image_index_t)(void); | 5322 typedef bool (RETRO_CALLCONV *retro_add_image_index_t)(void); |
2015 | 5323 |
5324 /** | |
5325 * Sets the disk image that will be inserted into the emulated disk drive | |
5326 * before \c retro_load_game is called. | |
5327 * | |
5328 * \c retro_load_game does not provide a way to ensure | |
5329 * that a particular disk image in a playlist is inserted into the console; | |
5330 * this function makes up for that. | |
5331 * Frontends should call it immediately before \c retro_load_game, | |
5332 * and the core should use the arguments | |
5333 * to validate the disk image in \c retro_load_game. | |
5334 * | |
5335 * When content is loaded, the core should verify that the | |
5336 * disk specified by \c index can be found at \c path. | |
5337 * This is to guard against auto-selecting the wrong image | |
5338 * if (for example) the user should modify an existing M3U playlist. | |
5339 * We have to let the core handle this because | |
5340 * \c set_initial_image() must be called before loading content, | |
5341 * i.e. the frontend cannot access image paths in advance | |
5342 * and thus cannot perform the error check itself. | |
5343 * If \c index is invalid (i.e. <tt>index >= get_num_images()</tt>) | |
5344 * or the disk image doesn't match the value given in \c path, | |
5345 * the core should ignore the arguments | |
5346 * and insert the disk at index 0 into the virtual disk tray. | |
5347 * | |
5348 * @warning If \c RETRO_ENVIRONMENT_SET_DISK_CONTROL_EXT_INTERFACE is called within \c retro_load_game, | |
5349 * then this function may not be executed. | |
5350 * Set the disk control interface in \c retro_init if possible. | |
5351 * | |
5352 * @param index The index of the disk image within the playlist to set. | |
5353 * @param path The path of the disk image to set as the first. | |
5354 * The core should not load this path immediately; | |
5355 * instead, it should use it within \c retro_load_game | |
5356 * to verify that the correct disk image was loaded. | |
5357 * @return \c true if the initial disk index was set, | |
5358 * \c false if the arguments are invalid | |
5359 * or the core doesn't support this function. | |
5360 */ | |
5361 typedef bool (RETRO_CALLCONV *retro_set_initial_image_t)(unsigned index, const char *path); | |
5362 | |
5363 /** | |
5364 * Returns the path of the disk image at the given index | |
5365 * on the host's file system. | |
5366 * | |
5367 * @param index The index of the disk image to get the path of. | |
5368 * @param path A buffer to store the path in. | |
5369 * @param len The size of \c path, in bytes. | |
5370 * @return \c true if the disk image's location was successfully | |
5371 * queried and copied into \c path, | |
5372 * \c false if the index is invalid | |
5373 * or the core couldn't locate the disk image. | |
5374 */ | |
5375 typedef bool (RETRO_CALLCONV *retro_get_image_path_t)(unsigned index, char *path, size_t len); | |
5376 | |
5377 /** | |
5378 * Returns a friendly label for the given disk image. | |
5379 * | |
5380 * In the simplest case, this may be the disk image's file name | |
5381 * with the extension omitted. | |
5382 * For cores or games with more complex content requirements, | |
5383 * the label can be used to provide information to help the player | |
5384 * select a disk image to insert; | |
5385 * for example, a core may label different kinds of disks | |
5386 * (save data, level disk, installation disk, bonus content, etc.). | |
5387 * with names that correspond to in-game prompts, | |
5388 * so that the frontend can provide better guidance to the player. | |
5389 * | |
5390 * @param index The index of the disk image to return a label for. | |
5391 * @param label A buffer to store the resulting label in. | |
5392 * @param len The length of \c label, in bytes. | |
5393 * @return \c true if the disk image at \c index is valid | |
5394 * and a label was copied into \c label. | |
5395 */ | |
5396 typedef bool (RETRO_CALLCONV *retro_get_image_label_t)(unsigned index, char *label, size_t len); | |
5397 | |
5398 /** | |
5399 * An interface that the frontend can use to exchange disks | |
5400 * within the emulated console's disk drive. | |
5401 * | |
5402 * All function pointers are required. | |
5403 * | |
5404 * @deprecated This struct is superseded by \ref retro_disk_control_ext_callback. | |
5405 * Only use this one to maintain compatibility | |
5406 * with older cores and frontends. | |
5407 * | |
5408 * @see RETRO_ENVIRONMENT_SET_DISK_CONTROL_EXT_INTERFACE | |
5409 * @see retro_disk_control_ext_callback | |
5410 */ | |
2016 struct retro_disk_control_callback | 5411 struct retro_disk_control_callback |
2017 { | 5412 { |
5413 /** @copydoc retro_set_eject_state_t */ | |
2018 retro_set_eject_state_t set_eject_state; | 5414 retro_set_eject_state_t set_eject_state; |
5415 | |
5416 /** @copydoc retro_get_eject_state_t */ | |
2019 retro_get_eject_state_t get_eject_state; | 5417 retro_get_eject_state_t get_eject_state; |
2020 | 5418 |
5419 /** @copydoc retro_get_image_index_t */ | |
2021 retro_get_image_index_t get_image_index; | 5420 retro_get_image_index_t get_image_index; |
5421 | |
5422 /** @copydoc retro_set_image_index_t */ | |
2022 retro_set_image_index_t set_image_index; | 5423 retro_set_image_index_t set_image_index; |
5424 | |
5425 /** @copydoc retro_get_num_images_t */ | |
2023 retro_get_num_images_t get_num_images; | 5426 retro_get_num_images_t get_num_images; |
2024 | 5427 |
5428 /** @copydoc retro_replace_image_index_t */ | |
2025 retro_replace_image_index_t replace_image_index; | 5429 retro_replace_image_index_t replace_image_index; |
5430 | |
5431 /** @copydoc retro_add_image_index_t */ | |
2026 retro_add_image_index_t add_image_index; | 5432 retro_add_image_index_t add_image_index; |
2027 }; | 5433 }; |
2028 | 5434 |
5435 /** | |
5436 * @copybrief retro_disk_control_callback | |
5437 * | |
5438 * All function pointers are required unless otherwise noted. | |
5439 * | |
5440 * @see RETRO_ENVIRONMENT_SET_DISK_CONTROL_EXT_INTERFACE | |
5441 */ | |
5442 struct retro_disk_control_ext_callback | |
5443 { | |
5444 /** @copydoc retro_set_eject_state_t */ | |
5445 retro_set_eject_state_t set_eject_state; | |
5446 | |
5447 /** @copydoc retro_get_eject_state_t */ | |
5448 retro_get_eject_state_t get_eject_state; | |
5449 | |
5450 /** @copydoc retro_get_image_index_t */ | |
5451 retro_get_image_index_t get_image_index; | |
5452 | |
5453 /** @copydoc retro_set_image_index_t */ | |
5454 retro_set_image_index_t set_image_index; | |
5455 | |
5456 /** @copydoc retro_get_num_images_t */ | |
5457 retro_get_num_images_t get_num_images; | |
5458 | |
5459 /** @copydoc retro_replace_image_index_t */ | |
5460 retro_replace_image_index_t replace_image_index; | |
5461 | |
5462 /** @copydoc retro_add_image_index_t */ | |
5463 retro_add_image_index_t add_image_index; | |
5464 | |
5465 /** @copydoc retro_set_initial_image_t | |
5466 * | |
5467 * Optional; not called if \c NULL. | |
5468 * | |
5469 * @note The frontend will only try to record/restore the last-used disk index | |
5470 * if both \c set_initial_image and \c get_image_path are implemented. | |
5471 */ | |
5472 retro_set_initial_image_t set_initial_image; | |
5473 | |
5474 /** | |
5475 * @copydoc retro_get_image_path_t | |
5476 * | |
5477 * Optional; not called if \c NULL. | |
5478 */ | |
5479 retro_get_image_path_t get_image_path; | |
5480 | |
5481 /** | |
5482 * @copydoc retro_get_image_label_t | |
5483 * | |
5484 * Optional; not called if \c NULL. | |
5485 */ | |
5486 retro_get_image_label_t get_image_label; | |
5487 }; | |
5488 | |
5489 /** @} */ | |
5490 | |
5491 /* Definitions for RETRO_ENVIRONMENT_SET_NETPACKET_INTERFACE. | |
5492 * A core can set it if sending and receiving custom network packets | |
5493 * during a multiplayer session is desired. | |
5494 */ | |
5495 | |
5496 /* Netpacket flags for retro_netpacket_send_t */ | |
5497 #define RETRO_NETPACKET_UNRELIABLE 0 /* Packet to be sent unreliable, depending on network quality it might not arrive. */ | |
5498 #define RETRO_NETPACKET_RELIABLE (1 << 0) /* Reliable packets are guaranteed to arrive at the target in the order they were sent. */ | |
5499 #define RETRO_NETPACKET_UNSEQUENCED (1 << 1) /* Packet will not be sequenced with other packets and may arrive out of order. Cannot be set on reliable packets. */ | |
5500 #define RETRO_NETPACKET_FLUSH_HINT (1 << 2) /* Request the packet and any previously buffered ones to be sent immediately */ | |
5501 | |
5502 /* Broadcast client_id for retro_netpacket_send_t */ | |
5503 #define RETRO_NETPACKET_BROADCAST 0xFFFF | |
5504 | |
5505 /* Used by the core to send a packet to one or all connected players. | |
5506 * A single packet sent via this interface can contain up to 64 KB of data. | |
5507 * | |
5508 * The client_id RETRO_NETPACKET_BROADCAST sends the packet as a broadcast to | |
5509 * all connected players. This is supported from the host as well as clients. | |
5510 * Otherwise, the argument indicates the player to send the packet to. | |
5511 * | |
5512 * A frontend must support sending reliable packets (RETRO_NETPACKET_RELIABLE). | |
5513 * Unreliable packets might not be supported by the frontend, but the flags can | |
5514 * still be specified. Reliable transmission will be used instead. | |
5515 * | |
5516 * Calling this with the flag RETRO_NETPACKET_FLUSH_HINT will send off the | |
5517 * packet and any previously buffered ones immediately and without blocking. | |
5518 * To only flush previously queued packets, buf or len can be passed as NULL/0. | |
5519 * | |
5520 * This function is not guaranteed to be thread-safe and must be called during | |
5521 * retro_run or any of the netpacket callbacks passed with this interface. | |
5522 */ | |
5523 typedef void (RETRO_CALLCONV *retro_netpacket_send_t)(int flags, const void* buf, size_t len, uint16_t client_id); | |
5524 | |
5525 /* Optionally read any incoming packets without waiting for the end of the | |
5526 * frame. While polling, retro_netpacket_receive_t and retro_netpacket_stop_t | |
5527 * can be called. The core can perform this in a loop to do a blocking read, | |
5528 * i.e., wait for incoming data, but needs to handle stop getting called and | |
5529 * also give up after a short while to avoid freezing on a connection problem. | |
5530 * It is a good idea to manually flush outgoing packets before calling this. | |
5531 * | |
5532 * This function is not guaranteed to be thread-safe and must be called during | |
5533 * retro_run or any of the netpacket callbacks passed with this interface. | |
5534 */ | |
5535 typedef void (RETRO_CALLCONV *retro_netpacket_poll_receive_t)(void); | |
5536 | |
5537 /* Called by the frontend to signify that a multiplayer session has started. | |
5538 * If client_id is 0 the local player is the host of the session and at this | |
5539 * point no other player has connected yet. | |
5540 * | |
5541 * If client_id is > 0 the local player is a client connected to a host and | |
5542 * at this point is already fully connected to the host. | |
5543 * | |
5544 * The core must store the function pointer send_fn and use it whenever it | |
5545 * wants to send a packet. Optionally poll_receive_fn can be stored and used | |
5546 * when regular receiving between frames is not enough. These function pointers | |
5547 * remain valid until the frontend calls retro_netpacket_stop_t. | |
5548 */ | |
5549 typedef void (RETRO_CALLCONV *retro_netpacket_start_t)(uint16_t client_id, retro_netpacket_send_t send_fn, retro_netpacket_poll_receive_t poll_receive_fn); | |
5550 | |
5551 /* Called by the frontend when a new packet arrives which has been sent from | |
5552 * another player with retro_netpacket_send_t. The client_id argument indicates | |
5553 * who has sent the packet. | |
5554 */ | |
5555 typedef void (RETRO_CALLCONV *retro_netpacket_receive_t)(const void* buf, size_t len, uint16_t client_id); | |
5556 | |
5557 /* Called by the frontend when the multiplayer session has ended. | |
5558 * Once this gets called the function pointers passed to | |
5559 * retro_netpacket_start_t will not be valid anymore. | |
5560 */ | |
5561 typedef void (RETRO_CALLCONV *retro_netpacket_stop_t)(void); | |
5562 | |
5563 /* Called by the frontend every frame (between calls to retro_run while | |
5564 * updating the state of the multiplayer session. | |
5565 * This is a good place for the core to call retro_netpacket_send_t from. | |
5566 */ | |
5567 typedef void (RETRO_CALLCONV *retro_netpacket_poll_t)(void); | |
5568 | |
5569 /* Called by the frontend when a new player connects to the hosted session. | |
5570 * This is only called on the host side, not for clients connected to the host. | |
5571 * If this function returns false, the newly connected player gets dropped. | |
5572 * This can be used for example to limit the number of players. | |
5573 */ | |
5574 typedef bool (RETRO_CALLCONV *retro_netpacket_connected_t)(uint16_t client_id); | |
5575 | |
5576 /* Called by the frontend when a player leaves or disconnects from the hosted session. | |
5577 * This is only called on the host side, not for clients connected to the host. | |
5578 */ | |
5579 typedef void (RETRO_CALLCONV *retro_netpacket_disconnected_t)(uint16_t client_id); | |
5580 | |
5581 /** | |
5582 * A callback interface for giving a core the ability to send and receive custom | |
5583 * network packets during a multiplayer session between two or more instances | |
5584 * of a libretro frontend. | |
5585 * | |
5586 * Normally during connection handshake the frontend will compare library_version | |
5587 * used by both parties and show a warning if there is a difference. When the core | |
5588 * supplies protocol_version, the frontend will check against this instead. | |
5589 * | |
5590 * @see RETRO_ENVIRONMENT_SET_NETPACKET_INTERFACE | |
5591 */ | |
5592 struct retro_netpacket_callback | |
5593 { | |
5594 retro_netpacket_start_t start; | |
5595 retro_netpacket_receive_t receive; | |
5596 retro_netpacket_stop_t stop; /* Optional - may be NULL */ | |
5597 retro_netpacket_poll_t poll; /* Optional - may be NULL */ | |
5598 retro_netpacket_connected_t connected; /* Optional - may be NULL */ | |
5599 retro_netpacket_disconnected_t disconnected; /* Optional - may be NULL */ | |
5600 const char* protocol_version; /* Optional - if not NULL will be used instead of core version to decide if communication is compatible */ | |
5601 }; | |
5602 | |
5603 /** | |
5604 * The pixel format used for rendering. | |
5605 * @see RETRO_ENVIRONMENT_SET_PIXEL_FORMAT | |
5606 */ | |
2029 enum retro_pixel_format | 5607 enum retro_pixel_format |
2030 { | 5608 { |
2031 /* 0RGB1555, native endian. | 5609 /** |
2032 * 0 bit must be set to 0. | 5610 * 0RGB1555, native endian. |
2033 * This pixel format is default for compatibility concerns only. | 5611 * Used as the default if \c RETRO_ENVIRONMENT_SET_PIXEL_FORMAT is not called. |
2034 * If a 15/16-bit pixel format is desired, consider using RGB565. */ | 5612 * The most significant bit must be set to 0. |
5613 * @deprecated This format remains supported to maintain compatibility. | |
5614 * New code should use <tt>RETRO_PIXEL_FORMAT_RGB565</tt> instead. | |
5615 * @see RETRO_PIXEL_FORMAT_RGB565 | |
5616 */ | |
2035 RETRO_PIXEL_FORMAT_0RGB1555 = 0, | 5617 RETRO_PIXEL_FORMAT_0RGB1555 = 0, |
2036 | 5618 |
2037 /* XRGB8888, native endian. | 5619 /** |
2038 * X bits are ignored. */ | 5620 * XRGB8888, native endian. |
5621 * The most significant byte (the <tt>X</tt>) is ignored. | |
5622 */ | |
2039 RETRO_PIXEL_FORMAT_XRGB8888 = 1, | 5623 RETRO_PIXEL_FORMAT_XRGB8888 = 1, |
2040 | 5624 |
2041 /* RGB565, native endian. | 5625 /** |
2042 * This pixel format is the recommended format to use if a 15/16-bit | 5626 * RGB565, native endian. |
2043 * format is desired as it is the pixel format that is typically | 5627 * This format is recommended if 16-bit pixels are desired, |
2044 * available on a wide range of low-power devices. | 5628 * as it is available on a variety of devices and APIs. |
2045 * | 5629 */ |
2046 * It is also natively supported in APIs like OpenGL ES. */ | |
2047 RETRO_PIXEL_FORMAT_RGB565 = 2, | 5630 RETRO_PIXEL_FORMAT_RGB565 = 2, |
2048 | 5631 |
2049 /* Ensure sizeof() == sizeof(int). */ | 5632 /** Defined to ensure that <tt>sizeof(retro_pixel_format) == sizeof(int)</tt>. Do not use. */ |
2050 RETRO_PIXEL_FORMAT_UNKNOWN = INT_MAX | 5633 RETRO_PIXEL_FORMAT_UNKNOWN = INT_MAX |
2051 }; | 5634 }; |
2052 | 5635 |
5636 /** @defgroup GET_SAVESTATE_CONTEXT Savestate Context | |
5637 * @{ | |
5638 */ | |
5639 | |
5640 /** | |
5641 * Details about how the frontend will use savestates. | |
5642 * | |
5643 * @see RETRO_ENVIRONMENT_GET_SAVESTATE_CONTEXT | |
5644 * @see retro_serialize | |
5645 */ | |
5646 enum retro_savestate_context | |
5647 { | |
5648 /** | |
5649 * Standard savestate written to disk. | |
5650 * May be loaded at any time, | |
5651 * even in a separate session or on another device. | |
5652 * | |
5653 * Should not contain any pointers to code or data. | |
5654 */ | |
5655 RETRO_SAVESTATE_CONTEXT_NORMAL = 0, | |
5656 | |
5657 /** | |
5658 * The savestate is guaranteed to be loaded | |
5659 * within the same session, address space, and binary. | |
5660 * Will not be written to disk or sent over the network; | |
5661 * therefore, internal pointers to code or data are acceptable. | |
5662 * May still be loaded or saved at any time. | |
5663 * | |
5664 * @note This context generally implies the use of runahead or rewinding, | |
5665 * which may work by taking savestates multiple times per second. | |
5666 * Savestate code that runs in this context should be fast. | |
5667 */ | |
5668 RETRO_SAVESTATE_CONTEXT_RUNAHEAD_SAME_INSTANCE = 1, | |
5669 | |
5670 /** | |
5671 * The savestate is guaranteed to be loaded | |
5672 * in the same session and by the same binary, | |
5673 * but possibly by a different address space | |
5674 * (e.g. for "second instance" runahead) | |
5675 * | |
5676 * Will not be written to disk or sent over the network, | |
5677 * but may be loaded in a different address space. | |
5678 * Therefore, the savestate <em>must not</em> contain pointers. | |
5679 */ | |
5680 RETRO_SAVESTATE_CONTEXT_RUNAHEAD_SAME_BINARY = 2, | |
5681 | |
5682 /** | |
5683 * The savestate will not be written to disk, | |
5684 * but no other guarantees are made. | |
5685 * The savestate will almost certainly be loaded | |
5686 * by a separate binary, device, and address space. | |
5687 * | |
5688 * This context is intended for use with frontends that support rollback netplay. | |
5689 * Serialized state should omit any data that would unnecessarily increase bandwidth usage. | |
5690 * Must not contain pointers, and integers must be saved in big-endian format. | |
5691 * @see retro_endianness.h | |
5692 * @see network_stream | |
5693 */ | |
5694 RETRO_SAVESTATE_CONTEXT_ROLLBACK_NETPLAY = 3, | |
5695 | |
5696 /** | |
5697 * @private Defined to ensure <tt>sizeof(retro_savestate_context) == sizeof(int)</tt>. | |
5698 * Do not use. | |
5699 */ | |
5700 RETRO_SAVESTATE_CONTEXT_UNKNOWN = INT_MAX | |
5701 }; | |
5702 | |
5703 /** @} */ | |
5704 | |
5705 /** @defgroup SET_MESSAGE User-Visible Messages | |
5706 * | |
5707 * @{ | |
5708 */ | |
5709 | |
5710 /** | |
5711 * Defines a message that the frontend will display to the user, | |
5712 * as determined by <tt>RETRO_ENVIRONMENT_SET_MESSAGE</tt>. | |
5713 * | |
5714 * @deprecated This struct is superseded by \ref retro_message_ext, | |
5715 * which provides more control over how a message is presented. | |
5716 * Only use it for compatibility with older cores and frontends. | |
5717 * | |
5718 * @see RETRO_ENVIRONMENT_SET_MESSAGE | |
5719 * @see retro_message_ext | |
5720 */ | |
2053 struct retro_message | 5721 struct retro_message |
2054 { | 5722 { |
2055 const char *msg; /* Message to be displayed. */ | 5723 /** |
2056 unsigned frames; /* Duration in frames of message. */ | 5724 * Null-terminated message to be displayed. |
5725 * If \c NULL or empty, the message will be ignored. | |
5726 */ | |
5727 const char *msg; | |
5728 | |
5729 /** Duration to display \c msg in frames. */ | |
5730 unsigned frames; | |
2057 }; | 5731 }; |
5732 | |
5733 /** | |
5734 * The method that the frontend will use to display a message to the player. | |
5735 * @see retro_message_ext | |
5736 */ | |
5737 enum retro_message_target | |
5738 { | |
5739 /** | |
5740 * Indicates that the frontend should display the given message | |
5741 * using all other targets defined by \c retro_message_target at once. | |
5742 */ | |
5743 RETRO_MESSAGE_TARGET_ALL = 0, | |
5744 | |
5745 /** | |
5746 * Indicates that the frontend should display the given message | |
5747 * using the frontend's on-screen display, if available. | |
5748 * | |
5749 * @attention If the frontend allows players to customize or disable notifications, | |
5750 * then they may not see messages sent to this target. | |
5751 */ | |
5752 RETRO_MESSAGE_TARGET_OSD, | |
5753 | |
5754 /** | |
5755 * Indicates that the frontend should log the message | |
5756 * via its usual logging mechanism, if available. | |
5757 * | |
5758 * This is not intended to be a substitute for \c RETRO_ENVIRONMENT_SET_LOG_INTERFACE. | |
5759 * It is intended for the common use case of | |
5760 * logging a player-facing message. | |
5761 * | |
5762 * This target should not be used for messages | |
5763 * of type \c RETRO_MESSAGE_TYPE_STATUS or \c RETRO_MESSAGE_TYPE_PROGRESS, | |
5764 * as it may add unnecessary noise to a log file. | |
5765 * | |
5766 * @see RETRO_ENVIRONMENT_SET_LOG_INTERFACE | |
5767 */ | |
5768 RETRO_MESSAGE_TARGET_LOG | |
5769 }; | |
5770 | |
5771 /** | |
5772 * A broad category for the type of message that the frontend will display. | |
5773 * | |
5774 * Each message type has its own use case, | |
5775 * therefore the frontend should present each one differently. | |
5776 * | |
5777 * @note This is a hint that the frontend may ignore. | |
5778 * The frontend should fall back to \c RETRO_MESSAGE_TYPE_NOTIFICATION | |
5779 * for message types that it doesn't support. | |
5780 */ | |
5781 enum retro_message_type | |
5782 { | |
5783 /** | |
5784 * A standard on-screen message. | |
5785 * | |
5786 * Suitable for a variety of use cases, | |
5787 * such as messages about errors | |
5788 * or other important events. | |
5789 * | |
5790 * Frontends that display their own messages | |
5791 * should display this type of core-generated message the same way. | |
5792 */ | |
5793 RETRO_MESSAGE_TYPE_NOTIFICATION = 0, | |
5794 | |
5795 /** | |
5796 * An on-screen message that should be visually distinct | |
5797 * from \c RETRO_MESSAGE_TYPE_NOTIFICATION messages. | |
5798 * | |
5799 * The exact meaning of "visually distinct" is left to the frontend, | |
5800 * but this usually implies that the frontend shows the message | |
5801 * in a way that it doesn't typically use for its own notices. | |
5802 */ | |
5803 RETRO_MESSAGE_TYPE_NOTIFICATION_ALT, | |
5804 | |
5805 /** | |
5806 * Indicates a frequently-updated status display, | |
5807 * rather than a standard notification. | |
5808 * Status messages are intended to be displayed permanently while a core is running | |
5809 * in a way that doesn't suggest user action is required. | |
5810 * | |
5811 * Here are some possible use cases for status messages: | |
5812 * | |
5813 * @li An internal framerate counter. | |
5814 * @li Debugging information. | |
5815 * Remember to let the player disable it in the core options. | |
5816 * @li Core-specific state, such as when a microphone is active. | |
5817 * | |
5818 * The status message is displayed for the given duration, | |
5819 * unless another status message of equal or greater priority is shown. | |
5820 */ | |
5821 RETRO_MESSAGE_TYPE_STATUS, | |
5822 | |
5823 /** | |
5824 * Denotes a message that reports the progress | |
5825 * of a long-running asynchronous task, | |
5826 * such as when a core loads large files from disk or the network. | |
5827 * | |
5828 * The frontend should display messages of this type as a progress bar | |
5829 * (or a progress spinner for indefinite tasks), | |
5830 * where \c retro_message_ext::msg is the progress bar's title | |
5831 * and \c retro_message_ext::progress sets the progress bar's length. | |
5832 * | |
5833 * This message type shouldn't be used for tasks that are expected to complete quickly. | |
5834 */ | |
5835 RETRO_MESSAGE_TYPE_PROGRESS | |
5836 }; | |
5837 | |
5838 /** | |
5839 * A core-provided message that the frontend will display to the player. | |
5840 * | |
5841 * @note The frontend is encouraged store these messages in a queue. | |
5842 * However, it should not empty the queue of core-submitted messages upon exit; | |
5843 * if a core exits with an error, it may want to use this API | |
5844 * to show an error message to the player. | |
5845 * | |
5846 * The frontend should maintain its own copy of the submitted message | |
5847 * and all subobjects, including strings. | |
5848 * | |
5849 * @see RETRO_ENVIRONMENT_SET_MESSAGE_EXT | |
5850 */ | |
5851 struct retro_message_ext | |
5852 { | |
5853 /** | |
5854 * The \c NULL-terminated text of a message to show to the player. | |
5855 * Must not be \c NULL. | |
5856 * | |
5857 * @note The frontend must honor newlines in this string | |
5858 * when rendering text to \c RETRO_MESSAGE_TARGET_OSD. | |
5859 */ | |
5860 const char *msg; | |
5861 | |
5862 /** | |
5863 * The duration that \c msg will be displayed on-screen, in milliseconds. | |
5864 * | |
5865 * Ignored for \c RETRO_MESSAGE_TARGET_LOG. | |
5866 */ | |
5867 unsigned duration; | |
5868 | |
5869 /** | |
5870 * The relative importance of this message | |
5871 * when targeting \c RETRO_MESSAGE_TARGET_OSD. | |
5872 * Higher values indicate higher priority. | |
5873 * | |
5874 * The frontend should use this to prioritize messages | |
5875 * when it can't show all active messages at once, | |
5876 * or to remove messages from its queue if it's full. | |
5877 * | |
5878 * The relative display order of messages with the same priority | |
5879 * is left to the frontend's discretion, | |
5880 * although we suggest breaking ties | |
5881 * in favor of the most recently-submitted message. | |
5882 * | |
5883 * Frontends may handle deprioritized messages at their discretion; | |
5884 * such messages may have their \c duration altered, | |
5885 * be hidden without being delayed, | |
5886 * or even be discarded entirely. | |
5887 * | |
5888 * @note In the reference frontend (RetroArch), | |
5889 * the same priority values are used for frontend-generated notifications, | |
5890 * which are typically between 0 and 3 depending upon importance. | |
5891 * | |
5892 * Ignored for \c RETRO_MESSAGE_TARGET_LOG. | |
5893 */ | |
5894 unsigned priority; | |
5895 | |
5896 /** | |
5897 * The severity level of this message. | |
5898 * | |
5899 * The frontend may use this to filter or customize messages | |
5900 * depending on the player's preferences. | |
5901 * Here are some ideas: | |
5902 * | |
5903 * @li Use this to prioritize errors and warnings | |
5904 * over higher-ranking info and debug messages. | |
5905 * @li Render warnings or errors with extra visual feedback, | |
5906 * e.g. with brighter colors or accompanying sound effects. | |
5907 * | |
5908 * @see RETRO_ENVIRONMENT_SET_LOG_INTERFACE | |
5909 */ | |
5910 enum retro_log_level level; | |
5911 | |
5912 /** | |
5913 * The intended destination of this message. | |
5914 * | |
5915 * @see retro_message_target | |
5916 */ | |
5917 enum retro_message_target target; | |
5918 | |
5919 /** | |
5920 * The intended semantics of this message. | |
5921 * | |
5922 * Ignored for \c RETRO_MESSAGE_TARGET_LOG. | |
5923 * | |
5924 * @see retro_message_type | |
5925 */ | |
5926 enum retro_message_type type; | |
5927 | |
5928 /** | |
5929 * The progress of an asynchronous task. | |
5930 * | |
5931 * A value between 0 and 100 (inclusive) indicates the task's percentage, | |
5932 * and a value of -1 indicates a task of unknown completion. | |
5933 * | |
5934 * @note Since message type is a hint, a frontend may ignore progress values. | |
5935 * Where relevant, a core should include progress percentage within the message string, | |
5936 * such that the message intent remains clear when displayed | |
5937 * as a standard frontend-generated notification. | |
5938 * | |
5939 * Ignored for \c RETRO_MESSAGE_TARGET_LOG and for | |
5940 * message types other than \c RETRO_MESSAGE_TYPE_PROGRESS. | |
5941 */ | |
5942 int8_t progress; | |
5943 }; | |
5944 | |
5945 /** @} */ | |
2058 | 5946 |
2059 /* Describes how the libretro implementation maps a libretro input bind | 5947 /* Describes how the libretro implementation maps a libretro input bind |
2060 * to its internal input system through a human readable string. | 5948 * to its internal input system through a human readable string. |
2061 * This string can be used to better let a user configure input. */ | 5949 * This string can be used to better let a user configure input. */ |
2062 struct retro_input_descriptor | 5950 struct retro_input_descriptor |
2071 * The pointer must remain valid until | 5959 * The pointer must remain valid until |
2072 * retro_unload_game() is called. */ | 5960 * retro_unload_game() is called. */ |
2073 const char *description; | 5961 const char *description; |
2074 }; | 5962 }; |
2075 | 5963 |
5964 /** | |
5965 * Contains basic information about the core. | |
5966 * | |
5967 * @see retro_get_system_info | |
5968 * @warning All pointers are owned by the core | |
5969 * and must remain valid throughout its lifetime. | |
5970 */ | |
2076 struct retro_system_info | 5971 struct retro_system_info |
2077 { | 5972 { |
2078 /* All pointers are owned by libretro implementation, and pointers must | 5973 /** |
2079 * remain valid until retro_deinit() is called. */ | 5974 * Descriptive name of the library. |
2080 | 5975 * |
2081 const char *library_name; /* Descriptive name of library. Should not | 5976 * @note Should not contain any version numbers, etc. |
2082 * contain any version numbers, etc. */ | 5977 */ |
2083 const char *library_version; /* Descriptive version of core. */ | 5978 const char *library_name; |
2084 | 5979 |
2085 const char *valid_extensions; /* A string listing probably content | 5980 /** |
2086 * extensions the core will be able to | 5981 * Descriptive version of the core. |
2087 * load, separated with pipe. | 5982 */ |
2088 * I.e. "bin|rom|iso". | 5983 const char *library_version; |
2089 * Typically used for a GUI to filter | 5984 |
2090 * out extensions. */ | 5985 /** |
2091 | 5986 * A pipe-delimited string list of file extensions that this core can load, e.g. "bin|rom|iso". |
2092 /* If true, retro_load_game() is guaranteed to provide a valid pathname | 5987 * Typically used by a frontend for filtering or core selection. |
2093 * in retro_game_info::path. | 5988 */ |
2094 * ::data and ::size are both invalid. | 5989 const char *valid_extensions; |
2095 * | 5990 |
2096 * If false, ::data and ::size are guaranteed to be valid, but ::path | 5991 /* Libretro cores that need to have direct access to their content |
2097 * might not be valid. | 5992 * files, including cores which use the path of the content files to |
2098 * | 5993 * determine the paths of other files, should set need_fullpath to true. |
2099 * This is typically set to true for libretro implementations that must | 5994 * |
2100 * load from file. | 5995 * Cores should strive for setting need_fullpath to false, |
2101 * Implementations should strive for setting this to false, as it allows | 5996 * as it allows the frontend to perform patching, etc. |
2102 * the frontend to perform patching, etc. */ | 5997 * |
5998 * If need_fullpath is true and retro_load_game() is called: | |
5999 * - retro_game_info::path is guaranteed to have a valid path | |
6000 * - retro_game_info::data and retro_game_info::size are invalid | |
6001 * | |
6002 * If need_fullpath is false and retro_load_game() is called: | |
6003 * - retro_game_info::path may be NULL | |
6004 * - retro_game_info::data and retro_game_info::size are guaranteed | |
6005 * to be valid | |
6006 * | |
6007 * See also: | |
6008 * - RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY | |
6009 * - RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY | |
6010 */ | |
2103 bool need_fullpath; | 6011 bool need_fullpath; |
2104 | 6012 |
2105 /* If true, the frontend is not allowed to extract any archives before | 6013 /* If true, the frontend is not allowed to extract any archives before |
2106 * loading the real content. | 6014 * loading the real content. |
2107 * Necessary for certain libretro implementations that load games | 6015 * Necessary for certain libretro implementations that load games |
2108 * from zipped archives. */ | 6016 * from zipped archives. */ |
2109 bool block_extract; | 6017 bool block_extract; |
2110 }; | 6018 }; |
2111 | 6019 |
6020 /* Defines overrides which modify frontend handling of | |
6021 * specific content file types. | |
6022 * An array of retro_system_content_info_override is | |
6023 * passed to RETRO_ENVIRONMENT_SET_CONTENT_INFO_OVERRIDE | |
6024 * NOTE: In the following descriptions, references to | |
6025 * retro_load_game() may be replaced with | |
6026 * retro_load_game_special() */ | |
6027 struct retro_system_content_info_override | |
6028 { | |
6029 /* A list of file extensions for which the override | |
6030 * should apply, delimited by a 'pipe' character | |
6031 * (e.g. "md|sms|gg") | |
6032 * Permitted file extensions are limited to those | |
6033 * included in retro_system_info::valid_extensions | |
6034 * and/or retro_subsystem_rom_info::valid_extensions */ | |
6035 const char *extensions; | |
6036 | |
6037 /* Overrides the need_fullpath value set in | |
6038 * retro_system_info and/or retro_subsystem_rom_info. | |
6039 * To reiterate: | |
6040 * | |
6041 * If need_fullpath is true and retro_load_game() is called: | |
6042 * - retro_game_info::path is guaranteed to contain a valid | |
6043 * path to an existent file | |
6044 * - retro_game_info::data and retro_game_info::size are invalid | |
6045 * | |
6046 * If need_fullpath is false and retro_load_game() is called: | |
6047 * - retro_game_info::path may be NULL | |
6048 * - retro_game_info::data and retro_game_info::size are guaranteed | |
6049 * to be valid | |
6050 * | |
6051 * In addition: | |
6052 * | |
6053 * If need_fullpath is true and retro_load_game() is called: | |
6054 * - retro_game_info_ext::full_path is guaranteed to contain a valid | |
6055 * path to an existent file | |
6056 * - retro_game_info_ext::archive_path may be NULL | |
6057 * - retro_game_info_ext::archive_file may be NULL | |
6058 * - retro_game_info_ext::dir is guaranteed to contain a valid path | |
6059 * to the directory in which the content file exists | |
6060 * - retro_game_info_ext::name is guaranteed to contain the | |
6061 * basename of the content file, without extension | |
6062 * - retro_game_info_ext::ext is guaranteed to contain the | |
6063 * extension of the content file in lower case format | |
6064 * - retro_game_info_ext::data and retro_game_info_ext::size | |
6065 * are invalid | |
6066 * | |
6067 * If need_fullpath is false and retro_load_game() is called: | |
6068 * - If retro_game_info_ext::file_in_archive is false: | |
6069 * - retro_game_info_ext::full_path is guaranteed to contain | |
6070 * a valid path to an existent file | |
6071 * - retro_game_info_ext::archive_path may be NULL | |
6072 * - retro_game_info_ext::archive_file may be NULL | |
6073 * - retro_game_info_ext::dir is guaranteed to contain a | |
6074 * valid path to the directory in which the content file exists | |
6075 * - retro_game_info_ext::name is guaranteed to contain the | |
6076 * basename of the content file, without extension | |
6077 * - retro_game_info_ext::ext is guaranteed to contain the | |
6078 * extension of the content file in lower case format | |
6079 * - If retro_game_info_ext::file_in_archive is true: | |
6080 * - retro_game_info_ext::full_path may be NULL | |
6081 * - retro_game_info_ext::archive_path is guaranteed to | |
6082 * contain a valid path to an existent compressed file | |
6083 * inside which the content file is located | |
6084 * - retro_game_info_ext::archive_file is guaranteed to | |
6085 * contain a valid path to an existent content file | |
6086 * inside the compressed file referred to by | |
6087 * retro_game_info_ext::archive_path | |
6088 * e.g. for a compressed file '/path/to/foo.zip' | |
6089 * containing 'bar.sfc' | |
6090 * > retro_game_info_ext::archive_path will be '/path/to/foo.zip' | |
6091 * > retro_game_info_ext::archive_file will be 'bar.sfc' | |
6092 * - retro_game_info_ext::dir is guaranteed to contain a | |
6093 * valid path to the directory in which the compressed file | |
6094 * (containing the content file) exists | |
6095 * - retro_game_info_ext::name is guaranteed to contain | |
6096 * EITHER | |
6097 * 1) the basename of the compressed file (containing | |
6098 * the content file), without extension | |
6099 * OR | |
6100 * 2) the basename of the content file inside the | |
6101 * compressed file, without extension | |
6102 * In either case, a core should consider 'name' to | |
6103 * be the canonical name/ID of the the content file | |
6104 * - retro_game_info_ext::ext is guaranteed to contain the | |
6105 * extension of the content file inside the compressed file, | |
6106 * in lower case format | |
6107 * - retro_game_info_ext::data and retro_game_info_ext::size are | |
6108 * guaranteed to be valid */ | |
6109 bool need_fullpath; | |
6110 | |
6111 /* If need_fullpath is false, specifies whether the content | |
6112 * data buffer available in retro_load_game() is 'persistent' | |
6113 * | |
6114 * If persistent_data is false and retro_load_game() is called: | |
6115 * - retro_game_info::data and retro_game_info::size | |
6116 * are valid only until retro_load_game() returns | |
6117 * - retro_game_info_ext::data and retro_game_info_ext::size | |
6118 * are valid only until retro_load_game() returns | |
6119 * | |
6120 * If persistent_data is true and retro_load_game() is called: | |
6121 * - retro_game_info::data and retro_game_info::size | |
6122 * are valid until retro_deinit() returns | |
6123 * - retro_game_info_ext::data and retro_game_info_ext::size | |
6124 * are valid until retro_deinit() returns */ | |
6125 bool persistent_data; | |
6126 }; | |
6127 | |
6128 /* Similar to retro_game_info, but provides extended | |
6129 * information about the source content file and | |
6130 * game memory buffer status. | |
6131 * And array of retro_game_info_ext is returned by | |
6132 * RETRO_ENVIRONMENT_GET_GAME_INFO_EXT | |
6133 * NOTE: In the following descriptions, references to | |
6134 * retro_load_game() may be replaced with | |
6135 * retro_load_game_special() */ | |
6136 struct retro_game_info_ext | |
6137 { | |
6138 /* - If file_in_archive is false, contains a valid | |
6139 * path to an existent content file (UTF-8 encoded) | |
6140 * - If file_in_archive is true, may be NULL */ | |
6141 const char *full_path; | |
6142 | |
6143 /* - If file_in_archive is false, may be NULL | |
6144 * - If file_in_archive is true, contains a valid path | |
6145 * to an existent compressed file inside which the | |
6146 * content file is located (UTF-8 encoded) */ | |
6147 const char *archive_path; | |
6148 | |
6149 /* - If file_in_archive is false, may be NULL | |
6150 * - If file_in_archive is true, contain a valid path | |
6151 * to an existent content file inside the compressed | |
6152 * file referred to by archive_path (UTF-8 encoded) | |
6153 * e.g. for a compressed file '/path/to/foo.zip' | |
6154 * containing 'bar.sfc' | |
6155 * > archive_path will be '/path/to/foo.zip' | |
6156 * > archive_file will be 'bar.sfc' */ | |
6157 const char *archive_file; | |
6158 | |
6159 /* - If file_in_archive is false, contains a valid path | |
6160 * to the directory in which the content file exists | |
6161 * (UTF-8 encoded) | |
6162 * - If file_in_archive is true, contains a valid path | |
6163 * to the directory in which the compressed file | |
6164 * (containing the content file) exists (UTF-8 encoded) */ | |
6165 const char *dir; | |
6166 | |
6167 /* Contains the canonical name/ID of the content file | |
6168 * (UTF-8 encoded). Intended for use when identifying | |
6169 * 'complementary' content named after the loaded file - | |
6170 * i.e. companion data of a different format (a CD image | |
6171 * required by a ROM), texture packs, internally handled | |
6172 * save files, etc. | |
6173 * - If file_in_archive is false, contains the basename | |
6174 * of the content file, without extension | |
6175 * - If file_in_archive is true, then string is | |
6176 * implementation specific. A frontend may choose to | |
6177 * set a name value of: | |
6178 * EITHER | |
6179 * 1) the basename of the compressed file (containing | |
6180 * the content file), without extension | |
6181 * OR | |
6182 * 2) the basename of the content file inside the | |
6183 * compressed file, without extension | |
6184 * RetroArch sets the 'name' value according to (1). | |
6185 * A frontend that supports routine loading of | |
6186 * content from archives containing multiple unrelated | |
6187 * content files may set the 'name' value according | |
6188 * to (2). */ | |
6189 const char *name; | |
6190 | |
6191 /* - If file_in_archive is false, contains the extension | |
6192 * of the content file in lower case format | |
6193 * - If file_in_archive is true, contains the extension | |
6194 * of the content file inside the compressed file, | |
6195 * in lower case format */ | |
6196 const char *ext; | |
6197 | |
6198 /* String of implementation specific meta-data. */ | |
6199 const char *meta; | |
6200 | |
6201 /* Memory buffer of loaded game content. Will be NULL: | |
6202 * IF | |
6203 * - retro_system_info::need_fullpath is true and | |
6204 * retro_system_content_info_override::need_fullpath | |
6205 * is unset | |
6206 * OR | |
6207 * - retro_system_content_info_override::need_fullpath | |
6208 * is true */ | |
6209 const void *data; | |
6210 | |
6211 /* Size of game content memory buffer, in bytes */ | |
6212 size_t size; | |
6213 | |
6214 /* True if loaded content file is inside a compressed | |
6215 * archive */ | |
6216 bool file_in_archive; | |
6217 | |
6218 /* - If data is NULL, value is unset/ignored | |
6219 * - If data is non-NULL: | |
6220 * - If persistent_data is false, data and size are | |
6221 * valid only until retro_load_game() returns | |
6222 * - If persistent_data is true, data and size are | |
6223 * are valid until retro_deinit() returns */ | |
6224 bool persistent_data; | |
6225 }; | |
6226 | |
6227 /** | |
6228 * Parameters describing the size and shape of the video frame. | |
6229 * @see retro_system_av_info | |
6230 * @see RETRO_ENVIRONMENT_SET_SYSTEM_AV_INFO | |
6231 * @see RETRO_ENVIRONMENT_SET_GEOMETRY | |
6232 * @see retro_get_system_av_info | |
6233 */ | |
2112 struct retro_game_geometry | 6234 struct retro_game_geometry |
2113 { | 6235 { |
2114 unsigned base_width; /* Nominal video width of game. */ | 6236 /** |
2115 unsigned base_height; /* Nominal video height of game. */ | 6237 * Nominal video width of game, in pixels. |
2116 unsigned max_width; /* Maximum possible width of game. */ | 6238 * This will typically be the emulated platform's native video width |
6239 * (or its smallest, if the original hardware supports multiple resolutions). | |
6240 */ | |
6241 unsigned base_width; | |
6242 | |
6243 /** | |
6244 * Nominal video height of game, in pixels. | |
6245 * This will typically be the emulated platform's native video height | |
6246 * (or its smallest, if the original hardware supports multiple resolutions). | |
6247 */ | |
6248 unsigned base_height; | |
6249 | |
6250 /** | |
6251 * Maximum possible width of the game screen, in pixels. | |
6252 * This will typically be the emulated platform's maximum video width. | |
6253 * For cores that emulate platforms with multiple screens (such as the Nintendo DS), | |
6254 * this should assume the core's widest possible screen layout (e.g. side-by-side). | |
6255 * For cores that support upscaling the resolution, | |
6256 * this should assume the highest supported scale factor is active. | |
6257 */ | |
6258 unsigned max_width; | |
6259 | |
6260 /** | |
6261 * Maximum possible height of the game screen, in pixels. | |
6262 * This will typically be the emulated platform's maximum video height. | |
6263 * For cores that emulate platforms with multiple screens (such as the Nintendo DS), | |
6264 * this should assume the core's tallest possible screen layout (e.g. vertical). | |
6265 * For cores that support upscaling the resolution, | |
6266 * this should assume the highest supported scale factor is active. | |
6267 */ | |
2117 unsigned max_height; /* Maximum possible height of game. */ | 6268 unsigned max_height; /* Maximum possible height of game. */ |
2118 | 6269 |
2119 float aspect_ratio; /* Nominal aspect ratio of game. If | 6270 /** |
2120 * aspect_ratio is <= 0.0, an aspect ratio | 6271 * Nominal aspect ratio of game. |
2121 * of base_width / base_height is assumed. | 6272 * If zero or less, |
2122 * A frontend could override this setting, | 6273 * an aspect ratio of <tt>base_width / base_height</tt> is assumed. |
2123 * if desired. */ | 6274 * |
6275 * @note A frontend may ignore this setting. | |
6276 */ | |
6277 float aspect_ratio; | |
2124 }; | 6278 }; |
2125 | 6279 |
6280 /** | |
6281 * Parameters describing the timing of the video and audio. | |
6282 * @see retro_system_av_info | |
6283 * @see RETRO_ENVIRONMENT_SET_SYSTEM_AV_INFO | |
6284 * @see retro_get_system_av_info | |
6285 */ | |
2126 struct retro_system_timing | 6286 struct retro_system_timing |
2127 { | 6287 { |
2128 double fps; /* FPS of video content. */ | 6288 /** Video output refresh rate, in frames per second. */ |
2129 double sample_rate; /* Sampling rate of audio. */ | 6289 double fps; |
6290 | |
6291 /** The audio output sample rate, in Hz. */ | |
6292 double sample_rate; | |
2130 }; | 6293 }; |
2131 | 6294 |
6295 /** | |
6296 * Configures how the core's audio and video should be updated. | |
6297 * @see RETRO_ENVIRONMENT_SET_SYSTEM_AV_INFO | |
6298 * @see retro_get_system_av_info | |
6299 */ | |
2132 struct retro_system_av_info | 6300 struct retro_system_av_info |
2133 { | 6301 { |
6302 /** Parameters describing the size and shape of the video frame. */ | |
2134 struct retro_game_geometry geometry; | 6303 struct retro_game_geometry geometry; |
6304 | |
6305 /** Parameters describing the timing of the video and audio. */ | |
2135 struct retro_system_timing timing; | 6306 struct retro_system_timing timing; |
2136 }; | 6307 }; |
2137 | 6308 |
6309 /** @defgroup SET_CORE_OPTIONS Core Options | |
6310 * @{ | |
6311 */ | |
6312 | |
6313 /** | |
6314 * Represents \ref RETRO_ENVIRONMENT_GET_VARIABLE "a core option query". | |
6315 * | |
6316 * @note In \ref RETRO_ENVIRONMENT_SET_VARIABLES | |
6317 * (which is a deprecated API), | |
6318 * this \c struct serves as an option definition. | |
6319 * | |
6320 * @see RETRO_ENVIRONMENT_GET_VARIABLE | |
6321 */ | |
2138 struct retro_variable | 6322 struct retro_variable |
2139 { | 6323 { |
2140 /* Variable to query in RETRO_ENVIRONMENT_GET_VARIABLE. | 6324 /** |
2141 * If NULL, obtains the complete environment string if more | 6325 * A unique key identifying this option. |
2142 * complex parsing is necessary. | 6326 * |
2143 * The environment string is formatted as key-value pairs | 6327 * Should be a key for an option that was previously defined |
2144 * delimited by semicolons as so: | 6328 * with \ref RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2 or similar. |
2145 * "key1=value1;key2=value2;..." | 6329 * |
6330 * Should be prefixed with the core's name | |
6331 * to minimize the risk of collisions with another core's options, | |
6332 * as frontends are not required to use a namespacing scheme for storing options. | |
6333 * For example, a core named "foo" might define an option named "foo_option". | |
6334 * | |
6335 * @note In \ref RETRO_ENVIRONMENT_SET_VARIABLES | |
6336 * (which is a deprecated API), | |
6337 * this field is used to define an option | |
6338 * named by this key. | |
2146 */ | 6339 */ |
2147 const char *key; | 6340 const char *key; |
2148 | 6341 |
2149 /* Value to be obtained. If key does not exist, it is set to NULL. */ | 6342 /** |
6343 * Value to be obtained. | |
6344 * | |
6345 * Set by the frontend to \c NULL if | |
6346 * the option named by \ref key does not exist. | |
6347 * | |
6348 * @note In \ref RETRO_ENVIRONMENT_SET_VARIABLES | |
6349 * (which is a deprecated API), | |
6350 * this field is set by the core to define the possible values | |
6351 * for an option named by \ref key. | |
6352 * When used this way, it must be formatted as follows: | |
6353 * @li The text before the first ';' is the option's human-readable title. | |
6354 * @li A single space follows the ';'. | |
6355 * @li The rest of the string is a '|'-delimited list of possible values, | |
6356 * with the first one being the default. | |
6357 */ | |
2150 const char *value; | 6358 const char *value; |
2151 }; | 6359 }; |
6360 | |
6361 /** | |
6362 * An argument that's used to show or hide a core option in the frontend. | |
6363 * | |
6364 * @see RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY | |
6365 */ | |
6366 struct retro_core_option_display | |
6367 { | |
6368 /** | |
6369 * The key for a core option that was defined with \ref RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2, | |
6370 * \ref RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2_INTL, | |
6371 * or their legacy equivalents. | |
6372 */ | |
6373 const char *key; | |
6374 | |
6375 /** | |
6376 * Whether the option named by \c key | |
6377 * should be displayed to the player in the frontend's core options menu. | |
6378 * | |
6379 * @note This value is a hint, \em not a requirement; | |
6380 * the frontend is free to ignore this field. | |
6381 */ | |
6382 bool visible; | |
6383 }; | |
6384 | |
6385 /** | |
6386 * The maximum number of choices that can be defined for a given core option. | |
6387 * | |
6388 * This limit was chosen as a compromise between | |
6389 * a core's flexibility and a streamlined user experience. | |
6390 * | |
6391 * @note A guiding principle of libretro's API design is that | |
6392 * all common interactions (gameplay, menu navigation, etc.) | |
6393 * should be possible without a keyboard. | |
6394 * | |
6395 * If you need more than 128 choices for a core option, | |
6396 * consider simplifying your option structure. | |
6397 * Here are some ideas: | |
6398 * | |
6399 * \li If a core option represents a numeric value, | |
6400 * consider reducing the option's granularity | |
6401 * (e.g. define time limits in increments of 5 seconds instead of 1 second). | |
6402 * Providing a fixed set of values based on experimentation | |
6403 * is also a good idea. | |
6404 * \li If a core option represents a dynamically-built list of files, | |
6405 * consider leaving out files that won't be useful. | |
6406 * For example, if a core allows the player to choose a specific BIOS file, | |
6407 * it can omit files of the wrong length or without a valid header. | |
6408 * | |
6409 * @see retro_core_option_definition | |
6410 * @see retro_core_option_v2_definition | |
6411 */ | |
6412 #define RETRO_NUM_CORE_OPTION_VALUES_MAX 128 | |
6413 | |
6414 /** | |
6415 * A descriptor for a particular choice within a core option. | |
6416 * | |
6417 * @note All option values are represented as strings. | |
6418 * If you need to represent any other type, | |
6419 * parse the string in \ref value. | |
6420 * | |
6421 * @see retro_core_option_v2_category | |
6422 */ | |
6423 struct retro_core_option_value | |
6424 { | |
6425 /** | |
6426 * The option value that the frontend will serialize. | |
6427 * | |
6428 * Must not be \c NULL or empty. | |
6429 * No other hard limits are placed on this value's contents, | |
6430 * but here are some suggestions: | |
6431 * | |
6432 * \li If the value represents a number, | |
6433 * don't include any non-digit characters (units, separators, etc.). | |
6434 * Instead, include that information in \c label. | |
6435 * This will simplify parsing. | |
6436 * \li If the value represents a file path, | |
6437 * store it as a relative path with respect to one of the common libretro directories | |
6438 * (e.g. \ref RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY "the system directory" | |
6439 * or \ref RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY "the save directory"), | |
6440 * and use forward slashes (\c "/") as directory separators. | |
6441 * This will simplify cloud storage if supported by the frontend, | |
6442 * as the same file may be used on multiple devices. | |
6443 */ | |
6444 const char *value; | |
6445 | |
6446 /** | |
6447 * Human-readable name for \c value that the frontend should show to players. | |
6448 * | |
6449 * May be \c NULL, in which case the frontend | |
6450 * should display \c value itself. | |
6451 * | |
6452 * Here are some guidelines for writing a good label: | |
6453 * | |
6454 * \li Make the option labels obvious | |
6455 * so that they don't need to be explained in the description. | |
6456 * \li Keep labels short, and don't use unnecessary words. | |
6457 * For example, "OpenGL" is a better label than "OpenGL Mode". | |
6458 * \li If the option represents a number, | |
6459 * consider adding units, separators, or other punctuation | |
6460 * into the label itself. | |
6461 * For example, "5 seconds" is a better label than "5". | |
6462 * \li If the option represents a number, use intuitive units | |
6463 * that don't take a lot of digits to express. | |
6464 * For example, prefer "1 minute" over "60 seconds" or "60,000 milliseconds". | |
6465 */ | |
6466 const char *label; | |
6467 }; | |
6468 | |
6469 /** | |
6470 * @copybrief retro_core_option_v2_definition | |
6471 * | |
6472 * @deprecated Use \ref retro_core_option_v2_definition instead, | |
6473 * as it supports categorizing options into groups. | |
6474 * Only use this \c struct to support older frontends or cores. | |
6475 * | |
6476 * @see RETRO_ENVIRONMENT_SET_CORE_OPTIONS | |
6477 * @see RETRO_ENVIRONMENT_SET_CORE_OPTIONS_INTL | |
6478 */ | |
6479 struct retro_core_option_definition | |
6480 { | |
6481 /** @copydoc retro_core_option_v2_definition::key */ | |
6482 const char *key; | |
6483 | |
6484 /** @copydoc retro_core_option_v2_definition::desc */ | |
6485 const char *desc; | |
6486 | |
6487 /** @copydoc retro_core_option_v2_definition::info */ | |
6488 const char *info; | |
6489 | |
6490 /** @copydoc retro_core_option_v2_definition::values */ | |
6491 struct retro_core_option_value values[RETRO_NUM_CORE_OPTION_VALUES_MAX]; | |
6492 | |
6493 /** @copydoc retro_core_option_v2_definition::default_value */ | |
6494 const char *default_value; | |
6495 }; | |
6496 | |
6497 #ifdef __PS3__ | |
6498 #undef local | |
6499 #endif | |
6500 | |
6501 /** | |
6502 * A variant of \ref retro_core_options that supports internationalization. | |
6503 * | |
6504 * @deprecated Use \ref retro_core_options_v2_intl instead, | |
6505 * as it supports categorizing options into groups. | |
6506 * Only use this \c struct to support older frontends or cores. | |
6507 * | |
6508 * @see retro_core_options | |
6509 * @see RETRO_ENVIRONMENT_SET_CORE_OPTIONS_INTL | |
6510 * @see RETRO_ENVIRONMENT_GET_LANGUAGE | |
6511 * @see retro_language | |
6512 */ | |
6513 struct retro_core_options_intl | |
6514 { | |
6515 /** @copydoc retro_core_options_v2_intl::us */ | |
6516 struct retro_core_option_definition *us; | |
6517 | |
6518 /** @copydoc retro_core_options_v2_intl::local */ | |
6519 struct retro_core_option_definition *local; | |
6520 }; | |
6521 | |
6522 /** | |
6523 * A descriptor for a group of related core options. | |
6524 * | |
6525 * Here's an example category: | |
6526 * | |
6527 * @code | |
6528 * { | |
6529 * "cpu", | |
6530 * "CPU Emulation", | |
6531 * "Settings for CPU quirks." | |
6532 * } | |
6533 * @endcode | |
6534 * | |
6535 * @see retro_core_options_v2 | |
6536 * @see RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2 | |
6537 * @see RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2_INTL | |
6538 */ | |
6539 struct retro_core_option_v2_category | |
6540 { | |
6541 /** | |
6542 * A string that uniquely identifies this category within the core's options. | |
6543 * Any \c retro_core_option_v2_definition whose \c category_key matches this | |
6544 * is considered to be within this category. | |
6545 * Different cores may use the same category keys, | |
6546 * so namespacing them is not necessary. | |
6547 * Valid characters are <tt>[a-zA-Z0-9_-]</tt>. | |
6548 * | |
6549 * Frontends should use this category to organize core options, | |
6550 * but may customize this category's presentation in other ways. | |
6551 * For example, a frontend may use common keys like "audio" or "gfx" | |
6552 * to select an appropriate icon in its UI. | |
6553 * | |
6554 * Required; must not be \c NULL. | |
6555 */ | |
6556 const char *key; | |
6557 | |
6558 /** | |
6559 * A brief human-readable name for this category, | |
6560 * intended for the frontend to display to the player. | |
6561 * This should be a name that's concise and descriptive, such as "Audio" or "Video". | |
6562 * | |
6563 * Required; must not be \c NULL. | |
6564 */ | |
6565 const char *desc; | |
6566 | |
6567 /** | |
6568 * A human-readable description for this category, | |
6569 * intended for the frontend to display to the player | |
6570 * as secondary help text (e.g. a sublabel or a tooltip). | |
6571 * Optional; may be \c NULL or an empty string. | |
6572 */ | |
6573 const char *info; | |
6574 }; | |
6575 | |
6576 /** | |
6577 * A descriptor for a particular core option and the values it may take. | |
6578 * | |
6579 * Supports categorizing options into groups, | |
6580 * so as not to overwhelm the player. | |
6581 * | |
6582 * @see retro_core_option_v2_category | |
6583 * @see RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2 | |
6584 * @see RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2_INTL | |
6585 */ | |
6586 struct retro_core_option_v2_definition | |
6587 { | |
6588 /** | |
6589 * A unique identifier for this option that cores may use | |
6590 * \ref RETRO_ENVIRONMENT_GET_VARIABLE "to query its value from the frontend". | |
6591 * Must be unique within this core. | |
6592 * | |
6593 * Should be unique globally; | |
6594 * the recommended method for doing so | |
6595 * is to prefix each option with the core's name. | |
6596 * For example, an option that controls the resolution for a core named "foo" | |
6597 * should be named \c "foo_resolution". | |
6598 * | |
6599 * Valid key characters are in the set <tt>[a-zA-Z0-9_-]</tt>. | |
6600 */ | |
6601 const char *key; | |
6602 | |
6603 /** | |
6604 * A human-readable name for this option, | |
6605 * intended to be displayed by frontends that don't support | |
6606 * categorizing core options. | |
6607 * | |
6608 * Required; must not be \c NULL or empty. | |
6609 */ | |
6610 const char *desc; | |
6611 | |
6612 /** | |
6613 * A human-readable name for this option, | |
6614 * intended to be displayed by frontends that support | |
6615 * categorizing core options. | |
6616 * | |
6617 * This version may be slightly more concise than \ref desc, | |
6618 * as it can rely on the structure of the options menu. | |
6619 * For example, "Interface" is a good \c desc_categorized, | |
6620 * as it can be displayed as a sublabel for a "Network" category. | |
6621 * For \c desc, "Network Interface" would be more suitable. | |
6622 * | |
6623 * Optional; if this field or \c category_key is empty or \c NULL, | |
6624 * \c desc will be used instead. | |
6625 */ | |
6626 const char *desc_categorized; | |
6627 | |
6628 /** | |
6629 * A human-readable description of this option and its effects, | |
6630 * intended to be displayed by frontends that don't support | |
6631 * categorizing core options. | |
6632 * | |
6633 * @details Intended to be displayed as secondary help text, | |
6634 * such as a tooltip or a sublabel. | |
6635 * | |
6636 * Here are some suggestions for writing a good description: | |
6637 * | |
6638 * \li Avoid technical jargon unless this option is meant for advanced users. | |
6639 * If unavoidable, suggest one of the default options for those unsure. | |
6640 * \li Don't repeat the option name in the description; | |
6641 * instead, describe what the option name means. | |
6642 * \li If an option requires a core restart or game reset to take effect, | |
6643 * be sure to say so. | |
6644 * \li Try to make the option labels obvious | |
6645 * so that they don't need to be explained in the description. | |
6646 * | |
6647 * Optional; may be \c NULL. | |
6648 */ | |
6649 const char *info; | |
6650 | |
6651 /** | |
6652 * @brief A human-readable description of this option and its effects, | |
6653 * intended to be displayed by frontends that support | |
6654 * categorizing core options. | |
6655 * | |
6656 * This version is provided to accommodate descriptions | |
6657 * that reference other options by name, | |
6658 * as options may have different user-facing names | |
6659 * depending on whether the frontend supports categorization. | |
6660 * | |
6661 * @copydetails info | |
6662 * | |
6663 * If empty or \c NULL, \c info will be used instead. | |
6664 * Will be ignored if \c category_key is empty or \c NULL. | |
6665 */ | |
6666 const char *info_categorized; | |
6667 | |
6668 /** | |
6669 * The key of the category that this option belongs to. | |
6670 * | |
6671 * Optional; if equal to \ref retro_core_option_v2_category::key "a defined category", | |
6672 * then this option shall be displayed by the frontend | |
6673 * next to other options in this same category, | |
6674 * assuming it supports doing so. | |
6675 * Option categories are intended to be displayed in a submenu, | |
6676 * but this isn't a hard requirement. | |
6677 * | |
6678 * If \c NULL, empty, or not equal to a defined category, | |
6679 * then this option is considered uncategorized | |
6680 * and the frontend shall display it outside of any category | |
6681 * (most likely at a top-level menu). | |
6682 * | |
6683 * @see retro_core_option_v2_category | |
6684 */ | |
6685 const char *category_key; | |
6686 | |
6687 /** | |
6688 * One or more possible values for this option, | |
6689 * up to the limit of \ref RETRO_NUM_CORE_OPTION_VALUES_MAX. | |
6690 * | |
6691 * Terminated by a \c { NULL, NULL } element, | |
6692 * although frontends should work even if all elements are used. | |
6693 */ | |
6694 struct retro_core_option_value values[RETRO_NUM_CORE_OPTION_VALUES_MAX]; | |
6695 | |
6696 /** | |
6697 * The default value for this core option. | |
6698 * Used if it hasn't been set, e.g. for new cores. | |
6699 * Must equal one of the \ref value members in the \c values array, | |
6700 * or else this option will be ignored. | |
6701 */ | |
6702 const char *default_value; | |
6703 }; | |
6704 | |
6705 /** | |
6706 * A set of core option descriptors and the categories that group them, | |
6707 * suitable for enabling a core to be customized. | |
6708 * | |
6709 * @see RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2 | |
6710 */ | |
6711 struct retro_core_options_v2 | |
6712 { | |
6713 /** | |
6714 * An array of \ref retro_core_option_v2_category "option categories", | |
6715 * terminated by a zeroed-out category \c struct. | |
6716 * | |
6717 * Will be ignored if the frontend doesn't support core option categories. | |
6718 * | |
6719 * If \c NULL or ignored, all options will be treated as uncategorized. | |
6720 * This most likely means that a frontend will display them at a top-level menu | |
6721 * without any kind of hierarchy or grouping. | |
6722 */ | |
6723 struct retro_core_option_v2_category *categories; | |
6724 | |
6725 /** | |
6726 * An array of \ref retro_core_option_v2_definition "core option descriptors", | |
6727 * terminated by a zeroed-out definition \c struct. | |
6728 * | |
6729 * Required; must not be \c NULL. | |
6730 */ | |
6731 struct retro_core_option_v2_definition *definitions; | |
6732 }; | |
6733 | |
6734 /** | |
6735 * A variant of \ref retro_core_options_v2 that supports internationalization. | |
6736 * | |
6737 * @see retro_core_options_v2 | |
6738 * @see RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2_INTL | |
6739 * @see RETRO_ENVIRONMENT_GET_LANGUAGE | |
6740 * @see retro_language | |
6741 */ | |
6742 struct retro_core_options_v2_intl | |
6743 { | |
6744 /** | |
6745 * Pointer to a core options set | |
6746 * whose text is written in American English. | |
6747 * | |
6748 * This may be passed to \c RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2 as-is | |
6749 * if not using \c RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2_INTL. | |
6750 * | |
6751 * Required; must not be \c NULL. | |
6752 */ | |
6753 struct retro_core_options_v2 *us; | |
6754 | |
6755 /** | |
6756 * Pointer to a core options set | |
6757 * whose text is written in one of libretro's \ref retro_language "supported languages", | |
6758 * most likely the one returned by \ref RETRO_ENVIRONMENT_GET_LANGUAGE. | |
6759 * | |
6760 * Structure is the same, but usage is slightly different: | |
6761 * | |
6762 * \li All text (except for keys and option values) | |
6763 * should be written in whichever language | |
6764 * is returned by \c RETRO_ENVIRONMENT_GET_LANGUAGE. | |
6765 * \li All fields besides keys and option values may be \c NULL, | |
6766 * in which case the corresponding string in \c us | |
6767 * is used instead. | |
6768 * \li All \ref retro_core_option_v2_definition::default_value "default option values" | |
6769 * are taken from \c us. | |
6770 * The defaults in this field are ignored. | |
6771 * | |
6772 * May be \c NULL, in which case \c us is used instead. | |
6773 */ | |
6774 struct retro_core_options_v2 *local; | |
6775 }; | |
6776 | |
6777 /** | |
6778 * Called by the frontend to determine if any core option's visibility has changed. | |
6779 * | |
6780 * Each time a frontend sets a core option, | |
6781 * it should call this function to see if | |
6782 * any core option should be made visible or invisible. | |
6783 * | |
6784 * May also be called after \ref retro_load_game "loading a game", | |
6785 * to determine what the initial visibility of each option should be. | |
6786 * | |
6787 * Within this function, the core must update the visibility | |
6788 * of any dynamically-hidden options | |
6789 * using \ref RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY. | |
6790 * | |
6791 * @note All core options are visible by default, | |
6792 * even during this function's first call. | |
6793 * | |
6794 * @return \c true if any core option's visibility was adjusted | |
6795 * since the last call to this function. | |
6796 * @see RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY | |
6797 * @see retro_core_option_display | |
6798 */ | |
6799 typedef bool (RETRO_CALLCONV *retro_core_options_update_display_callback_t)(void); | |
6800 | |
6801 /** | |
6802 * Callback registered by the core for the frontend to use | |
6803 * when setting the visibility of each core option. | |
6804 * | |
6805 * @see RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY | |
6806 * @see retro_core_option_display | |
6807 */ | |
6808 struct retro_core_options_update_display_callback | |
6809 { | |
6810 /** | |
6811 * @copydoc retro_core_options_update_display_callback_t | |
6812 * | |
6813 * Set by the core. | |
6814 */ | |
6815 retro_core_options_update_display_callback_t callback; | |
6816 }; | |
6817 | |
6818 /** @} */ | |
2152 | 6819 |
2153 struct retro_game_info | 6820 struct retro_game_info |
2154 { | 6821 { |
2155 const char *path; /* Path to game, UTF-8 encoded. | 6822 const char *path; /* Path to game, UTF-8 encoded. |
2156 * Sometimes used as a reference for building other paths. | 6823 * Sometimes used as a reference for building other paths. |
2164 * if need_fullpath was set. */ | 6831 * if need_fullpath was set. */ |
2165 size_t size; /* Size of memory buffer. */ | 6832 size_t size; /* Size of memory buffer. */ |
2166 const char *meta; /* String of implementation specific meta-data. */ | 6833 const char *meta; /* String of implementation specific meta-data. */ |
2167 }; | 6834 }; |
2168 | 6835 |
6836 /** @defgroup GET_CURRENT_SOFTWARE_FRAMEBUFFER Frontend-Owned Framebuffers | |
6837 * @{ | |
6838 */ | |
6839 | |
6840 /** @defgroup RETRO_MEMORY_ACCESS Framebuffer Memory Access Types | |
6841 * @{ | |
6842 */ | |
6843 | |
6844 /** Indicates that core will write to the framebuffer returned by the frontend. */ | |
2169 #define RETRO_MEMORY_ACCESS_WRITE (1 << 0) | 6845 #define RETRO_MEMORY_ACCESS_WRITE (1 << 0) |
2170 /* The core will write to the buffer provided by retro_framebuffer::data. */ | 6846 |
6847 /** Indicates that the core will read from the framebuffer returned by the frontend. */ | |
2171 #define RETRO_MEMORY_ACCESS_READ (1 << 1) | 6848 #define RETRO_MEMORY_ACCESS_READ (1 << 1) |
2172 /* The core will read from retro_framebuffer::data. */ | 6849 |
6850 /** @} */ | |
6851 | |
6852 /** @defgroup RETRO_MEMORY_TYPE Framebuffer Memory Types | |
6853 * @{ | |
6854 */ | |
6855 | |
6856 /** | |
6857 * Indicates that the returned framebuffer's memory is cached. | |
6858 * If not set, random access to the buffer may be very slow. | |
6859 */ | |
2173 #define RETRO_MEMORY_TYPE_CACHED (1 << 0) | 6860 #define RETRO_MEMORY_TYPE_CACHED (1 << 0) |
2174 /* The memory in data is cached. | 6861 |
2175 * If not cached, random writes and/or reading from the buffer is expected to be very slow. */ | 6862 /** @} */ |
6863 | |
6864 /** | |
6865 * A frame buffer owned by the frontend that a core may use for rendering. | |
6866 * | |
6867 * @see GET_CURRENT_SOFTWARE_FRAMEBUFFER | |
6868 * @see retro_video_refresh_t | |
6869 */ | |
2176 struct retro_framebuffer | 6870 struct retro_framebuffer |
2177 { | 6871 { |
2178 void *data; /* The framebuffer which the core can render into. | 6872 /** |
2179 Set by frontend in GET_CURRENT_SOFTWARE_FRAMEBUFFER. | 6873 * Pointer to the beginning of the framebuffer provided by the frontend. |
2180 The initial contents of data are unspecified. */ | 6874 * The initial contents of this buffer are unspecified, |
2181 unsigned width; /* The framebuffer width used by the core. Set by core. */ | 6875 * as is the means used to map the memory; |
2182 unsigned height; /* The framebuffer height used by the core. Set by core. */ | 6876 * this may be defined in software, |
2183 size_t pitch; /* The number of bytes between the beginning of a scanline, | 6877 * or it may be GPU memory mapped to RAM. |
2184 and beginning of the next scanline. | 6878 * |
2185 Set by frontend in GET_CURRENT_SOFTWARE_FRAMEBUFFER. */ | 6879 * If the framebuffer is used, |
2186 enum retro_pixel_format format; /* The pixel format the core must use to render into data. | 6880 * this pointer must be passed to \c retro_video_refresh_t as-is. |
2187 This format could differ from the format used in | 6881 * It is undefined behavior to pass an offset to this pointer. |
2188 SET_PIXEL_FORMAT. | 6882 * |
2189 Set by frontend in GET_CURRENT_SOFTWARE_FRAMEBUFFER. */ | 6883 * @warning This pointer is only guaranteed to be valid |
2190 | 6884 * for the duration of the same \c retro_run iteration |
2191 unsigned access_flags; /* How the core will access the memory in the framebuffer. | 6885 * \ref GET_CURRENT_SOFTWARE_FRAMEBUFFER "that requested the framebuffer". |
2192 RETRO_MEMORY_ACCESS_* flags. | 6886 * Reuse of this pointer is undefined. |
2193 Set by core. */ | 6887 */ |
2194 unsigned memory_flags; /* Flags telling core how the memory has been mapped. | 6888 void *data; |
2195 RETRO_MEMORY_TYPE_* flags. | 6889 |
2196 Set by frontend in GET_CURRENT_SOFTWARE_FRAMEBUFFER. */ | 6890 /** |
6891 * The width of the framebuffer given in \c data, in pixels. | |
6892 * Set by the core. | |
6893 * | |
6894 * @warning If the framebuffer is used, | |
6895 * this value must be passed to \c retro_video_refresh_t as-is. | |
6896 * It is undefined behavior to try to render \c data with any other width. | |
6897 */ | |
6898 unsigned width; | |
6899 | |
6900 /** | |
6901 * The height of the framebuffer given in \c data, in pixels. | |
6902 * Set by the core. | |
6903 * | |
6904 * @warning If the framebuffer is used, | |
6905 * this value must be passed to \c retro_video_refresh_t as-is. | |
6906 * It is undefined behavior to try to render \c data with any other height. | |
6907 */ | |
6908 unsigned height; | |
6909 | |
6910 /** | |
6911 * The distance between the start of one scanline and the beginning of the next, in bytes. | |
6912 * In practice this is usually equal to \c width times the pixel size, | |
6913 * but that's not guaranteed. | |
6914 * Sometimes called the "stride". | |
6915 * | |
6916 * @setby{frontend} | |
6917 * @warning If the framebuffer is used, | |
6918 * this value must be passed to \c retro_video_refresh_t as-is. | |
6919 * It is undefined to try to render \c data with any other pitch. | |
6920 */ | |
6921 size_t pitch; | |
6922 | |
6923 /** | |
6924 * The pixel format of the returned framebuffer. | |
6925 * May be different than the format specified by the core in \c RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, | |
6926 * e.g. due to conversions. | |
6927 * Set by the frontend. | |
6928 * | |
6929 * @see RETRO_ENVIRONMENT_SET_PIXEL_FORMAT | |
6930 */ | |
6931 enum retro_pixel_format format; | |
6932 | |
6933 /** | |
6934 * One or more \ref RETRO_MEMORY_ACCESS "memory access flags" | |
6935 * that specify how the core will access the memory in \c data. | |
6936 * | |
6937 * @setby{core} | |
6938 */ | |
6939 unsigned access_flags; | |
6940 | |
6941 /** | |
6942 * Zero or more \ref RETRO_MEMORY_TYPE "memory type flags" | |
6943 * that describe how the framebuffer's memory has been mapped. | |
6944 * | |
6945 * @setby{frontend} | |
6946 */ | |
6947 unsigned memory_flags; | |
2197 }; | 6948 }; |
2198 | 6949 |
2199 /* Callbacks */ | 6950 /** @} */ |
2200 | 6951 |
2201 /* Environment callback. Gives implementations a way of performing | 6952 /** @defgroup SET_FASTFORWARDING_OVERRIDE Fast-Forward Override |
2202 * uncommon tasks. Extensible. */ | 6953 * @{ |
6954 */ | |
6955 | |
6956 /** | |
6957 * Parameters that govern when and how the core takes control | |
6958 * of fast-forwarding mode. | |
6959 */ | |
6960 struct retro_fastforwarding_override | |
6961 { | |
6962 /** | |
6963 * The factor by which the core will be sped up | |
6964 * when \c fastforward is \c true. | |
6965 * This value is used as follows: | |
6966 * | |
6967 * @li A value greater than 1.0 will run the core at | |
6968 * the specified multiple of normal speed. | |
6969 * For example, a value of 5.0 | |
6970 * combined with a normal target rate of 60 FPS | |
6971 * will result in a target rate of 300 FPS. | |
6972 * The actual rate may be lower if the host's hardware can't keep up. | |
6973 * @li A value of 1.0 will run the core at normal speed. | |
6974 * @li A value between 0.0 (inclusive) and 1.0 (exclusive) | |
6975 * will run the core as fast as the host system can manage. | |
6976 * @li A negative value will let the frontend choose a factor. | |
6977 * @li An infinite value or \c NaN results in undefined behavior. | |
6978 * | |
6979 * @attention Setting this value to less than 1.0 will \em not | |
6980 * slow down the core. | |
6981 */ | |
6982 float ratio; | |
6983 | |
6984 /** | |
6985 * If \c true, the frontend should activate fast-forwarding | |
6986 * until this field is set to \c false or the core is unloaded. | |
6987 */ | |
6988 bool fastforward; | |
6989 | |
6990 /** | |
6991 * If \c true, the frontend should display an on-screen notification or icon | |
6992 * while \c fastforward is \c true (where supported). | |
6993 * Otherwise, the frontend should not display any such notification. | |
6994 */ | |
6995 bool notification; | |
6996 | |
6997 /** | |
6998 * If \c true, the core has exclusive control | |
6999 * over enabling and disabling fast-forwarding | |
7000 * via the \c fastforward field. | |
7001 * The frontend will not be able to start or stop fast-forwarding | |
7002 * until this field is set to \c false or the core is unloaded. | |
7003 */ | |
7004 bool inhibit_toggle; | |
7005 }; | |
7006 | |
7007 /** @} */ | |
7008 | |
7009 /** | |
7010 * During normal operation. | |
7011 * | |
7012 * @note Rate will be equal to the core's internal FPS. | |
7013 */ | |
7014 #define RETRO_THROTTLE_NONE 0 | |
7015 | |
7016 /** | |
7017 * While paused or stepping single frames. | |
7018 * | |
7019 * @note Rate will be 0. | |
7020 */ | |
7021 #define RETRO_THROTTLE_FRAME_STEPPING 1 | |
7022 | |
7023 /** | |
7024 * During fast forwarding. | |
7025 * | |
7026 * @note Rate will be 0 if not specifically limited to a maximum speed. | |
7027 */ | |
7028 #define RETRO_THROTTLE_FAST_FORWARD 2 | |
7029 | |
7030 /** | |
7031 * During slow motion. | |
7032 * | |
7033 * @note Rate will be less than the core's internal FPS. | |
7034 */ | |
7035 #define RETRO_THROTTLE_SLOW_MOTION 3 | |
7036 | |
7037 /** | |
7038 * While rewinding recorded save states. | |
7039 * | |
7040 * @note Rate can vary depending on the rewind speed or be 0 if the frontend | |
7041 * is not aiming for a specific rate. | |
7042 */ | |
7043 #define RETRO_THROTTLE_REWINDING 4 | |
7044 | |
7045 /** | |
7046 * While vsync is active in the video driver, and the target refresh rate is lower than the core's internal FPS. | |
7047 * | |
7048 * @note Rate is the target refresh rate. | |
7049 */ | |
7050 #define RETRO_THROTTLE_VSYNC 5 | |
7051 | |
7052 /** | |
7053 * When the frontend does not throttle in any way. | |
7054 * | |
7055 * @note Rate will be 0. An example could be if no vsync or audio output is active. | |
7056 */ | |
7057 #define RETRO_THROTTLE_UNBLOCKED 6 | |
7058 | |
7059 /** | |
7060 * Details about the actual rate an implementation is calling \c retro_run() at. | |
7061 * | |
7062 * @see RETRO_ENVIRONMENT_GET_THROTTLE_STATE | |
7063 */ | |
7064 struct retro_throttle_state | |
7065 { | |
7066 /** | |
7067 * The current throttling mode. | |
7068 * | |
7069 * @note Should be one of the \c RETRO_THROTTLE_* values. | |
7070 * @see RETRO_THROTTLE_NONE | |
7071 * @see RETRO_THROTTLE_FRAME_STEPPING | |
7072 * @see RETRO_THROTTLE_FAST_FORWARD | |
7073 * @see RETRO_THROTTLE_SLOW_MOTION | |
7074 * @see RETRO_THROTTLE_REWINDING | |
7075 * @see RETRO_THROTTLE_VSYNC | |
7076 * @see RETRO_THROTTLE_UNBLOCKED | |
7077 */ | |
7078 unsigned mode; | |
7079 | |
7080 /** | |
7081 * How many times per second the frontend aims to call retro_run. | |
7082 * | |
7083 * @note Depending on the mode, it can be 0 if there is no known fixed rate. | |
7084 * This won't be accurate if the total processing time of the core and | |
7085 * the frontend is longer than what is available for one frame. | |
7086 */ | |
7087 float rate; | |
7088 }; | |
7089 | |
7090 /** @defgroup GET_MICROPHONE_INTERFACE Microphone Interface | |
7091 * @{ | |
7092 */ | |
7093 | |
7094 /** | |
7095 * Opaque handle to a microphone that's been opened for use. | |
7096 * The underlying object is accessed or created with \c retro_microphone_interface_t. | |
7097 */ | |
7098 typedef struct retro_microphone retro_microphone_t; | |
7099 | |
7100 /** | |
7101 * Parameters for configuring a microphone. | |
7102 * Some of these might not be honored, | |
7103 * depending on the available hardware and driver configuration. | |
7104 */ | |
7105 typedef struct retro_microphone_params | |
7106 { | |
7107 /** | |
7108 * The desired sample rate of the microphone's input, in Hz. | |
7109 * The microphone's input will be resampled, | |
7110 * so cores can ask for whichever frequency they need. | |
7111 * | |
7112 * If zero, some reasonable default will be provided by the frontend | |
7113 * (usually from its config file). | |
7114 * | |
7115 * @see retro_get_mic_rate_t | |
7116 */ | |
7117 unsigned rate; | |
7118 } retro_microphone_params_t; | |
7119 | |
7120 /** | |
7121 * @copydoc retro_microphone_interface::open_mic | |
7122 */ | |
7123 typedef retro_microphone_t *(RETRO_CALLCONV *retro_open_mic_t)(const retro_microphone_params_t *params); | |
7124 | |
7125 /** | |
7126 * @copydoc retro_microphone_interface::close_mic | |
7127 */ | |
7128 typedef void (RETRO_CALLCONV *retro_close_mic_t)(retro_microphone_t *microphone); | |
7129 | |
7130 /** | |
7131 * @copydoc retro_microphone_interface::get_params | |
7132 */ | |
7133 typedef bool (RETRO_CALLCONV *retro_get_mic_params_t)(const retro_microphone_t *microphone, retro_microphone_params_t *params); | |
7134 | |
7135 /** | |
7136 * @copydoc retro_microphone_interface::set_mic_state | |
7137 */ | |
7138 typedef bool (RETRO_CALLCONV *retro_set_mic_state_t)(retro_microphone_t *microphone, bool state); | |
7139 | |
7140 /** | |
7141 * @copydoc retro_microphone_interface::get_mic_state | |
7142 */ | |
7143 typedef bool (RETRO_CALLCONV *retro_get_mic_state_t)(const retro_microphone_t *microphone); | |
7144 | |
7145 /** | |
7146 * @copydoc retro_microphone_interface::read_mic | |
7147 */ | |
7148 typedef int (RETRO_CALLCONV *retro_read_mic_t)(retro_microphone_t *microphone, int16_t* samples, size_t num_samples); | |
7149 | |
7150 /** | |
7151 * The current version of the microphone interface. | |
7152 * Will be incremented whenever \c retro_microphone_interface or \c retro_microphone_params_t | |
7153 * receive new fields. | |
7154 * | |
7155 * Frontends using cores built against older mic interface versions | |
7156 * should not access fields introduced in newer versions. | |
7157 */ | |
7158 #define RETRO_MICROPHONE_INTERFACE_VERSION 1 | |
7159 | |
7160 /** | |
7161 * An interface for querying the microphone and accessing data read from it. | |
7162 * | |
7163 * @see RETRO_ENVIRONMENT_GET_MICROPHONE_INTERFACE | |
7164 */ | |
7165 struct retro_microphone_interface | |
7166 { | |
7167 /** | |
7168 * The version of this microphone interface. | |
7169 * Set by the core to request a particular version, | |
7170 * and set by the frontend to indicate the returned version. | |
7171 * 0 indicates that the interface is invalid or uninitialized. | |
7172 */ | |
7173 unsigned interface_version; | |
7174 | |
7175 /** | |
7176 * Initializes a new microphone. | |
7177 * Assuming that microphone support is enabled and provided by the frontend, | |
7178 * cores may call this function whenever necessary. | |
7179 * A microphone could be opened throughout a core's lifetime, | |
7180 * or it could wait until a microphone is plugged in to the emulated device. | |
7181 * | |
7182 * The returned handle will be valid until it's freed, | |
7183 * even if the audio driver is reinitialized. | |
7184 * | |
7185 * This function is not guaranteed to be thread-safe. | |
7186 * | |
7187 * @param[in] args Parameters used to create the microphone. | |
7188 * May be \c NULL, in which case the default value of each parameter will be used. | |
7189 * | |
7190 * @returns Pointer to the newly-opened microphone, | |
7191 * or \c NULL if one couldn't be opened. | |
7192 * This likely means that no microphone is plugged in and recognized, | |
7193 * or the maximum number of supported microphones has been reached. | |
7194 * | |
7195 * @note Microphones are \em inactive by default; | |
7196 * to begin capturing audio, call \c set_mic_state. | |
7197 * @see retro_microphone_params_t | |
7198 */ | |
7199 retro_open_mic_t open_mic; | |
7200 | |
7201 /** | |
7202 * Closes a microphone that was initialized with \c open_mic. | |
7203 * Calling this function will stop all microphone activity | |
7204 * and free up the resources that it allocated. | |
7205 * Afterwards, the handle is invalid and must not be used. | |
7206 * | |
7207 * A frontend may close opened microphones when unloading content, | |
7208 * but this behavior is not guaranteed. | |
7209 * Cores should close their microphones when exiting, just to be safe. | |
7210 * | |
7211 * @param microphone Pointer to the microphone that was allocated by \c open_mic. | |
7212 * If \c NULL, this function does nothing. | |
7213 * | |
7214 * @note The handle might be reused if another microphone is opened later. | |
7215 */ | |
7216 retro_close_mic_t close_mic; | |
7217 | |
7218 /** | |
7219 * Returns the configured parameters of this microphone. | |
7220 * These may differ from what was requested depending on | |
7221 * the driver and device configuration. | |
7222 * | |
7223 * Cores should check these values before they start fetching samples. | |
7224 * | |
7225 * Will not change after the mic was opened. | |
7226 * | |
7227 * @param[in] microphone Opaque handle to the microphone | |
7228 * whose parameters will be retrieved. | |
7229 * @param[out] params The parameters object that the | |
7230 * microphone's parameters will be copied to. | |
7231 * | |
7232 * @return \c true if the parameters were retrieved, | |
7233 * \c false if there was an error. | |
7234 */ | |
7235 retro_get_mic_params_t get_params; | |
7236 | |
7237 /** | |
7238 * Enables or disables the given microphone. | |
7239 * Microphones are disabled by default | |
7240 * and must be explicitly enabled before they can be used. | |
7241 * Disabled microphones will not process incoming audio samples, | |
7242 * and will therefore have minimal impact on overall performance. | |
7243 * Cores may enable microphones throughout their lifetime, | |
7244 * or only for periods where they're needed. | |
7245 * | |
7246 * Cores that accept microphone input should be able to operate without it; | |
7247 * we suggest substituting silence in this case. | |
7248 * | |
7249 * @param microphone Opaque handle to the microphone | |
7250 * whose state will be adjusted. | |
7251 * This will have been provided by \c open_mic. | |
7252 * @param state \c true if the microphone should receive audio input, | |
7253 * \c false if it should be idle. | |
7254 * @returns \c true if the microphone's state was successfully set, | |
7255 * \c false if \c microphone is invalid | |
7256 * or if there was an error. | |
7257 */ | |
7258 retro_set_mic_state_t set_mic_state; | |
7259 | |
7260 /** | |
7261 * Queries the active state of a microphone at the given index. | |
7262 * Will return whether the microphone is enabled, | |
7263 * even if the driver is paused. | |
7264 * | |
7265 * @param microphone Opaque handle to the microphone | |
7266 * whose state will be queried. | |
7267 * @return \c true if the provided \c microphone is valid and active, | |
7268 * \c false if not or if there was an error. | |
7269 */ | |
7270 retro_get_mic_state_t get_mic_state; | |
7271 | |
7272 /** | |
7273 * Retrieves the input processed by the microphone since the last call. | |
7274 * \em Must be called every frame unless \c microphone is disabled, | |
7275 * similar to how \c retro_audio_sample_batch_t works. | |
7276 * | |
7277 * @param[in] microphone Opaque handle to the microphone | |
7278 * whose recent input will be retrieved. | |
7279 * @param[out] samples The buffer that will be used to store the microphone's data. | |
7280 * Microphone input is in mono (i.e. one number per sample). | |
7281 * Should be large enough to accommodate the expected number of samples per frame; | |
7282 * for example, a 44.1kHz sample rate at 60 FPS would require space for 735 samples. | |
7283 * @param[in] num_samples The size of the data buffer in samples (\em not bytes). | |
7284 * Microphone input is in mono, so a "frame" and a "sample" are equivalent in length here. | |
7285 * | |
7286 * @return The number of samples that were copied into \c samples. | |
7287 * If \c microphone is pending driver initialization, | |
7288 * this function will copy silence of the requested length into \c samples. | |
7289 * | |
7290 * Will return -1 if the microphone is disabled, | |
7291 * the audio driver is paused, | |
7292 * or there was an error. | |
7293 */ | |
7294 retro_read_mic_t read_mic; | |
7295 }; | |
7296 | |
7297 /** @} */ | |
7298 | |
7299 /** @defgroup GET_DEVICE_POWER Device Power | |
7300 * @{ | |
7301 */ | |
7302 | |
7303 /** | |
7304 * Describes how a device is being powered. | |
7305 * @see RETRO_ENVIRONMENT_GET_DEVICE_POWER | |
7306 */ | |
7307 enum retro_power_state | |
7308 { | |
7309 /** | |
7310 * Indicates that the frontend cannot report its power state at this time, | |
7311 * most likely due to a lack of support. | |
7312 * | |
7313 * \c RETRO_ENVIRONMENT_GET_DEVICE_POWER will not return this value; | |
7314 * instead, the environment callback will return \c false. | |
7315 */ | |
7316 RETRO_POWERSTATE_UNKNOWN = 0, | |
7317 | |
7318 /** | |
7319 * Indicates that the device is running on its battery. | |
7320 * Usually applies to portable devices such as handhelds, laptops, and smartphones. | |
7321 */ | |
7322 RETRO_POWERSTATE_DISCHARGING, | |
7323 | |
7324 /** | |
7325 * Indicates that the device's battery is currently charging. | |
7326 */ | |
7327 RETRO_POWERSTATE_CHARGING, | |
7328 | |
7329 /** | |
7330 * Indicates that the device is connected to a power source | |
7331 * and that its battery has finished charging. | |
7332 */ | |
7333 RETRO_POWERSTATE_CHARGED, | |
7334 | |
7335 /** | |
7336 * Indicates that the device is connected to a power source | |
7337 * and that it does not have a battery. | |
7338 * This usually suggests a desktop computer or a non-portable game console. | |
7339 */ | |
7340 RETRO_POWERSTATE_PLUGGED_IN | |
7341 }; | |
7342 | |
7343 /** | |
7344 * Indicates that an estimate is not available for the battery level or time remaining, | |
7345 * even if the actual power state is known. | |
7346 */ | |
7347 #define RETRO_POWERSTATE_NO_ESTIMATE (-1) | |
7348 | |
7349 /** | |
7350 * Describes the power state of the device running the frontend. | |
7351 * @see RETRO_ENVIRONMENT_GET_DEVICE_POWER | |
7352 */ | |
7353 struct retro_device_power | |
7354 { | |
7355 /** | |
7356 * The current state of the frontend's power usage. | |
7357 */ | |
7358 enum retro_power_state state; | |
7359 | |
7360 /** | |
7361 * A rough estimate of the amount of time remaining (in seconds) | |
7362 * before the device powers off. | |
7363 * This value depends on a variety of factors, | |
7364 * so it is not guaranteed to be accurate. | |
7365 * | |
7366 * Will be set to \c RETRO_POWERSTATE_NO_ESTIMATE if \c state does not equal \c RETRO_POWERSTATE_DISCHARGING. | |
7367 * May still be set to \c RETRO_POWERSTATE_NO_ESTIMATE if the frontend is unable to provide an estimate. | |
7368 */ | |
7369 int seconds; | |
7370 | |
7371 /** | |
7372 * The approximate percentage of battery charge, | |
7373 * ranging from 0 to 100 (inclusive). | |
7374 * The device may power off before this reaches 0. | |
7375 * | |
7376 * The user might have configured their device | |
7377 * to stop charging before the battery is full, | |
7378 * so do not assume that this will be 100 in the \c RETRO_POWERSTATE_CHARGED state. | |
7379 */ | |
7380 int8_t percent; | |
7381 }; | |
7382 | |
7383 /** @} */ | |
7384 | |
7385 /** | |
7386 * @defgroup Callbacks | |
7387 * @{ | |
7388 */ | |
7389 | |
7390 /** | |
7391 * Environment callback to give implementations a way of performing uncommon tasks. | |
7392 * | |
7393 * @note Extensible. | |
7394 * | |
7395 * @param cmd The command to run. | |
7396 * @param data A pointer to the data associated with the command. | |
7397 * | |
7398 * @return Varies by callback, | |
7399 * but will always return \c false if the command is not recognized. | |
7400 * | |
7401 * @see RETRO_ENVIRONMENT_SET_ROTATION | |
7402 * @see retro_set_environment() | |
7403 */ | |
2203 typedef bool (RETRO_CALLCONV *retro_environment_t)(unsigned cmd, void *data); | 7404 typedef bool (RETRO_CALLCONV *retro_environment_t)(unsigned cmd, void *data); |
2204 | 7405 |
2205 /* Render a frame. Pixel format is 15-bit 0RGB1555 native endian | 7406 /** |
2206 * unless changed (see RETRO_ENVIRONMENT_SET_PIXEL_FORMAT). | 7407 * Render a frame. |
2207 * | 7408 * |
2208 * Width and height specify dimensions of buffer. | 7409 * @note For performance reasons, it is highly recommended to have a frame |
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. | 7410 * that is packed in memory, i.e. pitch == width * byte_per_pixel. |
2213 * Certain graphic APIs, such as OpenGL ES, do not like textures | 7411 * Certain graphic APIs, such as OpenGL ES, do not like textures |
2214 * that are not packed in memory. | 7412 * that are not packed in memory. |
7413 * | |
7414 * @param data A pointer to the frame buffer data with a pixel format of 15-bit \c 0RGB1555 native endian, unless changed with \c RETRO_ENVIRONMENT_SET_PIXEL_FORMAT. | |
7415 * @param width The width of the frame buffer, in pixels. | |
7416 * @param height The height frame buffer, in pixels. | |
7417 * @param pitch The width of the frame buffer, in bytes. | |
7418 * | |
7419 * @see retro_set_video_refresh() | |
7420 * @see RETRO_ENVIRONMENT_SET_PIXEL_FORMAT | |
7421 * @see retro_pixel_format | |
2215 */ | 7422 */ |
2216 typedef void (RETRO_CALLCONV *retro_video_refresh_t)(const void *data, unsigned width, | 7423 typedef void (RETRO_CALLCONV *retro_video_refresh_t)(const void *data, unsigned width, |
2217 unsigned height, size_t pitch); | 7424 unsigned height, size_t pitch); |
2218 | 7425 |
2219 /* Renders a single audio frame. Should only be used if implementation | 7426 /** |
2220 * generates a single sample at a time. | 7427 * Renders a single audio frame. Should only be used if implementation generates a single sample at a time. |
2221 * Format is signed 16-bit native endian. | 7428 * |
7429 * @param left The left audio sample represented as a signed 16-bit native endian. | |
7430 * @param right The right audio sample represented as a signed 16-bit native endian. | |
7431 * | |
7432 * @see retro_set_audio_sample() | |
7433 * @see retro_set_audio_sample_batch() | |
2222 */ | 7434 */ |
2223 typedef void (RETRO_CALLCONV *retro_audio_sample_t)(int16_t left, int16_t right); | 7435 typedef void (RETRO_CALLCONV *retro_audio_sample_t)(int16_t left, int16_t right); |
2224 | 7436 |
2225 /* Renders multiple audio frames in one go. | 7437 /** |
2226 * | 7438 * Renders multiple audio frames in one go. |
2227 * One frame is defined as a sample of left and right channels, interleaved. | 7439 * |
2228 * I.e. int16_t buf[4] = { l, r, l, r }; would be 2 frames. | 7440 * @note Only one of the audio callbacks must ever be used. |
2229 * Only one of the audio callbacks must ever be used. | 7441 * |
7442 * @param data A pointer to the audio sample data pairs to render. | |
7443 * @param frames The number of frames that are represented in the data. One frame | |
7444 * is defined as a sample of left and right channels, interleaved. | |
7445 * For example: <tt>int16_t buf[4] = { l, r, l, r };</tt> would be 2 frames. | |
7446 * | |
7447 * @return The number of frames that were processed. | |
7448 * | |
7449 * @see retro_set_audio_sample_batch() | |
7450 * @see retro_set_audio_sample() | |
2230 */ | 7451 */ |
2231 typedef size_t (RETRO_CALLCONV *retro_audio_sample_batch_t)(const int16_t *data, | 7452 typedef size_t (RETRO_CALLCONV *retro_audio_sample_batch_t)(const int16_t *data, |
2232 size_t frames); | 7453 size_t frames); |
2233 | 7454 |
2234 /* Polls input. */ | 7455 /** |
7456 * Polls input. | |
7457 * | |
7458 * @see retro_set_input_poll() | |
7459 */ | |
2235 typedef void (RETRO_CALLCONV *retro_input_poll_t)(void); | 7460 typedef void (RETRO_CALLCONV *retro_input_poll_t)(void); |
2236 | 7461 |
2237 /* Queries for input for player 'port'. device will be masked with | 7462 /** |
2238 * RETRO_DEVICE_MASK. | 7463 * Queries for input for player 'port'. |
2239 * | 7464 * |
2240 * Specialization of devices such as RETRO_DEVICE_JOYPAD_MULTITAP that | 7465 * @param port Which player 'port' to query. |
2241 * have been set with retro_set_controller_port_device() | 7466 * @param device Which device to query for. Will be masked with \c RETRO_DEVICE_MASK. |
2242 * will still use the higher level RETRO_DEVICE_JOYPAD to request input. | 7467 * @param index The input index to retrieve. |
7468 * The exact semantics depend on the device type given in \c device. | |
7469 * @param id The ID of which value to query, like \c RETRO_DEVICE_ID_JOYPAD_B. | |
7470 * @returns Depends on the provided arguments, | |
7471 * but will return 0 if their values are unsupported | |
7472 * by the frontend or the backing physical device. | |
7473 * @note Specialization of devices such as \c RETRO_DEVICE_JOYPAD_MULTITAP that | |
7474 * have been set with \c retro_set_controller_port_device() will still use the | |
7475 * higher level \c RETRO_DEVICE_JOYPAD to request input. | |
7476 * | |
7477 * @see retro_set_input_state() | |
7478 * @see RETRO_DEVICE_NONE | |
7479 * @see RETRO_DEVICE_JOYPAD | |
7480 * @see RETRO_DEVICE_MOUSE | |
7481 * @see RETRO_DEVICE_KEYBOARD | |
7482 * @see RETRO_DEVICE_LIGHTGUN | |
7483 * @see RETRO_DEVICE_ANALOG | |
7484 * @see RETRO_DEVICE_POINTER | |
2243 */ | 7485 */ |
2244 typedef int16_t (RETRO_CALLCONV *retro_input_state_t)(unsigned port, unsigned device, | 7486 typedef int16_t (RETRO_CALLCONV *retro_input_state_t)(unsigned port, unsigned device, |
2245 unsigned index, unsigned id); | 7487 unsigned index, unsigned id); |
2246 | 7488 |
2247 /* Sets callbacks. retro_set_environment() is guaranteed to be called | 7489 /** |
2248 * before retro_init(). | 7490 * Sets the environment callback. |
2249 * | 7491 * |
2250 * The rest of the set_* functions are guaranteed to have been called | 7492 * @param cb The function which is used when making environment calls. |
2251 * before the first call to retro_run() is made. */ | 7493 * |
2252 RETRO_API void retro_set_environment(retro_environment_t); | 7494 * @note Guaranteed to be called before \c retro_init(). |
2253 RETRO_API void retro_set_video_refresh(retro_video_refresh_t); | 7495 * |
2254 RETRO_API void retro_set_audio_sample(retro_audio_sample_t); | 7496 * @see RETRO_ENVIRONMENT |
2255 RETRO_API void retro_set_audio_sample_batch(retro_audio_sample_batch_t); | 7497 */ |
2256 RETRO_API void retro_set_input_poll(retro_input_poll_t); | 7498 RETRO_API void retro_set_environment(retro_environment_t cb); |
2257 RETRO_API void retro_set_input_state(retro_input_state_t); | 7499 |
2258 | 7500 /** |
2259 /* Library global initialization/deinitialization. */ | 7501 * Sets the video refresh callback. |
7502 * | |
7503 * @param cb The function which is used when rendering a frame. | |
7504 * | |
7505 * @note Guaranteed to have been called before the first call to \c retro_run() is made. | |
7506 */ | |
7507 RETRO_API void retro_set_video_refresh(retro_video_refresh_t cb); | |
7508 | |
7509 /** | |
7510 * Sets the audio sample callback. | |
7511 * | |
7512 * @param cb The function which is used when rendering a single audio frame. | |
7513 * | |
7514 * @note Guaranteed to have been called before the first call to \c retro_run() is made. | |
7515 */ | |
7516 RETRO_API void retro_set_audio_sample(retro_audio_sample_t cb); | |
7517 | |
7518 /** | |
7519 * Sets the audio sample batch callback. | |
7520 * | |
7521 * @param cb The function which is used when rendering multiple audio frames in one go. | |
7522 * | |
7523 * @note Guaranteed to have been called before the first call to \c retro_run() is made. | |
7524 */ | |
7525 RETRO_API void retro_set_audio_sample_batch(retro_audio_sample_batch_t cb); | |
7526 | |
7527 /** | |
7528 * Sets the input poll callback. | |
7529 * | |
7530 * @param cb The function which is used to poll the active input. | |
7531 * | |
7532 * @note Guaranteed to have been called before the first call to \c retro_run() is made. | |
7533 */ | |
7534 RETRO_API void retro_set_input_poll(retro_input_poll_t cb); | |
7535 | |
7536 /** | |
7537 * Sets the input state callback. | |
7538 * | |
7539 * @param cb The function which is used to query the input state. | |
7540 * | |
7541 *@note Guaranteed to have been called before the first call to \c retro_run() is made. | |
7542 */ | |
7543 RETRO_API void retro_set_input_state(retro_input_state_t cb); | |
7544 | |
7545 /** | |
7546 * @} | |
7547 */ | |
7548 | |
7549 /** | |
7550 * Called by the frontend when initializing a libretro core. | |
7551 * | |
7552 * @warning There are many possible "gotchas" with global state in dynamic libraries. | |
7553 * Here are some to keep in mind: | |
7554 * <ul> | |
7555 * <li>Do not assume that the core was loaded by the operating system | |
7556 * for the first time within this call. | |
7557 * It may have been statically linked or retained from a previous session. | |
7558 * Consequently, cores must not rely on global variables being initialized | |
7559 * to their default values before this function is called; | |
7560 * this also goes for object constructors in C++. | |
7561 * <li>Although C++ requires that constructors be called for global variables, | |
7562 * it does not require that their destructors be called | |
7563 * if stored within a dynamic library's global scope. | |
7564 * <li>If the core is statically linked to the frontend, | |
7565 * global variables may be initialized when the frontend itself is initially executed. | |
7566 * </ul> | |
7567 * @see retro_deinit | |
7568 */ | |
2260 RETRO_API void retro_init(void); | 7569 RETRO_API void retro_init(void); |
7570 | |
7571 /** | |
7572 * Called by the frontend when deinitializing a libretro core. | |
7573 * The core must release all of its allocated resources before this function returns. | |
7574 * | |
7575 * @warning There are many possible "gotchas" with global state in dynamic libraries. | |
7576 * Here are some to keep in mind: | |
7577 * <ul> | |
7578 * <li>Do not assume that the operating system will unload the core after this function returns, | |
7579 * as the core may be linked statically or retained in memory. | |
7580 * Cores should use this function to clean up all allocated resources | |
7581 * and reset all global variables to their default states. | |
7582 * <li>Do not assume that this core won't be loaded again after this function returns. | |
7583 * It may be kept in memory by the frontend for later use, | |
7584 * or it may be statically linked. | |
7585 * Therefore, all global variables should be reset to their default states within this function. | |
7586 * <li>C++ does not require that destructors be called | |
7587 * for variables within a dynamic library's global scope. | |
7588 * Therefore, global objects that own dynamically-managed resources | |
7589 * (such as \c std::string or <tt>std::vector</tt>) | |
7590 * should be kept behind pointers that are explicitly deallocated within this function. | |
7591 * </ul> | |
7592 * @see retro_init | |
7593 */ | |
2261 RETRO_API void retro_deinit(void); | 7594 RETRO_API void retro_deinit(void); |
2262 | 7595 |
2263 /* Must return RETRO_API_VERSION. Used to validate ABI compatibility | 7596 /** |
2264 * when the API is revised. */ | 7597 * Retrieves which version of the libretro API is being used. |
7598 * | |
7599 * @note This is used to validate ABI compatibility when the API is revised. | |
7600 * | |
7601 * @return Must return \c RETRO_API_VERSION. | |
7602 * | |
7603 * @see RETRO_API_VERSION | |
7604 */ | |
2265 RETRO_API unsigned retro_api_version(void); | 7605 RETRO_API unsigned retro_api_version(void); |
2266 | 7606 |
2267 /* Gets statically known system info. Pointers provided in *info | 7607 /** |
2268 * must be statically allocated. | 7608 * Gets statically known system info. |
2269 * Can be called at any time, even before retro_init(). */ | 7609 * |
7610 * @note Can be called at any time, even before retro_init(). | |
7611 * | |
7612 * @param info A pointer to a \c retro_system_info where the info is to be loaded into. This must be statically allocated. | |
7613 */ | |
2270 RETRO_API void retro_get_system_info(struct retro_system_info *info); | 7614 RETRO_API void retro_get_system_info(struct retro_system_info *info); |
2271 | 7615 |
2272 /* Gets information about system audio/video timings and geometry. | 7616 /** |
2273 * Can be called only after retro_load_game() has successfully completed. | 7617 * Gets information about system audio/video timings and geometry. |
2274 * NOTE: The implementation of this function might not initialize every | 7618 * |
2275 * variable if needed. | 7619 * @note Can be called only after \c retro_load_game() has successfully completed. |
2276 * E.g. geom.aspect_ratio might not be initialized if core doesn't | 7620 * |
2277 * desire a particular aspect ratio. */ | 7621 * @note The implementation of this function might not initialize every variable |
7622 * if needed. For example, \c geom.aspect_ratio might not be initialized if | |
7623 * the core doesn't desire a particular aspect ratio. | |
7624 * | |
7625 * @param info A pointer to a \c retro_system_av_info where the audio/video information should be loaded into. | |
7626 * | |
7627 * @see retro_system_av_info | |
7628 */ | |
2278 RETRO_API void retro_get_system_av_info(struct retro_system_av_info *info); | 7629 RETRO_API void retro_get_system_av_info(struct retro_system_av_info *info); |
2279 | 7630 |
2280 /* Sets device to be used for player 'port'. | 7631 /** |
2281 * By default, RETRO_DEVICE_JOYPAD is assumed to be plugged into all | 7632 * Sets device to be used for player 'port'. |
7633 * | |
7634 * By default, \c RETRO_DEVICE_JOYPAD is assumed to be plugged into all | |
2282 * available ports. | 7635 * available ports. |
2283 * Setting a particular device type is not a guarantee that libretro cores | 7636 * |
7637 * @note 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 | 7638 * 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 | 7639 * 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 | 7640 * appropriate input device type on its own. It is also relevant when a |
2287 * core can change its behavior depending on device type. */ | 7641 * core can change its behavior depending on device type. |
7642 * | |
7643 * @note As part of the core's implementation of retro_set_controller_port_device, | |
7644 * the core should call \c RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS to notify the | |
7645 * frontend if the descriptions for any controls have changed as a | |
7646 * result of changing the device type. | |
7647 * | |
7648 * @param port Which port to set the device for, usually indicates the player number. | |
7649 * @param device Which device the given port is using. By default, \c RETRO_DEVICE_JOYPAD is assumed for all ports. | |
7650 * | |
7651 * @see RETRO_DEVICE_NONE | |
7652 * @see RETRO_DEVICE_JOYPAD | |
7653 * @see RETRO_DEVICE_MOUSE | |
7654 * @see RETRO_DEVICE_KEYBOARD | |
7655 * @see RETRO_DEVICE_LIGHTGUN | |
7656 * @see RETRO_DEVICE_ANALOG | |
7657 * @see RETRO_DEVICE_POINTER | |
7658 * @see RETRO_ENVIRONMENT_SET_CONTROLLER_INFO | |
7659 */ | |
2288 RETRO_API void retro_set_controller_port_device(unsigned port, unsigned device); | 7660 RETRO_API void retro_set_controller_port_device(unsigned port, unsigned device); |
2289 | 7661 |
2290 /* Resets the current game. */ | 7662 /** |
7663 * Resets the currently-loaded game. | |
7664 * Cores should treat this as a soft reset (i.e. an emulated reset button) if possible, | |
7665 * but hard resets are acceptable. | |
7666 */ | |
2291 RETRO_API void retro_reset(void); | 7667 RETRO_API void retro_reset(void); |
2292 | 7668 |
2293 /* Runs the game for one video frame. | 7669 /** |
2294 * During retro_run(), input_poll callback must be called at least once. | 7670 * Runs the game for one video frame. |
2295 * | 7671 * |
2296 * If a frame is not rendered for reasons where a game "dropped" a frame, | 7672 * During \c retro_run(), the \c retro_input_poll_t callback must be called at least once. |
2297 * this still counts as a frame, and retro_run() should explicitly dupe | 7673 * |
2298 * a frame if GET_CAN_DUPE returns true. | 7674 * @note If a frame is not rendered for reasons where a game "dropped" a frame, |
2299 * In this case, the video callback can take a NULL argument for data. | 7675 * this still counts as a frame, and \c retro_run() should explicitly dupe |
7676 * a frame if \c RETRO_ENVIRONMENT_GET_CAN_DUPE returns true. In this case, | |
7677 * the video callback can take a NULL argument for data. | |
7678 * | |
7679 * @see retro_input_poll_t | |
2300 */ | 7680 */ |
2301 RETRO_API void retro_run(void); | 7681 RETRO_API void retro_run(void); |
2302 | 7682 |
2303 /* Returns the amount of data the implementation requires to serialize | 7683 /** |
2304 * internal state (save states). | 7684 * Returns the amount of data the implementation requires to serialize internal state (save states). |
2305 * Between calls to retro_load_game() and retro_unload_game(), the | 7685 * |
7686 * @note Between calls to \c retro_load_game() and \c retro_unload_game(), the | |
2306 * returned size is never allowed to be larger than a previous returned | 7687 * 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. | 7688 * value, to ensure that the frontend can allocate a save state buffer once. |
7689 * | |
7690 * @return The amount of data the implementation requires to serialize the internal state. | |
7691 * | |
7692 * @see retro_serialize() | |
2308 */ | 7693 */ |
2309 RETRO_API size_t retro_serialize_size(void); | 7694 RETRO_API size_t retro_serialize_size(void); |
2310 | 7695 |
2311 /* Serializes internal state. If failed, or size is lower than | 7696 /** |
2312 * retro_serialize_size(), it should return false, true otherwise. */ | 7697 * Serializes the internal state. |
7698 * | |
7699 * @param data A pointer to where the serialized data should be saved to. | |
7700 * @param size The size of the memory. | |
7701 * | |
7702 * @return If failed, or size is lower than \c retro_serialize_size(), it | |
7703 * should return false. On success, it will return true. | |
7704 * | |
7705 * @see retro_serialize_size() | |
7706 * @see retro_unserialize() | |
7707 */ | |
2313 RETRO_API bool retro_serialize(void *data, size_t size); | 7708 RETRO_API bool retro_serialize(void *data, size_t size); |
7709 | |
7710 /** | |
7711 * Unserialize the given state data, and load it into the internal state. | |
7712 * | |
7713 * @return Returns true if loading the state was successful, false otherwise. | |
7714 * | |
7715 * @see retro_serialize() | |
7716 */ | |
2314 RETRO_API bool retro_unserialize(const void *data, size_t size); | 7717 RETRO_API bool retro_unserialize(const void *data, size_t size); |
2315 | 7718 |
7719 /** | |
7720 * Reset all the active cheats to their default disabled state. | |
7721 * | |
7722 * @see retro_cheat_set() | |
7723 */ | |
2316 RETRO_API void retro_cheat_reset(void); | 7724 RETRO_API void retro_cheat_reset(void); |
7725 | |
7726 /** | |
7727 * Enable or disable a cheat. | |
7728 * | |
7729 * @param index The index of the cheat to act upon. | |
7730 * @param enabled Whether to enable or disable the cheat. | |
7731 * @param code A string of the code used for the cheat. | |
7732 * | |
7733 * @see retro_cheat_reset() | |
7734 */ | |
2317 RETRO_API void retro_cheat_set(unsigned index, bool enabled, const char *code); | 7735 RETRO_API void retro_cheat_set(unsigned index, bool enabled, const char *code); |
2318 | 7736 |
2319 /* Loads a game. */ | 7737 /** |
7738 * Loads a game. | |
7739 * | |
7740 * @param game A pointer to a \c retro_game_info detailing information about the game to load. | |
7741 * May be \c NULL if the core is loaded without content. | |
7742 * | |
7743 * @return Will return true when the game was loaded successfully, or false otherwise. | |
7744 * | |
7745 * @see retro_game_info | |
7746 * @see RETRO_ENVIRONMENT_SET_SUPPORT_NO_GAME | |
7747 */ | |
2320 RETRO_API bool retro_load_game(const struct retro_game_info *game); | 7748 RETRO_API bool retro_load_game(const struct retro_game_info *game); |
2321 | 7749 |
2322 /* Loads a "special" kind of game. Should not be used, | 7750 /** |
2323 * except in extreme cases. */ | 7751 * Called when the frontend has loaded one or more "special" content files, |
7752 * typically through subsystems. | |
7753 * | |
7754 * @note Only necessary for cores that support subsystems. | |
7755 * Others may return \c false or delegate to <tt>retro_load_game</tt>. | |
7756 * | |
7757 * @param game_type The type of game to load, | |
7758 * as determined by \c retro_subsystem_info. | |
7759 * @param info A pointer to an array of \c retro_game_info objects | |
7760 * providing information about the loaded content. | |
7761 * @param num_info The number of \c retro_game_info objects passed into the info parameter. | |
7762 * @return \c true if loading is successful, false otherwise. | |
7763 * If the core returns \c false, | |
7764 * the frontend should abort the core | |
7765 * and return to its main menu (if applicable). | |
7766 * | |
7767 * @see RETRO_ENVIRONMENT_GET_GAME_INFO_EXT | |
7768 * @see RETRO_ENVIRONMENT_SET_SUBSYSTEM_INFO | |
7769 * @see retro_load_game() | |
7770 * @see retro_subsystem_info | |
7771 */ | |
2324 RETRO_API bool retro_load_game_special( | 7772 RETRO_API bool retro_load_game_special( |
2325 unsigned game_type, | 7773 unsigned game_type, |
2326 const struct retro_game_info *info, size_t num_info | 7774 const struct retro_game_info *info, size_t num_info |
2327 ); | 7775 ); |
2328 | 7776 |
2329 /* Unloads a currently loaded game. */ | 7777 /** |
7778 * Unloads the currently loaded game. | |
7779 * | |
7780 * @note This is called before \c retro_deinit(void). | |
7781 * | |
7782 * @see retro_load_game() | |
7783 * @see retro_deinit() | |
7784 */ | |
2330 RETRO_API void retro_unload_game(void); | 7785 RETRO_API void retro_unload_game(void); |
2331 | 7786 |
2332 /* Gets region of game. */ | 7787 /** |
7788 * Gets the region of the actively loaded content as either \c RETRO_REGION_NTSC or \c RETRO_REGION_PAL. | |
7789 * @note This refers to the region of the content's intended television standard, | |
7790 * not necessarily the region of the content's origin. | |
7791 * For emulated consoles that don't use either standard | |
7792 * (e.g. handhelds or post-HD platforms), | |
7793 * the core should return \c RETRO_REGION_NTSC. | |
7794 * @return The region of the actively loaded content. | |
7795 * | |
7796 * @see RETRO_REGION_NTSC | |
7797 * @see RETRO_REGION_PAL | |
7798 */ | |
2333 RETRO_API unsigned retro_get_region(void); | 7799 RETRO_API unsigned retro_get_region(void); |
2334 | 7800 |
2335 /* Gets region of memory. */ | 7801 /** |
7802 * Get a region of memory. | |
7803 * | |
7804 * @param id The ID for the memory block that's desired to retrieve. Can be \c RETRO_MEMORY_SAVE_RAM, \c RETRO_MEMORY_RTC, \c RETRO_MEMORY_SYSTEM_RAM, or \c RETRO_MEMORY_VIDEO_RAM. | |
7805 * | |
7806 * @return A pointer to the desired region of memory, or NULL when not available. | |
7807 * | |
7808 * @see RETRO_MEMORY_SAVE_RAM | |
7809 * @see RETRO_MEMORY_RTC | |
7810 * @see RETRO_MEMORY_SYSTEM_RAM | |
7811 * @see RETRO_MEMORY_VIDEO_RAM | |
7812 */ | |
2336 RETRO_API void *retro_get_memory_data(unsigned id); | 7813 RETRO_API void *retro_get_memory_data(unsigned id); |
7814 | |
7815 /** | |
7816 * Gets the size of the given region of memory. | |
7817 * | |
7818 * @param id The ID for the memory block to check the size of. Can be RETRO_MEMORY_SAVE_RAM, RETRO_MEMORY_RTC, RETRO_MEMORY_SYSTEM_RAM, or RETRO_MEMORY_VIDEO_RAM. | |
7819 * | |
7820 * @return The size of the region in memory, or 0 when not available. | |
7821 * | |
7822 * @see RETRO_MEMORY_SAVE_RAM | |
7823 * @see RETRO_MEMORY_RTC | |
7824 * @see RETRO_MEMORY_SYSTEM_RAM | |
7825 * @see RETRO_MEMORY_VIDEO_RAM | |
7826 */ | |
2337 RETRO_API size_t retro_get_memory_size(unsigned id); | 7827 RETRO_API size_t retro_get_memory_size(unsigned id); |
2338 | 7828 |
2339 #ifdef __cplusplus | 7829 #ifdef __cplusplus |
2340 } | 7830 } |
2341 #endif | 7831 #endif |