1
0
mirror of https://github.com/djhackersdev/bemanitools.git synced 2024-11-28 08:20:51 +01:00

camhook: Add disable_camera options

Allow users to manually disable specific cameras
This commit is contained in:
Jeffrey Paine 2023-04-10 15:03:51 -04:00 committed by icex2
parent 043906e353
commit 139c658d03
2 changed files with 45 additions and 15 deletions

View File

@ -706,11 +706,6 @@ void fill_cam_struct(struct CameraData *data, const char *devid)
// Device instance path
strcpy(data->deviceInstancePath, devid);
// continue
} else if (check_four(devid, "SKIP")) {
// User wants to leave this camera unassigned
num_addressed_cams++;
num_located_cams++;
return;
} else {
// UNKNOWN ENTRY
log_info("UNK: %s", devid);
@ -813,6 +808,14 @@ void camhook_init(struct camhook_config_cam *config_cam)
// fill before applying hooks
for (size_t i = 0; i < config_cam->num_devices; ++i) {
// Check if this camera is disabled first
if (config_cam->disable_camera[i]) {
// If so, pretend this camera is already assigned and move on
num_addressed_cams++;
num_located_cams++;
continue;
}
// If not, try to hook the camera
fill_cam_struct(&camData[i], config_cam->device_id[i]);
}
@ -834,7 +837,8 @@ void camhook_init(struct camhook_config_cam *config_cam)
NULL, "Mf.dll", camhook_mf_syms, lengthof(camhook_mf_syms));
log_info("Inserted cam hooks for %d cams", (int) num_setup);
} else {
// If the user has manually disabled all cams, don't print this in the log
} else if (num_addressed_cams != config_cam->num_devices) {
log_info("No cams detected, not hooking");
}
}

View File

@ -7,8 +7,18 @@
#define CAMHOOK_CONFIG_CAM_DISABLE_EMU_KEY "cam.disable_emu"
#define CAMHOOK_CONFIG_CAM_DEFAULT_DISABLE_EMU_VALUE false
// the following two arrays are based on CAMHOOK_CONFIG_CAM_MAX
// the following four arrays are based on CAMHOOK_CONFIG_CAM_MAX
// please insert more elements if more cams are added
const char *camhook_config_disable_camera[CAMHOOK_CONFIG_CAM_MAX] = {
"cam.disable_camera1",
"cam.disable_camera2",
};
const int camhook_config_disable_camera_default_values[CAMHOOK_CONFIG_CAM_MAX] = {
false,
false,
};
const char *camhook_config_device_id_keys[CAMHOOK_CONFIG_CAM_MAX] = {
"cam.device_id1",
"cam.device_id2",
@ -28,6 +38,11 @@ void camhook_config_cam_init(struct cconfig *config, size_t num_cams)
"Disables the camera emulation");
for (size_t i = 0; i < num_cams; ++i) {
cconfig_util_set_bool(
config,
camhook_config_disable_camera[i],
camhook_config_disable_camera_default_values[i],
"Disable camera");
cconfig_util_set_str(
config,
camhook_config_device_id_keys[i],
@ -56,6 +71,17 @@ void camhook_config_cam_get(
CAMHOOK_CONFIG_CAM_DEFAULT_DISABLE_EMU_VALUE);
}
for (size_t i = 0; i < num_cams; ++i) {
if (!cconfig_util_get_bool(
config,
camhook_config_disable_camera[i],
&config_cam->disable_camera[i],
camhook_config_disable_camera_default_values[i])) {
log_warning(
"Invalid value for key '%s' specified, fallback "
"to default '%d'",
camhook_config_disable_camera[i],
camhook_config_disable_camera_default_values[i]);
}
if (!cconfig_util_get_str(
config,
camhook_config_device_id_keys[i],