22#ifndef LIBRETRO_CORE_OPTIONS_H__
23#define LIBRETRO_CORE_OPTIONS_H__
29#include <retro_inline.h>
31#ifndef HAVE_NO_LANGEXTRA
32#include "libretro-core-options-intl.h"
74struct retro_core_option_v2_category option_cats_us[] = {
78 "Configure video settings"
83 "Configure cursor movement settings"
88 "Configure timing settings"
93 "Configure RetroPad mapping"
98 "Configure system settings"
100 { NULL, NULL, NULL },
103struct retro_core_option_v2_definition option_defs_us[] = {
105 "scummvm_pointer_device",
106 "Cursor > Pointer Device",
108 "Select which device controls the cursor.",
112 {
"retropad",
"RetroPad only"},
113 {
"mouse",
"RetroPad + RetroMouse"},
114 {
"pointer",
"RetroPad + Pointer"},
117#if defined(WIIU) || defined(__SWITCH__)
124 "scummvm_gamepad_cursor_speed",
125 "Cursor > Gamepad Cursor Speed",
126 "Gamepad Cursor Speed",
127 "Sets the mouse cursor speed multiplier when moving the cursor with the RetroPad left analog stick or D-Pad. The default value of '1.0' is optimised for games that have a native resolution of '320x200' or '320x240'. When running 'high definition' games with a resolution of '640x400' or '640x480', a Gamepad Cursor Speed of '2.0' is recommended.",
144 "scummvm_gamepad_cursor_acceleration_time",
145 "Cursor > Gamepad Cursor Acceleration",
146 "Gamepad Cursor Acceleration",
147 "The amount of time (In seconds) it takes for the cursor to reach full speed",
167 "scummvm_analog_response",
168 "Cursor > Analog Cursor Response",
169 "Analog Cursor Response",
170 "Determines how the speed of the cursor varies when tilting the RetroPad left analog stick. 'Linear': Speed is directly proportional to analog stick displacement. This is standard behaviour with which most users will be familiar. 'Quadratic': Speed increases quadratically with analog stick displacement. This allows for greater precision when making small movements without sacrificing maximum speed at full analog range. This mode may require practice for effective use.",
174 {
"linear",
"Linear"},
175 {
"quadratic",
"Quadratic"},
181 "scummvm_analog_deadzone",
182 "Cursor > Analog Deadzone",
184 "Sets the deadzone in percentage of the RetroPad analog sticks. Used to eliminate cursor drift/unwanted input.",
200 "scummvm_mouse_speed",
201 "Cursor > Mouse Speed",
203 "Sets the mouse cursor speed multiplier when moving the cursor with the RetroMouse.",
233 "scummvm_mouse_fine_control_speed_reduction",
234 "Cursor > Mouse Fine Control Speed Reduction",
235 "Mouse Fine Control Speed Reduction",
236 "Sets the mouse cursor speed reduction as percentage of normal speed when fine control is activated.",
249 "Timing > Frame rate cap",
251 "Set core frame rate upper limit. Reducing the limit will improve the performance on lower end devices. Changing this setting will reset the core.",
255 {
"disabled", NULL },
265 "scummvm_samplerate",
266 "Timing > Sample rate",
268 "Set core sample rate. Reducing the rate will slightly improve the performance on lower end devices. Changing this setting will reset the core.",
272 {
"48000 Hz", NULL },
273 {
"44100 Hz", NULL },
292 "scummvm_mapper_down",
304 "scummvm_mapper_left",
316 "scummvm_mapper_right",
376 "scummvm_mapper_select",
388 "scummvm_mapper_start",
397 "RETROKE_SCUMMVM_GUI"
409 "RETROKE_LEFT_BUTTON"
421 "RETROKE_RIGHT_BUTTON"
445 "RETROKE_FINE_CONTROL"
474 "RetroPad > Left Analog > Up",
486 "RetroPad > Left Analog > Down",
487 "Left Analog > Down",
498 "RetroPad > Left Analog > Left",
499 "Left Analog > Left",
510 "RetroPad > Left Analog > Right",
511 "Left Analog > Right",
523 "RetroPad > Right Analog > Up",
535 "RetroPad > Right Analog > Down",
536 "Right Analog > Down",
547 "RetroPad > Right Analog > Left",
548 "Right Analog > Left",
559 "RetroPad > Right Analog > Right",
560 "Right Analog > Right",
570 "scummvm_video_hw_acceleration",
571 "Video > Hardware acceleration",
572 "Hardware acceleration",
573 "Request video hardware acceleration (OpenGL or OpenGLES2) to the frontend if supported. It is needed to reload the core to apply this setting.",
591 "scummvm_gui_aspect_ratio",
592 "Video > GUI aspect ratio",
593 "ScummVM Launcher aspect ratio",
594 "Set ScummVM Launcher aspect ratio.",
606 "Video > GUI resolution",
607 "ScummVM Launcher resolution",
608 "Set ScummVM Launcher resolution.",
622 "scummvm_browsing_mode",
623 "System > Browsing mode",
625 "Select how the ScummVM file browser lists locations. 'Authorized storage' shows the folders authorized through the frontend (e.g. Android SAF trees). 'Local filesystem' browses the standard local paths.",
629 {
"local",
"Local filesystem"},
630 {
"authorized",
"Authorized storage"},
639 { NULL, NULL, NULL, NULL, NULL, NULL, {{0}}, NULL },
642struct retro_core_options_v2 options_us = {
653struct retro_core_option_value retro_keys_label_us [] = {
655 {
"RETROKE_VKBD",
"Toggle Virtual Keyboard"},
656 {
"RETROKE_LEFT",
"Mouse Cursor Left"},
657 {
"RETROKE_UP",
"Mouse Cursor Up"},
658 {
"RETROKE_DOWN",
"Mouse Cursor Down"},
659 {
"RETROKE_RIGHT",
"Mouse Cursor Right"},
660 {
"RETROKE_LEFT_BUTTON",
"Mouse Left Button"},
661 {
"RETROKE_RIGHT_BUTTON",
"Mouse Right Button"},
662 {
"RETROKE_FINE_CONTROL",
"Mouse Cursor Fine Control"},
663 {
"RETROKE_SCUMMVM_GUI",
"ScummVM GUI"},
664 {
"RETROKE_SHIFT_MOD",
"Keyboard Shift (Modifier)"},
665 {
"RETROKE_CTRL_MOD",
"Keyboard Control (Modifier)"},
666 {
"RETROKE_ALT_MOD",
"Keyboard Alt (Modifier)"},
667 {
"RETROK_BACKSPACE",
"Keyboard Backspace"},
668 {
"RETROK_TAB",
"Keyboard Tab"},
669 {
"RETROK_CLEAR",
"Keyboard Clear"},
670 {
"RETROK_RETURN",
"Keyboard Return"},
671 {
"RETROK_PAUSE",
"Keyboard Pause"},
672 {
"RETROK_ESCAPE",
"Keyboard Escape"},
673 {
"RETROK_SPACE",
"Keyboard Space"},
674 {
"RETROK_EXCLAIM",
"Keyboard !"},
675 {
"RETROK_QUOTEDBL",
"Keyboard \""},
676 {
"RETROK_HASH",
"Keyboard #"},
677 {
"RETROK_DOLLAR",
"Keyboard $"},
678 {
"RETROK_AMPERSAND",
"Keyboard &"},
679 {
"RETROK_QUOTE",
"Keyboard \'"},
680 {
"RETROK_LEFTPAREN",
"Keyboard ("},
681 {
"RETROK_RIGHTPAREN",
"Keyboard )"},
682 {
"RETROK_ASTERISK",
"Keyboard *"},
683 {
"RETROK_PLUS",
"Keyboard +"},
684 {
"RETROK_COMMA",
"Keyboard ,"},
685 {
"RETROK_MINUS",
"Keyboard -"},
686 {
"RETROK_PERIOD",
"Keyboard ."},
687 {
"RETROK_SLASH",
"Keyboard /"},
688 {
"RETROK_0",
"Keyboard 0"},
689 {
"RETROK_1",
"Keyboard 1"},
690 {
"RETROK_2",
"Keyboard 2"},
691 {
"RETROK_3",
"Keyboard 3"},
692 {
"RETROK_4",
"Keyboard 4"},
693 {
"RETROK_5",
"Keyboard 5"},
694 {
"RETROK_6",
"Keyboard 6"},
695 {
"RETROK_7",
"Keyboard 7"},
696 {
"RETROK_8",
"Keyboard 8"},
697 {
"RETROK_9",
"Keyboard 9"},
698 {
"RETROK_COLON",
"Keyboard :"},
699 {
"RETROK_SEMICOLON",
"Keyboard ;"},
700 {
"RETROK_LESS",
"Keyboard <"},
701 {
"RETROK_EQUALS",
"Keyboard ="},
702 {
"RETROK_GREATER",
"Keyboard >"},
703 {
"RETROK_QUESTION",
"Keyboard ?"},
704 {
"RETROK_AT",
"Keyboard @"},
705 {
"RETROK_LEFTBRACKET",
"Keyboard ["},
706 {
"RETROK_BACKSLASH",
"Keyboard \\"},
707 {
"RETROK_RIGHTBRACKET",
"Keyboard ]"},
708 {
"RETROK_CARET",
"Keyboard ^"},
709 {
"RETROK_UNDERSCORE",
"Keyboard _"},
710 {
"RETROK_BACKQUOTE",
"Keyboard `"},
711 {
"RETROK_a",
"Keyboard a"},
712 {
"RETROK_b",
"Keyboard b"},
713 {
"RETROK_c",
"Keyboard c"},
714 {
"RETROK_d",
"Keyboard d"},
715 {
"RETROK_e",
"Keyboard e"},
716 {
"RETROK_f",
"Keyboard f"},
717 {
"RETROK_g",
"Keyboard g"},
718 {
"RETROK_h",
"Keyboard h"},
719 {
"RETROK_i",
"Keyboard i"},
720 {
"RETROK_j",
"Keyboard j"},
721 {
"RETROK_k",
"Keyboard k"},
722 {
"RETROK_l",
"Keyboard l"},
723 {
"RETROK_m",
"Keyboard m"},
724 {
"RETROK_n",
"Keyboard n"},
725 {
"RETROK_o",
"Keyboard o"},
726 {
"RETROK_p",
"Keyboard p"},
727 {
"RETROK_q",
"Keyboard q"},
728 {
"RETROK_r",
"Keyboard r"},
729 {
"RETROK_s",
"Keyboard s"},
730 {
"RETROK_t",
"Keyboard t"},
731 {
"RETROK_u",
"Keyboard u"},
732 {
"RETROK_v",
"Keyboard v"},
733 {
"RETROK_w",
"Keyboard w"},
734 {
"RETROK_x",
"Keyboard x"},
735 {
"RETROK_y",
"Keyboard y"},
736 {
"RETROK_z",
"Keyboard z"},
737 {
"RETROK_KP0",
"Keyboard Numpad 0"},
738 {
"RETROK_KP1",
"Keyboard Numpad 1"},
739 {
"RETROK_KP2",
"Keyboard Numpad 2"},
740 {
"RETROK_KP3",
"Keyboard Numpad 3"},
741 {
"RETROK_KP4",
"Keyboard Numpad 4"},
742 {
"RETROK_KP5",
"Keyboard Numpad 5"},
743 {
"RETROK_KP6",
"Keyboard Numpad 6"},
744 {
"RETROK_KP7",
"Keyboard Numpad 7"},
745 {
"RETROK_KP8",
"Keyboard Numpad 8"},
746 {
"RETROK_KP9",
"Keyboard Numpad 9"},
747 {
"RETROK_KP_PERIOD",
"Keyboard Numpad ."},
748 {
"RETROK_KP_DIVIDE",
"Keyboard Numpad /"},
749 {
"RETROK_KP_MULTIPLY",
"Keyboard Numpad *"},
750 {
"RETROK_KP_MINUS",
"Keyboard Numpad -"},
751 {
"RETROK_KP_PLUS",
"Keyboard Numpad +"},
752 {
"RETROK_KP_ENTER",
"Keyboard Numpad Enter"},
753 {
"RETROK_KP_EQUALS",
"Keyboard Numpad ="},
754 {
"RETROK_UP",
"Keyboard Up"},
755 {
"RETROK_DOWN",
"Keyboard Down"},
756 {
"RETROK_LEFT",
"Keyboard Left"},
757 {
"RETROK_RIGHT",
"Keyboard Right"},
758 {
"RETROK_INSERT",
"Keyboard Insert"},
759 {
"RETROK_DELETE",
"Keyboard Delete"},
760 {
"RETROK_HOME",
"Keyboard Home"},
761 {
"RETROK_END",
"Keyboard End"},
762 {
"RETROK_PAGEUP",
"Keyboard PageUp"},
763 {
"RETROK_PAGEDOWN",
"Keyboard PageDown"},
764 {
"RETROK_F1",
"Keyboard F1"},
765 {
"RETROK_F2",
"Keyboard F2"},
766 {
"RETROK_F3",
"Keyboard F3"},
767 {
"RETROK_F4",
"Keyboard F4"},
768 {
"RETROK_F5",
"Keyboard F5"},
769 {
"RETROK_F6",
"Keyboard F6"},
770 {
"RETROK_F7",
"Keyboard F7"},
771 {
"RETROK_F8",
"Keyboard F8"},
772 {
"RETROK_F9",
"Keyboard F9"},
773 {
"RETROK_F10",
"Keyboard F10"},
774 {
"RETROK_F11",
"Keyboard F11"},
775 {
"RETROK_F12",
"Keyboard F12"},
782 {
"RETROK_LSHIFT",
"Keyboard Left Shift"},
783 {
"RETROK_RSHIFT",
"Keyboard Right Shift"},
784 {
"RETROK_LCTRL",
"Keyboard Left Control"},
785 {
"RETROK_RCTRL",
"Keyboard Right Control"},
786 {
"RETROK_LALT",
"Keyboard Left Alt"},
787 {
"RETROK_RALT",
"Keyboard Right Alt"},
811#ifndef HAVE_NO_LANGEXTRA
812struct retro_core_options_v2 *options_intl[RETRO_LANGUAGE_LAST] = {
834struct retro_core_option_value *retro_keys_labels_intl[RETRO_LANGUAGE_LAST] = {
863static INLINE
void libretro_fill_options_mapper_data(retro_environment_t environ_cb) {
867 while (option_defs_us[m].key) {
868 if (strstr(option_defs_us[m].key,
"scummvm_mapper_")) {
870 while (retro_keys_label_us[n].label && n < RETRO_NUM_CORE_OPTION_VALUES_MAX - 1) {
871 option_defs_us[m].values[n].value = retro_keys_label_us[n].value;
872 option_defs_us[m].values[n].label = retro_keys_label_us[n].label;
875 option_defs_us[m].values[n].value = NULL;
876 option_defs_us[m].values[n].label = NULL;
880#ifndef HAVE_NO_LANGEXTRA
881 struct retro_core_option_value *retro_keys_label_intl = NULL;
882 unsigned language = 0;
884 if (environ_cb(RETRO_ENVIRONMENT_GET_LANGUAGE, &language) &&
885 (language < RETRO_LANGUAGE_LAST) && (language != RETRO_LANGUAGE_ENGLISH))
886 retro_keys_label_intl = retro_keys_labels_intl[language];
888 if (! options_intl[language] || ! retro_keys_label_intl)
893 while (options_intl[language]->definitions[m].key) {
894 if (strstr(options_intl[language]->definitions[m].key,
"scummvm_mapper_")) {
896 while ((retro_keys_label_intl + n)->label && n < RETRO_NUM_CORE_OPTION_VALUES_MAX - 1) {
897 options_intl[language]->definitions[m].values[n].value = (retro_keys_label_intl + n)->value;
898 options_intl[language]->definitions[m].values[n].label = (retro_keys_label_intl + n)->label;
901 options_intl[language]->definitions[m].values[n].value = NULL;
902 options_intl[language]->definitions[m].values[n].label = NULL;
917static INLINE
void libretro_set_core_options(retro_environment_t environ_cb,
918 bool *categories_supported) {
919 unsigned version = 0;
920#ifndef HAVE_NO_LANGEXTRA
921 unsigned language = 0;
924 if (!environ_cb || !categories_supported)
927 *categories_supported =
false;
929 if (!environ_cb(RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION, &version))
933#ifndef HAVE_NO_LANGEXTRA
934 struct retro_core_options_v2_intl core_options_intl;
936 core_options_intl.us = &options_us;
937 core_options_intl.local = NULL;
939 if (environ_cb(RETRO_ENVIRONMENT_GET_LANGUAGE, &language) &&
940 (language < RETRO_LANGUAGE_LAST) && (language != RETRO_LANGUAGE_ENGLISH))
941 core_options_intl.local = options_intl[language];
943 *categories_supported = environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2_INTL,
946 *categories_supported = environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2,
951 size_t option_index = 0;
952 size_t num_options = 0;
953 struct retro_core_option_definition
954 *option_v1_defs_us = NULL;
955#ifndef HAVE_NO_LANGEXTRA
956 size_t num_options_intl = 0;
957 struct retro_core_option_v2_definition
958 *option_defs_intl = NULL;
959 struct retro_core_option_definition
960 *option_v1_defs_intl = NULL;
961 struct retro_core_options_intl
962 core_options_v1_intl;
964 struct retro_variable *variables = NULL;
965 char **values_buf = NULL;
969 if (option_defs_us[num_options].key)
977 option_v1_defs_us = (
struct retro_core_option_definition *)
978 calloc(num_options + 1,
sizeof(
struct retro_core_option_definition));
981 for (i = 0; i < num_options; i++) {
982 struct retro_core_option_v2_definition *option_def_us = &option_defs_us[i];
983 struct retro_core_option_value *option_values = option_def_us->values;
984 struct retro_core_option_definition *option_v1_def_us = &option_v1_defs_us[i];
985 struct retro_core_option_value *option_v1_values = option_v1_def_us->values;
987 option_v1_def_us->key = option_def_us->key;
988 option_v1_def_us->desc = option_def_us->desc;
989 option_v1_def_us->info = option_def_us->info;
990 option_v1_def_us->default_value = option_def_us->default_value;
993 while (option_values->value) {
994 option_v1_values->value = option_values->value;
995 option_v1_values->label = option_values->label;
1002#ifndef HAVE_NO_LANGEXTRA
1003 if (environ_cb(RETRO_ENVIRONMENT_GET_LANGUAGE, &language) &&
1004 (language < RETRO_LANGUAGE_LAST) && (language != RETRO_LANGUAGE_ENGLISH) &&
1005 options_intl[language])
1006 option_defs_intl = options_intl[language]->definitions;
1008 if (option_defs_intl) {
1011 if (option_defs_intl[num_options_intl].key)
1018 option_v1_defs_intl = (
struct retro_core_option_definition *)
1019 calloc(num_options_intl + 1,
sizeof(
struct retro_core_option_definition));
1022 for (i = 0; i < num_options_intl; i++) {
1023 struct retro_core_option_v2_definition *option_def_intl = &option_defs_intl[i];
1024 struct retro_core_option_value *option_values = option_def_intl->values;
1025 struct retro_core_option_definition *option_v1_def_intl = &option_v1_defs_intl[i];
1026 struct retro_core_option_value *option_v1_values = option_v1_def_intl->values;
1028 option_v1_def_intl->key = option_def_intl->key;
1029 option_v1_def_intl->desc = option_def_intl->desc;
1030 option_v1_def_intl->info = option_def_intl->info;
1031 option_v1_def_intl->default_value = option_def_intl->default_value;
1034 while (option_values->value) {
1035 option_v1_values->value = option_values->value;
1036 option_v1_values->label = option_values->label;
1044 core_options_v1_intl.us = option_v1_defs_us;
1045 core_options_v1_intl.local = option_v1_defs_intl;
1047 environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_INTL, &core_options_v1_intl);
1049 environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS, option_v1_defs_us);
1053 variables = (
struct retro_variable *)calloc(num_options + 1,
1054 sizeof(
struct retro_variable));
1055 values_buf = (
char **)calloc(num_options,
sizeof(
char *));
1057 if (!variables || !values_buf)
1061 for (i = 0; i < num_options; i++) {
1062 const char *key = option_defs_us[i].key;
1063 const char *desc = option_defs_us[i].desc;
1064 const char *default_value = option_defs_us[i].default_value;
1065 struct retro_core_option_value *values = option_defs_us[i].values;
1067 size_t default_index = 0;
1069 values_buf[i] = NULL;
1072 size_t num_values = 0;
1076 if (values[num_values].value) {
1079 if (strcmp(values[num_values].value, default_value) == 0)
1080 default_index = num_values;
1082 buf_len += strlen(values[num_values].value);
1089 if (num_values > 0) {
1090 buf_len += num_values - 1;
1091 buf_len += strlen(desc);
1093 values_buf[i] = (
char *)calloc(buf_len,
sizeof(
char));
1097 strcpy(values_buf[i], desc);
1098 strcat(values_buf[i],
"; ");
1101 strcat(values_buf[i], values[default_index].value);
1104 for (j = 0; j < num_values; j++) {
1105 if (j != default_index) {
1106 strcat(values_buf[i],
"|");
1107 strcat(values_buf[i], values[j].value);
1113 variables[option_index].key = key;
1114 variables[option_index].value = values_buf[i];
1119 environ_cb(RETRO_ENVIRONMENT_SET_VARIABLES, variables);
1125 if (option_v1_defs_us) {
1126 free(option_v1_defs_us);
1127 option_v1_defs_us = NULL;
1130#ifndef HAVE_NO_LANGEXTRA
1131 if (option_v1_defs_intl) {
1132 free(option_v1_defs_intl);
1133 option_v1_defs_intl = NULL;
1138 for (i = 0; i < num_options; i++) {
1139 if (values_buf[i]) {
1140 free(values_buf[i]);
1141 values_buf[i] = NULL;
void NORETURN_PRE error(MSVC_PRINTF const char *s,...) GCC_PRINTF(1