mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2026-01-19 04:27:51 -05:00
64 lines
2.6 KiB
C++
64 lines
2.6 KiB
C++
/*---------------------------------------------------------*\
|
|
| YeelightControllerDetect.cpp |
|
|
| |
|
|
| Detector for Yeelight |
|
|
| |
|
|
| Adam Honse (CalcProgrammer1) 18 Jan 2021 |
|
|
| |
|
|
| This file is part of the OpenRGB project |
|
|
| SPDX-License-Identifier: GPL-2.0-or-later |
|
|
\*---------------------------------------------------------*/
|
|
|
|
#include "DetectionManager.h"
|
|
#include "ResourceManager.h"
|
|
#include "RGBController_Yeelight.h"
|
|
#include "SettingsManager.h"
|
|
#include "YeelightController.h"
|
|
|
|
DetectedControllers DetectYeelightControllers()
|
|
{
|
|
DetectedControllers detected_controllers;
|
|
json yeelight_settings;
|
|
|
|
/*-----------------------------------------------------*\
|
|
| Get Yeelight settings from settings manager |
|
|
\*-----------------------------------------------------*/
|
|
yeelight_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("YeelightDevices");
|
|
|
|
/*-----------------------------------------------------*\
|
|
| If the Yeelight settings contains devices, process |
|
|
\*-----------------------------------------------------*/
|
|
if(yeelight_settings.contains("devices"))
|
|
{
|
|
for(unsigned int device_idx = 0; device_idx < yeelight_settings["devices"].size(); device_idx++)
|
|
{
|
|
std::string yeelight_host_ip;
|
|
|
|
if(yeelight_settings["devices"][device_idx].contains("host_ip"))
|
|
{
|
|
yeelight_host_ip = yeelight_settings["devices"][device_idx]["host_ip"];
|
|
}
|
|
|
|
if(yeelight_settings["devices"][device_idx].contains("ip"))
|
|
{
|
|
std::string yeelight_ip = yeelight_settings["devices"][device_idx]["ip"];
|
|
bool music_mode = false;
|
|
|
|
if(yeelight_settings["devices"][device_idx].contains("music_mode"))
|
|
{
|
|
music_mode = yeelight_settings["devices"][device_idx]["music_mode"];
|
|
}
|
|
|
|
YeelightController* controller = new YeelightController(yeelight_ip, yeelight_host_ip, music_mode);
|
|
RGBController_Yeelight* rgb_controller = new RGBController_Yeelight(controller);
|
|
|
|
detected_controllers.push_back(rgb_controller);
|
|
}
|
|
}
|
|
}
|
|
|
|
return(detected_controllers);
|
|
}
|
|
|
|
REGISTER_DETECTOR("Yeelight", DetectYeelightControllers);
|