From ac33a841ff12da3eb2ed1270594001627b102d59 Mon Sep 17 00:00:00 2001 From: Adam Honse Date: Sun, 31 Mar 2024 01:03:12 -0500 Subject: [PATCH] Initial commit for HID LampArray Controller --- .../HIDLampArrayController.cpp | 21 +++++++ .../HIDLampArrayController.h | 20 +++++++ .../HIDLampArrayControllerDetect.cpp | 22 +++++++ .../RGBController_HIDLampArray.cpp | 57 +++++++++++++++++++ .../RGBController_HIDLampArray.h | 30 ++++++++++ 5 files changed, 150 insertions(+) create mode 100644 Controllers/HIDLampArrayController/HIDLampArrayController.cpp create mode 100644 Controllers/HIDLampArrayController/HIDLampArrayController.h create mode 100644 Controllers/HIDLampArrayController/HIDLampArrayControllerDetect.cpp create mode 100644 Controllers/HIDLampArrayController/RGBController_HIDLampArray.cpp create mode 100644 Controllers/HIDLampArrayController/RGBController_HIDLampArray.h diff --git a/Controllers/HIDLampArrayController/HIDLampArrayController.cpp b/Controllers/HIDLampArrayController/HIDLampArrayController.cpp new file mode 100644 index 000000000..2f01d85e1 --- /dev/null +++ b/Controllers/HIDLampArrayController/HIDLampArrayController.cpp @@ -0,0 +1,21 @@ +#include "HIDLampArrayController.h" + +HIDLampArrayController::HIDLampArrayController(hid_device *dev_handle, const char *path) +{ + +} + +HIDLampArrayController::~HIDLampArrayController() +{ + +} + +std::string HIDLampArrayController::GetDeviceLocation() +{ + +} + +std::string HIDLampArrayController::GetSerialString() +{ + +} diff --git a/Controllers/HIDLampArrayController/HIDLampArrayController.h b/Controllers/HIDLampArrayController/HIDLampArrayController.h new file mode 100644 index 000000000..fae9ab78e --- /dev/null +++ b/Controllers/HIDLampArrayController/HIDLampArrayController.h @@ -0,0 +1,20 @@ +#pragma once + +#include +#include + +#include "RGBController.h" + +class HIDLampArrayController +{ +public: + HIDLampArrayController(hid_device *dev_handle, const char *path); + ~HIDLampArrayController(); + + std::string GetDeviceLocation(); + std::string GetSerialString(); + +private: + hid_device *dev; + std::string location; +}; diff --git a/Controllers/HIDLampArrayController/HIDLampArrayControllerDetect.cpp b/Controllers/HIDLampArrayController/HIDLampArrayControllerDetect.cpp new file mode 100644 index 000000000..fe08fda5c --- /dev/null +++ b/Controllers/HIDLampArrayController/HIDLampArrayControllerDetect.cpp @@ -0,0 +1,22 @@ +#include "Detector.h" +#include "HIDLampArrayController.h" +#include "RGBController.h" +#include "RGBController_HIDLampArray.h" +#include +#include + +void DetectHIDLampArrayControllers(hid_device_info* info, const std::string& name) +{ + hid_device* dev = hid_open_path(info->path); + + if(dev) + { + HIDLampArrayController* controller = new HIDLampArrayController(dev, info->path); + RGBController_HIDLampArray* rgb_controller = new RGBController_HIDLampArray(controller); + rgb_controller->name = name; + + ResourceManager::get()->RegisterRGBController(rgb_controller); + } +} /* DetectHIDLampArrayControllers() */ + +REGISTER_HID_DETECTOR("Arduino Zero HID Lamp Array Demo", DetectHIDLampArrayControllers, 0x2341, 0x804D); diff --git a/Controllers/HIDLampArrayController/RGBController_HIDLampArray.cpp b/Controllers/HIDLampArrayController/RGBController_HIDLampArray.cpp new file mode 100644 index 000000000..04793ae3d --- /dev/null +++ b/Controllers/HIDLampArrayController/RGBController_HIDLampArray.cpp @@ -0,0 +1,57 @@ +#include "RGBController_HIDLampArray.h" + +RGBController_HIDLampArray::RGBController_HIDLampArray(HIDLampArrayController* controller_ptr) +{ + controller = controller_ptr; + + name = "HID LampArray Device"; + vendor = "Generic"; + type = DEVICE_TYPE_MOUSEMAT; + description = "HID LampArray Device"; + location = controller->GetDeviceLocation(); + serial = controller->GetSerialString(); + + mode Direct; + Direct.name = "Direct"; + Direct.value = 0; + Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR; + Direct.color_mode = MODE_COLORS_PER_LED; + modes.push_back(Direct); + + SetupZones(); +} + +RGBController_HIDLampArray::~RGBController_HIDLampArray() +{ + +} + +void RGBController_HIDLampArray::SetupZones() +{ + +} + +void RGBController_HIDLampArray::ResizeZone(int /*zone*/, int /*new_size*/) +{ + +} + +void RGBController_HIDLampArray::DeviceUpdateLEDs() +{ + +} + +void RGBController_HIDLampArray::UpdateZoneLEDs(int /*zone*/) +{ + +} + +void RGBController_HIDLampArray::UpdateSingleLED(int /*led*/) +{ + +} + +void RGBController_HIDLampArray::DeviceUpdateMode() +{ + +} diff --git a/Controllers/HIDLampArrayController/RGBController_HIDLampArray.h b/Controllers/HIDLampArrayController/RGBController_HIDLampArray.h new file mode 100644 index 000000000..35b2b4551 --- /dev/null +++ b/Controllers/HIDLampArrayController/RGBController_HIDLampArray.h @@ -0,0 +1,30 @@ +/*-----------------------------------------------------*\ +| RGBController_HIDLampArray.h | +| | +| Generic RGB Interface HID LampArray Devices | +| | +| Adam Honse 3/26/2024 | +\*-----------------------------------------------------*/ + +#pragma once +#include "RGBController.h" +#include "HIDLampArrayController.h" + +class RGBController_HIDLampArray : public RGBController +{ +public: + RGBController_HIDLampArray(HIDLampArrayController* controller_ptr); + ~RGBController_HIDLampArray(); + + void SetupZones(); + void ResizeZone(int zone, int new_size); + + void DeviceUpdateLEDs(); + void UpdateZoneLEDs(int zone); + void UpdateSingleLED(int led); + + void DeviceUpdateMode(); + +private: + HIDLampArrayController* controller; +};