| 409 | } |
| 410 | |
| 411 | void ResourceManager::UpdateDeviceList() |
| 412 | { |
| 413 | DeviceListChangeMutex.lock(); |
| 414 | |
| 415 | /*-------------------------------------------------*\ |
| 416 | | Insert hardware controllers into controller list | |
| 417 | \*-------------------------------------------------*/ |
| 418 | for(unsigned int hw_controller_idx = 0; hw_controller_idx < rgb_controllers_hw.size(); hw_controller_idx++) |
| 419 | { |
| 420 | /*-------------------------------------------------*\ |
| 421 | | Check if the controller is already in the list | |
| 422 | | at the correct index | |
| 423 | \*-------------------------------------------------*/ |
| 424 | if(hw_controller_idx < rgb_controllers.size()) |
| 425 | { |
| 426 | if(rgb_controllers[hw_controller_idx] == rgb_controllers_hw[hw_controller_idx]) |
| 427 | { |
| 428 | continue; |
| 429 | } |
| 430 | } |
| 431 | |
| 432 | /*-------------------------------------------------*\ |
| 433 | | If not, check if the controller is already in the | |
| 434 | | list at a different index | |
| 435 | \*-------------------------------------------------*/ |
| 436 | for(unsigned int controller_idx = 0; controller_idx < rgb_controllers.size(); controller_idx++) |
| 437 | { |
| 438 | if(rgb_controllers[controller_idx] == rgb_controllers_hw[hw_controller_idx]) |
| 439 | { |
| 440 | rgb_controllers.erase(rgb_controllers.begin() + controller_idx); |
| 441 | rgb_controllers.insert(rgb_controllers.begin() + hw_controller_idx, rgb_controllers_hw[hw_controller_idx]); |
| 442 | break; |
| 443 | } |
| 444 | } |
| 445 | |
| 446 | /*-------------------------------------------------*\ |
| 447 | | If it still hasn't been found, add it to the list | |
| 448 | \*-------------------------------------------------*/ |
| 449 | rgb_controllers.insert(rgb_controllers.begin() + hw_controller_idx, rgb_controllers_hw[hw_controller_idx]); |
| 450 | } |
| 451 | |
| 452 | /*-------------------------------------------------*\ |
| 453 | | Device list has changed, call the callbacks | |
| 454 | \*-------------------------------------------------*/ |
| 455 | DeviceListChanged(); |
| 456 | |
| 457 | /*-------------------------------------------------*\ |
| 458 | | Device list has changed, inform all clients | |
| 459 | | connected to this server | |
| 460 | \*-------------------------------------------------*/ |
| 461 | server->DeviceListChanged(); |
| 462 | |
| 463 | DeviceListChangeMutex.unlock(); |
| 464 | } |
| 465 | |
| 466 | void ResourceManager::DeviceListChanged() |
| 467 | { |
nothing calls this directly
no test coverage detected