void rarch_input_set_default_keybind_names_for_emulator(void) { struct retro_system_info info; #ifdef ANDROID pretro_get_system_info(&info); #else retro_get_system_info(&info); #endif const char *id = info.library_name ? info.library_name : "Unknown"; // Genesis Plus GX/Next if (strstr(id, "Genesis Plus GX")) { strlcpy(rarch_default_libretro_keybind_name_lut[RETRO_DEVICE_ID_JOYPAD_B], "B button", sizeof(rarch_default_libretro_keybind_name_lut[RETRO_DEVICE_ID_JOYPAD_B])); strlcpy(rarch_default_libretro_keybind_name_lut[RETRO_DEVICE_ID_JOYPAD_A], "C button", sizeof(rarch_default_libretro_keybind_name_lut[RETRO_DEVICE_ID_JOYPAD_A])); strlcpy(rarch_default_libretro_keybind_name_lut[RETRO_DEVICE_ID_JOYPAD_X], "Y button", sizeof(rarch_default_libretro_keybind_name_lut[RETRO_DEVICE_ID_JOYPAD_X])); strlcpy(rarch_default_libretro_keybind_name_lut[RETRO_DEVICE_ID_JOYPAD_Y], "A button", sizeof(rarch_default_libretro_keybind_name_lut[RETRO_DEVICE_ID_JOYPAD_Y])); strlcpy(rarch_default_libretro_keybind_name_lut[RETRO_DEVICE_ID_JOYPAD_L], "X button", sizeof(rarch_default_libretro_keybind_name_lut[RETRO_DEVICE_ID_JOYPAD_L])); strlcpy(rarch_default_libretro_keybind_name_lut[RETRO_DEVICE_ID_JOYPAD_R], "Z button", sizeof(rarch_default_libretro_keybind_name_lut[RETRO_DEVICE_ID_JOYPAD_R])); strlcpy(rarch_default_libretro_keybind_name_lut[RETRO_DEVICE_ID_JOYPAD_SELECT], "Mode button", sizeof(rarch_default_libretro_keybind_name_lut[RETRO_DEVICE_ID_JOYPAD_SELECT])); } }
void rarch_console_name_from_id(char *name, size_t size) { if (size == 0) return; struct retro_system_info info; #ifdef ANDROID pretro_get_system_info(&info); #else retro_get_system_info(&info); #endif const char *id = info.library_name ? info.library_name : "Unknown"; if (!id || strlen(id) >= size) { name[0] = '\0'; return; } name[strlen(id)] = '\0'; for (size_t i = 0; id[i] != '\0'; i++) { char c = id[i]; if (isspace(c) || isblank(c)) name[i] = '_'; else name[i] = tolower(c); } }
static bool libretro_get_system_info_static(struct retro_system_info *info, bool *load_no_content) { struct retro_system_info dummy_info = {0}; if (load_no_content) { load_no_content_hook = load_no_content; /* load_no_content gets set in this callback. */ retro_set_environment(environ_cb_get_system_info); /* It's possible that we just set get_system_info callback * to the currently running core. * * Make sure we reset it to the actual environment callback. * Ignore any environment callbacks here in case we're running * on the non-current core. */ ignore_environment_cb = true; retro_set_environment(rarch_environment_cb); ignore_environment_cb = false; } retro_get_system_info(&dummy_info); memcpy(info, &dummy_info, sizeof(*info)); info->library_name = strdup(dummy_info.library_name); info->library_version = strdup(dummy_info.library_version); if (dummy_info.valid_extensions) info->valid_extensions = strdup(dummy_info.valid_extensions); return true; }
HRESULT CRetroArchMain::OnInit(XUIMessageInit * pInitData, BOOL& bHandled) { struct retro_system_info info; retro_get_system_info(&info); const char *id = info.library_name ? info.library_name : "Unknown"; GetChildById(L"XuiLogo", &m_logoimage); GetChildById(L"XuiBtnRomBrowser", &m_filebrowser); GetChildById(L"XuiBtnSettings", &m_settings); GetChildById(L"XuiBtnQuickMenu", &m_quick_menu); GetChildById(L"XuiBtnControls", &m_controls); GetChildById(L"XuiBtnQuit", &m_quit); GetChildById(L"XuiTxtTitle", &m_title); GetChildById(L"XuiTxtCoreText", &m_core); GetChildById(L"XuiBtnLibretroCore", &m_change_libretro_core); char core_text[256]; snprintf(core_text, sizeof(core_text), "%s %s", id, info.library_version); convert_char_to_wchar(strw_buffer, core_text, sizeof(strw_buffer)); m_core.SetText(strw_buffer); rarch_settings_create_menu_item_label_w(strw_buffer, S_LBL_RARCH_VERSION, sizeof(strw_buffer)); m_title.SetText(strw_buffer); g_extern.console.rmenu.input_loop = INPUT_LOOP_NONE; return 0; }
HRESULT CRetroArchMain::OnInit(XUIMessageInit * pInitData, BOOL& bHandled) { struct retro_system_info info; retro_get_system_info(&info); const char *id = info.library_name ? info.library_name : "Unknown"; GetChildById(L"XuiBtnRomBrowser", &m_filebrowser); GetChildById(L"XuiBtnSettings", &m_settings); GetChildById(L"XuiBtnQuickMenu", &m_quick_menu); GetChildById(L"XuiBtnControls", &m_controls); GetChildById(L"XuiBtnQuit", &m_quit); GetChildById(L"XuiTxtTitle", &m_title); GetChildById(L"XuiTxtCoreText", &m_core); GetChildById(L"XuiBtnLibsnesCore", &m_change_libretro_core); char core_text[256]; sprintf(core_text, "%s (v%s)", id, info.library_version); char package_version[32]; sprintf(package_version, "RetroArch %s", PACKAGE_VERSION); unsigned long dwNum = MultiByteToWideChar(CP_ACP, 0, core_text, -1, NULL, 0); unsigned long dwNum_package = MultiByteToWideChar(CP_ACP, 0, package_version, -1, NULL, 0); wchar_t * core_text_utf = new wchar_t[dwNum]; wchar_t * package_version_utf = new wchar_t[dwNum_package]; MultiByteToWideChar(CP_ACP, 0, core_text, -1, core_text_utf, dwNum); MultiByteToWideChar(CP_ACP, 0, package_version, -1, package_version_utf, dwNum_package); m_core.SetText(core_text_utf); m_title.SetText(package_version_utf); delete []core_text_utf; delete []package_version_utf; return S_OK; }
// Transforms a library id to a name suitable as a pathname. static void get_libretro_core_name(char *name, size_t size) { if (size == 0) return; struct retro_system_info info; retro_get_system_info(&info); const char *id = info.library_name ? info.library_name : "Unknown"; if (!id || strlen(id) >= size) { name[0] = '\0'; return; } name[strlen(id)] = '\0'; for (size_t i = 0; id[i] != '\0'; i++) { char c = id[i]; if (isspace(c) || isblank(c)) name[i] = '_'; else name[i] = tolower(c); } }
HRESULT CRetroArchFileBrowser::OnNotifyPress( HXUIOBJ hObjPressed, BOOL& bHandled ) { char path[MAX_PATH_LENGTH]; if(hObjPressed == m_romlist) { int index = m_romlist.GetCurSel(); if(browser.cur[index].d_type != FILE_ATTRIBUTE_DIRECTORY) { struct retro_system_info info; retro_get_system_info(&info); bool block_zip_extract = info.block_extract; memset(strbuffer, 0, sizeof(strbuffer)); wcstombs(strbuffer, (const wchar_t *)m_romlist.GetText(index), sizeof(strbuffer)); if((strstr(strbuffer, ".zip") || strstr(strbuffer, ".ZIP")) && !block_zip_extract) { char path_tmp[1024]; sprintf(path_tmp, "%s\\%s", FILEBROWSER_GET_CURRENT_DIRECTORY_NAME(browser), strbuffer); rarch_extract_zipfile(path_tmp); } else { memset(g_console.rom_path, 0, sizeof(g_console.rom_path)); sprintf(g_console.rom_path, "%s\\%s", FILEBROWSER_GET_CURRENT_DIRECTORY_NAME(browser), strbuffer); return_to_game(); g_console.initialize_rarch_enable = 1; } } else if(browser.cur[index].d_type == FILE_ATTRIBUTE_DIRECTORY) { memset(strbuffer, 0, sizeof(strbuffer)); wcstombs(strbuffer, (const wchar_t *)m_romlist.GetText(index), sizeof(strbuffer)); snprintf(path, sizeof(path), "%s\\%s", FILEBROWSER_GET_CURRENT_DIRECTORY_NAME(browser), strbuffer); filebrowser_fetch_directory_entries(path, &browser, &m_romlist, &m_rompathtitle); } } else if (hObjPressed == m_dir_game) { filebrowser_new(&browser, g_console.default_rom_startup_dir, rarch_console_get_rom_ext()); filebrowser_fetch_directory_entries(g_console.default_rom_startup_dir, &browser, &m_romlist, &m_rompathtitle); } else if (hObjPressed == m_dir_cache) { filebrowser_new(&browser, "cache:", rarch_console_get_rom_ext()); filebrowser_fetch_directory_entries("cache:", &browser, &m_romlist, &m_rompathtitle); } else if(hObjPressed == m_back) NavigateBack(app.hMainScene); bHandled = TRUE; return S_OK; }
HRESULT CRetroArchFileBrowser::OnNotifyPress( HXUIOBJ hObjPressed, BOOL& bHandled ) { char path[PATH_MAX]; if(hObjPressed == m_romlist) { int index = m_romlist.GetCurSel(); if(path_file_exists(browser.current_dir.list->elems[index].data)) { struct retro_system_info info; retro_get_system_info(&info); bool block_zip_extract = info.block_extract; const char * strbuffer = rarch_convert_wchar_to_const_char((const wchar_t*)m_romlist.GetText(index)); if((strstr(strbuffer, ".zip") || strstr(strbuffer, ".ZIP")) && !block_zip_extract) { char path_tmp[1024]; snprintf(path_tmp, sizeof(path_tmp), "%s\\%s", filebrowser_get_current_dir(&browser), strbuffer); rarch_extract_zipfile(path_tmp); } else { memset(g_console.rom_path, 0, sizeof(g_console.rom_path)); snprintf(g_console.rom_path, sizeof(g_console.rom_path), "%s\\%s", filebrowser_get_current_dir(&browser), strbuffer); rarch_settings_change(S_START_RARCH); } } else if(browser.current_dir.list->elems[index].attr.b) { const char * strbuffer = rarch_convert_wchar_to_const_char((const wchar_t *)m_romlist.GetText(index)); snprintf(path, sizeof(path), "%s\\%s", filebrowser_get_current_dir(&browser), strbuffer); filebrowser_fetch_directory_entries(path, &browser, &m_romlist, &m_rompathtitle); } } else if (hObjPressed == m_dir_game) { filebrowser_new(&browser, g_console.default_rom_startup_dir, rarch_console_get_rom_ext()); filebrowser_fetch_directory_entries(g_console.default_rom_startup_dir, &browser, &m_romlist, &m_rompathtitle); } else if (hObjPressed == m_dir_cache) { filebrowser_new(&browser, "cache:", rarch_console_get_rom_ext()); filebrowser_fetch_directory_entries("cache:", &browser, &m_romlist, &m_rompathtitle); if (g_console.info_msg_enable) rarch_settings_msg(S_MSG_CACHE_PARTITION, S_DELAY_180); } bHandled = TRUE; return 0; }
static void update_libretro_info(struct retro_system_info *info) { #ifndef HAVE_DYNAMIC retro_get_system_info(info); #endif core_info_list_free(g_extern.core_info); g_extern.core_info = NULL; if (*g_settings.libretro_directory) g_extern.core_info = core_info_list_new(g_settings.libretro_directory); rarch_update_system_info(info, NULL); }
static void menu_update_libretro_info(menu_handle_t *menu) { #ifndef HAVE_DYNAMIC retro_get_system_info(&menu->info); #endif core_info_list_free(menu->core_info); menu->core_info = NULL; if (*g_settings.libretro_directory) menu->core_info = core_info_list_new(g_settings.libretro_directory); menu_update_system_info(menu, NULL); }
const char *rarch_console_get_rom_ext(void) { const char *retval = NULL; struct retro_system_info info; retro_get_system_info(&info); if (info.valid_extensions) retval = info.valid_extensions; else retval = "ZIP|zip"; return retval; }
/** * menu_update_libretro_info: * * Update menu state which depends on config. **/ static void menu_update_libretro_info(void) { global_t *global = global_get_ptr(); struct retro_system_info *info = global ? &global->menu.info : NULL; if (!global || !info) return; #ifndef HAVE_DYNAMIC retro_get_system_info(info); #endif event_command(EVENT_CMD_CORE_INFO_INIT); event_command(EVENT_CMD_LOAD_CORE_PERSIST); }
void rarch_console_load_game_wrap(const char *path, unsigned extract_zip_mode, unsigned delay) { const char *game_to_load; char first_file_inzip[PATH_MAX]; char rom_path_temp[PATH_MAX]; char dir_path_temp[PATH_MAX]; struct retro_system_info info; bool block_zip_extract = false; bool extract_zip_cond = false; bool extract_zip_and_load_game_cond = false; bool load_game = !extract_zip_cond; retro_get_system_info(&info); block_zip_extract = info.block_extract; snprintf(rom_path_temp, sizeof(rom_path_temp), path); #ifdef HAVE_ZLIB extract_zip_cond = (strstr(rom_path_temp, ".zip") || strstr(rom_path_temp, ".ZIP")) && !block_zip_extract; if(extract_zip_cond) { fill_pathname_basedir(dir_path_temp, rom_path_temp, sizeof(dir_path_temp)); rarch_extract_zipfile(rom_path_temp, dir_path_temp, first_file_inzip, sizeof(first_file_inzip), extract_zip_mode); if(g_extern.console.rmenu.state.msg_info.enable) rarch_settings_msg(S_MSG_EXTRACTED_ZIPFILE, S_DELAY_180); } extract_zip_and_load_game_cond = (extract_zip_cond && g_extern.file_state.zip_extract_mode == ZIP_EXTRACT_TO_CURRENT_DIR_AND_LOAD_FIRST_FILE); load_game = (extract_zip_and_load_game_cond) || (!extract_zip_cond); if(extract_zip_and_load_game_cond) game_to_load = first_file_inzip; else #endif game_to_load = path; if(load_game) { rarch_console_load_game(game_to_load); if(g_extern.console.rmenu.state.msg_info.enable) rarch_settings_msg(S_MSG_LOADING_ROM, delay); } }
static void menu_update_libretro_info(void *data) { rgui_handle_t *rgui = (rgui_handle_t*)data; if (!rgui) return; #ifndef HAVE_DYNAMIC retro_get_system_info(&rgui->info); #endif memset(&rgui->core_info_current, 0, sizeof(rgui->core_info_current)); core_info_list_free(rgui->core_info); rgui->core_info = NULL; if (*g_settings.libretro_directory) rgui->core_info = core_info_list_new(g_settings.libretro_directory); menu_update_system_info(rgui, NULL); }
void menu_init(void) { rgui = rgui_init(); if (rgui == NULL) { RARCH_ERR("Could not initialize menu.\n"); rarch_fail(1, "menu_init()"); } rgui->trigger_state = 0; rgui->old_input_state = 0; rgui->do_held = false; rgui->frame_buf_show = true; rgui->current_pad = 0; #ifdef HAVE_DYNAMIC if (path_is_directory(g_settings.libretro)) strlcpy(rgui->libretro_dir, g_settings.libretro, sizeof(rgui->libretro_dir)); else if (*g_settings.libretro) { fill_pathname_basedir(rgui->libretro_dir, g_settings.libretro, sizeof(rgui->libretro_dir)); libretro_get_system_info(g_settings.libretro, &rgui->info, NULL); } #else retro_get_system_info(&rgui->info); #endif #ifdef HAVE_FILEBROWSER if (!(strlen(g_settings.rgui_browser_directory) > 0)) strlcpy(g_settings.rgui_browser_directory, default_paths.filebrowser_startup_dir, sizeof(g_settings.rgui_browser_directory)); rgui->browser = (filebrowser_t*)calloc(1, sizeof(*(rgui->browser))); if (rgui->browser == NULL) { RARCH_ERR("Could not initialize filebrowser.\n"); rarch_fail(1, "menu_init()"); } strlcpy(rgui->browser->current_dir.extensions, rgui->info.valid_extensions, sizeof(rgui->browser->current_dir.extensions)); // Look for zips to extract as well. if (*rgui->info.valid_extensions) { strlcat(rgui->browser->current_dir.extensions, "|zip", sizeof(rgui->browser->current_dir.extensions)); } strlcpy(rgui->browser->current_dir.root_dir, g_settings.rgui_browser_directory, sizeof(rgui->browser->current_dir.root_dir)); filebrowser_iterate(rgui->browser, FILEBROWSER_ACTION_RESET); #endif #ifdef HAVE_SHADER_MANAGER shader_manager_init(rgui); #endif if (*g_extern.config_path) { char history_path[PATH_MAX]; if (*g_settings.game_history_path) strlcpy(history_path, g_settings.game_history_path, sizeof(history_path)); else { fill_pathname_resolve_relative(history_path, g_extern.config_path, ".retroarch-game-history.txt", sizeof(history_path)); } RARCH_LOG("[RGUI]: Opening history: %s.\n", history_path); rgui->history = rom_history_init(history_path, g_settings.game_history_size); } rgui->last_time = rarch_get_time_usec(); }