Initial commit for Dream Cheeky Webmail Notifier
This commit is contained in:
parent
062ecf69f0
commit
bf630245d0
6 changed files with 285 additions and 0 deletions
83
Controllers/DreamCheekyController/DreamCheekyController.cpp
Normal file
83
Controllers/DreamCheekyController/DreamCheekyController.cpp
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
/*---------------------------------------------------------*\
|
||||
| DreamCheekyController.cpp |
|
||||
| |
|
||||
| Driver for Dream Cheeky devices |
|
||||
| |
|
||||
| Adam Honse (calcprogrammer1@gmail.com) 06 Sep 2024 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-only |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include <cstring>
|
||||
#include "DreamCheekyController.h"
|
||||
#include "StringUtils.h"
|
||||
|
||||
DreamCheekyController::DreamCheekyController(hid_device* dev_handle, const char* path)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = path;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| The Dream Cheeky Webmail Notifier requires four |
|
||||
| initialization packets before sending colors. |
|
||||
\*-----------------------------------------------------*/
|
||||
const unsigned char init_0[9] = { 0x00, 0x1F, 0x02, 0x00, 0x5F, 0x00, 0x00, 0x1F, 0x03 };
|
||||
const unsigned char init_1[9] = { 0x00, 0x00, 0x02, 0x00, 0x5F, 0x00, 0x00, 0x1F, 0x04 };
|
||||
const unsigned char init_2[9] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x05 };
|
||||
const unsigned char init_3[9] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 };
|
||||
|
||||
hid_write(dev, init_0, sizeof(init_0));
|
||||
hid_write(dev, init_1, sizeof(init_1));
|
||||
hid_write(dev, init_2, sizeof(init_2));
|
||||
hid_write(dev, init_3, sizeof(init_3));
|
||||
}
|
||||
|
||||
DreamCheekyController::~DreamCheekyController()
|
||||
{
|
||||
hid_close(dev);
|
||||
}
|
||||
|
||||
std::string DreamCheekyController::GetDeviceLocation()
|
||||
{
|
||||
return("HID: " + location);
|
||||
}
|
||||
|
||||
std::string DreamCheekyController::GetSerialString()
|
||||
{
|
||||
wchar_t serial_string[128];
|
||||
int ret = hid_get_serial_number_string(dev, serial_string, 128);
|
||||
|
||||
if(ret != 0)
|
||||
{
|
||||
return("");
|
||||
}
|
||||
|
||||
return(StringUtils::wstring_to_string(serial_string));
|
||||
}
|
||||
|
||||
void DreamCheekyController::SetColor(unsigned char red, unsigned char grn, unsigned char blu)
|
||||
{
|
||||
unsigned char usb_buf[9];
|
||||
|
||||
memset(usb_buf, 0, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| The Dream Cheeky Webmail Notifier color values range |
|
||||
| from 0-64, so we scale the 0-255 input range down by |
|
||||
| right shifting by 2 to get the range 0-63. Add 1 if |
|
||||
| the value is exactly 255 because otherwise the maximum|
|
||||
| value of 64 would never be reached. |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0] = 0x00;
|
||||
usb_buf[1] = (red >> 2) + (red == 255);
|
||||
usb_buf[2] = (grn >> 2) + (grn == 255);
|
||||
usb_buf[3] = (blu >> 2) + (blu == 255);
|
||||
usb_buf[4] = 0x00;
|
||||
usb_buf[5] = 0x00;
|
||||
usb_buf[6] = 0x00;
|
||||
usb_buf[7] = 0x1F;
|
||||
usb_buf[8] = 0x05;
|
||||
|
||||
hid_write(dev, usb_buf, sizeof(usb_buf));
|
||||
}
|
||||
31
Controllers/DreamCheekyController/DreamCheekyController.h
Normal file
31
Controllers/DreamCheekyController/DreamCheekyController.h
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/*---------------------------------------------------------*\
|
||||
| DreamCheekyController.h |
|
||||
| |
|
||||
| Driver for Dream Cheeky devices |
|
||||
| |
|
||||
| Adam Honse (calcprogrammer1@gmail.com) 06 Sep 2024 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-only |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <hidapi.h>
|
||||
|
||||
class DreamCheekyController
|
||||
{
|
||||
public:
|
||||
DreamCheekyController(hid_device* dev_handle, const char* path);
|
||||
~DreamCheekyController();
|
||||
|
||||
std::string GetDeviceLocation();
|
||||
std::string GetSerialString();
|
||||
|
||||
void SetColor(unsigned char red, unsigned char grn, unsigned char blu);
|
||||
|
||||
private:
|
||||
hid_device* dev;
|
||||
std::string location;
|
||||
};
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
/*---------------------------------------------------------*\
|
||||
| DreamCheekyControllerDetect.cpp |
|
||||
| |
|
||||
| Detector for Dream Cheeky devices |
|
||||
| |
|
||||
| Adam Honse (calcprogrammer1@gmail.com) 06 Sep 2024 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-only |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "Detector.h"
|
||||
#include "DreamCheekyController.h"
|
||||
#include "RGBController_DreamCheeky.h"
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Dream Cheeky USB Vendor ID |
|
||||
\*---------------------------------------------------------*/
|
||||
#define DREAM_CHEEKY_VID 0x1D34
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Dream Cheeky USB Product ID |
|
||||
\*---------------------------------------------------------*/
|
||||
#define DREAM_CHEEKY_WEBMAIL_NOTIFIER_PID 0x0004
|
||||
|
||||
void DetectDreamCheekyControllers(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
|
||||
if(dev)
|
||||
{
|
||||
DreamCheekyController* controller = new DreamCheekyController(dev, info->path);
|
||||
RGBController_DreamCheeky* rgb_controller = new RGBController_DreamCheeky(controller);
|
||||
rgb_controller->name = name;
|
||||
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
}
|
||||
|
||||
REGISTER_HID_DETECTOR( "Dream Cheeky Webmail Notifier", DetectDreamCheekyControllers, DREAM_CHEEKY_VID, DREAM_CHEEKY_WEBMAIL_NOTIFIER_PID );
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
/*---------------------------------------------------------*\
|
||||
| RGBController_DreamCheeky.cpp |
|
||||
| |
|
||||
| RGBController for Dream Cheeky devices |
|
||||
| |
|
||||
| Adam Honse (calcprogrammer1@gmail.com) 06 Sep 2024 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-only |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "RGBController_DreamCheeky.h"
|
||||
|
||||
RGBController_DreamCheeky::RGBController_DreamCheeky(DreamCheekyController* controller_ptr)
|
||||
{
|
||||
controller = controller_ptr;
|
||||
|
||||
name = "Dream Cheeky Device";
|
||||
type = DEVICE_TYPE_ACCESSORY;
|
||||
vendor = "Dream Cheeky";
|
||||
description = "Dream Cheeky 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_DreamCheeky::~RGBController_DreamCheeky()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_DreamCheeky::SetupZones()
|
||||
{
|
||||
zone mail_zone;
|
||||
mail_zone.name = "LED";
|
||||
mail_zone.type = ZONE_TYPE_SINGLE;
|
||||
mail_zone.leds_min = 1;
|
||||
mail_zone.leds_max = 1;
|
||||
mail_zone.leds_count = 1;
|
||||
mail_zone.matrix_map = NULL;
|
||||
zones.push_back(mail_zone);
|
||||
|
||||
led mail_led;
|
||||
mail_led.name = "LED";
|
||||
leds.push_back(mail_led);
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_DreamCheeky::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*-----------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_DreamCheeky::DeviceUpdateLEDs()
|
||||
{
|
||||
unsigned char red = RGBGetRValue(colors[0]);
|
||||
unsigned char grn = RGBGetGValue(colors[0]);
|
||||
unsigned char blu = RGBGetBValue(colors[0]);
|
||||
|
||||
controller->SetColor(red, grn, blu);
|
||||
}
|
||||
|
||||
void RGBController_DreamCheeky::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_DreamCheeky::UpdateSingleLED(int /*led*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_DreamCheeky::DeviceUpdateMode()
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_DreamCheeky::DeviceSaveMode()
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| This device does not support saving |
|
||||
\*-----------------------------------------------------*/
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
/*---------------------------------------------------------*\
|
||||
| RGBController_DreamCheeky.h |
|
||||
| |
|
||||
| RGBController for Dream Cheeky devices |
|
||||
| |
|
||||
| Adam Honse (calcprogrammer1@gmail.com) 06 Sep 2024 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-only |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "DreamCheekyController.h"
|
||||
#include "RGBController.h"
|
||||
|
||||
class RGBController_DreamCheeky : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_DreamCheeky(DreamCheekyController* controller_ptr);
|
||||
~RGBController_DreamCheeky();
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void DeviceUpdateMode();
|
||||
void DeviceSaveMode();
|
||||
|
||||
private:
|
||||
DreamCheekyController* controller;
|
||||
};
|
||||
|
|
@ -164,4 +164,5 @@ While no code from these projects directly made its way into OpenRGB, these proj
|
|||
* Signal RGB Plugins: https://gitlab.com/signalrgb/signal-plugins/-/tree/master/Plugins
|
||||
* k550-macos https://github.com/vookimedlo/ck550-macos/tree/master
|
||||
* luxafor-python https://github.com/vmitchell85/luxafor-python
|
||||
* dreamcheekyusb https://github.com/gbrayut/dreamcheekyusb
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue