Skip to content

Commit 0badfba

Browse files
ricarimCalcProgrammer1
authored andcommitted
Initial commit for HyperX Origins 2 65
1 parent 32be0b2 commit 0badfba

5 files changed

Lines changed: 511 additions & 0 deletions

File tree

Controllers/HyperXKeyboardController/HyperXKeyboardControllerDetect.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@
1515
#include "HyperXAlloyOriginsController.h"
1616
#include "HyperXAlloyOriginsCoreController.h"
1717
#include "HyperXAlloyOrigins60and65Controller.h"
18+
#include "HyperXOrigins2_65Controller.h"
1819
#include "RGBController_HyperXAlloyElite.h"
1920
#include "RGBController_HyperXAlloyElite2.h"
2021
#include "RGBController_HyperXAlloyFPS.h"
2122
#include "RGBController_HyperXAlloyOrigins.h"
2223
#include "RGBController_HyperXAlloyOriginsCore.h"
2324
#include "RGBController_HyperXAlloyOrigins60and65.h"
25+
#include "RGBController_HyperXOrigins2_65.h"
2426

2527
/*-----------------------------------------------------*\
2628
| HyperX keyboard vendor and product IDs |
@@ -44,6 +46,7 @@
4446
#define HYPERX_ALLOY_ORIGINS_65_HP_PID 0x038F
4547
#define HYPERX_ALLOY_ORIGINS_CORE_HP_PID 0x098F
4648
#define HYPERX_ALLOY_ORIGINS_HP_PID 0x0591
49+
#define HYPERX_ORIGINS_2_65_HP_PID 0x0CC2
4750

4851
AlloyOrigins60and65MappingLayoutType GetAlloyOrigins60and65MappingLayoutType(int pid)
4952
{
@@ -140,12 +143,27 @@ void DetectHyperXAlloyOrigins60and65(hid_device_info* info, const std::string& n
140143
}
141144
}
142145

146+
void DetectHyperXOrigins2_65(hid_device_info* info, const std::string& name)
147+
{
148+
hid_device* dev = hid_open_path(info->path);
149+
150+
if(dev)
151+
{
152+
HyperXOrigins2_65Controller* controller = new HyperXOrigins2_65Controller(dev, info->path, name);
153+
RGBController_HyperXOrigins2_65* rgb_controller = new RGBController_HyperXOrigins2_65(controller);
154+
155+
ResourceManager::get()->RegisterRGBController(rgb_controller);
156+
}
157+
}
158+
143159
REGISTER_HID_DETECTOR_IP("HyperX Alloy Elite RGB", DetectHyperXAlloyElite, HYPERX_KEYBOARD_VID, HYPERX_ALLOY_ELITE_PID, 2, 0xFF01);
144160
REGISTER_HID_DETECTOR_IP("HyperX Alloy FPS RGB", DetectHyperXAlloyFPS, HYPERX_KEYBOARD_VID, HYPERX_ALLOY_FPS_RGB_PID, 2, 0xFF01);
145161
REGISTER_HID_DETECTOR_I("HyperX Alloy Origins Core", DetectHyperXAlloyOriginsCore, HYPERX_KEYBOARD_VID, HYPERX_ALLOY_ORIGINS_CORE_PID, 2);
146162

147163
REGISTER_HID_DETECTOR_I("HyperX Alloy Origins Core (HP)", DetectHyperXAlloyOriginsCore, HP_KEYBOARD_VID, HYPERX_ALLOY_ORIGINS_CORE_HP_PID, 2);
148164

165+
REGISTER_HID_DETECTOR_I("HyperX Origins 2 65 (HP)", DetectHyperXOrigins2_65, HP_KEYBOARD_VID, HYPERX_ORIGINS_2_65_HP_PID, 3);
166+
149167
#ifdef _WIN32
150168
REGISTER_HID_DETECTOR_I("HyperX Alloy Origins", DetectHyperXAlloyOrigins, HYPERX_KEYBOARD_VID, HYPERX_ALLOY_ORIGINS_PID, 3);
151169
REGISTER_HID_DETECTOR_IP("HyperX Alloy Elite 2", DetectHyperXAlloyElite2, HYPERX_KEYBOARD_VID, HYPERX_ALLOY_ELITE_2_PID, 3, 0xFF90);
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
/*---------------------------------------------------------*\
2+
| HyperXOrigins2_65Controller.cpp |
3+
| |
4+
| Driver for HyperX Origins 2 65 keyboard |
5+
| |
6+
| Ricardo Amorim 28 Mar 2026 |
7+
| |
8+
| This file is part of the OpenRGB project |
9+
| SPDX-License-Identifier: GPL-2.0-or-later |
10+
\*---------------------------------------------------------*/
11+
12+
#include <cstring>
13+
#include "HyperXOrigins2_65Controller.h"
14+
#include "StringUtils.h"
15+
16+
HyperXOrigins2_65Controller::HyperXOrigins2_65Controller(hid_device* dev_handle, const char* path, std::string dev_name)
17+
{
18+
dev = dev_handle;
19+
location = path;
20+
name = dev_name;
21+
}
22+
23+
HyperXOrigins2_65Controller::~HyperXOrigins2_65Controller()
24+
{
25+
hid_close(dev);
26+
}
27+
28+
std::string HyperXOrigins2_65Controller::GetDeviceLocation()
29+
{
30+
return("HID " + location);
31+
}
32+
33+
std::string HyperXOrigins2_65Controller::GetNameString()
34+
{
35+
return(name);
36+
}
37+
38+
std::string HyperXOrigins2_65Controller::GetSerialString()
39+
{
40+
wchar_t serial_string[128];
41+
int ret = hid_get_serial_number_string(dev, serial_string, 128);
42+
43+
if(ret != 0)
44+
{
45+
return ("");
46+
}
47+
48+
return(StringUtils::wstring_to_string(serial_string));
49+
}
50+
51+
void HyperXOrigins2_65Controller::SetLEDsDirect(std::vector<RGBColor> colors)
52+
{
53+
/*-----------------------------------------------------*\
54+
| Set up variables to track progress of color transmit |
55+
| Do this after inserting blanks |
56+
\*-----------------------------------------------------*/
57+
int colors_to_send = (int)colors.size();
58+
int colors_sent = 0;
59+
60+
SendDirectInitialization();
61+
62+
for(int pkt_idx = 0; pkt_idx < 4; pkt_idx++)
63+
{
64+
if(colors_to_send > 20)
65+
{
66+
SendDirectColorPacket(&colors[colors_sent], 20, pkt_idx);
67+
colors_sent += 20;
68+
colors_to_send -= 20;
69+
}
70+
else if(colors_to_send > 0)
71+
{
72+
SendDirectColorPacket(&colors[colors_sent], colors_to_send, pkt_idx);
73+
colors_sent += colors_to_send;
74+
colors_to_send -= colors_to_send;
75+
}
76+
else
77+
{
78+
RGBColor temp = 0x00000000;
79+
SendDirectColorPacket(&temp, 1, pkt_idx);
80+
}
81+
}
82+
}
83+
84+
void HyperXOrigins2_65Controller::SendDirectInitialization()
85+
{
86+
unsigned char buf[65];
87+
88+
/*-----------------------------------------------------*\
89+
| Zero out buffer |
90+
\*-----------------------------------------------------*/
91+
memset(buf, 0x00, sizeof(buf));
92+
93+
/*-----------------------------------------------------*\
94+
| Set up Direct Initialization packet |
95+
\*-----------------------------------------------------*/
96+
buf[0x00] = 0x44;
97+
buf[0x01] = 0x01;
98+
buf[0x02] = 0x04;
99+
buf[0x03] = 0x00;
100+
101+
/*-----------------------------------------------------*\
102+
| Send packet |
103+
\*-----------------------------------------------------*/
104+
hid_write(dev, buf, 65);
105+
}
106+
107+
void HyperXOrigins2_65Controller::SendDirectColorPacket
108+
(
109+
RGBColor* color_data,
110+
unsigned int color_count,
111+
unsigned int seq
112+
)
113+
{
114+
unsigned char buf[65];
115+
116+
/*-----------------------------------------------------*\
117+
| Zero out buffer |
118+
\*-----------------------------------------------------*/
119+
memset(buf, 0x00, sizeof(buf));
120+
121+
/*-----------------------------------------------------*\
122+
| Set up Direct Initialization packet |
123+
\*-----------------------------------------------------*/
124+
buf[0x00] = 0x44;
125+
buf[0x01] = 0x02;
126+
buf[0x02] = (unsigned char)seq;
127+
buf[0x03] = 0x00;
128+
129+
/*-----------------------------------------------------*\
130+
| The maximum number of colors per packet is 20 |
131+
\*-----------------------------------------------------*/
132+
if(color_count > 20)
133+
{
134+
color_count = 20;
135+
}
136+
137+
/*-----------------------------------------------------*\
138+
| Copy in color data |
139+
\*-----------------------------------------------------*/
140+
for(unsigned int color_idx = 0; color_idx < color_count; color_idx++)
141+
{
142+
buf[4 + (color_idx * 3)] = RGBGetRValue(color_data[color_idx]);
143+
buf[4 + (color_idx * 3) + 1] = RGBGetGValue(color_data[color_idx]);
144+
buf[4 + (color_idx * 3) + 2] = RGBGetBValue(color_data[color_idx]);
145+
}
146+
147+
/*-----------------------------------------------------*\
148+
| Send packet |
149+
\*-----------------------------------------------------*/
150+
hid_write(dev, buf, 65);
151+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*---------------------------------------------------------*\
2+
| HyperXOrigins2_65Controller.h |
3+
| |
4+
| Driver for HyperX Origins 2 65 keyboard |
5+
| |
6+
| Ricardo Amorim 28 Mar 2026 |
7+
| |
8+
| This file is part of the OpenRGB project |
9+
| SPDX-License-Identifier: GPL-2.0-or-later |
10+
\*---------------------------------------------------------*/
11+
12+
#pragma once
13+
14+
#include <string>
15+
#include <hidapi.h>
16+
#include "RGBController.h"
17+
18+
class HyperXOrigins2_65Controller
19+
{
20+
public:
21+
HyperXOrigins2_65Controller(hid_device* dev_handle, const char* path, std::string dev_name);
22+
~HyperXOrigins2_65Controller();
23+
24+
std::string GetDeviceLocation();
25+
std::string GetNameString();
26+
std::string GetSerialString();
27+
28+
void SetLEDsDirect(std::vector<RGBColor> colors);
29+
30+
private:
31+
hid_device* dev;
32+
std::string location;
33+
std::string name;
34+
35+
void SendDirectInitialization();
36+
void SendDirectColorPacket
37+
(
38+
RGBColor* color_data,
39+
unsigned int color_count,
40+
unsigned int seq
41+
);
42+
};
43+

0 commit comments

Comments
 (0)