mirror of
https://github.com/djhackersdev/bemanitools.git
synced 2025-02-17 19:19:16 +01:00
camhook: Add disable_camera options
Allow users to manually disable specific cameras
This commit is contained in:
parent
043906e353
commit
139c658d03
@ -706,11 +706,6 @@ void fill_cam_struct(struct CameraData *data, const char *devid)
|
|||||||
// Device instance path
|
// Device instance path
|
||||||
strcpy(data->deviceInstancePath, devid);
|
strcpy(data->deviceInstancePath, devid);
|
||||||
// continue
|
// continue
|
||||||
} else if (check_four(devid, "SKIP")) {
|
|
||||||
// User wants to leave this camera unassigned
|
|
||||||
num_addressed_cams++;
|
|
||||||
num_located_cams++;
|
|
||||||
return;
|
|
||||||
} else {
|
} else {
|
||||||
// UNKNOWN ENTRY
|
// UNKNOWN ENTRY
|
||||||
log_info("UNK: %s", devid);
|
log_info("UNK: %s", devid);
|
||||||
@ -813,6 +808,14 @@ void camhook_init(struct camhook_config_cam *config_cam)
|
|||||||
|
|
||||||
// fill before applying hooks
|
// fill before applying hooks
|
||||||
for (size_t i = 0; i < config_cam->num_devices; ++i) {
|
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]);
|
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));
|
NULL, "Mf.dll", camhook_mf_syms, lengthof(camhook_mf_syms));
|
||||||
|
|
||||||
log_info("Inserted cam hooks for %d cams", (int) num_setup);
|
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");
|
log_info("No cams detected, not hooking");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,18 @@
|
|||||||
#define CAMHOOK_CONFIG_CAM_DISABLE_EMU_KEY "cam.disable_emu"
|
#define CAMHOOK_CONFIG_CAM_DISABLE_EMU_KEY "cam.disable_emu"
|
||||||
#define CAMHOOK_CONFIG_CAM_DEFAULT_DISABLE_EMU_VALUE false
|
#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
|
// 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] = {
|
const char *camhook_config_device_id_keys[CAMHOOK_CONFIG_CAM_MAX] = {
|
||||||
"cam.device_id1",
|
"cam.device_id1",
|
||||||
"cam.device_id2",
|
"cam.device_id2",
|
||||||
@ -28,6 +38,11 @@ void camhook_config_cam_init(struct cconfig *config, size_t num_cams)
|
|||||||
"Disables the camera emulation");
|
"Disables the camera emulation");
|
||||||
|
|
||||||
for (size_t i = 0; i < num_cams; ++i) {
|
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(
|
cconfig_util_set_str(
|
||||||
config,
|
config,
|
||||||
camhook_config_device_id_keys[i],
|
camhook_config_device_id_keys[i],
|
||||||
@ -56,17 +71,28 @@ void camhook_config_cam_get(
|
|||||||
CAMHOOK_CONFIG_CAM_DEFAULT_DISABLE_EMU_VALUE);
|
CAMHOOK_CONFIG_CAM_DEFAULT_DISABLE_EMU_VALUE);
|
||||||
}
|
}
|
||||||
for (size_t i = 0; i < num_cams; ++i) {
|
for (size_t i = 0; i < num_cams; ++i) {
|
||||||
if (!cconfig_util_get_str(
|
if (!cconfig_util_get_bool(
|
||||||
config,
|
config,
|
||||||
camhook_config_device_id_keys[i],
|
camhook_config_disable_camera[i],
|
||||||
config_cam->device_id[i],
|
&config_cam->disable_camera[i],
|
||||||
sizeof(config_cam->device_id[i]) - 1,
|
camhook_config_disable_camera_default_values[i])) {
|
||||||
camhook_config_device_default_values[i])) {
|
|
||||||
log_warning(
|
log_warning(
|
||||||
"Invalid value for key '%s' specified, fallback "
|
"Invalid value for key '%s' specified, fallback "
|
||||||
"to default '%s'",
|
"to default '%d'",
|
||||||
camhook_config_device_id_keys[i],
|
camhook_config_disable_camera[i],
|
||||||
camhook_config_device_default_values[i]);
|
camhook_config_disable_camera_default_values[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]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user