mirror of
https://github.com/spice2x/spice2x.github.io.git
synced 2026-11-30 02:56:42 -08:00
Compare commits
2
Commits
26-11-19
...
ae7d169b3f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ae7d169b3f | ||
|
|
ce87d20f25 |
No files matched your search
@@ -48,6 +48,8 @@ struct OptionDefinition {
|
||||
std::string file_extension = "";
|
||||
|
||||
std::string quick_setting_category = "";
|
||||
|
||||
bool trim_whitespace = false;
|
||||
};
|
||||
|
||||
class Option {
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#include "hooks/devicehook.h"
|
||||
#include "hooks/libraryhook.h"
|
||||
#ifdef SPICE64
|
||||
#include <mutex>
|
||||
#include <psapi.h>
|
||||
#include "hooks/graphics/nvapi_impl.h"
|
||||
#endif
|
||||
#include "hooks/graphics/nvapi_hook.h"
|
||||
@@ -40,6 +42,9 @@ static decltype(RegEnumKeyA) *RegEnumKeyA_orig = nullptr;
|
||||
static decltype(RegOpenKeyA) *RegOpenKeyA_orig = nullptr;
|
||||
static decltype(RegOpenKeyExA) *RegOpenKeyExA_orig = nullptr;
|
||||
static decltype(RegQueryValueExA) *RegQueryValueExA_orig = nullptr;
|
||||
#ifdef SPICE64
|
||||
static decltype(K32GetPerformanceInfo) *K32GetPerformanceInfo_orig = nullptr;
|
||||
#endif
|
||||
|
||||
namespace games::sdvx {
|
||||
|
||||
@@ -200,6 +205,35 @@ namespace games::sdvx {
|
||||
}
|
||||
|
||||
#ifdef SPICE64
|
||||
|
||||
static BOOL WINAPI K32GetPerformanceInfo_hook(PPERFORMANCE_INFORMATION info, DWORD cb) {
|
||||
if (info == nullptr) {
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
if (cb < sizeof(*info)) {
|
||||
SetLastError(ERROR_BAD_LENGTH);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// store a cached copy of the first successful call to K32GetPerformanceInfo
|
||||
static std::mutex cache_mutex;
|
||||
static PERFORMANCE_INFORMATION cached {};
|
||||
static bool cached_valid = false;
|
||||
std::lock_guard<std::mutex> lock(cache_mutex);
|
||||
if (!cached_valid) {
|
||||
if (!K32GetPerformanceInfo_orig(info, cb)) {
|
||||
return FALSE;
|
||||
}
|
||||
cached = *info;
|
||||
cached_valid = true;
|
||||
}
|
||||
|
||||
// return the cached copy to avoid performance issues with the game calling this every frame
|
||||
*info = cached;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static bool sdvx64_spam_remover(void *user, const std::string &data, logger::Style style, std::string &out) {
|
||||
if (data.empty() || data[0] != '[') {
|
||||
return false;
|
||||
@@ -534,6 +568,14 @@ namespace games::sdvx {
|
||||
if (is_valkyrie_model()) {
|
||||
sysutils::hook_EnumDisplayDevicesA();
|
||||
}
|
||||
|
||||
// keep one real snapshot for the session instead of querying statistics every frame
|
||||
K32GetPerformanceInfo_orig = detour::iat_try(
|
||||
"K32GetPerformanceInfo", K32GetPerformanceInfo_hook, avs::game::DLL_INSTANCE);
|
||||
if (K32GetPerformanceInfo_orig != nullptr) {
|
||||
log_info("sdvx", "installed cached hook for K32GetPerformanceInfo");
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -138,6 +138,7 @@ static const std::vector<OptionDefinition> OPTION_DEFINITIONS = std::invoke([]()
|
||||
.setting_name = "example.com:8083",
|
||||
.category = "Network",
|
||||
.quick_setting_category = "Network",
|
||||
.trim_whitespace = true,
|
||||
};
|
||||
c[launcher::Options::PCBID] = {
|
||||
.title = "PCBID",
|
||||
@@ -148,6 +149,7 @@ static const std::vector<OptionDefinition> OPTION_DEFINITIONS = std::invoke([]()
|
||||
.category = "Network",
|
||||
.sensitive = true,
|
||||
.quick_setting_category = "Network",
|
||||
.trim_whitespace = true,
|
||||
};
|
||||
c[launcher::Options::Player1Card] = {
|
||||
.title = "Player 1 Card",
|
||||
@@ -159,6 +161,7 @@ static const std::vector<OptionDefinition> OPTION_DEFINITIONS = std::invoke([]()
|
||||
.sensitive = true,
|
||||
.picker = OptionPickerType::EACard,
|
||||
.quick_setting_category = "Network",
|
||||
.trim_whitespace = true,
|
||||
};
|
||||
c[launcher::Options::Player2Card] = {
|
||||
.title = "Player 2 Card",
|
||||
@@ -170,6 +173,7 @@ static const std::vector<OptionDefinition> OPTION_DEFINITIONS = std::invoke([]()
|
||||
.sensitive = true,
|
||||
.picker = OptionPickerType::EACard,
|
||||
.quick_setting_category = "Network",
|
||||
.trim_whitespace = true,
|
||||
};
|
||||
c[launcher::Options::Player1PinMacro] = {
|
||||
.title = "Player 1 PIN Macro",
|
||||
|
||||
@@ -5282,9 +5282,16 @@ namespace overlay::windows {
|
||||
ImGui::InputTextWithHint("", hint, buffer, sizeof(buffer) - 1);
|
||||
// would like to use IsItemDeactivatedAfterEdit but can't handle the case when window is closed while editing
|
||||
if (ImGui::IsItemEdited()) {
|
||||
this->options_dirty = true;
|
||||
option.value = buffer;
|
||||
::Config::getInstance().updateBinding(games_list[games_selected], option);
|
||||
// trim whitespace to prevent copy/paste errors
|
||||
auto value = definition.trim_whitespace ?
|
||||
strtrim(buffer) : std::string(buffer);
|
||||
|
||||
if (option.value != value) {
|
||||
this->options_dirty = true;
|
||||
option.value = std::move(value);
|
||||
::Config::getInstance().updateBinding(games_list[games_selected], option);
|
||||
}
|
||||
|
||||
}
|
||||
if (ImGui::IsItemHovered(ImGui::TOOLTIP_FLAGS)) {
|
||||
ImGui::HelpTooltip(definition.desc.c_str());
|
||||
|
||||
Reference in new issue
Block a user