mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2026-05-24 22:45:55 -04:00
Add basic Razer Blade 14 2021 fan control based on razer-fan-control's reverse engineering effort. Commanding zero speed sets auto fan control mode
This commit is contained in:
39
Controllers/RazerController/FanController_Razer.cpp
Normal file
39
Controllers/RazerController/FanController_Razer.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
/*-----------------------------------------*\
|
||||
| FanController_Razer.cpp |
|
||||
| |
|
||||
| Generic Fan Interface for Razer Blade |
|
||||
| laptops that support fan control |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 6/23/2021 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "FanController_Razer.h"
|
||||
|
||||
FanController_Razer::FanController_Razer(RazerController* controller_ptr)
|
||||
{
|
||||
controller = controller_ptr;
|
||||
|
||||
name = controller->GetName();
|
||||
description = "Razer Device";
|
||||
version = controller->GetFirmwareString();
|
||||
|
||||
fan new_fan;
|
||||
|
||||
new_fan.name = "Razer Blade Laptop Fan";
|
||||
new_fan.speed_min = 0;
|
||||
new_fan.speed_max = 5400;
|
||||
new_fan.speed_cmd = 0;
|
||||
new_fan.rpm_rdg = 0;
|
||||
|
||||
fans.push_back(new_fan);
|
||||
}
|
||||
|
||||
void FanController_Razer::UpdateControl()
|
||||
{
|
||||
controller->SetFanRPM(fans[0].speed_cmd);
|
||||
}
|
||||
|
||||
void FanController_Razer::UpdateReading()
|
||||
{
|
||||
|
||||
}
|
||||
24
Controllers/RazerController/FanController_Razer.h
Normal file
24
Controllers/RazerController/FanController_Razer.h
Normal file
@@ -0,0 +1,24 @@
|
||||
/*-----------------------------------------*\
|
||||
| FanController_Razer.h |
|
||||
| |
|
||||
| Generic Fan Interface for Razer Blade |
|
||||
| laptops that support fan control |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 6/23/2021 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "FanController.h"
|
||||
#include "RazerController.h"
|
||||
|
||||
class FanController_Razer : public FanController
|
||||
{
|
||||
public:
|
||||
FanController_Razer(RazerController* controller_ptr);
|
||||
|
||||
void UpdateControl();
|
||||
void UpdateReading();
|
||||
|
||||
private:
|
||||
RazerController* controller;
|
||||
};
|
||||
@@ -355,6 +355,18 @@ bool RazerController::SupportsBreathing()
|
||||
return(supports_breathing);
|
||||
}
|
||||
|
||||
void RazerController::SetFanRPM(unsigned int fan_rpm_cmd)
|
||||
{
|
||||
if(fan_rpm_cmd == 0)
|
||||
{
|
||||
razer_set_fan_rpm_cmd(true, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
razer_set_fan_rpm_cmd(false, fan_rpm_cmd);
|
||||
}
|
||||
}
|
||||
|
||||
bool RazerController::SupportsReactive()
|
||||
{
|
||||
return(false);
|
||||
@@ -1796,6 +1808,29 @@ void RazerController::razer_set_mode_wave(unsigned char direction)
|
||||
}
|
||||
}
|
||||
|
||||
void RazerController::razer_set_fan_rpm_cmd(bool auto_fan_rpm, unsigned int fan_rpm_cmd)
|
||||
{
|
||||
struct razer_report mode_report = razer_create_report(0x0D, 0x02, 0x04);
|
||||
|
||||
mode_report.arguments[0] = 0x00;
|
||||
mode_report.arguments[1] = 0x01;
|
||||
mode_report.arguments[2] = 0x00;
|
||||
mode_report.arguments[3] = auto_fan_rpm ? 0x00 : 0x01;
|
||||
|
||||
razer_usb_send(&mode_report);
|
||||
|
||||
if(!auto_fan_rpm)
|
||||
{
|
||||
struct razer_report fan_rpm_report = razer_create_report(0x0D, 0x01, 0x03);
|
||||
|
||||
fan_rpm_report.arguments[0] = 0x00;
|
||||
fan_rpm_report.arguments[1] = 0x01;
|
||||
fan_rpm_report.arguments[2] = (fan_rpm_cmd / 100);
|
||||
|
||||
razer_usb_send(&fan_rpm_report);
|
||||
}
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------------*\
|
||||
| USB transfer functions |
|
||||
\*---------------------------------------------------------------------------------*/
|
||||
|
||||
@@ -246,6 +246,8 @@ public:
|
||||
void SetModeWave(unsigned char direction);
|
||||
|
||||
bool SupportsBreathing();
|
||||
void SetFanRPM(unsigned int fan_rpm_cmd);
|
||||
|
||||
bool SupportsReactive();
|
||||
bool SupportsWave();
|
||||
|
||||
@@ -341,6 +343,8 @@ private:
|
||||
void razer_set_mode_static(unsigned char red, unsigned char grn, unsigned char blu);
|
||||
void razer_set_mode_wave(unsigned char direction);
|
||||
|
||||
void razer_set_fan_rpm_cmd(bool auto_fan_rpm, unsigned int fan_rpm_cmd);
|
||||
|
||||
int razer_usb_receive(razer_report* report);
|
||||
int razer_usb_send(razer_report* report);
|
||||
int razer_usb_send_argb(razer_argb_report* report);
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
#include "RazerKrakenController.h"
|
||||
#include "RazerDevices.h"
|
||||
#include "ResourceManager.h"
|
||||
#include "FanController.h"
|
||||
#include "FanController_Razer.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_Razer.h"
|
||||
#include "RGBController_RazerAddressable.h"
|
||||
@@ -40,6 +42,12 @@ void DetectRazerControllers(hid_device_info* info, const std::string& name)
|
||||
|
||||
RGBController_Razer* rgb_controller = new RGBController_Razer(controller);
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
|
||||
if(info->product_id == RAZER_BLADE_14_2021_PID)
|
||||
{
|
||||
FanController_Razer* fan_controller = new FanController_Razer(controller);
|
||||
ResourceManager::get()->RegisterFanController(fan_controller);
|
||||
}
|
||||
}
|
||||
} /* DetectRazerControllers() */
|
||||
|
||||
|
||||
@@ -166,4 +166,4 @@ While no code from these projects directly made its way into OpenRGB, these proj
|
||||
* k550-macos https://github.com/vookimedlo/ck550-macos/tree/master
|
||||
* luxafor-python https://github.com/vmitchell85/luxafor-python
|
||||
* dreamcheekyusb https://github.com/gbrayut/dreamcheekyusb
|
||||
|
||||
* razer-laptop-control: https://github.com/rnd-ash/razer-laptop-control
|
||||
|
||||
Reference in New Issue
Block a user