mirror of
https://github.com/spice2x/spice2x.github.io.git
synced 2026-12-02 03:16:41 -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 file_extension = "";
|
||||||
|
|
||||||
std::string quick_setting_category = "";
|
std::string quick_setting_category = "";
|
||||||
|
|
||||||
|
bool trim_whitespace = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Option {
|
class Option {
|
||||||
|
|||||||
@@ -9,6 +9,8 @@
|
|||||||
#include "hooks/devicehook.h"
|
#include "hooks/devicehook.h"
|
||||||
#include "hooks/libraryhook.h"
|
#include "hooks/libraryhook.h"
|
||||||
#ifdef SPICE64
|
#ifdef SPICE64
|
||||||
|
#include <mutex>
|
||||||
|
#include <psapi.h>
|
||||||
#include "hooks/graphics/nvapi_impl.h"
|
#include "hooks/graphics/nvapi_impl.h"
|
||||||
#endif
|
#endif
|
||||||
#include "hooks/graphics/nvapi_hook.h"
|
#include "hooks/graphics/nvapi_hook.h"
|
||||||
@@ -40,6 +42,9 @@ static decltype(RegEnumKeyA) *RegEnumKeyA_orig = nullptr;
|
|||||||
static decltype(RegOpenKeyA) *RegOpenKeyA_orig = nullptr;
|
static decltype(RegOpenKeyA) *RegOpenKeyA_orig = nullptr;
|
||||||
static decltype(RegOpenKeyExA) *RegOpenKeyExA_orig = nullptr;
|
static decltype(RegOpenKeyExA) *RegOpenKeyExA_orig = nullptr;
|
||||||
static decltype(RegQueryValueExA) *RegQueryValueExA_orig = nullptr;
|
static decltype(RegQueryValueExA) *RegQueryValueExA_orig = nullptr;
|
||||||
|
#ifdef SPICE64
|
||||||
|
static decltype(K32GetPerformanceInfo) *K32GetPerformanceInfo_orig = nullptr;
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace games::sdvx {
|
namespace games::sdvx {
|
||||||
|
|
||||||
@@ -200,6 +205,35 @@ namespace games::sdvx {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SPICE64
|
#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) {
|
static bool sdvx64_spam_remover(void *user, const std::string &data, logger::Style style, std::string &out) {
|
||||||
if (data.empty() || data[0] != '[') {
|
if (data.empty() || data[0] != '[') {
|
||||||
return false;
|
return false;
|
||||||
@@ -534,6 +568,14 @@ namespace games::sdvx {
|
|||||||
if (is_valkyrie_model()) {
|
if (is_valkyrie_model()) {
|
||||||
sysutils::hook_EnumDisplayDevicesA();
|
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
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -138,6 +138,7 @@ static const std::vector<OptionDefinition> OPTION_DEFINITIONS = std::invoke([]()
|
|||||||
.setting_name = "example.com:8083",
|
.setting_name = "example.com:8083",
|
||||||
.category = "Network",
|
.category = "Network",
|
||||||
.quick_setting_category = "Network",
|
.quick_setting_category = "Network",
|
||||||
|
.trim_whitespace = true,
|
||||||
};
|
};
|
||||||
c[launcher::Options::PCBID] = {
|
c[launcher::Options::PCBID] = {
|
||||||
.title = "PCBID",
|
.title = "PCBID",
|
||||||
@@ -148,6 +149,7 @@ static const std::vector<OptionDefinition> OPTION_DEFINITIONS = std::invoke([]()
|
|||||||
.category = "Network",
|
.category = "Network",
|
||||||
.sensitive = true,
|
.sensitive = true,
|
||||||
.quick_setting_category = "Network",
|
.quick_setting_category = "Network",
|
||||||
|
.trim_whitespace = true,
|
||||||
};
|
};
|
||||||
c[launcher::Options::Player1Card] = {
|
c[launcher::Options::Player1Card] = {
|
||||||
.title = "Player 1 Card",
|
.title = "Player 1 Card",
|
||||||
@@ -159,6 +161,7 @@ static const std::vector<OptionDefinition> OPTION_DEFINITIONS = std::invoke([]()
|
|||||||
.sensitive = true,
|
.sensitive = true,
|
||||||
.picker = OptionPickerType::EACard,
|
.picker = OptionPickerType::EACard,
|
||||||
.quick_setting_category = "Network",
|
.quick_setting_category = "Network",
|
||||||
|
.trim_whitespace = true,
|
||||||
};
|
};
|
||||||
c[launcher::Options::Player2Card] = {
|
c[launcher::Options::Player2Card] = {
|
||||||
.title = "Player 2 Card",
|
.title = "Player 2 Card",
|
||||||
@@ -170,6 +173,7 @@ static const std::vector<OptionDefinition> OPTION_DEFINITIONS = std::invoke([]()
|
|||||||
.sensitive = true,
|
.sensitive = true,
|
||||||
.picker = OptionPickerType::EACard,
|
.picker = OptionPickerType::EACard,
|
||||||
.quick_setting_category = "Network",
|
.quick_setting_category = "Network",
|
||||||
|
.trim_whitespace = true,
|
||||||
};
|
};
|
||||||
c[launcher::Options::Player1PinMacro] = {
|
c[launcher::Options::Player1PinMacro] = {
|
||||||
.title = "Player 1 PIN Macro",
|
.title = "Player 1 PIN Macro",
|
||||||
|
|||||||
@@ -5282,9 +5282,16 @@ namespace overlay::windows {
|
|||||||
ImGui::InputTextWithHint("", hint, buffer, sizeof(buffer) - 1);
|
ImGui::InputTextWithHint("", hint, buffer, sizeof(buffer) - 1);
|
||||||
// would like to use IsItemDeactivatedAfterEdit but can't handle the case when window is closed while editing
|
// would like to use IsItemDeactivatedAfterEdit but can't handle the case when window is closed while editing
|
||||||
if (ImGui::IsItemEdited()) {
|
if (ImGui::IsItemEdited()) {
|
||||||
this->options_dirty = true;
|
// trim whitespace to prevent copy/paste errors
|
||||||
option.value = buffer;
|
auto value = definition.trim_whitespace ?
|
||||||
::Config::getInstance().updateBinding(games_list[games_selected], option);
|
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)) {
|
if (ImGui::IsItemHovered(ImGui::TOOLTIP_FLAGS)) {
|
||||||
ImGui::HelpTooltip(definition.desc.c_str());
|
ImGui::HelpTooltip(definition.desc.c_str());
|
||||||
|
|||||||
Reference in new issue
Block a user