Publish LumaOps source

This commit is contained in:
LumaOps release export
2026-09-03 01:18:36 +02:00
commit 7f1c0e5f71
2363 changed files with 501543 additions and 0 deletions
@@ -0,0 +1,59 @@
/*---------------------------------------------------------*\
| AsusTUFLaptopController_Linux.cpp |
| |
| Driver for ASUS TUF laptop |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include <string>
#include "AsusTUFLaptopController_Linux.h"
void AsusTUFLaptopLinuxController::SendUpdate
(
unsigned char mode,
unsigned char speed,
unsigned char save,
unsigned char red,
unsigned char green,
unsigned char blue
)
{
std::string s = "";
s.append(ASUS_KBD_BACKLIGHT_BASE_PATH);
s.append(ASUS_KBD_BACKLIGHT_MODE_PATH);
FILE *controller = fopen(s.c_str(), "w");
s = "";
s.append(std::to_string(save));
s.append(" ");
s.append(std::to_string(mode));
s.append(" ");
s.append(std::to_string(red));
s.append(" ");
s.append(std::to_string(green));
s.append(" ");
s.append(std::to_string(blue));
s.append(" ");
s.append(std::to_string(speed));
fputs(s.c_str(), controller);
fclose(controller);
}
void AsusTUFLaptopLinuxController::SendBrightness
(
unsigned char brightness
)
{
std::string s = "";
s.append(ASUS_KBD_BACKLIGHT_BASE_PATH);
s.append(ASUS_KBD_BACKLIGHT_BRIGHTNESS_PATH);
FILE *controller = fopen(s.c_str(), "w");
fputs(std::to_string(brightness).c_str(), controller);
fclose(controller);
}
@@ -0,0 +1,43 @@
/*---------------------------------------------------------*\
| AsusTUFLaptopController_Linux.h |
| |
| Driver for ASUS TUF laptop |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include "RGBController.h"
#define ASUS_KBD_BACKLIGHT_BRIGHTNESS_MIN 0
#define ASUS_KBD_BACKLIGHT_BRIGHTNESS_MAX 3
#define ASUS_KBD_BACKLIGHT_BRIGHTNESS 3
#define ASUS_KBD_BACKLIGHT_SPEED_MIN 0
#define ASUS_KBD_BACKLIGHT_SPEED_MAX 2
#define ASUS_KBD_BACKLIGHT_SPEED 1
#define ASUS_KBD_BACKLIGHT_BASE_PATH "/sys/devices/platform/asus-nb-wmi/leds/asus::kbd_backlight"
#define ASUS_KBD_BACKLIGHT_MODE_PATH "/kbd_rgb_mode"
#define ASUS_KBD_BACKLIGHT_BRIGHTNESS_PATH "/brightness"
class AsusTUFLaptopLinuxController
{
public:
void SendBrightness
(
unsigned char brightness
);
void SendUpdate
(
unsigned char mode,
unsigned char speed,
unsigned char save,
unsigned char red,
unsigned char green,
unsigned char blue
);
};
@@ -0,0 +1,343 @@
/*---------------------------------------------------------*\
| AsusTUFLaptopController_Windows.cpp |
| |
| Driver for ASUS TUF laptop |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include <cstdint>
#include <cstring>
#include <cstdio>
#include <Objbase.h>
#include <setupapi.h>
#include <comdef.h>
#include <Wbemidl.h>
#include "AsusTUFLaptopController_Windows.h"
static bool coInitialized = 0;
static GUID CLSID_GUID_DEVCLASS_SYSTEM = { 0x4D36E97D, 0xE325, 0x11CE, {0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18 } };
int AsusTUFLaptopController::checkWMIType()
{
int n;
int result = 0;
struct _SP_DEVINFO_DATA DeviceInfoData;
const int bufsize = 260;
wchar_t PropertyBuffer[bufsize];
HDEVINFO devinfo = SetupDiGetClassDevsW(&CLSID_GUID_DEVCLASS_SYSTEM, 0, 0, 2u);
if(devinfo == HDEVINFO(-1))
{
return 0;
}
n = 0;
DeviceInfoData.cbSize = sizeof(DeviceInfoData);
while(SetupDiEnumDeviceInfo(devinfo, n, &DeviceInfoData)) // Invalid buffer
{
if(SetupDiGetDeviceRegistryPropertyW(devinfo,
&DeviceInfoData,
SPDRP_ENUMERATOR_NAME,
NULL,
PBYTE(PropertyBuffer),
sizeof(PropertyBuffer),
0))
{
// If we found property "ACPI"
if(!wcscmp(PropertyBuffer, L"ACPI"))
{
memset(PropertyBuffer, 0, sizeof(PropertyBuffer));
if(SetupDiGetDeviceInstanceIdW(devinfo, &DeviceInfoData, PropertyBuffer, bufsize, 0))
{
_wcsupr_s(PropertyBuffer, bufsize);
if(wcsstr(PropertyBuffer, L"ACPI\\ATK0100"))
{
result = 1;
break;
}
if(!wcscmp(PropertyBuffer, L"ACPI\\PNP0C14\\ATK"))
{
result = 2;
break;
}
}
}
}
n++;
}
SetupDiDestroyDeviceInfoList(devinfo);
return(result);
}
AsusTUFLaptopController::AsusTUFLaptopController()
{
hDevice = CreateFileW(L"\\\\.\\ATKACPI", 0xC0000000, 3u, 0, 3u, 0, 0);
}
AsusTUFLaptopController* AsusTUFLaptopController::checkAndCreate()
{
// This might cause issues when coInitialize() is used in multiple places
HRESULT init = CoInitializeEx(0, COINIT_APARTMENTTHREADED);
if(init < 0 && init != 0x80010106)
{
return(0);
}
coInitialized = 1;
int type = checkWMIType();
if(type == 2)
{
AsusTUFLaptopController* controller = new AsusTUFLaptopController();
if(controller->hDevice != HANDLE(-1))
{
return(controller);
}
delete controller;
}
return(nullptr);
}
AsusTUFLaptopController::~AsusTUFLaptopController()
{
if(hDevice && hDevice != HANDLE(-1))
{
CloseHandle(hDevice);
hDevice = 0;
}
/*-----------------------------------------------------*\
| This might cause issues when coInitialize() is used |
| in multiple places |
\*-----------------------------------------------------*/
if(coInitialized)
{
CoUninitialize();
coInitialized = 0;
}
}
bool AsusTUFLaptopController::deviceIoControlWrapper(const void *dataIn, int commandIndex, int dataSizeIn, void *dataOut, int *dataSizeOut)
{
size_t BytesReturned;
const int bufsize = 1024;
char outBuffer[bufsize];
LPDWORD inBuffer = LPDWORD(malloc(dataSizeIn + 8));
inBuffer[0] = commandIndex;
inBuffer[1] = dataSizeIn;
memmove(inBuffer + 2, dataIn, dataSizeIn);
memset(outBuffer, 0, bufsize);
BytesReturned = 0;
bool result = DeviceIoControl(
hDevice,
0x22240Cu,
inBuffer,
dataSizeIn + 8,
outBuffer,
bufsize,
LPDWORD(&BytesReturned),
0);
if(result)
{
if((size_t)*dataSizeOut < BytesReturned)
{
BytesReturned = (size_t)*dataSizeOut;
}
memmove(dataOut, outBuffer, BytesReturned);
}
free(inBuffer);
return(result);
}
bool AsusTUFLaptopController::deviceControl(int a1, int a2)
{
if(hDevice && hDevice != HANDLE(-1))
{
int data[2];
data[0] = a1;
data[1] = a2;
int result;
int outBufSize = 4;
if(deviceIoControlWrapper(&data, 1398162756, 8, &result, &outBufSize))
{
if(outBufSize < 4)
{
result = 0;
}
if(result == 1)
{
return(1);
}
}
}
return(0);
}
bool AsusTUFLaptopController::deviceControl(int a1, int a2, int a3)
{
unsigned int data[3];
data[0] = a1;
data[1] = a2;
data[2] = a3;
int outBuf;
int outBufSize = 4;
if(hDevice && hDevice != HANDLE(-1))
{
if(deviceIoControlWrapper(data, 0x53564544, 12, &outBuf, &outBufSize))
{
if(outBufSize < 4)
{
outBuf = 0;
}
if(outBuf == 1)
{
return(1);
}
}
}
return(0);
}
bool AsusTUFLaptopController::getStatus(int a1, int *out)
{
int status;
int statusSize = 4;
if(!hDevice || hDevice == HANDLE(-1) || (!deviceIoControlWrapper(&a1, 1398035268, 4, &status, &statusSize)))
{
return(0);
}
if(statusSize < 4)
{
status = 0;
}
*out = status;
return(1);
}
bool AsusTUFLaptopController::getStatusExtended(int a1, int a2, int *status1, int *status2, int* status3)
{
int commandData[2];
commandData[0] = a1;
commandData[1] = a2;
int statusBuffer[3];
int statusSize = 12;
if(hDevice && hDevice != HANDLE(-1) && deviceIoControlWrapper(commandData, 1398035268, 8, statusBuffer, &statusSize))
{
*status1 = statusBuffer[0];
*status2 = statusBuffer[1];
*status3 = statusBuffer[2];
return(1);
}
else
{
return(0);
}
}
void AsusTUFLaptopController::setMode(unsigned char red,
unsigned char green,
unsigned char blue,
unsigned char mode,
unsigned char speed,
bool save)
{
/*--------------------------------------------------------*\
| Use switch case since our speed values are magic numbers |
| Default to Medium/Normal speed |
\*--------------------------------------------------------*/
unsigned char speed_val;
switch(speed)
{
case(1):
speed_val = ASUS_WMI_KEYBOARD_SPEED_SLOW;
break;
default:
case(2):
speed_val = ASUS_WMI_KEYBOARD_SPEED_NORMAL;
break;
case(3):
speed_val = ASUS_WMI_KEYBOARD_SPEED_FAST;
break;
}
/*----------------------------------------------------------*\
| We need to use a magic value to save to firmware in order |
| To persist reboots. Save is normal op with different magic |
\*----------------------------------------------------------*/
unsigned char save_val = ASUS_WMI_KEYBOARD_MAGIC_USE;
if(save)
{
save_val = ASUS_WMI_KEYBOARD_MAGIC_SAVE;
}
// B3 is store value
unsigned int high = save_val | (mode<<8) | (red<<16) | (green<<24);
unsigned int low = blue | (speed_val<<8);
deviceControl(ASUS_WMI_DEVID_TUF_RGB_MODE, high, low);
}
unsigned char AsusTUFLaptopController::getBrightness()
{
int backlight_state = 0;
getStatus(ASUS_WMI_DEVID_KBD_BACKLIGHT, &backlight_state);
/*-----------------------------------------------------*\
| Only lowest two bits indicate brightness level |
\*-----------------------------------------------------*/
return backlight_state & 0x7F;
}
void AsusTUFLaptopController::setBrightness(unsigned char brightness)
{
/*-----------------------------------------------------*\
| Only calls in this format persistently set brightness |
\*-----------------------------------------------------*/
int ctrl_param = 0x80 | (brightness & 0x7F);
deviceControl(ASUS_WMI_DEVID_KBD_BACKLIGHT, ctrl_param);
}
/*-----------------------------------------------------------*\
| These settings will not persist a reboot unless save is set |
\*-----------------------------------------------------------*/
void AsusTUFLaptopController::setPowerState(bool boot,
bool awake,
bool sleep,
bool shutdown,
bool save)
{
unsigned int state = 0xBD;
if(boot) state = state | ASUS_WMI_KEYBOARD_POWER_BOOT;
if(awake) state = state | ASUS_WMI_KEYBOARD_POWER_AWAKE;
if(sleep) state = state | ASUS_WMI_KEYBOARD_POWER_SLEEP;
if(shutdown) state = state | ASUS_WMI_KEYBOARD_POWER_SHUTDOWN;
if(save) state = state | ASUS_WMI_KEYBOARD_POWER_SAVE;
deviceControl(ASUS_WMI_DEVID_TUF_RGB_STATE, state);
}
void AsusTUFLaptopController::setFanMode(int mode)
{
deviceControl(ASUS_WMI_DEVID_FAN_BOOST_MODE, mode);
}
@@ -0,0 +1,84 @@
/*---------------------------------------------------------*\
| AsusTUFLaptopController_Windows.h |
| |
| Driver for ASUS TUF laptop |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include <windows.h>
#define ASUS_WMI_DEVID_KBD_BACKLIGHT 0x00050021
#define ASUS_WMI_DEVID_TUF_RGB_MODE 0x00100056
#define ASUS_WMI_DEVID_TUF_RGB_STATE 0x00100057
#define ASUS_WMI_DEVID_FAN_BOOST_MODE 0x00110018
#define ASUS_WMI_DEVID_THROTTLE_THERMAL_POLICY 0x00120075
#define ASUS_WMI_KEYBOARD_SPEED_SLOW 0xE1
#define ASUS_WMI_KEYBOARD_SPEED_NORMAL 0xEB
#define ASUS_WMI_KEYBOARD_SPEED_FAST 0xF5
#define ASUS_WMI_KEYBOARD_SPEED_MIN 1
#define ASUS_WMI_KEYBOARD_SPEED_MAX 3
#define ASUS_WMI_KEYBOARD_MODE_STATIC 0x00
#define ASUS_WMI_KEYBOARD_MODE_BREATHING 0x01
#define ASUS_WMI_KEYBOARD_MODE_COLORCYCLE 0x02
#define ASUS_WMI_KEYBOARD_MODE_STROBING 0x0A
#define ASUS_WMI_KEYBOARD_BRIGHTNESS_MIN 0
#define ASUS_WMI_KEYBOARD_BRIGHTNESS_MAX 3
#define ASUS_WMI_KEYBOARD_MAGIC_USE 0xB3
#define ASUS_WMI_KEYBOARD_MAGIC_SAVE 0xB4
#define ASUS_WMI_KEYBOARD_POWER_BOOT 0x03<<16
#define ASUS_WMI_KEYBOARD_POWER_AWAKE 0x0C<<16
#define ASUS_WMI_KEYBOARD_POWER_SLEEP 0x30<<16
#define ASUS_WMI_KEYBOARD_POWER_SHUTDOWN 0xC0<<16
#define ASUS_WMI_KEYBOARD_POWER_SAVE 0x01<<8
#define ASUS_WMI_FAN_SPEED_NORMAL 0
#define ASUS_WMI_FAN_SPEED_TURBO 1
#define ASUS_WMI_FAN_SPEED_SILENT 2
class AsusTUFLaptopController
{
private:
HANDLE hDevice;
static int checkWMIType();
AsusTUFLaptopController();
bool deviceIoControlWrapper(const void *dataIn, int commandIndex, int dataSizeIn, void *dataOut, int *dataSizeOut);
bool deviceControl(int a1, int a2);
bool deviceControl(int a1, int a2, int a3);
bool getStatus(int a1, int *out);
bool getStatusExtended(int a1, int a2, int *status1, int *status2, int* status3);
public:
static AsusTUFLaptopController * checkAndCreate();
~AsusTUFLaptopController();
void setMode(unsigned char red,
unsigned char green,
unsigned char blue,
unsigned char mode,
unsigned char speed,
bool save);
unsigned char getBrightness();
void setBrightness(unsigned char brightness);
void setPowerState(bool boot,
bool awake,
bool sleep,
bool shutdown,
bool save);
void setFanMode(int mode);
};
@@ -0,0 +1,35 @@
/*---------------------------------------------------------*\
| AsusTUFLaptopDetect_Linux.cpp |
| |
| Detector for ASUS TUF laptop |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include <string>
#include <unistd.h>
#include "Detector.h"
#include "RGBController_AsusTUFLaptop_Linux.h"
static void DetectAsusTUFLaptopLinuxControllers()
{
/*-------------------------------------------------------------------------------------*\
| If /sys/devices/platform/asus-nb-wmi/leds/asus::kbd_backlight/kbd_rgb_mode exists, |
| the kernel support TUF Laptop keyboard LED controlling. |
\*-------------------------------------------------------------------------------------*/
std::string s = "";
s.append(ASUS_KBD_BACKLIGHT_BASE_PATH);
s.append(ASUS_KBD_BACKLIGHT_MODE_PATH);
if(!access(s.c_str(), F_OK))
{
AsusTUFLaptopLinuxController* controller = new AsusTUFLaptopLinuxController();
RGBController_AsusTUFLaptopLinux* rgb_controller = new RGBController_AsusTUFLaptopLinux(controller);
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
return;
}
REGISTER_DETECTOR("ASUS TUF Laptop", DetectAsusTUFLaptopLinuxControllers);
@@ -0,0 +1,52 @@
/*---------------------------------------------------------*\
| AsusTUFLaptopDetect_Windows.cpp |
| |
| Detector for ASUS TUF laptop |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include <string>
#include "Detector.h"
#include "RGBController_AsusTUFLaptop_Windows.h"
#include "wmi.h"
static void DetectAsusTUFLaptopWMIControllers()
{
// Try to retrieve ProductID / Device name from WMI; Possibly can be rewritten to use wmi.cpp
// IF you encounter false detection ( e.g. if your laptop keyboard backlight uses USB interface
// instead of ACPI WMI) please add a WHITELIST by checking the
// `name` variable for model substrings like "FX505DU"
// For now, checking for "TUF Gaming" should suffice
Wmi wmi;
std::vector<QueryObj> systemProduct;
if (wmi.query("SELECT * FROM Win32_ComputerSystemProduct", systemProduct))
{
return;
}
// There should only be one, a cycle is a precaution
if(systemProduct.size() != 1)
{
return;
}
std::string& name = systemProduct[0]["Name"];
if(name.find("TUF Gaming") == name.npos)
{
return;
}
AsusTUFLaptopController* controller = AsusTUFLaptopController::checkAndCreate();
if(controller)
{
RGBController* new_controller = new RGBController_AsusTUFLaptopWMI(controller);
ResourceManager::get()->RegisterRGBController(new_controller);
}
} /* DetectAsusTUFLaptopWMIControllers() */
REGISTER_DETECTOR("ASUS TUF Laptop", DetectAsusTUFLaptopWMIControllers);
@@ -0,0 +1,159 @@
/*---------------------------------------------------------*\
| RGBController_AsusTUFLaptop_Linux.cpp |
| |
| RGBController for ASUS TUF laptop |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "RGBController_AsusTUFLaptop_Linux.h"
/**------------------------------------------------------------------*\
@name Asus TUF Laptop Linux WMI
@category Keyboard
@type File Stream
@save :x:
@direct :white_check_mark:
@effects :white_check_mark:
@detectors DetectAsusTUFLaptopLinuxControllers
@comment Tested on ASUS TUF Gaming A15 2022
PLEASE UPDATE YOUR KERNEL TO A VERSION NEWER THAN 6.1.0
Every devices supported by asus-wmi would work technically.
\*-------------------------------------------------------------------*/
RGBController_AsusTUFLaptopLinux::RGBController_AsusTUFLaptopLinux(AsusTUFLaptopLinuxController* controller_ptr)
{
controller = controller_ptr;
name = "ASUS TUF Laptop Keyboard";
vendor = "ASUS";
type = DEVICE_TYPE_LAPTOP;
description = "Asus TUF Device";
location = ASUS_KBD_BACKLIGHT_BASE_PATH;
mode Direct;
Direct.name = "Direct";
Direct.value = 4;
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
Direct.brightness_min = ASUS_KBD_BACKLIGHT_BRIGHTNESS_MIN;
Direct.brightness_max = ASUS_KBD_BACKLIGHT_BRIGHTNESS_MAX;
Direct.brightness = ASUS_KBD_BACKLIGHT_BRIGHTNESS;
Direct.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Direct);
mode Static;
Static.name = "Static";
Static.value = 0;
Static.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
Static.brightness_min = ASUS_KBD_BACKLIGHT_BRIGHTNESS_MIN;
Static.brightness_max = ASUS_KBD_BACKLIGHT_BRIGHTNESS_MAX;
Static.brightness = ASUS_KBD_BACKLIGHT_BRIGHTNESS;
Static.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Static);
mode Breathing;
Breathing.name = "Breathing";
Breathing.value = 1;
Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
Breathing.speed_min = ASUS_KBD_BACKLIGHT_SPEED_MIN;
Breathing.speed_max = ASUS_KBD_BACKLIGHT_SPEED_MAX;
Breathing.brightness_min = ASUS_KBD_BACKLIGHT_BRIGHTNESS_MIN;
Breathing.brightness_max = ASUS_KBD_BACKLIGHT_BRIGHTNESS_MAX;
Breathing.brightness = ASUS_KBD_BACKLIGHT_BRIGHTNESS;
Breathing.color_mode = MODE_COLORS_PER_LED;
Breathing.speed = ASUS_KBD_BACKLIGHT_SPEED;
modes.push_back(Breathing);
mode Cycle;
Cycle.name = "Spectrum Cycle";
Cycle.value = 2;
Cycle.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS;
Cycle.speed_min = ASUS_KBD_BACKLIGHT_SPEED_MIN;
Cycle.speed_max = ASUS_KBD_BACKLIGHT_SPEED_MAX;
Cycle.brightness_min = ASUS_KBD_BACKLIGHT_BRIGHTNESS_MIN;
Cycle.brightness_max = ASUS_KBD_BACKLIGHT_BRIGHTNESS_MAX;
Cycle.brightness = ASUS_KBD_BACKLIGHT_BRIGHTNESS;
Cycle.color_mode = MODE_COLORS_NONE;
Cycle.speed = ASUS_KBD_BACKLIGHT_SPEED;
modes.push_back(Cycle);
mode Flashing;
Flashing.name = "Flashing";
Flashing.value = 0x0A;
Flashing.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
Flashing.brightness_min = ASUS_KBD_BACKLIGHT_BRIGHTNESS_MIN;
Flashing.brightness_max = ASUS_KBD_BACKLIGHT_BRIGHTNESS_MAX;
Flashing.brightness = ASUS_KBD_BACKLIGHT_BRIGHTNESS;
Flashing.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Flashing);
SetupZones();
}
void RGBController_AsusTUFLaptopLinux::SetupZones()
{
/*---------------------------------------------------------*\
| Set up zone |
\*---------------------------------------------------------*/
zones.resize(1);
zones[0].type = ZONE_TYPE_SINGLE;
zones[0].name = "Keyboard Backlight zone";
zones[0].leds_min = 1;
zones[0].leds_max = 1;
zones[0].leds_count = 1;
zones[0].matrix_map = NULL;
/*---------------------------------------------------------*\
| Set up LED |
\*---------------------------------------------------------*/
leds.resize(1);
leds[0].name = "Keyboard Backlight LED";
SetupColors();
}
void RGBController_AsusTUFLaptopLinux::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_AsusTUFLaptopLinux::DeviceUpdateLEDs()
{
uint8_t red = RGBGetRValue(colors[0]);
uint8_t green = RGBGetGValue(colors[0]);
uint8_t blue = RGBGetBValue(colors[0]);
uint8_t speed = 0;
uint8_t mode = modes[active_mode].value;
uint8_t save = 1;
if(mode == 4)
{
mode = 0;
save = 0;
}
if(mode == 1 || mode == 2)
{
speed = modes[active_mode].speed;
}
controller->SendUpdate(mode, speed, save, red, green, blue);
controller->SendBrightness(modes[active_mode].brightness);
}
void RGBController_AsusTUFLaptopLinux::UpdateZoneLEDs(int /*zone*/)
{
DeviceUpdateLEDs();
}
void RGBController_AsusTUFLaptopLinux::UpdateSingleLED(int /*led*/)
{
DeviceUpdateLEDs();
}
void RGBController_AsusTUFLaptopLinux::DeviceUpdateMode()
{
DeviceUpdateLEDs();
}
@@ -0,0 +1,32 @@
/*---------------------------------------------------------*\
| RGBController_AsusTUFLaptop_Linux.h |
| |
| RGBController for ASUS TUF laptop |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include "RGBController.h"
#include "AsusTUFLaptopController_Linux.h"
class RGBController_AsusTUFLaptopLinux : public RGBController
{
public:
RGBController_AsusTUFLaptopLinux(AsusTUFLaptopLinuxController* controller_ptr);
void SetupZones() override;
void ResizeZone(int zone, int new_size) override;
void DeviceUpdateLEDs() override;
void UpdateZoneLEDs(int zone) override;
void UpdateSingleLED(int led) override;
void DeviceUpdateMode() override;
private:
AsusTUFLaptopLinuxController* controller;
};
@@ -0,0 +1,181 @@
/*---------------------------------------------------------*\
| RGBController_AsusTUFLaptop_Windows.cpp |
| |
| RGBController for ASUS TUF laptop |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "RGBController_AsusTUFLaptop_Windows.h"
using namespace std::chrono_literals;
/**------------------------------------------------------------------*\
@name Asus TUF Laptop
@category Keyboard
@type WMI
@save :x:
@direct :white_check_mark:
@effects :white_check_mark:
@detectors DetectAsusTUFLaptopWMIControllers
@comment
\*-------------------------------------------------------------------*/
RGBController_AsusTUFLaptopWMI::RGBController_AsusTUFLaptopWMI(AsusTUFLaptopController* controller_ptr)
{
name = "ASUS TUF Laptop Keyboard";
vendor = "ASUS";
type = DEVICE_TYPE_LAPTOP;
description = "WMI Device";
location = "\\\\.\\ATKACPI";
mode Static;
Static.name = "Static";
Static.value = ASUS_WMI_KEYBOARD_MODE_STATIC;
Static.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_MANUAL_SAVE;
Static.color_mode = MODE_COLORS_PER_LED;
Static.brightness_max = ASUS_WMI_KEYBOARD_BRIGHTNESS_MAX;
Static.brightness_min = ASUS_WMI_KEYBOARD_BRIGHTNESS_MIN;
Static.brightness = ASUS_WMI_KEYBOARD_BRIGHTNESS_MAX;
modes.push_back(Static);
mode Breathing;
Breathing.name = "Breathing";
Breathing.value = ASUS_WMI_KEYBOARD_MODE_BREATHING;
Breathing.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_MANUAL_SAVE;
Breathing.color_mode = MODE_COLORS_PER_LED;
Breathing.speed_min = ASUS_WMI_KEYBOARD_SPEED_MIN;
Breathing.speed_max = ASUS_WMI_KEYBOARD_SPEED_MAX;
Breathing.speed = 2;
Breathing.brightness_max = ASUS_WMI_KEYBOARD_BRIGHTNESS_MAX;
Breathing.brightness_min = ASUS_WMI_KEYBOARD_BRIGHTNESS_MIN;
Breathing.brightness = ASUS_WMI_KEYBOARD_BRIGHTNESS_MAX;
modes.push_back(Breathing);
mode ColorCycle;
ColorCycle.name = "Color Cycle";
ColorCycle.value = ASUS_WMI_KEYBOARD_MODE_COLORCYCLE;
ColorCycle.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_MANUAL_SAVE;
ColorCycle.color_mode = MODE_COLORS_NONE;
ColorCycle.speed_min = ASUS_WMI_KEYBOARD_SPEED_MIN;
ColorCycle.speed_max = ASUS_WMI_KEYBOARD_SPEED_MAX;
ColorCycle.speed = 2;
ColorCycle.brightness_max = ASUS_WMI_KEYBOARD_BRIGHTNESS_MAX;
ColorCycle.brightness_min = ASUS_WMI_KEYBOARD_BRIGHTNESS_MIN;
ColorCycle.brightness = ASUS_WMI_KEYBOARD_BRIGHTNESS_MAX;
modes.push_back(ColorCycle);
mode Strobing;
Strobing.name = "Strobing";
Strobing.value = ASUS_WMI_KEYBOARD_MODE_STROBING;
Strobing.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_MANUAL_SAVE;
Strobing.color_mode = MODE_COLORS_PER_LED;
Strobing.brightness_max = ASUS_WMI_KEYBOARD_BRIGHTNESS_MAX;
Strobing.brightness_min = ASUS_WMI_KEYBOARD_BRIGHTNESS_MIN;
Strobing.brightness = ASUS_WMI_KEYBOARD_BRIGHTNESS_MAX;
modes.push_back(Strobing);
SetupZones();
controller = controller_ptr;
ReadConfiguration();
}
RGBController_AsusTUFLaptopWMI::~RGBController_AsusTUFLaptopWMI()
{
delete controller;
}
void RGBController_AsusTUFLaptopWMI::SetupZones()
{
/*---------------------------------------------------------*\
| Device only has one zone and one led |
\*---------------------------------------------------------*/
zone* new_zone = new zone();
led* new_led = new led();
new_zone->type = ZONE_TYPE_SINGLE;
new_zone->name = "Keyboard Backlight zone";
new_zone->leds_min = 1;
new_zone->leds_max = 1;
new_zone->leds_count = 1;
new_zone->matrix_map = NULL;
new_led->name = "Keyboard Backlight LED";
zones.push_back(*new_zone);
leds.push_back(*new_led);
SetupColors();
}
void RGBController_AsusTUFLaptopWMI::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
/*---------------------------------------------------------*\
| Break this function off since we have to call save in the |
same operation as doing everything else. |
\*---------------------------------------------------------*/
void RGBController_AsusTUFLaptopWMI::ControllerSetMode(bool save)
{
unsigned char red = RGBGetRValue(colors[0]);
unsigned char green = RGBGetGValue(colors[0]);
unsigned char blue = RGBGetBValue(colors[0]);
unsigned char mode = (unsigned char)modes[(unsigned int)active_mode].value;
/*------------------------------------------------------------*\
| Use speed only if the mode supports it. Otherwise set normal |
\*------------------------------------------------------------*/
unsigned char speed = ASUS_WMI_KEYBOARD_SPEED_NORMAL;
if (modes[(unsigned int)active_mode].flags & MODE_FLAG_HAS_SPEED)
{
speed = (unsigned char)modes[(unsigned int)active_mode].speed;
}
controller->setMode(red, green, blue, mode, speed, save);
}
void RGBController_AsusTUFLaptopWMI::DeviceUpdateLEDs()
{
ControllerSetMode(false);
}
void RGBController_AsusTUFLaptopWMI::UpdateZoneLEDs(int /*zone*/)
{
ControllerSetMode(false);
}
void RGBController_AsusTUFLaptopWMI::UpdateSingleLED(int /*led*/)
{
ControllerSetMode(false);
}
void RGBController_AsusTUFLaptopWMI::DeviceUpdateMode()
{
if (modes[(unsigned int)active_mode].flags & MODE_FLAG_HAS_BRIGHTNESS)
{
controller->setBrightness((unsigned char)modes[(unsigned int)active_mode].brightness);
}
ControllerSetMode(false);
}
void RGBController_AsusTUFLaptopWMI::ReadConfiguration()
{
if (modes[(unsigned int)active_mode].flags & MODE_FLAG_HAS_BRIGHTNESS)
{
modes[(unsigned int)active_mode].brightness = controller->getBrightness();
}
}
void RGBController_AsusTUFLaptopWMI::DeviceSaveMode()
{
ControllerSetMode(true);
}
@@ -0,0 +1,37 @@
/*---------------------------------------------------------*\
| RGBController_AsusTUFLaptop_Windows.h |
| |
| RGBController for ASUS TUF laptop |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include "AsusTUFLaptopController_Windows.h"
#include "RGBController.h"
class RGBController_AsusTUFLaptopWMI : public RGBController
{
public:
RGBController_AsusTUFLaptopWMI(AsusTUFLaptopController* controller_ptr);
virtual ~RGBController_AsusTUFLaptopWMI();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void DeviceUpdateMode();
void DeviceSaveMode();
private:
AsusTUFLaptopController* controller;
void ReadConfiguration();
void ControllerSetMode(bool save);
};