Skip to content

Commit 85631bf

Browse files
S4NDM4NNCalcProgrammer1
authored andcommitted
Initial HP Omen 30L Support
Commits squashed and amended for code style/brightness control by Adam Honse <calcprogrammer1@gmail.com>
1 parent e52ba49 commit 85631bf

File tree

6 files changed

+518
-0
lines changed

6 files changed

+518
-0
lines changed
Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
/*-----------------------------------------*\
2+
| HPOmen30LController.cpp |
3+
| |
4+
| Driver for HP Omen 30L RGB lighting |
5+
| controller |
6+
\*-----------------------------------------*/
7+
8+
#include "HPOmen30LController.h"
9+
#include <cstring>
10+
#include <stdio.h>
11+
#include <stdlib.h>
12+
13+
HPOmen30LController::HPOmen30LController(hid_device* dev_handle, const char* path)
14+
{
15+
dev = dev_handle;
16+
location = path;
17+
18+
strcpy(device_name, "HP Omen 30L");
19+
20+
hp_zone logo;
21+
logo.value = HP_OMEN_30L_LOGO_ZONE;
22+
logo.mode = HP_OMEN_30L_DIRECT;
23+
logo.speed = HP_OMEN_30L_SPEED_MED;
24+
logo.brightness = 0x64;
25+
hp_zones.push_back(logo);
26+
27+
hp_zone bar;
28+
bar.value = HP_OMEN_30L_BAR_ZONE;
29+
bar.mode = HP_OMEN_30L_DIRECT;
30+
bar.speed = HP_OMEN_30L_SPEED_MED;
31+
bar.brightness = 0x64;
32+
hp_zones.push_back(bar);
33+
34+
hp_zone fan;
35+
fan.value = HP_OMEN_30L_FAN_ZONE;
36+
fan.mode = HP_OMEN_30L_DIRECT;
37+
fan.speed = HP_OMEN_30L_SPEED_MED;
38+
fan.brightness = 0x64;
39+
hp_zones.push_back(fan);
40+
41+
hp_zone cpu;
42+
cpu.value = HP_OMEN_30L_CPU_ZONE;
43+
cpu.mode = HP_OMEN_30L_DIRECT;
44+
cpu.speed = HP_OMEN_30L_SPEED_MED;
45+
cpu.brightness = 0x64;
46+
hp_zones.push_back(cpu);
47+
48+
}
49+
50+
HPOmen30LController::~HPOmen30LController()
51+
{
52+
hid_close(dev);
53+
}
54+
55+
std::string HPOmen30LController::GetLocationString()
56+
{
57+
return("HID: " + location);
58+
}
59+
60+
char* HPOmen30LController::GetDeviceName()
61+
{
62+
return device_name;
63+
}
64+
65+
std::string HPOmen30LController::GetSerialString()
66+
{
67+
std::string ret_string = "";
68+
return(ret_string);
69+
}
70+
71+
std::string HPOmen30LController::GetEffectChannelString(unsigned char channel)
72+
{
73+
std::string ret_string = "";
74+
return(ret_string);
75+
}
76+
77+
std::string HPOmen30LController::GetFirmwareVersionString()
78+
{
79+
std::string ret_string = "";
80+
return(ret_string);
81+
}
82+
83+
void HPOmen30LController::SetZoneMode(int zone,unsigned char mode, unsigned char speed,unsigned char brightness)
84+
{
85+
hp_zones[zone].mode = mode;
86+
hp_zones[zone].speed = speed;
87+
hp_zones[zone].brightness = brightness;
88+
89+
}
90+
91+
void HPOmen30LController::SetZoneColor(int zone, std::vector<RGBColor> colors)
92+
{
93+
SendZoneUpdate(zone, colors);
94+
}
95+
96+
void HPOmen30LController::SendZoneUpdate(int zone, std::vector<RGBColor> colors)
97+
{
98+
unsigned char usb_buf[] =
99+
{
100+
0x00, 0x00, // [0x00-0x01]
101+
0x12, 0x05, 0x00, 0x00, // [0x02-0x05]
102+
0x00, 0x00, 0x00, 0x00, // [0x06-0x09]
103+
0x00, 0x00, 0x00, 0x00, // [0x0A-0x0D]
104+
0x00, 0x00, 0x00, 0x00, // [0x0E-0x11]
105+
0x00, 0x00, 0x00, 0x00, // [0x12-0x15]
106+
0x00, 0x00, 0x00, 0x00, // [0x16-0x19]
107+
0x00, 0x00, 0x00, 0x00, // [0x1A-0x1D]
108+
0x00, 0x00, 0x00, 0x00, // [0x1E-0x21]
109+
0x00, 0x00, 0x00, 0x00, // [0x22-0x25]
110+
0x00, 0x00, 0x00, 0x00, // [0x26-0x29]
111+
0x00, 0x00, 0x00, 0x00, // [0x2A-0x2D]
112+
0x00, 0x00, 0x00, 0x00, // [0x2E-0x31]
113+
0x00, 0x00, 0x00, 0x00, // [0x32-0x35] Always 0x00*4
114+
0x00, 0x00, 0x00, 0x00 // [0x36-0x39] zone / 0x01 / theme / speed
115+
};
116+
117+
usb_buf[0x36] = hp_zones[zone].value;
118+
119+
if(hp_zones[zone].mode != HP_OMEN_30L_DIRECT)
120+
{
121+
hid_write(dev, usb_buf, 58);
122+
}
123+
124+
usb_buf[0x37] = 0x01;
125+
usb_buf[0x39] = hp_zones[zone].speed;
126+
usb_buf[0x03] = hp_zones[zone].mode;
127+
usb_buf[0x30] = hp_zones[zone].brightness;
128+
129+
if(hp_zones[zone].mode == HP_OMEN_30L_DIRECT)
130+
{
131+
usb_buf[0x31] = HP_OMEN_30L_DIRECT;
132+
usb_buf[0x04] = 0x01;
133+
}
134+
else
135+
{
136+
usb_buf[0x31] = 0x0A;
137+
}
138+
139+
if(hp_zones[zone].mode == HP_OMEN_30L_DIRECT)
140+
{
141+
usb_buf[0x08] = usb_buf[0x0C] = usb_buf[0x10] = usb_buf[0x14] = 0x64;
142+
usb_buf[0x09] = usb_buf[0x0D] = usb_buf[0x11] = usb_buf[0x15] = RGBGetRValue(colors[zone]);
143+
usb_buf[0x0A] = usb_buf[0x0E] = usb_buf[0x12] = usb_buf[0x16] = RGBGetGValue(colors[zone]);
144+
usb_buf[0x0B] = usb_buf[0x0F] = usb_buf[0x13] = usb_buf[0x17] = RGBGetBValue(colors[zone]);
145+
146+
hid_write(dev, usb_buf, 58);
147+
}
148+
else if(hp_zones[zone].mode == HP_OMEN_30L_STATIC)
149+
{
150+
usb_buf[0x08] = usb_buf[0x0B] = usb_buf[0x0E] = usb_buf[0x11] = RGBGetRValue(colors[zone]);
151+
usb_buf[0x09] = usb_buf[0x0C] = usb_buf[0x0F] = usb_buf[0x12] = RGBGetGValue(colors[zone]);
152+
usb_buf[0x0A] = usb_buf[0x0D] = usb_buf[0x10] = usb_buf[0x13] = RGBGetBValue(colors[zone]);
153+
154+
hid_write(dev, usb_buf, 58);
155+
}
156+
else
157+
{
158+
usb_buf[0x04] = colors.size();
159+
160+
for(int i = 0; i < colors.size(); i++)
161+
{
162+
usb_buf[0x05] = i + 1;
163+
164+
usb_buf[0x08] = usb_buf[0x0B] = usb_buf[0x0E] = usb_buf[0x11] = RGBGetRValue(colors[i]);
165+
usb_buf[0x09] = usb_buf[0x0C] = usb_buf[0x0F] = usb_buf[0x12] = RGBGetGValue(colors[i]);
166+
usb_buf[0x0A] = usb_buf[0x0D] = usb_buf[0x10] = usb_buf[0x13] = RGBGetBValue(colors[i]);
167+
168+
hid_write(dev, usb_buf, 58);
169+
}
170+
}
171+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*-----------------------------------------*\
2+
| HPOmen30LController.h |
3+
| |
4+
| Driver for HP Omen 30L RGB lighting |
5+
| controller |
6+
\*-----------------------------------------*/
7+
8+
#include "RGBController.h"
9+
#include <string>
10+
#include <hidapi/hidapi.h>
11+
#include <vector>
12+
13+
#pragma once
14+
15+
typedef struct
16+
{
17+
unsigned char value;
18+
unsigned char mode;
19+
unsigned char speed;
20+
unsigned char brightness;
21+
} hp_zone;
22+
23+
enum
24+
{
25+
HP_OMEN_30L_STATIC = 0x01, /* Static effect channel */
26+
HP_OMEN_30L_DIRECT = 0x04, /* Direct for effects plugin */
27+
HP_OMEN_30L_BREATHING = 0x06, /* Breathing effect channel */
28+
HP_OMEN_30L_COLOR_CYCLE = 0x07, /* Color cycle effect channel */
29+
HP_OMEN_30L_BLINKING = 0x08, /* Led blink */
30+
31+
};
32+
33+
enum
34+
{
35+
HP_OMEN_30L_SPEED_SLOW = 0x01, /* Slow speed */
36+
HP_OMEN_30L_SPEED_MED = 0x02, /* Normal speed */
37+
HP_OMEN_30L_SPEED_FAST = 0x03, /* Fast speed */
38+
};
39+
40+
enum
41+
{
42+
HP_OMEN_30L_LOGO_ZONE = 0x01,
43+
HP_OMEN_30L_BAR_ZONE = 0x02,
44+
HP_OMEN_30L_FAN_ZONE = 0x03,
45+
HP_OMEN_30L_CPU_ZONE = 0x04,
46+
};
47+
48+
class HPOmen30LController
49+
{
50+
public:
51+
HPOmen30LController(hid_device* dev_handle, const char* path);
52+
~HPOmen30LController();
53+
54+
char* GetDeviceName();
55+
56+
std::string GetEffectChannelString(unsigned char channel);
57+
std::string GetFirmwareVersionString();
58+
std::string GetLocationString();
59+
std::string GetSerialString();
60+
61+
void SetRingEffectChannel(unsigned char channel);
62+
void SetZoneMode(int zone,unsigned char mode, unsigned char speed, unsigned char brightness);
63+
void SetZoneColor(int zone, std::vector<RGBColor> colors);
64+
65+
private:
66+
char device_name[32];
67+
hid_device* dev;
68+
std::string location;
69+
70+
std::vector<hp_zone> hp_zones;
71+
72+
void SendZoneUpdate(int zone, std::vector<RGBColor> colors);
73+
74+
};
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#include "Detector.h"
2+
#include "HPOmen30LController.h"
3+
#include "RGBController.h"
4+
#include "RGBController_HPOmen30L.h"
5+
#include <hidapi/hidapi.h>
6+
7+
#define HP_OMEN_30L_VID 0x103C
8+
#define HP_OMEN_30L_PID 0x84FD
9+
10+
/******************************************************************************************\
11+
* *
12+
* DetectHPOmen30LController *
13+
* *
14+
* Tests the USB address to see if an HP Omen 30L controller exists there. *
15+
* *
16+
\******************************************************************************************/
17+
18+
void DetectHPOmen30LController(hid_device_info* info, const std::string&)
19+
{
20+
hid_device* dev = hid_open_path(info->path);
21+
22+
if(dev)
23+
{
24+
HPOmen30LController* controller = new HPOmen30LController(dev, info->path);
25+
RGBController_HPOmen30L* rgb_controller = new RGBController_HPOmen30L(controller);
26+
// Constructor sets the name
27+
ResourceManager::get()->RegisterRGBController(rgb_controller);
28+
}
29+
}
30+
31+
REGISTER_HID_DETECTOR("HP Omen 30L", DetectHPOmen30LController, HP_OMEN_30L_VID, HP_OMEN_30L_PID);

0 commit comments

Comments
 (0)