MCPcopy Create free account
hub / github.com/CalcProgrammer1/OpenRGB / LoadDeviceFromListWithOptions

Method LoadDeviceFromListWithOptions

ProfileManager.cpp:206–351  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

204}
205
206bool ProfileManager::LoadDeviceFromListWithOptions
207 (
208 std::vector<RGBController*>& temp_controllers,
209 std::vector<bool>& temp_controller_used,
210 RGBController* load_controller,
211 bool load_size,
212 bool load_settings
213 )
214{
215 for(std::size_t temp_index = 0; temp_index < temp_controllers.size(); temp_index++)
216 {
217 RGBController *temp_controller = temp_controllers[temp_index];
218
219 /*---------------------------------------------------------*\
220 | Do not compare location string for HID devices, as the |
221 | location string may change between runs as devices are |
222 | connected and disconnected. Also do not compare the I2C |
223 | bus number, since it is not persistent across reboots |
224 | on Linux - strip the I2C number and compare only address. |
225 \*---------------------------------------------------------*/
226 bool location_check;
227
228 if(load_controller->location.find("HID: ") == 0)
229 {
230 location_check = true;
231 }
232 else if(load_controller->location.find("I2C: ") == 0)
233 {
234 std::size_t loc = load_controller->location.rfind(", ");
235 if(loc == std::string::npos)
236 {
237 location_check = false;
238 }
239 else
240 {
241 std::string i2c_address = load_controller->location.substr(loc + 2);
242 location_check = temp_controller->location.find(i2c_address) != std::string::npos;
243 }
244 }
245 else
246 {
247 location_check = temp_controller->location == load_controller->location;
248 }
249
250 /*---------------------------------------------------------*\
251 | Test if saved controller data matches this controller |
252 \*---------------------------------------------------------*/
253 if((temp_controller_used[temp_index] == false )
254 &&(temp_controller->type == load_controller->type )
255 &&(temp_controller->name == load_controller->name )
256 &&(temp_controller->description == load_controller->description)
257 &&(temp_controller->version == load_controller->version )
258 &&(temp_controller->serial == load_controller->serial )
259 &&(location_check == true ))
260 {
261 /*---------------------------------------------------------*\
262 | Set used flag for this temp device |
263 \*---------------------------------------------------------*/

Callers 2

RegisterRGBControllerMethod · 0.80

Calls 4

sizeMethod · 0.45
findMethod · 0.45
ResizeZoneMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected