mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-05-09 12:08:13 +03:00
CLI: Add argument to pass an argument to the game (#2135)
This commit is contained in:
parent
1ea5f8f092
commit
3b92cd1c1a
6 changed files with 61 additions and 9 deletions
|
@ -99,7 +99,7 @@ Emulator::~Emulator() {
|
|||
Config::saveMainWindow(config_dir / "config.toml");
|
||||
}
|
||||
|
||||
void Emulator::Run(const std::filesystem::path& file) {
|
||||
void Emulator::Run(const std::filesystem::path& file, const std::vector<std::string> args) {
|
||||
// Applications expect to be run from /app0 so mount the file's parent path as app0.
|
||||
auto* mnt = Common::Singleton<Core::FileSys::MntPoints>::Instance();
|
||||
const auto game_folder = file.parent_path();
|
||||
|
@ -152,6 +152,15 @@ void Emulator::Run(const std::filesystem::path& file) {
|
|||
if (const auto raw_attributes = param_sfo->GetInteger("ATTRIBUTE")) {
|
||||
psf_attributes.raw = *raw_attributes;
|
||||
}
|
||||
if (!args.empty()) {
|
||||
int argc = std::min<int>(args.size(), 32);
|
||||
for (int i = 0; i < argc; i++) {
|
||||
LOG_INFO(Loader, "Game argument {}: {}", i, args[i]);
|
||||
}
|
||||
if (args.size() > 32) {
|
||||
LOG_ERROR(Loader, "Too many game arguments, only passing the first 32");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const auto pic1_path = mnt->GetHostPath("/app0/sce_sys/pic1.png");
|
||||
|
@ -239,7 +248,7 @@ void Emulator::Run(const std::filesystem::path& file) {
|
|||
}
|
||||
#endif
|
||||
|
||||
linker->Execute();
|
||||
linker->Execute(args);
|
||||
|
||||
window->InitTimers();
|
||||
while (window->IsOpen()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue