Adding Guncon support for mouse based lightguns
[pcsx_rearmed.git] / frontend / libretro_core_options.h
CommitLineData
919cac88 1#ifndef LIBRETRO_CORE_OPTIONS_H__
2#define LIBRETRO_CORE_OPTIONS_H__
3
4#include <stdlib.h>
5#include <string.h>
6
7#include <libretro.h>
8#include <retro_inline.h>
9
fbe06628 10#ifndef HAVE_NO_LANGEXTRA
11#include "libretro_core_options_intl.h"
12#endif
13
14/*
15 ********************************
16 * VERSION: 1.3
17 ********************************
18 *
19 * - 1.3: Move translations to libretro_core_options_intl.h
20 * - libretro_core_options_intl.h includes BOM and utf-8
21 * fix for MSVC 2010-2013
22 * - Added HAVE_NO_LANGEXTRA flag to disable translations
23 * on platforms/compilers without BOM support
24 * - 1.2: Use core options v1 interface when
25 * RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION is >= 1
26 * (previously required RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION == 1)
27 * - 1.1: Support generation of core options v0 retro_core_option_value
28 * arrays containing options with a single value
29 * - 1.0: First commit
30*/
31
919cac88 32#ifdef __cplusplus
33extern "C" {
34#endif
35
36/*
37 ********************************
38 * Core Option Definitions
39 ********************************
40*/
41
42/* RETRO_LANGUAGE_ENGLISH */
43
44/* Default language:
45 * - All other languages must include the same keys and values
46 * - Will be used as a fallback in the event that frontend language
47 * is not available
48 * - Will be used as a fallback for any missing entries in
49 * frontend language definition
50 */
51
919cac88 52struct retro_core_option_definition option_defs_us[] = {
53 {
54 "pcsx_rearmed_frameskip",
55 "Frameskip",
56 "Choose how much frames should be skipped to improve performance at the expense of visual smoothness.",
57 {
58 { "0", NULL },
59 { "1", NULL },
60 { "2", NULL },
61 { "3", NULL },
fbe06628 62 { NULL, NULL },
919cac88 63 },
64 "0",
65 },
66 {
67 "pcsx_rearmed_bios",
68 "Use BIOS",
69 "Allows you to use real bios file (if available) or emulated bios (HLE). Its recommended to use official bios file for better compatibility.",
70 {
71 { "auto", "auto" },
fbe06628 72 { "HLE", "hle" },
73 { NULL, NULL },
919cac88 74 },
75 "auto",
76 },
77 {
78 "pcsx_rearmed_region",
79 "Region",
80 "Choose what region the system is from. 60 Hz for NTSC, 50 Hz for PAL.",
81 {
82 { "auto", "auto" },
83 { "NTSC", "ntsc" },
fbe06628 84 { "PAL", "pal" },
85 { NULL, NULL },
919cac88 86 },
87 "auto",
88 },
89 {
90 "pcsx_rearmed_memcard2",
c8108d88 91 "Enable Second Memory Card (Shared)",
ef2683f1 92 "Enabled the memory card slot 2. This memory card is shared amongst all games.",
919cac88 93 {
fbe06628 94 { "disabled", NULL },
919cac88 95 { "enabled", NULL },
fbe06628 96 { NULL, NULL },
919cac88 97 },
e6f1e7f7 98 "disabled",
919cac88 99 },
100 {
101 "pcsx_rearmed_pad1type",
102 "Pad 1 Type",
103 "Pad type for player 1",
104 {
fbe06628 105 { "standard", NULL },
106 { "analog", NULL },
919cac88 107 { "dualshock", NULL },
fbe06628 108 { "negcon", NULL },
109 { "none", NULL },
110 { NULL, NULL },
919cac88 111 },
112 "standard",
113 },
114 {
115 "pcsx_rearmed_pad2type",
116 "Pad 2 Type",
117 "Pad type for player 2",
118 {
fbe06628 119 { "standard", NULL },
120 { "analog", NULL },
919cac88 121 { "dualshock", NULL },
fbe06628 122 { "negcon", NULL },
123 { "none", NULL },
124 { NULL, NULL },
919cac88 125 },
126 "standard",
127 },
128 {
129 "pcsx_rearmed_pad3type",
130 "Pad 3 Type",
131 "Pad type for player 3",
132 {
fbe06628 133 { "standard", NULL },
134 { "analog", NULL },
919cac88 135 { "dualshock", NULL },
fbe06628 136 { "negcon", NULL },
137 { "none", NULL },
138 { NULL, NULL },
919cac88 139 },
140 "none",
141 },
142 {
143 "pcsx_rearmed_pad4type",
144 "Pad 4 Type",
145 "Pad type for player 4",
146 {
fbe06628 147 { "standard", NULL },
148 { "analog", NULL },
919cac88 149 { "dualshock", NULL },
fbe06628 150 { "negcon", NULL },
151 { "none", NULL },
152 { NULL, NULL },
919cac88 153 },
154 "none",
155 },
156 {
157 "pcsx_rearmed_pad5type",
158 "Pad 5 Type",
159 "Pad type for player 5",
160 {
fbe06628 161 { "standard", NULL },
162 { "analog", NULL },
919cac88 163 { "dualshock", NULL },
fbe06628 164 { "negcon", NULL },
165 { "none", NULL },
166 { NULL, NULL },
919cac88 167 },
168 "none",
169 },{
170 "pcsx_rearmed_pad6type",
171 "Pad 6 Type",
172 "Pad type for player 6",
173 {
fbe06628 174 { "standard", NULL },
175 { "analog", NULL },
919cac88 176 { "dualshock", NULL },
fbe06628 177 { "negcon", NULL },
178 { "none", NULL },
179 { NULL, NULL },
919cac88 180 },
181 "none",
182 },{
183 "pcsx_rearmed_pad7type",
184 "Pad 7 Type",
185 "Pad type for player 7",
186 {
fbe06628 187 { "standard", NULL },
188 { "analog", NULL },
919cac88 189 { "dualshock", NULL },
fbe06628 190 { "negcon", NULL },
191 { "none", NULL },
192 { NULL, NULL },
919cac88 193 },
194 "none",
195 },{
196 "pcsx_rearmed_pad8type",
197 "Pad 8 Type",
198 "Pad type for player 8",
199 {
fbe06628 200 { "standard", NULL },
201 { "analog", NULL },
919cac88 202 { "dualshock", NULL },
fbe06628 203 { "negcon", NULL },
204 { "none", NULL },
205 { NULL, NULL },
919cac88 206 },
207 "none",
208 },
209 {
210 "pcsx_rearmed_multitap1",
211 "Multitap 1",
212 "Enables/Disables multitap on port 1, allowing upto 5 players in games that permit it.",
213 {
fbe06628 214 { "auto", NULL },
919cac88 215 { "disabled", NULL },
216 { "enabled", NULL },
fbe06628 217 { NULL, NULL },
919cac88 218 },
219 "auto",
220 },
221 {
222 "pcsx_rearmed_multitap2",
223 "Multitap 2",
ef2683f1 224 "Enables/Disables multitap on port 2, allowing up to 8 players in games that permit it. Multitap 1 has to be enabled for this to work.",
919cac88 225 {
fbe06628 226 { "auto", NULL },
227 { "disabled", NULL },
228 { "enabled", NULL },
229 { NULL, NULL },
919cac88 230 },
231 "auto",
232 },
233 {
234 "pcsx_rearmed_negcon_deadzone",
c8108d88 235 "NegCon Twist Deadzone (Percent)",
919cac88 236 "Sets the deadzone of the RetroPad left analog stick when simulating the 'twist' action of emulated neGcon Controllers. Used to eliminate drift/unwanted input.",
237 {
238 { "0", NULL },
239 { "5", NULL },
240 { "10", NULL },
241 { "15", NULL },
242 { "20", NULL },
243 { "25", NULL },
244 { "30", NULL },
fbe06628 245 { NULL, NULL },
919cac88 246 },
247 "0",
248 },
249 {
250 "pcsx_rearmed_negcon_response",
251 "NegCon Twist Response",
252 "Specifies the analog response when using a RetroPad left analog stick to simulate the 'twist' action of emulated neGcon Controllers.",
253 {
fbe06628 254 { "linear", NULL },
919cac88 255 { "quadratic", NULL },
fbe06628 256 { "cubic", NULL },
257 { NULL, NULL },
919cac88 258 },
259 "linear",
260 },
261 {
262 "pcsx_rearmed_vibration",
263 "Enable Vibration",
c8108d88 264 "Enables vibration feedback for controllers that supports vibration features.",
919cac88 265 {
266 { "disabled", NULL },
267 { "enabled", NULL },
fbe06628 268 { NULL, NULL },
919cac88 269 },
270 "enabled",
271 },
272 {
273 "pcsx_rearmed_dithering",
274 "Enable Dithering",
275 "If Off, disables the dithering pattern the PSX applies to combat color banding.",
276 {
277 { "disabled", NULL },
278 { "enabled", NULL },
fbe06628 279 { NULL, NULL },
919cac88 280 },
281 "enabled",
282 },
283
284#ifndef DRC_DISABLE
285 {
286 "pcsx_rearmed_drc",
c8108d88 287 "Dynamic Recompiler",
ef2683f1 288 "Enables core to use dynamic recompiler or interpreter (slower) CPU instructions.",
919cac88 289 {
290 { "disabled", NULL },
291 { "enabled", NULL },
fbe06628 292 { NULL, NULL },
919cac88 293 },
294 "enabled",
295 },
296 {
297 "pcsx_rearmed_psxclock",
c8108d88 298 "PSX CPU Clock",
fbe06628 299#ifdef HAVE_PRE_ARMV7
300 "Overclock or underclock the PSX clock. Default is 50",
301#else
302 "Overclock or underclock the PSX clock. Default is 57",
303#endif
919cac88 304 {
fbe06628 305 { "30", NULL },
306 { "31", NULL },
307 { "32", NULL },
308 { "33", NULL },
309 { "34", NULL },
310 { "35", NULL },
311 { "36", NULL },
312 { "37", NULL },
313 { "38", NULL },
314 { "39", NULL },
315 { "40", NULL },
316 { "41", NULL },
317 { "42", NULL },
318 { "43", NULL },
319 { "44", NULL },
320 { "45", NULL },
321 { "46", NULL },
322 { "47", NULL },
323 { "48", NULL },
324 { "49", NULL },
325 { "50", NULL },
326 { "51", NULL },
327 { "52", NULL },
328 { "53", NULL },
329 { "54", NULL },
330 { "55", NULL },
331 { "56", NULL },
332 { "57", NULL },
333 { "58", NULL },
334 { "59", NULL },
335 { "60", NULL },
336 { "61", NULL },
337 { "62", NULL },
338 { "63", NULL },
339 { "64", NULL },
340 { "65", NULL },
341 { "66", NULL },
342 { "67", NULL },
343 { "68", NULL },
344 { "69", NULL },
345 { "70", NULL },
346 { "71", NULL },
347 { "72", NULL },
348 { "73", NULL },
349 { "74", NULL },
350 { "75", NULL },
351 { "76", NULL },
352 { "77", NULL },
353 { "78", NULL },
354 { "79", NULL },
355 { "80", NULL },
356 { "81", NULL },
357 { "82", NULL },
358 { "83", NULL },
359 { "84", NULL },
360 { "85", NULL },
361 { "86", NULL },
362 { "87", NULL },
363 { "88", NULL },
364 { "89", NULL },
365 { "90", NULL },
366 { "91", NULL },
367 { "92", NULL },
368 { "93", NULL },
369 { "94", NULL },
370 { "95", NULL },
371 { "96", NULL },
372 { "97", NULL },
373 { "98", NULL },
374 { "99", NULL },
919cac88 375 { "100", NULL },
fbe06628 376 { NULL, NULL },
919cac88 377 },
fbe06628 378#ifdef HAVE_PRE_ARMV7
379 "50",
380#else
381 "57",
382#endif
919cac88 383 },
384#endif /* DRC_DISABLE */
385
386#ifdef __ARM_NEON__
387 {
388 "pcsx_rearmed_neon_interlace_enable",
c8108d88 389 "Enable Interlacing Mode",
919cac88 390 "Enables fake scanlines effect.",
391 {
392 { "disabled", NULL },
393 { "enabled", NULL },
fbe06628 394 { NULL, NULL },
919cac88 395 },
396 "disabled",
397 },
398 {
399 "pcsx_rearmed_neon_enhancement_enable",
c8108d88 400 "Enhanced Resolution (Slow)",
ef2683f1 401 "Renders in double resolution at the cost of lower performance.",
919cac88 402 {
403 { "disabled", NULL },
404 { "enabled", NULL },
fbe06628 405 { NULL, NULL },
919cac88 406 },
407 "disabled",
408 },
409 {
410 "pcsx_rearmed_neon_enhancement_no_main",
c8108d88 411 "Enhanced Resolution (Speed Hack)",
919cac88 412 "Speed hack for Enhanced resolution option (glitches some games).",
413 {
414 { "disabled", NULL },
415 { "enabled", NULL },
fbe06628 416 { NULL, NULL },
919cac88 417 },
418 "disabled",
419 },
420#endif /* __ARM_NEON__ */
421
422 {
423 "pcsx_rearmed_duping_enable",
c8108d88 424 "Frame Duping",
919cac88 425 "A speedup, redraws/reuses the last frame if there was no new data.",
426 {
427 { "disabled", NULL },
428 { "enabled", NULL },
fbe06628 429 { NULL, NULL },
919cac88 430 },
431 "enabled",
432 },
433 {
434 "pcsx_rearmed_display_internal_fps",
435 "Display Internal FPS",
436 "Shows an on-screen frames per second counter when enabled.",
437 {
438 { "disabled", NULL },
439 { "enabled", NULL },
fbe06628 440 { NULL, NULL },
919cac88 441 },
442 "disabled",
443 },
c8108d88 444
445 /* GPU PEOPS OPTIONS */
2d17de26 446#ifdef GPU_PEOPS
c8108d88 447 {
448 "pcsx_rearmed_show_gpu_peops_settings",
2d17de26 449 "Advanced GPU P.E.Op.S. Settings",
450 "Shows or hides advanced GPU plugin settings. NOTE: Quick Menu must be toggled for this setting to take effect.",
c8108d88 451 {
452 { "disabled", NULL },
453 { "enabled", NULL },
fbe06628 454 { NULL, NULL },
c8108d88 455 },
456 "disabled",
457 },
458 {
6713b629 459 "pcsx_rearmed_gpu_peops_odd_even_bit",
c8108d88 460 "(GPU) Odd/Even Bit Hack",
461 "Needed for Chrono Cross.",
462 {
463 { "disabled", NULL },
464 { "enabled", NULL },
fbe06628 465 { NULL, NULL },
c8108d88 466 },
467 "disabled",
468 },
469 {
6713b629 470 "pcsx_rearmed_gpu_peops_expand_screen_width",
c8108d88 471 "(GPU) Expand Screen Width",
472 "Capcom fighting games",
473 {
474 { "disabled", NULL },
475 { "enabled", NULL },
fbe06628 476 { NULL, NULL },
c8108d88 477 },
478 "disabled",
479 },
480 {
6713b629 481 "pcsx_rearmed_gpu_peops_ignore_brightness",
c8108d88 482 "(GPU) Ignore Brightness Color",
ef2683f1 483 "Black screens in Lunar Silver Star Story games",
c8108d88 484 {
485 { "disabled", NULL },
486 { "enabled", NULL },
fbe06628 487 { NULL, NULL },
c8108d88 488 },
489 "disabled",
490 },
491 {
6713b629 492 "pcsx_rearmed_gpu_peops_disable_coord_check",
c8108d88 493 "(GPU) Disable Coordinate Check",
494 "Compatibility mode",
495 {
496 { "disabled", NULL },
497 { "enabled", NULL },
fbe06628 498 { NULL, NULL },
c8108d88 499 },
500 "disabled",
501 },
502 {
6713b629 503 "pcsx_rearmed_gpu_peops_lazy_screen_update",
c8108d88 504 "(GPU) Lazy Screen Update",
505 "Pandemonium 2",
506 {
507 { "disabled", NULL },
508 { "enabled", NULL },
fbe06628 509 { NULL, NULL },
c8108d88 510 },
511 "disabled",
512 },
513 {
6713b629 514 "pcsx_rearmed_gpu_peops_old_frame_skip",
c8108d88 515 "(GPU) Old Frame Skipping",
516 "Skip every second frame",
517 {
518 { "disabled", NULL },
519 { "enabled", NULL },
fbe06628 520 { NULL, NULL },
c8108d88 521 },
522 "enabled",
523 },
524 {
6713b629 525 "pcsx_rearmed_gpu_peops_repeated_triangles",
c8108d88 526 "(GPU) Repeated Flat Tex Triangles",
ef2683f1 527 "Needed by Star Wars: Dark Forces",
c8108d88 528 {
529 { "disabled", NULL },
530 { "enabled", NULL },
fbe06628 531 { NULL, NULL },
c8108d88 532 },
533 "disabled",
534 },
535 {
6713b629 536 "pcsx_rearmed_gpu_peops_quads_with_triangles",
c8108d88 537 "(GPU) Draw Quads with Triangles",
538 "Better g-colors, worse textures",
539 {
540 { "disabled", NULL },
541 { "enabled", NULL },
fbe06628 542 { NULL, NULL },
c8108d88 543 },
544 "disabled",
545 },
546 {
6713b629 547 "pcsx_rearmed_gpu_peops_fake_busy_state",
c8108d88 548 "(GPU) Fake 'Gpu Busy' States",
549 "Toggle busy flags after drawing",
550 {
551 { "disabled", NULL },
552 { "enabled", NULL },
fbe06628 553 { NULL, NULL },
c8108d88 554 },
555 "disabled",
556 },
557#endif
558
919cac88 559 {
560 "pcsx_rearmed_show_bios_bootlogo",
561 "Show Bios Bootlogo",
ef2683f1 562 "When enabled, shows the PlayStation logo when starting or resetting. (Breaks some games).",
919cac88 563 {
564 { "disabled", NULL },
565 { "enabled", NULL },
fbe06628 566 { NULL, NULL },
919cac88 567 },
568 "disabled",
569 },
570 {
571 "pcsx_rearmed_spu_reverb",
572 "Sound Reverb",
573 "Enables or disables audio reverb effect.",
574 {
575 { "disabled", NULL },
576 { "enabled", NULL },
fbe06628 577 { NULL, NULL },
919cac88 578 },
579 "enabled",
580 },
581 {
582 "pcsx_rearmed_spu_interpolation",
c8108d88 583 "Sound Interpolation",
919cac88 584 NULL,
585 {
fbe06628 586 { "simple", "Simple" },
587 { "gaussian", "Gaussian" },
588 { "cubic", "Cubic" },
589 { "off", "disabled" },
590 { NULL, NULL },
919cac88 591 },
592 "simple",
593 },
594 {
595 "pcsx_rearmed_idiablofix",
596 "Diablo Music Fix",
597 NULL,
598 {
599 { "disabled", NULL },
600 { "enabled", NULL },
fbe06628 601 { NULL, NULL },
919cac88 602 },
603 "disabled",
604 },
605 {
606 "pcsx_rearmed_pe2_fix",
607 "Parasite Eve 2/Vandal Hearts 1/2 Fix",
608 NULL,
609 {
610 { "disabled", NULL },
611 { "enabled", NULL },
fbe06628 612 { NULL, NULL },
919cac88 613 },
614 "disabled",
615 },
616 {
617 "pcsx_rearmed_inuyasha_fix",
618 "InuYasha Sengoku Battle Fix",
619 NULL,
620 {
621 { "disabled", NULL },
622 { "enabled", NULL },
fbe06628 623 { NULL, NULL },
919cac88 624 },
625 "disabled",
626 },
627
628 /* ADVANCED OPTIONS */
629 {
630 "pcsx_rearmed_noxadecoding",
631 "XA Decoding",
632 NULL,
633 {
634 { "disabled", NULL },
635 { "enabled", NULL },
fbe06628 636 { NULL, NULL },
919cac88 637 },
638 "enabled",
639 },
640 {
641 "pcsx_rearmed_nocdaudio",
642 "CD Audio",
643 NULL,
644 {
645 { "disabled", NULL },
646 { "enabled", NULL },
fbe06628 647 { NULL, NULL },
919cac88 648 },
649 "enabled",
650 },
651
652#ifndef DRC_DISABLE
653 {
654 "pcsx_rearmed_nosmccheck",
655 "(Speed Hack) Disable SMC Checks",
656 "Will cause crashes when loading, break memcards.",
657 {
658 { "disabled", NULL },
659 { "enabled", NULL },
fbe06628 660 { NULL, NULL },
919cac88 661 },
662 "disabled",
663 },
664 {
665 "pcsx_rearmed_gteregsunneeded",
666 "(Speed Hack) Assume GTE Regs Unneeded",
667 "May cause graphical glitches.",
668 {
669 { "disabled", NULL },
670 { "enabled", NULL },
fbe06628 671 { NULL, NULL },
919cac88 672 },
673 "disabled",
674 },
675 {
676 "pcsx_rearmed_nogteflags",
677 "(Speed Hack) Disable GTE Flags",
678 "Will cause graphical glitches.",
679 {
680 { "disabled", NULL },
681 { "enabled", NULL },
38114665
ÖK
682 { NULL, NULL },
683 },
fbe06628 684 "disabled",
38114665
ÖK
685 },
686#endif /* DRC_DISABLE */
687
fbe06628 688 { NULL, NULL, NULL, {{0}}, NULL },
38114665
ÖK
689};
690
919cac88 691/*
692 ********************************
693 * Language Mapping
694 ********************************
695*/
696
fbe06628 697#ifndef HAVE_NO_LANGEXTRA
919cac88 698struct retro_core_option_definition *option_defs_intl[RETRO_LANGUAGE_LAST] = {
699 option_defs_us, /* RETRO_LANGUAGE_ENGLISH */
700 NULL, /* RETRO_LANGUAGE_JAPANESE */
701 NULL, /* RETRO_LANGUAGE_FRENCH */
702 NULL, /* RETRO_LANGUAGE_SPANISH */
703 NULL, /* RETRO_LANGUAGE_GERMAN */
704 NULL, /* RETRO_LANGUAGE_ITALIAN */
705 NULL, /* RETRO_LANGUAGE_DUTCH */
706 NULL, /* RETRO_LANGUAGE_PORTUGUESE_BRAZIL */
707 NULL, /* RETRO_LANGUAGE_PORTUGUESE_PORTUGAL */
708 NULL, /* RETRO_LANGUAGE_RUSSIAN */
709 NULL, /* RETRO_LANGUAGE_KOREAN */
710 NULL, /* RETRO_LANGUAGE_CHINESE_TRADITIONAL */
711 NULL, /* RETRO_LANGUAGE_CHINESE_SIMPLIFIED */
712 NULL, /* RETRO_LANGUAGE_ESPERANTO */
713 NULL, /* RETRO_LANGUAGE_POLISH */
714 NULL, /* RETRO_LANGUAGE_VIETNAMESE */
715 NULL, /* RETRO_LANGUAGE_ARABIC */
716 NULL, /* RETRO_LANGUAGE_GREEK */
fbe06628 717 option_defs_tr, /* RETRO_LANGUAGE_TURKISH */
919cac88 718};
fbe06628 719#endif
919cac88 720
721/*
722 ********************************
723 * Functions
724 ********************************
725*/
726
727/* Handles configuration/setting of core options.
fbe06628 728 * Should be called as early as possible - ideally inside
729 * retro_set_environment(), and no later than retro_load_game()
919cac88 730 * > We place the function body in the header to avoid the
731 * necessity of adding more .c files (i.e. want this to
732 * be as painless as possible for core devs)
733 */
734
735static INLINE void libretro_set_core_options(retro_environment_t environ_cb)
736{
737 unsigned version = 0;
738
739 if (!environ_cb)
740 return;
741
fbe06628 742 if (environ_cb(RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION, &version) && (version >= 1))
919cac88 743 {
fbe06628 744#ifndef HAVE_NO_LANGEXTRA
919cac88 745 struct retro_core_options_intl core_options_intl;
746 unsigned language = 0;
747
748 core_options_intl.us = option_defs_us;
749 core_options_intl.local = NULL;
750
751 if (environ_cb(RETRO_ENVIRONMENT_GET_LANGUAGE, &language) &&
752 (language < RETRO_LANGUAGE_LAST) && (language != RETRO_LANGUAGE_ENGLISH))
753 core_options_intl.local = option_defs_intl[language];
754
755 environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_INTL, &core_options_intl);
fbe06628 756#else
757 environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS, &option_defs_us);
758#endif
919cac88 759 }
760 else
761 {
762 size_t i;
763 size_t option_index = 0;
764 size_t num_options = 0;
765 struct retro_variable *variables = NULL;
766 char **values_buf = NULL;
767
768 /* Determine number of options
769 * > Note: We are going to skip a number of irrelevant
770 * core options when building the retro_variable array,
771 * but we'll allocate space for all of them. The difference
772 * in resource usage is negligible, and this allows us to
773 * keep the code 'cleaner' */
774 while (true)
775 {
776 if (option_defs_us[num_options].key)
777 num_options++;
778 else
779 break;
780 }
781
782 /* Allocate arrays */
783 variables = (struct retro_variable *)calloc(num_options + 1, sizeof(struct retro_variable));
784 values_buf = (char **)calloc(num_options, sizeof(char *));
785
786 if (!variables || !values_buf)
787 goto error;
788
789 /* Copy parameters from option_defs_us array */
790 for (i = 0; i < num_options; i++)
791 {
792 const char *key = option_defs_us[i].key;
793 const char *desc = option_defs_us[i].desc;
794 const char *default_value = option_defs_us[i].default_value;
795 struct retro_core_option_value *values = option_defs_us[i].values;
796 size_t buf_len = 3;
797 size_t default_index = 0;
798
799 values_buf[i] = NULL;
800
801 /* Skip options that are irrelevant when using the
802 * old style core options interface */
c8108d88 803 if ((strcmp(key, "pcsx_rearmed_show_gpu_peops_settings") == 0))
919cac88 804 continue;
805
806 if (desc)
807 {
808 size_t num_values = 0;
809
810 /* Determine number of values */
811 while (true)
812 {
813 if (values[num_values].value)
814 {
815 /* Check if this is the default value */
816 if (default_value)
817 if (strcmp(values[num_values].value, default_value) == 0)
818 default_index = num_values;
819
820 buf_len += strlen(values[num_values].value);
821 num_values++;
822 }
823 else
824 break;
825 }
826
827 /* Build values string */
fbe06628 828 if (num_values > 0)
919cac88 829 {
830 size_t j;
831
832 buf_len += num_values - 1;
833 buf_len += strlen(desc);
834
835 values_buf[i] = (char *)calloc(buf_len, sizeof(char));
836 if (!values_buf[i])
837 goto error;
838
839 strcpy(values_buf[i], desc);
840 strcat(values_buf[i], "; ");
841
842 /* Default value goes first */
843 strcat(values_buf[i], values[default_index].value);
844
845 /* Add remaining values */
846 for (j = 0; j < num_values; j++)
847 {
848 if (j != default_index)
849 {
850 strcat(values_buf[i], "|");
851 strcat(values_buf[i], values[j].value);
852 }
853 }
854 }
855 }
856
857 variables[option_index].key = key;
858 variables[option_index].value = values_buf[i];
859 option_index++;
860 }
861
862 /* Set variables */
863 environ_cb(RETRO_ENVIRONMENT_SET_VARIABLES, variables);
864
865error:
866
867 /* Clean up */
868 if (values_buf)
869 {
870 for (i = 0; i < num_options; i++)
871 {
872 if (values_buf[i])
873 {
874 free(values_buf[i]);
875 values_buf[i] = NULL;
876 }
877 }
878
879 free(values_buf);
880 values_buf = NULL;
881 }
882
883 if (variables)
884 {
885 free(variables);
886 variables = NULL;
887 }
888 }
889}
890
891#ifdef __cplusplus
892}
893#endif
894
895#endif