Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Zangetsu38 committed Aug 8, 2023
1 parent 442853c commit b6c85ae
Show file tree
Hide file tree
Showing 92 changed files with 1,459 additions and 369 deletions.
1 change: 1 addition & 0 deletions vita3k/config/include/config/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ enum PerfomanceOverleyPosition {
code(int, "keyboard-rightstick-up", 12, keyboard_rightstick_up) \
code(int, "keyboard-rightstick-down", 14, keyboard_rightstick_down) \
code(int, "keyboard-button-psbutton", 19, keyboard_button_psbutton) \
code(int, "keyboard-button-psbutton-shell", 42, keyboard_button_psbutton_shell) \
code(int, "keyboard-gui-toggle-gui", 10, keyboard_gui_toggle_gui) \
code(int, "keyboard-gui-fullscreen", 68, keyboard_gui_fullscreen) \
code(int, "keyboard-gui-toggle-touch", 23, keyboard_gui_toggle_touch) \
Expand Down
2 changes: 2 additions & 0 deletions vita3k/config/include/config/state.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ struct Config : YamlLoader {
load_config = rhs.load_config;
fullscreen = rhs.fullscreen;
console = rhs.console;
app_device = rhs.app_device;
app_args = rhs.app_args;
load_app_list = rhs.load_app_list;
self_path = rhs.self_path;
Expand All @@ -92,6 +93,7 @@ struct Config : YamlLoader {

// Setting not present in the YAML file
fs::path config_path = {};
std::string app_device;
std::string app_args;
std::string self_path;
bool overwrite_config = true;
Expand Down
21 changes: 19 additions & 2 deletions vita3k/config/src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,19 +139,20 @@ ExitCode init_config(Config &cfg, int argc, char **argv, const Root &root_paths)
// Positional options
app.add_option("content-path", command_line.content_path, "Path of app in .vpk/.zip or folder of content to install & run")
->default_str({});

// Grouped options
auto input = app.add_option_group("Input", "Special options for Vita3K");
input->add_option("--console,-z", command_line.console, "Starts the emulator in fullscreen mode.")
->default_val(false)->group("Input");
input->add_option("--app-device,-D", command_line.app_device, "App device")
->default_val("ux0")->group("Input");
input->add_option("--app-args,-Z", command_line.app_args, "Argument for app, use ', ' to separate arguments.")
->default_str("")->group("Input");
input->add_option("--load-app-list,-a", command_line.load_app_list, "Starts the emulator with load app list.")
->default_val(false)->group("Input");
input->add_option("--self,-S", command_line.self_path, "Path to the self to run inside Title ID")
->default_str("eboot.bin")->group("Input");
input->add_option("--installed-path,-r", command_line.run_app_path, "Path of installed app to run")
->default_str({})->check(CLI::IsMember(get_file_set(fs::path(cfg.pref_path) / "ux0/app")))->group("Input");
->default_str({})->group("Input");
input->add_option("--recompile-shader,-s", command_line.recompile_shader_path, "Recompile the given PS Vita shader (GXP format) to SPIR_V / GLSL and quit")
->default_str({})->group("Input");
input->add_option("--deleted-id,-d", command_line.delete_title_id, "Title ID of installed app to delete")
Expand Down Expand Up @@ -209,6 +210,22 @@ ExitCode init_config(Config &cfg, int argc, char **argv, const Root &root_paths)
return QuitRequested;
}

if (command_line.run_app_path.has_value()) {
const std::string app_path = command_line.run_app_path.value();
if ((app_path != "NPXS10062") && (app_path != "NPXS19999")) {
std::set<std::string> exist_apps = get_file_set(fs::path(cfg.pref_path) / command_line.app_device / "app");
if (exist_apps.find(app_path) == exist_apps.end()) {
std::cout << "--installed-path: " << app_path << " no in {";
for (auto &app : exist_apps) {
std::cout << app;
if (app != *exist_apps.rbegin())
std::cout << ", ";
}
std::cout << "}\n";
return InitConfigFailed;
}
}
}
if (command_line.recompile_shader_path.has_value()) {
cfg.recompile_shader_path = std::move(command_line.recompile_shader_path);
return QuitRequested;
Expand Down
2 changes: 2 additions & 0 deletions vita3k/emuenv/include/emuenv/state.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ struct EmuEnvState {
public:
// App info contained in its `param.sfo` file
sfo::SfoAppInfo &app_info;
std::string app_device{};
std::string app_path{};
int32_t app_sku_flag{};
std::string license_content_id{};
Expand All @@ -114,6 +115,7 @@ struct EmuEnvState {
std::string default_path{};
std::wstring pref_path{};
bool load_exec{};
std::string load_app_device{};
std::string load_app_path{};
std::string load_exec_argv{};
std::string load_exec_path{};
Expand Down
31 changes: 16 additions & 15 deletions vita3k/gui/include/gui/functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,70 +41,71 @@ void browse_live_area_apps_list(GuiState &gui, EmuEnvState &emuenv, const uint32
void browse_pages_manual(GuiState &gui, EmuEnvState &emuenv, const uint32_t button);
void browse_save_data_dialog(GuiState &gui, EmuEnvState &emuenv, const uint32_t button);
void browse_users_management(GuiState &gui, EmuEnvState &emuenv, const uint32_t button);
void close_and_run_new_app(GuiState &gui, EmuEnvState &emuenv, const std::string &app_path);
void close_and_run_new_app(EmuEnvState &emuenv, const std::string &app_device, const std::string &app_path);
void close_live_area_app(GuiState &gui, EmuEnvState &emuenv, const std::string &app_path);
void close_system_app(GuiState &gui, EmuEnvState &emuenv);
void delete_app(GuiState &gui, EmuEnvState &emuenv, const std::string &app_path);
void get_app_info(GuiState &gui, EmuEnvState &emuenv, const std::string &app_path);
size_t get_app_size(GuiState &gui, EmuEnvState &emuenv, const std::string &app_path);
std::vector<App>::iterator get_app_index(GuiState &gui, const std::string &app_path);
std::map<std::string, ImGui_Texture>::const_iterator get_app_icon(GuiState &gui, const std::string &app_path);
std::vector<std::string>::iterator get_live_area_current_open_apps_list_index(GuiState &gui, const std::string &app_path);
std::vector<std::pair<std::string, std::string>>::iterator get_live_area_current_open_apps_list_index(GuiState &gui, const std::string &app_path);
std::map<DateTime, std::string> get_date_time(GuiState &gui, EmuEnvState &emuenv, const tm &date_time);
std::string get_unit_size(const size_t size);
void get_app_param(GuiState &gui, EmuEnvState &emuenv, const std::string &app_path);
void get_app_param(GuiState &gui, EmuEnvState &emuenv, const std::string &app_device, const std::string &app_path);
std::string get_cpu_backend(GuiState &gui, EmuEnvState &emuenv, const std::string &app_path);
void get_firmware_file(EmuEnvState &emuenv);
void get_modules_list(GuiState &gui, EmuEnvState &emuenv);
void get_notice_list(EmuEnvState &emuenv);
std::string get_theme_title_from_buffer(const vfs::FileBuffer &buffer);
std::vector<TimeApp>::iterator get_time_app_index(GuiState &gui, EmuEnvState &emuenv, const std::string &app);
void get_time_apps(GuiState &gui, EmuEnvState &emuenv);
std::vector<App>::iterator get_user_app_index(GuiState &gui, const std::string &app_path);
void get_user_apps_title(GuiState &gui, EmuEnvState &emuenv);
void get_users_list(GuiState &gui, EmuEnvState &emuenv);
bool get_sys_apps_state(GuiState &gui);
void get_sys_apps_title(GuiState &gui, EmuEnvState &emuenv);
std::string get_sys_lang_name(uint32_t lang_id);
void init(GuiState &gui, EmuEnvState &emuenv);
void init_app_background(GuiState &gui, EmuEnvState &emuenv, const std::string &app_path);
void init_app_icon(GuiState &gui, EmuEnvState &emuenv, const std::string &app_path);
void init_app_background(GuiState &gui, EmuEnvState &emuenv, const std::string &app_device, const std::string &app_path);
void init_app_icon(GuiState &gui, EmuEnvState &emuenv, const std::string &app_device, const std::string &app_path);
void init_apps_icon(GuiState &gui, EmuEnvState &emuenv, const std::vector<gui::App> &app_list);
void init_config(GuiState &gui, EmuEnvState &emuenv, const std::string &app_path);
void init_content_manager(GuiState &gui, EmuEnvState &emuenv);
vfs::FileBuffer init_default_icon(GuiState &gui, EmuEnvState &emuenv);
void init_home(GuiState &gui, EmuEnvState &emuenv);
void init_live_area(GuiState &gui, EmuEnvState &emuenv, const std::string &app_path);
bool init_manual(GuiState &gui, EmuEnvState &emuenv, const std::string &app_path);
void init_live_area(GuiState &gui, EmuEnvState &emuenv, const std::string &app_device, const std::string &app_path);
bool init_manual(GuiState &gui, EmuEnvState &emuenv, const std::string &app_device, const std::string &app_path);
void init_notice_info(GuiState &gui, EmuEnvState &emuenv);
bool init_theme(GuiState &gui, EmuEnvState &emuenv, const std::string &content_id);
void init_theme_start_background(GuiState &gui, EmuEnvState &emuenv, const std::string &content_id);
void init_last_time_apps(GuiState &gui, EmuEnvState &emuenv);
void init_trophy_collection(GuiState &gui, EmuEnvState &emuenv);
void init_user(GuiState &gui, EmuEnvState &emuenv, const std::string &user_id);
void init_user_app(GuiState &gui, EmuEnvState &emuenv, const std::string &app_path);
void init_user_app(GuiState &gui, EmuEnvState &emuenv, const std::string &app_device, const std::string &app_path);
void init_user_apps(GuiState &gui, EmuEnvState &emuenv);
bool init_user_background(GuiState &gui, EmuEnvState &emuenv, const std::string &background_path);
bool init_user_backgrounds(GuiState &gui, EmuEnvState &emuenv);
void init_user_management(GuiState &gui, EmuEnvState &emuenv);
bool init_user_start_background(GuiState &gui, const std::string &image_path);
void load_and_update_compat_user_apps(GuiState &gui, EmuEnvState &emuenv);
void open_live_area(GuiState &gui, EmuEnvState &emuenv, const std::string &app_path);
void open_manual(GuiState &gui, EmuEnvState &emuenv, const std::string &app_path);
void open_live_area(GuiState &gui, EmuEnvState &emuenv, const std::string &app_device, const std::string &app_path);
void open_manual(GuiState &gui, EmuEnvState &emuenv, const std::string &app_device, const std::string &app_path);
void open_path(const std::string &path);
void open_search(const std::string &title);
void open_trophy_unlocked(GuiState &gui, EmuEnvState &emuenv, const std::string &np_com_id, const std::string &trophy_id);
void open_user(GuiState &gui, EmuEnvState &emuenv);
bool init_vita3k_update(GuiState &gui);
void pre_init(GuiState &gui, EmuEnvState &emuenv);
void pre_load_app(GuiState &gui, EmuEnvState &emuenv, bool live_area, const std::string &app_path);
void pre_run_app(GuiState &gui, EmuEnvState &emuenv, const std::string &app_path);
void pre_load_app(GuiState &gui, EmuEnvState &emuenv, bool live_area, const std::string &app_device, const std::string &app_path);
void pre_run_app(GuiState &gui, EmuEnvState &emuenv, const std::string &app_device, const std::string &app_path);
void save_apps_cache(GuiState &gui, EmuEnvState &emuenv);
void save_user(GuiState &gui, EmuEnvState &emuenv, const std::string &user_id);
void set_config(GuiState &gui, EmuEnvState &emuenv, const std::string &app_path);
void set_shaders_compiled_display(GuiState &gui, EmuEnvState &emuenv);
void update_app(GuiState &gui, EmuEnvState &emuenv, const std::string &app_path);
void update_app(GuiState &gui, EmuEnvState &emuenv, const std::string &app_device, const std::string &app_path);
void update_last_time_app_used(GuiState &gui, EmuEnvState &emuenv, const std::string &app);
void update_live_area_current_open_apps_list(GuiState &gui, EmuEnvState &emuenv, const std::string &app_path);
void update_live_area_current_open_apps_list(GuiState &gui, EmuEnvState &emuenv, const std::string &app_device, const std::string &app_path);
void update_notice_info(GuiState &gui, EmuEnvState &emuenv, const std::string &type);
void update_time_app_used(GuiState &gui, EmuEnvState &emuenv, const std::string &app);
void save_notice_list(EmuEnvState &emuenv);
Expand All @@ -114,7 +115,7 @@ void draw_end(GuiState &emuenv, SDL_Window *window);
void draw_vita_area(GuiState &gui, EmuEnvState &emuenv);
void draw_ui(GuiState &gui, EmuEnvState &emuenv);

void draw_app_context_menu(GuiState &gui, EmuEnvState &emuenv, const std::string &app_path);
void draw_app_context_menu(GuiState &gui, EmuEnvState &emuenv, const std::string &app_device, const std::string &app_path);
void draw_background(GuiState &gui, EmuEnvState &emuenv);
void draw_common_dialog(GuiState &gui, EmuEnvState &emuenv);
void draw_ime(Ime &ime, EmuEnvState &emuenv);
Expand Down
3 changes: 2 additions & 1 deletion vita3k/gui/include/gui/state.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ enum SortType {
};

struct App {
std::string device;
std::string app_ver;
std::string category;
std::string content_id;
Expand Down Expand Up @@ -326,7 +327,7 @@ struct GuiState {
bool is_nav_button = false;
bool is_key_locked = false;

std::vector<std::string> live_area_current_open_apps_list;
std::vector<std::pair<std::string, std::string>> live_area_current_open_apps_list;
int32_t live_area_app_current_open = -1;

std::map<std::string, std::vector<TimeApp>> time_apps;
Expand Down
12 changes: 6 additions & 6 deletions vita3k/gui/src/app_context_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,11 +282,11 @@ void open_path(const std::string &path) {

static std::string context_dialog;

void draw_app_context_menu(GuiState &gui, EmuEnvState &emuenv, const std::string &app_path) {
void draw_app_context_menu(GuiState &gui, EmuEnvState &emuenv, const std::string &app_device, const std::string &app_path) {
const auto APP_INDEX = get_app_index(gui, app_path);
const auto title_id = APP_INDEX->title_id;

const auto APP_PATH{ fs::path(emuenv.pref_path) / "ux0/app" / app_path };
const auto APP_PATH{ fs::path(emuenv.pref_path) / app_device / "app" / app_path };
const auto CUSTOM_CONFIG_PATH{ fs::path(emuenv.base_path) / "config" / fmt::format("config_{}.xml", app_path) };
const auto ADDCONT_PATH{ fs::path(emuenv.pref_path) / "ux0/addcont" / APP_INDEX->addcont };
const auto LICENSE_PATH{ fs::path(emuenv.pref_path) / "ux0/license" / title_id };
Expand Down Expand Up @@ -318,7 +318,7 @@ void draw_app_context_menu(GuiState &gui, EmuEnvState &emuenv, const std::string
ImGui::SetWindowFontScale(1.1f);
const auto START_STR = app_path == emuenv.io.app_path ? gui.lang.live_area.main["continue"] : gui.lang.live_area.main["start"];
if (ImGui::MenuItem(START_STR.c_str()))
pre_run_app(gui, emuenv, app_path);
pre_run_app(gui, emuenv, app_device, app_path);
if (app_path.find("NPXS") == std::string::npos) {
if (ImGui::BeginMenu(lang_compat.name.c_str())) {
if (!is_commercial_app || !gui.compat.compat_db_loaded) {
Expand Down Expand Up @@ -467,13 +467,13 @@ void draw_app_context_menu(GuiState &gui, EmuEnvState &emuenv, const std::string
}
if (!emuenv.cfg.show_live_area_screen && ImGui::BeginMenu("Live Area")) {
if (ImGui::MenuItem("Live Area", nullptr, &gui.vita_area.live_area_screen))
open_live_area(gui, emuenv, app_path);
open_live_area(gui, emuenv, app_device, app_path);
if (ImGui::MenuItem("Search", nullptr))
open_search(APP_INDEX->title);
if (fs::exists(MANUAL_PATH) && !fs::is_empty(MANUAL_PATH) && ImGui::MenuItem("Manual", nullptr))
open_manual(gui, emuenv, app_path);
open_manual(gui, emuenv, app_device, app_path);
if (ImGui::MenuItem("Update"))
update_app(gui, emuenv, app_path);
update_app(gui, emuenv, app_device, app_path);
ImGui::EndMenu();
}
if (ImGui::BeginMenu(common["delete"].c_str())) {
Expand Down
2 changes: 1 addition & 1 deletion vita3k/gui/src/archive_install_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ void draw_archive_install_dialog(GuiState &gui, EmuEnvState &emuenv) {
if (emuenv.app_info.app_category != "theme")
update_notice_info(gui, emuenv, "content");
if (content.category == "gd") {
init_user_app(gui, emuenv, content.title_id);
init_user_app(gui, emuenv, "ux0", content.title_id);
save_apps_cache(gui, emuenv);
}
}
Expand Down
2 changes: 1 addition & 1 deletion vita3k/gui/src/content_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ void draw_content_manager(GuiState &gui, EmuEnvState &emuenv) {
ImGui::Separator();
ImGui::SetWindowFontScale(1.2f);
if (ImGui::Selectable(lang.main["theme"].c_str(), false, ImGuiSelectableFlags_SpanAllColumns, ImVec2(0.f, SIZE_SELECT)))
pre_run_app(gui, emuenv, "NPXS10015");
pre_run_app(gui, emuenv, "vs0", "NPXS10015");
ImGui::NextColumn();
ImGui::SetWindowFontScale(0.8f);
ImGui::Selectable(space["themes"].c_str(), false, ImGuiSelectableFlags_SpanAllColumns, ImVec2(0.f, SIZE_SELECT));
Expand Down
2 changes: 2 additions & 0 deletions vita3k/gui/src/controls_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ static void prepare_map_array(EmuEnvState &emuenv, std::array<int, total_key_ent
map[25] = emuenv.cfg.keyboard_gui_toggle_gui;
map[26] = emuenv.cfg.keyboard_gui_fullscreen;
map[27] = emuenv.cfg.keyboard_gui_toggle_touch;
map[28] = emuenv.cfg.keyboard_button_psbutton_shell;
}

bool need_open_error_duplicate_key_popup = false;
Expand Down Expand Up @@ -158,6 +159,7 @@ void draw_controls_dialog(GuiState &gui, EmuEnvState &emuenv) {
remapper_button(gui, emuenv, &emuenv.cfg.keyboard_button_start, lang["start_button"].c_str());
remapper_button(gui, emuenv, &emuenv.cfg.keyboard_button_select, lang["select_button"].c_str());
remapper_button(gui, emuenv, &emuenv.cfg.keyboard_button_psbutton, lang["ps_button"].c_str());
remapper_button(gui, emuenv, &emuenv.cfg.keyboard_button_l3, (lang["ps_button"] + " PS Vita OS").c_str());
remapper_button(gui, emuenv, &emuenv.cfg.keyboard_button_l1, lang["l1_button"].c_str());
remapper_button(gui, emuenv, &emuenv.cfg.keyboard_button_r1, lang["r1_button"].c_str());
ImGui::EndTable();
Expand Down

0 comments on commit b6c85ae

Please sign in to comment.