mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-05-20 18:34:58 +00:00
LLE libc + other fixes part1 (#97)
* app0 folder is absolute * some improvements on symbols types * clang format * missing libs.h * improved symbols_resolver * moved config to config folder * functions to dump import functions * improved logging output * option for debugdump and improvements * Apply suggestions from code review Co-authored-by: GPUCode <47210458+GPUCode@users.noreply.github.com> * clang format --------- Co-authored-by: GPUCode <47210458+GPUCode@users.noreply.github.com>
This commit is contained in:
parent
00d401e103
commit
02dcf4d45c
14 changed files with 130 additions and 36 deletions
111
src/common/config.cpp
Normal file
111
src/common/config.cpp
Normal file
|
@ -0,0 +1,111 @@
|
|||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <fmt/core.h>
|
||||
#include <toml.hpp>
|
||||
#include "config.h"
|
||||
|
||||
namespace Config {
|
||||
|
||||
bool isNeo = false;
|
||||
u32 screenWidth = 1280;
|
||||
u32 screenHeight = 720;
|
||||
std::string logFilter;
|
||||
bool isDebugDump = false;
|
||||
|
||||
bool isNeoMode() {
|
||||
return isNeo;
|
||||
}
|
||||
|
||||
u32 getScreenWidth() {
|
||||
return screenWidth;
|
||||
}
|
||||
|
||||
u32 getScreenHeight() {
|
||||
return screenHeight;
|
||||
}
|
||||
|
||||
std::string getLogFilter() {
|
||||
return logFilter;
|
||||
}
|
||||
|
||||
bool debugDump() {
|
||||
return isDebugDump;
|
||||
}
|
||||
|
||||
void load(const std::filesystem::path& path) {
|
||||
// If the configuration file does not exist, create it and return
|
||||
std::error_code error;
|
||||
if (!std::filesystem::exists(path, error)) {
|
||||
save(path);
|
||||
return;
|
||||
}
|
||||
|
||||
toml::value data;
|
||||
|
||||
try {
|
||||
data = toml::parse(path);
|
||||
} catch (std::exception& ex) {
|
||||
fmt::print("Got exception trying to load config file. Exception: {}\n", ex.what());
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.contains("General")) {
|
||||
auto generalResult = toml::expect<toml::value>(data.at("General"));
|
||||
if (generalResult.is_ok()) {
|
||||
auto general = generalResult.unwrap();
|
||||
|
||||
isNeo = toml::find_or<toml::boolean>(general, "isPS4Pro", false);
|
||||
logFilter = toml::find_or<toml::string>(general, "logFilter", "");
|
||||
}
|
||||
}
|
||||
if (data.contains("GPU")) {
|
||||
auto generalResult = toml::expect<toml::value>(data.at("GPU"));
|
||||
if (generalResult.is_ok()) {
|
||||
auto general = generalResult.unwrap();
|
||||
|
||||
screenWidth = toml::find_or<toml::integer>(general, "screenWidth", false);
|
||||
screenHeight = toml::find_or<toml::integer>(general, "screenHeight", false);
|
||||
}
|
||||
}
|
||||
if (data.contains("Debug")) {
|
||||
auto debugResult = toml::expect<toml::value>(data.at("Debug"));
|
||||
if (debugResult.is_ok()) {
|
||||
auto debug = debugResult.unwrap();
|
||||
|
||||
isDebugDump = toml::find_or<toml::boolean>(debug, "DebugDump", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
void save(const std::filesystem::path& path) {
|
||||
toml::basic_value<toml::preserve_comments> data;
|
||||
|
||||
std::error_code error;
|
||||
if (std::filesystem::exists(path, error)) {
|
||||
try {
|
||||
data = toml::parse<toml::preserve_comments>(path);
|
||||
} catch (const std::exception& ex) {
|
||||
fmt::print("Exception trying to parse config file. Exception: {}\n", ex.what());
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (error) {
|
||||
fmt::print("Filesystem error accessing {} (error: {})\n", path.string(),
|
||||
error.message().c_str());
|
||||
}
|
||||
fmt::print("Saving new configuration file {}\n", path.string());
|
||||
}
|
||||
|
||||
data["General"]["isPS4Pro"] = isNeo;
|
||||
data["General"]["logFilter"] = logFilter;
|
||||
data["GPU"]["screenWidth"] = screenWidth;
|
||||
data["GPU"]["screenHeight"] = screenHeight;
|
||||
data["Debug"]["DebugDump"] = isDebugDump;
|
||||
|
||||
std::ofstream file(path, std::ios::out);
|
||||
file << data;
|
||||
file.close();
|
||||
}
|
||||
} // namespace Config
|
21
src/common/config.h
Normal file
21
src/common/config.h
Normal file
|
@ -0,0 +1,21 @@
|
|||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include "types.h"
|
||||
|
||||
namespace Config {
|
||||
void load(const std::filesystem::path& path);
|
||||
void save(const std::filesystem::path& path);
|
||||
|
||||
bool isNeoMode();
|
||||
std::string getLogFilter();
|
||||
|
||||
u32 getScreenWidth();
|
||||
u32 getScreenHeight();
|
||||
|
||||
bool debugDump();
|
||||
|
||||
}; // namespace Config
|
|
@ -6,13 +6,13 @@
|
|||
#include <thread>
|
||||
|
||||
#include <fmt/format.h>
|
||||
#include "Util/config.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h> // For OutputDebugStringW
|
||||
#endif
|
||||
|
||||
#include "common/bounded_threadsafe_queue.h"
|
||||
#include "common/config.h"
|
||||
#include "common/io_file.h"
|
||||
#include "common/logging/backend.h"
|
||||
#include "common/logging/log.h"
|
||||
|
|
|
@ -35,7 +35,6 @@ static auto UserPaths = [] {
|
|||
create_path(PathType::LogDir, user_dir / LOG_DIR);
|
||||
create_path(PathType::ScreenshotsDir, user_dir / SCREENSHOTS_DIR);
|
||||
create_path(PathType::ShaderDir, user_dir / SHADER_DIR);
|
||||
create_path(PathType::App0, user_dir / APP0_DIR);
|
||||
|
||||
return paths;
|
||||
}();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue