static int action_iterate_help(char *s, size_t len, const char *label) { unsigned i; static const unsigned binds[] = { RETRO_DEVICE_ID_JOYPAD_UP, RETRO_DEVICE_ID_JOYPAD_DOWN, RETRO_DEVICE_ID_JOYPAD_A, RETRO_DEVICE_ID_JOYPAD_B, RETRO_DEVICE_ID_JOYPAD_SELECT, RARCH_MENU_TOGGLE, RARCH_QUIT_KEY, RETRO_DEVICE_ID_JOYPAD_X, RETRO_DEVICE_ID_JOYPAD_Y, }; char desc[ARRAY_SIZE(binds)][64] = {{0}}; settings_t *settings = config_get_ptr(); menu_driver_render(); for (i = 0; i < ARRAY_SIZE(binds); i++) { const struct retro_keybind *keybind = (const struct retro_keybind*) &settings->input.binds[0][binds[i]]; const struct retro_keybind *auto_bind = (const struct retro_keybind*) input_get_auto_bind(0, binds[i]); input_get_bind_string(desc[i], keybind, auto_bind, sizeof(desc[i])); } snprintf(s, len, "Welcome to RetroArch\n" " \n" /* strtok_r doesn't split empty strings. */ "Basic Menu controls:\n" " Scroll (Up): %-20s\n" " Scroll (Down): %-20s\n" " Accept/OK: %-20s\n" " Back: %-20s\n" " Info: %-20s\n" "Enter/Exit Menu: %-20s\n" " Exit RetroArch: %-20s\n" "Toggle Keyboard: %-20s\n" " \n" "To run content:\n" "Load a libretro core (Core).\n" "Load a content file (Load Content). \n" " \n" "See Path Settings to set directories \n" "for faster access to files.\n" " \n" "Press Accept/OK to continue.", desc[0], desc[1], desc[2], desc[3], desc[4], desc[5], desc[6], desc[7]); return 0; }
static int action_iterate_help(char *s, size_t len, const char *label) { unsigned i; menu_handle_t *menu = menu_driver_get_ptr(); settings_t *settings = config_get_ptr(); switch (menu->help_screen_type) { case MENU_HELP_WELCOME: { static int64_t timeout_end; int64_t timeout; static bool timer_begin = false; static bool timer_end = false; int64_t current = retro_get_time_usec(); if (!timer_begin) { timeout_end = retro_get_time_usec() + 3 /* seconds */ * 1000000; timer_begin = true; timer_end = false; } timeout = (timeout_end - current) / 1000000; menu_hash_get_help(MENU_LABEL_WELCOME_TO_RETROARCH, s, len); if (!timer_end && timeout <= 0) { timer_end = true; timer_begin = false; timeout_end = 0; menu->help_screen_type = MENU_HELP_NONE; return 1; } } break; case MENU_HELP_CONTROLS: { char s2[PATH_MAX_LENGTH]; const unsigned binds[] = { RETRO_DEVICE_ID_JOYPAD_UP, RETRO_DEVICE_ID_JOYPAD_DOWN, RETRO_DEVICE_ID_JOYPAD_A, RETRO_DEVICE_ID_JOYPAD_B, RETRO_DEVICE_ID_JOYPAD_SELECT, RETRO_DEVICE_ID_JOYPAD_START, RARCH_MENU_TOGGLE, RARCH_QUIT_KEY, RETRO_DEVICE_ID_JOYPAD_X, RETRO_DEVICE_ID_JOYPAD_Y, }; char desc[ARRAY_SIZE(binds)][64] = {{0}}; for (i = 0; i < ARRAY_SIZE(binds); i++) { const struct retro_keybind *keybind = (const struct retro_keybind*) &settings->input.binds[0][binds[i]]; const struct retro_keybind *auto_bind = (const struct retro_keybind*) input_get_auto_bind(0, binds[i]); input_get_bind_string(desc[i], keybind, auto_bind, sizeof(desc[i])); } menu_hash_get_help(MENU_LABEL_VALUE_MENU_CONTROLS_PROLOG, s2, sizeof(s2)); snprintf(s, len, "%s" "[%s]: " "%-20s\n" "[%s]: " "%-20s\n" "[%s]: " "%-20s\n" "[%s]: " "%-20s\n" "[%s]: " "%-20s\n" "[%s]: " "%-20s\n" "[%s]: " "%-20s\n" "[%s]: " "%-20s\n" "[%s]: " "%-20s\n", s2, menu_hash_to_str(MENU_LABEL_VALUE_BASIC_MENU_CONTROLS_SCROLL_UP), desc[0], menu_hash_to_str(MENU_LABEL_VALUE_BASIC_MENU_CONTROLS_SCROLL_DOWN), desc[1], menu_hash_to_str(MENU_LABEL_VALUE_BASIC_MENU_CONTROLS_CONFIRM), desc[2], menu_hash_to_str(MENU_LABEL_VALUE_BASIC_MENU_CONTROLS_BACK), desc[3], menu_hash_to_str(MENU_LABEL_VALUE_BASIC_MENU_CONTROLS_INFO), desc[4], menu_hash_to_str(MENU_LABEL_VALUE_BASIC_MENU_CONTROLS_START), desc[5], menu_hash_to_str(MENU_LABEL_VALUE_BASIC_MENU_CONTROLS_TOGGLE_MENU), desc[6], menu_hash_to_str(MENU_LABEL_VALUE_BASIC_MENU_CONTROLS_QUIT), desc[7], menu_hash_to_str(MENU_LABEL_VALUE_BASIC_MENU_CONTROLS_TOGGLE_KEYBOARD), desc[8] ); } break; case MENU_HELP_WHAT_IS_A_CORE: menu_hash_get_help(MENU_LABEL_VALUE_WHAT_IS_A_CORE_DESC, s, len); break; case MENU_HELP_LOADING_CONTENT: menu_hash_get_help(MENU_LABEL_LOAD_CONTENT, s, len); break; case MENU_HELP_CHANGE_VIRTUAL_GAMEPAD: menu_hash_get_help(MENU_LABEL_VALUE_HELP_CHANGE_VIRTUAL_GAMEPAD_DESC, s, len); break; case MENU_HELP_AUDIO_VIDEO_TROUBLESHOOTING: menu_hash_get_help(MENU_LABEL_VALUE_HELP_AUDIO_VIDEO_TROUBLESHOOTING_DESC, s, len); break; case MENU_HELP_SCANNING_CONTENT: menu_hash_get_help(MENU_LABEL_VALUE_HELP_SCANNING_CONTENT_DESC, s, len); break; case MENU_HELP_EXTRACT: menu_hash_get_help(MENU_LABEL_VALUE_EXTRACTING_PLEASE_WAIT, s, len); break; case MENU_HELP_NONE: default: break; } return 0; }
static int action_iterate_help(const char *label, unsigned action) { unsigned i; static const unsigned binds[] = { RETRO_DEVICE_ID_JOYPAD_UP, RETRO_DEVICE_ID_JOYPAD_DOWN, RETRO_DEVICE_ID_JOYPAD_A, RETRO_DEVICE_ID_JOYPAD_B, RETRO_DEVICE_ID_JOYPAD_SELECT, RARCH_MENU_TOGGLE, RARCH_QUIT_KEY, RETRO_DEVICE_ID_JOYPAD_X, }; char desc[ARRAY_SIZE(binds)][64]; char msg[PATH_MAX_LENGTH]; menu_handle_t *menu = menu_driver_get_ptr(); settings_t *settings = config_get_ptr(); if (!menu) return 0; menu_driver_render(); for (i = 0; i < ARRAY_SIZE(binds); i++) { const struct retro_keybind *keybind = (const struct retro_keybind*) &settings->input.binds[0][binds[i]]; const struct retro_keybind *auto_bind = (const struct retro_keybind*) input_get_auto_bind(0, binds[i]); input_get_bind_string(desc[i], keybind, auto_bind, sizeof(desc[i])); } snprintf(msg, sizeof(msg), "-- Welcome to RetroArch --\n" " \n" // strtok_r doesn't split empty strings. "Basic Menu controls:\n" " Scroll (Up): %-20s\n" " Scroll (Down): %-20s\n" " Accept/OK: %-20s\n" " Back: %-20s\n" " Info: %-20s\n" "Enter/Exit Menu: %-20s\n" " Exit RetroArch: %-20s\n" "Toggle Keyboard: %-20s\n" " \n" "To run content:\n" "Load a libretro core (Core).\n" "Load a content file (Load Content). \n" " \n" "See Path Settings to set directories for faster access to files.\n" " \n" "Press Accept/OK to continue.", desc[0], desc[1], desc[2], desc[3], desc[4], desc[5], desc[6], desc[7]); menu_driver_render_messagebox(msg); if (action == MENU_ACTION_OK) menu_list_pop(menu->menu_list->menu_stack, NULL); return 0; }
static int menu_start_screen_iterate(unsigned action) { unsigned i; char msg[1024]; if (!driver.menu) return 0; if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render) driver.menu_ctx->render(); static const unsigned binds[] = { RETRO_DEVICE_ID_JOYPAD_UP, RETRO_DEVICE_ID_JOYPAD_DOWN, RETRO_DEVICE_ID_JOYPAD_A, RETRO_DEVICE_ID_JOYPAD_B, RETRO_DEVICE_ID_JOYPAD_SELECT, RARCH_MENU_TOGGLE, RARCH_QUIT_KEY, }; char desc[ARRAY_SIZE(binds)][64]; for (i = 0; i < ARRAY_SIZE(binds); i++) { const struct retro_keybind *bind = (const struct retro_keybind*) &g_settings.input.binds[0][binds[i]]; const struct retro_keybind *auto_bind = (const struct retro_keybind*) input_get_auto_bind(0, binds[i]); input_get_bind_string(desc[i], bind, auto_bind, sizeof(desc[i])); } snprintf(msg, sizeof(msg), "-- Welcome to RetroArch --\n" " \n" // strtok_r doesn't split empty strings. "Basic Menu controls:\n" " Scroll (Up): %-20s\n" " Scroll (Down): %-20s\n" " Accept/OK: %-20s\n" " Back: %-20s\n" " Info: %-20s\n" "Enter/Exit Menu: %-20s\n" " Exit RetroArch: %-20s\n" " \n" "To run content:\n" "Load a libretro core (Core).\n" "Load a content file (Load Content). \n" " \n" "See Path Options to set directories\n" "for faster access to files.\n" " \n" "Press Accept/OK to continue.", desc[0], desc[1], desc[2], desc[3], desc[4], desc[5], desc[6]); if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render_messagebox) driver.menu_ctx->render_messagebox(msg); if (action == MENU_ACTION_OK) menu_entries_pop(driver.menu->menu_stack); return 0; }
void menu_set_settings_label(char *type_str, size_t type_str_size, unsigned *w, unsigned type) { switch (type) { case RGUI_SETTINGS_VIDEO_ROTATION: strlcpy(type_str, rotation_lut[g_settings.video.rotation], type_str_size); break; case RGUI_SETTINGS_VIDEO_SOFT_FILTER: snprintf(type_str, type_str_size, (g_extern.lifecycle_mode_state & (1ULL << MODE_VIDEO_SOFT_FILTER_ENABLE)) ? "ON" : "OFF"); break; case RGUI_SETTINGS_VIDEO_FILTER: if (g_settings.video.smooth) strlcpy(type_str, "Bilinear filtering", type_str_size); else strlcpy(type_str, "Point filtering", type_str_size); break; case RGUI_SETTINGS_VIDEO_GAMMA: snprintf(type_str, type_str_size, "%d", g_extern.console.screen.gamma_correction); break; case RGUI_SETTINGS_VIDEO_VSYNC: strlcpy(type_str, g_settings.video.vsync ? "ON" : "OFF", type_str_size); break; case RGUI_SETTINGS_VIDEO_HARD_SYNC: strlcpy(type_str, g_settings.video.hard_sync ? "ON" : "OFF", type_str_size); break; case RGUI_SETTINGS_VIDEO_BLACK_FRAME_INSERTION: strlcpy(type_str, g_settings.video.black_frame_insertion ? "ON" : "OFF", type_str_size); break; case RGUI_SETTINGS_VIDEO_SWAP_INTERVAL: snprintf(type_str, type_str_size, "%u", g_settings.video.swap_interval); break; case RGUI_SETTINGS_VIDEO_THREADED: strlcpy(type_str, g_settings.video.threaded ? "ON" : "OFF", type_str_size); break; case RGUI_SETTINGS_VIDEO_WINDOW_SCALE_X: snprintf(type_str, type_str_size, "%.1fx", g_settings.video.xscale); break; case RGUI_SETTINGS_VIDEO_WINDOW_SCALE_Y: snprintf(type_str, type_str_size, "%.1fx", g_settings.video.yscale); break; case RGUI_SETTINGS_VIDEO_CROP_OVERSCAN: strlcpy(type_str, g_settings.video.crop_overscan ? "ON" : "OFF", type_str_size); break; case RGUI_SETTINGS_VIDEO_HARD_SYNC_FRAMES: snprintf(type_str, type_str_size, "%u", g_settings.video.hard_sync_frames); break; case RGUI_SETTINGS_VIDEO_REFRESH_RATE_AUTO: { double refresh_rate = 0.0; double deviation = 0.0; unsigned sample_points = 0; if (driver_monitor_fps_statistics(&refresh_rate, &deviation, &sample_points)) snprintf(type_str, type_str_size, "%.3f Hz (%.1f%% dev, %u samples)", refresh_rate, 100.0 * deviation, sample_points); else strlcpy(type_str, "N/A", type_str_size); break; } case RGUI_SETTINGS_VIDEO_INTEGER_SCALE: strlcpy(type_str, g_settings.video.scale_integer ? "ON" : "OFF", type_str_size); break; case RGUI_SETTINGS_VIDEO_ASPECT_RATIO: strlcpy(type_str, aspectratio_lut[g_settings.video.aspect_ratio_idx].name, type_str_size); break; #if defined(GEKKO) case RGUI_SETTINGS_VIDEO_RESOLUTION: strlcpy(type_str, gx_get_video_mode(), type_str_size); break; #elif defined(__CELLOS_LV2__) case RGUI_SETTINGS_VIDEO_RESOLUTION: { unsigned width = gfx_ctx_get_resolution_width(g_extern.console.screen.resolutions.list[g_extern.console.screen.resolutions.current.idx]); unsigned height = gfx_ctx_get_resolution_height(g_extern.console.screen.resolutions.list[g_extern.console.screen.resolutions.current.idx]); snprintf(type_str, type_str_size, "%dx%d", width, height); } break; #endif case RGUI_FILE_PLAIN: strlcpy(type_str, "(FILE)", type_str_size); *w = 6; break; case RGUI_FILE_DIRECTORY: strlcpy(type_str, "(DIR)", type_str_size); *w = 5; break; case RGUI_SETTINGS_REWIND_ENABLE: strlcpy(type_str, g_settings.rewind_enable ? "ON" : "OFF", type_str_size); break; #ifdef HAVE_SCREENSHOTS case RGUI_SETTINGS_GPU_SCREENSHOT: strlcpy(type_str, g_settings.video.gpu_screenshot ? "ON" : "OFF", type_str_size); break; #endif case RGUI_SETTINGS_REWIND_GRANULARITY: snprintf(type_str, type_str_size, "%u", g_settings.rewind_granularity); break; case RGUI_SETTINGS_CONFIG_SAVE_ON_EXIT: strlcpy(type_str, g_extern.config_save_on_exit ? "ON" : "OFF", type_str_size); break; case RGUI_SETTINGS_SRAM_AUTOSAVE: strlcpy(type_str, g_settings.autosave_interval ? "ON" : "OFF", type_str_size); break; case RGUI_SETTINGS_SAVESTATE_SAVE: case RGUI_SETTINGS_SAVESTATE_LOAD: snprintf(type_str, type_str_size, "%d", g_extern.state_slot); break; case RGUI_SETTINGS_AUDIO_MUTE: strlcpy(type_str, g_extern.audio_data.mute ? "ON" : "OFF", type_str_size); break; case RGUI_SETTINGS_AUDIO_CONTROL_RATE_DELTA: snprintf(type_str, type_str_size, "%.3f", g_settings.audio.rate_control_delta); break; case RGUI_SETTINGS_DEBUG_TEXT: snprintf(type_str, type_str_size, (g_settings.fps_show) ? "ON" : "OFF"); break; case RGUI_BROWSER_DIR_PATH: strlcpy(type_str, *g_settings.rgui_browser_directory ? g_settings.rgui_browser_directory : "<default>", type_str_size); break; #ifdef HAVE_SCREENSHOTS case RGUI_SCREENSHOT_DIR_PATH: strlcpy(type_str, *g_settings.screenshot_directory ? g_settings.screenshot_directory : "<ROM dir>", type_str_size); break; #endif case RGUI_SAVEFILE_DIR_PATH: strlcpy(type_str, *g_extern.savefile_dir ? g_extern.savefile_dir : "<ROM dir>", type_str_size); break; #ifdef HAVE_OVERLAY case RGUI_OVERLAY_DIR_PATH: strlcpy(type_str, *g_extern.overlay_dir ? g_extern.overlay_dir : "<default>", type_str_size); break; #endif case RGUI_SAVESTATE_DIR_PATH: strlcpy(type_str, *g_extern.savestate_dir ? g_extern.savestate_dir : "<ROM dir>", type_str_size); break; #ifdef HAVE_DYNAMIC case RGUI_LIBRETRO_DIR_PATH: strlcpy(type_str, *rgui->libretro_dir ? rgui->libretro_dir : "<None>", type_str_size); break; #endif case RGUI_LIBRETRO_INFO_DIR_PATH: strlcpy(type_str, *g_settings.libretro_info_path ? g_settings.libretro_info_path : "<Core dir>", type_str_size); break; case RGUI_CONFIG_DIR_PATH: strlcpy(type_str, *g_settings.rgui_config_directory ? g_settings.rgui_config_directory : "<default>", type_str_size); break; case RGUI_SHADER_DIR_PATH: strlcpy(type_str, *g_settings.video.shader_dir ? g_settings.video.shader_dir : "<default>", type_str_size); break; case RGUI_SYSTEM_DIR_PATH: strlcpy(type_str, *g_settings.system_directory ? g_settings.system_directory : "<ROM dir>", type_str_size); break; case RGUI_SETTINGS_DISK_INDEX: { const struct retro_disk_control_callback *control = &g_extern.system.disk_control; unsigned images = control->get_num_images(); unsigned current = control->get_image_index(); if (current >= images) strlcpy(type_str, "No Disk", type_str_size); else snprintf(type_str, type_str_size, "%u", current + 1); break; } case RGUI_SETTINGS_CONFIG: if (*g_extern.config_path) fill_pathname_base(type_str, g_extern.config_path, type_str_size); else strlcpy(type_str, "<default>", type_str_size); break; case RGUI_SETTINGS_OPEN_FILEBROWSER: case RGUI_SETTINGS_OPEN_FILEBROWSER_DEFERRED_CORE: case RGUI_SETTINGS_OPEN_HISTORY: case RGUI_SETTINGS_CORE_OPTIONS: case RGUI_SETTINGS_CUSTOM_VIEWPORT: case RGUI_SETTINGS_TOGGLE_FULLSCREEN: case RGUI_SETTINGS_VIDEO_OPTIONS: case RGUI_SETTINGS_AUDIO_OPTIONS: case RGUI_SETTINGS_DISK_OPTIONS: case RGUI_SETTINGS_SAVE_CONFIG: #ifdef HAVE_SHADER_MANAGER case RGUI_SETTINGS_SHADER_OPTIONS: case RGUI_SETTINGS_SHADER_PRESET: #endif case RGUI_SETTINGS_CORE: case RGUI_SETTINGS_DISK_APPEND: case RGUI_SETTINGS_INPUT_OPTIONS: case RGUI_SETTINGS_PATH_OPTIONS: case RGUI_SETTINGS_OPTIONS: case RGUI_SETTINGS_CUSTOM_BIND_ALL: case RGUI_SETTINGS_CUSTOM_BIND_DEFAULT_ALL: case RGUI_START_SCREEN: strlcpy(type_str, "...", type_str_size); break; #ifdef HAVE_OVERLAY case RGUI_SETTINGS_OVERLAY_PRESET: strlcpy(type_str, path_basename(g_settings.input.overlay), type_str_size); break; case RGUI_SETTINGS_OVERLAY_OPACITY: { snprintf(type_str, type_str_size, "%.2f", g_settings.input.overlay_opacity); break; } case RGUI_SETTINGS_OVERLAY_SCALE: { snprintf(type_str, type_str_size, "%.2f", g_settings.input.overlay_scale); break; } #endif case RGUI_SETTINGS_BIND_PLAYER: { snprintf(type_str, type_str_size, "#%d", rgui->current_pad + 1); break; } case RGUI_SETTINGS_BIND_DEVICE: { int map = g_settings.input.joypad_map[rgui->current_pad]; if (map >= 0 && map < MAX_PLAYERS) { const char *device_name = g_settings.input.device_names[map]; if (*device_name) strlcpy(type_str, device_name, type_str_size); else snprintf(type_str, type_str_size, "N/A (port #%u)", map); } else strlcpy(type_str, "Disabled", type_str_size); break; } case RGUI_SETTINGS_BIND_DEVICE_TYPE: { const char *name; switch (g_settings.input.libretro_device[rgui->current_pad]) { case RETRO_DEVICE_NONE: name = "None"; break; case RETRO_DEVICE_JOYPAD: name = "Joypad"; break; case RETRO_DEVICE_ANALOG: name = "Joypad w/ Analog"; break; case RETRO_DEVICE_JOYPAD_MULTITAP: name = "Multitap"; break; case RETRO_DEVICE_MOUSE: name = "Mouse"; break; case RETRO_DEVICE_LIGHTGUN_JUSTIFIER: name = "Justifier"; break; case RETRO_DEVICE_LIGHTGUN_JUSTIFIERS: name = "Justifiers"; break; case RETRO_DEVICE_LIGHTGUN_SUPER_SCOPE: name = "SuperScope"; break; default: name = "Unknown"; break; } strlcpy(type_str, name, type_str_size); break; } case RGUI_SETTINGS_BIND_UP: case RGUI_SETTINGS_BIND_DOWN: case RGUI_SETTINGS_BIND_LEFT: case RGUI_SETTINGS_BIND_RIGHT: case RGUI_SETTINGS_BIND_A: case RGUI_SETTINGS_BIND_B: case RGUI_SETTINGS_BIND_X: case RGUI_SETTINGS_BIND_Y: case RGUI_SETTINGS_BIND_START: case RGUI_SETTINGS_BIND_SELECT: case RGUI_SETTINGS_BIND_L: case RGUI_SETTINGS_BIND_R: case RGUI_SETTINGS_BIND_L2: case RGUI_SETTINGS_BIND_R2: case RGUI_SETTINGS_BIND_L3: case RGUI_SETTINGS_BIND_R3: case RGUI_SETTINGS_BIND_ANALOG_LEFT_X_PLUS: case RGUI_SETTINGS_BIND_ANALOG_LEFT_X_MINUS: case RGUI_SETTINGS_BIND_ANALOG_LEFT_Y_PLUS: case RGUI_SETTINGS_BIND_ANALOG_LEFT_Y_MINUS: case RGUI_SETTINGS_BIND_ANALOG_RIGHT_X_PLUS: case RGUI_SETTINGS_BIND_ANALOG_RIGHT_X_MINUS: case RGUI_SETTINGS_BIND_ANALOG_RIGHT_Y_PLUS: case RGUI_SETTINGS_BIND_ANALOG_RIGHT_Y_MINUS: case RGUI_SETTINGS_BIND_MENU_TOGGLE: { unsigned id = type - RGUI_SETTINGS_BIND_B; struct platform_bind key_label; strlcpy(key_label.desc, "Unknown", sizeof(key_label.desc)); key_label.joykey = g_settings.input.binds[rgui->current_pad][id].joykey; if (driver.input->set_keybinds) { driver.input->set_keybinds(&key_label, 0, 0, 0, (1ULL << KEYBINDS_ACTION_GET_BIND_LABEL)); strlcpy(type_str, key_label.desc, type_str_size); } else { const struct retro_keybind *bind = &g_settings.input.binds[rgui->current_pad][type - RGUI_SETTINGS_BIND_BEGIN]; input_get_bind_string(type_str, bind, type_str_size); } break; } default: type_str[0] = 0; w = 0; break; } }