Split USB memory path configurations

This commit is contained in:
QCDLZCLW3K
2022-05-30 02:00:49 +00:00
parent 0294eed22b
commit 2223947dd8
9 changed files with 194 additions and 154 deletions
+30 -11
View File
@@ -9,14 +9,16 @@
#define DDRHOOK1_CONFIG_DDRHOOK1_USE_COM4_EMU_KEY "ddrhook1.use_com4_emu"
#define DDRHOOK1_CONFIG_DDRHOOK1_STANDARD_DEF_KEY "ddrhook1.standard_def"
#define DDRHOOK1_CONFIG_DDRHOOK1_USE_15KHZ_KEY "ddrhook1.use_15khz"
#define DDRHOOK1_CONFIG_DDRHOOK1_USBMEM_PATH "ddrhook1.usbmem_path"
#define DDRHOOK1_CONFIG_DDRHOOK1_USBMEM_ENABLED "ddrhook1.usbmem_enabled"
#define DDRHOOK1_CONFIG_DDRHOOK1_USBMEM_PATH_P1 "ddrhook1.usbmem_path_p1"
#define DDRHOOK1_CONFIG_DDRHOOK1_USBMEM_PATH_P2 "ddrhook1.usbmem_path_p2"
#define DDRHOOK1_CONFIG_DDRHOOK1_DEFAULT_USE_COM4_EMU_VALUE true
#define DDRHOOK1_CONFIG_DDRHOOK1_DEFAULT_STANDARD_DEF_VALUE false
#define DDRHOOK1_CONFIG_DDRHOOK1_DEFAULT_USE_15KHZ_VALUE false
#define DDRHOOK1_CONFIG_DDRHOOK1_DEFAULT_USBMEM_ENABLED false
#define DDRHOOK1_CONFIG_DDRHOOK1_DEFAULT_USBMEM_PATH "usbmem"
#define DDRHOOK1_CONFIG_DDRHOOK1_DEFAULT_USBMEM_PATH_P1 "usbmem_p1"
#define DDRHOOK1_CONFIG_DDRHOOK1_DEFAULT_USBMEM_PATH_P2 "usbmem_p2"
void ddrhook1_config_ddrhook1_init(struct cconfig *config)
{
@@ -42,9 +44,14 @@ void ddrhook1_config_ddrhook1_init(struct cconfig *config)
"Enable USB memory data emulation");
cconfig_util_set_str(
config,
DDRHOOK1_CONFIG_DDRHOOK1_USBMEM_PATH,
DDRHOOK1_CONFIG_DDRHOOK1_DEFAULT_USBMEM_PATH,
"Specify path for USB memory data");
DDRHOOK1_CONFIG_DDRHOOK1_USBMEM_PATH_P1,
DDRHOOK1_CONFIG_DDRHOOK1_DEFAULT_USBMEM_PATH_P1,
"Specify path for P1 USB memory data");
cconfig_util_set_str(
config,
DDRHOOK1_CONFIG_DDRHOOK1_USBMEM_PATH_P2,
DDRHOOK1_CONFIG_DDRHOOK1_DEFAULT_USBMEM_PATH_P2,
"Specify path for P2 USB memory data");
}
void ddrhook1_config_ddrhook1_get(
@@ -96,14 +103,26 @@ void ddrhook1_config_ddrhook1_get(
}
if (!cconfig_util_get_str(
config,
DDRHOOK1_CONFIG_DDRHOOK1_USBMEM_PATH,
config_ddrhook1->usbmem_path,
sizeof(config_ddrhook1->usbmem_path) - 1,
DDRHOOK1_CONFIG_DDRHOOK1_DEFAULT_USBMEM_PATH)) {
DDRHOOK1_CONFIG_DDRHOOK1_USBMEM_PATH_P1,
config_ddrhook1->usbmem_path_p1,
sizeof(config_ddrhook1->usbmem_path_p1) - 1,
DDRHOOK1_CONFIG_DDRHOOK1_DEFAULT_USBMEM_PATH_P1)) {
log_warning(
"Invalid value for key '%s' specified, fallback "
"to default '%s'",
DDRHOOK1_CONFIG_DDRHOOK1_USBMEM_PATH,
DDRHOOK1_CONFIG_DDRHOOK1_DEFAULT_USBMEM_PATH);
DDRHOOK1_CONFIG_DDRHOOK1_USBMEM_PATH_P1,
DDRHOOK1_CONFIG_DDRHOOK1_DEFAULT_USBMEM_PATH_P1);
}
if (!cconfig_util_get_str(
config,
DDRHOOK1_CONFIG_DDRHOOK1_USBMEM_PATH_P2,
config_ddrhook1->usbmem_path_p2,
sizeof(config_ddrhook1->usbmem_path_p2) - 1,
DDRHOOK1_CONFIG_DDRHOOK1_DEFAULT_USBMEM_PATH_P2)) {
log_warning(
"Invalid value for key '%s' specified, fallback "
"to default '%s'",
DDRHOOK1_CONFIG_DDRHOOK1_USBMEM_PATH_P2,
DDRHOOK1_CONFIG_DDRHOOK1_DEFAULT_USBMEM_PATH_P2);
}
}
+2 -1
View File
@@ -13,7 +13,8 @@ struct ddrhook1_config_ddrhook1 {
bool standard_def;
bool use_15khz;
bool usbmem_enabled;
char usbmem_path[MAX_PATH];
char usbmem_path_p1[MAX_PATH];
char usbmem_path_p2[MAX_PATH];
};
/**
+2 -1
View File
@@ -129,7 +129,8 @@ static DWORD STDCALL my_main()
&security_rp_sign_key_black_ddrx,
&security_rp_sign_key_white_eamuse);
extio_init();
usbmem_init(config_ddrhook1.usbmem_path, config_ddrhook1.usbmem_enabled);
usbmem_init(config_ddrhook1.usbmem_path_p1, config_ddrhook1.usbmem_path_p2,
config_ddrhook1.usbmem_enabled);
spike_init();
com4_init();
+9 -9
View File
@@ -136,26 +136,26 @@ static char *ddrhook1_filesystem_get_path(LPCTSTR path)
} else if (strnicmp(path, "E:/conf", 7) == 0
|| strnicmp(path, "E:\\conf", 7) == 0) {
char *launcher_folder;
char *conf_path;
char *sub_path;
ddrhook1_get_launcher_path_parts(NULL, &launcher_folder);
conf_path = strstr(path, "conf");
sub_path = strstr(path, "conf");
if (conf_path && launcher_folder) {
if (sub_path && launcher_folder) {
new_path = (char*)xmalloc(MAX_PATH);
sprintf(new_path, "%s\\%s", launcher_folder, conf_path);
sprintf(new_path, "%s\\%s", launcher_folder, sub_path);
}
} else if (stricmp(path, "F:/update") == 0
|| stricmp(path, "F:\\update") == 0) {
char *launcher_folder;
char *conf_path;
char *sub_path;
ddrhook1_get_launcher_path_parts(NULL, &launcher_folder);
conf_path = strstr(path, "update");
sub_path = strstr(path, "update");
if (conf_path && launcher_folder) {
if (sub_path && launcher_folder) {
new_path = (char*)xmalloc(MAX_PATH);
sprintf(new_path, "%s\\%s", launcher_folder, conf_path);
sprintf(new_path, "%s\\%s", launcher_folder, sub_path);
}
}
@@ -187,7 +187,7 @@ static HANDLE STDCALL my_FindFirstFileA(
new_path,
lpFindFileData);
log_misc("FindFirstFileA remapped path: %s -> %s\n", lpFileName, new_path);
log_misc("FindFirstFileA remapped path: %s -> %s", lpFileName, new_path);
free(new_path);
return r;