mirror of
https://github.com/spice2x/spice2x.github.io.git
synced 2026-11-30 02:56:42 -08:00
bc: add light support and unity player arguments injection (#932)
## Link to GitHub Issue or related Pull Request, if one exists #0 ## Description of change _Just imitation of the existing implementations of CCJ, MFG or QKS._ - Add BI2X hook and lighting support. - Align Unity launch argument handling and cursor visibility with other Unity games in spice2x using `unity_utils::force_show_cursor` and `unity_utils::set_args`. - Add `-bcargs` command-line option to pass custom arguments directly to the Unity player. - Upgrade I/O initialization to `devicehook_init_trampoline()` and ensure the raw log directory is created recursively. ## Testing - Verified build on GitHub Actions with no compiler warnings. - Tested with the CI compiled executable. - HID lighting worked fine on aic_pico and iidx_pico. - Display arguments such as `-w`, `-windowborder` and `-windowsize` are correctly passed. _(However, once the game launches, it reinitializes the window and switches to fullscreen before the checking phase begins. To maintain these arguments, an additional hook is required. I resolved this issue using a BepInEx plugin.)_
This commit is contained in:
11 files changed
+267
-15
No files matched your search
+28
-14
@@ -1,25 +1,30 @@
|
||||
#include "bc.h"
|
||||
|
||||
#include <format>
|
||||
#include "hooks/setupapihook.h"
|
||||
#include "util/fileutils.h"
|
||||
#include "util/libutils.h"
|
||||
#include "acio2emu/handle.h"
|
||||
#include "acioemu/handle.h"
|
||||
#include "hooks/graphics/graphics.h"
|
||||
#include "util/detour.h"
|
||||
#include "util/unity_player.h"
|
||||
#include "node.h"
|
||||
#include "bi2x_hook.h"
|
||||
|
||||
namespace games::bc {
|
||||
|
||||
static decltype(ShowCursor) *ShowCursor_orig = nullptr;
|
||||
|
||||
static int WINAPI ShowCursor_hook(BOOL bShow) {
|
||||
// log_misc("bsac", "ShowCursor {}", bShow);
|
||||
return 1;
|
||||
}
|
||||
std::string BC_INJECT_ARGS = "";
|
||||
|
||||
void BCGame::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"));
|
||||
|
||||
SETUPAPI_SETTINGS settings {};
|
||||
@@ -32,15 +37,24 @@ namespace games::bc {
|
||||
auto iob = new acio2emu::IOBHandle(L"COM3");
|
||||
iob->register_node(std::make_unique<TBSNode>());
|
||||
|
||||
if (GRAPHICS_SHOW_CURSOR) {
|
||||
detour::trampoline_try(
|
||||
"user32.dll", "ShowCursor",
|
||||
(void*)ShowCursor_hook, (void**)&ShowCursor_orig);
|
||||
}
|
||||
#if SPICE64
|
||||
// insert BI2X hooks
|
||||
bi2x_hook_init();
|
||||
#endif
|
||||
|
||||
devicehook_init();
|
||||
devicehook_init_trampoline();
|
||||
devicehook_add(iob);
|
||||
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() {
|
||||
@@ -48,4 +62,4 @@ namespace games::bc {
|
||||
|
||||
devicehook_dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user