diff --git a/Controllers/ClevoLightbarController/ClevoLightbarController.cpp b/Controllers/ClevoLightbarController/ClevoLightbarController.cpp new file mode 100644 index 000000000..d234ad24c --- /dev/null +++ b/Controllers/ClevoLightbarController/ClevoLightbarController.cpp @@ -0,0 +1,136 @@ +/*---------------------------------------------------------*\ +| ClevoLightbarController.cpp | +| | +| Driver for Clevo laptop lightbar (ITE 8291 rev 0.03) | +| Protocol based on tuxedo-drivers ite_8291_lb module | +| | +| Kyle Cascade (kyle@cascade.family) 16 Jan 2026 | +| | +| This file is part of the OpenRGB project | +| SPDX-License-Identifier: GPL-2.0-or-later | +\*---------------------------------------------------------*/ + +#include "ClevoLightbarController.h" +#include + +ClevoLightbarController::ClevoLightbarController(hid_device* dev_handle, const hid_device_info& info) +{ + dev = dev_handle; + location = info.path; +} + +ClevoLightbarController::~ClevoLightbarController() +{ + hid_close(dev); +} + +std::string ClevoLightbarController::GetDeviceLocation() +{ + return("HID: " + location); +} + +std::string ClevoLightbarController::GetSerialString() +{ + wchar_t serial_string[128]; + int ret = hid_get_serial_number_string(dev, serial_string, 128); + + if(ret != 0) + { + return(""); + } + + std::wstring return_wstring = serial_string; + std::string return_string(return_wstring.begin(), return_wstring.end()); + + return(return_string); +} + +void ClevoLightbarController::WriteControl(unsigned char* data) +{ + hid_send_feature_report(dev, data, CLEVO_LIGHTBAR_REPORT_SIZE); +} + +void ClevoLightbarController::TurnOn() +{ + /*---------------------------------------------------------*\ + | Not required for 0x7001 - device turns on when setting | + | color/brightness | + \*---------------------------------------------------------*/ +} + +void ClevoLightbarController::TurnOff() +{ + /*---------------------------------------------------------*\ + | Turn off sequence for device 0x7001 | + \*---------------------------------------------------------*/ + unsigned char buf[CLEVO_LIGHTBAR_REPORT_SIZE]; + + memset(buf, 0x00, CLEVO_LIGHTBAR_REPORT_SIZE); + buf[0] = 0x12; + buf[2] = 0x03; + WriteControl(buf); + + memset(buf, 0x00, CLEVO_LIGHTBAR_REPORT_SIZE); + buf[0] = 0x08; + buf[1] = 0x05; + WriteControl(buf); + + memset(buf, 0x00, CLEVO_LIGHTBAR_REPORT_SIZE); + buf[0] = 0x08; + buf[1] = 0x01; + WriteControl(buf); + + memset(buf, 0x00, CLEVO_LIGHTBAR_REPORT_SIZE); + buf[0] = 0x1A; + buf[7] = 0x01; + WriteControl(buf); +} + +void ClevoLightbarController::SetColor(unsigned char red, unsigned char green, unsigned char blue) +{ + /*---------------------------------------------------------*\ + | Set color: 0x14 0x00 0x01 R G B 0x00 0x00 | + \*---------------------------------------------------------*/ + unsigned char buf[CLEVO_LIGHTBAR_REPORT_SIZE]; + + memset(buf, 0x00, CLEVO_LIGHTBAR_REPORT_SIZE); + buf[0] = 0x14; + buf[1] = 0x00; + buf[2] = 0x01; + buf[3] = red; + buf[4] = green; + buf[5] = blue; + + WriteControl(buf); +} + +void ClevoLightbarController::SetBrightness(unsigned char brightness) +{ + /*---------------------------------------------------------*\ + | Set brightness (mono mode): | + | 0x08 0x22 0x01 0x01 brightness 0x01 0x00 0x00 | + \*---------------------------------------------------------*/ + unsigned char buf[CLEVO_LIGHTBAR_REPORT_SIZE]; + + memset(buf, 0x00, CLEVO_LIGHTBAR_REPORT_SIZE); + buf[0] = 0x08; + buf[1] = 0x22; + buf[2] = 0x01; + buf[3] = 0x01; + buf[4] = brightness; + buf[5] = 0x01; + + WriteControl(buf); +} + +void ClevoLightbarController::SetMode(unsigned char mode, unsigned char brightness, unsigned char speed) +{ + /*---------------------------------------------------------*\ + | Currently only direct (mono) mode is implemented | + | Breathing mode would be: 0x08 0x22 0x02 speed brightness | + \*---------------------------------------------------------*/ + (void)mode; + (void)speed; + + SetBrightness(brightness); +} diff --git a/Controllers/ClevoLightbarController/ClevoLightbarController.h b/Controllers/ClevoLightbarController/ClevoLightbarController.h new file mode 100644 index 000000000..c35540587 --- /dev/null +++ b/Controllers/ClevoLightbarController/ClevoLightbarController.h @@ -0,0 +1,52 @@ +/*---------------------------------------------------------*\ +| ClevoLightbarController.h | +| | +| Driver for Clevo laptop lightbar (ITE 8291 rev 0.03) | +| | +| Kyle Cascade (kyle@cascade.family) 16 Jan 2026 | +| | +| This file is part of the OpenRGB project | +| SPDX-License-Identifier: GPL-2.0-or-later | +\*---------------------------------------------------------*/ + +#pragma once + +#include "RGBController.h" +#include +#include + +#define CLEVO_LIGHTBAR_REPORT_SIZE 8 +#define CLEVO_LIGHTBAR_BRIGHTNESS_MIN 0 +#define CLEVO_LIGHTBAR_BRIGHTNESS_MAX 100 +#define CLEVO_LIGHTBAR_SPEED_MIN 1 +#define CLEVO_LIGHTBAR_SPEED_MAX 10 +#define CLEVO_LIGHTBAR_SPEED_DEFAULT 5 + +enum +{ + CLEVO_LIGHTBAR_MODE_DIRECT = 0, + CLEVO_LIGHTBAR_MODE_BREATHING = 1, + CLEVO_LIGHTBAR_MODE_OFF = 2 +}; + +class ClevoLightbarController +{ +public: + ClevoLightbarController(hid_device* dev_handle, const hid_device_info& info); + ~ClevoLightbarController(); + + std::string GetDeviceLocation(); + std::string GetSerialString(); + + void SetColor(unsigned char red, unsigned char green, unsigned char blue); + void SetBrightness(unsigned char brightness); + void SetMode(unsigned char mode, unsigned char brightness, unsigned char speed); + void TurnOn(); + void TurnOff(); + +private: + hid_device* dev; + std::string location; + + void WriteControl(unsigned char* data); +}; diff --git a/Controllers/ClevoLightbarController/ClevoLightbarControllerDetect.cpp b/Controllers/ClevoLightbarController/ClevoLightbarControllerDetect.cpp new file mode 100644 index 000000000..ce6c6e035 --- /dev/null +++ b/Controllers/ClevoLightbarController/ClevoLightbarControllerDetect.cpp @@ -0,0 +1,42 @@ +/*---------------------------------------------------------*\ +| ClevoLightbarControllerDetect.cpp | +| | +| Detector for Clevo laptop lightbar (ITE 8291 rev 0.03) | +| | +| Kyle Cascade (kyle@cascade.family) 16 Jan 2026 | +| | +| This file is part of the OpenRGB project | +| SPDX-License-Identifier: GPL-2.0-or-later | +\*---------------------------------------------------------*/ + +#include "Detector.h" +#include "ClevoLightbarController.h" +#include "RGBController_ClevoLightbar.h" +#include "RGBController.h" +#include + +/*-----------------------------------------------------*\ +| ITE Tech vendor ID | +\*-----------------------------------------------------*/ +#define ITE_VID 0x048D + +/*-----------------------------------------------------*\ +| CLEVO Lightbar product ID | +\*-----------------------------------------------------*/ +#define CLEVO_LIGHTBAR_PID 0x7001 + +void DetectClevoLightbarControllers(hid_device_info* info, const std::string& name) +{ + hid_device* dev = hid_open_path(info->path); + + if(dev) + { + ClevoLightbarController* controller = new ClevoLightbarController(dev, *info); + RGBController_ClevoLightbar* rgb_controller = new RGBController_ClevoLightbar(controller); + rgb_controller->name = name; + + ResourceManager::get()->RegisterRGBController(rgb_controller); + } +} + +REGISTER_HID_DETECTOR_PU("CLEVO Lightbar", DetectClevoLightbarControllers, ITE_VID, CLEVO_LIGHTBAR_PID, 0xFF03, 0x02); diff --git a/Controllers/ClevoLightbarController/RGBController_ClevoLightbar.cpp b/Controllers/ClevoLightbarController/RGBController_ClevoLightbar.cpp new file mode 100644 index 000000000..a87a0a2d8 --- /dev/null +++ b/Controllers/ClevoLightbarController/RGBController_ClevoLightbar.cpp @@ -0,0 +1,112 @@ +/*---------------------------------------------------------*\ +| RGBController_ClevoLightbar.cpp | +| | +| Generic RGB Interface for Clevo laptop lightbar | +| | +| Kyle Cascade (kyle@cascade.family) 16 Jan 2026 | +| | +| This file is part of the OpenRGB project | +| SPDX-License-Identifier: GPL-2.0-or-later | +\*---------------------------------------------------------*/ + +#include "RGBController_ClevoLightbar.h" + +/**------------------------------------------------------------------*\ + @name CLEVO Lightbar + @category LEDStrip + @type USB + @save :x: + @direct :white_check_mark: + @effects :x: + @detectors DetectClevoLightbarControllers + @comment +\*-------------------------------------------------------------------*/ + +RGBController_ClevoLightbar::RGBController_ClevoLightbar(ClevoLightbarController* controller_ptr) +{ + controller = controller_ptr; + + name = "CLEVO Lightbar"; + vendor = "CLEVO Computers"; + type = DEVICE_TYPE_LEDSTRIP; + description = "CLEVO Laptop Lightbar"; + location = controller->GetDeviceLocation(); + serial = controller->GetSerialString(); + + mode Direct; + Direct.name = "Direct"; + Direct.value = CLEVO_LIGHTBAR_MODE_DIRECT; + Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_BRIGHTNESS; + Direct.color_mode = MODE_COLORS_PER_LED; + Direct.brightness_min = CLEVO_LIGHTBAR_BRIGHTNESS_MIN; + Direct.brightness_max = CLEVO_LIGHTBAR_BRIGHTNESS_MAX; + Direct.brightness = CLEVO_LIGHTBAR_BRIGHTNESS_MAX; + modes.push_back(Direct); + + mode Off; + Off.name = "Off"; + Off.value = CLEVO_LIGHTBAR_MODE_OFF; + Off.flags = 0; + Off.color_mode = MODE_COLORS_NONE; + modes.push_back(Off); + + SetupZones(); +} + +RGBController_ClevoLightbar::~RGBController_ClevoLightbar() +{ + delete controller; +} + +void RGBController_ClevoLightbar::SetupZones() +{ + zone lightbar_zone; + lightbar_zone.name = "Lightbar"; + lightbar_zone.type = ZONE_TYPE_SINGLE; + lightbar_zone.leds_min = 1; + lightbar_zone.leds_max = 1; + lightbar_zone.leds_count = 1; + lightbar_zone.matrix_map = NULL; + zones.push_back(lightbar_zone); + + led lightbar_led; + lightbar_led.name = "Lightbar"; + leds.push_back(lightbar_led); + + SetupColors(); +} + +void RGBController_ClevoLightbar::ResizeZone(int /*zone*/, int /*new_size*/) +{ + /*---------------------------------------------------------*\ + | This device does not support resizing zones | + \*---------------------------------------------------------*/ +} + +void RGBController_ClevoLightbar::DeviceUpdateLEDs() +{ + unsigned char red = RGBGetRValue(colors[0]); + unsigned char green = RGBGetGValue(colors[0]); + unsigned char blue = RGBGetBValue(colors[0]); + + controller->SetColor(red, green, blue); + controller->SetBrightness(modes[active_mode].brightness); +} + +void RGBController_ClevoLightbar::UpdateZoneLEDs(int /*zone*/) +{ + DeviceUpdateLEDs(); +} + +void RGBController_ClevoLightbar::UpdateSingleLED(int /*led*/) +{ + DeviceUpdateLEDs(); +} + +void RGBController_ClevoLightbar::DeviceUpdateMode() +{ + if(modes[active_mode].value == CLEVO_LIGHTBAR_MODE_OFF) + { + controller->TurnOff(); + } +} diff --git a/Controllers/ClevoLightbarController/RGBController_ClevoLightbar.h b/Controllers/ClevoLightbarController/RGBController_ClevoLightbar.h new file mode 100644 index 000000000..a429cfdb1 --- /dev/null +++ b/Controllers/ClevoLightbarController/RGBController_ClevoLightbar.h @@ -0,0 +1,34 @@ +/*---------------------------------------------------------*\ +| RGBController_ClevoLightbar.h | +| | +| Generic RGB Interface for Clevo laptop lightbar | +| | +| Kyle Cascade (kyle@cascade.family) 16 Jan 2026 | +| | +| This file is part of the OpenRGB project | +| SPDX-License-Identifier: GPL-2.0-or-later | +\*---------------------------------------------------------*/ + +#pragma once + +#include "RGBController.h" +#include "ClevoLightbarController.h" + +class RGBController_ClevoLightbar : public RGBController +{ +public: + RGBController_ClevoLightbar(ClevoLightbarController* controller_ptr); + ~RGBController_ClevoLightbar(); + + void SetupZones(); + void ResizeZone(int zone, int new_size); + + void DeviceUpdateLEDs(); + void UpdateZoneLEDs(int zone); + void UpdateSingleLED(int led); + + void DeviceUpdateMode(); + +private: + ClevoLightbarController* controller; +};