Skip to content

Commit bf63024

Browse files
Initial commit for Dream Cheeky Webmail Notifier
1 parent 062ecf6 commit bf63024

File tree

6 files changed

+285
-0
lines changed

6 files changed

+285
-0
lines changed
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/*---------------------------------------------------------*\
2+
| DreamCheekyController.cpp |
3+
| |
4+
| Driver for Dream Cheeky devices |
5+
| |
6+
| Adam Honse (calcprogrammer1@gmail.com) 06 Sep 2024 |
7+
| |
8+
| This file is part of the OpenRGB project |
9+
| SPDX-License-Identifier: GPL-2.0-only |
10+
\*---------------------------------------------------------*/
11+
12+
#include <cstring>
13+
#include "DreamCheekyController.h"
14+
#include "StringUtils.h"
15+
16+
DreamCheekyController::DreamCheekyController(hid_device* dev_handle, const char* path)
17+
{
18+
dev = dev_handle;
19+
location = path;
20+
21+
/*-----------------------------------------------------*\
22+
| The Dream Cheeky Webmail Notifier requires four |
23+
| initialization packets before sending colors. |
24+
\*-----------------------------------------------------*/
25+
const unsigned char init_0[9] = { 0x00, 0x1F, 0x02, 0x00, 0x5F, 0x00, 0x00, 0x1F, 0x03 };
26+
const unsigned char init_1[9] = { 0x00, 0x00, 0x02, 0x00, 0x5F, 0x00, 0x00, 0x1F, 0x04 };
27+
const unsigned char init_2[9] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x05 };
28+
const unsigned char init_3[9] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 };
29+
30+
hid_write(dev, init_0, sizeof(init_0));
31+
hid_write(dev, init_1, sizeof(init_1));
32+
hid_write(dev, init_2, sizeof(init_2));
33+
hid_write(dev, init_3, sizeof(init_3));
34+
}
35+
36+
DreamCheekyController::~DreamCheekyController()
37+
{
38+
hid_close(dev);
39+
}
40+
41+
std::string DreamCheekyController::GetDeviceLocation()
42+
{
43+
return("HID: " + location);
44+
}
45+
46+
std::string DreamCheekyController::GetSerialString()
47+
{
48+
wchar_t serial_string[128];
49+
int ret = hid_get_serial_number_string(dev, serial_string, 128);
50+
51+
if(ret != 0)
52+
{
53+
return("");
54+
}
55+
56+
return(StringUtils::wstring_to_string(serial_string));
57+
}
58+
59+
void DreamCheekyController::SetColor(unsigned char red, unsigned char grn, unsigned char blu)
60+
{
61+
unsigned char usb_buf[9];
62+
63+
memset(usb_buf, 0, sizeof(usb_buf));
64+
65+
/*-----------------------------------------------------*\
66+
| The Dream Cheeky Webmail Notifier color values range |
67+
| from 0-64, so we scale the 0-255 input range down by |
68+
| right shifting by 2 to get the range 0-63. Add 1 if |
69+
| the value is exactly 255 because otherwise the maximum|
70+
| value of 64 would never be reached. |
71+
\*-----------------------------------------------------*/
72+
usb_buf[0] = 0x00;
73+
usb_buf[1] = (red >> 2) + (red == 255);
74+
usb_buf[2] = (grn >> 2) + (grn == 255);
75+
usb_buf[3] = (blu >> 2) + (blu == 255);
76+
usb_buf[4] = 0x00;
77+
usb_buf[5] = 0x00;
78+
usb_buf[6] = 0x00;
79+
usb_buf[7] = 0x1F;
80+
usb_buf[8] = 0x05;
81+
82+
hid_write(dev, usb_buf, sizeof(usb_buf));
83+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*---------------------------------------------------------*\
2+
| DreamCheekyController.h |
3+
| |
4+
| Driver for Dream Cheeky devices |
5+
| |
6+
| Adam Honse (calcprogrammer1@gmail.com) 06 Sep 2024 |
7+
| |
8+
| This file is part of the OpenRGB project |
9+
| SPDX-License-Identifier: GPL-2.0-only |
10+
\*---------------------------------------------------------*/
11+
12+
#pragma once
13+
14+
#include <string>
15+
#include <hidapi.h>
16+
17+
class DreamCheekyController
18+
{
19+
public:
20+
DreamCheekyController(hid_device* dev_handle, const char* path);
21+
~DreamCheekyController();
22+
23+
std::string GetDeviceLocation();
24+
std::string GetSerialString();
25+
26+
void SetColor(unsigned char red, unsigned char grn, unsigned char blu);
27+
28+
private:
29+
hid_device* dev;
30+
std::string location;
31+
};
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*---------------------------------------------------------*\
2+
| DreamCheekyControllerDetect.cpp |
3+
| |
4+
| Detector for Dream Cheeky devices |
5+
| |
6+
| Adam Honse (calcprogrammer1@gmail.com) 06 Sep 2024 |
7+
| |
8+
| This file is part of the OpenRGB project |
9+
| SPDX-License-Identifier: GPL-2.0-only |
10+
\*---------------------------------------------------------*/
11+
12+
#include "Detector.h"
13+
#include "DreamCheekyController.h"
14+
#include "RGBController_DreamCheeky.h"
15+
16+
/*---------------------------------------------------------*\
17+
| Dream Cheeky USB Vendor ID |
18+
\*---------------------------------------------------------*/
19+
#define DREAM_CHEEKY_VID 0x1D34
20+
21+
/*---------------------------------------------------------*\
22+
| Dream Cheeky USB Product ID |
23+
\*---------------------------------------------------------*/
24+
#define DREAM_CHEEKY_WEBMAIL_NOTIFIER_PID 0x0004
25+
26+
void DetectDreamCheekyControllers(hid_device_info* info, const std::string& name)
27+
{
28+
hid_device* dev = hid_open_path(info->path);
29+
30+
if(dev)
31+
{
32+
DreamCheekyController* controller = new DreamCheekyController(dev, info->path);
33+
RGBController_DreamCheeky* rgb_controller = new RGBController_DreamCheeky(controller);
34+
rgb_controller->name = name;
35+
36+
ResourceManager::get()->RegisterRGBController(rgb_controller);
37+
}
38+
}
39+
40+
REGISTER_HID_DETECTOR( "Dream Cheeky Webmail Notifier", DetectDreamCheekyControllers, DREAM_CHEEKY_VID, DREAM_CHEEKY_WEBMAIL_NOTIFIER_PID );
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
/*---------------------------------------------------------*\
2+
| RGBController_DreamCheeky.cpp |
3+
| |
4+
| RGBController for Dream Cheeky devices |
5+
| |
6+
| Adam Honse (calcprogrammer1@gmail.com) 06 Sep 2024 |
7+
| |
8+
| This file is part of the OpenRGB project |
9+
| SPDX-License-Identifier: GPL-2.0-only |
10+
\*---------------------------------------------------------*/
11+
12+
#include "RGBController_DreamCheeky.h"
13+
14+
RGBController_DreamCheeky::RGBController_DreamCheeky(DreamCheekyController* controller_ptr)
15+
{
16+
controller = controller_ptr;
17+
18+
name = "Dream Cheeky Device";
19+
type = DEVICE_TYPE_ACCESSORY;
20+
vendor = "Dream Cheeky";
21+
description = "Dream Cheeky Device";
22+
location = controller->GetDeviceLocation();
23+
serial = controller->GetSerialString();
24+
25+
mode Direct;
26+
Direct.name = "Direct";
27+
Direct.value = 0;
28+
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
29+
Direct.color_mode = MODE_COLORS_PER_LED;
30+
modes.push_back(Direct);
31+
32+
SetupZones();
33+
}
34+
35+
RGBController_DreamCheeky::~RGBController_DreamCheeky()
36+
{
37+
38+
}
39+
40+
void RGBController_DreamCheeky::SetupZones()
41+
{
42+
zone mail_zone;
43+
mail_zone.name = "LED";
44+
mail_zone.type = ZONE_TYPE_SINGLE;
45+
mail_zone.leds_min = 1;
46+
mail_zone.leds_max = 1;
47+
mail_zone.leds_count = 1;
48+
mail_zone.matrix_map = NULL;
49+
zones.push_back(mail_zone);
50+
51+
led mail_led;
52+
mail_led.name = "LED";
53+
leds.push_back(mail_led);
54+
55+
SetupColors();
56+
}
57+
58+
void RGBController_DreamCheeky::ResizeZone(int /*zone*/, int /*new_size*/)
59+
{
60+
/*-----------------------------------------------------*\
61+
| This device does not support resizing zones |
62+
\*-----------------------------------------------------*/
63+
}
64+
65+
void RGBController_DreamCheeky::DeviceUpdateLEDs()
66+
{
67+
unsigned char red = RGBGetRValue(colors[0]);
68+
unsigned char grn = RGBGetGValue(colors[0]);
69+
unsigned char blu = RGBGetBValue(colors[0]);
70+
71+
controller->SetColor(red, grn, blu);
72+
}
73+
74+
void RGBController_DreamCheeky::UpdateZoneLEDs(int /*zone*/)
75+
{
76+
DeviceUpdateLEDs();
77+
}
78+
79+
void RGBController_DreamCheeky::UpdateSingleLED(int /*led*/)
80+
{
81+
DeviceUpdateLEDs();
82+
}
83+
84+
void RGBController_DreamCheeky::DeviceUpdateMode()
85+
{
86+
DeviceUpdateLEDs();
87+
}
88+
89+
void RGBController_DreamCheeky::DeviceSaveMode()
90+
{
91+
/*-----------------------------------------------------*\
92+
| This device does not support saving |
93+
\*-----------------------------------------------------*/
94+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*---------------------------------------------------------*\
2+
| RGBController_DreamCheeky.h |
3+
| |
4+
| RGBController for Dream Cheeky devices |
5+
| |
6+
| Adam Honse (calcprogrammer1@gmail.com) 06 Sep 2024 |
7+
| |
8+
| This file is part of the OpenRGB project |
9+
| SPDX-License-Identifier: GPL-2.0-only |
10+
\*---------------------------------------------------------*/
11+
12+
#pragma once
13+
14+
#include "DreamCheekyController.h"
15+
#include "RGBController.h"
16+
17+
class RGBController_DreamCheeky : public RGBController
18+
{
19+
public:
20+
RGBController_DreamCheeky(DreamCheekyController* controller_ptr);
21+
~RGBController_DreamCheeky();
22+
23+
void SetupZones();
24+
25+
void ResizeZone(int zone, int new_size);
26+
27+
void DeviceUpdateLEDs();
28+
void UpdateZoneLEDs(int zone);
29+
void UpdateSingleLED(int led);
30+
31+
void DeviceUpdateMode();
32+
void DeviceSaveMode();
33+
34+
private:
35+
DreamCheekyController* controller;
36+
};

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,4 +164,5 @@ While no code from these projects directly made its way into OpenRGB, these proj
164164
* Signal RGB Plugins: https://gitlab.com/signalrgb/signal-plugins/-/tree/master/Plugins
165165
* k550-macos https://github.com/vookimedlo/ck550-macos/tree/master
166166
* luxafor-python https://github.com/vmitchell85/luxafor-python
167+
* dreamcheekyusb https://github.com/gbrayut/dreamcheekyusb
167168

0 commit comments

Comments
 (0)