mirror of
https://github.com/spice2x/spice2x.github.io.git
synced 2026-08-01 22:30:42 -07:00
ddr: automatically register codecs on launch (#351)
## Link to GitHub Issue, if one exists #345 ## Description of change On launch of spice.exe / spice64.exe, call `regsvr32` on known codecs in the `com` directory. Add an option to skip this (`-ddrnocodec`) as a chicken bit. ## Testing Tested 32 and 64 bit DDR.
This commit is contained in:
@@ -27,6 +27,7 @@ namespace games::ddr {
|
||||
|
||||
// settings
|
||||
bool SDMODE = false;
|
||||
bool NO_CODEC_REGISTRATION = false;
|
||||
|
||||
uint8_t DDR_TAPELEDS[TAPELED_DEVICE_COUNT][50][3] {};
|
||||
|
||||
@@ -52,6 +53,50 @@ namespace games::ddr {
|
||||
DDRGame::DDRGame() : Game("Dance Dance Revolution") {
|
||||
}
|
||||
|
||||
void DDRGame::register_codecs() {
|
||||
// find where spice.exe / spice64.exe is located
|
||||
const auto &spice_bin_path = libutils::module_file_name(nullptr).parent_path();
|
||||
|
||||
// find the com directory
|
||||
std::filesystem::path dir = "";
|
||||
if (MODULE_PATH == spice_bin_path) {
|
||||
// try: \com
|
||||
dir = spice_bin_path / "com";
|
||||
} else {
|
||||
// try: modules\..\com
|
||||
dir = MODULE_PATH / ".." / "com";
|
||||
}
|
||||
|
||||
if (fileutils::dir_exists(dir)) {
|
||||
log_info("ddr", "looking for codecs in this directory: {}", dir.string());
|
||||
} else {
|
||||
log_info("ddr", "codecs directory not found: {}", dir.string());
|
||||
return;
|
||||
}
|
||||
|
||||
for (const auto &file : std::filesystem::directory_iterator(dir)) {
|
||||
const auto &filename = file.path().filename();
|
||||
const auto extension = strtolower(filename.extension().string());
|
||||
|
||||
if (extension != ".dll") {
|
||||
continue;
|
||||
}
|
||||
|
||||
log_info("ddr", "found DLL: {}", filename.string());
|
||||
if (filename == "k-clvsd.dll" || filename.string().find("xactengine") == 0) {
|
||||
const std::string cmd = "regsvr32.exe /s " + file.path().string();
|
||||
|
||||
int result = 0;
|
||||
std::thread t([cmd, &result]() {
|
||||
result = system(cmd.c_str());
|
||||
});
|
||||
t.join();
|
||||
log_info("ddr", "`{}` returned {}", cmd, result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DDRGame::pre_attach() {
|
||||
if (!cfg::CONFIGURATOR_STANDALONE && avs::game::is_model("TDX")) {
|
||||
log_fatal(
|
||||
@@ -87,6 +132,10 @@ namespace games::ddr {
|
||||
"!!! !!!\n\n\n"
|
||||
);
|
||||
}
|
||||
|
||||
if (!cfg::CONFIGURATOR_STANDALONE && !NO_CODEC_REGISTRATION) {
|
||||
this->register_codecs();
|
||||
}
|
||||
}
|
||||
|
||||
void DDRGame::attach() {
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace games::ddr {
|
||||
|
||||
// settings
|
||||
extern bool SDMODE;
|
||||
extern bool NO_CODEC_REGISTRATION;
|
||||
|
||||
// Buffers to store RGB data for tape LEDs on gold cabinets
|
||||
const size_t TAPELED_DEVICE_COUNT = 11;
|
||||
@@ -18,5 +19,8 @@ namespace games::ddr {
|
||||
virtual void pre_attach() override;
|
||||
virtual void attach() override;
|
||||
virtual void detach() override;
|
||||
|
||||
private:
|
||||
void register_codecs();
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user