diff --git a/dist/iidx/iidxhook-25.conf b/dist/iidx/iidxhook-25.conf index 61a05c9..5ba9b8a 100644 --- a/dist/iidx/iidxhook-25.conf +++ b/dist/iidx/iidxhook-25.conf @@ -37,10 +37,16 @@ gfx.device_adapter=-1 # Disables the camera emulation cam.disable_emu=false -# Override camera device ID 1 detection (copy from device manager, do not escape) +# Disable camera 1. Use, i.e., if you only have one camera and want it to be mapped to camera 2 ingame. +cam.disable_camera1=false + +# Disable camera 2. Use, i.e., if you have more than one camera but only want to map camera 1 ingame. +cam.disable_camera2=false + +# Override camera device ID 1 detection (copy from device manager, do not escape) Leave blank to automatically detect cam.device_id1= -# Override camera device ID 2 detection (copy from device manager, do not escape) +# Override camera device ID 2 detection (copy from device manager, do not escape) Leave blank to automatically detect cam.device_id2= # Disable card reader emulation and enable usage of real card reader hardware on COM1 (for games supporting slotted readers) @@ -50,4 +56,4 @@ io.disable_card_reader_emu=false io.disable_bio2_emu=false # Disables the poll limiter, warning very high CPU usage may arise -io.disable_poll_limiter=false \ No newline at end of file +io.disable_poll_limiter=false diff --git a/dist/iidx/iidxhook-26.conf b/dist/iidx/iidxhook-26.conf index 61a05c9..5ba9b8a 100644 --- a/dist/iidx/iidxhook-26.conf +++ b/dist/iidx/iidxhook-26.conf @@ -37,10 +37,16 @@ gfx.device_adapter=-1 # Disables the camera emulation cam.disable_emu=false -# Override camera device ID 1 detection (copy from device manager, do not escape) +# Disable camera 1. Use, i.e., if you only have one camera and want it to be mapped to camera 2 ingame. +cam.disable_camera1=false + +# Disable camera 2. Use, i.e., if you have more than one camera but only want to map camera 1 ingame. +cam.disable_camera2=false + +# Override camera device ID 1 detection (copy from device manager, do not escape) Leave blank to automatically detect cam.device_id1= -# Override camera device ID 2 detection (copy from device manager, do not escape) +# Override camera device ID 2 detection (copy from device manager, do not escape) Leave blank to automatically detect cam.device_id2= # Disable card reader emulation and enable usage of real card reader hardware on COM1 (for games supporting slotted readers) @@ -50,4 +56,4 @@ io.disable_card_reader_emu=false io.disable_bio2_emu=false # Disables the poll limiter, warning very high CPU usage may arise -io.disable_poll_limiter=false \ No newline at end of file +io.disable_poll_limiter=false diff --git a/dist/iidx/iidxhook-27.conf b/dist/iidx/iidxhook-27.conf index b977db9..62e879c 100644 --- a/dist/iidx/iidxhook-27.conf +++ b/dist/iidx/iidxhook-27.conf @@ -20,7 +20,13 @@ io.disable_file_hooks=false io.tt_multiplier=1.0 # Disables the camera emulation -cam.disable_emu=false +cam.disable_emu=true + +# Disable camera 1. Use, i.e., if you only have one camera and want it to be mapped to camera 2 ingame. +cam.disable_camera1=false + +# Disable camera 2. Use, i.e., if you have more than one camera but only want to map camera 1 ingame. +cam.disable_camera2=false # Override camera device ID detection (copy from device manager, do not escape) cam.device_id1= diff --git a/dist/iidx/iidxhook-28.conf b/dist/iidx/iidxhook-28.conf index 3154052..62e879c 100644 --- a/dist/iidx/iidxhook-28.conf +++ b/dist/iidx/iidxhook-28.conf @@ -22,6 +22,12 @@ io.tt_multiplier=1.0 # Disables the camera emulation cam.disable_emu=true +# Disable camera 1. Use, i.e., if you only have one camera and want it to be mapped to camera 2 ingame. +cam.disable_camera1=false + +# Disable camera 2. Use, i.e., if you have more than one camera but only want to map camera 1 ingame. +cam.disable_camera2=false + # Override camera device ID detection (copy from device manager, do not escape) cam.device_id1= diff --git a/dist/iidx/iidxhook-29.conf b/dist/iidx/iidxhook-29.conf index 3154052..eb7e6bc 100644 --- a/dist/iidx/iidxhook-29.conf +++ b/dist/iidx/iidxhook-29.conf @@ -22,6 +22,12 @@ io.tt_multiplier=1.0 # Disables the camera emulation cam.disable_emu=true +# Disable camera 1. Use, i.e., if you only have one camera and want it to be mapped to camera 2 ingame. +cam.disable_camera1=true + +# Disable camera 2. Use, i.e., if you have more than one camera but only want to map camera 1 ingame. +cam.disable_camera2=false + # Override camera device ID detection (copy from device manager, do not escape) cam.device_id1= diff --git a/src/main/camhook/cam.c b/src/main/camhook/cam.c index 19978e8..f368721 100644 --- a/src/main/camhook/cam.c +++ b/src/main/camhook/cam.c @@ -808,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]); } @@ -829,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"); } } diff --git a/src/main/camhook/config-cam.c b/src/main/camhook/config-cam.c index e905f0b..05ed8de 100644 --- a/src/main/camhook/config-cam.c +++ b/src/main/camhook/config-cam.c @@ -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,17 +71,28 @@ 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_str( + if (!cconfig_util_get_bool( 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])) { + 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 '%s'", - camhook_config_device_id_keys[i], - camhook_config_device_default_values[i]); + "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], + 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]); } } } diff --git a/src/main/camhook/config-cam.h b/src/main/camhook/config-cam.h index f329108..893a20b 100644 --- a/src/main/camhook/config-cam.h +++ b/src/main/camhook/config-cam.h @@ -11,6 +11,7 @@ struct camhook_config_cam { bool disable_emu; size_t num_devices; char device_id[CAMHOOK_CONFIG_CAM_MAX][MAX_PATH]; + bool disable_camera[CAMHOOK_CONFIG_CAM_MAX]; }; void camhook_config_cam_init(struct cconfig *config, size_t num_cams);