| 545 | } |
| 546 | |
| 547 | bool OptionDevice(std::vector<DeviceOptions>* current_devices, std::string argument, Options* options, std::vector<RGBController *>& rgb_controllers) |
| 548 | { |
| 549 | bool found = false; |
| 550 | ResourceManager::get()->WaitForDeviceDetection(); |
| 551 | |
| 552 | try |
| 553 | { |
| 554 | int current_device = std::stoi(argument); |
| 555 | |
| 556 | if((current_device >= static_cast<int>(rgb_controllers.size())) || (current_device < 0)) |
| 557 | { |
| 558 | throw nullptr; |
| 559 | } |
| 560 | |
| 561 | DeviceOptions newDev; |
| 562 | newDev.device = current_device; |
| 563 | |
| 564 | if(!options->hasDevice) |
| 565 | { |
| 566 | options->hasDevice = true; |
| 567 | } |
| 568 | |
| 569 | current_devices->push_back(newDev); |
| 570 | |
| 571 | found = true; |
| 572 | } |
| 573 | catch(...) |
| 574 | { |
| 575 | if(argument.length() > 1) |
| 576 | { |
| 577 | for(unsigned int i = 0; i < rgb_controllers.size(); i++) |
| 578 | { |
| 579 | /*---------------------------------------------------------*\ |
| 580 | | If the argument is not a number then check all the | |
| 581 | | controllers names for a match | |
| 582 | \*---------------------------------------------------------*/ |
| 583 | std::string name = rgb_controllers[i]->name; |
| 584 | std::transform(name.begin(), name.end(), name.begin(), ::tolower); |
| 585 | std::transform(argument.begin(), argument.end(), argument.begin(), ::tolower); |
| 586 | |
| 587 | if(name.find(argument) != std::string::npos) |
| 588 | { |
| 589 | found = true; |
| 590 | |
| 591 | DeviceOptions newDev; |
| 592 | newDev.device = i; |
| 593 | |
| 594 | if(!options->hasDevice) |
| 595 | { |
| 596 | options->hasDevice = true; |
| 597 | } |
| 598 | |
| 599 | current_devices->push_back(newDev); |
| 600 | } |
| 601 | } |
| 602 | } |
| 603 | else |
| 604 | { |
no test coverage detected