mirror of
https://github.com/djhackersdev/bemanitools.git
synced 2024-11-12 01:10:49 +01:00
camhook: move camera hook facilities to their own module
makes the number of cameras configurable (up to 2), as SDVX only needs 1
This commit is contained in:
parent
2d8017dbda
commit
b434d7975d
@ -80,6 +80,7 @@ include src/main/aciotest/Module.mk
|
||||
include src/main/bio2emu/Module.mk
|
||||
include src/main/bsthook/Module.mk
|
||||
include src/main/bstio/Module.mk
|
||||
include src/main/camhook/Module.mk
|
||||
include src/main/cconfig/Module.mk
|
||||
include src/main/config/Module.mk
|
||||
include src/main/ddrhook/Module.mk
|
||||
|
@ -226,7 +226,8 @@ void property_node_datasize(struct property_node *node);
|
||||
bool std_getenv(const char *key, char *val, uint32_t nbytes);
|
||||
void std_setenv(const char *key, const char *val);
|
||||
|
||||
int avs_fs_addfs(void* filesys_struct);
|
||||
int avs_fs_mount (const char* mountpoint, const char* fsroot, const char* fstype, void* data);
|
||||
int avs_fs_addfs(void *filesys_struct);
|
||||
int avs_fs_mount(
|
||||
const char *mountpoint, const char *fsroot, const char *fstype, void *data);
|
||||
|
||||
#endif
|
||||
|
11
src/main/camhook/Module.mk
Normal file
11
src/main/camhook/Module.mk
Normal file
@ -0,0 +1,11 @@
|
||||
libs += camhook
|
||||
|
||||
libs_camhook := \
|
||||
hook \
|
||||
hooklib \
|
||||
cconfig \
|
||||
util \
|
||||
|
||||
src_camhook := \
|
||||
cam.c \
|
||||
config-cam.c \
|
@ -18,7 +18,7 @@
|
||||
#include "hook/com-proxy.h"
|
||||
#include "hook/table.h"
|
||||
|
||||
#include "iidxhook8/cam.h"
|
||||
#include "camhook/cam.h"
|
||||
|
||||
#include "util/defs.h"
|
||||
#include "util/log.h"
|
||||
@ -78,9 +78,21 @@ struct CameraData {
|
||||
char parent_name[CAMERA_DATA_STRING_SIZE];
|
||||
char parent_deviceInstancePath[CAMERA_DATA_STRING_SIZE];
|
||||
int parent_address;
|
||||
|
||||
bool fake_addressed;
|
||||
int fake_address;
|
||||
|
||||
bool fake_located;
|
||||
size_t fake_located_node;
|
||||
};
|
||||
|
||||
static struct CameraData camData[2];
|
||||
static struct CameraData camData[CAMHOOK_CONFIG_CAM_MAX];
|
||||
int camAddresses[CAMHOOK_CONFIG_CAM_MAX] = {
|
||||
1,
|
||||
7,
|
||||
};
|
||||
static size_t num_addressed_cams = 0;
|
||||
static size_t num_located_cams = 0;
|
||||
|
||||
static CONFIGRET my_CM_Locate_DevNodeA(
|
||||
PDEVINST pdnDevInst, DEVINSTID_A pDeviceID, ULONG ulFlags);
|
||||
@ -144,7 +156,7 @@ static HDEVINFO my_SetupDiGetClassDevsA(
|
||||
static HDEVINFO (*real_SetupDiGetClassDevsA)(
|
||||
CONST GUID *ClassGuid, PCSTR Enumerator, HWND hwndParent, DWORD Flags);
|
||||
|
||||
static const struct hook_symbol iidxhook5_cfgmgr32_syms[] = {
|
||||
static const struct hook_symbol camhook_cfgmgr32_syms[] = {
|
||||
{.name = "CM_Locate_DevNodeA",
|
||||
.patch = my_CM_Locate_DevNodeA,
|
||||
.link = (void **) &real_CM_Locate_DevNodeA},
|
||||
@ -168,58 +180,54 @@ static const struct hook_symbol iidxhook5_cfgmgr32_syms[] = {
|
||||
.link = (void **) &real_SetupDiGetClassDevsA},
|
||||
};
|
||||
|
||||
static const struct hook_symbol iidxhook5_mf_syms[] = {
|
||||
static const struct hook_symbol camhook_mf_syms[] = {
|
||||
{.name = "MFEnumDeviceSources",
|
||||
.patch = my_MFEnumDeviceSources,
|
||||
.link = (void **) &real_MFEnumDeviceSources},
|
||||
};
|
||||
|
||||
#define CUSTOM_DEV_NODE1 0x04040004
|
||||
#define CUSTOM_DEV_NODE2 0x04040008
|
||||
|
||||
#define CUSTOM_DEV_PARENT_NODE1 0x04040014
|
||||
#define CUSTOM_DEV_PARENT_NODE2 0x04040018
|
||||
DEVINST camhook_custom_nodes[CAMHOOK_CONFIG_CAM_MAX] = {
|
||||
0x04040004,
|
||||
0x04040008,
|
||||
};
|
||||
DEVINST camhook_custom_parent_nodes[CAMHOOK_CONFIG_CAM_MAX] = {
|
||||
0x04040014,
|
||||
0x04040018,
|
||||
};
|
||||
const char *camhook_custom_parent_device_id[CAMHOOK_CONFIG_CAM_MAX] = {
|
||||
"USB\\VEN_1022&DEV_7908",
|
||||
"USB\\VEN_1022&DEV_7914",
|
||||
};
|
||||
|
||||
static CONFIGRET
|
||||
my_CM_Locate_DevNodeA(PDEVINST pdnDevInst, DEVINSTID_A pDeviceID, ULONG ulFlags)
|
||||
{
|
||||
log_info("Inside: %s", __FUNCTION__);
|
||||
char builtString1[CAMERA_DATA_STRING_SIZE] = {0};
|
||||
char builtString2[CAMERA_DATA_STRING_SIZE] = {0};
|
||||
|
||||
if (camData[0].setup) {
|
||||
snprintf(
|
||||
builtString1,
|
||||
CAMERA_DATA_STRING_SIZE,
|
||||
"USB\\VID_288C&PID_0002&MI_00\\%s",
|
||||
camData[0].extra_upper);
|
||||
|
||||
if (camData[1].setup) {
|
||||
snprintf(
|
||||
builtString2,
|
||||
CAMERA_DATA_STRING_SIZE,
|
||||
"USB\\VID_288C&PID_0002&MI_00\\%s",
|
||||
camData[1].extra_upper);
|
||||
}
|
||||
} else if (camData[1].setup) {
|
||||
snprintf(
|
||||
builtString1,
|
||||
CAMERA_DATA_STRING_SIZE,
|
||||
"USB\\VID_288C&PID_0002&MI_00\\%s",
|
||||
camData[1].extra_upper);
|
||||
}
|
||||
|
||||
char builtString[CAMERA_DATA_STRING_SIZE] = {0};
|
||||
if (pdnDevInst) {
|
||||
if (strcmp(pDeviceID, builtString1) == 0) {
|
||||
log_info("Injecting custom device 1");
|
||||
*pdnDevInst = CUSTOM_DEV_NODE1;
|
||||
return CR_SUCCESS;
|
||||
}
|
||||
|
||||
if (strcmp(pDeviceID, builtString2) == 0) {
|
||||
log_info("Injecting custom device 2");
|
||||
*pdnDevInst = CUSTOM_DEV_NODE2;
|
||||
return CR_SUCCESS;
|
||||
for (size_t i = 0; i < CAMHOOK_CONFIG_CAM_MAX; ++i) {
|
||||
if (camData[i].setup) {
|
||||
snprintf(
|
||||
builtString,
|
||||
CAMERA_DATA_STRING_SIZE,
|
||||
"USB\\VID_288C&PID_0002&MI_00\\%s",
|
||||
camData[i].extra_upper);
|
||||
if (strcmp(pDeviceID, builtString) == 0) {
|
||||
if (!camData[i].fake_located) {
|
||||
camData[i].fake_located_node = num_located_cams;
|
||||
camData[i].fake_located = true;
|
||||
++num_located_cams;
|
||||
}
|
||||
log_info(
|
||||
"Injecting custom device %d to node %x",
|
||||
(int) i,
|
||||
(int) camData[i].fake_located_node);
|
||||
*pdnDevInst =
|
||||
camhook_custom_nodes[camData[i].fake_located_node];
|
||||
return CR_SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return real_CM_Locate_DevNodeA(pdnDevInst, pDeviceID, ulFlags);
|
||||
@ -231,15 +239,12 @@ my_CM_Get_Parent(PDEVINST pdnDevInst, DEVINST dnDevInst, ULONG ulFlags)
|
||||
log_info("Inside: %s", __FUNCTION__);
|
||||
|
||||
if (pdnDevInst) {
|
||||
if (dnDevInst == CUSTOM_DEV_NODE1) {
|
||||
log_info("Injecting custom parent 1");
|
||||
*pdnDevInst = CUSTOM_DEV_PARENT_NODE1;
|
||||
return CR_SUCCESS;
|
||||
}
|
||||
if (dnDevInst == CUSTOM_DEV_NODE2) {
|
||||
log_info("Injecting custom parent 2");
|
||||
*pdnDevInst = CUSTOM_DEV_PARENT_NODE2;
|
||||
return CR_SUCCESS;
|
||||
for (size_t i = 0; i < CAMHOOK_CONFIG_CAM_MAX; ++i) {
|
||||
if (dnDevInst == camhook_custom_nodes[i]) {
|
||||
log_info("Injecting custom parent %d", (int) i);
|
||||
*pdnDevInst = camhook_custom_parent_nodes[i];
|
||||
return CR_SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -250,22 +255,15 @@ static CONFIGRET my_CM_Get_Device_IDA(
|
||||
DEVINST dnDevInst, PSTR Buffer, ULONG BufferLen, ULONG ulFlags)
|
||||
{
|
||||
log_info("Inside: %s", __FUNCTION__);
|
||||
|
||||
if (Buffer) {
|
||||
if (dnDevInst == CUSTOM_DEV_PARENT_NODE1) {
|
||||
log_info("Injecting custom parent 1 ID");
|
||||
strncpy(Buffer, "USB\\VEN_1022&DEV_7908", BufferLen);
|
||||
Buffer[BufferLen - 1] = '\0';
|
||||
log_info("%s", Buffer);
|
||||
return CR_SUCCESS;
|
||||
}
|
||||
|
||||
if (dnDevInst == CUSTOM_DEV_PARENT_NODE2) {
|
||||
log_info("Injecting custom parent 2 ID");
|
||||
strncpy(Buffer, "USB\\VEN_1022&DEV_7914", BufferLen);
|
||||
Buffer[BufferLen - 1] = '\0';
|
||||
log_info("%s", Buffer);
|
||||
return CR_SUCCESS;
|
||||
for (size_t i = 0; i < CAMHOOK_CONFIG_CAM_MAX; ++i) {
|
||||
if (dnDevInst == camhook_custom_parent_nodes[i]) {
|
||||
log_info("Injecting custom parent %d ID", (int) i);
|
||||
strncpy(Buffer, camhook_custom_parent_device_id[i], BufferLen);
|
||||
Buffer[BufferLen - 1] = '\0';
|
||||
log_info("%s", Buffer);
|
||||
return CR_SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
return real_CM_Get_Device_IDA(dnDevInst, Buffer, BufferLen, ulFlags);
|
||||
@ -274,8 +272,7 @@ static CONFIGRET my_CM_Get_Device_IDA(
|
||||
static HRESULT(STDCALL *real_GetAllocatedString)(
|
||||
IMFActivate *self, REFGUID guidKey, LPWSTR *ppwszValue, UINT32 *pcchLength);
|
||||
|
||||
HRESULT
|
||||
my_GetAllocatedString(
|
||||
HRESULT my_GetAllocatedString(
|
||||
IMFActivate *self, REFGUID guidKey, LPWSTR *ppwszValue, UINT32 *pcchLength)
|
||||
{
|
||||
HRESULT ret;
|
||||
@ -287,16 +284,16 @@ my_GetAllocatedString(
|
||||
|
||||
wchar_t *pwc = NULL;
|
||||
|
||||
if (camData[0].setup) {
|
||||
pwc = wcsstr(*ppwszValue, camData[0].deviceSymbolicLink);
|
||||
}
|
||||
|
||||
if (camData[1].setup) {
|
||||
// look for a matching deviceSymbolicLink
|
||||
for (size_t i = 0; i < CAMHOOK_CONFIG_CAM_MAX; ++i) {
|
||||
if (!pwc) {
|
||||
pwc = wcsstr(*ppwszValue, camData[1].deviceSymbolicLink);
|
||||
if (camData[i].setup) {
|
||||
pwc = wcsstr(*ppwszValue, camData[i].deviceSymbolicLink);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if matches, replace with target device ID
|
||||
if (pwc) {
|
||||
// \\?\usb#vid_288c&pid_0002&mi_00
|
||||
pwc[12] = L'2';
|
||||
@ -399,33 +396,21 @@ static BOOL my_SetupDiGetDeviceRegistryPropertyA(
|
||||
|
||||
if (Property == SPDRP_DEVICEDESC) {
|
||||
if (PropertyBuffer) {
|
||||
if (camData[0].setup) {
|
||||
if (strcmp(
|
||||
(char *) PropertyBuffer, camData[0].parent_name) ==
|
||||
0) {
|
||||
log_info(
|
||||
"%s: replacing %s",
|
||||
__FUNCTION__,
|
||||
camData[0].parent_name);
|
||||
strncpy(
|
||||
(char *) PropertyBuffer,
|
||||
"USB Composite Device",
|
||||
PropertyBufferSize);
|
||||
}
|
||||
}
|
||||
|
||||
if (camData[1].setup) {
|
||||
if (strcmp(
|
||||
(char *) PropertyBuffer, camData[1].parent_name) ==
|
||||
0) {
|
||||
log_info(
|
||||
"%s: replacing %s",
|
||||
__FUNCTION__,
|
||||
camData[1].parent_name);
|
||||
strncpy(
|
||||
(char *) PropertyBuffer,
|
||||
"USB Composite Device",
|
||||
PropertyBufferSize);
|
||||
char *PropertyBufferChar = (char *) PropertyBuffer;
|
||||
for (size_t i = 0; i < CAMHOOK_CONFIG_CAM_MAX; ++i) {
|
||||
if (camData[i].setup) {
|
||||
if (strcmp(
|
||||
PropertyBufferChar, camData[i].parent_name) ==
|
||||
0) {
|
||||
log_info(
|
||||
"%s: replacing %s",
|
||||
__FUNCTION__,
|
||||
camData[i].parent_name);
|
||||
strncpy(
|
||||
PropertyBufferChar,
|
||||
"USB Composite Device",
|
||||
PropertyBufferSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -434,22 +419,23 @@ static BOOL my_SetupDiGetDeviceRegistryPropertyA(
|
||||
} else if (Property == SPDRP_ADDRESS) {
|
||||
if (PropertyBuffer) {
|
||||
int addr = *(int *) PropertyBuffer;
|
||||
|
||||
if (camData[0].setup) {
|
||||
if (addr == camData[0].parent_address) {
|
||||
log_info("%s: replacing addr1", __FUNCTION__);
|
||||
*(int *) PropertyBuffer = 1;
|
||||
} else if (camData[1].setup) {
|
||||
if (addr == camData[1].parent_address) {
|
||||
log_info("%s: replacing addr7", __FUNCTION__);
|
||||
*(int *) PropertyBuffer = 7;
|
||||
for (size_t i = 0; i < CAMHOOK_CONFIG_CAM_MAX; ++i) {
|
||||
if (camData[i].setup) {
|
||||
if (addr == camData[i].parent_address) {
|
||||
if (!camData[i].fake_addressed) {
|
||||
camData[i].fake_address =
|
||||
camAddresses[num_addressed_cams];
|
||||
camData[i].fake_addressed = true;
|
||||
++num_addressed_cams;
|
||||
}
|
||||
log_info(
|
||||
"%s: assigning cam %d to addr %d",
|
||||
__FUNCTION__,
|
||||
(int) i,
|
||||
camData[i].fake_address);
|
||||
*(int *) PropertyBuffer = camData[i].fake_address;
|
||||
}
|
||||
}
|
||||
} else if (camData[1].setup) {
|
||||
if (addr == camData[1].parent_address) {
|
||||
log_info("%s: replacing addr1 (alt)", __FUNCTION__);
|
||||
*(int *) PropertyBuffer = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -799,22 +785,30 @@ void fill_cam_struct(struct CameraData *data, const char *devid)
|
||||
data->setup = true;
|
||||
}
|
||||
|
||||
void cam_hook_init(const char *devID1, const char *devID2)
|
||||
void camhook_init(struct camhook_config_cam *config_cam)
|
||||
{
|
||||
// fill before applying hooks
|
||||
fill_cam_struct(&camData[0], devID1);
|
||||
fill_cam_struct(&camData[1], devID2);
|
||||
for (size_t i = 0; i < config_cam->num_devices; ++i) {
|
||||
fill_cam_struct(&camData[i], config_cam->device_id[i]);
|
||||
}
|
||||
|
||||
if (camData[0].setup || camData[1].setup) {
|
||||
size_t num_setup = 0;
|
||||
for (size_t i = 0; i < config_cam->num_devices; ++i) {
|
||||
if (camData[i].setup) {
|
||||
num_setup++;
|
||||
}
|
||||
}
|
||||
|
||||
if (num_setup > 0) {
|
||||
hook_table_apply(
|
||||
NULL,
|
||||
"setupapi.dll",
|
||||
iidxhook5_cfgmgr32_syms,
|
||||
lengthof(iidxhook5_cfgmgr32_syms));
|
||||
camhook_cfgmgr32_syms,
|
||||
lengthof(camhook_cfgmgr32_syms));
|
||||
hook_table_apply(
|
||||
NULL, "Mf.dll", iidxhook5_mf_syms, lengthof(iidxhook5_mf_syms));
|
||||
NULL, "Mf.dll", camhook_mf_syms, lengthof(camhook_mf_syms));
|
||||
|
||||
log_info("Inserted cam hooks");
|
||||
log_info("Inserted cam hooks for %d cams", (int) num_setup);
|
||||
} else {
|
||||
log_info("No cams detected, not hooking");
|
||||
}
|
8
src/main/camhook/cam.h
Normal file
8
src/main/camhook/cam.h
Normal file
@ -0,0 +1,8 @@
|
||||
#ifndef CAMHOOK_CAM_H
|
||||
#define CAMHOOK_CAM_H
|
||||
|
||||
#include "camhook/config-cam.h"
|
||||
|
||||
void camhook_init(struct camhook_config_cam *config_cam);
|
||||
|
||||
#endif
|
70
src/main/camhook/config-cam.c
Normal file
70
src/main/camhook/config-cam.c
Normal file
@ -0,0 +1,70 @@
|
||||
#include "cconfig/cconfig-util.h"
|
||||
|
||||
#include "camhook/config-cam.h"
|
||||
|
||||
#include "util/log.h"
|
||||
|
||||
#define CAMHOOK_CONFIG_CAM_DISABLE_EMU_KEY "cam.disable_emu"
|
||||
#define CAMHOOK_CONFIG_CAM_DEFAULT_DISABLE_EMU_VALUE false
|
||||
|
||||
const char *camhook_config_device_id_keys[CAMHOOK_CONFIG_CAM_MAX] = {
|
||||
"cam.device_id1",
|
||||
"cam.device_id2",
|
||||
};
|
||||
|
||||
const char *camhook_config_device_default_values[CAMHOOK_CONFIG_CAM_MAX] = {
|
||||
"",
|
||||
"",
|
||||
};
|
||||
|
||||
void camhook_config_cam_init(struct cconfig *config, size_t num_cams)
|
||||
{
|
||||
cconfig_util_set_bool(
|
||||
config,
|
||||
CAMHOOK_CONFIG_CAM_DISABLE_EMU_KEY,
|
||||
CAMHOOK_CONFIG_CAM_DEFAULT_DISABLE_EMU_VALUE,
|
||||
"Disables the camera emulation");
|
||||
|
||||
for (size_t i = 0; i < num_cams; ++i) {
|
||||
cconfig_util_set_str(
|
||||
config,
|
||||
camhook_config_device_id_keys[i],
|
||||
camhook_config_device_default_values[i],
|
||||
"Override camera device ID detection (copy from device manager, do "
|
||||
"not escape)");
|
||||
}
|
||||
}
|
||||
|
||||
void camhook_config_cam_get(
|
||||
struct camhook_config_cam *config_cam,
|
||||
struct cconfig *config,
|
||||
size_t num_cams)
|
||||
{
|
||||
config_cam->num_devices = num_cams;
|
||||
|
||||
if (!cconfig_util_get_bool(
|
||||
config,
|
||||
CAMHOOK_CONFIG_CAM_DISABLE_EMU_KEY,
|
||||
&config_cam->disable_emu,
|
||||
CAMHOOK_CONFIG_CAM_DEFAULT_DISABLE_EMU_VALUE)) {
|
||||
log_warning(
|
||||
"Invalid value for key '%s' specified, fallback "
|
||||
"to default '%d'",
|
||||
CAMHOOK_CONFIG_CAM_DISABLE_EMU_KEY,
|
||||
CAMHOOK_CONFIG_CAM_DEFAULT_DISABLE_EMU_VALUE);
|
||||
}
|
||||
for (size_t i = 0; i < num_cams; ++i) {
|
||||
if (!cconfig_util_get_str(
|
||||
config,
|
||||
camhook_config_device_id_keys[i],
|
||||
config_cam->device_id[i],
|
||||
sizeof(config_cam->device_id[i]) - 1,
|
||||
camhook_config_device_default_values[i])) {
|
||||
log_warning(
|
||||
"Invalid value for key '%s' specified, fallback "
|
||||
"to default '%s'",
|
||||
camhook_config_device_id_keys[i],
|
||||
camhook_config_device_default_values[i]);
|
||||
}
|
||||
}
|
||||
}
|
23
src/main/camhook/config-cam.h
Normal file
23
src/main/camhook/config-cam.h
Normal file
@ -0,0 +1,23 @@
|
||||
#ifndef CAMHOOK_CONFIG_CAM_H
|
||||
#define CAMHOOK_CONFIG_CAM_H
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include "cconfig/cconfig.h"
|
||||
|
||||
#define CAMHOOK_CONFIG_CAM_MAX 2
|
||||
|
||||
struct camhook_config_cam {
|
||||
bool disable_emu;
|
||||
size_t num_devices;
|
||||
char device_id[CAMHOOK_CONFIG_CAM_MAX][MAX_PATH];
|
||||
};
|
||||
|
||||
void camhook_config_cam_init(struct cconfig *config, size_t num_cams);
|
||||
|
||||
void camhook_config_cam_get(
|
||||
struct camhook_config_cam *config_cam,
|
||||
struct cconfig *config,
|
||||
size_t num_cams);
|
||||
|
||||
#endif
|
@ -15,6 +15,7 @@ libs_iidxhook8 := \
|
||||
iidxhook-util \
|
||||
acioemu \
|
||||
bio2emu \
|
||||
camhook \
|
||||
iidxio \
|
||||
hook \
|
||||
hooklib \
|
||||
@ -24,7 +25,5 @@ libs_iidxhook8 := \
|
||||
|
||||
src_iidxhook8 := \
|
||||
bi2a.c \
|
||||
cam.c \
|
||||
config-cam.c \
|
||||
config-io.c \
|
||||
dllmain.c \
|
||||
|
@ -1,6 +0,0 @@
|
||||
#ifndef IIDXHOOK5_CAM_H
|
||||
#define IIDXHOOK5_CAM_H
|
||||
|
||||
void cam_hook_init(const char *devID1, const char *devID2);
|
||||
|
||||
#endif
|
@ -1,78 +0,0 @@
|
||||
#include "cconfig/cconfig-util.h"
|
||||
|
||||
#include "iidxhook8/config-cam.h"
|
||||
|
||||
#include "util/log.h"
|
||||
|
||||
#define IIDXHOOK8_CONFIG_CAM_DISABLE_EMU_KEY "cam.disable_emu"
|
||||
#define IIDXHOOK8_CONFIG_CAM_DEVICE_ID1_KEY "cam.device_id1"
|
||||
#define IIDXHOOK8_CONFIG_CAM_DEVICE_ID2_KEY "cam.device_id2"
|
||||
|
||||
#define IIDXHOOK8_CONFIG_CAM_DEFAULT_DISABLE_EMU_VALUE false
|
||||
#define IIDXHOOK8_CONFIG_CAM_DEFAULT_DEVICE_ID1_VALUE ""
|
||||
#define IIDXHOOK8_CONFIG_CAM_DEFAULT_DEVICE_ID2_VALUE ""
|
||||
|
||||
void iidxhook8_config_cam_init(struct cconfig *config)
|
||||
{
|
||||
cconfig_util_set_bool(
|
||||
config,
|
||||
IIDXHOOK8_CONFIG_CAM_DISABLE_EMU_KEY,
|
||||
IIDXHOOK8_CONFIG_CAM_DEFAULT_DISABLE_EMU_VALUE,
|
||||
"Disables the camera emulation");
|
||||
|
||||
cconfig_util_set_str(
|
||||
config,
|
||||
IIDXHOOK8_CONFIG_CAM_DEVICE_ID1_KEY,
|
||||
IIDXHOOK8_CONFIG_CAM_DEFAULT_DEVICE_ID1_VALUE,
|
||||
"Override camera device ID 1 detection (copy from device manager, "
|
||||
"do not escape)");
|
||||
|
||||
cconfig_util_set_str(
|
||||
config,
|
||||
IIDXHOOK8_CONFIG_CAM_DEVICE_ID2_KEY,
|
||||
IIDXHOOK8_CONFIG_CAM_DEFAULT_DEVICE_ID2_VALUE,
|
||||
"Override camera device ID 2 detection (copy from device manager, "
|
||||
"do not escape)");
|
||||
}
|
||||
|
||||
void iidxhook8_config_cam_get(
|
||||
struct iidxhook8_config_cam *config_cam, struct cconfig *config)
|
||||
{
|
||||
if (!cconfig_util_get_bool(
|
||||
config,
|
||||
IIDXHOOK8_CONFIG_CAM_DISABLE_EMU_KEY,
|
||||
&config_cam->disable_emu,
|
||||
IIDXHOOK8_CONFIG_CAM_DEFAULT_DISABLE_EMU_VALUE)) {
|
||||
log_warning(
|
||||
"Invalid value for key '%s' specified, fallback "
|
||||
"to default '%d'",
|
||||
IIDXHOOK8_CONFIG_CAM_DISABLE_EMU_KEY,
|
||||
IIDXHOOK8_CONFIG_CAM_DEFAULT_DISABLE_EMU_VALUE);
|
||||
}
|
||||
|
||||
if (!cconfig_util_get_str(
|
||||
config,
|
||||
IIDXHOOK8_CONFIG_CAM_DEVICE_ID1_KEY,
|
||||
config_cam->device_id1,
|
||||
sizeof(config_cam->device_id1) - 1,
|
||||
IIDXHOOK8_CONFIG_CAM_DEFAULT_DEVICE_ID1_VALUE)) {
|
||||
log_warning(
|
||||
"Invalid value for key '%s' specified, fallback "
|
||||
"to default '%s'",
|
||||
IIDXHOOK8_CONFIG_CAM_DEVICE_ID1_KEY,
|
||||
IIDXHOOK8_CONFIG_CAM_DEFAULT_DEVICE_ID1_VALUE);
|
||||
}
|
||||
|
||||
if (!cconfig_util_get_str(
|
||||
config,
|
||||
IIDXHOOK8_CONFIG_CAM_DEVICE_ID2_KEY,
|
||||
config_cam->device_id2,
|
||||
sizeof(config_cam->device_id2) - 1,
|
||||
IIDXHOOK8_CONFIG_CAM_DEFAULT_DEVICE_ID2_VALUE)) {
|
||||
log_warning(
|
||||
"Invalid value for key '%s' specified, fallback "
|
||||
"to default '%s'",
|
||||
IIDXHOOK8_CONFIG_CAM_DEVICE_ID2_KEY,
|
||||
IIDXHOOK8_CONFIG_CAM_DEFAULT_DEVICE_ID2_VALUE);
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
#ifndef IIDXHOOK8_CONFIG_CAM_H
|
||||
#define IIDXHOOK8_CONFIG_CAM_H
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include "cconfig/cconfig.h"
|
||||
|
||||
struct iidxhook8_config_cam {
|
||||
bool disable_emu;
|
||||
char device_id1[MAX_PATH];
|
||||
char device_id2[MAX_PATH];
|
||||
};
|
||||
|
||||
void iidxhook8_config_cam_init(struct cconfig *config);
|
||||
|
||||
void iidxhook8_config_cam_get(
|
||||
struct iidxhook8_config_cam *config_cam, struct cconfig *config);
|
||||
|
||||
#endif
|
@ -26,8 +26,8 @@
|
||||
#include "bio2emu/emu.h"
|
||||
#include "iidxhook8/bi2a.h"
|
||||
|
||||
#include "iidxhook8/cam.h"
|
||||
#include "iidxhook8/config-cam.h"
|
||||
#include "camhook/cam.h"
|
||||
#include "camhook/config-cam.h"
|
||||
#include "iidxhook8/config-io.h"
|
||||
|
||||
#include "imports/avs.h"
|
||||
@ -87,7 +87,7 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
|
||||
struct cconfig *config;
|
||||
|
||||
struct iidxhook_config_gfx config_gfx;
|
||||
struct iidxhook8_config_cam config_cam;
|
||||
struct camhook_config_cam config_cam;
|
||||
|
||||
// log_server_init is required due to IO occuring in a non avs_thread
|
||||
log_server_init();
|
||||
@ -99,8 +99,8 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
|
||||
config = cconfig_init();
|
||||
|
||||
iidxhook_config_gfx_init(config);
|
||||
iidxhook8_config_cam_init(config);
|
||||
iidxhook8_config_io_init(config);
|
||||
camhook_config_cam_init(config, 2);
|
||||
|
||||
if (!cconfig_hook_config_init(
|
||||
config,
|
||||
@ -112,8 +112,8 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
|
||||
}
|
||||
|
||||
iidxhook_config_gfx_get(&config_gfx, config);
|
||||
iidxhook8_config_cam_get(&config_cam, config);
|
||||
iidxhook8_config_io_get(&iidxhook8_config_io, config);
|
||||
camhook_config_cam_get(&config_cam, config, 2);
|
||||
|
||||
cconfig_finit(config);
|
||||
|
||||
@ -165,7 +165,7 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
|
||||
|
||||
// camera hooks
|
||||
if (!config_cam.disable_emu) {
|
||||
cam_hook_init(config_cam.device_id1, config_cam.device_id2);
|
||||
camhook_init(&config_cam);
|
||||
}
|
||||
|
||||
log_info("-------------------------------------------------------------");
|
||||
|
Loading…
Reference in New Issue
Block a user