From af23c040075cfecb89a213cd55f1df5d84ac501c Mon Sep 17 00:00:00 2001 From: Dmitry K Date: Thu, 6 Jul 2023 16:33:25 +0000 Subject: [PATCH] [FAN Controller] Initial implementation for Asus TUF Fan controller --- .../AsusTUFLaptopDetect_Windows.cpp | 3 ++ .../FanController_AsusTUFLaptop_Windows.cpp | 44 +++++++++++++++++++ .../FanController_AsusTUFLaptop_Windows.h | 18 ++++++++ 3 files changed, 65 insertions(+) create mode 100644 Controllers/AsusTUFLaptopController/FanController_AsusTUFLaptop_Windows.cpp create mode 100644 Controllers/AsusTUFLaptopController/FanController_AsusTUFLaptop_Windows.h diff --git a/Controllers/AsusTUFLaptopController/AsusTUFLaptopDetect_Windows.cpp b/Controllers/AsusTUFLaptopController/AsusTUFLaptopDetect_Windows.cpp index 012d30e3..d50fcc76 100644 --- a/Controllers/AsusTUFLaptopController/AsusTUFLaptopDetect_Windows.cpp +++ b/Controllers/AsusTUFLaptopController/AsusTUFLaptopDetect_Windows.cpp @@ -9,6 +9,7 @@ #include #include "Detector.h" +#include "FanController_AsusTUFLaptop_Windows.h" #include "RGBController_AsusTUFLaptop_Windows.h" #include "wmi.h" @@ -44,8 +45,10 @@ static void DetectAsusTUFLaptopWMIControllers() if(controller) { RGBController* new_controller = new RGBController_AsusTUFLaptopWMI(controller); + FanController* fan_controller = new FanController_AsusTUFLaptopWMI(controller); ResourceManager::get()->RegisterRGBController(new_controller); + ResourceManager::get()->RegisterFanController(fan_controller); } } /* DetectAsusTUFLaptopWMIControllers() */ diff --git a/Controllers/AsusTUFLaptopController/FanController_AsusTUFLaptop_Windows.cpp b/Controllers/AsusTUFLaptopController/FanController_AsusTUFLaptop_Windows.cpp new file mode 100644 index 00000000..a78b4d90 --- /dev/null +++ b/Controllers/AsusTUFLaptopController/FanController_AsusTUFLaptop_Windows.cpp @@ -0,0 +1,44 @@ +#include "FanController_AsusTUFLaptop_Windows.h" + + +FanController_AsusTUFLaptopWMI::FanController_AsusTUFLaptopWMI(AsusTUFLaptopController* dev) +{ + controller = dev; + name = "ASUS TUF Laptop"; + description = "WMI Device"; + location = "\\\\.\\ATKACPI"; + + // Coolers RPM reading & current mode retrieval is still WIP + fans.resize(2); + fans[0].name = "CPU Cooler"; + fans[0].speed_min = 0; + fans[0].speed_max = 2; + fans[0].speed_cmd = 1; + fans[0].prev_speed_cmd = 1; + fans[0].rpm_rdg = 0; // We don't have it, but we don't want an unitialized value either +} + +void FanController_AsusTUFLaptopWMI::UpdateControl() +{ + int mode = fans[0].speed_cmd; + switch(mode) + { + case 0: + mode = ASUS_WMI_FAN_SPEED_SILENT; + break; + case 1: + mode = ASUS_WMI_FAN_SPEED_NORMAL; + break; + case 2: + mode = ASUS_WMI_FAN_SPEED_TURBO; + break; + } + + controller->setFanMode(mode); +} + +void FanController_AsusTUFLaptopWMI::UpdateReading() +{ + ; +} + diff --git a/Controllers/AsusTUFLaptopController/FanController_AsusTUFLaptop_Windows.h b/Controllers/AsusTUFLaptopController/FanController_AsusTUFLaptop_Windows.h new file mode 100644 index 00000000..3f5371fa --- /dev/null +++ b/Controllers/AsusTUFLaptopController/FanController_AsusTUFLaptop_Windows.h @@ -0,0 +1,18 @@ +#ifndef FANCONTROLLER_ASUSTUFLAPTOPWMI_H +#define FANCONTROLLER_ASUSTUFLAPTOPWMI_H + +#include "FanController.h" +#include "AsusTUFLaptopController_Windows.h" + +class FanController_AsusTUFLaptopWMI : public FanController +{ +private: + AsusTUFLaptopController* controller; + +public: + FanController_AsusTUFLaptopWMI(AsusTUFLaptopController* dev); + void UpdateControl() override; + void UpdateReading() override; +}; + +#endif // FANCONTROLLER_ASUSTUFLAPTOPWMI_H