Files
OpenRGB/Controllers/HIDLampArrayController/HIDLampArrayControllerDetect.cpp
2026-02-02 23:25:19 -06:00

51 lines
1.8 KiB
C++

/*---------------------------------------------------------*\
| HIDLampArrayControllerDetect.cpp |
| |
| Detector for HID LampArray Devices |
| |
| Adam Honse (calcprogrammer1@gmail.com) 26 Mar 2024 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-only |
\*---------------------------------------------------------*/
#include "DetectionManager.h"
#include "HIDLampArrayController.h"
#include "RGBController.h"
#include "RGBController_HIDLampArray.h"
#include <vector>
#include <hidapi.h>
DetectedControllers DetectHIDLampArrayControllers(hid_device_info* info, const std::string& /*name*/)
{
DetectedControllers detected_controllers;
hid_device* dev;
dev = hid_open_path(info->path);
if(dev)
{
HIDLampArrayController* controller = new HIDLampArrayController(dev, info->path);
/*-------------------------------------------------*\
| Only create the RGBController if there are lamps |
| detected in the controller. Otherwise, delete |
| the controller. |
\*-------------------------------------------------*/
if(controller->GetLampCount() > 0)
{
RGBController_HIDLampArray* rgb_controller = new RGBController_HIDLampArray(controller);
detected_controllers.push_back(rgb_controller);
}
else
{
delete controller;
}
}
return(detected_controllers);
}
REGISTER_HID_DETECTOR_PU_ONLY("HID LampArray Device", DetectHIDLampArrayControllers, 0x59, 0x01);