|
|
|
|
@ -12,6 +12,10 @@
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include "HPOmen30LController.h"
|
|
|
|
|
|
|
|
|
|
#define HP_OMEN_30L_BUFFER_SIZE 58
|
|
|
|
|
#define HP_OMEN_30L_VERSION_ID 0x12
|
|
|
|
|
#define HP_OMEN_30L_MAX_BRIGHTNESS 0x64
|
|
|
|
|
|
|
|
|
|
HPOmen30LController::HPOmen30LController(hid_device* dev_handle, const char* path)
|
|
|
|
|
{
|
|
|
|
|
dev = dev_handle;
|
|
|
|
|
@ -23,30 +27,50 @@ HPOmen30LController::HPOmen30LController(hid_device* dev_handle, const char* pat
|
|
|
|
|
logo.value = HP_OMEN_30L_LOGO_ZONE;
|
|
|
|
|
logo.mode = HP_OMEN_30L_DIRECT;
|
|
|
|
|
logo.speed = HP_OMEN_30L_SPEED_MED;
|
|
|
|
|
logo.brightness = 0x64;
|
|
|
|
|
logo.brightness = HP_OMEN_30L_MAX_BRIGHTNESS;
|
|
|
|
|
hp_zones.push_back(logo);
|
|
|
|
|
|
|
|
|
|
hp_zone bar;
|
|
|
|
|
bar.value = HP_OMEN_30L_BAR_ZONE;
|
|
|
|
|
bar.mode = HP_OMEN_30L_DIRECT;
|
|
|
|
|
bar.speed = HP_OMEN_30L_SPEED_MED;
|
|
|
|
|
bar.brightness = 0x64;
|
|
|
|
|
bar.brightness = HP_OMEN_30L_MAX_BRIGHTNESS;
|
|
|
|
|
hp_zones.push_back(bar);
|
|
|
|
|
|
|
|
|
|
hp_zone fan;
|
|
|
|
|
fan.value = HP_OMEN_30L_FAN_ZONE;
|
|
|
|
|
fan.mode = HP_OMEN_30L_DIRECT;
|
|
|
|
|
fan.speed = HP_OMEN_30L_SPEED_MED;
|
|
|
|
|
fan.brightness = 0x64;
|
|
|
|
|
fan.brightness = HP_OMEN_30L_MAX_BRIGHTNESS;
|
|
|
|
|
hp_zones.push_back(fan);
|
|
|
|
|
|
|
|
|
|
hp_zone cpu;
|
|
|
|
|
cpu.value = HP_OMEN_30L_CPU_ZONE;
|
|
|
|
|
cpu.mode = HP_OMEN_30L_DIRECT;
|
|
|
|
|
cpu.speed = HP_OMEN_30L_SPEED_MED;
|
|
|
|
|
cpu.brightness = 0x64;
|
|
|
|
|
cpu.brightness = HP_OMEN_30L_MAX_BRIGHTNESS;
|
|
|
|
|
hp_zones.push_back(cpu);
|
|
|
|
|
|
|
|
|
|
hp_zone botFan;
|
|
|
|
|
botFan.value = HP_OMEN_30L_BOT_FAN_ZONE;
|
|
|
|
|
botFan.mode = HP_OMEN_30L_DIRECT;
|
|
|
|
|
botFan.speed = HP_OMEN_30L_SPEED_MED;
|
|
|
|
|
botFan.brightness = HP_OMEN_30L_MAX_BRIGHTNESS;
|
|
|
|
|
hp_zones.push_back(botFan);
|
|
|
|
|
|
|
|
|
|
hp_zone midFan;
|
|
|
|
|
midFan.value = HP_OMEN_30L_MID_FAN_ZONE;
|
|
|
|
|
midFan.mode = HP_OMEN_30L_DIRECT;
|
|
|
|
|
midFan.speed = HP_OMEN_30L_SPEED_MED;
|
|
|
|
|
midFan.brightness = HP_OMEN_30L_MAX_BRIGHTNESS;
|
|
|
|
|
hp_zones.push_back(midFan);
|
|
|
|
|
|
|
|
|
|
hp_zone topFan;
|
|
|
|
|
topFan.value = HP_OMEN_30L_TOP_FAN_ZONE;
|
|
|
|
|
topFan.mode = HP_OMEN_30L_DIRECT;
|
|
|
|
|
topFan.speed = HP_OMEN_30L_SPEED_MED;
|
|
|
|
|
topFan.brightness = HP_OMEN_30L_MAX_BRIGHTNESS;
|
|
|
|
|
hp_zones.push_back(topFan);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HPOmen30LController::~HPOmen30LController()
|
|
|
|
|
@ -97,77 +121,88 @@ void HPOmen30LController::SetZoneColor(int zone, std::vector<RGBColor> colors)
|
|
|
|
|
|
|
|
|
|
void HPOmen30LController::SendZoneUpdate(int zone, std::vector<RGBColor> colors)
|
|
|
|
|
{
|
|
|
|
|
unsigned char usb_buf[] =
|
|
|
|
|
{
|
|
|
|
|
0x00, 0x00, // [0x00-0x01]
|
|
|
|
|
0x12, 0x05, 0x00, 0x00, // [0x02-0x05]
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, // [0x06-0x09]
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, // [0x0A-0x0D]
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, // [0x0E-0x11]
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, // [0x12-0x15]
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, // [0x16-0x19]
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, // [0x1A-0x1D]
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, // [0x1E-0x21]
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, // [0x22-0x25]
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, // [0x26-0x29]
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, // [0x2A-0x2D]
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, // [0x2E-0x31]
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, // [0x32-0x35] Always 0x00*4
|
|
|
|
|
0x00, 0x00, 0x00, 0x00 // [0x36-0x39] zone / 0x01 / theme / speed
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
unsigned char usb_buf[HP_OMEN_30L_BUFFER_SIZE] = {}; // zero-initialize array
|
|
|
|
|
// 0x00 - 0x01: Unknown
|
|
|
|
|
// 0x02: Version ID (HP_OMEN_30L_VERSION_ID)
|
|
|
|
|
// 0x03: Lighting mode (static, direct, off, breathing, cycle, blinking, ...)
|
|
|
|
|
// 0x04: Total color count (only different from 1 in modes with changing colors)
|
|
|
|
|
// 0x05: Current color number (see above, used to set the different colors, one at a time, starting at 1)
|
|
|
|
|
// 0x06 - 0x07: Unknown
|
|
|
|
|
// 0x08 - 0x23: Used to control the RGB (static) or RGBA (direct) of the first seven LED zones
|
|
|
|
|
// 0x24 - 0x2f: Unknown, probably also used for RGB/RGBA control if there's support up to 10 zones
|
|
|
|
|
// 0x30: Brightness
|
|
|
|
|
// 0x31: Type (static=0x02, direct=0x04, changing colors=0x0A)
|
|
|
|
|
// 0x32 - 0x35: Unknown
|
|
|
|
|
// 0x36: Zone to update (can only update one at a time)
|
|
|
|
|
// 0x37: Power mode to update (on, suspend)
|
|
|
|
|
// 0x38: Theme (either 0 to use the colors set in 0x04/0x05, or the ID of a predefined theme)
|
|
|
|
|
// 0x39: Color change speed (only relevant for modes with changing colors)
|
|
|
|
|
|
|
|
|
|
usb_buf[0x02] = HP_OMEN_30L_VERSION_ID;
|
|
|
|
|
usb_buf[0x36] = hp_zones[zone].value;
|
|
|
|
|
|
|
|
|
|
if(hp_zones[zone].mode != HP_OMEN_30L_DIRECT)
|
|
|
|
|
{
|
|
|
|
|
hid_write(dev, usb_buf, 58);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
usb_buf[0x37] = 0x01;
|
|
|
|
|
usb_buf[0x39] = hp_zones[zone].speed;
|
|
|
|
|
// The Omen controller allows setting different modes for when the computer is powered on
|
|
|
|
|
// vs when the computer is suspended.
|
|
|
|
|
// Because the OpenRGB UI does not allow such a choice, we're only changing the powered on mode.
|
|
|
|
|
// If this ever changes, we need to take the user choice into consideration (HP_OMEN_30L_POWER_SUSPEND)
|
|
|
|
|
usb_buf[0x37] = HP_OMEN_30L_POWER_ON;
|
|
|
|
|
usb_buf[0x03] = hp_zones[zone].mode;
|
|
|
|
|
usb_buf[0x30] = hp_zones[zone].brightness;
|
|
|
|
|
|
|
|
|
|
if(hp_zones[zone].mode == HP_OMEN_30L_DIRECT)
|
|
|
|
|
if (hp_zones[zone].mode == HP_OMEN_30L_OFF)
|
|
|
|
|
{
|
|
|
|
|
usb_buf[0x31] = HP_OMEN_30L_DIRECT;
|
|
|
|
|
usb_buf[0x04] = 0x01;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
usb_buf[0x31] = 0x0A;
|
|
|
|
|
hid_write(dev, usb_buf, HP_OMEN_30L_BUFFER_SIZE);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
usb_buf[0x30] = hp_zones[zone].brightness;
|
|
|
|
|
int index = hp_zones[zone].value - 1;
|
|
|
|
|
if(hp_zones[zone].mode == HP_OMEN_30L_DIRECT)
|
|
|
|
|
{
|
|
|
|
|
usb_buf[0x08] = usb_buf[0x0C] = usb_buf[0x10] = usb_buf[0x14] = 0x64;
|
|
|
|
|
usb_buf[0x09] = usb_buf[0x0D] = usb_buf[0x11] = usb_buf[0x15] = RGBGetRValue(colors[zone]);
|
|
|
|
|
usb_buf[0x0A] = usb_buf[0x0E] = usb_buf[0x12] = usb_buf[0x16] = RGBGetGValue(colors[zone]);
|
|
|
|
|
usb_buf[0x0B] = usb_buf[0x0F] = usb_buf[0x13] = usb_buf[0x17] = RGBGetBValue(colors[zone]);
|
|
|
|
|
|
|
|
|
|
hid_write(dev, usb_buf, 58);
|
|
|
|
|
usb_buf[0x31] = HP_OMEN_30L_DIRECT;
|
|
|
|
|
usb_buf[0x04] = 0x01;
|
|
|
|
|
usb_buf[0x05] = 0x01;
|
|
|
|
|
usb_buf[0x08 + index * 4] = HP_OMEN_30L_MAX_BRIGHTNESS;
|
|
|
|
|
usb_buf[0x09 + index * 4] = RGBGetRValue(colors[zone]);
|
|
|
|
|
usb_buf[0x0A + index * 4] = RGBGetGValue(colors[zone]);
|
|
|
|
|
usb_buf[0x0B + index * 4] = RGBGetBValue(colors[zone]);
|
|
|
|
|
|
|
|
|
|
hid_write(dev, usb_buf, HP_OMEN_30L_BUFFER_SIZE);
|
|
|
|
|
}
|
|
|
|
|
else if(hp_zones[zone].mode == HP_OMEN_30L_STATIC)
|
|
|
|
|
{
|
|
|
|
|
usb_buf[0x08] = usb_buf[0x0B] = usb_buf[0x0E] = usb_buf[0x11] = RGBGetRValue(colors[zone]);
|
|
|
|
|
usb_buf[0x09] = usb_buf[0x0C] = usb_buf[0x0F] = usb_buf[0x12] = RGBGetGValue(colors[zone]);
|
|
|
|
|
usb_buf[0x0A] = usb_buf[0x0D] = usb_buf[0x10] = usb_buf[0x13] = RGBGetBValue(colors[zone]);
|
|
|
|
|
|
|
|
|
|
hid_write(dev, usb_buf, 58);
|
|
|
|
|
usb_buf[0x31] = 0x02;
|
|
|
|
|
usb_buf[0x04] = 0x01;
|
|
|
|
|
usb_buf[0x05] = 0x01;
|
|
|
|
|
usb_buf[0x08 + index * 3] = RGBGetRValue(colors[zone]);
|
|
|
|
|
usb_buf[0x09 + index * 3] = RGBGetGValue(colors[zone]);
|
|
|
|
|
usb_buf[0x0A + index * 3] = RGBGetBValue(colors[zone]);
|
|
|
|
|
|
|
|
|
|
hid_write(dev, usb_buf, HP_OMEN_30L_BUFFER_SIZE);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
usb_buf[0x04] = (unsigned char)colors.size();
|
|
|
|
|
|
|
|
|
|
for(unsigned int i = 0; i < (unsigned int)colors.size(); i++)
|
|
|
|
|
usb_buf[0x31] = 0x0A;
|
|
|
|
|
usb_buf[0x39] = hp_zones[zone].speed;
|
|
|
|
|
|
|
|
|
|
// Theme is custom by default, but if we could select a theme through the UI,
|
|
|
|
|
// we would set it in usb_buf[0x38] here and ignore the custom colors vector
|
|
|
|
|
unsigned char theme = HP_OMEN_30L_THEME_CUSTOM;
|
|
|
|
|
usb_buf[0x38] = theme;
|
|
|
|
|
if (theme == HP_OMEN_30L_THEME_CUSTOM)
|
|
|
|
|
{
|
|
|
|
|
usb_buf[0x05] = i + 1;
|
|
|
|
|
|
|
|
|
|
usb_buf[0x08] = usb_buf[0x0B] = usb_buf[0x0E] = usb_buf[0x11] = RGBGetRValue(colors[i]);
|
|
|
|
|
usb_buf[0x09] = usb_buf[0x0C] = usb_buf[0x0F] = usb_buf[0x12] = RGBGetGValue(colors[i]);
|
|
|
|
|
usb_buf[0x0A] = usb_buf[0x0D] = usb_buf[0x10] = usb_buf[0x13] = RGBGetBValue(colors[i]);
|
|
|
|
|
|
|
|
|
|
hid_write(dev, usb_buf, 58);
|
|
|
|
|
usb_buf[0x04] = (unsigned char)colors.size();
|
|
|
|
|
for(unsigned int i = 0; i < (unsigned int)colors.size(); i++)
|
|
|
|
|
{
|
|
|
|
|
usb_buf[0x05] = i + 1;
|
|
|
|
|
usb_buf[0x08 + index * 3] = RGBGetRValue(colors[i]);
|
|
|
|
|
usb_buf[0x09 + index * 3] = RGBGetGValue(colors[i]);
|
|
|
|
|
usb_buf[0x0A + index * 3] = RGBGetBValue(colors[i]);
|
|
|
|
|
hid_write(dev, usb_buf, HP_OMEN_30L_BUFFER_SIZE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
hid_write(dev, usb_buf, HP_OMEN_30L_BUFFER_SIZE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|