Skip to content

Commit 90508f7

Browse files
dripsnekCalcProgrammer1
authored andcommitted
Initial Razer Hanbo Chroma support
1 parent dd034cb commit 90508f7

File tree

7 files changed

+695
-0
lines changed

7 files changed

+695
-0
lines changed

Controllers/RazerController/RazerControllerDetect.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@
1414
#include "Detector.h"
1515
#include "RazerController.h"
1616
#include "RazerKrakenController.h"
17+
#include "RazerHanboController.h"
1718
#include "RazerDevices.h"
1819
#include "ResourceManager.h"
1920
#include "RGBController_Razer.h"
2021
#include "RGBController_RazerAddressable.h"
2122
#include "RGBController_RazerKraken.h"
23+
#include "RGBController_RazerHanbo.h"
2224

2325
/******************************************************************************************\
2426
* *
@@ -151,6 +153,27 @@ void DetectRazerKrakenControllers(hid_device_info* info, const std::string& name
151153
}
152154
} /* DetectRazerKrakenControllers() */
153155

156+
/******************************************************************************************\
157+
* *
158+
* DetectRazerHanboController *
159+
* *
160+
* Tests the USB address to see if a Razer Hanbo controller exists there. *
161+
* *
162+
\******************************************************************************************/
163+
164+
void DetectRazerHanboControllers(hid_device_info* info, const std::string& name)
165+
{
166+
hid_device* dev = hid_open_path(info->path);
167+
168+
if(dev)
169+
{
170+
RazerHanboController* controller = new RazerHanboController(dev, info->path, info->product_id, name);
171+
172+
RGBController_RazerHanbo* rgb_controller = new RGBController_RazerHanbo(controller);
173+
ResourceManager::get()->RegisterRGBController(rgb_controller);
174+
}
175+
} /* DetectRazerHanboControllers() */
176+
154177
/*-----------------------------------------------------------------------------------------------------*\
155178
| Keyboards |
156179
\*-----------------------------------------------------------------------------------------------------*/
@@ -354,6 +377,7 @@ REGISTER_HID_DETECTOR_IPU("Razer Mouse Dock Pro", Det
354377
REGISTER_HID_DETECTOR_IPU("Lian Li O11 Dynamic - Razer Edition", DetectRazerControllers, RAZER_VID, RAZER_O11_DYNAMIC_PID, 0x02, 0x01, 0x02);
355378
REGISTER_HID_DETECTOR_PU("Razer Seiren Emote", DetectRazerControllers, RAZER_VID, RAZER_SEIREN_EMOTE_PID, 0x0C, 0x01 );
356379
REGISTER_HID_DETECTOR_PU("Razer Thunderbolt 4 Dock Chroma", DetectRazerControllers, RAZER_VID, RAZER_THUNDERBOLT_4_DOCK_CHROMA_PID, 0x0C, 0x01 );
380+
REGISTER_HID_DETECTOR_IPU("Razer Hanbo Chroma", DetectRazerHanboControllers, RAZER_VID, RAZER_HANBO_CHROMA_PID, 0x00, 0xFF00, 0x01);
357381

358382
/*-----------------------------------------------------------------------------------------------------*\
359383
| Nommo devices seem to have an issue where interface 1 doesn't show on Linux or MacOS. Due to the way |

Controllers/RazerController/RazerDevices.cpp

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8516,6 +8516,78 @@ static const razer_device thunderbolt_4_dock_chroma_device =
85168516
NULL
85178517
};
85188518

8519+
/*-------------------------------------------------------------*\
8520+
| Razer Hanbo Chroma |
8521+
| |
8522+
| Zone "Pump" |
8523+
| Linear |
8524+
| 16 LEDs |
8525+
| |
8526+
| Zone "Fan 1" |
8527+
| Linear |
8528+
| 18 LEDs |
8529+
| |
8530+
| Zone "Fan 2" |
8531+
| Linear |
8532+
| 18 LEDs |
8533+
| |
8534+
| Zone "Fan 3" |
8535+
| Linear |
8536+
| 18 LEDs |
8537+
| |
8538+
\*-------------------------------------------------------------*/
8539+
static const razer_zone hanbo_chroma_pump_zone =
8540+
{
8541+
"Pump",
8542+
ZONE_TYPE_LINEAR,
8543+
1,
8544+
16
8545+
};
8546+
8547+
static const razer_zone hanbo_chroma_fan_one_zone =
8548+
{
8549+
"Fan 1",
8550+
ZONE_TYPE_LINEAR,
8551+
1,
8552+
18
8553+
};
8554+
8555+
static const razer_zone hanbo_chroma_fan_two_zone =
8556+
{
8557+
"Fan 2",
8558+
ZONE_TYPE_LINEAR,
8559+
1,
8560+
18
8561+
};
8562+
8563+
static const razer_zone hanbo_chroma_fan_three_zone =
8564+
{
8565+
"Fan 3",
8566+
ZONE_TYPE_LINEAR,
8567+
1,
8568+
18
8569+
};
8570+
8571+
static const razer_device hanbo_chroma_device =
8572+
{
8573+
"Razer Hanbo Chroma",
8574+
RAZER_HANBO_CHROMA_PID,
8575+
DEVICE_TYPE_COOLER,
8576+
RAZER_MATRIX_TYPE_EXTENDED,
8577+
0x3F,
8578+
1,
8579+
70,
8580+
{
8581+
&hanbo_chroma_pump_zone,
8582+
&hanbo_chroma_fan_one_zone,
8583+
&hanbo_chroma_fan_two_zone,
8584+
&hanbo_chroma_fan_three_zone,
8585+
NULL,
8586+
NULL
8587+
},
8588+
NULL
8589+
};
8590+
85198591
/*-------------------------------------------------------------------------*\
85208592
| DEVICE MASTER LIST |
85218593
\*-------------------------------------------------------------------------*/
@@ -8719,6 +8791,7 @@ const razer_device* razer_device_list[] =
87198791
&o11_dynamic_device,
87208792
&seiren_emote_device,
87218793
&thunderbolt_4_dock_chroma_device,
8794+
&hanbo_chroma_device
87228795
};
87238796

87248797
const unsigned int RAZER_NUM_DEVICES = (sizeof(razer_device_list) / sizeof(razer_device_list[ 0 ]));

Controllers/RazerController/RazerDevices.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@
258258
#define RAZER_SEIREN_EMOTE_PID 0x0F1B
259259
#define RAZER_STRIDER_CHROMA_PID 0x0C05
260260
#define RAZER_THUNDERBOLT_4_DOCK_CHROMA_PID 0x0F21
261+
#define RAZER_HANBO_CHROMA_PID 0x0F35
261262

262263
typedef struct
263264
{
Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
/*---------------------------------------------------------*\
2+
| RGBController_RazerHanbo.cpp |
3+
| |
4+
| RGBController for Razer Hanbo devices |
5+
| |
6+
| Joseph East (dripsnek) 12 Apr 2025 |
7+
| |
8+
| This file is part of the OpenRGB project |
9+
| SPDX-License-Identifier: GPL-2.0-only |
10+
\*---------------------------------------------------------*/
11+
12+
#include "RGBController_RazerHanbo.h"
13+
#include "RazerDevices.h"
14+
15+
/**------------------------------------------------------------------*\
16+
@name Razer Hanbo Chroma
17+
@category Cooler
18+
@type USB
19+
@save :robot:
20+
@direct :white_check_mark:
21+
@effects :white_check_mark:
22+
@detectors DetectRazerHanboControllers
23+
@comment
24+
\*-------------------------------------------------------------------*/
25+
26+
RGBController_RazerHanbo::RGBController_RazerHanbo(RazerHanboController* controller_ptr)
27+
{
28+
controller = controller_ptr;
29+
name = controller->GetName();
30+
vendor = "Razer";
31+
type = controller->GetDeviceType();
32+
description = "Razer Hanbo Device";
33+
location = controller->GetDeviceLocation();
34+
version = controller->GetFirmwareString();
35+
serial = controller->GetSerialString();
36+
37+
mode Direct;
38+
Direct.name = "Direct";
39+
Direct.value = RAZER_HANBO_MODE_DIRECT;
40+
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
41+
Direct.color_mode = MODE_COLORS_PER_LED;
42+
Direct.brightness_min = MIN_BRIGHTNESS;
43+
Direct.brightness_max = MAX_BRIGHTNESS;
44+
Direct.brightness = MAX_BRIGHTNESS/2;
45+
modes.push_back(Direct);
46+
47+
mode Off;
48+
Off.name = "Off";
49+
Off.value = RAZER_HANBO_MODE_OFF;
50+
Off.flags = 0;
51+
Off.color_mode = MODE_COLORS_NONE;
52+
modes.push_back(Off);
53+
54+
mode SpectrumCycle;
55+
SpectrumCycle.name = "Spectrum Cycle";
56+
SpectrumCycle.value = RAZER_HANBO_MODE_SPECTRUM_CYCLE;
57+
SpectrumCycle.flags = 0;
58+
SpectrumCycle.color_mode = MODE_COLORS_NONE;
59+
modes.push_back(SpectrumCycle);
60+
61+
local_mode = RAZER_HANBO_MODE_DIRECT;
62+
63+
SetupZones();
64+
}
65+
66+
RGBController_RazerHanbo::~RGBController_RazerHanbo()
67+
{
68+
delete controller;
69+
}
70+
71+
void RGBController_RazerHanbo::SetupZones()
72+
{
73+
unsigned int device_index = controller->GetDeviceIndex();
74+
75+
/*---------------------------------------------------------*\
76+
| Fill in zone information based on device table |
77+
\*---------------------------------------------------------*/
78+
for(unsigned int zone_id = 0; zone_id < RAZER_MAX_ZONES; zone_id++)
79+
{
80+
if(device_list[device_index]->zones[zone_id] != NULL)
81+
{
82+
zone new_zone;
83+
84+
new_zone.name = device_list[device_index]->zones[zone_id]->name;
85+
new_zone.type = device_list[device_index]->zones[zone_id]->type;
86+
new_zone.leds_count = device_list[device_index]->zones[zone_id]->rows * device_list[device_index]->zones[zone_id]->cols;
87+
new_zone.leds_min = new_zone.leds_count;
88+
new_zone.leds_max = new_zone.leds_count;
89+
90+
if(new_zone.type == ZONE_TYPE_MATRIX)
91+
{
92+
matrix_map_type * new_map = new matrix_map_type;
93+
94+
new_zone.matrix_map = new_map;
95+
new_map->height = device_list[device_index]->zones[zone_id]->rows;
96+
new_map->width = device_list[device_index]->zones[zone_id]->cols;
97+
new_map->map = new unsigned int[new_map->height * new_map->width];
98+
99+
for(unsigned int y = 0; y < new_map->height; y++)
100+
{
101+
for(unsigned int x = 0; x < new_map->width; x++)
102+
{
103+
new_map->map[(y * new_map->width) + x] = (y * new_map->width) + x;
104+
}
105+
}
106+
}
107+
else
108+
{
109+
new_zone.matrix_map = NULL;
110+
}
111+
112+
zones.push_back(new_zone);
113+
}
114+
}
115+
116+
for(unsigned int zone_id = 0; zone_id < zones.size(); zone_id++)
117+
{
118+
for(unsigned int row_id = 0; row_id < device_list[device_index]->zones[zone_id]->rows; row_id++)
119+
{
120+
for(unsigned int col_id = 0; col_id < device_list[device_index]->zones[zone_id]->cols; col_id++)
121+
{
122+
led* new_led = new led();
123+
124+
new_led->name = device_list[device_index]->zones[zone_id]->name;
125+
126+
if(zones[zone_id].leds_count > 1)
127+
{
128+
new_led->name.append(" LED ");
129+
new_led->name.append(std::to_string(col_id + 1));
130+
}
131+
132+
leds.push_back(*new_led);
133+
}
134+
}
135+
}
136+
137+
SetupColors();
138+
}
139+
140+
void RGBController_RazerHanbo::ResizeZone(int /*zone*/, int /*new_size*/)
141+
{
142+
/*---------------------------------------------------------*\
143+
| This device does not support resizing zones |
144+
\*---------------------------------------------------------*/
145+
}
146+
147+
void RGBController_RazerHanbo::DeviceUpdateLEDs()
148+
{
149+
UpdateZoneLEDs(PUMP);
150+
UpdateZoneLEDs(FAN1);
151+
UpdateZoneLEDs(FAN2);
152+
UpdateZoneLEDs(FAN3);
153+
}
154+
155+
/*---------------------------------------------------------*\
156+
| The Hanbo command set is arranged in terms of zones. |
157+
| Transactions are straight forward when grouped this way. |
158+
\*---------------------------------------------------------*/
159+
160+
void RGBController_RazerHanbo::UpdateZoneLEDs(int zoneid)
161+
{
162+
controller->SetZoneLeds(zoneid, this->zones[zoneid]);
163+
}
164+
165+
void RGBController_RazerHanbo::UpdateSingleLED(int /*led*/)
166+
{
167+
DeviceUpdateLEDs();
168+
}
169+
170+
void RGBController_RazerHanbo::DeviceUpdateMode()
171+
{
172+
switch(modes[active_mode].value)
173+
{
174+
case RAZER_HANBO_MODE_DIRECT:
175+
if(local_mode != RAZER_HANBO_MODE_DIRECT)
176+
controller->SetDirectMode();
177+
break;
178+
179+
case RAZER_HANBO_MODE_OFF:
180+
controller->SetModeOff();
181+
break;
182+
183+
case RAZER_HANBO_MODE_SPECTRUM_CYCLE:
184+
controller->SetModeSpectrumCycle();
185+
break;
186+
}
187+
188+
local_mode = modes[active_mode].value;
189+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*---------------------------------------------------------*\
2+
| RGBController_Razer.h |
3+
| |
4+
| RGBController for Razer Hanbo devices |
5+
| |
6+
| Joseph East (dripsnek) 12 Apr 2025 |
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 "RGBController.h"
15+
#include "RazerHanboController.h"
16+
17+
enum
18+
{
19+
RAZER_HANBO_MODE_DIRECT,
20+
RAZER_HANBO_MODE_OFF,
21+
RAZER_HANBO_MODE_SPECTRUM_CYCLE,
22+
};
23+
24+
class RGBController_RazerHanbo : public RGBController
25+
{
26+
public:
27+
RGBController_RazerHanbo(RazerHanboController* controller_ptr);
28+
~RGBController_RazerHanbo();
29+
30+
void SetupZones();
31+
32+
void ResizeZone(int zone, int new_size);
33+
34+
void DeviceUpdateLEDs();
35+
void UpdateZoneLEDs(int zone);
36+
void UpdateSingleLED(int led);
37+
38+
void DeviceUpdateMode();
39+
40+
private:
41+
RazerHanboController* controller;
42+
int local_mode;
43+
};

0 commit comments

Comments
 (0)