mirror of
https://github.com/spice2x/spice2x.github.io.git
synced 2026-12-06 03:26:41 -08:00
Compare commits
14
Commits
c83496776e
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c371a45b91 | ||
|
|
69585ac43d | ||
|
|
3d530bfee0 | ||
|
|
af66dd5b50 | ||
|
|
1e0de890bc | ||
|
|
ae433ccb1d | ||
|
|
57c083e7ad | ||
|
|
e2fd48953e | ||
|
|
a4850165bb | ||
|
|
ae7d169b3f | ||
|
|
ce87d20f25 | ||
|
|
3e3db7a411 | ||
|
|
37f947b57f | ||
|
|
63bfef7c69 |
No files matched your search
@@ -6,6 +6,7 @@
|
|||||||
*.iws
|
*.iws
|
||||||
|
|
||||||
# CMake
|
# CMake
|
||||||
|
/build/
|
||||||
cmake-build*
|
cmake-build*
|
||||||
|
|
||||||
# user config
|
# user config
|
||||||
|
|||||||
@@ -141,6 +141,12 @@ else()
|
|||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-local-typedefs") # for our logging system
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-local-typedefs") # for our logging system
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-attributes") # fmtlib workaround
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-attributes") # fmtlib workaround
|
||||||
|
|
||||||
|
# static linking
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static -static-libgcc")
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static -static-libgcc -static-libstdc++")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT MSVC)
|
||||||
# release flags
|
# release flags
|
||||||
if(CMAKE_BUILD_TYPE MATCHES "Release")
|
if(CMAKE_BUILD_TYPE MATCHES "Release")
|
||||||
|
|
||||||
@@ -160,8 +166,8 @@ else()
|
|||||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fvisibility=hidden -fvisibility-inlines-hidden")
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fvisibility=hidden -fvisibility-inlines-hidden")
|
||||||
|
|
||||||
# remove symbol table and relocation information
|
# remove symbol table and relocation information
|
||||||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -s")
|
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -s")
|
||||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -s")
|
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} -s")
|
||||||
|
|
||||||
# performance
|
# performance
|
||||||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O2 -pipe")
|
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O2 -pipe")
|
||||||
@@ -223,10 +229,6 @@ else()
|
|||||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Og -pipe")
|
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Og -pipe")
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Og -pipe")
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Og -pipe")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# static linking
|
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static -static-libgcc")
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static -static-libgcc -static-libstdc++")
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# default defines
|
# default defines
|
||||||
@@ -453,6 +455,7 @@ set(SOURCE_FILES ${SOURCE_FILES}
|
|||||||
games/hpm/hpm.cpp
|
games/hpm/hpm.cpp
|
||||||
games/hpm/io.cpp
|
games/hpm/io.cpp
|
||||||
games/iidx/iidx.cpp
|
games/iidx/iidx.cpp
|
||||||
|
games/iidx/dxva2.cpp
|
||||||
games/iidx/io.cpp
|
games/iidx/io.cpp
|
||||||
games/iidx/poke.cpp
|
games/iidx/poke.cpp
|
||||||
games/iidx/bi2a.cpp
|
games/iidx/bi2a.cpp
|
||||||
@@ -541,6 +544,7 @@ set(SOURCE_FILES ${SOURCE_FILES}
|
|||||||
games/onpara/touchpanel.cpp
|
games/onpara/touchpanel.cpp
|
||||||
games/bc/bc.cpp
|
games/bc/bc.cpp
|
||||||
games/bc/io.cpp
|
games/bc/io.cpp
|
||||||
|
games/bc/bi2x_hook.cpp
|
||||||
games/ccj/ccj.cpp
|
games/ccj/ccj.cpp
|
||||||
games/ccj/io.cpp
|
games/ccj/io.cpp
|
||||||
games/ccj/bi2x_hook.cpp
|
games/ccj/bi2x_hook.cpp
|
||||||
@@ -595,6 +599,7 @@ set(SOURCE_FILES ${SOURCE_FILES}
|
|||||||
hooks/cfgmgr32hook.cpp
|
hooks/cfgmgr32hook.cpp
|
||||||
hooks/debughook.cpp
|
hooks/debughook.cpp
|
||||||
hooks/devicehook.cpp
|
hooks/devicehook.cpp
|
||||||
|
hooks/eventlog.cpp
|
||||||
hooks/graphics/graphics.cpp
|
hooks/graphics/graphics.cpp
|
||||||
hooks/graphics/graphics_windowed.cpp
|
hooks/graphics/graphics_windowed.cpp
|
||||||
hooks/graphics/jpeg_encoder.cpp
|
hooks/graphics/jpeg_encoder.cpp
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
#include "external/rapidjson/document.h"
|
#include "external/rapidjson/document.h"
|
||||||
#include "cfg/screen_resize.h"
|
#include "cfg/screen_resize.h"
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
using namespace std::placeholders;
|
using namespace std::placeholders;
|
||||||
using namespace rapidjson;
|
using namespace rapidjson;
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
#include "core.h"
|
#include "core.h"
|
||||||
|
|
||||||
|
#include <climits>
|
||||||
|
#include <cstring>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "avs/game.h"
|
||||||
#include "external/robin_hood.h"
|
#include "external/robin_hood.h"
|
||||||
#include "games/popn/popn.h"
|
#include "games/popn/popn.h"
|
||||||
#include "launcher/logger.h"
|
#include "launcher/logger.h"
|
||||||
@@ -1181,6 +1184,18 @@ namespace avs {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef SPICE64
|
||||||
|
// nabla increased heap size a few months into service (June 2026?)
|
||||||
|
if (dll_name == "soundvoltex.dll" &&
|
||||||
|
avs::game::is_ext(2025121501, INT_MAX)) {
|
||||||
|
auto old_size = HEAP_SIZE;
|
||||||
|
HEAP_SIZE = 0x18000000;
|
||||||
|
DEFAULT_HEAP_SIZE_SET = true;
|
||||||
|
log_info("avs-core", "updated heap size: {} -> {} (nabla)", old_size, avs::core::HEAP_SIZE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// hack, both hello! popn and popn hc using popn.dll
|
// hack, both hello! popn and popn hc using popn.dll
|
||||||
if (games::popn::is_pikapika_model()) {
|
if (games::popn::is_pikapika_model()) {
|
||||||
auto old_size = HEAP_SIZE;
|
auto old_size = HEAP_SIZE;
|
||||||
@@ -2101,9 +2116,6 @@ namespace avs {
|
|||||||
log_fatal("avs-core", "unknown AVS boot procedure");
|
log_fatal("avs-core", "unknown AVS boot procedure");
|
||||||
}
|
}
|
||||||
|
|
||||||
// wait a bit for output
|
|
||||||
Sleep(100);
|
|
||||||
|
|
||||||
// destroy config
|
// destroy config
|
||||||
config_destroy(config);
|
config_destroy(config);
|
||||||
}
|
}
|
||||||
|
|||||||
+54
-89
@@ -1,5 +1,8 @@
|
|||||||
#define SECURITY_WIN32
|
#define SECURITY_WIN32
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <chrono>
|
||||||
|
#include <climits>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -91,6 +94,7 @@ namespace avs {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static constexpr size_t alignment = 16;
|
static constexpr size_t alignment = 16;
|
||||||
|
using handshake_clock = std::chrono::steady_clock;
|
||||||
|
|
||||||
static int io_buf_init(struct io_buf *buf, size_t initial_capacity) {
|
static int io_buf_init(struct io_buf *buf, size_t initial_capacity) {
|
||||||
uint8_t *tmp_bytes = nullptr;
|
uint8_t *tmp_bytes = nullptr;
|
||||||
@@ -261,89 +265,35 @@ arg_fail:
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int impl_socket_recv_all(
|
static int tls_recv_handshake(
|
||||||
struct avs_net_sock_desc_work *work,
|
struct avs_net_sock_desc_work *work,
|
||||||
struct io_buf *buf,
|
handshake_clock::time_point deadline)
|
||||||
uint32_t recv_timeout)
|
|
||||||
{
|
{
|
||||||
uint8_t old_non_blocking_value = 0;
|
const auto now = handshake_clock::now();
|
||||||
uint8_t non_blocking = 0;
|
if (now < deadline) {
|
||||||
avs_net_size_t old_non_blocking_value_size = 0;
|
const auto remaining = std::chrono::ceil<std::chrono::milliseconds>(deadline - now);
|
||||||
struct avs_net_poll_fd poll_fds[1] {};
|
avs_net_poll_fd poll_fd {};
|
||||||
int ret = 0;
|
poll_fd.socket = work->sock_fd;
|
||||||
|
poll_fd.events = AVS_NET_POLL_POLLIN;
|
||||||
if (work == nullptr || work->sock_fd < 0) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto err = io_buf_validate(buf);
|
|
||||||
|
|
||||||
if (err != 0) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (buf->pos == buf->limit) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
poll_fds[0].socket = work->sock_fd;
|
|
||||||
poll_fds[0].events = AVS_NET_POLL_POLLIN;
|
|
||||||
|
|
||||||
non_blocking = 1;
|
|
||||||
old_non_blocking_value_size = sizeof(old_non_blocking_value);
|
|
||||||
|
|
||||||
core::avs_net_getsockopt(work->sock_fd, AVS_SO_NONBLOCK, &old_non_blocking_value, &old_non_blocking_value_size);
|
|
||||||
core::avs_net_setsockopt(work->sock_fd, AVS_SO_NONBLOCK, &non_blocking, sizeof(non_blocking));
|
|
||||||
|
|
||||||
while (true) {
|
|
||||||
auto result = core::avs_net_poll(poll_fds, std::size(poll_fds), recv_timeout);
|
|
||||||
|
|
||||||
|
const auto result = core::avs_net_poll(&poll_fd, 1,
|
||||||
|
static_cast<int>(remaining.count()));
|
||||||
if (result < 0) {
|
if (result < 0) {
|
||||||
log_warning("avs::ssl", "avs_net_poll failed: 0x{:08x}", result);
|
log_warning("avs::ssl", "avs_net_poll failed during TLS handshake: 0x{:08x}", result);
|
||||||
|
return result;
|
||||||
ret = -1;
|
|
||||||
|
|
||||||
goto out;
|
|
||||||
}
|
}
|
||||||
|
if (result > 0) {
|
||||||
if (!result) {
|
if (poll_fd.r_events & AVS_NET_POLL_POLLIN) {
|
||||||
#if 0
|
return impl_socket_recv(work, &work->recv_buf);
|
||||||
log_warning("avs::ssl", "socket timeout, no data received after {} milliseconds", recv_timeout);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
goto poll_succeeded_or_empty;
|
|
||||||
}
|
}
|
||||||
|
log_warning("avs::ssl", "unexpected TLS handshake poll events: 0x{:04x}",
|
||||||
if (poll_fds[0].r_events & AVS_NET_POLL_POLLIN) {
|
poll_fd.r_events);
|
||||||
result = core::avs_net_recv(work->sock_fd, &buf->bytes[buf->pos], buf->limit - buf->pos);
|
return core::avs_error_make(AVS_ERROR_CLASS_NET, AVS_ERROR_SUBCLASS_SC_BADMSG);
|
||||||
|
|
||||||
if (result < 0) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result == 0) {
|
|
||||||
log_misc("avs::ssl", "connection closed");
|
|
||||||
|
|
||||||
ret = -1;
|
|
||||||
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
log_warning("avs::ssl", "socket({}) got {} bytes during handshake", work->sock_fd, result);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
buf->pos += result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
poll_succeeded_or_empty:
|
log_warning("avs::ssl", "timed out waiting for TLS handshake data");
|
||||||
ret = 0;
|
return core::avs_error_make(AVS_ERROR_CLASS_NET, AVS_ERROR_SUBCLASS_NET_TIMEOUT);
|
||||||
|
|
||||||
out:
|
|
||||||
core::avs_net_setsockopt(work->sock_fd, AVS_SO_NONBLOCK, &old_non_blocking_value, sizeof(old_non_blocking_value));
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int impl_socket_send(struct avs_net_sock_desc_work *work, struct io_buf *buf) {
|
static int impl_socket_send(struct avs_net_sock_desc_work *work, struct io_buf *buf) {
|
||||||
@@ -897,6 +847,7 @@ out:
|
|||||||
uint32_t address,
|
uint32_t address,
|
||||||
avs_net_port_t port)
|
avs_net_port_t port)
|
||||||
{
|
{
|
||||||
|
constexpr uint32_t default_handshake_timeout_ms = 10000;
|
||||||
constexpr uint32_t security_context_flags = ISC_REQ_CONFIDENTIALITY |
|
constexpr uint32_t security_context_flags = ISC_REQ_CONFIDENTIALITY |
|
||||||
ISC_REQ_INTEGRITY |
|
ISC_REQ_INTEGRITY |
|
||||||
ISC_REQ_STREAM |
|
ISC_REQ_STREAM |
|
||||||
@@ -912,6 +863,7 @@ out:
|
|||||||
SECURITY_STATUS status = SEC_E_OK;
|
SECURITY_STATUS status = SEC_E_OK;
|
||||||
int result = 0;
|
int result = 0;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
handshake_clock::time_point handshake_deadline;
|
||||||
|
|
||||||
char hostname[256];
|
char hostname[256];
|
||||||
|
|
||||||
@@ -987,6 +939,11 @@ out:
|
|||||||
goto first_isc_fail;
|
goto first_isc_fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// share one receive budget across all TLS flights and partial reads
|
||||||
|
handshake_deadline = handshake_clock::now() + std::chrono::milliseconds(work->recv_timeout
|
||||||
|
? std::min<uint32_t>(work->recv_timeout, INT_MAX)
|
||||||
|
: default_handshake_timeout_ms);
|
||||||
|
|
||||||
while (status != SEC_E_OK) {
|
while (status != SEC_E_OK) {
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case SEC_I_CONTINUE_NEEDED:
|
case SEC_I_CONTINUE_NEEDED:
|
||||||
@@ -1002,33 +959,26 @@ out:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
work->recv_buf.pos = 0;
|
if (work->recv_buf.pos == 0) {
|
||||||
work->recv_buf.limit = work->recv_buf.capacity;
|
err = tls_recv_handshake(work, handshake_deadline);
|
||||||
|
|
||||||
err = impl_socket_recv_all(work, &work->recv_buf, 100);
|
|
||||||
|
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
goto loop_fail;
|
goto loop_fail;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SEC_E_INCOMPLETE_MESSAGE:
|
case SEC_E_INCOMPLETE_MESSAGE:
|
||||||
if (recv_bufs[1].BufferType != SECBUFFER_MISSING) {
|
if (work->recv_buf.pos == work->recv_buf.capacity) {
|
||||||
err = core::avs_error_make(AVS_ERROR_CLASS_NET, AVS_ERROR_SUBCLASS_SC_BADMSG);
|
err = io_buf_grow(&work->recv_buf);
|
||||||
|
|
||||||
goto loop_fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
err = io_buf_grow_to(&work->recv_buf, work->recv_buf.pos + recv_bufs[1].cbBuffer);
|
|
||||||
|
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
|
log_warning("avs::ssl", "failed to grow TLS handshake receive buffer");
|
||||||
goto loop_fail;
|
goto loop_fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
work->recv_buf.limit = work->recv_buf.capacity;
|
work->recv_buf.limit = work->recv_buf.capacity;
|
||||||
|
}
|
||||||
|
|
||||||
err = impl_socket_recv(work, &work->recv_buf);
|
err = tls_recv_handshake(work, handshake_deadline);
|
||||||
|
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
goto loop_fail;
|
goto loop_fail;
|
||||||
@@ -1093,6 +1043,21 @@ out:
|
|||||||
&send_vec,
|
&send_vec,
|
||||||
&attributes,
|
&attributes,
|
||||||
nullptr);
|
nullptr);
|
||||||
|
|
||||||
|
if (status == SEC_I_CONTINUE_NEEDED || status == SEC_E_OK) {
|
||||||
|
const auto extra = recv_bufs[1].BufferType == SECBUFFER_EXTRA
|
||||||
|
? recv_bufs[1].cbBuffer : 0;
|
||||||
|
if (extra > 0) {
|
||||||
|
const auto tail = work->recv_buf.bytes + (work->recv_buf.pos - extra);
|
||||||
|
if (status == SEC_E_OK) {
|
||||||
|
work->recv_ciphertext_tail = tail;
|
||||||
|
work->recv_ciphertext_count = extra;
|
||||||
|
} else {
|
||||||
|
memmove(work->recv_buf.bytes, tail, extra);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
work->recv_buf.pos = extra;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log_misc("avs::ssl", "TLS handshake complete");
|
log_misc("avs::ssl", "TLS handshake complete");
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
#include "screen_resize.h"
|
#include "screen_resize.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <cmath>
|
||||||
#include "avs/game.h"
|
#include "avs/game.h"
|
||||||
#include "external/rapidjson/document.h"
|
#include "external/rapidjson/document.h"
|
||||||
#include "external/rapidjson/pointer.h"
|
#include "external/rapidjson/pointer.h"
|
||||||
@@ -97,7 +99,10 @@ namespace cfg {
|
|||||||
int duplicate = 0;
|
int duplicate = 0;
|
||||||
load_int_value(doc, root + prefix + "duplicate", duplicate);
|
load_int_value(doc, root + prefix + "duplicate", duplicate);
|
||||||
scene.duplicate = static_cast<cfg::ScreenDuplicateMode>(duplicate);
|
scene.duplicate = static_cast<cfg::ScreenDuplicateMode>(duplicate);
|
||||||
|
|
||||||
|
load_split_config(doc, root + prefix, scene.split);
|
||||||
}
|
}
|
||||||
|
this->need_surface_clean = true;
|
||||||
|
|
||||||
// windowed settings are always under game settings
|
// windowed settings are always under game settings
|
||||||
root = "/sp2x_games/" + eamuse_get_game() + "/";
|
root = "/sp2x_games/" + eamuse_get_game() + "/";
|
||||||
@@ -179,6 +184,70 @@ namespace cfg {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void load_split_scale(
|
||||||
|
const rapidjson::Document &doc, const std::string &path, float &scale) {
|
||||||
|
const auto value = rapidjson::Pointer(path).Get(doc);
|
||||||
|
if (!value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (value->IsNumber()) {
|
||||||
|
const double number = value->GetDouble();
|
||||||
|
if (std::isfinite(number) && number >= split_region_setting::min_scale &&
|
||||||
|
number <= split_region_setting::max_scale) {
|
||||||
|
scale = static_cast<float>(number);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log_warning("ScreenResize", "{} must be a number from {} to {}; using default",
|
||||||
|
path, split_region_setting::min_scale, split_region_setting::max_scale);
|
||||||
|
scale = split_region_setting::default_scale;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScreenResize::load_split_region(
|
||||||
|
rapidjson::Document &doc, const std::string &path, split_region_setting ®ion) {
|
||||||
|
load_int_value(doc, path + "offset_x", region.offset_x);
|
||||||
|
load_int_value(doc, path + "offset_y", region.offset_y);
|
||||||
|
load_split_scale(doc, path + "scale_x", region.scale_x);
|
||||||
|
load_split_scale(doc, path + "scale_y", region.scale_y);
|
||||||
|
load_bool_value(doc, path + "keep_aspect_ratio", region.keep_aspect_ratio);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScreenResize::load_split_config(
|
||||||
|
rapidjson::Document &doc, const std::string &path, split_screen_setting &split) {
|
||||||
|
load_bool_value(doc, path + "split_mode", split.enabled);
|
||||||
|
const auto ratio = rapidjson::Pointer(path + "split_ratio").Get(doc);
|
||||||
|
if (ratio) {
|
||||||
|
if (ratio->IsNumber() && std::isfinite(ratio->GetDouble())) {
|
||||||
|
split.ratio = static_cast<float>(std::clamp(
|
||||||
|
ratio->GetDouble(), split_screen_setting::min_ratio,
|
||||||
|
split_screen_setting::max_ratio));
|
||||||
|
} else {
|
||||||
|
log_warning("ScreenResize", "{}split_ratio must be a finite number", path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
load_bool_value(doc, path + "split_swap_sides", split.swap_sides);
|
||||||
|
load_split_region(doc, path + "split_left/", split.left);
|
||||||
|
load_split_region(doc, path + "split_right/", split.right);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void save_split_region(
|
||||||
|
rapidjson::Document &doc, const std::string &path, const split_region_setting ®ion) {
|
||||||
|
rapidjson::Pointer(path + "offset_x").Set(doc, region.offset_x);
|
||||||
|
rapidjson::Pointer(path + "offset_y").Set(doc, region.offset_y);
|
||||||
|
rapidjson::Pointer(path + "scale_x").Set(doc, region.scale_x);
|
||||||
|
rapidjson::Pointer(path + "scale_y").Set(doc, region.scale_y);
|
||||||
|
rapidjson::Pointer(path + "keep_aspect_ratio").Set(doc, region.keep_aspect_ratio);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void save_split_config(
|
||||||
|
rapidjson::Document &doc, const std::string &path, const split_screen_setting &split) {
|
||||||
|
rapidjson::Pointer(path + "split_mode").Set(doc, split.enabled);
|
||||||
|
rapidjson::Pointer(path + "split_ratio").Set(doc, split.ratio);
|
||||||
|
rapidjson::Pointer(path + "split_swap_sides").Set(doc, split.swap_sides);
|
||||||
|
save_split_region(doc, path + "split_left/", split.left);
|
||||||
|
save_split_region(doc, path + "split_right/", split.right);
|
||||||
|
}
|
||||||
|
|
||||||
void ScreenResize::config_save() {
|
void ScreenResize::config_save() {
|
||||||
rapidjson::Document doc;
|
rapidjson::Document doc;
|
||||||
std::string config = fileutils::text_read(this->config_path);
|
std::string config = fileutils::text_read(this->config_path);
|
||||||
@@ -212,6 +281,8 @@ namespace cfg {
|
|||||||
rapidjson::Pointer(root + prefix + "scale_y").Set(doc, scene.scale_y);
|
rapidjson::Pointer(root + prefix + "scale_y").Set(doc, scene.scale_y);
|
||||||
rapidjson::Pointer(root + prefix + "keep_aspect_ratio").Set(doc, scene.keep_aspect_ratio);
|
rapidjson::Pointer(root + prefix + "keep_aspect_ratio").Set(doc, scene.keep_aspect_ratio);
|
||||||
rapidjson::Pointer(root + prefix + "duplicate").Set(doc, scene.duplicate);
|
rapidjson::Pointer(root + prefix + "duplicate").Set(doc, scene.duplicate);
|
||||||
|
|
||||||
|
save_split_config(doc, root + prefix, scene.split);
|
||||||
}
|
}
|
||||||
|
|
||||||
// windowed mode settings
|
// windowed mode settings
|
||||||
@@ -227,7 +298,10 @@ namespace cfg {
|
|||||||
// build JSON
|
// build JSON
|
||||||
rapidjson::StringBuffer buffer;
|
rapidjson::StringBuffer buffer;
|
||||||
rapidjson::PrettyWriter<rapidjson::StringBuffer> writer(buffer);
|
rapidjson::PrettyWriter<rapidjson::StringBuffer> writer(buffer);
|
||||||
doc.Accept(writer);
|
if (!doc.Accept(writer)) {
|
||||||
|
log_warning("ScreenResize", "unable to serialize config; existing file left unchanged");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// save to file
|
// save to file
|
||||||
if (fileutils::write_config_file("ScreenResize", this->config_path, buffer.GetString())) {
|
if (fileutils::write_config_file("ScreenResize", this->config_path, buffer.GetString())) {
|
||||||
|
|||||||
@@ -21,6 +21,29 @@ namespace cfg {
|
|||||||
CopyRight = 2,
|
CopyRight = 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct split_region_setting {
|
||||||
|
static constexpr double min_scale = 0.6;
|
||||||
|
static constexpr double max_scale = 3.0;
|
||||||
|
static constexpr float default_scale = 1.0f;
|
||||||
|
|
||||||
|
int offset_x = 0;
|
||||||
|
int offset_y = 0;
|
||||||
|
float scale_x = default_scale;
|
||||||
|
float scale_y = default_scale;
|
||||||
|
bool keep_aspect_ratio = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct split_screen_setting {
|
||||||
|
static constexpr double min_ratio = 0.1;
|
||||||
|
static constexpr double max_ratio = 0.9;
|
||||||
|
|
||||||
|
bool enabled = false;
|
||||||
|
float ratio = 0.5f;
|
||||||
|
bool swap_sides = false;
|
||||||
|
split_region_setting left;
|
||||||
|
split_region_setting right;
|
||||||
|
};
|
||||||
|
|
||||||
struct fullscreen_setting {
|
struct fullscreen_setting {
|
||||||
int offset_x = 0;
|
int offset_x = 0;
|
||||||
int offset_y = 0;
|
int offset_y = 0;
|
||||||
@@ -28,6 +51,8 @@ namespace cfg {
|
|||||||
float scale_y = 1.0;
|
float scale_y = 1.0;
|
||||||
bool keep_aspect_ratio = true;
|
bool keep_aspect_ratio = true;
|
||||||
ScreenDuplicateMode duplicate = ScreenDuplicateMode::None;
|
ScreenDuplicateMode duplicate = ScreenDuplicateMode::None;
|
||||||
|
|
||||||
|
split_screen_setting split;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern std::optional<std::string> SCREEN_RESIZE_CFG_PATH_OVERRIDE;
|
extern std::optional<std::string> SCREEN_RESIZE_CFG_PATH_OVERRIDE;
|
||||||
@@ -41,6 +66,10 @@ namespace cfg {
|
|||||||
bool load_int_value(rapidjson::Document& doc, std::string path, int& value);
|
bool load_int_value(rapidjson::Document& doc, std::string path, int& value);
|
||||||
bool load_uint32_value(rapidjson::Document& doc, std::string path, uint32_t& value);
|
bool load_uint32_value(rapidjson::Document& doc, std::string path, uint32_t& value);
|
||||||
bool load_float_value(rapidjson::Document& doc, std::string path, float& value);
|
bool load_float_value(rapidjson::Document& doc, std::string path, float& value);
|
||||||
|
void load_split_config(
|
||||||
|
rapidjson::Document &doc, const std::string &path, split_screen_setting &split);
|
||||||
|
void load_split_region(
|
||||||
|
rapidjson::Document &doc, const std::string &path, split_region_setting ®ion);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ScreenResize();
|
ScreenResize();
|
||||||
|
|||||||
+2
-2
@@ -18,11 +18,11 @@ RUN useradd user -m && echo "ALL ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
|
|||||||
RUN su user -c "cd /tmp/ && git clone https://aur.archlinux.org/yay-bin.git --depth=1 && cd yay-bin && makepkg --noconfirm -si && yay --noconfirm -S mingw-w64-cmake"
|
RUN su user -c "cd /tmp/ && git clone https://aur.archlinux.org/yay-bin.git --depth=1 && cd yay-bin && makepkg --noconfirm -si && yay --noconfirm -S mingw-w64-cmake"
|
||||||
|
|
||||||
RUN mkdir -p /opt/llvm-mingw-xp \
|
RUN mkdir -p /opt/llvm-mingw-xp \
|
||||||
&& curl -fsSL "https://github.com/mon/llvm-mingw-xp/releases/download/llvm-mingw-xp-22.1.0/llvm-mingw-llvm-mingw-xp-22.1.0-msvcrt-ubuntu-22.04-x86_64.tar.xz" \
|
&& curl -fsSL "https://github.com/mon/llvm-mingw-xp/releases/download/llvm-mingw-xp-23.1.5/llvm-mingw-xp-23.1.5-msvcrt-ubuntu-22.04-x86_64.tar.xz" \
|
||||||
| tar -xJ --strip-components=1 -C /opt/llvm-mingw-xp
|
| tar -xJ --strip-components=1 -C /opt/llvm-mingw-xp
|
||||||
ENV PATH="$PATH:/opt/llvm-mingw-xp/bin"
|
ENV PATH="$PATH:/opt/llvm-mingw-xp/bin"
|
||||||
|
|
||||||
RUN curl -fsSL "https://github.com/mon/windows-dll-compat-checker/releases/download/v1.3/windows_dll_compat_checker-linux-x86_64.tar.xz" \
|
RUN curl -fsSL "https://github.com/mon/windows-dll-compat-checker/releases/download/v1.6/windows_dll_compat_checker-linux-x86_64.tar.xz" \
|
||||||
| tar -xJ -C /usr/local/bin
|
| tar -xJ -C /usr/local/bin
|
||||||
|
|
||||||
# Stock makepkg.conf builds serially; this makes the AUR compiles below parallel.
|
# Stock makepkg.conf builds serially; this makes the AUR compiles below parallel.
|
||||||
|
|||||||
+27
-13
@@ -1,25 +1,30 @@
|
|||||||
#include "bc.h"
|
#include "bc.h"
|
||||||
|
|
||||||
|
#include <format>
|
||||||
#include "hooks/setupapihook.h"
|
#include "hooks/setupapihook.h"
|
||||||
|
#include "util/fileutils.h"
|
||||||
#include "util/libutils.h"
|
#include "util/libutils.h"
|
||||||
#include "acio2emu/handle.h"
|
#include "acio2emu/handle.h"
|
||||||
#include "acioemu/handle.h"
|
#include "acioemu/handle.h"
|
||||||
#include "hooks/graphics/graphics.h"
|
#include "hooks/graphics/graphics.h"
|
||||||
#include "util/detour.h"
|
#include "util/unity_player.h"
|
||||||
#include "node.h"
|
#include "node.h"
|
||||||
|
#include "bi2x_hook.h"
|
||||||
|
|
||||||
namespace games::bc {
|
namespace games::bc {
|
||||||
|
|
||||||
static decltype(ShowCursor) *ShowCursor_orig = nullptr;
|
std::string BC_INJECT_ARGS = "";
|
||||||
|
|
||||||
static int WINAPI ShowCursor_hook(BOOL bShow) {
|
|
||||||
// log_misc("bsac", "ShowCursor {}", bShow);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void BCGame::attach() {
|
void BCGame::attach() {
|
||||||
Game::attach();
|
Game::attach();
|
||||||
|
|
||||||
|
// create required directories
|
||||||
|
fileutils::dir_create_recursive("dev/raw/log");
|
||||||
|
|
||||||
|
// preload libraries
|
||||||
|
libutils::load_library("libaio.dll");
|
||||||
|
libutils::load_library("libaio-iob2_video.dll");
|
||||||
|
|
||||||
setupapihook_init(libutils::load_library("libaio.dll"));
|
setupapihook_init(libutils::load_library("libaio.dll"));
|
||||||
|
|
||||||
SETUPAPI_SETTINGS settings {};
|
SETUPAPI_SETTINGS settings {};
|
||||||
@@ -32,15 +37,24 @@ namespace games::bc {
|
|||||||
auto iob = new acio2emu::IOBHandle(L"COM3");
|
auto iob = new acio2emu::IOBHandle(L"COM3");
|
||||||
iob->register_node(std::make_unique<TBSNode>());
|
iob->register_node(std::make_unique<TBSNode>());
|
||||||
|
|
||||||
if (GRAPHICS_SHOW_CURSOR) {
|
#if SPICE64
|
||||||
detour::trampoline_try(
|
// insert BI2X hooks
|
||||||
"user32.dll", "ShowCursor",
|
bi2x_hook_init();
|
||||||
(void*)ShowCursor_hook, (void**)&ShowCursor_orig);
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
devicehook_init();
|
devicehook_init_trampoline();
|
||||||
devicehook_add(iob);
|
devicehook_add(iob);
|
||||||
devicehook_add(new acioemu::ACIOHandle(L"COM1"));
|
devicehook_add(new acioemu::ACIOHandle(L"COM1"));
|
||||||
|
|
||||||
|
if (GRAPHICS_SHOW_CURSOR) {
|
||||||
|
unity_utils::force_show_cursor(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
unity_utils::set_args(
|
||||||
|
std::format("{} {}{}",
|
||||||
|
GetCommandLineA(),
|
||||||
|
BC_INJECT_ARGS,
|
||||||
|
unity_utils::get_unity_player_args()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void BCGame::detach() {
|
void BCGame::detach() {
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
#include "games/game.h"
|
#include "games/game.h"
|
||||||
|
|
||||||
namespace games::bc {
|
namespace games::bc {
|
||||||
|
extern std::string BC_INJECT_ARGS;
|
||||||
|
|
||||||
class BCGame : public games::Game {
|
class BCGame : public games::Game {
|
||||||
public:
|
public:
|
||||||
BCGame() : Game("Busou Shinki: Armored Princess Battle Conductor") {}
|
BCGame() : Game("Busou Shinki: Armored Princess Battle Conductor") {}
|
||||||
|
|||||||
@@ -0,0 +1,163 @@
|
|||||||
|
#include "bi2x_hook.h"
|
||||||
|
|
||||||
|
#if SPICE64
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <iterator>
|
||||||
|
|
||||||
|
#include "util/detour.h"
|
||||||
|
#include "util/logging.h"
|
||||||
|
#include "rawinput/rawinput.h"
|
||||||
|
#include "games/io.h"
|
||||||
|
#include "io.h"
|
||||||
|
#include "util/tapeled.h"
|
||||||
|
|
||||||
|
namespace games::bc {
|
||||||
|
|
||||||
|
struct AIO_IOB2_BI2X_TBS;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* typedefs
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef void (__fastcall *aioIob2Bi2xTBS_GetDeviceStatus_t)(
|
||||||
|
AIO_IOB2_BI2X_TBS *i_pNodeCtl, void *o_DevStatus);
|
||||||
|
typedef void (__fastcall *aioIob2Bi2xTBS_SetButton0Lamp_t)(
|
||||||
|
AIO_IOB2_BI2X_TBS *i_pNodeCtl, bool i_bOn);
|
||||||
|
typedef void (__fastcall *aioIob2Bi2xTBS_SetIrLed_t)(
|
||||||
|
AIO_IOB2_BI2X_TBS *i_pNodeCtl, bool i_bOn);
|
||||||
|
typedef void (__fastcall *aioIob2Bi2xTBS_SetIccrLed_t)(
|
||||||
|
AIO_IOB2_BI2X_TBS *i_pNodeCtl, uint32_t i_RGB);
|
||||||
|
typedef void (__fastcall *aioIob2Bi2xTBS_SetStickLed_t)(
|
||||||
|
AIO_IOB2_BI2X_TBS *i_pNodeCtl, uint32_t i_RGB);
|
||||||
|
typedef void (__fastcall *aioIob2Bi2xTBS_SetTapeLedData_t)(
|
||||||
|
AIO_IOB2_BI2X_TBS *i_pNodeCtl, uint32_t i_TapeLed, uint8_t *i_pData);
|
||||||
|
|
||||||
|
static aioIob2Bi2xTBS_GetDeviceStatus_t aioIob2Bi2xTBS_GetDeviceStatus_orig = nullptr;
|
||||||
|
static aioIob2Bi2xTBS_SetButton0Lamp_t aioIob2Bi2xTBS_SetButton0Lamp_orig = nullptr;
|
||||||
|
static aioIob2Bi2xTBS_SetIrLed_t aioIob2Bi2xTBS_SetIrLed_orig = nullptr;
|
||||||
|
static aioIob2Bi2xTBS_SetIccrLed_t aioIob2Bi2xTBS_SetIccrLed_orig = nullptr;
|
||||||
|
static aioIob2Bi2xTBS_SetStickLed_t aioIob2Bi2xTBS_SetStickLed_orig = nullptr;
|
||||||
|
static aioIob2Bi2xTBS_SetTapeLedData_t aioIob2Bi2xTBS_SetTapeLedData_orig = nullptr;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* hooks
|
||||||
|
*/
|
||||||
|
|
||||||
|
static void write_light_rgb(
|
||||||
|
Lights::bc_lights_t r, Lights::bc_lights_t g, Lights::bc_lights_t b, uint32_t color) {
|
||||||
|
|
||||||
|
auto &lights = get_lights();
|
||||||
|
GameAPI::Lights::writeLight(RI_MGR, lights.at(r), ((color >> 16) & 0xFF) / 255.f);
|
||||||
|
GameAPI::Lights::writeLight(RI_MGR, lights.at(g), ((color >> 8) & 0xFF) / 255.f);
|
||||||
|
GameAPI::Lights::writeLight(RI_MGR, lights.at(b), (color & 0xFF) / 255.f);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void __fastcall aioIob2Bi2xTBS_GetDeviceStatus(
|
||||||
|
AIO_IOB2_BI2X_TBS *i_pNodeCtl, void *o_DevStatus) {
|
||||||
|
|
||||||
|
RI_MGR->devices_flush_output();
|
||||||
|
|
||||||
|
if (aioIob2Bi2xTBS_GetDeviceStatus_orig) {
|
||||||
|
aioIob2Bi2xTBS_GetDeviceStatus_orig(i_pNodeCtl, o_DevStatus);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void __fastcall aioIob2Bi2xTBS_SetButton0Lamp(
|
||||||
|
AIO_IOB2_BI2X_TBS *i_pNodeCtl, bool i_bOn) {
|
||||||
|
|
||||||
|
auto &lights = get_lights();
|
||||||
|
GameAPI::Lights::writeLight(RI_MGR, lights.at(Lights::Button), (i_bOn ? 1.f : 0.f));
|
||||||
|
|
||||||
|
if (aioIob2Bi2xTBS_SetButton0Lamp_orig) {
|
||||||
|
aioIob2Bi2xTBS_SetButton0Lamp_orig(i_pNodeCtl, i_bOn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void __fastcall aioIob2Bi2xTBS_SetIrLed(
|
||||||
|
AIO_IOB2_BI2X_TBS *i_pNodeCtl, bool i_bOn) {
|
||||||
|
|
||||||
|
auto &lights = get_lights();
|
||||||
|
GameAPI::Lights::writeLight(RI_MGR, lights.at(Lights::IrLed), (i_bOn ? 1.f : 0.f));
|
||||||
|
|
||||||
|
if (aioIob2Bi2xTBS_SetIrLed_orig) {
|
||||||
|
aioIob2Bi2xTBS_SetIrLed_orig(i_pNodeCtl, i_bOn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void __fastcall aioIob2Bi2xTBS_SetIccrLed(
|
||||||
|
AIO_IOB2_BI2X_TBS *i_pNodeCtl, uint32_t i_RGB) {
|
||||||
|
|
||||||
|
write_light_rgb(Lights::CardReader_R, Lights::CardReader_G, Lights::CardReader_B, i_RGB);
|
||||||
|
|
||||||
|
if (aioIob2Bi2xTBS_SetIccrLed_orig) {
|
||||||
|
aioIob2Bi2xTBS_SetIccrLed_orig(i_pNodeCtl, i_RGB);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void __fastcall aioIob2Bi2xTBS_SetStickLed(
|
||||||
|
AIO_IOB2_BI2X_TBS *i_pNodeCtl, uint32_t i_RGB) {
|
||||||
|
|
||||||
|
write_light_rgb(Lights::Joystick_R, Lights::Joystick_G, Lights::Joystick_B, i_RGB);
|
||||||
|
|
||||||
|
if (aioIob2Bi2xTBS_SetStickLed_orig) {
|
||||||
|
aioIob2Bi2xTBS_SetStickLed_orig(i_pNodeCtl, i_RGB);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void __fastcall aioIob2Bi2xTBS_SetTapeLedData(
|
||||||
|
AIO_IOB2_BI2X_TBS *i_pNodeCtl, uint32_t i_TapeLed, uint8_t *i_pData) {
|
||||||
|
|
||||||
|
static struct TapeLedMapping {
|
||||||
|
size_t data_size;
|
||||||
|
int r, g, b;
|
||||||
|
|
||||||
|
TapeLedMapping(size_t data_size, int r, int g, int b)
|
||||||
|
: data_size(data_size), r(r), g(g), b(b) {}
|
||||||
|
} mapping[] = {
|
||||||
|
{ 48, Lights::TitlePanel_R, Lights::TitlePanel_G, Lights::TitlePanel_B },
|
||||||
|
{ 49, Lights::SidePanel_R, Lights::SidePanel_G, Lights::SidePanel_B },
|
||||||
|
};
|
||||||
|
|
||||||
|
if (tapeledutils::is_enabled() && i_TapeLed < std::size(mapping)) {
|
||||||
|
auto &map = mapping[i_TapeLed];
|
||||||
|
const auto rgb = tapeledutils::pick_color_from_led_tape(i_pData, map.data_size);
|
||||||
|
|
||||||
|
auto &lights = get_lights();
|
||||||
|
GameAPI::Lights::writeLight(RI_MGR, lights.at(map.r), rgb.r);
|
||||||
|
GameAPI::Lights::writeLight(RI_MGR, lights.at(map.g), rgb.g);
|
||||||
|
GameAPI::Lights::writeLight(RI_MGR, lights.at(map.b), rgb.b);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (aioIob2Bi2xTBS_SetTapeLedData_orig) {
|
||||||
|
aioIob2Bi2xTBS_SetTapeLedData_orig(i_pNodeCtl, i_TapeLed, i_pData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void bi2x_hook_init() {
|
||||||
|
static bool initialized = false;
|
||||||
|
if (initialized) {
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
initialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
log_info("bc_bi2x_hook", "init");
|
||||||
|
|
||||||
|
const auto libaioIob2VideoDll = "libaio-iob2_video.dll";
|
||||||
|
detour::trampoline_try(libaioIob2VideoDll, "aioIob2Bi2xTBS_GetDeviceStatus",
|
||||||
|
aioIob2Bi2xTBS_GetDeviceStatus, &aioIob2Bi2xTBS_GetDeviceStatus_orig);
|
||||||
|
detour::trampoline_try(libaioIob2VideoDll, "aioIob2Bi2xTBS_SetButton0Lamp",
|
||||||
|
aioIob2Bi2xTBS_SetButton0Lamp, &aioIob2Bi2xTBS_SetButton0Lamp_orig);
|
||||||
|
detour::trampoline_try(libaioIob2VideoDll, "aioIob2Bi2xTBS_SetIrLed",
|
||||||
|
aioIob2Bi2xTBS_SetIrLed, &aioIob2Bi2xTBS_SetIrLed_orig);
|
||||||
|
detour::trampoline_try(libaioIob2VideoDll, "aioIob2Bi2xTBS_SetIccrLed",
|
||||||
|
aioIob2Bi2xTBS_SetIccrLed, &aioIob2Bi2xTBS_SetIccrLed_orig);
|
||||||
|
detour::trampoline_try(libaioIob2VideoDll, "aioIob2Bi2xTBS_SetStickLed",
|
||||||
|
aioIob2Bi2xTBS_SetStickLed, &aioIob2Bi2xTBS_SetStickLed_orig);
|
||||||
|
detour::trampoline_try(libaioIob2VideoDll, "aioIob2Bi2xTBS_SetTapeLedData",
|
||||||
|
aioIob2Bi2xTBS_SetTapeLedData, &aioIob2Bi2xTBS_SetTapeLedData_orig);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#if SPICE64
|
||||||
|
|
||||||
|
namespace games::bc {
|
||||||
|
void bi2x_hook_init();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -48,3 +48,31 @@ std::vector<Analog> &games::bc::get_analogs() {
|
|||||||
|
|
||||||
return analogs;
|
return analogs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<Light> &games::bc::get_lights() {
|
||||||
|
static std::vector<Light> lights;
|
||||||
|
|
||||||
|
if (lights.empty()) {
|
||||||
|
lights = GameAPI::Lights::getLights("Busou Shinki: Armored Princess Battle Conductor");
|
||||||
|
|
||||||
|
GameAPI::Lights::sortLights(
|
||||||
|
&lights,
|
||||||
|
"Title Panel R",
|
||||||
|
"Title Panel G",
|
||||||
|
"Title Panel B",
|
||||||
|
"Side Panel R",
|
||||||
|
"Side Panel G",
|
||||||
|
"Side Panel B",
|
||||||
|
"Card Reader R",
|
||||||
|
"Card Reader G",
|
||||||
|
"Card Reader B",
|
||||||
|
"Joystick R",
|
||||||
|
"Joystick G",
|
||||||
|
"Joystick B",
|
||||||
|
"Button",
|
||||||
|
"IR LED"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return lights;
|
||||||
|
}
|
||||||
@@ -30,7 +30,27 @@ namespace games::bc {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace Lights {
|
||||||
|
typedef enum {
|
||||||
|
TitlePanel_R,
|
||||||
|
TitlePanel_G,
|
||||||
|
TitlePanel_B,
|
||||||
|
SidePanel_R,
|
||||||
|
SidePanel_G,
|
||||||
|
SidePanel_B,
|
||||||
|
CardReader_R,
|
||||||
|
CardReader_G,
|
||||||
|
CardReader_B,
|
||||||
|
Joystick_R,
|
||||||
|
Joystick_G,
|
||||||
|
Joystick_B,
|
||||||
|
Button,
|
||||||
|
IrLed,
|
||||||
|
} bc_lights_t;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<Button> &get_buttons();
|
std::vector<Button> &get_buttons();
|
||||||
std::string get_buttons_help();
|
std::string get_buttons_help();
|
||||||
std::vector<Analog> &get_analogs();
|
std::vector<Analog> &get_analogs();
|
||||||
|
std::vector<Light> &get_lights();
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,114 @@
|
|||||||
|
#include "dxva2.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <atomic>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
#include <d3d9.h>
|
||||||
|
#include <dxva2api.h>
|
||||||
|
|
||||||
|
#include "avs/game.h"
|
||||||
|
#include "hooks/graphics/backends/d3d9/d3d9_backend.h"
|
||||||
|
#include "util/detour.h"
|
||||||
|
#include "util/logging.h"
|
||||||
|
|
||||||
|
namespace games::iidx {
|
||||||
|
static decltype(DXVA2CreateDirect3DDeviceManager9) *create_dxva2_manager_orig = nullptr;
|
||||||
|
static bool force_dxva2_workaround = false;
|
||||||
|
|
||||||
|
static bool has_video_player_with_dxva2_fallback(HMODULE module) {
|
||||||
|
// iidx34+ tries AVMfVideoPlayerWithDxva and falls back to MF-based software decoder
|
||||||
|
// (can install dxva2 hooks to trigger the fallback)
|
||||||
|
//
|
||||||
|
// older iidx (003 variants of iidx29-30?) uses MfVideo::DxvaDeviceImpl and does not automatically fallback
|
||||||
|
// (requires a DLL patch to trigger the fallback)
|
||||||
|
//
|
||||||
|
// this function detects the AVMfVideoPlayerWithDxva case and returns true
|
||||||
|
|
||||||
|
constexpr char player_type[] = ".?AVMfVideoPlayerWithDxva@Video@Graphics@@";
|
||||||
|
const auto *image = reinterpret_cast<const char *>(module);
|
||||||
|
const auto *dos_header = reinterpret_cast<const IMAGE_DOS_HEADER *>(image);
|
||||||
|
const auto *nt_headers =
|
||||||
|
reinterpret_cast<const IMAGE_NT_HEADERS *>(image + dos_header->e_lfanew);
|
||||||
|
|
||||||
|
const auto *section = IMAGE_FIRST_SECTION(nt_headers);
|
||||||
|
for (WORD i = 0; i < nt_headers->FileHeader.NumberOfSections; i++, section++) {
|
||||||
|
if (std::memcmp(section->Name, ".data", sizeof(".data")) != 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto size = std::min(section->Misc.VirtualSize, section->SizeOfRawData);
|
||||||
|
const std::string_view data(image + section->VirtualAddress, size);
|
||||||
|
const std::string_view marker(player_type, sizeof(player_type));
|
||||||
|
return data.find(marker) != std::string_view::npos;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static HRESULT WINAPI create_dxva2_manager_hook(UINT *reset_token, IDirect3DDeviceManager9 **manager) {
|
||||||
|
if (!force_dxva2_workaround && !graphics_d3d9_is_dxvk()) {
|
||||||
|
return create_dxva2_manager_orig(reset_token, manager);
|
||||||
|
}
|
||||||
|
|
||||||
|
// dxvk can create the manager without providing a usable decoder; failing creation
|
||||||
|
// lets iidx fall back to software decoding on builds that support it.
|
||||||
|
static std::atomic_bool logged = false;
|
||||||
|
if (!logged.exchange(true, std::memory_order_relaxed)) {
|
||||||
|
log_info(
|
||||||
|
"iidx",
|
||||||
|
"DXVA2 workaround active ({}): returning E_FAIL from DXVA2CreateDirect3DDeviceManager9",
|
||||||
|
force_dxva2_workaround ? "forced on by user" : "automatically for DXVK");
|
||||||
|
}
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void init_dxva2_workaround(std::string_view mode) {
|
||||||
|
// default (no selection) is auto
|
||||||
|
if (mode.empty()) {
|
||||||
|
mode = "auto";
|
||||||
|
}
|
||||||
|
|
||||||
|
// forced off by user
|
||||||
|
if (mode == "off") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const bool forced_on_by_user = (mode == "on");
|
||||||
|
|
||||||
|
// invalid option value
|
||||||
|
if (!forced_on_by_user && mode != "auto") {
|
||||||
|
log_warning("iidx", "invalid DXVA2 workaround mode '{}'; expected auto, on, or off", mode);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto module = avs::game::DLL_INSTANCE;
|
||||||
|
if (!module) {
|
||||||
|
if (forced_on_by_user) {
|
||||||
|
log_warning("iidx", "DXVA2 workaround requested, but the game DLL is not loaded");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!forced_on_by_user && !has_video_player_with_dxva2_fallback(module)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
force_dxva2_workaround = forced_on_by_user;
|
||||||
|
|
||||||
|
// install hook
|
||||||
|
create_dxva2_manager_orig = detour::iat_try(
|
||||||
|
"DXVA2CreateDirect3DDeviceManager9", create_dxva2_manager_hook, module, "dxva2.dll");
|
||||||
|
|
||||||
|
if (!create_dxva2_manager_orig) {
|
||||||
|
if (forced_on_by_user) {
|
||||||
|
log_warning("iidx", "DXVA2 workaround requested, but the DXVA2 import was not found");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (forced_on_by_user) {
|
||||||
|
log_info("iidx", "DXVA2 disabled by user");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string_view>
|
||||||
|
|
||||||
|
namespace games::iidx {
|
||||||
|
void init_dxva2_workaround(std::string_view mode);
|
||||||
|
}
|
||||||
@@ -39,6 +39,7 @@
|
|||||||
|
|
||||||
#include "bi2a.h"
|
#include "bi2a.h"
|
||||||
#include "bi2x_hook.h"
|
#include "bi2x_hook.h"
|
||||||
|
#include "dxva2.h"
|
||||||
#include "ezusb.h"
|
#include "ezusb.h"
|
||||||
#include "io.h"
|
#include "io.h"
|
||||||
#include "poke.h"
|
#include "poke.h"
|
||||||
@@ -311,8 +312,9 @@ namespace games::iidx {
|
|||||||
|
|
||||||
void IIDXGame::attach() {
|
void IIDXGame::attach() {
|
||||||
Game::attach();
|
Game::attach();
|
||||||
// IO boards
|
|
||||||
auto options = games::get_options(eamuse_get_game());
|
auto options = games::get_options(eamuse_get_game());
|
||||||
|
|
||||||
|
// IO boards
|
||||||
if (!options->at(launcher::Options::IIDXBIO2FW).value_bool()) {
|
if (!options->at(launcher::Options::IIDXBIO2FW).value_bool()) {
|
||||||
|
|
||||||
// reduce boot wait time
|
// reduce boot wait time
|
||||||
@@ -452,6 +454,10 @@ namespace games::iidx {
|
|||||||
|
|
||||||
#if SPICE64
|
#if SPICE64
|
||||||
|
|
||||||
|
// dxvk workaround for movie decoder
|
||||||
|
init_dxva2_workaround(
|
||||||
|
options->at(launcher::Options::IIDXNoDxva2).value_text());
|
||||||
|
|
||||||
if (TDJ_MODE) {
|
if (TDJ_MODE) {
|
||||||
sysutils::hook_EnumDisplayDevicesA();
|
sysutils::hook_EnumDisplayDevicesA();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -301,6 +301,7 @@ namespace games {
|
|||||||
buttons.insert({ bc, bc::get_buttons() });
|
buttons.insert({ bc, bc::get_buttons() });
|
||||||
buttons_help.insert({ bc, bc::get_buttons_help() });
|
buttons_help.insert({ bc, bc::get_buttons_help() });
|
||||||
analogs.insert({ bc, bc::get_analogs() });
|
analogs.insert({ bc, bc::get_analogs() });
|
||||||
|
lights.insert({ bc, bc::get_lights() });
|
||||||
file_hints[bc].push_back({"game/bsac_app.exe"});
|
file_hints[bc].push_back({"game/bsac_app.exe"});
|
||||||
|
|
||||||
// ccj
|
// ccj
|
||||||
|
|||||||
@@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -183,6 +183,30 @@ HRESULT STDMETHODCALLTYPE WrappedIAudioClient::Initialize(
|
|||||||
WAVEFORMATEXTENSIBLE resample_storage = {};
|
WAVEFORMATEXTENSIBLE resample_storage = {};
|
||||||
const WAVEFORMATEX *device_format = pFormat;
|
const WAVEFORMATEX *device_format = pFormat;
|
||||||
|
|
||||||
|
#if SPICE_LINUX
|
||||||
|
WAVEFORMATEXTENSIBLE full_width_storage = {};
|
||||||
|
if (this->shared.redirected_from_exclusive &&
|
||||||
|
pFormat->wFormatTag == WAVE_FORMAT_EXTENSIBLE &&
|
||||||
|
pFormat->cbSize == sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX) &&
|
||||||
|
pFormat->wBitsPerSample == 32) {
|
||||||
|
const auto *ext = reinterpret_cast<const WAVEFORMATEXTENSIBLE *>(pFormat);
|
||||||
|
if (ext->SubFormat == GUID_KSDATAFORMAT_SUBTYPE_PCM &&
|
||||||
|
ext->Samples.wValidBitsPerSample == 24) {
|
||||||
|
|
||||||
|
// workaround for bug in wine
|
||||||
|
//
|
||||||
|
// Windows reads audio data in the **top** 24 bits, but Wine's PulseAudio mapping
|
||||||
|
// for this format reads the **bottom** 24 bits, causing static.
|
||||||
|
// report 32 valid bits so Wine selects s32le and reads the whole sample.
|
||||||
|
// the bottom 8 bits are zero padding, so the audio data and volume stay the same.
|
||||||
|
full_width_storage = *ext;
|
||||||
|
full_width_storage.Samples.wValidBitsPerSample = 32;
|
||||||
|
device_format = &full_width_storage.Format;
|
||||||
|
log_info("audio::wasapi", "using 32-bit PCM for Linux shared-mode 24-in-32 audio");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!this->shared.redirected_from_exclusive) {
|
if (!this->shared.redirected_from_exclusive) {
|
||||||
|
|
||||||
// when downmixing, open the real device as stereo while the game keeps writing its native
|
// when downmixing, open the real device as stereo while the game keeps writing its native
|
||||||
|
|||||||
@@ -0,0 +1,153 @@
|
|||||||
|
#include "eventlog.h"
|
||||||
|
|
||||||
|
#include <mutex>
|
||||||
|
#include <set>
|
||||||
|
|
||||||
|
#include "util/detour.h"
|
||||||
|
#include "util/logging.h"
|
||||||
|
|
||||||
|
namespace hooks::eventlog {
|
||||||
|
static decltype(OpenEventLogA) *OpenEventLogA_orig = nullptr;
|
||||||
|
static decltype(OpenEventLogW) *OpenEventLogW_orig = nullptr;
|
||||||
|
static decltype(CloseEventLog) *CloseEventLog_orig = nullptr;
|
||||||
|
static decltype(GetNumberOfEventLogRecords) *GetNumberOfEventLogRecords_orig = nullptr;
|
||||||
|
static decltype(ReadEventLogA) *ReadEventLogA_orig = nullptr;
|
||||||
|
static decltype(ReadEventLogW) *ReadEventLogW_orig = nullptr;
|
||||||
|
|
||||||
|
// count and read calls only receive a handle, not the server name used at open
|
||||||
|
static std::mutex handles_mutex;
|
||||||
|
static std::set<HANDLE> local_log_handles;
|
||||||
|
|
||||||
|
static HANDLE record_open(HANDLE handle, bool local) {
|
||||||
|
// bookkeeping must not change the last error left by OpenEventLog
|
||||||
|
auto error = GetLastError();
|
||||||
|
{
|
||||||
|
std::lock_guard lock(handles_mutex);
|
||||||
|
if (local) {
|
||||||
|
local_log_handles.insert(handle);
|
||||||
|
} else {
|
||||||
|
// another DLL may have closed a local handle without going through our hook
|
||||||
|
local_log_handles.erase(handle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SetLastError(error);
|
||||||
|
return handle;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool is_local_log(HANDLE handle) {
|
||||||
|
std::lock_guard lock(handles_mutex);
|
||||||
|
return local_log_handles.count(handle) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static HANDLE WINAPI OpenEventLogA_hook(LPCSTR server, LPCSTR source) {
|
||||||
|
auto handle = OpenEventLogA_orig(server, source);
|
||||||
|
return handle ? record_open(handle, !server || !*server) : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static HANDLE WINAPI OpenEventLogW_hook(LPCWSTR server, LPCWSTR source) {
|
||||||
|
auto handle = OpenEventLogW_orig(server, source);
|
||||||
|
return handle ? record_open(handle, !server || !*server) : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static BOOL WINAPI CloseEventLog_hook(HANDLE handle) {
|
||||||
|
// finish removing this handle before another open can register its reused value
|
||||||
|
std::unique_lock lock(handles_mutex);
|
||||||
|
auto result = CloseEventLog_orig(handle);
|
||||||
|
auto error = GetLastError();
|
||||||
|
if (result) {
|
||||||
|
local_log_handles.erase(handle);
|
||||||
|
}
|
||||||
|
lock.unlock();
|
||||||
|
|
||||||
|
SetLastError(error);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static BOOL WINAPI GetNumberOfEventLogRecords_hook(HANDLE handle, PDWORD count) {
|
||||||
|
// let Windows validate the request; only replace a successful local count
|
||||||
|
auto result = GetNumberOfEventLogRecords_orig(handle, count);
|
||||||
|
auto error = GetLastError();
|
||||||
|
|
||||||
|
if (result && is_local_log(handle)) {
|
||||||
|
*count = 0;
|
||||||
|
}
|
||||||
|
SetLastError(error);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool valid_read_flags(DWORD flags) {
|
||||||
|
// exactly one positioning mode and one direction; pass unknown bits through to Windows
|
||||||
|
switch (flags) {
|
||||||
|
case EVENTLOG_SEQUENTIAL_READ | EVENTLOG_FORWARDS_READ:
|
||||||
|
case EVENTLOG_SEQUENTIAL_READ | EVENTLOG_BACKWARDS_READ:
|
||||||
|
case EVENTLOG_SEEK_READ | EVENTLOG_FORWARDS_READ:
|
||||||
|
case EVENTLOG_SEEK_READ | EVENTLOG_BACKWARDS_READ:
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static BOOL read_event_log(decltype(ReadEventLogA) *original, HANDLE handle, DWORD flags,
|
||||||
|
DWORD offset, LPVOID buffer, DWORD size, DWORD *bytes_read, DWORD *needed) {
|
||||||
|
if (!valid_read_flags(flags) || !is_local_log(handle)) {
|
||||||
|
return original(handle, flags, offset, buffer, size, bytes_read, needed);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!buffer || !bytes_read || !needed) {
|
||||||
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// callers that read without checking the count should also see an empty log
|
||||||
|
*bytes_read = 0;
|
||||||
|
*needed = 0;
|
||||||
|
SetLastError(ERROR_HANDLE_EOF);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static BOOL WINAPI ReadEventLogA_hook(HANDLE handle, DWORD flags, DWORD offset, LPVOID buffer,
|
||||||
|
DWORD size, DWORD *bytes_read, DWORD *needed) {
|
||||||
|
return read_event_log(ReadEventLogA_orig, handle, flags, offset, buffer, size, bytes_read, needed);
|
||||||
|
}
|
||||||
|
|
||||||
|
static BOOL WINAPI ReadEventLogW_hook(HANDLE handle, DWORD flags, DWORD offset, LPVOID buffer,
|
||||||
|
DWORD size, DWORD *bytes_read, DWORD *needed) {
|
||||||
|
return read_event_log(ReadEventLogW_orig, handle, flags, offset, buffer, size, bytes_read, needed);
|
||||||
|
}
|
||||||
|
|
||||||
|
void init(HMODULE module) {
|
||||||
|
// some games like SDVX read the Application event log, one record at a time, looking for
|
||||||
|
// Windows activation timestamps; present local logs as empty to avoid these scans.
|
||||||
|
if (!module) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr auto dll = "advapi32.dll";
|
||||||
|
if (!detour::iat_find("OpenEventLogA", module, dll) &&
|
||||||
|
!detour::iat_find("OpenEventLogW", module, dll)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CloseEventLog_orig = detour::iat_try("CloseEventLog", CloseEventLog_hook, module, dll);
|
||||||
|
if (!CloseEventLog_orig) {
|
||||||
|
log_misc("eventlog", "no CloseEventLog import; leaving event log access unchanged");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
GetNumberOfEventLogRecords_orig = detour::iat_try(
|
||||||
|
"GetNumberOfEventLogRecords", GetNumberOfEventLogRecords_hook, module, dll);
|
||||||
|
ReadEventLogA_orig = detour::iat_try("ReadEventLogA", ReadEventLogA_hook, module, dll);
|
||||||
|
ReadEventLogW_orig = detour::iat_try("ReadEventLogW", ReadEventLogW_hook, module, dll);
|
||||||
|
if (!GetNumberOfEventLogRecords_orig && !ReadEventLogA_orig && !ReadEventLogW_orig) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// start tracking opens only after we can intercept reads or counts and observe closes
|
||||||
|
OpenEventLogA_orig = detour::iat_try("OpenEventLogA", OpenEventLogA_hook, module, dll);
|
||||||
|
OpenEventLogW_orig = detour::iat_try("OpenEventLogW", OpenEventLogW_hook, module, dll);
|
||||||
|
if (OpenEventLogA_orig || OpenEventLogW_orig) {
|
||||||
|
log_info("eventlog", "hooks installed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
namespace hooks::eventlog {
|
||||||
|
void init(HMODULE module);
|
||||||
|
}
|
||||||
@@ -286,8 +286,37 @@ static bool is_dx9_on_12_enabled() {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool detect_dxvk(HMODULE d3d9) {
|
||||||
|
// **mostly** reliable detection for dxvk; these are used internally for debugging
|
||||||
|
constexpr WORD register_annotation = 28257;
|
||||||
|
constexpr WORD unregister_annotation = 28258;
|
||||||
|
if (!d3d9 ||
|
||||||
|
!GetProcAddress(d3d9, MAKEINTRESOURCEA(register_annotation)) ||
|
||||||
|
!GetProcAddress(d3d9, MAKEINTRESOURCEA(unregister_annotation))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// log once
|
||||||
|
static std::atomic_bool logged = false;
|
||||||
|
if (!logged.exchange(true, std::memory_order_relaxed)) {
|
||||||
|
log_info("graphics::d3d9", "DXVK detected");
|
||||||
|
deferredlogs::defer_error_messages({
|
||||||
|
"dxvk detected",
|
||||||
|
" Vulkan-based renderer may cause graphical issues or crashes",
|
||||||
|
" it should only be used if necessary on your PC",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool graphics_d3d9_is_dxvk() {
|
||||||
|
return detect_dxvk(libutils::try_module("d3d9.dll"));
|
||||||
|
}
|
||||||
|
|
||||||
static IDirect3D9 *WINAPI Direct3DCreate9_hook(UINT SDKVersion) {
|
static IDirect3D9 *WINAPI Direct3DCreate9_hook(UINT SDKVersion) {
|
||||||
log_misc("graphics::d3d9", "Direct3DCreate9 hook hit");
|
log_misc("graphics::d3d9", "Direct3DCreate9 hook hit");
|
||||||
|
graphics_d3d9_is_dxvk();
|
||||||
|
|
||||||
// remove hook
|
// remove hook
|
||||||
if (D3D9_DIRECT3D_CREATE9_ADR) {
|
if (D3D9_DIRECT3D_CREATE9_ADR) {
|
||||||
@@ -330,6 +359,7 @@ static IDirect3D9 *WINAPI Direct3DCreate9_hook(UINT SDKVersion) {
|
|||||||
|
|
||||||
static HRESULT WINAPI Direct3DCreate9Ex_hook(UINT SDKVersion, IDirect3D9Ex **d3d9ex) {
|
static HRESULT WINAPI Direct3DCreate9Ex_hook(UINT SDKVersion, IDirect3D9Ex **d3d9ex) {
|
||||||
log_misc("graphics::d3d9", "Direct3DCreate9Ex hook hit");
|
log_misc("graphics::d3d9", "Direct3DCreate9Ex hook hit");
|
||||||
|
graphics_d3d9_is_dxvk();
|
||||||
|
|
||||||
// call original
|
// call original
|
||||||
HRESULT result;
|
HRESULT result;
|
||||||
@@ -366,6 +396,7 @@ void graphics_d3d9_init() {
|
|||||||
if (!d3d9) {
|
if (!d3d9) {
|
||||||
log_info("graphics::d3d9", "skipping inline hooks");
|
log_info("graphics::d3d9", "skipping inline hooks");
|
||||||
} else {
|
} else {
|
||||||
|
detect_dxvk(d3d9);
|
||||||
|
|
||||||
// 9 on 12
|
// 9 on 12
|
||||||
Direct3DCreate9On12_orig = (Direct3DCreate9On12_t) libutils::try_proc(d3d9, "Direct3DCreate9On12");
|
Direct3DCreate9On12_orig = (Direct3DCreate9On12_t) libutils::try_proc(d3d9, "Direct3DCreate9On12");
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ static const GUID IID_WrappedIDirect3D9 = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void graphics_d3d9_init();
|
void graphics_d3d9_init();
|
||||||
|
bool graphics_d3d9_is_dxvk();
|
||||||
void graphics_d3d9_on_present(
|
void graphics_d3d9_on_present(
|
||||||
HWND hFocusWindow,
|
HWND hFocusWindow,
|
||||||
IDirect3DDevice9 *device,
|
IDirect3DDevice9 *device,
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <climits>
|
#include <climits>
|
||||||
|
#include <cmath>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -1088,6 +1089,76 @@ static float topSurface_aspect_ratio = 1.f;
|
|||||||
static UINT backbuffer_width = 0;
|
static UINT backbuffer_width = 0;
|
||||||
static UINT backbuffer_height = 0;
|
static UINT backbuffer_height = 0;
|
||||||
|
|
||||||
|
static RECT compute_split_src_rect(
|
||||||
|
const RECT &origin_rect,
|
||||||
|
LONG player_width,
|
||||||
|
LONG player_height,
|
||||||
|
bool is_right_source,
|
||||||
|
const cfg::split_region_setting ®ion) {
|
||||||
|
float w_new = static_cast<float>(player_width) / region.scale_x;
|
||||||
|
float h_new = static_cast<float>(player_height) / region.scale_y;
|
||||||
|
|
||||||
|
const float max_w = static_cast<float>(topSurface_width);
|
||||||
|
const float max_h = static_cast<float>(topSurface_height);
|
||||||
|
|
||||||
|
if (region.keep_aspect_ratio) {
|
||||||
|
const float limit = std::min({1.0f, max_w / w_new, max_h / h_new});
|
||||||
|
w_new *= limit;
|
||||||
|
h_new *= limit;
|
||||||
|
} else {
|
||||||
|
w_new = std::min(w_new, max_w);
|
||||||
|
h_new = std::min(h_new, max_h);
|
||||||
|
}
|
||||||
|
|
||||||
|
const LONG src_w = std::clamp<LONG>(
|
||||||
|
static_cast<LONG>(std::lround(w_new)), 1, static_cast<LONG>(topSurface_width));
|
||||||
|
const LONG src_h = std::clamp<LONG>(
|
||||||
|
static_cast<LONG>(std::lround(h_new)), 1, static_cast<LONG>(topSurface_height));
|
||||||
|
|
||||||
|
const float anchor_x = is_right_source
|
||||||
|
? (static_cast<float>(origin_rect.right) - static_cast<float>(player_width) * 0.5f)
|
||||||
|
: (static_cast<float>(origin_rect.left) + static_cast<float>(player_width) * 0.5f);
|
||||||
|
const float anchor_y =
|
||||||
|
(static_cast<float>(origin_rect.top) + static_cast<float>(origin_rect.bottom)) * 0.5f;
|
||||||
|
|
||||||
|
// widen before applying offsets so even extreme settings stay within the surface
|
||||||
|
const auto left = static_cast<int64_t>(std::lround(anchor_x - src_w * 0.5f)) - region.offset_x;
|
||||||
|
const auto top = static_cast<int64_t>(std::lround(anchor_y - src_h * 0.5f)) - region.offset_y;
|
||||||
|
const auto x = static_cast<LONG>(std::clamp<int64_t>(left, 0, topSurface_width - src_w));
|
||||||
|
const auto y = static_cast<LONG>(std::clamp<int64_t>(top, 0, topSurface_height - src_h));
|
||||||
|
return {x, y, x + src_w, y + src_h};
|
||||||
|
}
|
||||||
|
|
||||||
|
static void draw_split_region(
|
||||||
|
IDirect3DDevice9 *device, const RECT &src, const RECT &dest,
|
||||||
|
D3DTEXTUREFILTERTYPE filter, const char *player) {
|
||||||
|
if (device->StretchRect(topSurface, &src, backbuffer, &dest, filter) != D3D_OK) {
|
||||||
|
log_warning(
|
||||||
|
"graphics::d3d9",
|
||||||
|
"SurfaceHook - StretchRect split {} failed, src: {} {} {} {}, dst: {} {} {} {}",
|
||||||
|
player, src.left, src.top, src.right, src.bottom,
|
||||||
|
dest.left, dest.top, dest.right, dest.bottom);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void draw_split_screen(
|
||||||
|
IDirect3DDevice9 *device, const RECT &origin, LONG width, LONG height,
|
||||||
|
const cfg::split_screen_setting &split, D3DTEXTUREFILTERTYPE filter) {
|
||||||
|
const LONG left_width = std::clamp<LONG>(
|
||||||
|
std::lround(static_cast<float>(width) * split.ratio), 1, width - 1);
|
||||||
|
const LONG right_width = width - left_width;
|
||||||
|
const RECT left_src = compute_split_src_rect(origin, left_width, height, false, split.left);
|
||||||
|
const RECT right_src = compute_split_src_rect(origin, right_width, height, true, split.right);
|
||||||
|
|
||||||
|
// move each viewport with its original width, without changing its source crop
|
||||||
|
const LONG left_x = split.swap_sides ? right_width : 0;
|
||||||
|
const LONG right_x = split.swap_sides ? 0 : left_width;
|
||||||
|
const RECT left_dest {left_x, 0, left_x + left_width, height};
|
||||||
|
const RECT right_dest {right_x, 0, right_x + right_width, height};
|
||||||
|
draw_split_region(device, left_src, left_dest, filter, "1P");
|
||||||
|
draw_split_region(device, right_src, right_dest, filter, "2P");
|
||||||
|
}
|
||||||
|
|
||||||
void SurfaceHook(IDirect3DDevice9 *pReal) {
|
void SurfaceHook(IDirect3DDevice9 *pReal) {
|
||||||
|
|
||||||
// phase 0 - create a surface that has the same aspect ratio as the original back buffer
|
// phase 0 - create a surface that has the same aspect ratio as the original back buffer
|
||||||
@@ -1121,7 +1192,12 @@ void SurfaceHook(IDirect3DDevice9 *pReal) {
|
|||||||
"graphics::d3d9", "SurfaceHook - Backbuffer: {} {} {}",
|
"graphics::d3d9", "SurfaceHook - Backbuffer: {} {} {}",
|
||||||
param.BackBufferWidth, param.BackBufferHeight, param.BackBufferCount);
|
param.BackBufferWidth, param.BackBufferHeight, param.BackBufferCount);
|
||||||
|
|
||||||
|
if (tex) {
|
||||||
tex->GetSurfaceLevel(0, &topSurface);
|
tex->GetSurfaceLevel(0, &topSurface);
|
||||||
|
}
|
||||||
|
if (topSurface) {
|
||||||
|
pReal->ColorFill(topSurface, nullptr, D3DCOLOR_XRGB(0, 0, 0));
|
||||||
|
}
|
||||||
if (swapChain->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &backbuffer) != D3D_OK) {
|
if (swapChain->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &backbuffer) != D3D_OK) {
|
||||||
log_warning("graphics::d3d9", "SurfaceHook - GetBackBuffer failed");
|
log_warning("graphics::d3d9", "SurfaceHook - GetBackBuffer failed");
|
||||||
}
|
}
|
||||||
@@ -1129,19 +1205,35 @@ void SurfaceHook(IDirect3DDevice9 *pReal) {
|
|||||||
swapChain->Release();
|
swapChain->Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!topSurface || !backbuffer) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// pre-calculate dimensions used for phase 1
|
// pre-calculate dimensions used for phase 1
|
||||||
const int rectLeft = backbuffer_width;
|
const int rectLeft = backbuffer_width;
|
||||||
const int rectTop = backbuffer_height;
|
const int rectTop = backbuffer_height;
|
||||||
const int w = backbuffer_width;
|
const int w = backbuffer_width;
|
||||||
const int h = backbuffer_height;
|
const int h = backbuffer_height;
|
||||||
|
|
||||||
|
const auto &resize = *cfg::SCREENRESIZE;
|
||||||
|
const auto &scene = resize.scene_settings[resize.screen_resize_current_scene];
|
||||||
|
const bool use_split_mode = resize.enable_screen_resize && scene.split.enabled &&
|
||||||
|
w >= 2 && h >= 1;
|
||||||
|
|
||||||
|
const auto effective_duplicate =
|
||||||
|
(resize.enable_screen_resize && !use_split_mode)
|
||||||
|
? scene.duplicate
|
||||||
|
: cfg::ScreenDuplicateMode::None;
|
||||||
|
|
||||||
// this code used to clear the surface using ColorFill on every call, but
|
// this code used to clear the surface using ColorFill on every call, but
|
||||||
// this turned out to be very expensive, leading to major frame drops in
|
// this turned out to be very expensive, leading to major frame drops in
|
||||||
// SDVX Live2D scenario
|
// SDVX Live2D scenario
|
||||||
if (cfg::SCREENRESIZE->need_surface_clean) {
|
static auto last_duplicate_mode = cfg::ScreenDuplicateMode::None;
|
||||||
|
if (cfg::SCREENRESIZE->need_surface_clean || last_duplicate_mode != effective_duplicate) {
|
||||||
pReal->ColorFill(topSurface, nullptr, D3DCOLOR_XRGB(0, 0, 0));
|
pReal->ColorFill(topSurface, nullptr, D3DCOLOR_XRGB(0, 0, 0));
|
||||||
cfg::SCREENRESIZE->need_surface_clean = false;
|
cfg::SCREENRESIZE->need_surface_clean = false;
|
||||||
}
|
}
|
||||||
|
last_duplicate_mode = effective_duplicate;
|
||||||
|
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
@@ -1167,18 +1259,15 @@ void SurfaceHook(IDirect3DDevice9 *pReal) {
|
|||||||
|
|
||||||
bool duplicate = false;
|
bool duplicate = false;
|
||||||
RECT originRect2 = originRect;
|
RECT originRect2 = originRect;
|
||||||
if (cfg::SCREENRESIZE->enable_screen_resize) {
|
if (effective_duplicate == cfg::ScreenDuplicateMode::CopyLeft) {
|
||||||
auto& scene = cfg::SCREENRESIZE->scene_settings[cfg::SCREENRESIZE->screen_resize_current_scene];
|
|
||||||
if (scene.duplicate == cfg::ScreenDuplicateMode::CopyLeft) {
|
|
||||||
duplicate = true;
|
duplicate = true;
|
||||||
originRect2.right = originRect.left;
|
originRect2.right = originRect.left;
|
||||||
originRect2.left = (LONG)(originRect2.left - (originRect.right - originRect.left));
|
originRect2.left = (LONG)(originRect2.left - (originRect.right - originRect.left));
|
||||||
} else if (scene.duplicate == cfg::ScreenDuplicateMode::CopyRight) {
|
} else if (effective_duplicate == cfg::ScreenDuplicateMode::CopyRight) {
|
||||||
duplicate = true;
|
duplicate = true;
|
||||||
originRect2.left = originRect.right;
|
originRect2.left = originRect.right;
|
||||||
originRect2.right = (LONG)(originRect2.left + (originRect.right - originRect.left));
|
originRect2.right = (LONG)(originRect2.left + (originRect.right - originRect.left));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// log_misc(
|
// log_misc(
|
||||||
// "graphics::d3d9", "originRect: {} {} {} {}",
|
// "graphics::d3d9", "originRect: {} {} {} {}",
|
||||||
@@ -1207,6 +1296,14 @@ void SurfaceHook(IDirect3DDevice9 *pReal) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const bool use_linear_filter = !resize.enable_screen_resize || resize.enable_linear_filter;
|
||||||
|
const auto filter = use_linear_filter ? D3DTEXF_LINEAR : D3DTEXF_NONE;
|
||||||
|
|
||||||
|
if (use_split_mode) {
|
||||||
|
draw_split_screen(pReal, originRect, w, h, scene.split, filter);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// phase 2 - viewport calculation - do the actual zoom / offset math
|
// phase 2 - viewport calculation - do the actual zoom / offset math
|
||||||
// figure out what region of the surface to copy back to the back buffer.
|
// figure out what region of the surface to copy back to the back buffer.
|
||||||
RECT targetRect {
|
RECT targetRect {
|
||||||
@@ -1215,8 +1312,7 @@ void SurfaceHook(IDirect3DDevice9 *pReal) {
|
|||||||
(LONG)(rectLeft + w),
|
(LONG)(rectLeft + w),
|
||||||
(LONG)(rectTop + h),
|
(LONG)(rectTop + h),
|
||||||
};
|
};
|
||||||
if (cfg::SCREENRESIZE->enable_screen_resize) {
|
if (resize.enable_screen_resize) {
|
||||||
auto& scene = cfg::SCREENRESIZE->scene_settings[cfg::SCREENRESIZE->screen_resize_current_scene];
|
|
||||||
auto w_new = w / scene.scale_x;
|
auto w_new = w / scene.scale_x;
|
||||||
auto h_new = h / scene.scale_y;
|
auto h_new = h / scene.scale_y;
|
||||||
|
|
||||||
@@ -1280,14 +1376,10 @@ void SurfaceHook(IDirect3DDevice9 *pReal) {
|
|||||||
// targetRect.left, targetRect.top, targetRect.right, targetRect.bottom);
|
// targetRect.left, targetRect.top, targetRect.right, targetRect.bottom);
|
||||||
|
|
||||||
// phase 3 - draw the surface to back buffer
|
// phase 3 - draw the surface to back buffer
|
||||||
bool use_linear_filter = true;
|
|
||||||
if (cfg::SCREENRESIZE->enable_screen_resize) {
|
|
||||||
use_linear_filter = cfg::SCREENRESIZE->enable_linear_filter;
|
|
||||||
}
|
|
||||||
hr = pReal->StretchRect(
|
hr = pReal->StretchRect(
|
||||||
topSurface, &targetRect,
|
topSurface, &targetRect,
|
||||||
backbuffer, nullptr,
|
backbuffer, nullptr,
|
||||||
use_linear_filter ? D3DTEXF_LINEAR : D3DTEXF_NONE);
|
filter);
|
||||||
if (hr != D3D_OK) {
|
if (hr != D3D_OK) {
|
||||||
log_warning(
|
log_warning(
|
||||||
"graphics::d3d9",
|
"graphics::d3d9",
|
||||||
|
|||||||
@@ -82,6 +82,7 @@
|
|||||||
#include "hooks/audio/backends/wasapi/downmix.h"
|
#include "hooks/audio/backends/wasapi/downmix.h"
|
||||||
#include "hooks/debughook.h"
|
#include "hooks/debughook.h"
|
||||||
#include "hooks/devicehook.h"
|
#include "hooks/devicehook.h"
|
||||||
|
#include "hooks/eventlog.h"
|
||||||
#include "hooks/graphics/nvenc_hook.h"
|
#include "hooks/graphics/nvenc_hook.h"
|
||||||
#include "hooks/input/dinput8/hook.h"
|
#include "hooks/input/dinput8/hook.h"
|
||||||
#include "hooks/graphics/graphics.h"
|
#include "hooks/graphics/graphics.h"
|
||||||
@@ -1485,6 +1486,9 @@ int main_implementation(int argc, char *argv[]) {
|
|||||||
if (options[launcher::Options::CCJMouseTrackballWithToggle].value_bool()) {
|
if (options[launcher::Options::CCJMouseTrackballWithToggle].value_bool()) {
|
||||||
games::ccj::MOUSE_TRACKBALL_USE_TOGGLE = true;
|
games::ccj::MOUSE_TRACKBALL_USE_TOGGLE = true;
|
||||||
}
|
}
|
||||||
|
if (options[launcher::Options::BCArgs].is_active()) {
|
||||||
|
games::bc::BC_INJECT_ARGS = options[launcher::Options::BCArgs].value_text();
|
||||||
|
}
|
||||||
if (options[launcher::Options::CCJArgs].is_active()) {
|
if (options[launcher::Options::CCJArgs].is_active()) {
|
||||||
games::ccj::CCJ_INJECT_ARGS = options[launcher::Options::CCJArgs].value_text();
|
games::ccj::CCJ_INJECT_ARGS = options[launcher::Options::CCJArgs].value_text();
|
||||||
}
|
}
|
||||||
@@ -2706,6 +2710,7 @@ int main_implementation(int argc, char *argv[]) {
|
|||||||
|
|
||||||
// load game
|
// load game
|
||||||
avs::game::load_dll();
|
avs::game::load_dll();
|
||||||
|
hooks::eventlog::init(avs::game::DLL_INSTANCE);
|
||||||
|
|
||||||
// attach games
|
// attach games
|
||||||
for (auto game : games) {
|
for (auto game : games) {
|
||||||
|
|||||||
@@ -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",
|
||||||
@@ -842,6 +846,21 @@ static const std::vector<OptionDefinition> OPTION_DEFINITIONS = std::invoke([]()
|
|||||||
.game_name = "Beatmania IIDX",
|
.game_name = "Beatmania IIDX",
|
||||||
.category = "Game Overlay",
|
.category = "Game Overlay",
|
||||||
};
|
};
|
||||||
|
c[launcher::Options::IIDXNoDxva2] = {
|
||||||
|
.title = "IIDX Disable DXVA2 Decoder",
|
||||||
|
.name = "iidxnodxva2",
|
||||||
|
.desc =
|
||||||
|
"Forcibly disables the DXVA2 decoder, causing the game to use the software decoder instead "
|
||||||
|
"on some versions of IIDX",
|
||||||
|
.type = OptionType::Enum,
|
||||||
|
.game_name = "Beatmania IIDX",
|
||||||
|
.category = "Advanced Game Options",
|
||||||
|
.elements = {
|
||||||
|
{"auto", ""},
|
||||||
|
{"on", ""},
|
||||||
|
{"off", ""},
|
||||||
|
},
|
||||||
|
};
|
||||||
c[launcher::Options::LoadSoundVoltexModule] = {
|
c[launcher::Options::LoadSoundVoltexModule] = {
|
||||||
.title = "Force Load Sound Voltex Module",
|
.title = "Force Load Sound Voltex Module",
|
||||||
.name = "sdvx",
|
.name = "sdvx",
|
||||||
@@ -2362,6 +2381,15 @@ static const std::vector<OptionDefinition> OPTION_DEFINITIONS = std::invoke([]()
|
|||||||
{"all", "basic + HID devices"},
|
{"all", "basic + HID devices"},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
c[launcher::Options::BCArgs] = {
|
||||||
|
.title = "BC Arguments Override",
|
||||||
|
.name = "bcargs",
|
||||||
|
.desc = "Command line arguments passed to the game.",
|
||||||
|
.type = OptionType::Text,
|
||||||
|
.setting_name = "",
|
||||||
|
.game_name = "Busou Shinki: Armored Princess Battle Conductor",
|
||||||
|
.category = "Advanced Game Options",
|
||||||
|
};
|
||||||
c[launcher::Options::QKSArgs] = {
|
c[launcher::Options::QKSArgs] = {
|
||||||
.title = "QKS Arguments Override",
|
.title = "QKS Arguments Override",
|
||||||
.name = "qksargs",
|
.name = "qksargs",
|
||||||
@@ -3554,6 +3582,7 @@ std::unique_ptr<std::vector<Option>> launcher::parse_options(int argc, char *arg
|
|||||||
// validate it is an integer
|
// validate it is an integer
|
||||||
try {
|
try {
|
||||||
auto _ = std::stoull(argv[i], nullptr, 16);
|
auto _ = std::stoull(argv[i], nullptr, 16);
|
||||||
|
option.value_add(argv[i]);
|
||||||
} catch (const std::exception &ex) {
|
} catch (const std::exception &ex) {
|
||||||
log_fatal("options", "parameter for -{} is not a hex number: {}", alias, argv[i]);
|
log_fatal("options", "parameter for -{} is not a hex number: {}", alias, argv[i]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,6 +83,7 @@ namespace launcher {
|
|||||||
spice2x_IIDXLEDColor,
|
spice2x_IIDXLEDColor,
|
||||||
spice2x_IIDXLEDPos,
|
spice2x_IIDXLEDPos,
|
||||||
IIDXLEDBorderless,
|
IIDXLEDBorderless,
|
||||||
|
IIDXNoDxva2,
|
||||||
LoadSoundVoltexModule,
|
LoadSoundVoltexModule,
|
||||||
SDVXForce720p,
|
SDVXForce720p,
|
||||||
SDVXPrinterEmulation,
|
SDVXPrinterEmulation,
|
||||||
@@ -241,6 +242,7 @@ namespace launcher {
|
|||||||
DisableAvsCache,
|
DisableAvsCache,
|
||||||
OutputPEB,
|
OutputPEB,
|
||||||
DumpSystemInfo,
|
DumpSystemInfo,
|
||||||
|
BCArgs,
|
||||||
QKSArgs,
|
QKSArgs,
|
||||||
CCJArgs,
|
CCJArgs,
|
||||||
CCJMouseTrackball,
|
CCJMouseTrackball,
|
||||||
|
|||||||
+44
-73
@@ -155,7 +155,8 @@ namespace nvapi {
|
|||||||
log_misc("nvapi", "NVAPI module initialized");
|
log_misc("nvapi", "NVAPI module initialized");
|
||||||
}
|
}
|
||||||
|
|
||||||
NvAPI_Status create_profile_if_needed(NvDRSSessionHandle h_session, NvDRSProfileHandle *h_profile) {
|
static NvAPI_Status create_profile_if_needed(NvDRSSessionHandle h_session,
|
||||||
|
NvDRSProfileHandle *h_profile, bool &changed) {
|
||||||
NvAPI_UnicodeString app_name;
|
NvAPI_UnicodeString app_name;
|
||||||
#ifdef SPICE64
|
#ifdef SPICE64
|
||||||
memcpy_s(app_name, sizeof(app_name), L"spice64.exe", 12 * sizeof(wchar_t));
|
memcpy_s(app_name, sizeof(app_name), L"spice64.exe", 12 * sizeof(wchar_t));
|
||||||
@@ -203,57 +204,38 @@ namespace nvapi {
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
changed = true;
|
||||||
return NVAPI_OK;
|
return NVAPI_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NvAPI_Status set_gpu_power_state(NvDRSSessionHandle h_session, NvDRSProfileHandle h_profile) {
|
static void apply_dword_setting(NvDRSSessionHandle session, NvDRSProfileHandle profile,
|
||||||
auto drs_setting = NVDRS_SETTING {};
|
NvU32 id, NvU32 value, const char *name, bool &changed) {
|
||||||
drs_setting.version = NVDRS_SETTING_VER;
|
NVDRS_SETTING setting {};
|
||||||
drs_setting.settingId = PREFERRED_PSTATE_ID;
|
setting.version = NVDRS_SETTING_VER;
|
||||||
drs_setting.settingType = NVDRS_DWORD_TYPE;
|
auto status = NvAPI_DRS_GetSetting(session, profile, id, &setting);
|
||||||
drs_setting.u32PredefinedValue = PREFERRED_PSTATE_PREFER_MAX;
|
if (status == NVAPI_OK) {
|
||||||
drs_setting.u32CurrentValue = PREFERRED_PSTATE_PREFER_MAX;
|
// an inherited or predefined value is not an explicit application override
|
||||||
return NvAPI_DRS_SetSetting(h_session, h_profile, &drs_setting);
|
if (setting.settingLocation == NVDRS_CURRENT_PROFILE_LOCATION &&
|
||||||
|
!setting.isCurrentPredefined && setting.settingType == NVDRS_DWORD_TYPE &&
|
||||||
|
setting.u32CurrentValue == value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else if (status != NVAPI_SETTING_NOT_FOUND) {
|
||||||
|
log_warning("nvapi", "could not read {}: {}", name, get_error_message(status));
|
||||||
}
|
}
|
||||||
|
|
||||||
NvAPI_Status set_gsync_mode(NvDRSSessionHandle h_session, NvDRSProfileHandle h_profile) {
|
setting = {};
|
||||||
auto drs_setting = NVDRS_SETTING {};
|
setting.version = NVDRS_SETTING_VER;
|
||||||
drs_setting.version = NVDRS_SETTING_VER;
|
setting.settingId = id;
|
||||||
drs_setting.settingId = VRR_APP_OVERRIDE_ID;
|
setting.settingType = NVDRS_DWORD_TYPE;
|
||||||
drs_setting.settingType = NVDRS_DWORD_TYPE;
|
setting.u32PredefinedValue = value;
|
||||||
drs_setting.u32PredefinedValue = VRR_APP_OVERRIDE_FIXED_REFRESH;
|
setting.u32CurrentValue = value;
|
||||||
drs_setting.u32CurrentValue = VRR_APP_OVERRIDE_FIXED_REFRESH;
|
status = NvAPI_DRS_SetSetting(session, profile, &setting);
|
||||||
return NvAPI_DRS_SetSetting(h_session, h_profile, &drs_setting);
|
if (status == NVAPI_OK) {
|
||||||
|
changed = true;
|
||||||
|
} else {
|
||||||
|
log_warning("nvapi", "could not set {}: {}", name, get_error_message(status));
|
||||||
}
|
}
|
||||||
|
|
||||||
NvAPI_Status set_vsync_mode(NvDRSSessionHandle h_session, NvDRSProfileHandle h_profile) {
|
|
||||||
auto drs_setting = NVDRS_SETTING {};
|
|
||||||
drs_setting.version = NVDRS_SETTING_VER;
|
|
||||||
drs_setting.settingId = VSYNCMODE_ID;
|
|
||||||
drs_setting.settingType = NVDRS_DWORD_TYPE;
|
|
||||||
drs_setting.u32PredefinedValue = VSYNCMODE_PASSIVE;
|
|
||||||
drs_setting.u32CurrentValue = VSYNCMODE_PASSIVE;
|
|
||||||
return NvAPI_DRS_SetSetting(h_session, h_profile, &drs_setting);
|
|
||||||
}
|
|
||||||
|
|
||||||
NvAPI_Status set_refresh_rate(NvDRSSessionHandle h_session, NvDRSProfileHandle h_profile) {
|
|
||||||
auto drs_setting = NVDRS_SETTING {};
|
|
||||||
drs_setting.version = NVDRS_SETTING_VER;
|
|
||||||
drs_setting.settingId = REFRESH_RATE_OVERRIDE_ID;
|
|
||||||
drs_setting.settingType = NVDRS_DWORD_TYPE;
|
|
||||||
drs_setting.u32PredefinedValue = REFRESH_RATE_OVERRIDE_APPLICATION_CONTROLLED;
|
|
||||||
drs_setting.u32CurrentValue = REFRESH_RATE_OVERRIDE_APPLICATION_CONTROLLED;
|
|
||||||
return NvAPI_DRS_SetSetting(h_session, h_profile, &drs_setting);
|
|
||||||
}
|
|
||||||
|
|
||||||
NvAPI_Status set_max_fps(NvDRSSessionHandle h_session, NvDRSProfileHandle h_profile) {
|
|
||||||
auto drs_setting = NVDRS_SETTING {};
|
|
||||||
drs_setting.version = NVDRS_SETTING_VER;
|
|
||||||
drs_setting.settingId = FRL_FPS_ID;
|
|
||||||
drs_setting.settingType = NVDRS_DWORD_TYPE;
|
|
||||||
drs_setting.u32PredefinedValue = FRL_FPS_DISABLED;
|
|
||||||
drs_setting.u32CurrentValue = FRL_FPS_DISABLED;
|
|
||||||
return NvAPI_DRS_SetSetting(h_session, h_profile, &drs_setting);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_profile_settings() {
|
void set_profile_settings() {
|
||||||
@@ -278,41 +260,30 @@ namespace nvapi {
|
|||||||
|
|
||||||
NvDRSProfileHandle h_profile = nullptr;
|
NvDRSProfileHandle h_profile = nullptr;
|
||||||
log_info("nvapi", "creating NVIDIA profile for spice(64).exe...");
|
log_info("nvapi", "creating NVIDIA profile for spice(64).exe...");
|
||||||
if (create_profile_if_needed(h_session, &h_profile) != NVAPI_OK) {
|
bool changed = false;
|
||||||
|
if (create_profile_if_needed(h_session, &h_profile, changed) != NVAPI_OK) {
|
||||||
NvAPI_DRS_DestroySession(h_session);
|
NvAPI_DRS_DestroySession(h_session);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
log_info("nvapi", "setting VSync to Application Controlled...");
|
apply_dword_setting(h_session, h_profile, VSYNCMODE_ID, VSYNCMODE_PASSIVE,
|
||||||
if ((status = set_vsync_mode(h_session, h_profile)) != NVAPI_OK) {
|
"VSync mode", changed);
|
||||||
log_warning("nvapi", "could not set VSync mode: {}", get_error_message(status));
|
apply_dword_setting(h_session, h_profile, PREFERRED_PSTATE_ID, PREFERRED_PSTATE_PREFER_MAX,
|
||||||
}
|
"preferred PState", changed);
|
||||||
|
apply_dword_setting(h_session, h_profile, VRR_APP_OVERRIDE_ID, VRR_APP_OVERRIDE_FIXED_REFRESH,
|
||||||
log_info("nvapi", "applying preferred PState to Maximum Performance...");
|
"G-SYNC mode", changed);
|
||||||
if ((status = set_gpu_power_state(h_session, h_profile)) != NVAPI_OK) {
|
apply_dword_setting(h_session, h_profile, REFRESH_RATE_OVERRIDE_ID,
|
||||||
log_warning("nvapi", "could not set preferred PState: {}", get_error_message(status));
|
REFRESH_RATE_OVERRIDE_APPLICATION_CONTROLLED, "preferred refresh rate", changed);
|
||||||
}
|
apply_dword_setting(h_session, h_profile, FRL_FPS_ID, FRL_FPS_DISABLED,
|
||||||
|
"max framerate", changed);
|
||||||
log_info("nvapi", "disabling G-SYNC...");
|
|
||||||
if ((status = set_gsync_mode(h_session, h_profile)) != NVAPI_OK) {
|
|
||||||
log_warning("nvapi", "could not set G-Sync mode: {}", get_error_message(status));
|
|
||||||
}
|
|
||||||
|
|
||||||
log_info("nvapi", "setting preferred refresh rate to Application Controlled...");
|
|
||||||
if ((status = set_refresh_rate(h_session, h_profile)) != NVAPI_OK) {
|
|
||||||
log_warning("nvapi", "could not set preferred refresh rate: {}", get_error_message(status));
|
|
||||||
}
|
|
||||||
|
|
||||||
log_info("nvapi", "disabling max framerate...");
|
|
||||||
if ((status = set_max_fps(h_session, h_profile)) != NVAPI_OK) {
|
|
||||||
log_warning("nvapi", "could not disable max framerate: {}", get_error_message(status));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (changed) {
|
||||||
log_info("nvapi", "saving settings for DRS session...");
|
log_info("nvapi", "saving settings for DRS session...");
|
||||||
if ((status = NvAPI_DRS_SaveSettings(h_session)) != NVAPI_OK) {
|
if ((status = NvAPI_DRS_SaveSettings(h_session)) != NVAPI_OK) {
|
||||||
log_warning("nvapi", "could not save driver settings: {}", get_error_message(status));
|
log_warning("nvapi", "could not save driver settings: {}", get_error_message(status));
|
||||||
NvAPI_DRS_DestroySession(h_session);
|
}
|
||||||
return;
|
} else {
|
||||||
|
log_misc("nvapi", "no driver profile changes to save");
|
||||||
}
|
}
|
||||||
|
|
||||||
log_info("nvapi", "destroying DRS session...");
|
log_info("nvapi", "destroying DRS session...");
|
||||||
|
|||||||
@@ -5282,10 +5282,17 @@ 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()) {
|
||||||
|
// 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;
|
this->options_dirty = true;
|
||||||
option.value = buffer;
|
option.value = std::move(value);
|
||||||
::Config::getInstance().updateBinding(games_list[games_selected], option);
|
::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());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
#include <algorithm>
|
||||||
|
#include <climits>
|
||||||
|
|
||||||
#include <games/io.h>
|
#include <games/io.h>
|
||||||
|
|
||||||
#include "screen_resize.h"
|
#include "screen_resize.h"
|
||||||
@@ -55,15 +58,10 @@ namespace overlay::windows {
|
|||||||
cfg::SCREENRESIZE->enable_screen_resize = false;
|
cfg::SCREENRESIZE->enable_screen_resize = false;
|
||||||
cfg::SCREENRESIZE->screen_resize_current_scene = 0;
|
cfg::SCREENRESIZE->screen_resize_current_scene = 0;
|
||||||
cfg::SCREENRESIZE->enable_linear_filter = true;
|
cfg::SCREENRESIZE->enable_linear_filter = true;
|
||||||
for (size_t i = 0; i < std::size(cfg::SCREENRESIZE->scene_settings); i++) {
|
for (auto &scene : cfg::SCREENRESIZE->scene_settings) {
|
||||||
auto& scene = cfg::SCREENRESIZE->scene_settings[i];
|
scene = {};
|
||||||
scene.keep_aspect_ratio = true;
|
|
||||||
scene.offset_x = 0;
|
|
||||||
scene.offset_y = 0;
|
|
||||||
scene.scale_x = 1.f;
|
|
||||||
scene.scale_y = 1.f;
|
|
||||||
scene.duplicate = cfg::ScreenDuplicateMode::None;
|
|
||||||
}
|
}
|
||||||
|
cfg::SCREENRESIZE->need_surface_clean = true;
|
||||||
|
|
||||||
cfg::SCREENRESIZE->enable_window_resize = false;
|
cfg::SCREENRESIZE->enable_window_resize = false;
|
||||||
cfg::SCREENRESIZE->window_always_on_top = false;
|
cfg::SCREENRESIZE->window_always_on_top = false;
|
||||||
@@ -101,6 +99,78 @@ namespace overlay::windows {
|
|||||||
build_footer();
|
build_footer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool split_scale_slider(const char *label, float &scale) {
|
||||||
|
return ImGui::SliderFloat(
|
||||||
|
label, &scale, cfg::split_region_setting::min_scale,
|
||||||
|
cfg::split_region_setting::max_scale, "%.3f", ImGuiSliderFlags_AlwaysClamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void build_split_region_config(const char *label, cfg::split_region_setting ®ion) {
|
||||||
|
if (!ImGui::TreeNodeEx(label, ImGuiTreeNodeFlags_DefaultOpen)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ImGui::InputInt("X Offset", ®ion.offset_x);
|
||||||
|
ImGui::InputInt("Y Offset", ®ion.offset_y);
|
||||||
|
|
||||||
|
if (ImGui::Checkbox("Keep Aspect Ratio", ®ion.keep_aspect_ratio) &&
|
||||||
|
region.keep_aspect_ratio) {
|
||||||
|
region.scale_y = region.scale_x;
|
||||||
|
}
|
||||||
|
if (region.keep_aspect_ratio) {
|
||||||
|
if (split_scale_slider("Scale", region.scale_x)) {
|
||||||
|
region.scale_y = region.scale_x;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
split_scale_slider("Width Scale", region.scale_x);
|
||||||
|
split_scale_slider("Height Scale", region.scale_y);
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::TreePop();
|
||||||
|
}
|
||||||
|
|
||||||
|
static cfg::split_region_setting mirror_split_region(cfg::split_region_setting region) {
|
||||||
|
region.offset_x = static_cast<int>(
|
||||||
|
std::min<int64_t>(-static_cast<int64_t>(region.offset_x), INT_MAX));
|
||||||
|
return region;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void build_split_config(cfg::split_screen_setting &split) {
|
||||||
|
float divider = split.swap_sides ? 1.0f - split.ratio : split.ratio;
|
||||||
|
if (ImGui::SliderFloat(
|
||||||
|
"Split Position", ÷r, cfg::split_screen_setting::min_ratio,
|
||||||
|
cfg::split_screen_setting::max_ratio, "%.2f", ImGuiSliderFlags_AlwaysClamp)) {
|
||||||
|
split.ratio = split.swap_sides ? 1.0f - divider : divider;
|
||||||
|
}
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::HelpMarker("Position of the divider from the left edge (0.50 = center).");
|
||||||
|
|
||||||
|
ImGui::Checkbox("Swap Sides", &split.swap_sides);
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::HelpMarker("Swap the playfields without changing their widths, zoom, or offsets.");
|
||||||
|
|
||||||
|
if (ImGui::Button("Mirror 1P -> 2P")) {
|
||||||
|
split.right = mirror_split_region(split.left);
|
||||||
|
}
|
||||||
|
ImGui::SameLine();
|
||||||
|
if (ImGui::Button("Mirror 2P -> 1P")) {
|
||||||
|
split.left = mirror_split_region(split.right);
|
||||||
|
}
|
||||||
|
ImGui::SameLine();
|
||||||
|
if (ImGui::Button("Reset Split")) {
|
||||||
|
split = {};
|
||||||
|
split.enabled = true;
|
||||||
|
}
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::HelpMarker("Mirror copies zoom and offsets, but reverses the X offset.");
|
||||||
|
|
||||||
|
build_split_region_config(split.swap_sides
|
||||||
|
? "1P Playfield (Displayed Right)###split_left"
|
||||||
|
: "1P Playfield (Left)###split_left", split.left);
|
||||||
|
build_split_region_config(split.swap_sides
|
||||||
|
? "2P Playfield (Displayed Left)###split_right"
|
||||||
|
: "2P Playfield (Right)###split_right", split.right);
|
||||||
|
}
|
||||||
|
|
||||||
void ScreenResize::build_fullscreen_config() {
|
void ScreenResize::build_fullscreen_config() {
|
||||||
|
|
||||||
ImGui::TextColored(ImVec4(1, 0.5f, 0.5f, 1.f),
|
ImGui::TextColored(ImVec4(1, 0.5f, 0.5f, 1.f),
|
||||||
@@ -138,6 +208,19 @@ namespace overlay::windows {
|
|||||||
|
|
||||||
auto& scene = cfg::SCREENRESIZE->scene_settings[cfg::SCREENRESIZE->screen_resize_current_scene];
|
auto& scene = cfg::SCREENRESIZE->scene_settings[cfg::SCREENRESIZE->screen_resize_current_scene];
|
||||||
|
|
||||||
|
const bool split_changed =
|
||||||
|
ImGui::Checkbox("Split Screen (Dual Playfield)", &scene.split.enabled);
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::HelpMarker(
|
||||||
|
"Split the screen into independent Left (1P) and Right (2P) zoom viewports, "
|
||||||
|
"allowing separate zoom and offset per playfield (e.g. Battle mode).");
|
||||||
|
if (split_changed) {
|
||||||
|
cfg::SCREENRESIZE->need_surface_clean = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (scene.split.enabled) {
|
||||||
|
build_split_config(scene.split);
|
||||||
|
} else {
|
||||||
// general settings
|
// general settings
|
||||||
ImGui::InputInt("X Offset", &scene.offset_x);
|
ImGui::InputInt("X Offset", &scene.offset_x);
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
@@ -179,14 +262,15 @@ namespace overlay::windows {
|
|||||||
"Show an identical copy of the image on the left or right, allowing you to achieve "
|
"Show an identical copy of the image on the left or right, allowing you to achieve "
|
||||||
"wrap-around effect when an offset is set.");
|
"wrap-around effect when an offset is set.");
|
||||||
|
|
||||||
ImGui::EndDisabled();
|
|
||||||
|
|
||||||
// tell d3d9 device to clear surface to get rid of ghost image
|
// tell d3d9 device to clear surface to get rid of ghost image
|
||||||
if (duplicate_changed) {
|
if (duplicate_changed) {
|
||||||
cfg::SCREENRESIZE->need_surface_clean = true;
|
cfg::SCREENRESIZE->need_surface_clean = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImGui::EndDisabled();
|
||||||
|
}
|
||||||
|
|
||||||
void ScreenResize::build_windowed_config() {
|
void ScreenResize::build_windowed_config() {
|
||||||
// for now, only supports the first window
|
// for now, only supports the first window
|
||||||
const auto window = get_first_window();
|
const auto window = get_first_window();
|
||||||
|
|||||||
@@ -275,7 +275,6 @@ void rawinput::RawInputManager::devices_scan_rawinput(RAWINPUTDEVICELIST *device
|
|||||||
|
|
||||||
// extract information out of name
|
// extract information out of name
|
||||||
auto device_info = rawinput::RawInputManager::get_device_info(device_name);
|
auto device_info = rawinput::RawInputManager::get_device_info(device_name);
|
||||||
auto device_description = rawinput::RawInputManager::rawinput_get_device_description(device_info, device_name);
|
|
||||||
|
|
||||||
// get device information
|
// get device information
|
||||||
RID_DEVICE_INFO rawinput_device_info {};
|
RID_DEVICE_INFO rawinput_device_info {};
|
||||||
@@ -301,15 +300,16 @@ void rawinput::RawInputManager::devices_scan_rawinput(RAWINPUTDEVICELIST *device
|
|||||||
new_device.id = unique_id;
|
new_device.id = unique_id;
|
||||||
new_device.handle = device->hDevice;
|
new_device.handle = device->hDevice;
|
||||||
new_device.name = device_name;
|
new_device.name = device_name;
|
||||||
new_device.desc = device_description;
|
|
||||||
new_device.info = device_info;
|
new_device.info = device_info;
|
||||||
new_device.input_time = get_performance_seconds();
|
new_device.input_time = get_performance_seconds();
|
||||||
switch (device->dwType) {
|
switch (device->dwType) {
|
||||||
case RIM_TYPEMOUSE:
|
case RIM_TYPEMOUSE:
|
||||||
|
new_device.desc = rawinput_get_device_description(device_info, device_name);
|
||||||
new_device.type = MOUSE;
|
new_device.type = MOUSE;
|
||||||
new_device.mouseInfo = new DeviceMouseInfo();
|
new_device.mouseInfo = new DeviceMouseInfo();
|
||||||
break;
|
break;
|
||||||
case RIM_TYPEKEYBOARD:
|
case RIM_TYPEKEYBOARD:
|
||||||
|
new_device.desc = rawinput_get_device_description(device_info, device_name);
|
||||||
new_device.type = KEYBOARD;
|
new_device.type = KEYBOARD;
|
||||||
new_device.keyboardInfo = new DeviceKeyboardInfo();
|
new_device.keyboardInfo = new DeviceKeyboardInfo();
|
||||||
break;
|
break;
|
||||||
@@ -402,13 +402,6 @@ void rawinput::RawInputManager::devices_scan_rawinput(RAWINPUTDEVICELIST *device
|
|||||||
prod_ws = wchar_to_u8(prod_str_buffer);
|
prod_ws = wchar_to_u8(prod_str_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// For Bluetooth LE HID devices (e.g., newer Xbox controllers) HidD_GetProductString
|
|
||||||
// and HidD_GetManufacturerString will return blank strings.
|
|
||||||
// https://docs.microsoft.com/en-us/answers/questions/401236/hidd-getproductstring-with-ble-hid-device.html
|
|
||||||
if (man_ws.empty() && prod_ws.empty()) {
|
|
||||||
prod_ws = device_description;
|
|
||||||
}
|
|
||||||
|
|
||||||
// build desc string
|
// build desc string
|
||||||
std::string desc_ws;
|
std::string desc_ws;
|
||||||
if (string_begins_with(prod_ws, man_ws)) {
|
if (string_begins_with(prod_ws, man_ws)) {
|
||||||
@@ -427,6 +420,12 @@ void rawinput::RawInputManager::devices_scan_rawinput(RAWINPUTDEVICELIST *device
|
|||||||
log_warning("rawinput", "failed to get HID device attributes for {}", device_name);
|
log_warning("rawinput", "failed to get HID device attributes for {}", device_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// For Bluetooth LE HID devices (e.g., newer Xbox controllers) HidD_GetProductString
|
||||||
|
// and HidD_GetManufacturerString will return blank strings.
|
||||||
|
// https://docs.microsoft.com/en-us/answers/questions/401236/hidd-getproductstring-with-ble-hid-device.html
|
||||||
|
if (new_device.desc.empty()) {
|
||||||
|
new_device.desc = rawinput_get_device_description(device_info, device_name);
|
||||||
|
}
|
||||||
|
|
||||||
// get button caps
|
// get button caps
|
||||||
USHORT button_cap_length = caps.NumberInputButtonCaps;
|
USHORT button_cap_length = caps.NumberInputButtonCaps;
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "transform.h"
|
#include "transform.h"
|
||||||
|
|
||||||
|
#include "hooks/graphics/graphics.h"
|
||||||
#include "touch/touch.h"
|
#include "touch/touch.h"
|
||||||
#include "util/logging.h"
|
#include "util/logging.h"
|
||||||
|
|
||||||
@@ -141,6 +142,13 @@ namespace nativetouch::inject {
|
|||||||
end_mouse_contact(window);
|
end_mouse_contact(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SDVX accepts both mouse and touch on its windowed subscreen, causing duplicate input.
|
||||||
|
if (GRAPHICS_WINDOWED &&
|
||||||
|
window == SDVX_SUBSCREEN_WINDOW &&
|
||||||
|
message >= WM_MOUSEFIRST && message <= WM_MOUSELAST) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user