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" 74 struct 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 struct retro_core_option_v2_definition option_defs_us[] = {
100 "scummvm_gamepad_cursor_only",
101 "Cursor > Exclusive cursor control with RetroPad",
102 "Exclusive cursor control with RetroPad",
103 "Allows the use of RetroPad only to control mouse cursor, excluding the other inputs (e.g. physical mouse, touch screen).",
114 "scummvm_gamepad_cursor_speed",
115 "Cursor > Gamepad Cursor Speed",
116 "Gamepad Cursor Speed",
117 "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.",
134 "scummvm_gamepad_cursor_acceleration_time",
135 "Cursor > Gamepad Cursor Acceleration",
136 "Gamepad Cursor Acceleration",
137 "The amount of time (In seconds) it takes for the cursor to reach full speed",
157 "scummvm_analog_response",
158 "Cursor > Analog Cursor Response",
159 "Analog Cursor Response",
160 "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.",
164 {
"linear",
"Linear"},
165 {
"quadratic",
"Quadratic"},
171 "scummvm_analog_deadzone",
172 "Cursor > Analog Deadzone",
174 "Sets the deadzone in percentage of the RetroPad analog sticks. Used to eliminate cursor drift/unwanted input.",
190 "scummvm_mouse_speed",
191 "Cursor > Mouse Speed",
193 "Sets the mouse cursor speed multiplier when moving the cursor with the RetroMouse.",
223 "scummvm_mouse_fine_control_speed_reduction",
224 "Cursor > Mouse Fine Control Speed Reduction",
225 "Mouse Fine Control Speed Reduction",
226 "Sets the mouse cursor speed reduction as percentage of normal speed when fine control is activated.",
239 "Timing > Frame rate cap",
241 "Set core frame rate upper limit. Reducing the limit will improve the performance on lower end devices. Changing this setting will reset the core.",
245 {
"disabled", NULL },
255 "scummvm_samplerate",
256 "Timing > Sample rate",
258 "Set core sample rate. Reducing the rate will slightly improve the performance on lower end devices. Changing this setting will reset the core.",
262 {
"48000 Hz", NULL },
263 {
"44100 Hz", NULL },
282 "scummvm_mapper_down",
294 "scummvm_mapper_left",
306 "scummvm_mapper_right",
366 "scummvm_mapper_select",
378 "scummvm_mapper_start",
387 "RETROKE_SCUMMVM_GUI" 399 "RETROKE_LEFT_BUTTON" 411 "RETROKE_RIGHT_BUTTON" 435 "RETROKE_FINE_CONTROL" 464 "RetroPad > Left Analog > Up",
476 "RetroPad > Left Analog > Down",
477 "Left Analog > Down",
488 "RetroPad > Left Analog > Left",
489 "Left Analog > Left",
500 "RetroPad > Left Analog > Right",
501 "Left Analog > Right",
513 "RetroPad > Right Analog > Up",
525 "RetroPad > Right Analog > Down",
526 "Right Analog > Down",
537 "RetroPad > Right Analog > Left",
538 "Right Analog > Left",
549 "RetroPad > Right Analog > Right",
550 "Right Analog > Right",
560 "scummvm_video_hw_acceleration",
561 "Video > Hardware acceleration",
562 "Hardware acceleration",
563 "Request video hardware acceleration (OpenGL or OpenGLES2) to the frontend if supported. It is needed to reload the core to apply this setting.",
581 "scummvm_gui_aspect_ratio",
582 "Video > GUI aspect ratio",
583 "ScummVM Launcher aspect ratio",
584 "Set ScummVM Launcher aspect ratio.",
596 "Video > GUI resolution",
597 "ScummVM Launcher resolution",
598 "Set ScummVM Launcher resolution.",
611 { NULL, NULL, NULL, NULL, NULL, NULL, {{0}}, NULL },
614 struct retro_core_options_v2 options_us = {
625 struct retro_core_option_value retro_keys_label_us [] = {
627 {
"RETROKE_VKBD",
"Toggle Virtual Keyboard"},
628 {
"RETROKE_LEFT",
"Mouse Cursor Left"},
629 {
"RETROKE_UP",
"Mouse Cursor Up"},
630 {
"RETROKE_DOWN",
"Mouse Cursor Down"},
631 {
"RETROKE_RIGHT",
"Mouse Cursor Right"},
632 {
"RETROKE_LEFT_BUTTON",
"Mouse Left Button"},
633 {
"RETROKE_RIGHT_BUTTON",
"Mouse Right Button"},
634 {
"RETROKE_FINE_CONTROL",
"Mouse Cursor Fine Control"},
635 {
"RETROKE_SCUMMVM_GUI",
"ScummVM GUI"},
636 {
"RETROKE_SHIFT_MOD",
"Keyboard Shift (Modifier)"},
637 {
"RETROKE_CTRL_MOD",
"Keyboard Control (Modifier)"},
638 {
"RETROKE_ALT_MOD",
"Keyboard Alt (Modifier)"},
639 {
"RETROK_BACKSPACE",
"Keyboard Backspace"},
640 {
"RETROK_TAB",
"Keyboard Tab"},
641 {
"RETROK_CLEAR",
"Keyboard Clear"},
642 {
"RETROK_RETURN",
"Keyboard Return"},
643 {
"RETROK_PAUSE",
"Keyboard Pause"},
644 {
"RETROK_ESCAPE",
"Keyboard Escape"},
645 {
"RETROK_SPACE",
"Keyboard Space"},
646 {
"RETROK_EXCLAIM",
"Keyboard !"},
647 {
"RETROK_QUOTEDBL",
"Keyboard \""},
648 {
"RETROK_HASH",
"Keyboard #"},
649 {
"RETROK_DOLLAR",
"Keyboard $"},
650 {
"RETROK_AMPERSAND",
"Keyboard &"},
651 {
"RETROK_QUOTE",
"Keyboard \'"},
652 {
"RETROK_LEFTPAREN",
"Keyboard ("},
653 {
"RETROK_RIGHTPAREN",
"Keyboard )"},
654 {
"RETROK_ASTERISK",
"Keyboard *"},
655 {
"RETROK_PLUS",
"Keyboard +"},
656 {
"RETROK_COMMA",
"Keyboard ,"},
657 {
"RETROK_MINUS",
"Keyboard -"},
658 {
"RETROK_PERIOD",
"Keyboard ."},
659 {
"RETROK_SLASH",
"Keyboard /"},
660 {
"RETROK_0",
"Keyboard 0"},
661 {
"RETROK_1",
"Keyboard 1"},
662 {
"RETROK_2",
"Keyboard 2"},
663 {
"RETROK_3",
"Keyboard 3"},
664 {
"RETROK_4",
"Keyboard 4"},
665 {
"RETROK_5",
"Keyboard 5"},
666 {
"RETROK_6",
"Keyboard 6"},
667 {
"RETROK_7",
"Keyboard 7"},
668 {
"RETROK_8",
"Keyboard 8"},
669 {
"RETROK_9",
"Keyboard 9"},
670 {
"RETROK_COLON",
"Keyboard :"},
671 {
"RETROK_SEMICOLON",
"Keyboard ;"},
672 {
"RETROK_LESS",
"Keyboard <"},
673 {
"RETROK_EQUALS",
"Keyboard ="},
674 {
"RETROK_GREATER",
"Keyboard >"},
675 {
"RETROK_QUESTION",
"Keyboard ?"},
676 {
"RETROK_AT",
"Keyboard @"},
677 {
"RETROK_LEFTBRACKET",
"Keyboard ["},
678 {
"RETROK_BACKSLASH",
"Keyboard \\"},
679 {
"RETROK_RIGHTBRACKET",
"Keyboard ]"},
680 {
"RETROK_CARET",
"Keyboard ^"},
681 {
"RETROK_UNDERSCORE",
"Keyboard _"},
682 {
"RETROK_BACKQUOTE",
"Keyboard `"},
683 {
"RETROK_a",
"Keyboard a"},
684 {
"RETROK_b",
"Keyboard b"},
685 {
"RETROK_c",
"Keyboard c"},
686 {
"RETROK_d",
"Keyboard d"},
687 {
"RETROK_e",
"Keyboard e"},
688 {
"RETROK_f",
"Keyboard f"},
689 {
"RETROK_g",
"Keyboard g"},
690 {
"RETROK_h",
"Keyboard h"},
691 {
"RETROK_i",
"Keyboard i"},
692 {
"RETROK_j",
"Keyboard j"},
693 {
"RETROK_k",
"Keyboard k"},
694 {
"RETROK_l",
"Keyboard l"},
695 {
"RETROK_m",
"Keyboard m"},
696 {
"RETROK_n",
"Keyboard n"},
697 {
"RETROK_o",
"Keyboard o"},
698 {
"RETROK_p",
"Keyboard p"},
699 {
"RETROK_q",
"Keyboard q"},
700 {
"RETROK_r",
"Keyboard r"},
701 {
"RETROK_s",
"Keyboard s"},
702 {
"RETROK_t",
"Keyboard t"},
703 {
"RETROK_u",
"Keyboard u"},
704 {
"RETROK_v",
"Keyboard v"},
705 {
"RETROK_w",
"Keyboard w"},
706 {
"RETROK_x",
"Keyboard x"},
707 {
"RETROK_y",
"Keyboard y"},
708 {
"RETROK_z",
"Keyboard z"},
709 {
"RETROK_KP0",
"Keyboard Numpad 0"},
710 {
"RETROK_KP1",
"Keyboard Numpad 1"},
711 {
"RETROK_KP2",
"Keyboard Numpad 2"},
712 {
"RETROK_KP3",
"Keyboard Numpad 3"},
713 {
"RETROK_KP4",
"Keyboard Numpad 4"},
714 {
"RETROK_KP5",
"Keyboard Numpad 5"},
715 {
"RETROK_KP6",
"Keyboard Numpad 6"},
716 {
"RETROK_KP7",
"Keyboard Numpad 7"},
717 {
"RETROK_KP8",
"Keyboard Numpad 8"},
718 {
"RETROK_KP9",
"Keyboard Numpad 9"},
719 {
"RETROK_KP_PERIOD",
"Keyboard Numpad ."},
720 {
"RETROK_KP_DIVIDE",
"Keyboard Numpad /"},
721 {
"RETROK_KP_MULTIPLY",
"Keyboard Numpad *"},
722 {
"RETROK_KP_MINUS",
"Keyboard Numpad -"},
723 {
"RETROK_KP_PLUS",
"Keyboard Numpad +"},
724 {
"RETROK_KP_ENTER",
"Keyboard Numpad Enter"},
725 {
"RETROK_KP_EQUALS",
"Keyboard Numpad ="},
726 {
"RETROK_UP",
"Keyboard Up"},
727 {
"RETROK_DOWN",
"Keyboard Down"},
728 {
"RETROK_LEFT",
"Keyboard Left"},
729 {
"RETROK_RIGHT",
"Keyboard Right"},
730 {
"RETROK_INSERT",
"Keyboard Insert"},
731 {
"RETROK_DELETE",
"Keyboard Delete"},
732 {
"RETROK_HOME",
"Keyboard Home"},
733 {
"RETROK_END",
"Keyboard End"},
734 {
"RETROK_PAGEUP",
"Keyboard PageUp"},
735 {
"RETROK_PAGEDOWN",
"Keyboard PageDown"},
736 {
"RETROK_F1",
"Keyboard F1"},
737 {
"RETROK_F2",
"Keyboard F2"},
738 {
"RETROK_F3",
"Keyboard F3"},
739 {
"RETROK_F4",
"Keyboard F4"},
740 {
"RETROK_F5",
"Keyboard F5"},
741 {
"RETROK_F6",
"Keyboard F6"},
742 {
"RETROK_F7",
"Keyboard F7"},
743 {
"RETROK_F8",
"Keyboard F8"},
744 {
"RETROK_F9",
"Keyboard F9"},
745 {
"RETROK_F10",
"Keyboard F10"},
746 {
"RETROK_F11",
"Keyboard F11"},
747 {
"RETROK_F12",
"Keyboard F12"},
754 {
"RETROK_LSHIFT",
"Keyboard Left Shift"},
755 {
"RETROK_RSHIFT",
"Keyboard Right Shift"},
756 {
"RETROK_LCTRL",
"Keyboard Left Control"},
757 {
"RETROK_RCTRL",
"Keyboard Right Control"},
758 {
"RETROK_LALT",
"Keyboard Left Alt"},
759 {
"RETROK_RALT",
"Keyboard Right Alt"},
783 #ifndef HAVE_NO_LANGEXTRA 784 struct retro_core_options_v2 *options_intl[RETRO_LANGUAGE_LAST] = {
806 struct retro_core_option_value *retro_keys_labels_intl[RETRO_LANGUAGE_LAST] = {
835 static INLINE
void libretro_fill_options_mapper_data(retro_environment_t environ_cb) {
839 while (option_defs_us[m].key) {
840 if (strstr(option_defs_us[m].key,
"scummvm_mapper_")) {
842 while (retro_keys_label_us[n].label && n < RETRO_NUM_CORE_OPTION_VALUES_MAX - 1) {
843 option_defs_us[m].values[n].value = retro_keys_label_us[n].value;
844 option_defs_us[m].values[n].label = retro_keys_label_us[n].label;
847 option_defs_us[m].values[n].value = NULL;
848 option_defs_us[m].values[n].label = NULL;
852 #ifndef HAVE_NO_LANGEXTRA 853 struct retro_core_option_value *retro_keys_label_intl = NULL;
854 unsigned language = 0;
856 if (environ_cb(RETRO_ENVIRONMENT_GET_LANGUAGE, &language) &&
857 (language < RETRO_LANGUAGE_LAST) && (language != RETRO_LANGUAGE_ENGLISH))
858 retro_keys_label_intl = retro_keys_labels_intl[language];
860 if (! options_intl[language] || ! retro_keys_label_intl)
865 while (options_intl[language]->definitions[m].key) {
866 if (strstr(options_intl[language]->definitions[m].key,
"scummvm_mapper_")) {
868 while ((retro_keys_label_intl + n)->label && n < RETRO_NUM_CORE_OPTION_VALUES_MAX - 1) {
869 options_intl[language]->definitions[m].values[n].value = (retro_keys_label_intl + n)->value;
870 options_intl[language]->definitions[m].values[n].label = (retro_keys_label_intl + n)->label;
873 options_intl[language]->definitions[m].values[n].value = NULL;
874 options_intl[language]->definitions[m].values[n].label = NULL;
889 static INLINE
void libretro_set_core_options(retro_environment_t environ_cb,
890 bool *categories_supported) {
891 unsigned version = 0;
892 #ifndef HAVE_NO_LANGEXTRA 893 unsigned language = 0;
896 if (!environ_cb || !categories_supported)
899 *categories_supported =
false;
901 if (!environ_cb(RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION, &version))
905 #ifndef HAVE_NO_LANGEXTRA 906 struct retro_core_options_v2_intl core_options_intl;
908 core_options_intl.us = &options_us;
909 core_options_intl.local = NULL;
911 if (environ_cb(RETRO_ENVIRONMENT_GET_LANGUAGE, &language) &&
912 (language < RETRO_LANGUAGE_LAST) && (language != RETRO_LANGUAGE_ENGLISH))
913 core_options_intl.local = options_intl[language];
915 *categories_supported = environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2_INTL,
918 *categories_supported = environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2,
923 size_t option_index = 0;
924 size_t num_options = 0;
925 struct retro_core_option_definition
926 *option_v1_defs_us = NULL;
927 #ifndef HAVE_NO_LANGEXTRA 928 size_t num_options_intl = 0;
929 struct retro_core_option_v2_definition
930 *option_defs_intl = NULL;
931 struct retro_core_option_definition
932 *option_v1_defs_intl = NULL;
933 struct retro_core_options_intl
934 core_options_v1_intl;
936 struct retro_variable *variables = NULL;
937 char **values_buf = NULL;
941 if (option_defs_us[num_options].key)
949 option_v1_defs_us = (
struct retro_core_option_definition *)
950 calloc(num_options + 1,
sizeof(
struct retro_core_option_definition));
953 for (i = 0; i < num_options; i++) {
954 struct retro_core_option_v2_definition *option_def_us = &option_defs_us[i];
955 struct retro_core_option_value *option_values = option_def_us->values;
956 struct retro_core_option_definition *option_v1_def_us = &option_v1_defs_us[i];
957 struct retro_core_option_value *option_v1_values = option_v1_def_us->values;
959 option_v1_def_us->key = option_def_us->key;
960 option_v1_def_us->desc = option_def_us->desc;
961 option_v1_def_us->info = option_def_us->info;
962 option_v1_def_us->default_value = option_def_us->default_value;
965 while (option_values->value) {
966 option_v1_values->value = option_values->value;
967 option_v1_values->label = option_values->label;
974 #ifndef HAVE_NO_LANGEXTRA 975 if (environ_cb(RETRO_ENVIRONMENT_GET_LANGUAGE, &language) &&
976 (language < RETRO_LANGUAGE_LAST) && (language != RETRO_LANGUAGE_ENGLISH) &&
977 options_intl[language])
978 option_defs_intl = options_intl[language]->definitions;
980 if (option_defs_intl) {
983 if (option_defs_intl[num_options_intl].key)
990 option_v1_defs_intl = (
struct retro_core_option_definition *)
991 calloc(num_options_intl + 1,
sizeof(
struct retro_core_option_definition));
994 for (i = 0; i < num_options_intl; i++) {
995 struct retro_core_option_v2_definition *option_def_intl = &option_defs_intl[i];
996 struct retro_core_option_value *option_values = option_def_intl->values;
997 struct retro_core_option_definition *option_v1_def_intl = &option_v1_defs_intl[i];
998 struct retro_core_option_value *option_v1_values = option_v1_def_intl->values;
1000 option_v1_def_intl->key = option_def_intl->key;
1001 option_v1_def_intl->desc = option_def_intl->desc;
1002 option_v1_def_intl->info = option_def_intl->info;
1003 option_v1_def_intl->default_value = option_def_intl->default_value;
1006 while (option_values->value) {
1007 option_v1_values->value = option_values->value;
1008 option_v1_values->label = option_values->label;
1016 core_options_v1_intl.us = option_v1_defs_us;
1017 core_options_v1_intl.local = option_v1_defs_intl;
1019 environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_INTL, &core_options_v1_intl);
1021 environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS, option_v1_defs_us);
1025 variables = (
struct retro_variable *)calloc(num_options + 1,
1026 sizeof(
struct retro_variable));
1027 values_buf = (
char **)calloc(num_options,
sizeof(
char *));
1029 if (!variables || !values_buf)
1033 for (i = 0; i < num_options; i++) {
1034 const char *key = option_defs_us[i].key;
1035 const char *desc = option_defs_us[i].desc;
1036 const char *default_value = option_defs_us[i].default_value;
1037 struct retro_core_option_value *values = option_defs_us[i].values;
1039 size_t default_index = 0;
1041 values_buf[i] = NULL;
1044 size_t num_values = 0;
1048 if (values[num_values].value) {
1051 if (strcmp(values[num_values].value, default_value) == 0)
1052 default_index = num_values;
1054 buf_len += strlen(values[num_values].value);
1061 if (num_values > 0) {
1062 buf_len += num_values - 1;
1063 buf_len += strlen(desc);
1065 values_buf[i] = (
char *)calloc(buf_len,
sizeof(
char));
1069 strcpy(values_buf[i], desc);
1070 strcat(values_buf[i],
"; ");
1073 strcat(values_buf[i], values[default_index].value);
1076 for (j = 0; j < num_values; j++) {
1077 if (j != default_index) {
1078 strcat(values_buf[i],
"|");
1079 strcat(values_buf[i], values[j].value);
1085 variables[option_index].key = key;
1086 variables[option_index].value = values_buf[i];
1091 environ_cb(RETRO_ENVIRONMENT_SET_VARIABLES, variables);
1097 if (option_v1_defs_us) {
1098 free(option_v1_defs_us);
1099 option_v1_defs_us = NULL;
1102 #ifndef HAVE_NO_LANGEXTRA 1103 if (option_v1_defs_intl) {
1104 free(option_v1_defs_intl);
1105 option_v1_defs_intl = NULL;
1110 for (i = 0; i < num_options; i++) {
1111 if (values_buf[i]) {
1112 free(values_buf[i]);
1113 values_buf[i] = NULL;
void NORETURN_PRE error(MSVC_PRINTF const char *s,...) GCC_PRINTF(1