@@ -124,6 +124,7 @@ ResourceManager::ResourceManager()
124124 detection_is_required = false ;
125125 dynamic_detectors_processed = false ;
126126 init_finished = false ;
127+ initial_detection = true ;
127128 background_thread_running = true ;
128129
129130 /* -----------------------------------------------------*\
@@ -1056,27 +1057,18 @@ void ResourceManager::DetectDevicesCoroutine()
10561057 DetectDeviceMutex.lock ();
10571058
10581059 hid_device_info* current_hid_device;
1059- float percent = 0 .0f ;
1060- float percent_denominator = 0 .0f ;
1060+ float percent = 0 .0f ;
1061+ float percent_denominator = 0 .0f ;
10611062 json detector_settings;
1062- unsigned int hid_device_count = 0 ;
1063- hid_device_info* hid_devices = NULL ;
1064- bool hid_safe_mode = false ;
1063+ unsigned int hid_device_count = 0 ;
1064+ hid_device_info* hid_devices = NULL ;
1065+ bool hid_safe_mode = false ;
1066+ unsigned int initial_detection_delay_ms = 0 ;
10651067
10661068 LOG_INFO (" ------------------------------------------------------" );
10671069 LOG_INFO (" | Start device detection |" );
10681070 LOG_INFO (" ------------------------------------------------------" );
10691071
1070- /* -----------------------------------------------------*\
1071- | Reset the size entry used flags vector |
1072- \*-----------------------------------------------------*/
1073- detection_size_entry_used.resize (rgb_controllers_sizes.size ());
1074-
1075- for (std::size_t size_idx = 0 ; size_idx < (unsigned int )detection_size_entry_used.size (); size_idx++)
1076- {
1077- detection_size_entry_used[size_idx] = false ;
1078- }
1079-
10801072 /* -----------------------------------------------------*\
10811073 | Open device disable list and read in disabled |
10821074 | device strings |
@@ -1091,6 +1083,39 @@ void ResourceManager::DetectDevicesCoroutine()
10911083 hid_safe_mode = detector_settings[" hid_safe_mode" ];
10921084 }
10931085
1086+ /* -----------------------------------------------------*\
1087+ | Check initial detection delay setting |
1088+ \*-----------------------------------------------------*/
1089+ if (detector_settings.contains (" initial_detection_delay_ms" ))
1090+ {
1091+ initial_detection_delay_ms = detector_settings[" initial_detection_delay_ms" ];
1092+ }
1093+
1094+ /* -----------------------------------------------------*\
1095+ | If configured, delay detection for the configured |
1096+ | time only on first detection |
1097+ \*-----------------------------------------------------*/
1098+ if (initial_detection)
1099+ {
1100+ if (initial_detection_delay_ms != 0 )
1101+ {
1102+ LOG_INFO (" [ResourceManager] Delaying detection for %d ms" , initial_detection_delay_ms);
1103+ std::this_thread::sleep_for (initial_detection_delay_ms * 1ms);
1104+ }
1105+
1106+ initial_detection = false ;
1107+ }
1108+
1109+ /* -----------------------------------------------------*\
1110+ | Reset the size entry used flags vector |
1111+ \*-----------------------------------------------------*/
1112+ detection_size_entry_used.resize (rgb_controllers_sizes.size ());
1113+
1114+ for (std::size_t size_idx = 0 ; size_idx < (unsigned int )detection_size_entry_used.size (); size_idx++)
1115+ {
1116+ detection_size_entry_used[size_idx] = false ;
1117+ }
1118+
10941119 /* -----------------------------------------------------*\
10951120 | Calculate the percentage denominator by adding the |
10961121 | number of I2C and miscellaneous detectors and the |
0 commit comments