From 67e7cfc2004f59862229f292467edf7b706f3d65 Mon Sep 17 00:00:00 2001 From: ds22x Date: Sat, 17 Sep 2022 17:37:51 +0200 Subject: [PATCH] Update to core options v2 interface --- .../libretro-common/include/libretro.h | 1221 ++++++++++++++++- .../libretro-common/include/retro_inline.h | 2 +- src/libretro/libretro.cpp | 37 +- src/libretro/libretro_core_options.h | 636 ++++++--- src/libretro/libretro_core_options_intl.h | 312 +++-- 5 files changed, 1851 insertions(+), 357 deletions(-) diff --git a/src/libretro/libretro-common/include/libretro.h b/src/libretro/libretro-common/include/libretro.h index f97a9695..bb114aed 100644 --- a/src/libretro/libretro-common/include/libretro.h +++ b/src/libretro/libretro-common/include/libretro.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2018 The RetroArch team +/* Copyright (C) 2010-2020 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this libretro API header (libretro.h). @@ -278,6 +278,17 @@ enum retro_language RETRO_LANGUAGE_ARABIC = 16, RETRO_LANGUAGE_GREEK = 17, RETRO_LANGUAGE_TURKISH = 18, + RETRO_LANGUAGE_SLOVAK = 19, + RETRO_LANGUAGE_PERSIAN = 20, + RETRO_LANGUAGE_HEBREW = 21, + RETRO_LANGUAGE_ASTURIAN = 22, + RETRO_LANGUAGE_FINNISH = 23, + RETRO_LANGUAGE_INDONESIAN = 24, + RETRO_LANGUAGE_SWEDISH = 25, + RETRO_LANGUAGE_UKRAINIAN = 26, + RETRO_LANGUAGE_CZECH = 27, + RETRO_LANGUAGE_CATALAN_VALENCIA = 28, + RETRO_LANGUAGE_CATALAN = 29, RETRO_LANGUAGE_LAST, /* Ensure sizeof(enum) == sizeof(int) */ @@ -708,6 +719,9 @@ enum retro_mod * state of rumble motors in controllers. * A strong and weak motor is supported, and they can be * controlled indepedently. + * Should be called from either retro_init() or retro_load_game(). + * Should not be called from retro_set_environment(). + * Returns false if rumble functionality is unavailable. */ #define RETRO_ENVIRONMENT_GET_INPUT_DEVICE_CAPABILITIES 24 /* uint64_t * -- @@ -1087,10 +1101,10 @@ enum retro_mod #define RETRO_ENVIRONMENT_GET_TARGET_REFRESH_RATE (50 | RETRO_ENVIRONMENT_EXPERIMENTAL) /* float * -- - * Float value that lets us know what target refresh rate + * Float value that lets us know what target refresh rate * is curently in use by the frontend. * - * The core can use the returned value to set an ideal + * The core can use the returned value to set an ideal * refresh rate/framerate. */ @@ -1098,7 +1112,7 @@ enum retro_mod /* bool * -- * Boolean value that indicates whether or not the frontend supports * input bitmasks being returned by retro_input_state_t. The advantage - * of this is that retro_input_state_t has to be only called once to + * of this is that retro_input_state_t has to be only called once to * grab all button states instead of multiple times. * * If it returns true, you can pass RETRO_DEVICE_ID_JOYPAD_MASK as 'id' @@ -1123,6 +1137,13 @@ enum retro_mod * retro_core_option_definition structs to RETRO_ENVIRONMENT_SET_CORE_OPTIONS_INTL. * This allows the core to additionally set option sublabel information * and/or provide localisation support. + * + * If version is >= 2, core options may instead be set by passing + * a retro_core_options_v2 struct to RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2, + * or an array of retro_core_options_v2 structs to + * RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2_INTL. This allows the core + * to additionally set optional core option category information + * for frontends with core option category support. */ #define RETRO_ENVIRONMENT_SET_CORE_OPTIONS 53 @@ -1164,7 +1185,7 @@ enum retro_mod * default value is NULL, the first entry in the * retro_core_option_definition::values array is treated as the default. * - * The number of possible options should be very limited, + * The number of possible option values should be very limited, * and must be less than RETRO_NUM_CORE_OPTION_VALUES_MAX. * i.e. it should be feasible to cycle through options * without a keyboard. @@ -1174,7 +1195,7 @@ enum retro_mod * "foo_option", * "Speed hack coprocessor X", * "Provides increased performance at the expense of reduced accuracy", - * { + * { * { "false", NULL }, * { "true", NULL }, * { "unstable", "Turbo (Unstable)" }, @@ -1197,6 +1218,7 @@ enum retro_mod * This should only be called if RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION * returns an API version of >= 1. * This should be called instead of RETRO_ENVIRONMENT_SET_VARIABLES. + * This should be called instead of RETRO_ENVIRONMENT_SET_CORE_OPTIONS. * This should be called the first time as early as * possible (ideally in retro_set_environment). * Afterwards it may be called again for the core to communicate @@ -1246,6 +1268,503 @@ enum retro_mod * default when calling SET_VARIABLES/SET_CORE_OPTIONS. */ +#define RETRO_ENVIRONMENT_GET_PREFERRED_HW_RENDER 56 + /* unsigned * -- + * + * Allows an implementation to ask frontend preferred hardware + * context to use. Core should use this information to deal + * with what specific context to request with SET_HW_RENDER. + * + * 'data' points to an unsigned variable + */ + +#define RETRO_ENVIRONMENT_GET_DISK_CONTROL_INTERFACE_VERSION 57 + /* unsigned * -- + * Unsigned value is the API version number of the disk control + * interface supported by the frontend. If callback return false, + * API version is assumed to be 0. + * + * In legacy code, the disk control interface is defined by passing + * a struct of type retro_disk_control_callback to + * RETRO_ENVIRONMENT_SET_DISK_CONTROL_INTERFACE. + * This may be still be done regardless of the disk control + * interface version. + * + * If version is >= 1 however, the disk control interface may + * instead be defined by passing a struct of type + * retro_disk_control_ext_callback to + * RETRO_ENVIRONMENT_SET_DISK_CONTROL_EXT_INTERFACE. + * This allows the core to provide additional information about + * disk images to the frontend and/or enables extra + * disk control functionality by the frontend. + */ + +#define RETRO_ENVIRONMENT_SET_DISK_CONTROL_EXT_INTERFACE 58 + /* const struct retro_disk_control_ext_callback * -- + * Sets an interface which frontend can use to eject and insert + * disk images, and also obtain information about individual + * disk image files registered by the core. + * This is used for games which consist of multiple images and + * must be manually swapped out by the user (e.g. PSX, floppy disk + * based systems). + */ + +#define RETRO_ENVIRONMENT_GET_MESSAGE_INTERFACE_VERSION 59 + /* unsigned * -- + * Unsigned value is the API version number of the message + * interface supported by the frontend. If callback returns + * false, API version is assumed to be 0. + * + * In legacy code, messages may be displayed in an + * implementation-specific manner by passing a struct + * of type retro_message to RETRO_ENVIRONMENT_SET_MESSAGE. + * This may be still be done regardless of the message + * interface version. + * + * If version is >= 1 however, messages may instead be + * displayed by passing a struct of type retro_message_ext + * to RETRO_ENVIRONMENT_SET_MESSAGE_EXT. This allows the + * core to specify message logging level, priority and + * destination (OSD, logging interface or both). + */ + +#define RETRO_ENVIRONMENT_SET_MESSAGE_EXT 60 + /* const struct retro_message_ext * -- + * Sets a message to be displayed in an implementation-specific + * manner for a certain amount of 'frames'. Additionally allows + * the core to specify message logging level, priority and + * destination (OSD, logging interface or both). + * Should not be used for trivial messages, which should simply be + * logged via RETRO_ENVIRONMENT_GET_LOG_INTERFACE (or as a + * fallback, stderr). + */ + +#define RETRO_ENVIRONMENT_GET_INPUT_MAX_USERS 61 + /* unsigned * -- + * Unsigned value is the number of active input devices + * provided by the frontend. This may change between + * frames, but will remain constant for the duration + * of each frame. + * If callback returns true, a core need not poll any + * input device with an index greater than or equal to + * the number of active devices. + * If callback returns false, the number of active input + * devices is unknown. In this case, all input devices + * should be considered active. + */ + +#define RETRO_ENVIRONMENT_SET_AUDIO_BUFFER_STATUS_CALLBACK 62 + /* const struct retro_audio_buffer_status_callback * -- + * Lets the core know the occupancy level of the frontend + * audio buffer. Can be used by a core to attempt frame + * skipping in order to avoid buffer under-runs. + * A core may pass NULL to disable buffer status reporting + * in the frontend. + */ + +#define RETRO_ENVIRONMENT_SET_MINIMUM_AUDIO_LATENCY 63 + /* const unsigned * -- + * Sets minimum frontend audio latency in milliseconds. + * Resultant audio latency may be larger than set value, + * or smaller if a hardware limit is encountered. A frontend + * is expected to honour requests up to 512 ms. + * + * - If value is less than current frontend + * audio latency, callback has no effect + * - If value is zero, default frontend audio + * latency is set + * + * May be used by a core to increase audio latency and + * therefore decrease the probability of buffer under-runs + * (crackling) when performing 'intensive' operations. + * A core utilising RETRO_ENVIRONMENT_SET_AUDIO_BUFFER_STATUS_CALLBACK + * to implement audio-buffer-based frame skipping may achieve + * optimal results by setting the audio latency to a 'high' + * (typically 6x or 8x) integer multiple of the expected + * frame time. + * + * WARNING: This can only be called from within retro_run(). + * Calling this can require a full reinitialization of audio + * drivers in the frontend, so it is important to call it very + * sparingly, and usually only with the users explicit consent. + * An eventual driver reinitialize will happen so that audio + * callbacks happening after this call within the same retro_run() + * call will target the newly initialized driver. + */ + +#define RETRO_ENVIRONMENT_SET_FASTFORWARDING_OVERRIDE 64 + /* const struct retro_fastforwarding_override * -- + * Used by a libretro core to override the current + * fastforwarding mode of the frontend. + * If NULL is passed to this function, the frontend + * will return true if fastforwarding override + * functionality is supported (no change in + * fastforwarding state will occur in this case). + */ + +#define RETRO_ENVIRONMENT_SET_CONTENT_INFO_OVERRIDE 65 + /* const struct retro_system_content_info_override * -- + * Allows an implementation to override 'global' content + * info parameters reported by retro_get_system_info(). + * Overrides also affect subsystem content info parameters + * set via RETRO_ENVIRONMENT_SET_SUBSYSTEM_INFO. + * This function must be called inside retro_set_environment(). + * If callback returns false, content info overrides + * are unsupported by the frontend, and will be ignored. + * If callback returns true, extended game info may be + * retrieved by calling RETRO_ENVIRONMENT_GET_GAME_INFO_EXT + * in retro_load_game() or retro_load_game_special(). + * + * 'data' points to an array of retro_system_content_info_override + * structs terminated by a { NULL, false, false } element. + * If 'data' is NULL, no changes will be made to the frontend; + * a core may therefore pass NULL in order to test whether + * the RETRO_ENVIRONMENT_SET_CONTENT_INFO_OVERRIDE and + * RETRO_ENVIRONMENT_GET_GAME_INFO_EXT callbacks are supported + * by the frontend. + * + * For struct member descriptions, see the definition of + * struct retro_system_content_info_override. + * + * Example: + * + * - struct retro_system_info: + * { + * "My Core", // library_name + * "v1.0", // library_version + * "m3u|md|cue|iso|chd|sms|gg|sg", // valid_extensions + * true, // need_fullpath + * false // block_extract + * } + * + * - Array of struct retro_system_content_info_override: + * { + * { + * "md|sms|gg", // extensions + * false, // need_fullpath + * true // persistent_data + * }, + * { + * "sg", // extensions + * false, // need_fullpath + * false // persistent_data + * }, + * { NULL, false, false } + * } + * + * Result: + * - Files of type m3u, cue, iso, chd will not be + * loaded by the frontend. Frontend will pass a + * valid path to the core, and core will handle + * loading internally + * - Files of type md, sms, gg will be loaded by + * the frontend. A valid memory buffer will be + * passed to the core. This memory buffer will + * remain valid until retro_deinit() returns + * - Files of type sg will be loaded by the frontend. + * A valid memory buffer will be passed to the core. + * This memory buffer will remain valid until + * retro_load_game() (or retro_load_game_special()) + * returns + * + * NOTE: If an extension is listed multiple times in + * an array of retro_system_content_info_override + * structs, only the first instance will be registered + */ + +#define RETRO_ENVIRONMENT_GET_GAME_INFO_EXT 66 + /* const struct retro_game_info_ext ** -- + * Allows an implementation to fetch extended game + * information, providing additional content path + * and memory buffer status details. + * This function may only be called inside + * retro_load_game() or retro_load_game_special(). + * If callback returns false, extended game information + * is unsupported by the frontend. In this case, only + * regular retro_game_info will be available. + * RETRO_ENVIRONMENT_GET_GAME_INFO_EXT is guaranteed + * to return true if RETRO_ENVIRONMENT_SET_CONTENT_INFO_OVERRIDE + * returns true. + * + * 'data' points to an array of retro_game_info_ext structs. + * + * For struct member descriptions, see the definition of + * struct retro_game_info_ext. + * + * - If function is called inside retro_load_game(), + * the retro_game_info_ext array is guaranteed to + * have a size of 1 - i.e. the returned pointer may + * be used to access directly the members of the + * first retro_game_info_ext struct, for example: + * + * struct retro_game_info_ext *game_info_ext; + * if (environ_cb(RETRO_ENVIRONMENT_GET_GAME_INFO_EXT, &game_info_ext)) + * printf("Content Directory: %s\n", game_info_ext->dir); + * + * - If the function is called inside retro_load_game_special(), + * the retro_game_info_ext array is guaranteed to have a + * size equal to the num_info argument passed to + * retro_load_game_special() + */ + +#define RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2 67 + /* const struct retro_core_options_v2 * -- + * Allows an implementation to signal the environment + * which variables it might want to check for later using + * GET_VARIABLE. + * This allows the frontend to present these variables to + * a user dynamically. + * This should only be called if RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION + * returns an API version of >= 2. + * This should be called instead of RETRO_ENVIRONMENT_SET_VARIABLES. + * This should be called instead of RETRO_ENVIRONMENT_SET_CORE_OPTIONS. + * This should be called the first time as early as + * possible (ideally in retro_set_environment). + * Afterwards it may be called again for the core to communicate + * updated options to the frontend, but the number of core + * options must not change from the number in the initial call. + * If RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION returns an API + * version of >= 2, this callback is guaranteed to succeed + * (i.e. callback return value does not indicate success) + * If callback returns true, frontend has core option category + * support. + * If callback returns false, frontend does not have core option + * category support. + * + * 'data' points to a retro_core_options_v2 struct, containing + * of two pointers: + * - retro_core_options_v2::categories is an array of + * retro_core_option_v2_category structs terminated by a + * { NULL, NULL, NULL } element. If retro_core_options_v2::categories + * is NULL, all core options will have no category and will be shown + * at the top level of the frontend core option interface. If frontend + * does not have core option category support, categories array will + * be ignored. + * - retro_core_options_v2::definitions is an array of + * retro_core_option_v2_definition structs terminated by a + * { NULL, NULL, NULL, NULL, NULL, NULL, {{0}}, NULL } + * element. + * + * >> retro_core_option_v2_category notes: + * + * - retro_core_option_v2_category::key should contain string + * that uniquely identifies the core option category. Valid + * key characters are [a-z, A-Z, 0-9, _, -] + * Namespace collisions with other implementations' category + * keys are permitted. + * - retro_core_option_v2_category::desc should contain a human + * readable description of the category key. + * - retro_core_option_v2_category::info should contain any + * additional human readable information text that a typical + * user may need to understand the nature of the core option + * category. + * + * Example entry: + * { + * "advanced_settings", + * "Advanced", + * "Options affecting low-level emulation performance and accuracy." + * } + * + * >> retro_core_option_v2_definition notes: + * + * - retro_core_option_v2_definition::key should be namespaced to not + * collide with other implementations' keys. e.g. A core called + * 'foo' should use keys named as 'foo_option'. Valid key characters + * are [a-z, A-Z, 0-9, _, -]. + * - retro_core_option_v2_definition::desc should contain a human readable + * description of the key. Will be used when the frontend does not + * have core option category support. Examples: "Aspect Ratio" or + * "Video > Aspect Ratio". + * - retro_core_option_v2_definition::desc_categorized should contain a + * human readable description of the key, which will be used when + * frontend has core option category support. Example: "Aspect Ratio", + * where associated retro_core_option_v2_category::desc is "Video". + * If empty or NULL, the string specified by + * retro_core_option_v2_definition::desc will be used instead. + * retro_core_option_v2_definition::desc_categorized will be ignored + * if retro_core_option_v2_definition::category_key is empty or NULL. + * - retro_core_option_v2_definition::info should contain any additional + * human readable information text that a typical user may need to + * understand the functionality of the option. + * - retro_core_option_v2_definition::info_categorized should contain + * any additional human readable information text that a typical user + * may need to understand the functionality of the option, and will be + * used when frontend has core option category support. This is provided + * to accommodate the case where info text references an option by + * name/desc, and the desc/desc_categorized text for that option differ. + * If empty or NULL, the string specified by + * retro_core_option_v2_definition::info will be used instead. + * retro_core_option_v2_definition::info_categorized will be ignored + * if retro_core_option_v2_definition::category_key is empty or NULL. + * - retro_core_option_v2_definition::category_key should contain a + * category identifier (e.g. "video" or "audio") that will be + * assigned to the core option if frontend has core option category + * support. A categorized option will be shown in a subsection/ + * submenu of the frontend core option interface. If key is empty + * or NULL, or if key does not match one of the + * retro_core_option_v2_category::key values in the associated + * retro_core_option_v2_category array, option will have no category + * and will be shown at the top level of the frontend core option + * interface. + * - retro_core_option_v2_definition::values is an array of + * retro_core_option_value structs terminated by a { NULL, NULL } + * element. + * --> retro_core_option_v2_definition::values[index].value is an + * expected option value. + * --> retro_core_option_v2_definition::values[index].label is a + * human readable label used when displaying the value on screen. + * If NULL, the value itself is used. + * - retro_core_option_v2_definition::default_value is the default + * core option setting. It must match one of the expected option + * values in the retro_core_option_v2_definition::values array. If + * it does not, or the default value is NULL, the first entry in the + * retro_core_option_v2_definition::values array is treated as the + * default. + * + * The number of possible option values should be very limited, + * and must be less than RETRO_NUM_CORE_OPTION_VALUES_MAX. + * i.e. it should be feasible to cycle through options + * without a keyboard. + * + * Example entries: + * + * - Uncategorized: + * + * { + * "foo_option", + * "Speed hack coprocessor X", + * NULL, + * "Provides increased performance at the expense of reduced accuracy.", + * NULL, + * NULL, + * { + * { "false", NULL }, + * { "true", NULL }, + * { "unstable", "Turbo (Unstable)" }, + * { NULL, NULL }, + * }, + * "false" + * } + * + * - Categorized: + * + * { + * "foo_option", + * "Advanced > Speed hack coprocessor X", + * "Speed hack coprocessor X", + * "Setting 'Advanced > Speed hack coprocessor X' to 'true' or 'Turbo' provides increased performance at the expense of reduced accuracy", + * "Setting 'Speed hack coprocessor X' to 'true' or 'Turbo' provides increased performance at the expense of reduced accuracy", + * "advanced_settings", + * { + * { "false", NULL }, + * { "true", NULL }, + * { "unstable", "Turbo (Unstable)" }, + * { NULL, NULL }, + * }, + * "false" + * } + * + * Only strings are operated on. The possible values will + * generally be displayed and stored as-is by the frontend. + */ + +#define RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2_INTL 68 + /* const struct retro_core_options_v2_intl * -- + * Allows an implementation to signal the environment + * which variables it might want to check for later using + * GET_VARIABLE. + * This allows the frontend to present these variables to + * a user dynamically. + * This should only be called if RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION + * returns an API version of >= 2. + * This should be called instead of RETRO_ENVIRONMENT_SET_VARIABLES. + * This should be called instead of RETRO_ENVIRONMENT_SET_CORE_OPTIONS. + * This should be called instead of RETRO_ENVIRONMENT_SET_CORE_OPTIONS_INTL. + * This should be called instead of RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2. + * This should be called the first time as early as + * possible (ideally in retro_set_environment). + * Afterwards it may be called again for the core to communicate + * updated options to the frontend, but the number of core + * options must not change from the number in the initial call. + * If RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION returns an API + * version of >= 2, this callback is guaranteed to succeed + * (i.e. callback return value does not indicate success) + * If callback returns true, frontend has core option category + * support. + * If callback returns false, frontend does not have core option + * category support. + * + * This is fundamentally the same as RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2, + * with the addition of localisation support. The description of the + * RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2 callback should be consulted + * for further details. + * + * 'data' points to a retro_core_options_v2_intl struct. + * + * - retro_core_options_v2_intl::us is a pointer to a + * retro_core_options_v2 struct defining the US English + * core options implementation. It must point to a valid struct. + * + * - retro_core_options_v2_intl::local is a pointer to a + * retro_core_options_v2 struct defining core options for + * the current frontend language. It may be NULL (in which case + * retro_core_options_v2_intl::us is used by the frontend). Any items + * missing from this struct will be read from + * retro_core_options_v2_intl::us instead. + * + * NOTE: Default core option values are always taken from the + * retro_core_options_v2_intl::us struct. Any default values in + * the retro_core_options_v2_intl::local struct will be ignored. + */ + +#define RETRO_ENVIRONMENT_SET_CORE_OPTIONS_UPDATE_DISPLAY_CALLBACK 69 + /* const struct retro_core_options_update_display_callback * -- + * Allows a frontend to signal that a core must update + * the visibility of any dynamically hidden core options, + * and enables the frontend to detect visibility changes. + * Used by the frontend to update the menu display status + * of core options without requiring a call of retro_run(). + * Must be called in retro_set_environment(). + */ + +#define RETRO_ENVIRONMENT_SET_VARIABLE 70 + /* const struct retro_variable * -- + * Allows an implementation to notify the frontend + * that a core option value has changed. + * + * retro_variable::key and retro_variable::value + * must match strings that have been set previously + * via one of the following: + * + * - RETRO_ENVIRONMENT_SET_VARIABLES + * - RETRO_ENVIRONMENT_SET_CORE_OPTIONS + * - RETRO_ENVIRONMENT_SET_CORE_OPTIONS_INTL + * - RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2 + * - RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2_INTL + * + * After changing a core option value via this + * callback, RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE + * will return true. + * + * If data is NULL, no changes will be registered + * and the callback will return true; an + * implementation may therefore pass NULL in order + * to test whether the callback is supported. + */ + +#define RETRO_ENVIRONMENT_GET_THROTTLE_STATE (71 | RETRO_ENVIRONMENT_EXPERIMENTAL) + /* struct retro_throttle_state * -- + * Allows an implementation to get details on the actual rate + * the frontend is attempting to call retro_run(). + */ + +#define RETRO_ENVIRONMENT_GET_SAVESTATE_CONTEXT (72 | RETRO_ENVIRONMENT_EXPERIMENTAL) + /* int * -- + * Tells the core about the context the frontend is asking for savestate. + * (see enum retro_savestate_context) + */ + /* VFS functionality */ /* File paths: @@ -1382,17 +1901,17 @@ typedef int (RETRO_CALLCONV *retro_vfs_closedir_t)(struct retro_vfs_dir_handle * struct retro_vfs_interface { /* VFS API v1 */ - retro_vfs_get_path_t get_path; - retro_vfs_open_t open; - retro_vfs_close_t close; - retro_vfs_size_t size; - retro_vfs_tell_t tell; - retro_vfs_seek_t seek; - retro_vfs_read_t read; - retro_vfs_write_t write; - retro_vfs_flush_t flush; - retro_vfs_remove_t remove; - retro_vfs_rename_t rename; + retro_vfs_get_path_t get_path; + retro_vfs_open_t open; + retro_vfs_close_t close; + retro_vfs_size_t size; + retro_vfs_tell_t tell; + retro_vfs_seek_t seek; + retro_vfs_read_t read; + retro_vfs_write_t write; + retro_vfs_flush_t flush; + retro_vfs_remove_t remove; + retro_vfs_rename_t rename; /* VFS API v2 */ retro_vfs_truncate_t truncate; /* VFS API v3 */ @@ -1420,11 +1939,11 @@ struct retro_vfs_interface_info enum retro_hw_render_interface_type { - RETRO_HW_RENDER_INTERFACE_VULKAN = 0, - RETRO_HW_RENDER_INTERFACE_D3D9 = 1, - RETRO_HW_RENDER_INTERFACE_D3D10 = 2, - RETRO_HW_RENDER_INTERFACE_D3D11 = 3, - RETRO_HW_RENDER_INTERFACE_D3D12 = 4, + RETRO_HW_RENDER_INTERFACE_VULKAN = 0, + RETRO_HW_RENDER_INTERFACE_D3D9 = 1, + RETRO_HW_RENDER_INTERFACE_D3D10 = 2, + RETRO_HW_RENDER_INTERFACE_D3D11 = 3, + RETRO_HW_RENDER_INTERFACE_D3D12 = 4, RETRO_HW_RENDER_INTERFACE_GSKIT_PS2 = 5, RETRO_HW_RENDER_INTERFACE_DUMMY = INT_MAX }; @@ -1922,6 +2441,10 @@ enum retro_sensor_action { RETRO_SENSOR_ACCELEROMETER_ENABLE = 0, RETRO_SENSOR_ACCELEROMETER_DISABLE, + RETRO_SENSOR_GYROSCOPE_ENABLE, + RETRO_SENSOR_GYROSCOPE_DISABLE, + RETRO_SENSOR_ILLUMINANCE_ENABLE, + RETRO_SENSOR_ILLUMINANCE_DISABLE, RETRO_SENSOR_DUMMY = INT_MAX }; @@ -1930,6 +2453,10 @@ enum retro_sensor_action #define RETRO_SENSOR_ACCELEROMETER_X 0 #define RETRO_SENSOR_ACCELEROMETER_Y 1 #define RETRO_SENSOR_ACCELEROMETER_Z 2 +#define RETRO_SENSOR_GYROSCOPE_X 3 +#define RETRO_SENSOR_GYROSCOPE_Y 4 +#define RETRO_SENSOR_GYROSCOPE_Z 5 +#define RETRO_SENSOR_ILLUMINANCE 6 typedef bool (RETRO_CALLCONV *retro_set_sensor_state_t)(unsigned port, enum retro_sensor_action action, unsigned rate); @@ -2127,6 +2654,30 @@ struct retro_frame_time_callback retro_usec_t reference; }; +/* Notifies a libretro core of the current occupancy + * level of the frontend audio buffer. + * + * - active: 'true' if audio buffer is currently + * in use. Will be 'false' if audio is + * disabled in the frontend + * + * - occupancy: Given as a value in the range [0,100], + * corresponding to the occupancy percentage + * of the audio buffer + * + * - underrun_likely: 'true' if the frontend expects an + * audio buffer underrun during the + * next frame (indicates that a core + * should attempt frame skipping) + * + * It will be called right before retro_run() every frame. */ +typedef void (RETRO_CALLCONV *retro_audio_buffer_status_callback_t)( + bool active, unsigned occupancy, bool underrun_likely); +struct retro_audio_buffer_status_callback +{ + retro_audio_buffer_status_callback_t callback; +}; + /* Pass this to retro_video_refresh_t if rendering to hardware. * Passing NULL to retro_video_refresh_t is still a frame dupe as normal. * */ @@ -2287,7 +2838,8 @@ struct retro_keyboard_callback retro_keyboard_event_t callback; }; -/* Callbacks for RETRO_ENVIRONMENT_SET_DISK_CONTROL_INTERFACE. +/* Callbacks for RETRO_ENVIRONMENT_SET_DISK_CONTROL_INTERFACE & + * RETRO_ENVIRONMENT_SET_DISK_CONTROL_EXT_INTERFACE. * Should be set for implementations which can swap out multiple disk * images in runtime. * @@ -2345,6 +2897,53 @@ typedef bool (RETRO_CALLCONV *retro_replace_image_index_t)(unsigned index, * with replace_image_index. */ typedef bool (RETRO_CALLCONV *retro_add_image_index_t)(void); +/* Sets initial image to insert in drive when calling + * core_load_game(). + * Since we cannot pass the initial index when loading + * content (this would require a major API change), this + * is set by the frontend *before* calling the core's + * retro_load_game()/retro_load_game_special() implementation. + * A core should therefore cache the index/path values and handle + * them inside retro_load_game()/retro_load_game_special(). + * - If 'index' is invalid (index >= get_num_images()), the + * core should ignore the set value and instead use 0 + * - 'path' is used purely for error checking - i.e. when + * content is loaded, the core should verify that the + * disk specified by 'index' has the specified file path. + * This is to guard against auto selecting the wrong image + * if (for example) the user should modify an existing M3U + * playlist. We have to let the core handle this because + * set_initial_image() must be called before loading content, + * i.e. the frontend cannot access image paths in advance + * and thus cannot perform the error check itself. + * If set path and content path do not match, the core should + * ignore the set 'index' value and instead use 0 + * Returns 'false' if index or 'path' are invalid, or core + * does not support this functionality + */ +typedef bool (RETRO_CALLCONV *retro_set_initial_image_t)(unsigned index, const char *path); + +/* Fetches the path of the specified disk image file. + * Returns 'false' if index is invalid (index >= get_num_images()) + * or path is otherwise unavailable. + */ +typedef bool (RETRO_CALLCONV *retro_get_image_path_t)(unsigned index, char *path, size_t len); + +/* Fetches a core-provided 'label' for the specified disk + * image file. In the simplest case this may be a file name + * (without extension), but for cores with more complex + * content requirements information may be provided to + * facilitate user disk swapping - for example, a core + * running floppy-disk-based content may uniquely label + * save disks, data disks, level disks, etc. with names + * corresponding to in-game disk change prompts (so the + * frontend can provide better user guidance than a 'dumb' + * disk index value). + * Returns 'false' if index is invalid (index >= get_num_images()) + * or label is otherwise unavailable. + */ +typedef bool (RETRO_CALLCONV *retro_get_image_label_t)(unsigned index, char *label, size_t len); + struct retro_disk_control_callback { retro_set_eject_state_t set_eject_state; @@ -2358,6 +2957,27 @@ struct retro_disk_control_callback retro_add_image_index_t add_image_index; }; +struct retro_disk_control_ext_callback +{ + retro_set_eject_state_t set_eject_state; + retro_get_eject_state_t get_eject_state; + + retro_get_image_index_t get_image_index; + retro_set_image_index_t set_image_index; + retro_get_num_images_t get_num_images; + + retro_replace_image_index_t replace_image_index; + retro_add_image_index_t add_image_index; + + /* NOTE: Frontend will only attempt to record/restore + * last used disk index if both set_initial_image() + * and get_image_path() are implemented */ + retro_set_initial_image_t set_initial_image; /* Optional - may be NULL */ + + retro_get_image_path_t get_image_path; /* Optional - may be NULL */ + retro_get_image_label_t get_image_label; /* Optional - may be NULL */ +}; + enum retro_pixel_format { /* 0RGB1555, native endian. @@ -2382,12 +3002,139 @@ enum retro_pixel_format RETRO_PIXEL_FORMAT_UNKNOWN = INT_MAX }; +enum retro_savestate_context +{ + /* Standard savestate written to disk. */ + RETRO_SAVESTATE_CONTEXT_NORMAL = 0, + + /* Savestate where you are guaranteed that the same instance will load the save state. + * You can store internal pointers to code or data. + * It's still a full serialization and deserialization, and could be loaded or saved at any time. + * It won't be written to disk or sent over the network. + */ + RETRO_SAVESTATE_CONTEXT_RUNAHEAD_SAME_INSTANCE = 1, + + /* Savestate where you are guaranteed that the same emulator binary will load that savestate. + * You can skip anything that would slow down saving or loading state but you can not store internal pointers. + * It won't be written to disk or sent over the network. + * Example: "Second Instance" runahead + */ + RETRO_SAVESTATE_CONTEXT_RUNAHEAD_SAME_BINARY = 2, + + /* Savestate used within a rollback netplay feature. + * You should skip anything that would unnecessarily increase bandwidth usage. + * It won't be written to disk but it will be sent over the network. + */ + RETRO_SAVESTATE_CONTEXT_ROLLBACK_NETPLAY = 3, + + /* Ensure sizeof() == sizeof(int). */ + RETRO_SAVESTATE_CONTEXT_UNKNOWN = INT_MAX +}; + struct retro_message { const char *msg; /* Message to be displayed. */ unsigned frames; /* Duration in frames of message. */ }; +enum retro_message_target +{ + RETRO_MESSAGE_TARGET_ALL = 0, + RETRO_MESSAGE_TARGET_OSD, + RETRO_MESSAGE_TARGET_LOG +}; + +enum retro_message_type +{ + RETRO_MESSAGE_TYPE_NOTIFICATION = 0, + RETRO_MESSAGE_TYPE_NOTIFICATION_ALT, + RETRO_MESSAGE_TYPE_STATUS, + RETRO_MESSAGE_TYPE_PROGRESS +}; + +struct retro_message_ext +{ + /* Message string to be displayed/logged */ + const char *msg; + /* Duration (in ms) of message when targeting the OSD */ + unsigned duration; + /* Message priority when targeting the OSD + * > When multiple concurrent messages are sent to + * the frontend and the frontend does not have the + * capacity to display them all, messages with the + * *highest* priority value should be shown + * > There is no upper limit to a message priority + * value (within the bounds of the unsigned data type) + * > In the reference frontend (RetroArch), the same + * priority values are used for frontend-generated + * notifications, which are typically assigned values + * between 0 and 3 depending upon importance */ + unsigned priority; + /* Message logging level (info, warn, error, etc.) */ + enum retro_log_level level; + /* Message destination: OSD, logging interface or both */ + enum retro_message_target target; + /* Message 'type' when targeting the OSD + * > RETRO_MESSAGE_TYPE_NOTIFICATION: Specifies that a + * message should be handled in identical fashion to + * a standard frontend-generated notification + * > RETRO_MESSAGE_TYPE_NOTIFICATION_ALT: Specifies that + * message is a notification that requires user attention + * or action, but that it should be displayed in a manner + * that differs from standard frontend-generated notifications. + * This would typically correspond to messages that should be + * displayed immediately (independently from any internal + * frontend message queue), and/or which should be visually + * distinguishable from frontend-generated notifications. + * For example, a core may wish to inform the user of + * information related to a disk-change event. It is + * expected that the frontend itself may provide a + * notification in this case; if the core sends a + * message of type RETRO_MESSAGE_TYPE_NOTIFICATION, an + * uncomfortable 'double-notification' may occur. A message + * of RETRO_MESSAGE_TYPE_NOTIFICATION_ALT should therefore + * be presented such that visual conflict with regular + * notifications does not occur + * > RETRO_MESSAGE_TYPE_STATUS: Indicates that message + * is not a standard notification. This typically + * corresponds to 'status' indicators, such as a core's + * internal FPS, which are intended to be displayed + * either permanently while a core is running, or in + * a manner that does not suggest user attention or action + * is required. 'Status' type messages should therefore be + * displayed in a different on-screen location and in a manner + * easily distinguishable from both standard frontend-generated + * notifications and messages of type RETRO_MESSAGE_TYPE_NOTIFICATION_ALT + * > RETRO_MESSAGE_TYPE_PROGRESS: Indicates that message reports + * the progress of an internal core task. For example, in cases + * where a core itself handles the loading of content from a file, + * this may correspond to the percentage of the file that has been + * read. Alternatively, an audio/video playback core may use a + * message of type RETRO_MESSAGE_TYPE_PROGRESS to display the current + * playback position as a percentage of the runtime. 'Progress' type + * messages should therefore be displayed as a literal progress bar, + * where: + * - 'retro_message_ext.msg' is the progress bar title/label + * - 'retro_message_ext.progress' determines the length of + * the progress bar + * NOTE: Message type is a *hint*, and may be ignored + * by the frontend. If a frontend lacks support for + * displaying messages via alternate means than standard + * frontend-generated notifications, it will treat *all* + * messages as having the type RETRO_MESSAGE_TYPE_NOTIFICATION */ + enum retro_message_type type; + /* Task progress when targeting the OSD and message is + * of type RETRO_MESSAGE_TYPE_PROGRESS + * > -1: Unmetered/indeterminate + * > 0-100: Current progress percentage + * NOTE: Since message type is a hint, a frontend may ignore + * progress values. Where relevant, a core should therefore + * include progress percentage within the message string, + * such that the message intent remains clear when displayed + * as a standard frontend-generated notification */ + int8_t progress; +}; + /* Describes how the libretro implementation maps a libretro input bind * to its internal input system through a human readable string. * This string can be used to better let a user configure input. */ @@ -2408,7 +3155,7 @@ struct retro_input_descriptor struct retro_system_info { /* All pointers are owned by libretro implementation, and pointers must - * remain valid until retro_deinit() is called. */ + * remain valid until it is unloaded. */ const char *library_name; /* Descriptive name of library. Should not * contain any version numbers, etc. */ @@ -2450,6 +3197,213 @@ struct retro_system_info bool block_extract; }; +/* Defines overrides which modify frontend handling of + * specific content file types. + * An array of retro_system_content_info_override is + * passed to RETRO_ENVIRONMENT_SET_CONTENT_INFO_OVERRIDE + * NOTE: In the following descriptions, references to + * retro_load_game() may be replaced with + * retro_load_game_special() */ +struct retro_system_content_info_override +{ + /* A list of file extensions for which the override + * should apply, delimited by a 'pipe' character + * (e.g. "md|sms|gg") + * Permitted file extensions are limited to those + * included in retro_system_info::valid_extensions + * and/or retro_subsystem_rom_info::valid_extensions */ + const char *extensions; + + /* Overrides the need_fullpath value set in + * retro_system_info and/or retro_subsystem_rom_info. + * To reiterate: + * + * If need_fullpath is true and retro_load_game() is called: + * - retro_game_info::path is guaranteed to contain a valid + * path to an existent file + * - retro_game_info::data and retro_game_info::size are invalid + * + * If need_fullpath is false and retro_load_game() is called: + * - retro_game_info::path may be NULL + * - retro_game_info::data and retro_game_info::size are guaranteed + * to be valid + * + * In addition: + * + * If need_fullpath is true and retro_load_game() is called: + * - retro_game_info_ext::full_path is guaranteed to contain a valid + * path to an existent file + * - retro_game_info_ext::archive_path may be NULL + * - retro_game_info_ext::archive_file may be NULL + * - retro_game_info_ext::dir is guaranteed to contain a valid path + * to the directory in which the content file exists + * - retro_game_info_ext::name is guaranteed to contain the + * basename of the content file, without extension + * - retro_game_info_ext::ext is guaranteed to contain the + * extension of the content file in lower case format + * - retro_game_info_ext::data and retro_game_info_ext::size + * are invalid + * + * If need_fullpath is false and retro_load_game() is called: + * - If retro_game_info_ext::file_in_archive is false: + * - retro_game_info_ext::full_path is guaranteed to contain + * a valid path to an existent file + * - retro_game_info_ext::archive_path may be NULL + * - retro_game_info_ext::archive_file may be NULL + * - retro_game_info_ext::dir is guaranteed to contain a + * valid path to the directory in which the content file exists + * - retro_game_info_ext::name is guaranteed to contain the + * basename of the content file, without extension + * - retro_game_info_ext::ext is guaranteed to contain the + * extension of the content file in lower case format + * - If retro_game_info_ext::file_in_archive is true: + * - retro_game_info_ext::full_path may be NULL + * - retro_game_info_ext::archive_path is guaranteed to + * contain a valid path to an existent compressed file + * inside which the content file is located + * - retro_game_info_ext::archive_file is guaranteed to + * contain a valid path to an existent content file + * inside the compressed file referred to by + * retro_game_info_ext::archive_path + * e.g. for a compressed file '/path/to/foo.zip' + * containing 'bar.sfc' + * > retro_game_info_ext::archive_path will be '/path/to/foo.zip' + * > retro_game_info_ext::archive_file will be 'bar.sfc' + * - retro_game_info_ext::dir is guaranteed to contain a + * valid path to the directory in which the compressed file + * (containing the content file) exists + * - retro_game_info_ext::name is guaranteed to contain + * EITHER + * 1) the basename of the compressed file (containing + * the content file), without extension + * OR + * 2) the basename of the content file inside the + * compressed file, without extension + * In either case, a core should consider 'name' to + * be the canonical name/ID of the the content file + * - retro_game_info_ext::ext is guaranteed to contain the + * extension of the content file inside the compressed file, + * in lower case format + * - retro_game_info_ext::data and retro_game_info_ext::size are + * guaranteed to be valid */ + bool need_fullpath; + + /* If need_fullpath is false, specifies whether the content + * data buffer available in retro_load_game() is 'persistent' + * + * If persistent_data is false and retro_load_game() is called: + * - retro_game_info::data and retro_game_info::size + * are valid only until retro_load_game() returns + * - retro_game_info_ext::data and retro_game_info_ext::size + * are valid only until retro_load_game() returns + * + * If persistent_data is true and retro_load_game() is called: + * - retro_game_info::data and retro_game_info::size + * are valid until retro_deinit() returns + * - retro_game_info_ext::data and retro_game_info_ext::size + * are valid until retro_deinit() returns */ + bool persistent_data; +}; + +/* Similar to retro_game_info, but provides extended + * information about the source content file and + * game memory buffer status. + * And array of retro_game_info_ext is returned by + * RETRO_ENVIRONMENT_GET_GAME_INFO_EXT + * NOTE: In the following descriptions, references to + * retro_load_game() may be replaced with + * retro_load_game_special() */ +struct retro_game_info_ext +{ + /* - If file_in_archive is false, contains a valid + * path to an existent content file (UTF-8 encoded) + * - If file_in_archive is true, may be NULL */ + const char *full_path; + + /* - If file_in_archive is false, may be NULL + * - If file_in_archive is true, contains a valid path + * to an existent compressed file inside which the + * content file is located (UTF-8 encoded) */ + const char *archive_path; + + /* - If file_in_archive is false, may be NULL + * - If file_in_archive is true, contain a valid path + * to an existent content file inside the compressed + * file referred to by archive_path (UTF-8 encoded) + * e.g. for a compressed file '/path/to/foo.zip' + * containing 'bar.sfc' + * > archive_path will be '/path/to/foo.zip' + * > archive_file will be 'bar.sfc' */ + const char *archive_file; + + /* - If file_in_archive is false, contains a valid path + * to the directory in which the content file exists + * (UTF-8 encoded) + * - If file_in_archive is true, contains a valid path + * to the directory in which the compressed file + * (containing the content file) exists (UTF-8 encoded) */ + const char *dir; + + /* Contains the canonical name/ID of the content file + * (UTF-8 encoded). Intended for use when identifying + * 'complementary' content named after the loaded file - + * i.e. companion data of a different format (a CD image + * required by a ROM), texture packs, internally handled + * save files, etc. + * - If file_in_archive is false, contains the basename + * of the content file, without extension + * - If file_in_archive is true, then string is + * implementation specific. A frontend may choose to + * set a name value of: + * EITHER + * 1) the basename of the compressed file (containing + * the content file), without extension + * OR + * 2) the basename of the content file inside the + * compressed file, without extension + * RetroArch sets the 'name' value according to (1). + * A frontend that supports routine loading of + * content from archives containing multiple unrelated + * content files may set the 'name' value according + * to (2). */ + const char *name; + + /* - If file_in_archive is false, contains the extension + * of the content file in lower case format + * - If file_in_archive is true, contains the extension + * of the content file inside the compressed file, + * in lower case format */ + const char *ext; + + /* String of implementation specific meta-data. */ + const char *meta; + + /* Memory buffer of loaded game content. Will be NULL: + * IF + * - retro_system_info::need_fullpath is true and + * retro_system_content_info_override::need_fullpath + * is unset + * OR + * - retro_system_content_info_override::need_fullpath + * is true */ + const void *data; + + /* Size of game content memory buffer, in bytes */ + size_t size; + + /* True if loaded content file is inside a compressed + * archive */ + bool file_in_archive; + + /* - If data is NULL, value is unset/ignored + * - If data is non-NULL: + * - If persistent_data is false, data and size are + * valid only until retro_load_game() returns + * - If persistent_data is true, data and size are + * are valid until retro_deinit() returns */ + bool persistent_data; +}; + struct retro_game_geometry { unsigned base_width; /* Nominal video width of game. */ @@ -2548,6 +3502,10 @@ struct retro_core_option_definition const char *default_value; }; +#ifdef __PS3__ +#undef local +#endif + struct retro_core_options_intl { /* Pointer to an array of retro_core_option_definition structs @@ -2561,6 +3519,143 @@ struct retro_core_options_intl struct retro_core_option_definition *local; }; +struct retro_core_option_v2_category +{ + /* Variable uniquely identifying the + * option category. Valid key characters + * are [a-z, A-Z, 0-9, _, -] */ + const char *key; + + /* Human-readable category description + * > Used as category menu label when + * frontend has core option category + * support */ + const char *desc; + + /* Human-readable category information + * > Used as category menu sublabel when + * frontend has core option category + * support + * > Optional (may be NULL or an empty + * string) */ + const char *info; +}; + +struct retro_core_option_v2_definition +{ + /* Variable to query in RETRO_ENVIRONMENT_GET_VARIABLE. + * Valid key characters are [a-z, A-Z, 0-9, _, -] */ + const char *key; + + /* Human-readable core option description + * > Used as menu label when frontend does + * not have core option category support + * e.g. "Video > Aspect Ratio" */ + const char *desc; + + /* Human-readable core option description + * > Used as menu label when frontend has + * core option category support + * e.g. "Aspect Ratio", where associated + * retro_core_option_v2_category::desc + * is "Video" + * > If empty or NULL, the string specified by + * desc will be used as the menu label + * > Will be ignored (and may be set to NULL) + * if category_key is empty or NULL */ + const char *desc_categorized; + + /* Human-readable core option information + * > Used as menu sublabel */ + const char *info; + + /* Human-readable core option information + * > Used as menu sublabel when frontend + * has core option category support + * (e.g. may be required when info text + * references an option by name/desc, + * and the desc/desc_categorized text + * for that option differ) + * > If empty or NULL, the string specified by + * info will be used as the menu sublabel + * > Will be ignored (and may be set to NULL) + * if category_key is empty or NULL */ + const char *info_categorized; + + /* Variable specifying category (e.g. "video", + * "audio") that will be assigned to the option + * if frontend has core option category support. + * > Categorized options will be displayed in a + * subsection/submenu of the frontend core + * option interface + * > Specified string must match one of the + * retro_core_option_v2_category::key values + * in the associated retro_core_option_v2_category + * array; If no match is not found, specified + * string will be considered as NULL + * > If specified string is empty or NULL, option will + * have no category and will be shown at the top + * level of the frontend core option interface */ + const char *category_key; + + /* Array of retro_core_option_value structs, terminated by NULL */ + struct retro_core_option_value values[RETRO_NUM_CORE_OPTION_VALUES_MAX]; + + /* Default core option value. Must match one of the values + * in the retro_core_option_value array, otherwise will be + * ignored */ + const char *default_value; +}; + +struct retro_core_options_v2 +{ + /* Array of retro_core_option_v2_category structs, + * terminated by NULL + * > If NULL, all entries in definitions array + * will have no category and will be shown at + * the top level of the frontend core option + * interface + * > Will be ignored if frontend does not have + * core option category support */ + struct retro_core_option_v2_category *categories; + + /* Array of retro_core_option_v2_definition structs, + * terminated by NULL */ + struct retro_core_option_v2_definition *definitions; +}; + +struct retro_core_options_v2_intl +{ + /* Pointer to a retro_core_options_v2 struct + * > US English implementation + * > Must point to a valid struct */ + struct retro_core_options_v2 *us; + + /* Pointer to a retro_core_options_v2 struct + * - Implementation for current frontend language + * - May be NULL */ + struct retro_core_options_v2 *local; +}; + +/* Used by the frontend to monitor changes in core option + * visibility. May be called each time any core option + * value is set via the frontend. + * - On each invocation, the core must update the visibility + * of any dynamically hidden options using the + * RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY environment + * callback. + * - On the first invocation, returns 'true' if the visibility + * of any core option has changed since the last call of + * retro_load_game() or retro_load_game_special(). + * - On each subsequent invocation, returns 'true' if the + * visibility of any core option has changed since the last + * time the function was called. */ +typedef bool (RETRO_CALLCONV *retro_core_options_update_display_callback_t)(void); +struct retro_core_options_update_display_callback +{ + retro_core_options_update_display_callback_t callback; +}; + struct retro_game_info { const char *path; /* Path to game, UTF-8 encoded. @@ -2607,6 +3702,84 @@ struct retro_framebuffer Set by frontend in GET_CURRENT_SOFTWARE_FRAMEBUFFER. */ }; +/* Used by a libretro core to override the current + * fastforwarding mode of the frontend */ +struct retro_fastforwarding_override +{ + /* Specifies the runtime speed multiplier that + * will be applied when 'fastforward' is true. + * For example, a value of 5.0 when running 60 FPS + * content will cap the fast-forward rate at 300 FPS. + * Note that the target multiplier may not be achieved + * if the host hardware has insufficient processing + * power. + * Setting a value of 0.0 (or greater than 0.0 but + * less than 1.0) will result in an uncapped + * fast-forward rate (limited only by hardware + * capacity). + * If the value is negative, it will be ignored + * (i.e. the frontend will use a runtime speed + * multiplier of its own choosing) */ + float ratio; + + /* If true, fastforwarding mode will be enabled. + * If false, fastforwarding mode will be disabled. */ + bool fastforward; + + /* If true, and if supported by the frontend, an + * on-screen notification will be displayed while + * 'fastforward' is true. + * If false, and if supported by the frontend, any + * on-screen fast-forward notifications will be + * suppressed */ + bool notification; + + /* If true, the core will have sole control over + * when fastforwarding mode is enabled/disabled; + * the frontend will not be able to change the + * state set by 'fastforward' until either + * 'inhibit_toggle' is set to false, or the core + * is unloaded */ + bool inhibit_toggle; +}; + +/* During normal operation. Rate will be equal to the core's internal FPS. */ +#define RETRO_THROTTLE_NONE 0 + +/* While paused or stepping single frames. Rate will be 0. */ +#define RETRO_THROTTLE_FRAME_STEPPING 1 + +/* During fast forwarding. + * Rate will be 0 if not specifically limited to a maximum speed. */ +#define RETRO_THROTTLE_FAST_FORWARD 2 + +/* During slow motion. Rate will be less than the core's internal FPS. */ +#define RETRO_THROTTLE_SLOW_MOTION 3 + +/* While rewinding recorded save states. Rate can vary depending on the rewind + * speed or be 0 if the frontend is not aiming for a specific rate. */ +#define RETRO_THROTTLE_REWINDING 4 + +/* While vsync is active in the video driver and the target refresh rate is + * lower than the core's internal FPS. Rate is the target refresh rate. */ +#define RETRO_THROTTLE_VSYNC 5 + +/* When the frontend does not throttle in any way. Rate will be 0. + * An example could be if no vsync or audio output is active. */ +#define RETRO_THROTTLE_UNBLOCKED 6 + +struct retro_throttle_state +{ + /* The current throttling mode. Should be one of the values above. */ + unsigned mode; + + /* How many times per second the frontend aims to call retro_run. + * Depending on the mode, it can be 0 if there is no known fixed rate. + * This won't be accurate if the total processing time of the core and + * the frontend is longer than what is available for one frame. */ + float rate; +}; + /* Callbacks */ /* Environment callback. Gives implementations a way of performing diff --git a/src/libretro/libretro-common/include/retro_inline.h b/src/libretro/libretro-common/include/retro_inline.h index e4a21f6c..b27d6dd6 100644 --- a/src/libretro/libretro-common/include/retro_inline.h +++ b/src/libretro/libretro-common/include/retro_inline.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2018 The RetroArch team +/* Copyright (C) 2010-2020 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (retro_inline.h). diff --git a/src/libretro/libretro.cpp b/src/libretro/libretro.cpp index ee4426e4..92ca62e4 100644 --- a/src/libretro/libretro.cpp +++ b/src/libretro/libretro.cpp @@ -59,7 +59,6 @@ static bool option_sndInterpolation = true; static bool option_useBios = false; static bool option_colorizerHack = false; static bool option_forceRTCenable = false; -static bool option_showAdvancedOptions = false; static double option_sndFiltering = 0.5; static unsigned option_gbPalette = 0; static bool option_lcdfilter = false; @@ -510,7 +509,8 @@ void retro_set_controller_port_device(unsigned port, unsigned device) void retro_set_environment(retro_environment_t cb) { environ_cb = cb; - libretro_set_core_options(environ_cb); + bool categoriesSupported; + libretro_set_core_options(environ_cb, &categoriesSupported); } void retro_get_system_info(struct retro_system_info *info) @@ -1205,39 +1205,6 @@ static void update_variables(bool startup) else ifb_filter_func = NULL; - var.key = "vbam_show_advanced_options"; - var.value = NULL; - - if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { - bool newval = (!strcmp(var.value, "enabled")) ? true : false; - if ((option_showAdvancedOptions != newval) || startup) { - option_showAdvancedOptions = newval; - struct retro_core_option_display option_display; - unsigned i; - char options[][13] = { - "vbam_sound_1", - "vbam_sound_2", - "vbam_sound_3", - "vbam_sound_4", - "vbam_sound_5", - "vbam_sound_6", - "vbam_layer_1", - "vbam_layer_2", - "vbam_layer_3", - "vbam_layer_4", - "vbam_layer_5", - "vbam_layer_6", - "vbam_layer_7", - "vbam_layer_8" - }; - option_display.visible = option_showAdvancedOptions; - for (i = 0; i < (sizeof(options) / sizeof(options[0])); i++) { - option_display.key = options[i]; - environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY, &option_display); - } - } - } - // Hide some core options depending on rom image type if (startup) { unsigned i; diff --git a/src/libretro/libretro_core_options.h b/src/libretro/libretro_core_options.h index e05e46ba..5b5c8acd 100644 --- a/src/libretro/libretro_core_options.h +++ b/src/libretro/libretro_core_options.h @@ -13,9 +13,10 @@ /* ******************************** - * VERSION: 1.3 + * VERSION: 2.0 ******************************** * + * - 2.0: Add support for core options v2 interface * - 1.3: Move translations to libretro_core_options_intl.h * - libretro_core_options_intl.h includes BOM and utf-8 * fix for MSVC 2010-2013 @@ -48,31 +49,43 @@ extern "C" { * - Will be used as a fallback for any missing entries in * frontend language definition */ -struct retro_core_option_definition option_defs_us[] = { - { - "vbam_solarsensor", - "Solar Sensor Level", - "Adjusts simulated solar level in Boktai games. L2/R2 buttons can also be used to quickly change levels.", - { - { "0", NULL }, - { "1", NULL }, - { "2", NULL }, - { "3", NULL }, - { "4", NULL }, - { "5", NULL }, - { "6", NULL }, - { "7", NULL }, - { "8", NULL }, - { "9", NULL }, - { "10", NULL }, - { NULL, NULL }, - }, - "0" - }, +struct retro_core_option_v2_category option_cats_us[] = { + { + "system", + "System", + "Configure system options." + }, + { + "video", + "Video", + "Configure video options." + }, + { + "audio", + "Audio", + "Configure audio options." + }, + { + "input", + "Input", + "Configure input options." + }, + { + "advanced", + "Advanced options", + "Configure advanced options which can enable or disable sound channels and graphics layers." + }, + { NULL, NULL, NULL }, +}; + +struct retro_core_option_v2_definition option_defs_us[] = { { "vbam_usebios", "Use Official BIOS (If Available)", + NULL, "Use official BIOS when available. Core needs to be restarted for changes to apply.", + NULL, + "system", { { "disabled", NULL }, { "enabled", NULL }, @@ -83,7 +96,10 @@ struct retro_core_option_definition option_defs_us[] = { { "vbam_forceRTCenable", "Force-Enable RTC", + NULL, "Forces the internal real-time clock to be enabled regardless of rom. Usuable for rom patches that requires clock to be enabled (aka Pokemon).", + NULL, + "system", { { "disabled", NULL }, { "enabled", NULL }, @@ -91,10 +107,124 @@ struct retro_core_option_definition option_defs_us[] = { }, "disabled" }, + { + "vbam_gbHardware", + "(GB) Emulated Hardware (Needs Restart)", + NULL, + "Sets the Game Boy hardware type to emulate. Restart core to apply.", + NULL, + "system", + { + { "gbc", "Game Boy Color" }, + { "auto", "Automatic" }, + { "sgb", "Super Game Boy" }, + { "gb", "Game Boy" }, + { "gba", "Game Boy Advance" }, + { "sgb2", "Super Game Boy 2" }, + { NULL, NULL }, + }, + "gbc" + }, + { + "vbam_allowcolorizerhack", + "(GB) Enable Colorizer Hack (Needs Restart)", + NULL, + "Allows Colorizer hacked GB games (e.g. DX patched games) to normally run in GBC/GBA hardware type. This also disables the use of bios file. NOT RECOMMENDED for use on non-colorized games.", + NULL, + "system", + { + { "disabled", NULL }, + { "enabled", NULL }, + { NULL, NULL }, + }, + "disabled" + }, + { + "vbam_palettes", + "(GB) Color Palette", + NULL, + "Set Game Boy palettes to use.", + NULL, + "video", + { + { "black and white", NULL }, + { "blue sea", NULL }, + { "dark knight", NULL }, + { "green forest", NULL }, + { "hot desert", NULL }, + { "pink dreams", NULL }, + { "wierd colors", NULL }, + { "original gameboy", NULL }, + { "gba sp", NULL }, + { NULL, NULL }, + }, + "standard" + }, + { + "vbam_showborders", + "(GB) Show Borders", + NULL, + "When enabled, if loaded content is SGB compatible, this will show the border from the game if available.", + NULL, + "video", + { + { "disabled", NULL }, + { "enabled", NULL }, + { "auto", NULL }, + { NULL, NULL }, + }, + "disabled" + }, + { + "vbam_gbcoloroption", + "(GB) Color Correction", + NULL, + "Applies color correction which fixes colors in some games.", + NULL, + "video", + { + { "disabled", NULL }, + { "enabled", NULL }, + { NULL, NULL }, + }, + "disabled" + }, + { + "vbam_lcdfilter", + "LCD Color Filter", + NULL, + "Darkens the onscreen colors by applying a screen filter.", + NULL, + "video", + { + { "disabled", NULL }, + { "enabled", NULL }, + { NULL, NULL }, + }, + "disabled" + }, + { + "vbam_interframeblending", + "Interframe Blending", + NULL, + "Simulates LCD ghosting effects. 'Smart' attempts to detect screen flickering, and only performs a 50:50 mix on affected pixels, while 'Motion Blur' mimics natural LCD response times by combining multiple buffered frames. 'Smart' blending is required when playing games that aggressively exploit LCD ghosting for transparency effects (Wave Race, Chikyuu Kaihou Gun ZAS, F-Zero, the Boktai series...).", + NULL, + "video", + { + { "disabled", NULL }, + { "smart", "Smart" }, + { "motion blur", "Motion Blur" }, + { NULL, NULL }, + }, + "disabled" + }, { "vbam_soundinterpolation", "Sound Interpolation", + NULL, "Enable or disable sound filtering.", + NULL, + "audio", { { "disabled", NULL }, { "enabled", NULL }, @@ -105,7 +235,10 @@ struct retro_core_option_definition option_defs_us[] = { { "vbam_soundfiltering", "Sound Filtering", + NULL, "Sets the amount of filtering to use. Higher value reduces higher frequencies.", + NULL, + "audio", { { "0", NULL }, { "1", NULL }, @@ -122,100 +255,13 @@ struct retro_core_option_definition option_defs_us[] = { }, "5" }, - { - "vbam_palettes", - "(GB) Color Palette", - "Set Game Boy palettes to use.", - { - { "black and white", NULL }, - { "blue sea", NULL }, - { "dark knight", NULL }, - { "green forest", NULL }, - { "hot desert", NULL }, - { "pink dreams", NULL }, - { "wierd colors", NULL }, - { "original gameboy", NULL }, - { "gba sp", NULL }, - { NULL, NULL }, - }, - "standard" - }, - { - "vbam_gbHardware", - "(GB) Emulated Hardware (Needs Restart)", - "Sets the Game Boy hardware type to emulate. Restart core to apply.", - { - { "gbc", "Game Boy Color" }, - { "auto", "Automatic" }, - { "sgb", "Super Game Boy" }, - { "gb", "Game Boy" }, - { "gba", "Game Boy Advance" }, - { "sgb2", "Super Game Boy 2" }, - { NULL, NULL }, - }, - "gbc" - }, - { - "vbam_allowcolorizerhack", - "(GB) Enable Colorizer Hack (Needs Restart)", - "Allows Colorizer hacked GB games (e.g. DX patched games) to normally run in GBC/GBA hardware type. This also disables the use of bios file. NOT RECOMMENDED for use on non-colorized games.", - { - { "disabled", NULL }, - { "enabled", NULL }, - { NULL, NULL }, - }, - "disabled" - }, - { - "vbam_showborders", - "(GB) Show Borders", - "When enabled, if loaded content is SGB compatible, this will show the border from the game if available.", - { - { "disabled", NULL }, - { "enabled", NULL }, - { "auto", NULL }, - { NULL, NULL }, - }, - "disabled" - }, - { - "vbam_gbcoloroption", - "(GB) Color Correction", - "Applies color correction which fixes colors in some games.", - { - { "disabled", NULL }, - { "enabled", NULL }, - { NULL, NULL }, - }, - "disabled" - }, - { - "vbam_lcdfilter", - "LCD Color Filter", - "Darkens the onscreen colors by applying a screen filter.", - { - { "disabled", NULL }, - { "enabled", NULL }, - { NULL, NULL }, - }, - "disabled" - }, - { - "vbam_interframeblending", - "Interframe Blending", - "Simulates LCD ghosting effects. 'Smart' attempts to detect screen flickering, and only performs a 50:50 mix on affected pixels, while 'Motion Blur' mimics natural LCD response times by combining multiple buffered frames. 'Smart' blending is required when playing games that aggressively exploit LCD ghosting for transparency effects (Wave Race, Chikyuu Kaihou Gun ZAS, F-Zero, the Boktai series...).", - { - { "disabled", NULL }, - { "smart", "Smart" }, - { "motion blur", "Motion Blur" }, - { NULL, NULL }, - }, - "disabled" - }, { "vbam_turboenable", "Enable Turbo Buttons", + NULL, "Enable or disable gamepad turbo buttons.", + NULL, + "input", { { "disabled", NULL }, { "enabled", NULL }, @@ -226,7 +272,10 @@ struct retro_core_option_definition option_defs_us[] = { { "vbam_turbodelay", "Turbo Delay (in frames)", + NULL, "Repeat rate of turbo triggers in frames. Higher value triggers more.", + NULL, + "input", { { "1", NULL }, { "2", NULL }, @@ -247,10 +296,36 @@ struct retro_core_option_definition option_defs_us[] = { }, "3" }, + { + "vbam_solarsensor", + "Solar Sensor Level", + NULL, + "Adjusts simulated solar level in Boktai games. L2/R2 buttons can also be used to quickly change levels.", + NULL, + "input", + { + { "0", NULL }, + { "1", NULL }, + { "2", NULL }, + { "3", NULL }, + { "4", NULL }, + { "5", NULL }, + { "6", NULL }, + { "7", NULL }, + { "8", NULL }, + { "9", NULL }, + { "10", NULL }, + { NULL, NULL }, + }, + "0" + }, { "vbam_astick_deadzone", "Sensors Deadzone (%)", + NULL, "Set deadzone (in percent) of analog sticks.", + NULL, + "input", { { "0", NULL }, { "5", NULL }, @@ -266,7 +341,10 @@ struct retro_core_option_definition option_defs_us[] = { { "vbam_gyro_sensitivity", "Sensor Sensitivity (Gyroscope) (%)", + NULL, "Default bind is left analog. Used to adjust sensitivity level for gyro-enabled games.", + NULL, + "input", { { "10", NULL }, { "15", NULL }, @@ -298,7 +376,10 @@ struct retro_core_option_definition option_defs_us[] = { { "vbam_tilt_sensitivity", "Sensor Sensitivity (Tilt) (%)", + NULL, "Default bind is right analog. Used to adjust sensitivity level for gyro-enabled games.", + NULL, + "input", { { "10", NULL }, { "15", NULL }, @@ -330,18 +411,10 @@ struct retro_core_option_definition option_defs_us[] = { { "vbam_swap_astick", "Swap Left/Right Analog", + NULL, "Swaps left and right analog stick function for gyro and tilt.", - { - { "disabled", NULL }, - { "enabled", NULL }, - { NULL, NULL }, - }, - "disabled" - }, - { - "vbam_show_advanced_options", - "Show Advanced Options", - "Show advanced options which can enable or disable sound channels and graphics layers.", + NULL, + "input", { { "disabled", NULL }, { "enabled", NULL }, @@ -352,7 +425,10 @@ struct retro_core_option_definition option_defs_us[] = { { "vbam_sound_1", "Sound Channel 1", + NULL, "Enables or disables tone & sweep sound channel.", + NULL, + "advanced", { { "disabled", NULL }, { "enabled", NULL }, @@ -363,7 +439,10 @@ struct retro_core_option_definition option_defs_us[] = { { "vbam_sound_2", "Sound Channel 2", + NULL, "Enables or disables tone sound channel.", + NULL, + "advanced", { { "disabled", NULL }, { "enabled", NULL }, @@ -374,7 +453,10 @@ struct retro_core_option_definition option_defs_us[] = { { "vbam_sound_3", "Sound Channel 3", + NULL, "Enables or disables wave output sound channel.", + NULL, + "advanced", { { "disabled", NULL }, { "enabled", NULL }, @@ -385,7 +467,10 @@ struct retro_core_option_definition option_defs_us[] = { { "vbam_sound_4", "Sound Channel 4", + NULL, "Enables or disables noise audio channel.", + NULL, + "advanced", { { "disabled", NULL }, { "enabled", NULL }, @@ -396,7 +481,10 @@ struct retro_core_option_definition option_defs_us[] = { { "vbam_sound_5", "Sound DMA Channel A", + NULL, "Enables or disables DMA sound channel A.", + NULL, + "advanced", { { "disabled", NULL }, { "enabled", NULL }, @@ -407,7 +495,10 @@ struct retro_core_option_definition option_defs_us[] = { { "vbam_sound_6", "Sound DMA Channel B", + NULL, "Enables or disables DMA sound channel B.", + NULL, + "advanced", { { "disabled", NULL }, { "enabled", NULL }, @@ -418,7 +509,10 @@ struct retro_core_option_definition option_defs_us[] = { { "vbam_layer_1", "Show Background Layer 1", + NULL, "Shows or hides background layer 1.", + NULL, + "advanced", { { "disabled", NULL }, { "enabled", NULL }, @@ -429,7 +523,10 @@ struct retro_core_option_definition option_defs_us[] = { { "vbam_layer_2", "Show Background Layer 2", + NULL, "Shows or hides background layer 2.", + NULL, + "advanced", { { "disabled", NULL }, { "enabled", NULL }, @@ -440,7 +537,10 @@ struct retro_core_option_definition option_defs_us[] = { { "vbam_layer_3", "Show Background Layer 3", + NULL, "Shows or hides background layer 3.", + NULL, + "advanced", { { "disabled", NULL }, { "enabled", NULL }, @@ -451,7 +551,10 @@ struct retro_core_option_definition option_defs_us[] = { { "vbam_layer_4", "Show Background Layer 4", + NULL, "Shows or hides background layer 4.", + NULL, + "advanced", { { "disabled", NULL }, { "enabled", NULL }, @@ -462,7 +565,10 @@ struct retro_core_option_definition option_defs_us[] = { { "vbam_layer_5", "Show Sprite Layer", + NULL, "Shows or hides sprite layer.", + NULL, + "advanced", { { "disabled", NULL }, { "enabled", NULL }, @@ -473,7 +579,10 @@ struct retro_core_option_definition option_defs_us[] = { { "vbam_layer_6", "Show Window Layer 1", + NULL, "Shows or hides window layer 1.", + NULL, + "advanced", { { "disabled", NULL }, { "enabled", NULL }, @@ -484,7 +593,10 @@ struct retro_core_option_definition option_defs_us[] = { { "vbam_layer_7", "Show Window Layer 2", + NULL, "Shows or hides window layer 2.", + NULL, + "advanced", { { "disabled", NULL }, { "enabled", NULL }, @@ -495,7 +607,10 @@ struct retro_core_option_definition option_defs_us[] = { { "vbam_layer_8", "Show Sprite Window Layer", + NULL, "Shows or hides sprite window layer.", + NULL, + "advanced", { { "disabled", NULL }, { "enabled", NULL }, @@ -503,8 +618,12 @@ struct retro_core_option_definition option_defs_us[] = { }, "enabled" }, + { NULL, NULL, NULL, NULL, NULL, NULL, {{0}}, NULL }, +}; - { NULL, NULL, NULL, {{0}}, NULL } +struct retro_core_options_v2 options_us = { + option_cats_us, + option_defs_us }; /* @@ -514,8 +633,8 @@ struct retro_core_option_definition option_defs_us[] = { */ #ifndef HAVE_NO_LANGEXTRA -struct retro_core_option_definition *option_defs_intl[RETRO_LANGUAGE_LAST] = { - option_defs_us, /* RETRO_LANGUAGE_ENGLISH */ +struct retro_core_options_v2 *options_intl[RETRO_LANGUAGE_LAST] = { + &options_us, /* RETRO_LANGUAGE_ENGLISH */ NULL, /* RETRO_LANGUAGE_JAPANESE */ NULL, /* RETRO_LANGUAGE_FRENCH */ NULL, /* RETRO_LANGUAGE_SPANISH */ @@ -533,7 +652,7 @@ struct retro_core_option_definition *option_defs_intl[RETRO_LANGUAGE_LAST] = { NULL, /* RETRO_LANGUAGE_VIETNAMESE */ NULL, /* RETRO_LANGUAGE_ARABIC */ NULL, /* RETRO_LANGUAGE_GREEK */ - option_defs_tr, /* RETRO_LANGUAGE_TURKISH */ + &options_tr, /* RETRO_LANGUAGE_TURKISH */ }; #endif @@ -551,39 +670,61 @@ struct retro_core_option_definition *option_defs_intl[RETRO_LANGUAGE_LAST] = { * be as painless as possible for core devs) */ -static INLINE void libretro_set_core_options(retro_environment_t environ_cb) +static INLINE void libretro_set_core_options(retro_environment_t environ_cb, + bool *categories_supported) { - unsigned version = 0; + unsigned version = 0; +#ifndef HAVE_NO_LANGEXTRA + unsigned language = 0; +#endif - if (!environ_cb) + if (!environ_cb || !categories_supported) return; - if (environ_cb(RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION, &version) && (version >= 1)) + *categories_supported = false; + + if (!environ_cb(RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION, &version)) + version = 0; + + if (version >= 2) { #ifndef HAVE_NO_LANGEXTRA - struct retro_core_options_intl core_options_intl; - unsigned language = 0; + struct retro_core_options_v2_intl core_options_intl; - core_options_intl.us = option_defs_us; + core_options_intl.us = &options_us; core_options_intl.local = NULL; if (environ_cb(RETRO_ENVIRONMENT_GET_LANGUAGE, &language) && (language < RETRO_LANGUAGE_LAST) && (language != RETRO_LANGUAGE_ENGLISH)) - core_options_intl.local = option_defs_intl[language]; + core_options_intl.local = options_intl[language]; - environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_INTL, &core_options_intl); + *categories_supported = environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2_INTL, + &core_options_intl); #else - environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS, &option_defs_us); + *categories_supported = environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2, + &options_us); #endif } else { - size_t i; + size_t i, j; + size_t option_index = 0; size_t num_options = 0; + struct retro_core_option_definition + *option_v1_defs_us = NULL; +#ifndef HAVE_NO_LANGEXTRA + size_t num_options_intl = 0; + struct retro_core_option_v2_definition + *option_defs_intl = NULL; + struct retro_core_option_definition + *option_v1_defs_intl = NULL; + struct retro_core_options_intl + core_options_v1_intl; +#endif struct retro_variable *variables = NULL; char **values_buf = NULL; - /* Determine number of options */ + /* Determine total number of options */ while (true) { if (option_defs_us[num_options].key) @@ -592,86 +733,187 @@ static INLINE void libretro_set_core_options(retro_environment_t environ_cb) break; } - /* Allocate arrays */ - variables = (struct retro_variable *)calloc(num_options + 1, sizeof(struct retro_variable)); - values_buf = (char **)calloc(num_options, sizeof(char *)); - - if (!variables || !values_buf) - goto error; - - /* Copy parameters from option_defs_us array */ - for (i = 0; i < num_options; i++) + if (version >= 1) { - const char *key = option_defs_us[i].key; - const char *desc = option_defs_us[i].desc; - const char *default_value = option_defs_us[i].default_value; - struct retro_core_option_value *values = option_defs_us[i].values; - size_t buf_len = 3; - size_t default_index = 0; + /* Allocate US array */ + option_v1_defs_us = (struct retro_core_option_definition *) + calloc(num_options + 1, sizeof(struct retro_core_option_definition)); - values_buf[i] = NULL; - - if (desc) + /* Copy parameters from option_defs_us array */ + for (i = 0; i < num_options; i++) { - size_t num_values = 0; + struct retro_core_option_v2_definition *option_def_us = &option_defs_us[i]; + struct retro_core_option_value *option_values = option_def_us->values; + struct retro_core_option_definition *option_v1_def_us = &option_v1_defs_us[i]; + struct retro_core_option_value *option_v1_values = option_v1_def_us->values; - /* Determine number of values */ + option_v1_def_us->key = option_def_us->key; + option_v1_def_us->desc = option_def_us->desc; + option_v1_def_us->info = option_def_us->info; + option_v1_def_us->default_value = option_def_us->default_value; + + /* Values must be copied individually... */ + while (option_values->value) + { + option_v1_values->value = option_values->value; + option_v1_values->label = option_values->label; + + option_values++; + option_v1_values++; + } + } + +#ifndef HAVE_NO_LANGEXTRA + if (environ_cb(RETRO_ENVIRONMENT_GET_LANGUAGE, &language) && + (language < RETRO_LANGUAGE_LAST) && (language != RETRO_LANGUAGE_ENGLISH) && + options_intl[language]) + option_defs_intl = options_intl[language]->definitions; + + if (option_defs_intl) + { + /* Determine number of intl options */ while (true) { - if (values[num_values].value) - { - /* Check if this is the default value */ - if (default_value) - if (strcmp(values[num_values].value, default_value) == 0) - default_index = num_values; - - buf_len += strlen(values[num_values].value); - num_values++; - } + if (option_defs_intl[num_options_intl].key) + num_options_intl++; else break; } - /* Build values string */ - if (num_values > 0) + /* Allocate intl array */ + option_v1_defs_intl = (struct retro_core_option_definition *) + calloc(num_options_intl + 1, sizeof(struct retro_core_option_definition)); + + /* Copy parameters from option_defs_intl array */ + for (i = 0; i < num_options_intl; i++) { - size_t j; + struct retro_core_option_v2_definition *option_def_intl = &option_defs_intl[i]; + struct retro_core_option_value *option_values = option_def_intl->values; + struct retro_core_option_definition *option_v1_def_intl = &option_v1_defs_intl[i]; + struct retro_core_option_value *option_v1_values = option_v1_def_intl->values; - buf_len += num_values - 1; - buf_len += strlen(desc); + option_v1_def_intl->key = option_def_intl->key; + option_v1_def_intl->desc = option_def_intl->desc; + option_v1_def_intl->info = option_def_intl->info; + option_v1_def_intl->default_value = option_def_intl->default_value; - values_buf[i] = (char *)calloc(buf_len, sizeof(char)); - if (!values_buf[i]) - goto error; - - strcpy(values_buf[i], desc); - strcat(values_buf[i], "; "); - - /* Default value goes first */ - strcat(values_buf[i], values[default_index].value); - - /* Add remaining values */ - for (j = 0; j < num_values; j++) + /* Values must be copied individually... */ + while (option_values->value) { - if (j != default_index) - { - strcat(values_buf[i], "|"); - strcat(values_buf[i], values[j].value); - } + option_v1_values->value = option_values->value; + option_v1_values->label = option_values->label; + + option_values++; + option_v1_values++; } } } - variables[i].key = key; - variables[i].value = values_buf[i]; + core_options_v1_intl.us = option_v1_defs_us; + core_options_v1_intl.local = option_v1_defs_intl; + + environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_INTL, &core_options_v1_intl); +#else + environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS, option_v1_defs_us); +#endif + } + else + { + /* Allocate arrays */ + variables = (struct retro_variable *)calloc(num_options + 1, + sizeof(struct retro_variable)); + values_buf = (char **)calloc(num_options, sizeof(char *)); + + if (!variables || !values_buf) + goto error; + + /* Copy parameters from option_defs_us array */ + for (i = 0; i < num_options; i++) + { + const char *key = option_defs_us[i].key; + const char *desc = option_defs_us[i].desc; + const char *default_value = option_defs_us[i].default_value; + struct retro_core_option_value *values = option_defs_us[i].values; + size_t buf_len = 3; + size_t default_index = 0; + + values_buf[i] = NULL; + + if (desc) + { + size_t num_values = 0; + + /* Determine number of values */ + while (true) + { + if (values[num_values].value) + { + /* Check if this is the default value */ + if (default_value) + if (strcmp(values[num_values].value, default_value) == 0) + default_index = num_values; + + buf_len += strlen(values[num_values].value); + num_values++; + } + else + break; + } + + /* Build values string */ + if (num_values > 0) + { + buf_len += num_values - 1; + buf_len += strlen(desc); + + values_buf[i] = (char *)calloc(buf_len, sizeof(char)); + if (!values_buf[i]) + goto error; + + strcpy(values_buf[i], desc); + strcat(values_buf[i], "; "); + + /* Default value goes first */ + strcat(values_buf[i], values[default_index].value); + + /* Add remaining values */ + for (j = 0; j < num_values; j++) + { + if (j != default_index) + { + strcat(values_buf[i], "|"); + strcat(values_buf[i], values[j].value); + } + } + } + } + + variables[option_index].key = key; + variables[option_index].value = values_buf[i]; + option_index++; + } + + /* Set variables */ + environ_cb(RETRO_ENVIRONMENT_SET_VARIABLES, variables); } - /* Set variables */ - environ_cb(RETRO_ENVIRONMENT_SET_VARIABLES, variables); - error: - /* Clean up */ + + if (option_v1_defs_us) + { + free(option_v1_defs_us); + option_v1_defs_us = NULL; + } + +#ifndef HAVE_NO_LANGEXTRA + if (option_v1_defs_intl) + { + free(option_v1_defs_intl); + option_v1_defs_intl = NULL; + } +#endif + if (values_buf) { for (i = 0; i < num_options; i++) diff --git a/src/libretro/libretro_core_options_intl.h b/src/libretro/libretro_core_options_intl.h index 6e9dfc2d..38142c86 100644 --- a/src/libretro/libretro_core_options_intl.h +++ b/src/libretro/libretro_core_options_intl.h @@ -73,31 +73,43 @@ extern "C" { /* RETRO_LANGUAGE_TURKISH */ -struct retro_core_option_definition option_defs_tr[] = { - { - "vbam_solarsensor", - "Solar Sensör Seviyesi", - "Boktai oyunlarında simüle güneş seviyesini ayarlar. L2 / R2 düğmeleri ayrıca seviyeleri hızlıca değiştirmek için de kullanılabilir.", - { - { "0", NULL }, - { "1", NULL }, - { "2", NULL }, - { "3", NULL }, - { "4", NULL }, - { "5", NULL }, - { "6", NULL }, - { "7", NULL }, - { "8", NULL }, - { "9", NULL }, - { "10", NULL }, - { NULL, NULL }, - }, - "0" - }, +struct retro_core_option_v2_category option_cats_tr[] = { + { + "system", + NULL, + NULL, + }, + { + "video", + NULL, + NULL, + }, + { + "audio", + NULL, + NULL, + }, + { + "input", + NULL, + NULL, + }, + { + "advanced", + NULL, + NULL, + }, + { NULL, NULL, NULL }, +}; + +struct retro_core_option_v2_definition option_defs_tr[] = { { "vbam_usebios", "Resmi BIOS'u kullanın (Varsa)", + NULL, "Mümkün olduğunda resmi BIOS kullanın. Değişikliklerin uygulanabilmesi için çekirdeğin yeniden başlatılması gerekiyor.", + NULL, + "system", { { "disabled", NULL }, { "enabled", NULL }, @@ -108,7 +120,92 @@ struct retro_core_option_definition option_defs_tr[] = { { "vbam_forceRTCenable", "RTC'yi Etkinleştir", + NULL, "RAM'den bağımsız olarak dahili gerçek zamanlı saati etkinleştirmeye zorlar. Saatin etkinleştirilmesini gerektiren rom yamalar için kullanılabilir (Pokemon gibi).", + NULL, + "system", + { + { "disabled", NULL }, + { "enabled", NULL }, + { NULL, NULL }, + }, + "disabled" + }, + { + "vbam_gbHardware", + "(GB) Öykünülmüş Donanım (Yeniden Başlatılması Gerekiyor)", + NULL, + "Game Boy donanım tipini taklit edecek şekilde ayarlar. Uygulamak için çekirdeği yeniden başlatın.", + NULL, + "system", + { + { "gbc", "Game Boy Color" }, + { "auto", "Automatic" }, + { "sgb", "Super Game Boy" }, + { "gb", "Game Boy" }, + { "gba", "Game Boy Advance" }, + { "sgb2", "Super Game Boy 2" }, + { NULL, NULL }, + }, + "gbc" + }, + { + "vbam_allowcolorizerhack", + "(GB) Colorizer Hack'i Etkinleştir (Yeniden Başlatılması Gerekiyor)", + NULL, + "Colorizer'ın saldırıya uğramış GB oyunlarının (örn. DX yamalı oyunlar) normalde GBC / GBA donanım türünde çalışmasına izin verir. Bu ayrıca bios dosyasının kullanımını da devre dışı bırakır. Renklendirilmemiş oyunlarda kullanılması tavsiye edilmez.", + NULL, + "system", + { + { "disabled", NULL }, + { "enabled", NULL }, + { NULL, NULL }, + }, + "disabled" + }, + { + "vbam_palettes", + "(GB) Renk Paleti", + NULL, + "Game Boy paletlerini kullanmak için ayarlayın.", + NULL, + "video", + { + { "black and white", NULL }, + { "blue sea", NULL }, + { "dark knight", NULL }, + { "green forest", NULL }, + { "hot desert", NULL }, + { "pink dreams", NULL }, + { "wierd colors", NULL }, + { "original gameboy", NULL }, + { "gba sp", NULL }, + { NULL, NULL }, + }, + "standard" + }, + { + "vbam_showborders", + "(GB) Sınırları Göster", + NULL, + "Etkinleştirildiğinde, yüklü içerik SGB uyumluysa, bu durum oyundaki sınırı gösterir.", + NULL, + "video", + { + { "disabled", NULL }, + { "enabled", NULL }, + { "auto", NULL }, + { NULL, NULL }, + }, + "disabled" + }, + { + "vbam_gbcoloroption", + "(GB) Renk Düzeltme", + NULL, + "Bazı oyunlarda renkleri düzelten renk düzeltmesini uygular.", + NULL, + "video", { { "disabled", NULL }, { "enabled", NULL }, @@ -119,7 +216,10 @@ struct retro_core_option_definition option_defs_tr[] = { { "vbam_soundinterpolation", "Ses Enterpolasyonu", + NULL, "Ses filtresini etkinleştirin veya devre dışı bırakın.", + NULL, + "audio", { { "disabled", NULL }, { "enabled", NULL }, @@ -130,7 +230,10 @@ struct retro_core_option_definition option_defs_tr[] = { { "vbam_soundfiltering", "Ses Filtreleme", + NULL, "Kullanılacak filtreleme miktarını ayarlar. Yüksek değer, yüksek frekansları azaltır.", + NULL, + "audio", { { "0", NULL }, { "1", NULL }, @@ -147,77 +250,13 @@ struct retro_core_option_definition option_defs_tr[] = { }, "5" }, - { - "vbam_palettes", - "(GB) Renk Paleti", - "Game Boy paletlerini kullanmak için ayarlayın.", - { - { "black and white", NULL }, - { "blue sea", NULL }, - { "dark knight", NULL }, - { "green forest", NULL }, - { "hot desert", NULL }, - { "pink dreams", NULL }, - { "wierd colors", NULL }, - { "original gameboy", NULL }, - { "gba sp", NULL }, - { NULL, NULL }, - }, - "standard" - }, - { - "vbam_gbHardware", - "(GB) Öykünülmüş Donanım (Yeniden Başlatılması Gerekiyor)", - "Game Boy donanım tipini taklit edecek şekilde ayarlar. Uygulamak için çekirdeği yeniden başlatın.", - { - { "gbc", "Game Boy Color" }, - { "auto", "Automatic" }, - { "sgb", "Super Game Boy" }, - { "gb", "Game Boy" }, - { "gba", "Game Boy Advance" }, - { "sgb2", "Super Game Boy 2" }, - { NULL, NULL }, - }, - "gbc" - }, - { - "vbam_allowcolorizerhack", - "(GB) Colorizer Hack'i Etkinleştir (Yeniden Başlatılması Gerekiyor)", - "Colorizer'ın saldırıya uğramış GB oyunlarının (örn. DX yamalı oyunlar) normalde GBC / GBA donanım türünde çalışmasına izin verir. Bu ayrıca bios dosyasının kullanımını da devre dışı bırakır. Renklendirilmemiş oyunlarda kullanılması tavsiye edilmez.", - { - { "disabled", NULL }, - { "enabled", NULL }, - { NULL, NULL }, - }, - "disabled" - }, - { - "vbam_showborders", - "(GB) Sınırları Göster", - "Etkinleştirildiğinde, yüklü içerik SGB uyumluysa, bu durum oyundaki sınırı gösterir.", - { - { "disabled", NULL }, - { "enabled", NULL }, - { "auto", NULL }, - { NULL, NULL }, - }, - "disabled" - }, - { - "vbam_gbcoloroption", - "(GB) Renk Düzeltme", - "Bazı oyunlarda renkleri düzelten renk düzeltmesini uygular.", - { - { "disabled", NULL }, - { "enabled", NULL }, - { NULL, NULL }, - }, - "disabled" - }, { "vbam_turboenable", "Turbo Düğmelerini Etkinleştir", + NULL, "Gamepad turbo düğmelerini etkinleştirin veya devre dışı bırakın.", + NULL, + "input", { { "disabled", NULL }, { "enabled", NULL }, @@ -228,7 +267,10 @@ struct retro_core_option_definition option_defs_tr[] = { { "vbam_turbodelay", "Turbo Gecikme (kare cinsinden)", + NULL, "Karelerde turbo tetikleyicilerin oranını tekrarlayın. Daha yüksek değer daha fazla tetikler.", + NULL, + "input", { { "1", NULL }, { "2", NULL }, @@ -249,10 +291,36 @@ struct retro_core_option_definition option_defs_tr[] = { }, "3" }, + { + "vbam_solarsensor", + "Solar Sensör Seviyesi", + NULL, + "Boktai oyunlarında simüle güneş seviyesini ayarlar. L2 / R2 düğmeleri ayrıca seviyeleri hızlıca değiştirmek için de kullanılabilir.", + NULL, + "input", + { + { "0", NULL }, + { "1", NULL }, + { "2", NULL }, + { "3", NULL }, + { "4", NULL }, + { "5", NULL }, + { "6", NULL }, + { "7", NULL }, + { "8", NULL }, + { "9", NULL }, + { "10", NULL }, + { NULL, NULL }, + }, + "0" + }, { "vbam_astick_deadzone", "Sensörlerin Ölü Bölgesi (%)", + NULL, "Analog çubukların ölü bölgesini (yüzde olarak) ayarlayın.", + NULL, + "input", { { "0", NULL }, { "5", NULL }, @@ -268,7 +336,10 @@ struct retro_core_option_definition option_defs_tr[] = { { "vbam_gyro_sensitivity", "Sensör Hassasiyeti (Jiroskop) (%)", + NULL, "Varsayılan konumlandırma, sol analogdur. Gyro özellikli oyunlar için hassasiyet seviyesini ayarlamak için kullanılır.", + NULL, + "input", { { "10", NULL }, { "15", NULL }, @@ -300,7 +371,10 @@ struct retro_core_option_definition option_defs_tr[] = { { "vbam_tilt_sensitivity", "Sensör Hassasiyeti (Eğim) (%)", + NULL, "Varsayılan konumlandırma sağ analogdur. Gyro özellikli oyunlar için hassasiyet seviyesini ayarlamak için kullanılır.", + NULL, + "input", { { "10", NULL }, { "15", NULL }, @@ -332,18 +406,10 @@ struct retro_core_option_definition option_defs_tr[] = { { "vbam_swap_astick", "Sol / Sağ Analog Değiştirme", + NULL, "Döndürme ve eğme için sola ve sağa analog çubuk işlevini değiştirir.", - { - { "disabled", NULL }, - { "enabled", NULL }, - { NULL, NULL }, - }, - "disabled" - }, - { - "vbam_show_advanced_options", - "Gelişmiş Ayarları Göster", - "Ses kanallarını ve grafik katmanlarını etkinleştirebilen veya devre dışı bırakabilen gelişmiş seçenekleri gösterin.", + NULL, + "input", { { "disabled", NULL }, { "enabled", NULL }, @@ -354,7 +420,10 @@ struct retro_core_option_definition option_defs_tr[] = { { "vbam_sound_1", "Ses Kanalı 1", + NULL, "Tonlu ve tarama ses kanalını etkinleştirir veya devre dışı bırakır.", + NULL, + "advanced", { { "disabled", NULL }, { "enabled", NULL }, @@ -365,7 +434,10 @@ struct retro_core_option_definition option_defs_tr[] = { { "vbam_sound_2", "Ses Kanalı 2", + NULL, "Tonlu ses kanalını etkinleştirir veya devre dışı bırakır.", + NULL, + "advanced", { { "disabled", NULL }, { "enabled", NULL }, @@ -376,7 +448,10 @@ struct retro_core_option_definition option_defs_tr[] = { { "vbam_sound_3", "Ses Kanalı 3", + NULL, "Dalga çıkışı ses kanalını etkinleştirir veya devre dışı bırakır.", + NULL, + "advanced", { { "disabled", NULL }, { "enabled", NULL }, @@ -387,7 +462,10 @@ struct retro_core_option_definition option_defs_tr[] = { { "vbam_sound_4", "Ses Kanalı 4", + NULL, "Gürültü ses kanalını etkinleştirir veya devre dışı bırakır.", + NULL, + "advanced", { { "disabled", NULL }, { "enabled", NULL }, @@ -398,7 +476,10 @@ struct retro_core_option_definition option_defs_tr[] = { { "vbam_sound_5", "DMA Ses Kanalı A", + NULL, "DMA ses kanalı A'yı etkinleştirir veya devre dışı bırakır.", + NULL, + "advanced", { { "disabled", NULL }, { "enabled", NULL }, @@ -409,7 +490,10 @@ struct retro_core_option_definition option_defs_tr[] = { { "vbam_sound_6", "DMA Ses Kanalı B", + NULL, "DMA ses kanalı B'yi etkinleştirir veya devre dışı bırakır.", + NULL, + "advanced", { { "disabled", NULL }, { "enabled", NULL }, @@ -420,7 +504,10 @@ struct retro_core_option_definition option_defs_tr[] = { { "vbam_layer_1", "Arka Plan Katmanını Göster 1", + NULL, "1. arka plan katmanını gösterir veya gizler.", + NULL, + "advanced", { { "disabled", NULL }, { "enabled", NULL }, @@ -431,7 +518,10 @@ struct retro_core_option_definition option_defs_tr[] = { { "vbam_layer_2", "Arka Plan Katmanını Göster 2", + NULL, "2. arka plan katmanını gösterir veya gizler.", + NULL, + "advanced", { { "disabled", NULL }, { "enabled", NULL }, @@ -442,7 +532,10 @@ struct retro_core_option_definition option_defs_tr[] = { { "vbam_layer_3", "Arka Plan Katmanını Göster 3", + NULL, "3. arka plan katmanını gösterir veya gizler.", + NULL, + "advanced", { { "disabled", NULL }, { "enabled", NULL }, @@ -453,7 +546,10 @@ struct retro_core_option_definition option_defs_tr[] = { { "vbam_layer_4", "Arka Plan Katmanını Göster 4", + NULL, "4. arka plan katmanını gösterir veya gizler.", + NULL, + "advanced", { { "disabled", NULL }, { "enabled", NULL }, @@ -464,7 +560,10 @@ struct retro_core_option_definition option_defs_tr[] = { { "vbam_layer_5", "Sprite Katmanını Göster", + NULL, "Sprite katmanını gösterir veya gizler.", + NULL, + "advanced", { { "disabled", NULL }, { "enabled", NULL }, @@ -475,7 +574,10 @@ struct retro_core_option_definition option_defs_tr[] = { { "vbam_layer_6", "Pencere Katmanını Göster 1", + NULL, "Pencere katmanı 1'i gösterir veya gizler.", + NULL, + "advanced", { { "disabled", NULL }, { "enabled", NULL }, @@ -486,7 +588,10 @@ struct retro_core_option_definition option_defs_tr[] = { { "vbam_layer_7", "Pencere Katmanını Göster 2", + NULL, "Pencere katmanı 2'yi gösterir veya gizler.", + NULL, + "advanced", { { "disabled", NULL }, { "enabled", NULL }, @@ -497,7 +602,10 @@ struct retro_core_option_definition option_defs_tr[] = { { "vbam_layer_8", "Sprite Pencere Katmanını Göster", + NULL, "Sprite pencere katmanını gösterir veya gizler.", + NULL, + "advanced", { { "disabled", NULL }, { "enabled", NULL }, @@ -505,8 +613,12 @@ struct retro_core_option_definition option_defs_tr[] = { }, "enabled" }, + { NULL, NULL, NULL, NULL, NULL, NULL, {{0}}, NULL }, +}; - { NULL, NULL, NULL, {{0}}, NULL } +struct retro_core_options_v2 options_tr = { + option_cats_tr, + option_defs_tr }; #ifdef __cplusplus