Add basic support for Asus TUF laptop keyboards through Faustus
This commit is contained in:
parent
d28be0640e
commit
a4474602d8
5 changed files with 196 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
*.pro.user*
|
||||
|
|
@ -336,6 +336,7 @@ void DetectMSI3ZoneControllers(std::vector<RGBController*>& rgb_controllers);
|
|||
void DetectPoseidonZRGBControllers(std::vector<RGBController*>& rgb_controllers);
|
||||
void DetectCorsairCmdrProControllers(std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectCorsairNodeProControllers(std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectFaustusControllers(std::vector<RGBController*> &rgb_controllers);
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
|
|
@ -381,6 +382,7 @@ void DetectRGBControllers(void)
|
|||
\*-------------------------------------*/
|
||||
#else
|
||||
DetectOpenRazerControllers(rgb_controllers);
|
||||
DetectFaustusControllers(rgb_controllers);
|
||||
#endif
|
||||
|
||||
} /* DetectRGBControllers() */
|
||||
|
|
|
|||
|
|
@ -199,6 +199,7 @@ unix:INCLUDEPATH += \
|
|||
|
||||
unix:HEADERS += \
|
||||
i2c_smbus/i2c_smbus_linux.h \
|
||||
RGBController/RGBController_Faustus.h \
|
||||
|
||||
unix:LIBS += \
|
||||
-lusb-1.0 \
|
||||
|
|
@ -218,4 +219,5 @@ unix:SOURCES += \
|
|||
i2c_smbus/i2c_smbus_linux.cpp \
|
||||
serial_port/find_usb_serial_port_linux.cpp \
|
||||
RGBController/OpenRazerDetect.cpp \
|
||||
RGBController/RGBController_Faustus.cpp \
|
||||
RGBController/RGBController_OpenRazer.cpp \
|
||||
|
|
|
|||
150
RGBController/RGBController_Faustus.cpp
Normal file
150
RGBController/RGBController_Faustus.cpp
Normal file
|
|
@ -0,0 +1,150 @@
|
|||
#include "RGBController_Faustus.h"
|
||||
|
||||
#include <dirent.h>
|
||||
#include <string.h>
|
||||
|
||||
RGBController_Faustus::RGBController_Faustus(const std::string& dev_path)
|
||||
{
|
||||
name = "Faustus";
|
||||
description = "ASUS TUF Keyboard Backlight";
|
||||
type = DEVICE_TYPE_KEYBOARD;
|
||||
|
||||
modes.resize(4);
|
||||
modes[0].name = "Static";
|
||||
modes[0].value = FAUSTUS_MODE_STATIC;
|
||||
modes[0].flags = MODE_FLAG_HAS_COLOR;
|
||||
modes[0].random = false;
|
||||
|
||||
modes[1].name = "Breathing";
|
||||
modes[1].value = FAUSTUS_MODE_BREATHING;
|
||||
modes[1].flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_COLOR;
|
||||
modes[1].speed_min = FAUSTUS_SPEED_SLOWEST;
|
||||
modes[1].speed_max = FAUSTUS_SPEED_FASTEST;
|
||||
modes[1].random = false;
|
||||
modes[1].speed = FAUSTUS_SPEED_NORMAL;
|
||||
|
||||
modes[2].name = "Color Cycle";
|
||||
modes[2].value = FAUSTUS_MODE_COLOR_CYCLE;
|
||||
modes[2].flags = MODE_FLAG_HAS_SPEED;
|
||||
modes[2].speed_min = FAUSTUS_SPEED_SLOWEST;
|
||||
modes[2].speed_max = FAUSTUS_SPEED_FASTEST;
|
||||
modes[2].random = false;
|
||||
modes[2].speed = FAUSTUS_SPEED_NORMAL;
|
||||
|
||||
modes[3].name = "Strobe";
|
||||
modes[3].value = FAUSTUS_MODE_STROBE;
|
||||
modes[3].flags = MODE_FLAG_HAS_SPEED;
|
||||
modes[3].speed_min = FAUSTUS_SPEED_SLOWEST;
|
||||
modes[3].speed_max = FAUSTUS_SPEED_FASTEST;
|
||||
modes[3].random = false;
|
||||
modes[3].speed = FAUSTUS_SPEED_NORMAL;
|
||||
|
||||
colors.resize(1);
|
||||
leds.resize(1);
|
||||
leds[0].name = "Keyboard backlight LED";
|
||||
zones.resize(1);
|
||||
zones[0].type = ZONE_TYPE_SINGLE;
|
||||
zones[0].name = "Keyboard backlight zone";
|
||||
zones[0].map.push_back(std::vector<int>(1, 0));
|
||||
|
||||
// Prepare file streams
|
||||
r_path = dev_path;
|
||||
g_path = dev_path;
|
||||
b_path = dev_path;
|
||||
mode_path = dev_path;
|
||||
flags_path = dev_path;
|
||||
set_path = dev_path;
|
||||
|
||||
r_path.append("/kbbl_red");
|
||||
g_path.append("/kbbl_green");
|
||||
b_path.append("/kbbl_blue");
|
||||
mode_path.append("/kbbl_mode");
|
||||
flags_path.append("/kbbl_flags");
|
||||
set_path.append("/kbbl_set");
|
||||
}
|
||||
|
||||
void RGBController_Faustus::UpdateLEDs()
|
||||
{
|
||||
int rv = uint8_t(RGBGetRValue(colors[0]));
|
||||
int gv = uint8_t(RGBGetGValue(colors[0]));
|
||||
int bv = uint8_t(RGBGetBValue(colors[0]));
|
||||
|
||||
std::ofstream str_r;
|
||||
std::ofstream str_g;
|
||||
std::ofstream str_b;
|
||||
std::ofstream str_mode;
|
||||
std::ofstream str_flags;
|
||||
std::ofstream str_set;
|
||||
|
||||
str_r.open(r_path, std::ios::out | std::ios::trunc);
|
||||
str_g.open(g_path, std::ios::out | std::ios::trunc);
|
||||
str_b.open(b_path, std::ios::out | std::ios::trunc);
|
||||
str_mode.open(mode_path, std::ios::out | std::ios::trunc);
|
||||
str_flags.open(flags_path, std::ios::out | std::ios::trunc);
|
||||
str_set.open(set_path, std::ios::out | std::ios::trunc);
|
||||
|
||||
str_r << std::hex;
|
||||
str_g << std::hex;
|
||||
str_b << std::hex;
|
||||
str_mode << std::hex;
|
||||
str_flags << std::hex;
|
||||
str_set << std::hex;
|
||||
|
||||
str_r << rv;
|
||||
str_g << gv;
|
||||
str_b << bv;
|
||||
str_mode << active_mode;
|
||||
str_flags << 0x2a; // All of em
|
||||
str_set << 2;
|
||||
|
||||
// Flush everything
|
||||
str_r.close();
|
||||
str_g.close();
|
||||
str_b.close();
|
||||
str_mode.close();
|
||||
str_flags.close();
|
||||
str_set.close();
|
||||
}
|
||||
|
||||
void RGBController_Faustus::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
UpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_Faustus::UpdateSingleLED(int led)
|
||||
{
|
||||
UpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_Faustus::SetCustomMode()
|
||||
{
|
||||
SetMode(0);
|
||||
}
|
||||
|
||||
void RGBController_Faustus::UpdateMode()
|
||||
{
|
||||
UpdateLEDs();
|
||||
}
|
||||
|
||||
void DetectFaustusControllers(std::vector<RGBController*> &rgb_controllers)
|
||||
{
|
||||
const char* base_path = "/sys/devices/platform/faustus/kbbl";
|
||||
DIR* dir = opendir(base_path);
|
||||
if(!dir) return;
|
||||
// Directory is present - we pretty much have a driver confirmation already, but double check for all files required just in case
|
||||
struct dirent* dent = readdir(dir);
|
||||
if(!dent) return;
|
||||
int found = 0;
|
||||
while(dent)
|
||||
{
|
||||
const char* fname = dent->d_name;
|
||||
if(!strcmp(fname, "kbbl_red") || !strcmp(fname, "kbbl_green") || !strcmp(fname, "kbbl_blue") || !strcmp(fname, "kbbl_mode") || !strcmp(fname, "kbbl_flags") || !strcmp(fname, "kbbl_set"))
|
||||
{
|
||||
++found;
|
||||
}
|
||||
dent = readdir(dir);
|
||||
}
|
||||
closedir(dir);
|
||||
if(found != 6) return;
|
||||
rgb_controllers.push_back(new RGBController_Faustus(base_path));
|
||||
}
|
||||
41
RGBController/RGBController_Faustus.h
Normal file
41
RGBController/RGBController_Faustus.h
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
#ifndef RGBCONTROLLER_FAUSTUS_H
|
||||
#define RGBCONTROLLER_FAUSTUS_H
|
||||
|
||||
#include "RGBController.h"
|
||||
#include <fstream>
|
||||
|
||||
enum
|
||||
{
|
||||
FAUSTUS_MODE_STATIC = 0,
|
||||
FAUSTUS_MODE_BREATHING = 1,
|
||||
FAUSTUS_MODE_COLOR_CYCLE = 2,
|
||||
FAUSTUS_MODE_STROBE = 3
|
||||
};
|
||||
enum
|
||||
{
|
||||
FAUSTUS_SPEED_SLOWEST = 0,
|
||||
FAUSTUS_SPEED_NORMAL = 1,
|
||||
FAUSTUS_SPEED_FASTEST = 2,
|
||||
};
|
||||
|
||||
class RGBController_Faustus : public RGBController
|
||||
{
|
||||
private:
|
||||
std::string r_path;
|
||||
std::string g_path;
|
||||
std::string b_path;
|
||||
std::string mode_path;
|
||||
std::string flags_path;
|
||||
std::string set_path;
|
||||
|
||||
public:
|
||||
RGBController_Faustus(const std::string& dev_path);
|
||||
void UpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void UpdateMode();
|
||||
};
|
||||
|
||||
#endif // RGBCONTROLLER_FAUSTUS_H
|
||||
Loading…
Add table
Add a link
Reference in a new issue