Publish curated LumaOps source from c85ee9ef8f1454f5c305398902afbb9e6738de40
Managed validation / full (push) Failing after 8s
Managed validation / full (push) Failing after 8s
This commit is contained in:
1 parent
91f8b3e3c1
commit
def7920856
2271 files changed
+501225
-501178
No files matched your search
@@ -1,292 +1,292 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| QMKOpenRGBBaseController.cpp |
|
||||
| |
|
||||
| Common Driver for OpenRGB QMK Keyboard Protocol |
|
||||
| |
|
||||
| ChrisM 20 Dec 2023 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "LogManager.h"
|
||||
#include "RGBControllerKeyNames.h"
|
||||
#include "SettingsManager.h"
|
||||
#include "QMKOpenRGBBaseController.h"
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
QMKOpenRGBBaseController::QMKOpenRGBBaseController(hid_device *dev_handle, const char *path, unsigned char max_led_count)
|
||||
{
|
||||
/*-------------------------------------------------*\
|
||||
| Get QMKOpenRGB settings |
|
||||
\*-------------------------------------------------*/
|
||||
json qmk_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("QMKOpenRGBDevices");
|
||||
if(qmk_settings.contains("leds_per_update"))
|
||||
{
|
||||
if(qmk_settings["leds_per_update"] > max_led_count)
|
||||
{
|
||||
qmk_settings["leds_per_update"] = max_led_count;
|
||||
}
|
||||
else if(qmk_settings["leds_per_update"] < 1)
|
||||
{
|
||||
qmk_settings["leds_per_update"] = 1;
|
||||
}
|
||||
SettingsManager* settings_manager = ResourceManager::get()->GetSettingsManager();
|
||||
settings_manager->SetSettings("QMKOpenRGBDevices", qmk_settings);
|
||||
settings_manager->SaveSettings();
|
||||
leds_per_update = qmk_settings["leds_per_update"];
|
||||
}
|
||||
else
|
||||
{
|
||||
leds_per_update = max_led_count;
|
||||
}
|
||||
|
||||
if(qmk_settings.contains("delay"))
|
||||
{
|
||||
delay = (unsigned int)qmk_settings["delay"] * 1ms;
|
||||
}
|
||||
else
|
||||
{
|
||||
delay = 0ms;
|
||||
}
|
||||
|
||||
dev = dev_handle;
|
||||
location = path;
|
||||
|
||||
GetDeviceInfo();
|
||||
GetModeInfo();
|
||||
}
|
||||
|
||||
QMKOpenRGBBaseController::~QMKOpenRGBBaseController()
|
||||
{
|
||||
hid_close(dev);
|
||||
}
|
||||
|
||||
std::string QMKOpenRGBBaseController::GetLocation()
|
||||
{
|
||||
return("HID: " + location);
|
||||
}
|
||||
|
||||
std::string QMKOpenRGBBaseController::GetDeviceName()
|
||||
{
|
||||
return device_name;
|
||||
}
|
||||
|
||||
std::string QMKOpenRGBBaseController::GetDeviceVendor()
|
||||
{
|
||||
return device_vendor;
|
||||
}
|
||||
|
||||
unsigned int QMKOpenRGBBaseController::GetTotalNumberOfLEDs()
|
||||
{
|
||||
return total_number_of_leds;
|
||||
}
|
||||
|
||||
unsigned int QMKOpenRGBBaseController::GetTotalNumberOfLEDsWithEmptySpace()
|
||||
{
|
||||
return total_number_of_leds_with_empty_space;
|
||||
}
|
||||
|
||||
unsigned int QMKOpenRGBBaseController::GetMode()
|
||||
{
|
||||
return mode;
|
||||
}
|
||||
|
||||
unsigned int QMKOpenRGBBaseController::GetModeSpeed()
|
||||
{
|
||||
return mode_speed;
|
||||
}
|
||||
|
||||
unsigned int QMKOpenRGBBaseController::GetModeColor()
|
||||
{
|
||||
return mode_color;
|
||||
}
|
||||
|
||||
std::vector<point_t> QMKOpenRGBBaseController::GetLEDPoints()
|
||||
{
|
||||
return led_points;
|
||||
}
|
||||
|
||||
std::vector<unsigned int> QMKOpenRGBBaseController::GetLEDFlags()
|
||||
{
|
||||
return led_flags;
|
||||
}
|
||||
|
||||
std::vector<std::string> QMKOpenRGBBaseController::GetLEDNames()
|
||||
{
|
||||
return led_names;
|
||||
}
|
||||
|
||||
std::vector<RGBColor> QMKOpenRGBBaseController::GetLEDColors()
|
||||
{
|
||||
return led_colors;
|
||||
}
|
||||
|
||||
unsigned int QMKOpenRGBBaseController::GetProtocolVersion()
|
||||
{
|
||||
unsigned char usb_buf[QMK_OPENRGB_PACKET_SIZE];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, QMK_OPENRGB_PACKET_SIZE);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up config table request packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x00;
|
||||
usb_buf[0x01] = QMK_OPENRGB_GET_PROTOCOL_VERSION;
|
||||
|
||||
int bytes_read = 0;
|
||||
do
|
||||
{
|
||||
hid_write(dev, usb_buf, QMK_OPENRGB_PACKET_SIZE);
|
||||
bytes_read = hid_read_timeout(dev, usb_buf, QMK_OPENRGB_PACKET_SIZE, QMK_OPENRGB_HID_READ_TIMEOUT);
|
||||
} while(bytes_read <= 0);
|
||||
|
||||
return usb_buf[1];
|
||||
}
|
||||
|
||||
std::string QMKOpenRGBBaseController::GetQMKVersion()
|
||||
{
|
||||
unsigned char usb_buf[QMK_OPENRGB_PACKET_SIZE];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, QMK_OPENRGB_PACKET_SIZE);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up config table request packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x00;
|
||||
usb_buf[0x01] = QMK_OPENRGB_GET_QMK_VERSION;
|
||||
|
||||
hid_write(dev, usb_buf, QMK_OPENRGB_PACKET_SIZE);
|
||||
hid_read(dev, usb_buf, QMK_OPENRGB_PACKET_SIZE);
|
||||
|
||||
std::string qmk_version;
|
||||
int i = 1;
|
||||
while (usb_buf[i] != 0)
|
||||
{
|
||||
qmk_version.push_back(usb_buf[i]);
|
||||
i++;
|
||||
}
|
||||
|
||||
return qmk_version;
|
||||
}
|
||||
|
||||
void QMKOpenRGBBaseController::GetDeviceInfo()
|
||||
{
|
||||
unsigned char usb_buf[QMK_OPENRGB_PACKET_SIZE];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, QMK_OPENRGB_PACKET_SIZE);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up config table request packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x00;
|
||||
usb_buf[0x01] = QMK_OPENRGB_GET_DEVICE_INFO;
|
||||
|
||||
int bytes_read = 0;
|
||||
do
|
||||
{
|
||||
hid_write(dev, usb_buf, QMK_OPENRGB_PACKET_SIZE);
|
||||
bytes_read = hid_read_timeout(dev, usb_buf, QMK_OPENRGB_PACKET_SIZE, QMK_OPENRGB_HID_READ_TIMEOUT);
|
||||
} while(bytes_read <= 0);
|
||||
|
||||
total_number_of_leds = usb_buf[QMK_OPENRGB_TOTAL_NUMBER_OF_LEDS_BYTE];
|
||||
total_number_of_leds_with_empty_space = usb_buf[QMK_OPENRGB_TOTAL_NUMBER_OF_LEDS_WITH_EMPTY_SPACE_BYTE];
|
||||
|
||||
int i = QMK_OPENRGB_TOTAL_NUMBER_OF_LEDS_WITH_EMPTY_SPACE_BYTE + 1;
|
||||
while (usb_buf[i] != 0)
|
||||
{
|
||||
device_name.push_back(usb_buf[i]);
|
||||
i++;
|
||||
}
|
||||
|
||||
i++;
|
||||
while (usb_buf[i] != 0)
|
||||
{
|
||||
device_vendor.push_back(usb_buf[i]);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
void QMKOpenRGBBaseController::GetModeInfo()
|
||||
{
|
||||
unsigned char usb_buf[QMK_OPENRGB_PACKET_SIZE];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, QMK_OPENRGB_PACKET_SIZE);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up config table request packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x00;
|
||||
usb_buf[0x01] = QMK_OPENRGB_GET_MODE_INFO;
|
||||
|
||||
int bytes_read = 0;
|
||||
do
|
||||
{
|
||||
hid_write(dev, usb_buf, 65);
|
||||
bytes_read = hid_read_timeout(dev, usb_buf, 65, QMK_OPENRGB_HID_READ_TIMEOUT);
|
||||
} while(bytes_read <= 0);
|
||||
|
||||
mode = usb_buf[QMK_OPENRGB_MODE_BYTE];
|
||||
mode_speed = usb_buf[QMK_OPENRGB_SPEED_BYTE];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| QMK hue range is between 0-255 so hue needs to be |
|
||||
| converted |
|
||||
\*-----------------------------------------------------*/
|
||||
unsigned int oldRange = 255;
|
||||
unsigned int newRange = 359;
|
||||
unsigned int convertedHue = (usb_buf[QMK_OPENRGB_HUE_BYTE] * newRange / oldRange);
|
||||
|
||||
hsv_t hsv;
|
||||
hsv.hue = convertedHue;
|
||||
hsv.saturation = usb_buf[QMK_OPENRGB_SATURATION_BYTE];
|
||||
hsv.value = usb_buf[QMK_OPENRGB_VALUE_BYTE];
|
||||
|
||||
mode_color = hsv2rgb(&hsv);
|
||||
}
|
||||
|
||||
void QMKOpenRGBBaseController::SetMode(hsv_t hsv_color, unsigned char mode, unsigned char speed)
|
||||
{
|
||||
SetMode(hsv_color, mode, speed, false);
|
||||
}
|
||||
|
||||
void QMKOpenRGBBaseController::SetMode(hsv_t hsv_color, unsigned char mode, unsigned char speed, bool save)
|
||||
{
|
||||
unsigned char usb_buf[QMK_OPENRGB_PACKET_SIZE];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, QMK_OPENRGB_PACKET_SIZE);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up config table request packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x00;
|
||||
usb_buf[0x01] = QMK_OPENRGB_SET_MODE;
|
||||
usb_buf[0x02] = hsv_color.hue * 255 / 359;
|
||||
usb_buf[0x03] = hsv_color.saturation;
|
||||
usb_buf[0x04] = hsv_color.value;
|
||||
usb_buf[0x05] = mode;
|
||||
usb_buf[0x06] = speed;
|
||||
usb_buf[0x07] = save;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 65);
|
||||
hid_read_timeout(dev, usb_buf, 65, QMK_OPENRGB_HID_READ_TIMEOUT);
|
||||
}
|
||||
/*---------------------------------------------------------*\
|
||||
| QMKOpenRGBBaseController.cpp |
|
||||
| |
|
||||
| Common Driver for OpenRGB QMK Keyboard Protocol |
|
||||
| |
|
||||
| ChrisM 20 Dec 2023 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "LogManager.h"
|
||||
#include "RGBControllerKeyNames.h"
|
||||
#include "SettingsManager.h"
|
||||
#include "QMKOpenRGBBaseController.h"
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
QMKOpenRGBBaseController::QMKOpenRGBBaseController(hid_device *dev_handle, const char *path, unsigned char max_led_count)
|
||||
{
|
||||
/*-------------------------------------------------*\
|
||||
| Get QMKOpenRGB settings |
|
||||
\*-------------------------------------------------*/
|
||||
json qmk_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("QMKOpenRGBDevices");
|
||||
if(qmk_settings.contains("leds_per_update"))
|
||||
{
|
||||
if(qmk_settings["leds_per_update"] > max_led_count)
|
||||
{
|
||||
qmk_settings["leds_per_update"] = max_led_count;
|
||||
}
|
||||
else if(qmk_settings["leds_per_update"] < 1)
|
||||
{
|
||||
qmk_settings["leds_per_update"] = 1;
|
||||
}
|
||||
SettingsManager* settings_manager = ResourceManager::get()->GetSettingsManager();
|
||||
settings_manager->SetSettings("QMKOpenRGBDevices", qmk_settings);
|
||||
settings_manager->SaveSettings();
|
||||
leds_per_update = qmk_settings["leds_per_update"];
|
||||
}
|
||||
else
|
||||
{
|
||||
leds_per_update = max_led_count;
|
||||
}
|
||||
|
||||
if(qmk_settings.contains("delay"))
|
||||
{
|
||||
delay = (unsigned int)qmk_settings["delay"] * 1ms;
|
||||
}
|
||||
else
|
||||
{
|
||||
delay = 0ms;
|
||||
}
|
||||
|
||||
dev = dev_handle;
|
||||
location = path;
|
||||
|
||||
GetDeviceInfo();
|
||||
GetModeInfo();
|
||||
}
|
||||
|
||||
QMKOpenRGBBaseController::~QMKOpenRGBBaseController()
|
||||
{
|
||||
hid_close(dev);
|
||||
}
|
||||
|
||||
std::string QMKOpenRGBBaseController::GetLocation()
|
||||
{
|
||||
return("HID: " + location);
|
||||
}
|
||||
|
||||
std::string QMKOpenRGBBaseController::GetDeviceName()
|
||||
{
|
||||
return device_name;
|
||||
}
|
||||
|
||||
std::string QMKOpenRGBBaseController::GetDeviceVendor()
|
||||
{
|
||||
return device_vendor;
|
||||
}
|
||||
|
||||
unsigned int QMKOpenRGBBaseController::GetTotalNumberOfLEDs()
|
||||
{
|
||||
return total_number_of_leds;
|
||||
}
|
||||
|
||||
unsigned int QMKOpenRGBBaseController::GetTotalNumberOfLEDsWithEmptySpace()
|
||||
{
|
||||
return total_number_of_leds_with_empty_space;
|
||||
}
|
||||
|
||||
unsigned int QMKOpenRGBBaseController::GetMode()
|
||||
{
|
||||
return mode;
|
||||
}
|
||||
|
||||
unsigned int QMKOpenRGBBaseController::GetModeSpeed()
|
||||
{
|
||||
return mode_speed;
|
||||
}
|
||||
|
||||
unsigned int QMKOpenRGBBaseController::GetModeColor()
|
||||
{
|
||||
return mode_color;
|
||||
}
|
||||
|
||||
std::vector<point_t> QMKOpenRGBBaseController::GetLEDPoints()
|
||||
{
|
||||
return led_points;
|
||||
}
|
||||
|
||||
std::vector<unsigned int> QMKOpenRGBBaseController::GetLEDFlags()
|
||||
{
|
||||
return led_flags;
|
||||
}
|
||||
|
||||
std::vector<std::string> QMKOpenRGBBaseController::GetLEDNames()
|
||||
{
|
||||
return led_names;
|
||||
}
|
||||
|
||||
std::vector<RGBColor> QMKOpenRGBBaseController::GetLEDColors()
|
||||
{
|
||||
return led_colors;
|
||||
}
|
||||
|
||||
unsigned int QMKOpenRGBBaseController::GetProtocolVersion()
|
||||
{
|
||||
unsigned char usb_buf[QMK_OPENRGB_PACKET_SIZE];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, QMK_OPENRGB_PACKET_SIZE);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up config table request packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x00;
|
||||
usb_buf[0x01] = QMK_OPENRGB_GET_PROTOCOL_VERSION;
|
||||
|
||||
int bytes_read = 0;
|
||||
do
|
||||
{
|
||||
hid_write(dev, usb_buf, QMK_OPENRGB_PACKET_SIZE);
|
||||
bytes_read = hid_read_timeout(dev, usb_buf, QMK_OPENRGB_PACKET_SIZE, QMK_OPENRGB_HID_READ_TIMEOUT);
|
||||
} while(bytes_read <= 0);
|
||||
|
||||
return usb_buf[1];
|
||||
}
|
||||
|
||||
std::string QMKOpenRGBBaseController::GetQMKVersion()
|
||||
{
|
||||
unsigned char usb_buf[QMK_OPENRGB_PACKET_SIZE];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, QMK_OPENRGB_PACKET_SIZE);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up config table request packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x00;
|
||||
usb_buf[0x01] = QMK_OPENRGB_GET_QMK_VERSION;
|
||||
|
||||
hid_write(dev, usb_buf, QMK_OPENRGB_PACKET_SIZE);
|
||||
hid_read(dev, usb_buf, QMK_OPENRGB_PACKET_SIZE);
|
||||
|
||||
std::string qmk_version;
|
||||
int i = 1;
|
||||
while (usb_buf[i] != 0)
|
||||
{
|
||||
qmk_version.push_back(usb_buf[i]);
|
||||
i++;
|
||||
}
|
||||
|
||||
return qmk_version;
|
||||
}
|
||||
|
||||
void QMKOpenRGBBaseController::GetDeviceInfo()
|
||||
{
|
||||
unsigned char usb_buf[QMK_OPENRGB_PACKET_SIZE];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, QMK_OPENRGB_PACKET_SIZE);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up config table request packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x00;
|
||||
usb_buf[0x01] = QMK_OPENRGB_GET_DEVICE_INFO;
|
||||
|
||||
int bytes_read = 0;
|
||||
do
|
||||
{
|
||||
hid_write(dev, usb_buf, QMK_OPENRGB_PACKET_SIZE);
|
||||
bytes_read = hid_read_timeout(dev, usb_buf, QMK_OPENRGB_PACKET_SIZE, QMK_OPENRGB_HID_READ_TIMEOUT);
|
||||
} while(bytes_read <= 0);
|
||||
|
||||
total_number_of_leds = usb_buf[QMK_OPENRGB_TOTAL_NUMBER_OF_LEDS_BYTE];
|
||||
total_number_of_leds_with_empty_space = usb_buf[QMK_OPENRGB_TOTAL_NUMBER_OF_LEDS_WITH_EMPTY_SPACE_BYTE];
|
||||
|
||||
int i = QMK_OPENRGB_TOTAL_NUMBER_OF_LEDS_WITH_EMPTY_SPACE_BYTE + 1;
|
||||
while (usb_buf[i] != 0)
|
||||
{
|
||||
device_name.push_back(usb_buf[i]);
|
||||
i++;
|
||||
}
|
||||
|
||||
i++;
|
||||
while (usb_buf[i] != 0)
|
||||
{
|
||||
device_vendor.push_back(usb_buf[i]);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
void QMKOpenRGBBaseController::GetModeInfo()
|
||||
{
|
||||
unsigned char usb_buf[QMK_OPENRGB_PACKET_SIZE];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, QMK_OPENRGB_PACKET_SIZE);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up config table request packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x00;
|
||||
usb_buf[0x01] = QMK_OPENRGB_GET_MODE_INFO;
|
||||
|
||||
int bytes_read = 0;
|
||||
do
|
||||
{
|
||||
hid_write(dev, usb_buf, 65);
|
||||
bytes_read = hid_read_timeout(dev, usb_buf, 65, QMK_OPENRGB_HID_READ_TIMEOUT);
|
||||
} while(bytes_read <= 0);
|
||||
|
||||
mode = usb_buf[QMK_OPENRGB_MODE_BYTE];
|
||||
mode_speed = usb_buf[QMK_OPENRGB_SPEED_BYTE];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| QMK hue range is between 0-255 so hue needs to be |
|
||||
| converted |
|
||||
\*-----------------------------------------------------*/
|
||||
unsigned int oldRange = 255;
|
||||
unsigned int newRange = 359;
|
||||
unsigned int convertedHue = (usb_buf[QMK_OPENRGB_HUE_BYTE] * newRange / oldRange);
|
||||
|
||||
hsv_t hsv;
|
||||
hsv.hue = convertedHue;
|
||||
hsv.saturation = usb_buf[QMK_OPENRGB_SATURATION_BYTE];
|
||||
hsv.value = usb_buf[QMK_OPENRGB_VALUE_BYTE];
|
||||
|
||||
mode_color = hsv2rgb(&hsv);
|
||||
}
|
||||
|
||||
void QMKOpenRGBBaseController::SetMode(hsv_t hsv_color, unsigned char mode, unsigned char speed)
|
||||
{
|
||||
SetMode(hsv_color, mode, speed, false);
|
||||
}
|
||||
|
||||
void QMKOpenRGBBaseController::SetMode(hsv_t hsv_color, unsigned char mode, unsigned char speed, bool save)
|
||||
{
|
||||
unsigned char usb_buf[QMK_OPENRGB_PACKET_SIZE];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, QMK_OPENRGB_PACKET_SIZE);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up config table request packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x00;
|
||||
usb_buf[0x01] = QMK_OPENRGB_SET_MODE;
|
||||
usb_buf[0x02] = hsv_color.hue * 255 / 359;
|
||||
usb_buf[0x03] = hsv_color.saturation;
|
||||
usb_buf[0x04] = hsv_color.value;
|
||||
usb_buf[0x05] = mode;
|
||||
usb_buf[0x06] = speed;
|
||||
usb_buf[0x07] = save;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 65);
|
||||
hid_read_timeout(dev, usb_buf, 65, QMK_OPENRGB_HID_READ_TIMEOUT);
|
||||
}
|
||||
@@ -1,78 +1,78 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| QMKOpenRGBBaseController.h |
|
||||
| |
|
||||
| Common Driver for OpenRGB QMK Keyboard Protocol |
|
||||
| |
|
||||
| ChrisM 20 Dec 2023 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "LogManager.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBControllerKeyNames.h"
|
||||
#include "SettingsManager.h"
|
||||
#include "QMKOpenRGBController.h"
|
||||
|
||||
class QMKOpenRGBBaseController
|
||||
{
|
||||
public:
|
||||
QMKOpenRGBBaseController(hid_device *dev_handle, const char *path, unsigned char max_led_count);
|
||||
virtual ~QMKOpenRGBBaseController();
|
||||
|
||||
std::string GetLocation();
|
||||
std::string GetDeviceName();
|
||||
std::string GetDeviceVendor();
|
||||
|
||||
unsigned int GetTotalNumberOfLEDs();
|
||||
unsigned int GetTotalNumberOfLEDsWithEmptySpace();
|
||||
unsigned int GetMode();
|
||||
unsigned int GetModeSpeed();
|
||||
unsigned int GetModeColor();
|
||||
|
||||
std::vector<point_t> GetLEDPoints();
|
||||
std::vector<unsigned int> GetLEDFlags();
|
||||
std::vector<std::string> GetLEDNames();
|
||||
std::vector<RGBColor> GetLEDColors();
|
||||
|
||||
unsigned int GetProtocolVersion();
|
||||
std::string GetQMKVersion();
|
||||
void GetDeviceInfo();
|
||||
void GetModeInfo();
|
||||
|
||||
void SetMode(hsv_t hsv_color, unsigned char mode, unsigned char speed);
|
||||
void SetMode(hsv_t hsv_color, unsigned char mode, unsigned char speed, bool save);
|
||||
|
||||
virtual void GetLEDInfo(unsigned int leds_count) = 0;
|
||||
virtual void DirectModeSetSingleLED(unsigned int led, unsigned char red, unsigned char green, unsigned char blue) = 0;
|
||||
virtual void DirectModeSetLEDs(std::vector<RGBColor> colors, unsigned int leds_count) = 0;
|
||||
|
||||
protected:
|
||||
hid_device *dev;
|
||||
|
||||
unsigned int leds_per_update;
|
||||
|
||||
std::string location;
|
||||
|
||||
std::string device_name;
|
||||
std::string device_vendor;
|
||||
|
||||
std::chrono::milliseconds delay;
|
||||
|
||||
unsigned int total_number_of_leds;
|
||||
unsigned int total_number_of_leds_with_empty_space;
|
||||
unsigned int mode;
|
||||
unsigned int mode_speed;
|
||||
|
||||
RGBColor mode_color;
|
||||
|
||||
std::vector<point_t> led_points;
|
||||
std::vector<unsigned int> led_flags;
|
||||
std::vector<std::string> led_names;
|
||||
std::vector<RGBColor> led_colors;
|
||||
|
||||
private:
|
||||
};
|
||||
/*---------------------------------------------------------*\
|
||||
| QMKOpenRGBBaseController.h |
|
||||
| |
|
||||
| Common Driver for OpenRGB QMK Keyboard Protocol |
|
||||
| |
|
||||
| ChrisM 20 Dec 2023 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "LogManager.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBControllerKeyNames.h"
|
||||
#include "SettingsManager.h"
|
||||
#include "QMKOpenRGBController.h"
|
||||
|
||||
class QMKOpenRGBBaseController
|
||||
{
|
||||
public:
|
||||
QMKOpenRGBBaseController(hid_device *dev_handle, const char *path, unsigned char max_led_count);
|
||||
virtual ~QMKOpenRGBBaseController();
|
||||
|
||||
std::string GetLocation();
|
||||
std::string GetDeviceName();
|
||||
std::string GetDeviceVendor();
|
||||
|
||||
unsigned int GetTotalNumberOfLEDs();
|
||||
unsigned int GetTotalNumberOfLEDsWithEmptySpace();
|
||||
unsigned int GetMode();
|
||||
unsigned int GetModeSpeed();
|
||||
unsigned int GetModeColor();
|
||||
|
||||
std::vector<point_t> GetLEDPoints();
|
||||
std::vector<unsigned int> GetLEDFlags();
|
||||
std::vector<std::string> GetLEDNames();
|
||||
std::vector<RGBColor> GetLEDColors();
|
||||
|
||||
unsigned int GetProtocolVersion();
|
||||
std::string GetQMKVersion();
|
||||
void GetDeviceInfo();
|
||||
void GetModeInfo();
|
||||
|
||||
void SetMode(hsv_t hsv_color, unsigned char mode, unsigned char speed);
|
||||
void SetMode(hsv_t hsv_color, unsigned char mode, unsigned char speed, bool save);
|
||||
|
||||
virtual void GetLEDInfo(unsigned int leds_count) = 0;
|
||||
virtual void DirectModeSetSingleLED(unsigned int led, unsigned char red, unsigned char green, unsigned char blue) = 0;
|
||||
virtual void DirectModeSetLEDs(std::vector<RGBColor> colors, unsigned int leds_count) = 0;
|
||||
|
||||
protected:
|
||||
hid_device *dev;
|
||||
|
||||
unsigned int leds_per_update;
|
||||
|
||||
std::string location;
|
||||
|
||||
std::string device_name;
|
||||
std::string device_vendor;
|
||||
|
||||
std::chrono::milliseconds delay;
|
||||
|
||||
unsigned int total_number_of_leds;
|
||||
unsigned int total_number_of_leds_with_empty_space;
|
||||
unsigned int mode;
|
||||
unsigned int mode_speed;
|
||||
|
||||
RGBColor mode_color;
|
||||
|
||||
std::vector<point_t> led_points;
|
||||
std::vector<unsigned int> led_flags;
|
||||
std::vector<std::string> led_names;
|
||||
std::vector<RGBColor> led_colors;
|
||||
|
||||
private:
|
||||
};
|
||||
@@ -1,133 +1,133 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| QMKOpenRGBController.h |
|
||||
| |
|
||||
| Driver for OpenRGB QMK Keyboard Protocol |
|
||||
| |
|
||||
| Kasper 10 Oct 2020 |
|
||||
| Jath03 28 May 2021 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstring>
|
||||
#include <map>
|
||||
#include <hidapi.h>
|
||||
#include "ResourceManager.h"
|
||||
#include "RGBController.h"
|
||||
#include "hsv.h"
|
||||
|
||||
#define QMK_OPENRGB_PACKET_SIZE 65
|
||||
#define QMK_OPENRGB_HID_READ_TIMEOUT 50
|
||||
|
||||
enum CommandsId
|
||||
{
|
||||
QMK_OPENRGB_GET_PROTOCOL_VERSION = 1,
|
||||
QMK_OPENRGB_GET_QMK_VERSION,
|
||||
QMK_OPENRGB_GET_DEVICE_INFO,
|
||||
QMK_OPENRGB_GET_MODE_INFO,
|
||||
QMK_OPENRGB_GET_LED_INFO,
|
||||
QMK_OPENRGB_GET_IS_MODE_ENABLED,
|
||||
QMK_OPENRGB_GET_ENABLED_MODES = QMK_OPENRGB_GET_IS_MODE_ENABLED,
|
||||
|
||||
QMK_OPENRGB_SET_MODE,
|
||||
QMK_OPENRGB_DIRECT_MODE_SET_SINGLE_LED,
|
||||
QMK_OPENRGB_DIRECT_MODE_SET_LEDS,
|
||||
};
|
||||
|
||||
enum Modes
|
||||
{
|
||||
QMK_OPENRGB_MODE_OPENRGB_DIRECT = 1,
|
||||
QMK_OPENRGB_MODE_SOLID_COLOR,
|
||||
QMK_OPENRGB_MODE_ALPHA_MOD,
|
||||
QMK_OPENRGB_MODE_GRADIENT_UP_DOWN,
|
||||
QMK_OPENRGB_MODE_GRADIENT_LEFT_RIGHT,
|
||||
QMK_OPENRGB_MODE_BREATHING,
|
||||
QMK_OPENRGB_MODE_BAND_SAT,
|
||||
QMK_OPENRGB_MODE_BAND_VAL,
|
||||
QMK_OPENRGB_MODE_BAND_PINWHEEL_SAT,
|
||||
QMK_OPENRGB_MODE_BAND_PINWHEEL_VAL,
|
||||
QMK_OPENRGB_MODE_BAND_SPIRAL_SAT,
|
||||
QMK_OPENRGB_MODE_BAND_SPIRAL_VAL,
|
||||
QMK_OPENRGB_MODE_CYCLE_ALL,
|
||||
QMK_OPENRGB_MODE_CYCLE_LEFT_RIGHT,
|
||||
QMK_OPENRGB_MODE_CYCLE_UP_DOWN,
|
||||
QMK_OPENRGB_MODE_CYCLE_OUT_IN,
|
||||
QMK_OPENRGB_MODE_CYCLE_OUT_IN_DUAL,
|
||||
QMK_OPENRGB_MODE_RAINBOW_MOVING_CHEVRON,
|
||||
QMK_OPENRGB_MODE_CYCLE_PINWHEEL,
|
||||
QMK_OPENRGB_MODE_CYCLE_SPIRAL,
|
||||
QMK_OPENRGB_MODE_DUAL_BEACON,
|
||||
QMK_OPENRGB_MODE_RAINBOW_BEACON,
|
||||
QMK_OPENRGB_MODE_RAINBOW_PINWHEELS,
|
||||
QMK_OPENRGB_MODE_RAINDROPS,
|
||||
QMK_OPENRGB_MODE_JELLYBEAN_RAINDROPS,
|
||||
QMK_OPENRGB_MODE_HUE_BREATHING,
|
||||
QMK_OPENRGB_MODE_HUE_PENDULUM,
|
||||
QMK_OPENRGB_MODE_HUE_WAVE,
|
||||
QMK_OPENRGB_MODE_TYPING_HEATMAP,
|
||||
QMK_OPENRGB_MODE_DIGITAL_RAIN,
|
||||
QMK_OPENRGB_MODE_SOLID_REACTIVE_SIMPLE,
|
||||
QMK_OPENRGB_MODE_SOLID_REACTIVE,
|
||||
QMK_OPENRGB_MODE_SOLID_REACTIVE_WIDE,
|
||||
QMK_OPENRGB_MODE_SOLID_REACTIVE_MULTIWIDE,
|
||||
QMK_OPENRGB_MODE_SOLID_REACTIVE_CROSS,
|
||||
QMK_OPENRGB_MODE_SOLID_REACTIVE_MULTICROSS,
|
||||
QMK_OPENRGB_MODE_SOLID_REACTIVE_NEXUS,
|
||||
QMK_OPENRGB_MODE_SOLID_REACTIVE_MULTINEXUS,
|
||||
QMK_OPENRGB_MODE_SPLASH,
|
||||
QMK_OPENRGB_MODE_MULTISPLASH,
|
||||
QMK_OPENRGB_MODE_SOLID_SPLASH,
|
||||
QMK_OPENRGB_MODE_SOLID_MULTISPLASH,
|
||||
QMK_OPENRGB_MODE_PIXEL_RAIN,
|
||||
QMK_OPENRGB_MODE_PIXEL_FLOW,
|
||||
QMK_OPENRGB_MODE_PIXEL_FRACTAL,
|
||||
};
|
||||
|
||||
enum SpeedCommands
|
||||
{
|
||||
QMK_OPENRGB_SPEED_SLOWEST = 0x00, /* Slowest speed */
|
||||
QMK_OPENRGB_SPEED_NORMAL = 0x7F, /* Normal speed */
|
||||
QMK_OPENRGB_SPEED_FASTEST = 0xFF, /* Fastest speed */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
QMK_OPENRGB_FAILURE = 25, /* Failure status code */
|
||||
QMK_OPENRGB_SUCCESS = 50, /* Success status code */
|
||||
QMK_OPENRGB_END_OF_MESSAGE = 100, /* End of Message status code */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
QMK_OPENRGB_TOTAL_NUMBER_OF_LEDS_BYTE = 1,
|
||||
QMK_OPENRGB_TOTAL_NUMBER_OF_LEDS_WITH_EMPTY_SPACE_BYTE = 2
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
QMK_OPENRGB_MODE_BYTE = 1,
|
||||
QMK_OPENRGB_SPEED_BYTE = 2,
|
||||
QMK_OPENRGB_HUE_BYTE = 3,
|
||||
QMK_OPENRGB_SATURATION_BYTE = 4,
|
||||
QMK_OPENRGB_VALUE_BYTE = 5,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
QMK_OPENRGB_POINT_X_BYTE = 1,
|
||||
QMK_OPENRGB_POINT_Y_BYTE = 2,
|
||||
QMK_OPENRGB_FLAG_BYTE = 3,
|
||||
QMK_OPENRGB_R_COLOR_BYTE = 4,
|
||||
QMK_OPENRGB_G_COLOR_BYTE = 5,
|
||||
QMK_OPENRGB_B_COLOR_BYTE = 6,
|
||||
QMK_OPENRGB_KEYCODE_BYTE = 7
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t x;
|
||||
uint8_t y;
|
||||
} point_t;
|
||||
/*---------------------------------------------------------*\
|
||||
| QMKOpenRGBController.h |
|
||||
| |
|
||||
| Driver for OpenRGB QMK Keyboard Protocol |
|
||||
| |
|
||||
| Kasper 10 Oct 2020 |
|
||||
| Jath03 28 May 2021 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstring>
|
||||
#include <map>
|
||||
#include <hidapi.h>
|
||||
#include "ResourceManager.h"
|
||||
#include "RGBController.h"
|
||||
#include "hsv.h"
|
||||
|
||||
#define QMK_OPENRGB_PACKET_SIZE 65
|
||||
#define QMK_OPENRGB_HID_READ_TIMEOUT 50
|
||||
|
||||
enum CommandsId
|
||||
{
|
||||
QMK_OPENRGB_GET_PROTOCOL_VERSION = 1,
|
||||
QMK_OPENRGB_GET_QMK_VERSION,
|
||||
QMK_OPENRGB_GET_DEVICE_INFO,
|
||||
QMK_OPENRGB_GET_MODE_INFO,
|
||||
QMK_OPENRGB_GET_LED_INFO,
|
||||
QMK_OPENRGB_GET_IS_MODE_ENABLED,
|
||||
QMK_OPENRGB_GET_ENABLED_MODES = QMK_OPENRGB_GET_IS_MODE_ENABLED,
|
||||
|
||||
QMK_OPENRGB_SET_MODE,
|
||||
QMK_OPENRGB_DIRECT_MODE_SET_SINGLE_LED,
|
||||
QMK_OPENRGB_DIRECT_MODE_SET_LEDS,
|
||||
};
|
||||
|
||||
enum Modes
|
||||
{
|
||||
QMK_OPENRGB_MODE_OPENRGB_DIRECT = 1,
|
||||
QMK_OPENRGB_MODE_SOLID_COLOR,
|
||||
QMK_OPENRGB_MODE_ALPHA_MOD,
|
||||
QMK_OPENRGB_MODE_GRADIENT_UP_DOWN,
|
||||
QMK_OPENRGB_MODE_GRADIENT_LEFT_RIGHT,
|
||||
QMK_OPENRGB_MODE_BREATHING,
|
||||
QMK_OPENRGB_MODE_BAND_SAT,
|
||||
QMK_OPENRGB_MODE_BAND_VAL,
|
||||
QMK_OPENRGB_MODE_BAND_PINWHEEL_SAT,
|
||||
QMK_OPENRGB_MODE_BAND_PINWHEEL_VAL,
|
||||
QMK_OPENRGB_MODE_BAND_SPIRAL_SAT,
|
||||
QMK_OPENRGB_MODE_BAND_SPIRAL_VAL,
|
||||
QMK_OPENRGB_MODE_CYCLE_ALL,
|
||||
QMK_OPENRGB_MODE_CYCLE_LEFT_RIGHT,
|
||||
QMK_OPENRGB_MODE_CYCLE_UP_DOWN,
|
||||
QMK_OPENRGB_MODE_CYCLE_OUT_IN,
|
||||
QMK_OPENRGB_MODE_CYCLE_OUT_IN_DUAL,
|
||||
QMK_OPENRGB_MODE_RAINBOW_MOVING_CHEVRON,
|
||||
QMK_OPENRGB_MODE_CYCLE_PINWHEEL,
|
||||
QMK_OPENRGB_MODE_CYCLE_SPIRAL,
|
||||
QMK_OPENRGB_MODE_DUAL_BEACON,
|
||||
QMK_OPENRGB_MODE_RAINBOW_BEACON,
|
||||
QMK_OPENRGB_MODE_RAINBOW_PINWHEELS,
|
||||
QMK_OPENRGB_MODE_RAINDROPS,
|
||||
QMK_OPENRGB_MODE_JELLYBEAN_RAINDROPS,
|
||||
QMK_OPENRGB_MODE_HUE_BREATHING,
|
||||
QMK_OPENRGB_MODE_HUE_PENDULUM,
|
||||
QMK_OPENRGB_MODE_HUE_WAVE,
|
||||
QMK_OPENRGB_MODE_TYPING_HEATMAP,
|
||||
QMK_OPENRGB_MODE_DIGITAL_RAIN,
|
||||
QMK_OPENRGB_MODE_SOLID_REACTIVE_SIMPLE,
|
||||
QMK_OPENRGB_MODE_SOLID_REACTIVE,
|
||||
QMK_OPENRGB_MODE_SOLID_REACTIVE_WIDE,
|
||||
QMK_OPENRGB_MODE_SOLID_REACTIVE_MULTIWIDE,
|
||||
QMK_OPENRGB_MODE_SOLID_REACTIVE_CROSS,
|
||||
QMK_OPENRGB_MODE_SOLID_REACTIVE_MULTICROSS,
|
||||
QMK_OPENRGB_MODE_SOLID_REACTIVE_NEXUS,
|
||||
QMK_OPENRGB_MODE_SOLID_REACTIVE_MULTINEXUS,
|
||||
QMK_OPENRGB_MODE_SPLASH,
|
||||
QMK_OPENRGB_MODE_MULTISPLASH,
|
||||
QMK_OPENRGB_MODE_SOLID_SPLASH,
|
||||
QMK_OPENRGB_MODE_SOLID_MULTISPLASH,
|
||||
QMK_OPENRGB_MODE_PIXEL_RAIN,
|
||||
QMK_OPENRGB_MODE_PIXEL_FLOW,
|
||||
QMK_OPENRGB_MODE_PIXEL_FRACTAL,
|
||||
};
|
||||
|
||||
enum SpeedCommands
|
||||
{
|
||||
QMK_OPENRGB_SPEED_SLOWEST = 0x00, /* Slowest speed */
|
||||
QMK_OPENRGB_SPEED_NORMAL = 0x7F, /* Normal speed */
|
||||
QMK_OPENRGB_SPEED_FASTEST = 0xFF, /* Fastest speed */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
QMK_OPENRGB_FAILURE = 25, /* Failure status code */
|
||||
QMK_OPENRGB_SUCCESS = 50, /* Success status code */
|
||||
QMK_OPENRGB_END_OF_MESSAGE = 100, /* End of Message status code */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
QMK_OPENRGB_TOTAL_NUMBER_OF_LEDS_BYTE = 1,
|
||||
QMK_OPENRGB_TOTAL_NUMBER_OF_LEDS_WITH_EMPTY_SPACE_BYTE = 2
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
QMK_OPENRGB_MODE_BYTE = 1,
|
||||
QMK_OPENRGB_SPEED_BYTE = 2,
|
||||
QMK_OPENRGB_HUE_BYTE = 3,
|
||||
QMK_OPENRGB_SATURATION_BYTE = 4,
|
||||
QMK_OPENRGB_VALUE_BYTE = 5,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
QMK_OPENRGB_POINT_X_BYTE = 1,
|
||||
QMK_OPENRGB_POINT_Y_BYTE = 2,
|
||||
QMK_OPENRGB_FLAG_BYTE = 3,
|
||||
QMK_OPENRGB_R_COLOR_BYTE = 4,
|
||||
QMK_OPENRGB_G_COLOR_BYTE = 5,
|
||||
QMK_OPENRGB_B_COLOR_BYTE = 6,
|
||||
QMK_OPENRGB_KEYCODE_BYTE = 7
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t x;
|
||||
uint8_t y;
|
||||
} point_t;
|
||||
@@ -1,167 +1,167 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| QMKOpenRGBControllerDetect.cpp |
|
||||
| |
|
||||
| Detector for OpenRGB QMK Keyboard Protocol |
|
||||
| |
|
||||
| Kasper 10 Oct 2020 |
|
||||
| Jath03 28 May 2021 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include <string>
|
||||
#include <hidapi.h>
|
||||
#include "Detector.h"
|
||||
#include "QMKOpenRGBRev9Controller.h"
|
||||
#include "QMKOpenRGBRevBController.h"
|
||||
#include "QMKOpenRGBRevDController.h"
|
||||
#include "RGBController_QMKOpenRGBRev9.h"
|
||||
#include "RGBController_QMKOpenRGBRevB.h"
|
||||
#include "RGBController_QMKOpenRGBRevD.h"
|
||||
#include "RGBController_QMKOpenRGBRevE.h"
|
||||
#include "LogManager.h"
|
||||
#include "SettingsManager.h"
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Protocol version |
|
||||
\*-----------------------------------------------------*/
|
||||
#define QMK_OPENRGB_PROTOCOL_VERSION_9 0x09
|
||||
#define QMK_OPENRGB_PROTOCOL_VERSION_B 0x0B
|
||||
#define QMK_OPENRGB_PROTOCOL_VERSION_C 0x0C
|
||||
#define QMK_OPENRGB_PROTOCOL_VERSION_D 0x0D
|
||||
#define QMK_OPENRGB_PROTOCOL_VERSION_E 0x0E
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Usage and Usage Page |
|
||||
\*-----------------------------------------------------*/
|
||||
#define QMK_USAGE_PAGE 0xFF60
|
||||
#define QMK_USAGE 0x61
|
||||
|
||||
unsigned int GetProtocolVersion(hid_device *dev)
|
||||
{
|
||||
unsigned char usb_buf[QMK_OPENRGB_PACKET_SIZE];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, QMK_OPENRGB_PACKET_SIZE);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up config table request packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x00;
|
||||
usb_buf[0x01] = QMK_OPENRGB_GET_PROTOCOL_VERSION;
|
||||
|
||||
int bytes_read = 0;
|
||||
do
|
||||
{
|
||||
hid_write(dev, usb_buf, QMK_OPENRGB_PACKET_SIZE);
|
||||
bytes_read = hid_read_timeout(dev, usb_buf, QMK_OPENRGB_PACKET_SIZE, QMK_OPENRGB_HID_READ_TIMEOUT);
|
||||
} while(bytes_read <= 0);
|
||||
|
||||
return usb_buf[1];
|
||||
}
|
||||
|
||||
void DetectQMKOpenRGBControllers(hid_device_info *info, const std::string&)
|
||||
{
|
||||
hid_device *dev = hid_open_path(info->path);
|
||||
|
||||
if(dev)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Use Rev9 controller for getting protocol version. |
|
||||
| Protocol version request may not change across |
|
||||
| protocol versions |
|
||||
\*-----------------------------------------------------*/
|
||||
unsigned int version = GetProtocolVersion(dev);
|
||||
|
||||
switch(version)
|
||||
{
|
||||
case QMK_OPENRGB_PROTOCOL_VERSION_9:
|
||||
{
|
||||
QMKOpenRGBRev9Controller* controller = new QMKOpenRGBRev9Controller(dev, info->path);
|
||||
RGBController_QMKOpenRGBRev9* rgb_controller = new RGBController_QMKOpenRGBRev9(controller);
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
break;
|
||||
case QMK_OPENRGB_PROTOCOL_VERSION_B:
|
||||
{
|
||||
QMKOpenRGBRevBController* controller = new QMKOpenRGBRevBController(dev, info->path);
|
||||
RGBController_QMKOpenRGBRevB* rgb_controller = new RGBController_QMKOpenRGBRevB(controller, false);
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
break;
|
||||
case QMK_OPENRGB_PROTOCOL_VERSION_C:
|
||||
{
|
||||
QMKOpenRGBRevBController* controller = new QMKOpenRGBRevBController(dev, info->path);
|
||||
RGBController_QMKOpenRGBRevB* rgb_controller = new RGBController_QMKOpenRGBRevB(controller, true);
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
break;
|
||||
case QMK_OPENRGB_PROTOCOL_VERSION_D:
|
||||
{
|
||||
QMKOpenRGBRevDController* controller = new QMKOpenRGBRevDController(dev, info->path);
|
||||
RGBController_QMKOpenRGBRevD* rgb_controller = new RGBController_QMKOpenRGBRevD(controller, true);
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
break;
|
||||
case QMK_OPENRGB_PROTOCOL_VERSION_E:
|
||||
{
|
||||
QMKOpenRGBRevDController* controller = new QMKOpenRGBRevDController(dev, info->path);
|
||||
RGBController_QMKOpenRGBRevE* rgb_controller = new RGBController_QMKOpenRGBRevE(controller, true);
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (version == 0)
|
||||
{
|
||||
LOG_WARNING("[QMK OpenRGB] Detection failed - the detected keyboard does not have the OpenRGB protocol feature enabled! \n"
|
||||
"Please make sure your keyboard supports RGB Matrix, add OPENRGB_ENABLE = yes to the rules.mk inside your keymap folder, compile and flash again!");
|
||||
}
|
||||
else if (version < QMK_OPENRGB_PROTOCOL_VERSION_9)
|
||||
{
|
||||
LOG_WARNING("[QMK OpenRGB] Detection failed - the detected keyboard is using an outdated protocol version %i. Please update to to the update to the latest version of QMK-OpenRGB! \n"
|
||||
"For officaly supported QMK boards grab <a href=\"https://github.com/Kasper24/QMK-OpenRGB\">url</a> \n"
|
||||
"For Sonix boards grab <a href=\"https://github.com/SonixQMK/qmk_firmware/tree/sn32_openrgb\">url</a>", version);
|
||||
}
|
||||
else if (version > QMK_OPENRGB_PROTOCOL_VERSION_E)
|
||||
{
|
||||
LOG_WARNING("[QMK OpenRGB] Detection failed - the detected keyboard is using version protocol %i which is not supported by this OpenRGB build. Please update OpenRGB!", version);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RegisterQMKDetectors()
|
||||
{
|
||||
/*-------------------------------------------------*\
|
||||
| Get QMKOpenRGB settings |
|
||||
\*-------------------------------------------------*/
|
||||
json qmk_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("QMKOpenRGBDevices");
|
||||
|
||||
if(qmk_settings.contains("devices"))
|
||||
{
|
||||
for(unsigned int device_idx = 0; device_idx < qmk_settings["devices"].size(); device_idx++)
|
||||
{
|
||||
if( qmk_settings["devices"][device_idx].contains("usb_pid")
|
||||
&& qmk_settings["devices"][device_idx].contains("usb_vid")
|
||||
&& qmk_settings["devices"][device_idx].contains("name"))
|
||||
{
|
||||
std::string usb_pid_str = qmk_settings["devices"][device_idx]["usb_pid"];
|
||||
std::string usb_vid_str = qmk_settings["devices"][device_idx]["usb_vid"];
|
||||
std::string name = qmk_settings["devices"][device_idx]["name"];
|
||||
|
||||
/*-------------------------------------*\
|
||||
| Parse hex string to integer |
|
||||
\*-------------------------------------*/
|
||||
unsigned short usb_pid = std::stoi(usb_pid_str, 0, 16);
|
||||
unsigned short usb_vid = std::stoi(usb_vid_str, 0, 16);
|
||||
|
||||
REGISTER_DYNAMIC_HID_DETECTOR_IPU(name, DetectQMKOpenRGBControllers, usb_vid, usb_pid, 1, QMK_USAGE_PAGE, QMK_USAGE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
REGISTER_DYNAMIC_DETECTOR("QMK OpenRGB Devices", RegisterQMKDetectors);
|
||||
/*---------------------------------------------------------*\
|
||||
| QMKOpenRGBControllerDetect.cpp |
|
||||
| |
|
||||
| Detector for OpenRGB QMK Keyboard Protocol |
|
||||
| |
|
||||
| Kasper 10 Oct 2020 |
|
||||
| Jath03 28 May 2021 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include <string>
|
||||
#include <hidapi.h>
|
||||
#include "Detector.h"
|
||||
#include "QMKOpenRGBRev9Controller.h"
|
||||
#include "QMKOpenRGBRevBController.h"
|
||||
#include "QMKOpenRGBRevDController.h"
|
||||
#include "RGBController_QMKOpenRGBRev9.h"
|
||||
#include "RGBController_QMKOpenRGBRevB.h"
|
||||
#include "RGBController_QMKOpenRGBRevD.h"
|
||||
#include "RGBController_QMKOpenRGBRevE.h"
|
||||
#include "LogManager.h"
|
||||
#include "SettingsManager.h"
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Protocol version |
|
||||
\*-----------------------------------------------------*/
|
||||
#define QMK_OPENRGB_PROTOCOL_VERSION_9 0x09
|
||||
#define QMK_OPENRGB_PROTOCOL_VERSION_B 0x0B
|
||||
#define QMK_OPENRGB_PROTOCOL_VERSION_C 0x0C
|
||||
#define QMK_OPENRGB_PROTOCOL_VERSION_D 0x0D
|
||||
#define QMK_OPENRGB_PROTOCOL_VERSION_E 0x0E
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Usage and Usage Page |
|
||||
\*-----------------------------------------------------*/
|
||||
#define QMK_USAGE_PAGE 0xFF60
|
||||
#define QMK_USAGE 0x61
|
||||
|
||||
unsigned int GetProtocolVersion(hid_device *dev)
|
||||
{
|
||||
unsigned char usb_buf[QMK_OPENRGB_PACKET_SIZE];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, QMK_OPENRGB_PACKET_SIZE);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up config table request packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x00;
|
||||
usb_buf[0x01] = QMK_OPENRGB_GET_PROTOCOL_VERSION;
|
||||
|
||||
int bytes_read = 0;
|
||||
do
|
||||
{
|
||||
hid_write(dev, usb_buf, QMK_OPENRGB_PACKET_SIZE);
|
||||
bytes_read = hid_read_timeout(dev, usb_buf, QMK_OPENRGB_PACKET_SIZE, QMK_OPENRGB_HID_READ_TIMEOUT);
|
||||
} while(bytes_read <= 0);
|
||||
|
||||
return usb_buf[1];
|
||||
}
|
||||
|
||||
void DetectQMKOpenRGBControllers(hid_device_info *info, const std::string&)
|
||||
{
|
||||
hid_device *dev = hid_open_path(info->path);
|
||||
|
||||
if(dev)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Use Rev9 controller for getting protocol version. |
|
||||
| Protocol version request may not change across |
|
||||
| protocol versions |
|
||||
\*-----------------------------------------------------*/
|
||||
unsigned int version = GetProtocolVersion(dev);
|
||||
|
||||
switch(version)
|
||||
{
|
||||
case QMK_OPENRGB_PROTOCOL_VERSION_9:
|
||||
{
|
||||
QMKOpenRGBRev9Controller* controller = new QMKOpenRGBRev9Controller(dev, info->path);
|
||||
RGBController_QMKOpenRGBRev9* rgb_controller = new RGBController_QMKOpenRGBRev9(controller);
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
break;
|
||||
case QMK_OPENRGB_PROTOCOL_VERSION_B:
|
||||
{
|
||||
QMKOpenRGBRevBController* controller = new QMKOpenRGBRevBController(dev, info->path);
|
||||
RGBController_QMKOpenRGBRevB* rgb_controller = new RGBController_QMKOpenRGBRevB(controller, false);
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
break;
|
||||
case QMK_OPENRGB_PROTOCOL_VERSION_C:
|
||||
{
|
||||
QMKOpenRGBRevBController* controller = new QMKOpenRGBRevBController(dev, info->path);
|
||||
RGBController_QMKOpenRGBRevB* rgb_controller = new RGBController_QMKOpenRGBRevB(controller, true);
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
break;
|
||||
case QMK_OPENRGB_PROTOCOL_VERSION_D:
|
||||
{
|
||||
QMKOpenRGBRevDController* controller = new QMKOpenRGBRevDController(dev, info->path);
|
||||
RGBController_QMKOpenRGBRevD* rgb_controller = new RGBController_QMKOpenRGBRevD(controller, true);
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
break;
|
||||
case QMK_OPENRGB_PROTOCOL_VERSION_E:
|
||||
{
|
||||
QMKOpenRGBRevDController* controller = new QMKOpenRGBRevDController(dev, info->path);
|
||||
RGBController_QMKOpenRGBRevE* rgb_controller = new RGBController_QMKOpenRGBRevE(controller, true);
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (version == 0)
|
||||
{
|
||||
LOG_WARNING("[QMK OpenRGB] Detection failed - the detected keyboard does not have the OpenRGB protocol feature enabled! \n"
|
||||
"Please make sure your keyboard supports RGB Matrix, add OPENRGB_ENABLE = yes to the rules.mk inside your keymap folder, compile and flash again!");
|
||||
}
|
||||
else if (version < QMK_OPENRGB_PROTOCOL_VERSION_9)
|
||||
{
|
||||
LOG_WARNING("[QMK OpenRGB] Detection failed - the detected keyboard is using an outdated protocol version %i. Please update to to the update to the latest version of QMK-OpenRGB! \n"
|
||||
"For officaly supported QMK boards grab <a href=\"https://github.com/Kasper24/QMK-OpenRGB\">url</a> \n"
|
||||
"For Sonix boards grab <a href=\"https://github.com/SonixQMK/qmk_firmware/tree/sn32_openrgb\">url</a>", version);
|
||||
}
|
||||
else if (version > QMK_OPENRGB_PROTOCOL_VERSION_E)
|
||||
{
|
||||
LOG_WARNING("[QMK OpenRGB] Detection failed - the detected keyboard is using version protocol %i which is not supported by this OpenRGB build. Please update OpenRGB!", version);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RegisterQMKDetectors()
|
||||
{
|
||||
/*-------------------------------------------------*\
|
||||
| Get QMKOpenRGB settings |
|
||||
\*-------------------------------------------------*/
|
||||
json qmk_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("QMKOpenRGBDevices");
|
||||
|
||||
if(qmk_settings.contains("devices"))
|
||||
{
|
||||
for(unsigned int device_idx = 0; device_idx < qmk_settings["devices"].size(); device_idx++)
|
||||
{
|
||||
if( qmk_settings["devices"][device_idx].contains("usb_pid")
|
||||
&& qmk_settings["devices"][device_idx].contains("usb_vid")
|
||||
&& qmk_settings["devices"][device_idx].contains("name"))
|
||||
{
|
||||
std::string usb_pid_str = qmk_settings["devices"][device_idx]["usb_pid"];
|
||||
std::string usb_vid_str = qmk_settings["devices"][device_idx]["usb_vid"];
|
||||
std::string name = qmk_settings["devices"][device_idx]["name"];
|
||||
|
||||
/*-------------------------------------*\
|
||||
| Parse hex string to integer |
|
||||
\*-------------------------------------*/
|
||||
unsigned short usb_pid = std::stoi(usb_pid_str, 0, 16);
|
||||
unsigned short usb_vid = std::stoi(usb_vid_str, 0, 16);
|
||||
|
||||
REGISTER_DYNAMIC_HID_DETECTOR_IPU(name, DetectQMKOpenRGBControllers, usb_vid, usb_pid, 1, QMK_USAGE_PAGE, QMK_USAGE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
REGISTER_DYNAMIC_DETECTOR("QMK OpenRGB Devices", RegisterQMKDetectors);
|
||||
+170
-170
@@ -1,170 +1,170 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| QMKOpenRGBRev9Controller.cpp |
|
||||
| |
|
||||
| Driver for OpenRGB QMK Keyboard Protocol Revision 9 |
|
||||
| Revision 9 was initially supported by OpenRGB 0.6 |
|
||||
| |
|
||||
| Kasper 10 Oct 2020 |
|
||||
| Jath03 28 May 2021 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "QMKKeycodes.h"
|
||||
#include "QMKOpenRGBRev9Controller.h"
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
QMKOpenRGBRev9Controller::QMKOpenRGBRev9Controller(hid_device *dev_handle, const char *path) :
|
||||
QMKOpenRGBBaseController(dev_handle, path, 20)
|
||||
{
|
||||
}
|
||||
|
||||
QMKOpenRGBRev9Controller::~QMKOpenRGBRev9Controller()
|
||||
{
|
||||
}
|
||||
|
||||
void QMKOpenRGBRev9Controller::GetLEDInfo(unsigned int led)
|
||||
{
|
||||
unsigned char usb_buf[QMK_OPENRGB_PACKET_SIZE];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, QMK_OPENRGB_PACKET_SIZE);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up config table request packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x00;
|
||||
usb_buf[0x01] = QMK_OPENRGB_GET_LED_INFO;
|
||||
usb_buf[0x02] = led;
|
||||
|
||||
int bytes_read = 0;
|
||||
do
|
||||
{
|
||||
hid_write(dev, usb_buf, QMK_OPENRGB_PACKET_SIZE);
|
||||
bytes_read = hid_read_timeout(dev, usb_buf, QMK_OPENRGB_PACKET_SIZE, QMK_OPENRGB_HID_READ_TIMEOUT);
|
||||
} while(bytes_read <= 0);
|
||||
|
||||
if(usb_buf[62] != QMK_OPENRGB_FAILURE)
|
||||
{
|
||||
led_points.push_back(point_t{usb_buf[QMK_OPENRGB_POINT_X_BYTE], usb_buf[QMK_OPENRGB_POINT_Y_BYTE]});
|
||||
led_flags.push_back(usb_buf[QMK_OPENRGB_FLAG_BYTE]);
|
||||
led_colors.push_back(ToRGBColor(usb_buf[QMK_OPENRGB_R_COLOR_BYTE], usb_buf[QMK_OPENRGB_G_COLOR_BYTE], usb_buf[QMK_OPENRGB_B_COLOR_BYTE]));
|
||||
}
|
||||
|
||||
if(usb_buf[QMK_OPENRGB_KEYCODE_BYTE] != 0)
|
||||
{
|
||||
if(qmk_keynames.count(usb_buf[QMK_OPENRGB_KEYCODE_BYTE]) > 0)
|
||||
{
|
||||
led_names.push_back(qmk_keynames[usb_buf[QMK_OPENRGB_KEYCODE_BYTE]]);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_DEBUG("[%s] Key code: %d (%02X) @ offset %d was not found in the QMK keyname map",
|
||||
device_name.c_str(), usb_buf[QMK_OPENRGB_KEYCODE_BYTE],
|
||||
usb_buf[QMK_OPENRGB_KEYCODE_BYTE], led);
|
||||
led_names.push_back(KEY_EN_UNUSED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool QMKOpenRGBRev9Controller::GetIsModeEnabled(unsigned int mode)
|
||||
{
|
||||
unsigned char usb_buf[QMK_OPENRGB_PACKET_SIZE];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, QMK_OPENRGB_PACKET_SIZE);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up config table request packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x00;
|
||||
usb_buf[0x01] = QMK_OPENRGB_GET_IS_MODE_ENABLED;
|
||||
usb_buf[0x02] = mode;
|
||||
|
||||
int bytes_read = 0;
|
||||
do
|
||||
{
|
||||
hid_write(dev, usb_buf, QMK_OPENRGB_PACKET_SIZE);
|
||||
bytes_read = hid_read_timeout(dev, usb_buf, QMK_OPENRGB_PACKET_SIZE, QMK_OPENRGB_HID_READ_TIMEOUT);
|
||||
} while(bytes_read <= 0);
|
||||
|
||||
return usb_buf[1] == QMK_OPENRGB_SUCCESS ? true : false;
|
||||
}
|
||||
|
||||
void QMKOpenRGBRev9Controller::DirectModeSetSingleLED(unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
unsigned char usb_buf[QMK_OPENRGB_PACKET_SIZE];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, QMK_OPENRGB_PACKET_SIZE);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up config table request packet |
|
||||
\*-----------------------------------------------------*/
|
||||
|
||||
usb_buf[0x00] = 0x00;
|
||||
usb_buf[0x01] = QMK_OPENRGB_DIRECT_MODE_SET_SINGLE_LED;
|
||||
usb_buf[0x02] = led;
|
||||
usb_buf[0x03] = red;
|
||||
usb_buf[0x04] = green;
|
||||
usb_buf[0x05] = blue;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 65);
|
||||
hid_read_timeout(dev, usb_buf, 65, QMK_OPENRGB_HID_READ_TIMEOUT);
|
||||
}
|
||||
|
||||
void QMKOpenRGBRev9Controller::DirectModeSetLEDs(std::vector<RGBColor> colors, unsigned int leds_count)
|
||||
{
|
||||
unsigned int leds_sent = 0;
|
||||
unsigned int tmp_leds_per_update = leds_per_update;
|
||||
|
||||
while (leds_sent < leds_count)
|
||||
{
|
||||
if ((leds_count - leds_sent) < tmp_leds_per_update)
|
||||
{
|
||||
tmp_leds_per_update = leds_count - leds_sent;
|
||||
}
|
||||
|
||||
unsigned char usb_buf[QMK_OPENRGB_PACKET_SIZE];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, QMK_OPENRGB_PACKET_SIZE);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up config table request packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x00;
|
||||
usb_buf[0x01] = QMK_OPENRGB_DIRECT_MODE_SET_LEDS;
|
||||
usb_buf[0x02] = leds_sent;
|
||||
usb_buf[0x03] = tmp_leds_per_update;
|
||||
|
||||
for (unsigned int led_idx = 0; led_idx < tmp_leds_per_update; led_idx++)
|
||||
{
|
||||
usb_buf[(led_idx * 3) + 4] = RGBGetRValue(colors[led_idx + leds_sent]);
|
||||
usb_buf[(led_idx * 3) + 5] = RGBGetGValue(colors[led_idx + leds_sent]);
|
||||
usb_buf[(led_idx * 3) + 6] = RGBGetBValue(colors[led_idx + leds_sent]);
|
||||
}
|
||||
|
||||
hid_write(dev, usb_buf, 65);
|
||||
|
||||
if(delay > 0ms)
|
||||
{
|
||||
std::this_thread::sleep_for(delay);
|
||||
}
|
||||
|
||||
leds_sent += tmp_leds_per_update;
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------*\
|
||||
| QMKOpenRGBRev9Controller.cpp |
|
||||
| |
|
||||
| Driver for OpenRGB QMK Keyboard Protocol Revision 9 |
|
||||
| Revision 9 was initially supported by OpenRGB 0.6 |
|
||||
| |
|
||||
| Kasper 10 Oct 2020 |
|
||||
| Jath03 28 May 2021 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "QMKKeycodes.h"
|
||||
#include "QMKOpenRGBRev9Controller.h"
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
QMKOpenRGBRev9Controller::QMKOpenRGBRev9Controller(hid_device *dev_handle, const char *path) :
|
||||
QMKOpenRGBBaseController(dev_handle, path, 20)
|
||||
{
|
||||
}
|
||||
|
||||
QMKOpenRGBRev9Controller::~QMKOpenRGBRev9Controller()
|
||||
{
|
||||
}
|
||||
|
||||
void QMKOpenRGBRev9Controller::GetLEDInfo(unsigned int led)
|
||||
{
|
||||
unsigned char usb_buf[QMK_OPENRGB_PACKET_SIZE];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, QMK_OPENRGB_PACKET_SIZE);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up config table request packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x00;
|
||||
usb_buf[0x01] = QMK_OPENRGB_GET_LED_INFO;
|
||||
usb_buf[0x02] = led;
|
||||
|
||||
int bytes_read = 0;
|
||||
do
|
||||
{
|
||||
hid_write(dev, usb_buf, QMK_OPENRGB_PACKET_SIZE);
|
||||
bytes_read = hid_read_timeout(dev, usb_buf, QMK_OPENRGB_PACKET_SIZE, QMK_OPENRGB_HID_READ_TIMEOUT);
|
||||
} while(bytes_read <= 0);
|
||||
|
||||
if(usb_buf[62] != QMK_OPENRGB_FAILURE)
|
||||
{
|
||||
led_points.push_back(point_t{usb_buf[QMK_OPENRGB_POINT_X_BYTE], usb_buf[QMK_OPENRGB_POINT_Y_BYTE]});
|
||||
led_flags.push_back(usb_buf[QMK_OPENRGB_FLAG_BYTE]);
|
||||
led_colors.push_back(ToRGBColor(usb_buf[QMK_OPENRGB_R_COLOR_BYTE], usb_buf[QMK_OPENRGB_G_COLOR_BYTE], usb_buf[QMK_OPENRGB_B_COLOR_BYTE]));
|
||||
}
|
||||
|
||||
if(usb_buf[QMK_OPENRGB_KEYCODE_BYTE] != 0)
|
||||
{
|
||||
if(qmk_keynames.count(usb_buf[QMK_OPENRGB_KEYCODE_BYTE]) > 0)
|
||||
{
|
||||
led_names.push_back(qmk_keynames[usb_buf[QMK_OPENRGB_KEYCODE_BYTE]]);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_DEBUG("[%s] Key code: %d (%02X) @ offset %d was not found in the QMK keyname map",
|
||||
device_name.c_str(), usb_buf[QMK_OPENRGB_KEYCODE_BYTE],
|
||||
usb_buf[QMK_OPENRGB_KEYCODE_BYTE], led);
|
||||
led_names.push_back(KEY_EN_UNUSED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool QMKOpenRGBRev9Controller::GetIsModeEnabled(unsigned int mode)
|
||||
{
|
||||
unsigned char usb_buf[QMK_OPENRGB_PACKET_SIZE];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, QMK_OPENRGB_PACKET_SIZE);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up config table request packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x00;
|
||||
usb_buf[0x01] = QMK_OPENRGB_GET_IS_MODE_ENABLED;
|
||||
usb_buf[0x02] = mode;
|
||||
|
||||
int bytes_read = 0;
|
||||
do
|
||||
{
|
||||
hid_write(dev, usb_buf, QMK_OPENRGB_PACKET_SIZE);
|
||||
bytes_read = hid_read_timeout(dev, usb_buf, QMK_OPENRGB_PACKET_SIZE, QMK_OPENRGB_HID_READ_TIMEOUT);
|
||||
} while(bytes_read <= 0);
|
||||
|
||||
return usb_buf[1] == QMK_OPENRGB_SUCCESS ? true : false;
|
||||
}
|
||||
|
||||
void QMKOpenRGBRev9Controller::DirectModeSetSingleLED(unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
unsigned char usb_buf[QMK_OPENRGB_PACKET_SIZE];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, QMK_OPENRGB_PACKET_SIZE);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up config table request packet |
|
||||
\*-----------------------------------------------------*/
|
||||
|
||||
usb_buf[0x00] = 0x00;
|
||||
usb_buf[0x01] = QMK_OPENRGB_DIRECT_MODE_SET_SINGLE_LED;
|
||||
usb_buf[0x02] = led;
|
||||
usb_buf[0x03] = red;
|
||||
usb_buf[0x04] = green;
|
||||
usb_buf[0x05] = blue;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 65);
|
||||
hid_read_timeout(dev, usb_buf, 65, QMK_OPENRGB_HID_READ_TIMEOUT);
|
||||
}
|
||||
|
||||
void QMKOpenRGBRev9Controller::DirectModeSetLEDs(std::vector<RGBColor> colors, unsigned int leds_count)
|
||||
{
|
||||
unsigned int leds_sent = 0;
|
||||
unsigned int tmp_leds_per_update = leds_per_update;
|
||||
|
||||
while (leds_sent < leds_count)
|
||||
{
|
||||
if ((leds_count - leds_sent) < tmp_leds_per_update)
|
||||
{
|
||||
tmp_leds_per_update = leds_count - leds_sent;
|
||||
}
|
||||
|
||||
unsigned char usb_buf[QMK_OPENRGB_PACKET_SIZE];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, QMK_OPENRGB_PACKET_SIZE);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up config table request packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x00;
|
||||
usb_buf[0x01] = QMK_OPENRGB_DIRECT_MODE_SET_LEDS;
|
||||
usb_buf[0x02] = leds_sent;
|
||||
usb_buf[0x03] = tmp_leds_per_update;
|
||||
|
||||
for (unsigned int led_idx = 0; led_idx < tmp_leds_per_update; led_idx++)
|
||||
{
|
||||
usb_buf[(led_idx * 3) + 4] = RGBGetRValue(colors[led_idx + leds_sent]);
|
||||
usb_buf[(led_idx * 3) + 5] = RGBGetGValue(colors[led_idx + leds_sent]);
|
||||
usb_buf[(led_idx * 3) + 6] = RGBGetBValue(colors[led_idx + leds_sent]);
|
||||
}
|
||||
|
||||
hid_write(dev, usb_buf, 65);
|
||||
|
||||
if(delay > 0ms)
|
||||
{
|
||||
std::this_thread::sleep_for(delay);
|
||||
}
|
||||
|
||||
leds_sent += tmp_leds_per_update;
|
||||
}
|
||||
}
|
||||
+33
-33
@@ -1,33 +1,33 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| QMKOpenRGBRev9Controller.h |
|
||||
| |
|
||||
| Driver for OpenRGB QMK Keyboard Protocol Revision 9 |
|
||||
| Revision 9 was initially supported by OpenRGB 0.6 |
|
||||
| |
|
||||
| Kasper 10 Oct 2020 |
|
||||
| Jath03 28 May 2021 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "QMKOpenRGBBaseController.h"
|
||||
|
||||
class QMKOpenRGBRev9Controller : public QMKOpenRGBBaseController
|
||||
{
|
||||
public:
|
||||
QMKOpenRGBRev9Controller(hid_device *dev_handle, const char *path);
|
||||
~QMKOpenRGBRev9Controller();
|
||||
|
||||
//Virtual function implementations
|
||||
void GetLEDInfo(unsigned int led);
|
||||
void DirectModeSetSingleLED(unsigned int led, unsigned char red, unsigned char green, unsigned char blue);
|
||||
void DirectModeSetLEDs(std::vector<RGBColor> colors, unsigned int num_colors);
|
||||
|
||||
//Protocol Specific functions
|
||||
bool GetIsModeEnabled(unsigned int mode);
|
||||
|
||||
private:
|
||||
};
|
||||
/*---------------------------------------------------------*\
|
||||
| QMKOpenRGBRev9Controller.h |
|
||||
| |
|
||||
| Driver for OpenRGB QMK Keyboard Protocol Revision 9 |
|
||||
| Revision 9 was initially supported by OpenRGB 0.6 |
|
||||
| |
|
||||
| Kasper 10 Oct 2020 |
|
||||
| Jath03 28 May 2021 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "QMKOpenRGBBaseController.h"
|
||||
|
||||
class QMKOpenRGBRev9Controller : public QMKOpenRGBBaseController
|
||||
{
|
||||
public:
|
||||
QMKOpenRGBRev9Controller(hid_device *dev_handle, const char *path);
|
||||
~QMKOpenRGBRev9Controller();
|
||||
|
||||
//Virtual function implementations
|
||||
void GetLEDInfo(unsigned int led);
|
||||
void DirectModeSetSingleLED(unsigned int led, unsigned char red, unsigned char green, unsigned char blue);
|
||||
void DirectModeSetLEDs(std::vector<RGBColor> colors, unsigned int num_colors);
|
||||
|
||||
//Protocol Specific functions
|
||||
bool GetIsModeEnabled(unsigned int mode);
|
||||
|
||||
private:
|
||||
};
|
||||
+762
-762
File diff suppressed because it is too large.
Load diff
+99
-99
@@ -1,99 +1,99 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController_QMKOpenRGBRev9.h |
|
||||
| |
|
||||
| RGBController for OpenRGB QMK Keyboard Protocol |
|
||||
| Revision 9 |
|
||||
| |
|
||||
| Kasper 10 Oct 2020 |
|
||||
| Jath03 28 May 2021 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include "RGBController.h"
|
||||
#include "QMKOpenRGBRev9Controller.h"
|
||||
|
||||
#define NO_LED 0xFFFFFFFF
|
||||
|
||||
typedef std::vector<std::vector<unsigned int>> VectorMatrix;
|
||||
|
||||
class RGBController_QMKOpenRGBRev9 : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_QMKOpenRGBRev9(QMKOpenRGBRev9Controller* controller_ptr);
|
||||
~RGBController_QMKOpenRGBRev9();
|
||||
|
||||
void SetupZones();
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
QMKOpenRGBRev9Controller* controller;
|
||||
std::vector<unsigned int> flat_matrix_map;
|
||||
std::vector<unsigned int> flat_underglow_map;
|
||||
|
||||
void InitializeMode
|
||||
(
|
||||
std::string name,
|
||||
unsigned int ¤t_mode,
|
||||
unsigned int flags,
|
||||
unsigned int color_mode
|
||||
);
|
||||
|
||||
unsigned int CalculateDivisor
|
||||
(
|
||||
std::vector<point_t> led_points,
|
||||
std::set<int> rows,
|
||||
std::set<int> columns
|
||||
);
|
||||
|
||||
void CountKeyTypes
|
||||
(
|
||||
std::vector<unsigned int> led_flags,
|
||||
unsigned int total_led_count,
|
||||
unsigned int& key_leds,
|
||||
unsigned int& underglow_leds
|
||||
);
|
||||
|
||||
void PlaceLEDsInMaps
|
||||
(
|
||||
std::set<int> unique_rows,
|
||||
std::set<int> unique_cols,
|
||||
unsigned int divisor,
|
||||
std::vector<point_t> led_points,
|
||||
std::vector<unsigned int> led_flags,
|
||||
VectorMatrix& matrix_map_xl,
|
||||
VectorMatrix& underglow_map_xl
|
||||
);
|
||||
|
||||
VectorMatrix MakeEmptyMatrixMap
|
||||
(
|
||||
std::size_t height,
|
||||
std::size_t width
|
||||
);
|
||||
|
||||
void CleanMatrixMaps
|
||||
(
|
||||
VectorMatrix& matrix_map,
|
||||
VectorMatrix& underglow_map,
|
||||
unsigned int height,
|
||||
bool has_underglow
|
||||
);
|
||||
|
||||
std::vector<unsigned int> FlattenMatrixMap
|
||||
(
|
||||
VectorMatrix matrix_map
|
||||
);
|
||||
};
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController_QMKOpenRGBRev9.h |
|
||||
| |
|
||||
| RGBController for OpenRGB QMK Keyboard Protocol |
|
||||
| Revision 9 |
|
||||
| |
|
||||
| Kasper 10 Oct 2020 |
|
||||
| Jath03 28 May 2021 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include "RGBController.h"
|
||||
#include "QMKOpenRGBRev9Controller.h"
|
||||
|
||||
#define NO_LED 0xFFFFFFFF
|
||||
|
||||
typedef std::vector<std::vector<unsigned int>> VectorMatrix;
|
||||
|
||||
class RGBController_QMKOpenRGBRev9 : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_QMKOpenRGBRev9(QMKOpenRGBRev9Controller* controller_ptr);
|
||||
~RGBController_QMKOpenRGBRev9();
|
||||
|
||||
void SetupZones();
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
QMKOpenRGBRev9Controller* controller;
|
||||
std::vector<unsigned int> flat_matrix_map;
|
||||
std::vector<unsigned int> flat_underglow_map;
|
||||
|
||||
void InitializeMode
|
||||
(
|
||||
std::string name,
|
||||
unsigned int ¤t_mode,
|
||||
unsigned int flags,
|
||||
unsigned int color_mode
|
||||
);
|
||||
|
||||
unsigned int CalculateDivisor
|
||||
(
|
||||
std::vector<point_t> led_points,
|
||||
std::set<int> rows,
|
||||
std::set<int> columns
|
||||
);
|
||||
|
||||
void CountKeyTypes
|
||||
(
|
||||
std::vector<unsigned int> led_flags,
|
||||
unsigned int total_led_count,
|
||||
unsigned int& key_leds,
|
||||
unsigned int& underglow_leds
|
||||
);
|
||||
|
||||
void PlaceLEDsInMaps
|
||||
(
|
||||
std::set<int> unique_rows,
|
||||
std::set<int> unique_cols,
|
||||
unsigned int divisor,
|
||||
std::vector<point_t> led_points,
|
||||
std::vector<unsigned int> led_flags,
|
||||
VectorMatrix& matrix_map_xl,
|
||||
VectorMatrix& underglow_map_xl
|
||||
);
|
||||
|
||||
VectorMatrix MakeEmptyMatrixMap
|
||||
(
|
||||
std::size_t height,
|
||||
std::size_t width
|
||||
);
|
||||
|
||||
void CleanMatrixMaps
|
||||
(
|
||||
VectorMatrix& matrix_map,
|
||||
VectorMatrix& underglow_map,
|
||||
unsigned int height,
|
||||
bool has_underglow
|
||||
);
|
||||
|
||||
std::vector<unsigned int> FlattenMatrixMap
|
||||
(
|
||||
VectorMatrix matrix_map
|
||||
);
|
||||
};
|
||||
+194
-194
@@ -1,194 +1,194 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| QMKOpenRGBRevBController.cpp |
|
||||
| |
|
||||
| Driver for OpenRGB QMK Keyboard Protocol Revision B |
|
||||
| |
|
||||
| Kasper 28 Jun 2021 |
|
||||
| Jath03 28 May 2021 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "QMKKeycodes.h"
|
||||
#include "QMKOpenRGBRevBController.h"
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
QMKOpenRGBRevBController::QMKOpenRGBRevBController(hid_device *dev_handle, const char *path) :
|
||||
QMKOpenRGBBaseController(dev_handle, path, 20)
|
||||
{
|
||||
}
|
||||
|
||||
QMKOpenRGBRevBController::~QMKOpenRGBRevBController()
|
||||
{
|
||||
}
|
||||
|
||||
void QMKOpenRGBRevBController::GetLEDInfo(unsigned int leds_count)
|
||||
{
|
||||
unsigned int leds_sent = 0;
|
||||
unsigned int leds_per_update_info = 8;
|
||||
|
||||
while (leds_sent < leds_count)
|
||||
{
|
||||
if ((leds_count - leds_sent) < leds_per_update_info)
|
||||
{
|
||||
leds_per_update_info = leds_count - leds_sent;
|
||||
}
|
||||
|
||||
unsigned char usb_buf[QMK_OPENRGB_PACKET_SIZE];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, QMK_OPENRGB_PACKET_SIZE);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up config table request packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x00;
|
||||
usb_buf[0x01] = QMK_OPENRGB_GET_LED_INFO;
|
||||
usb_buf[0x02] = leds_sent;
|
||||
usb_buf[0x03] = leds_per_update_info;
|
||||
|
||||
int bytes_read = 0;
|
||||
do
|
||||
{
|
||||
hid_write(dev, usb_buf, QMK_OPENRGB_PACKET_SIZE);
|
||||
bytes_read = hid_read_timeout(dev, usb_buf, QMK_OPENRGB_PACKET_SIZE, QMK_OPENRGB_HID_READ_TIMEOUT);
|
||||
} while(bytes_read <= 0);
|
||||
|
||||
for (unsigned int led_idx = 0; led_idx < leds_per_update_info; led_idx++)
|
||||
{
|
||||
unsigned int offset = led_idx * 7;
|
||||
|
||||
if(usb_buf[(offset) + QMK_OPENRGB_FLAG_BYTE] != QMK_OPENRGB_FAILURE)
|
||||
{
|
||||
led_points.push_back(point_t{usb_buf[(offset) + QMK_OPENRGB_POINT_X_BYTE], usb_buf[(offset) + QMK_OPENRGB_POINT_Y_BYTE]});
|
||||
led_flags.push_back(usb_buf[(offset) + QMK_OPENRGB_FLAG_BYTE]);
|
||||
led_colors.push_back(ToRGBColor(usb_buf[(offset) + QMK_OPENRGB_R_COLOR_BYTE], usb_buf[(offset) + QMK_OPENRGB_G_COLOR_BYTE], usb_buf[(offset) + QMK_OPENRGB_B_COLOR_BYTE]));
|
||||
}
|
||||
|
||||
if(usb_buf[(offset) + QMK_OPENRGB_KEYCODE_BYTE] != 0)
|
||||
{
|
||||
if(qmk_keynames.count(usb_buf[(offset) + QMK_OPENRGB_KEYCODE_BYTE]) > 0)
|
||||
{
|
||||
led_names.push_back(qmk_keynames[usb_buf[(offset) + QMK_OPENRGB_KEYCODE_BYTE]]);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_DEBUG("[%s] Key code: %d (%02X) @ offset %d was not found in the QMK keyname map",
|
||||
device_name.c_str(), usb_buf[offset + QMK_OPENRGB_KEYCODE_BYTE],
|
||||
usb_buf[offset + QMK_OPENRGB_KEYCODE_BYTE], leds_sent + led_idx);
|
||||
led_names.push_back(KEY_EN_UNUSED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
leds_sent += leds_per_update_info;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<unsigned int> QMKOpenRGBRevBController::GetEnabledModes()
|
||||
{
|
||||
unsigned char usb_buf[QMK_OPENRGB_PACKET_SIZE];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, QMK_OPENRGB_PACKET_SIZE);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up config table request packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x00;
|
||||
usb_buf[0x01] = QMK_OPENRGB_GET_ENABLED_MODES;
|
||||
|
||||
int bytes_read = 0;
|
||||
do
|
||||
{
|
||||
hid_write(dev, usb_buf, QMK_OPENRGB_PACKET_SIZE);
|
||||
bytes_read = hid_read_timeout(dev, usb_buf, QMK_OPENRGB_PACKET_SIZE, QMK_OPENRGB_HID_READ_TIMEOUT);
|
||||
} while(bytes_read <= 0);
|
||||
|
||||
std::vector<unsigned int> enabled_modes;
|
||||
int i = 1;
|
||||
while (usb_buf[i] != 0)
|
||||
{
|
||||
enabled_modes.push_back(usb_buf[i]);
|
||||
i++;
|
||||
}
|
||||
return enabled_modes;
|
||||
}
|
||||
|
||||
void QMKOpenRGBRevBController::DirectModeSetSingleLED(unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
unsigned char usb_buf[QMK_OPENRGB_PACKET_SIZE];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, QMK_OPENRGB_PACKET_SIZE);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up config table request packet |
|
||||
\*-----------------------------------------------------*/
|
||||
|
||||
usb_buf[0x00] = 0x00;
|
||||
usb_buf[0x01] = QMK_OPENRGB_DIRECT_MODE_SET_SINGLE_LED;
|
||||
usb_buf[0x02] = led;
|
||||
usb_buf[0x03] = red;
|
||||
usb_buf[0x04] = green;
|
||||
usb_buf[0x05] = blue;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 65);
|
||||
hid_read_timeout(dev, usb_buf, 65, QMK_OPENRGB_HID_READ_TIMEOUT);
|
||||
}
|
||||
|
||||
void QMKOpenRGBRevBController::DirectModeSetLEDs(std::vector<RGBColor> colors, unsigned int leds_count)
|
||||
{
|
||||
unsigned int leds_sent = 0;
|
||||
unsigned int tmp_leds_per_update = leds_per_update;
|
||||
|
||||
while (leds_sent < leds_count)
|
||||
{
|
||||
if ((leds_count - leds_sent) < tmp_leds_per_update)
|
||||
{
|
||||
tmp_leds_per_update = leds_count - leds_sent;
|
||||
}
|
||||
|
||||
unsigned char usb_buf[QMK_OPENRGB_PACKET_SIZE];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, QMK_OPENRGB_PACKET_SIZE);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up config table request packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x00;
|
||||
usb_buf[0x01] = QMK_OPENRGB_DIRECT_MODE_SET_LEDS;
|
||||
usb_buf[0x02] = leds_sent;
|
||||
usb_buf[0x03] = tmp_leds_per_update;
|
||||
|
||||
for (unsigned int led_idx = 0; led_idx < tmp_leds_per_update; led_idx++)
|
||||
{
|
||||
usb_buf[(led_idx * 3) + 4] = RGBGetRValue(colors[led_idx + leds_sent]);
|
||||
usb_buf[(led_idx * 3) + 5] = RGBGetGValue(colors[led_idx + leds_sent]);
|
||||
usb_buf[(led_idx * 3) + 6] = RGBGetBValue(colors[led_idx + leds_sent]);
|
||||
}
|
||||
|
||||
hid_write(dev, usb_buf, 65);
|
||||
|
||||
if(delay > 0ms)
|
||||
{
|
||||
std::this_thread::sleep_for(delay);
|
||||
}
|
||||
|
||||
leds_sent += tmp_leds_per_update;
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------*\
|
||||
| QMKOpenRGBRevBController.cpp |
|
||||
| |
|
||||
| Driver for OpenRGB QMK Keyboard Protocol Revision B |
|
||||
| |
|
||||
| Kasper 28 Jun 2021 |
|
||||
| Jath03 28 May 2021 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "QMKKeycodes.h"
|
||||
#include "QMKOpenRGBRevBController.h"
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
QMKOpenRGBRevBController::QMKOpenRGBRevBController(hid_device *dev_handle, const char *path) :
|
||||
QMKOpenRGBBaseController(dev_handle, path, 20)
|
||||
{
|
||||
}
|
||||
|
||||
QMKOpenRGBRevBController::~QMKOpenRGBRevBController()
|
||||
{
|
||||
}
|
||||
|
||||
void QMKOpenRGBRevBController::GetLEDInfo(unsigned int leds_count)
|
||||
{
|
||||
unsigned int leds_sent = 0;
|
||||
unsigned int leds_per_update_info = 8;
|
||||
|
||||
while (leds_sent < leds_count)
|
||||
{
|
||||
if ((leds_count - leds_sent) < leds_per_update_info)
|
||||
{
|
||||
leds_per_update_info = leds_count - leds_sent;
|
||||
}
|
||||
|
||||
unsigned char usb_buf[QMK_OPENRGB_PACKET_SIZE];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, QMK_OPENRGB_PACKET_SIZE);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up config table request packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x00;
|
||||
usb_buf[0x01] = QMK_OPENRGB_GET_LED_INFO;
|
||||
usb_buf[0x02] = leds_sent;
|
||||
usb_buf[0x03] = leds_per_update_info;
|
||||
|
||||
int bytes_read = 0;
|
||||
do
|
||||
{
|
||||
hid_write(dev, usb_buf, QMK_OPENRGB_PACKET_SIZE);
|
||||
bytes_read = hid_read_timeout(dev, usb_buf, QMK_OPENRGB_PACKET_SIZE, QMK_OPENRGB_HID_READ_TIMEOUT);
|
||||
} while(bytes_read <= 0);
|
||||
|
||||
for (unsigned int led_idx = 0; led_idx < leds_per_update_info; led_idx++)
|
||||
{
|
||||
unsigned int offset = led_idx * 7;
|
||||
|
||||
if(usb_buf[(offset) + QMK_OPENRGB_FLAG_BYTE] != QMK_OPENRGB_FAILURE)
|
||||
{
|
||||
led_points.push_back(point_t{usb_buf[(offset) + QMK_OPENRGB_POINT_X_BYTE], usb_buf[(offset) + QMK_OPENRGB_POINT_Y_BYTE]});
|
||||
led_flags.push_back(usb_buf[(offset) + QMK_OPENRGB_FLAG_BYTE]);
|
||||
led_colors.push_back(ToRGBColor(usb_buf[(offset) + QMK_OPENRGB_R_COLOR_BYTE], usb_buf[(offset) + QMK_OPENRGB_G_COLOR_BYTE], usb_buf[(offset) + QMK_OPENRGB_B_COLOR_BYTE]));
|
||||
}
|
||||
|
||||
if(usb_buf[(offset) + QMK_OPENRGB_KEYCODE_BYTE] != 0)
|
||||
{
|
||||
if(qmk_keynames.count(usb_buf[(offset) + QMK_OPENRGB_KEYCODE_BYTE]) > 0)
|
||||
{
|
||||
led_names.push_back(qmk_keynames[usb_buf[(offset) + QMK_OPENRGB_KEYCODE_BYTE]]);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_DEBUG("[%s] Key code: %d (%02X) @ offset %d was not found in the QMK keyname map",
|
||||
device_name.c_str(), usb_buf[offset + QMK_OPENRGB_KEYCODE_BYTE],
|
||||
usb_buf[offset + QMK_OPENRGB_KEYCODE_BYTE], leds_sent + led_idx);
|
||||
led_names.push_back(KEY_EN_UNUSED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
leds_sent += leds_per_update_info;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<unsigned int> QMKOpenRGBRevBController::GetEnabledModes()
|
||||
{
|
||||
unsigned char usb_buf[QMK_OPENRGB_PACKET_SIZE];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, QMK_OPENRGB_PACKET_SIZE);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up config table request packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x00;
|
||||
usb_buf[0x01] = QMK_OPENRGB_GET_ENABLED_MODES;
|
||||
|
||||
int bytes_read = 0;
|
||||
do
|
||||
{
|
||||
hid_write(dev, usb_buf, QMK_OPENRGB_PACKET_SIZE);
|
||||
bytes_read = hid_read_timeout(dev, usb_buf, QMK_OPENRGB_PACKET_SIZE, QMK_OPENRGB_HID_READ_TIMEOUT);
|
||||
} while(bytes_read <= 0);
|
||||
|
||||
std::vector<unsigned int> enabled_modes;
|
||||
int i = 1;
|
||||
while (usb_buf[i] != 0)
|
||||
{
|
||||
enabled_modes.push_back(usb_buf[i]);
|
||||
i++;
|
||||
}
|
||||
return enabled_modes;
|
||||
}
|
||||
|
||||
void QMKOpenRGBRevBController::DirectModeSetSingleLED(unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
unsigned char usb_buf[QMK_OPENRGB_PACKET_SIZE];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, QMK_OPENRGB_PACKET_SIZE);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up config table request packet |
|
||||
\*-----------------------------------------------------*/
|
||||
|
||||
usb_buf[0x00] = 0x00;
|
||||
usb_buf[0x01] = QMK_OPENRGB_DIRECT_MODE_SET_SINGLE_LED;
|
||||
usb_buf[0x02] = led;
|
||||
usb_buf[0x03] = red;
|
||||
usb_buf[0x04] = green;
|
||||
usb_buf[0x05] = blue;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 65);
|
||||
hid_read_timeout(dev, usb_buf, 65, QMK_OPENRGB_HID_READ_TIMEOUT);
|
||||
}
|
||||
|
||||
void QMKOpenRGBRevBController::DirectModeSetLEDs(std::vector<RGBColor> colors, unsigned int leds_count)
|
||||
{
|
||||
unsigned int leds_sent = 0;
|
||||
unsigned int tmp_leds_per_update = leds_per_update;
|
||||
|
||||
while (leds_sent < leds_count)
|
||||
{
|
||||
if ((leds_count - leds_sent) < tmp_leds_per_update)
|
||||
{
|
||||
tmp_leds_per_update = leds_count - leds_sent;
|
||||
}
|
||||
|
||||
unsigned char usb_buf[QMK_OPENRGB_PACKET_SIZE];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, QMK_OPENRGB_PACKET_SIZE);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up config table request packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x00;
|
||||
usb_buf[0x01] = QMK_OPENRGB_DIRECT_MODE_SET_LEDS;
|
||||
usb_buf[0x02] = leds_sent;
|
||||
usb_buf[0x03] = tmp_leds_per_update;
|
||||
|
||||
for (unsigned int led_idx = 0; led_idx < tmp_leds_per_update; led_idx++)
|
||||
{
|
||||
usb_buf[(led_idx * 3) + 4] = RGBGetRValue(colors[led_idx + leds_sent]);
|
||||
usb_buf[(led_idx * 3) + 5] = RGBGetGValue(colors[led_idx + leds_sent]);
|
||||
usb_buf[(led_idx * 3) + 6] = RGBGetBValue(colors[led_idx + leds_sent]);
|
||||
}
|
||||
|
||||
hid_write(dev, usb_buf, 65);
|
||||
|
||||
if(delay > 0ms)
|
||||
{
|
||||
std::this_thread::sleep_for(delay);
|
||||
}
|
||||
|
||||
leds_sent += tmp_leds_per_update;
|
||||
}
|
||||
}
|
||||
+32
-32
@@ -1,32 +1,32 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| QMKOpenRGBRevBController.h |
|
||||
| |
|
||||
| Driver for OpenRGB QMK Keyboard Protocol Revision B |
|
||||
| |
|
||||
| Kasper 28 Jun 2021 |
|
||||
| Jath03 28 May 2021 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "QMKOpenRGBBaseController.h"
|
||||
|
||||
class QMKOpenRGBRevBController : public QMKOpenRGBBaseController
|
||||
{
|
||||
public:
|
||||
QMKOpenRGBRevBController(hid_device *dev_handle, const char *path);
|
||||
~QMKOpenRGBRevBController();
|
||||
|
||||
//Virtual function implementations
|
||||
void GetLEDInfo(unsigned int leds_count);
|
||||
void DirectModeSetSingleLED(unsigned int led, unsigned char red, unsigned char green, unsigned char blue);
|
||||
void DirectModeSetLEDs(std::vector<RGBColor> colors, unsigned int num_colors);
|
||||
|
||||
//Protocol Specific functions
|
||||
std::vector<unsigned int> GetEnabledModes();
|
||||
|
||||
private:
|
||||
};
|
||||
/*---------------------------------------------------------*\
|
||||
| QMKOpenRGBRevBController.h |
|
||||
| |
|
||||
| Driver for OpenRGB QMK Keyboard Protocol Revision B |
|
||||
| |
|
||||
| Kasper 28 Jun 2021 |
|
||||
| Jath03 28 May 2021 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "QMKOpenRGBBaseController.h"
|
||||
|
||||
class QMKOpenRGBRevBController : public QMKOpenRGBBaseController
|
||||
{
|
||||
public:
|
||||
QMKOpenRGBRevBController(hid_device *dev_handle, const char *path);
|
||||
~QMKOpenRGBRevBController();
|
||||
|
||||
//Virtual function implementations
|
||||
void GetLEDInfo(unsigned int leds_count);
|
||||
void DirectModeSetSingleLED(unsigned int led, unsigned char red, unsigned char green, unsigned char blue);
|
||||
void DirectModeSetLEDs(std::vector<RGBColor> colors, unsigned int num_colors);
|
||||
|
||||
//Protocol Specific functions
|
||||
std::vector<unsigned int> GetEnabledModes();
|
||||
|
||||
private:
|
||||
};
|
||||
+807
-807
File diff suppressed because it is too large.
Load diff
+101
-101
@@ -1,101 +1,101 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController_QMKOpenRGBRevB.h |
|
||||
| |
|
||||
| RGBController for OpenRGB QMK Keyboard Protocol |
|
||||
| Revision B |
|
||||
| |
|
||||
| Kasper 28 Jun 2021 |
|
||||
| Jath03 28 May 2021 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include "RGBController.h"
|
||||
#include "QMKOpenRGBRevBController.h"
|
||||
|
||||
#define NO_LED 0xFFFFFFFF
|
||||
|
||||
typedef std::vector<std::vector<unsigned int>> VectorMatrix;
|
||||
|
||||
class RGBController_QMKOpenRGBRevB : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_QMKOpenRGBRevB(QMKOpenRGBRevBController* controller_ptr, bool save);
|
||||
~RGBController_QMKOpenRGBRevB();
|
||||
|
||||
void SetupZones();
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void DeviceUpdateMode();
|
||||
void DeviceSaveMode();
|
||||
|
||||
private:
|
||||
QMKOpenRGBRevBController* controller;
|
||||
std::vector<unsigned int> flat_matrix_map;
|
||||
std::vector<unsigned int> flat_underglow_map;
|
||||
|
||||
void InitializeMode
|
||||
(
|
||||
std::string name,
|
||||
unsigned int ¤t_mode,
|
||||
unsigned int flags,
|
||||
unsigned int color_mode,
|
||||
bool save
|
||||
);
|
||||
|
||||
unsigned int CalculateDivisor
|
||||
(
|
||||
std::vector<point_t> led_points,
|
||||
std::set<int> rows,
|
||||
std::set<int> columns
|
||||
);
|
||||
|
||||
void CountKeyTypes
|
||||
(
|
||||
std::vector<unsigned int> led_flags,
|
||||
unsigned int total_led_count,
|
||||
unsigned int& key_leds,
|
||||
unsigned int& underglow_leds
|
||||
);
|
||||
|
||||
void PlaceLEDsInMaps
|
||||
(
|
||||
std::set<int> unique_rows,
|
||||
std::set<int> unique_cols,
|
||||
unsigned int divisor,
|
||||
std::vector<point_t> led_points,
|
||||
std::vector<unsigned int> led_flags,
|
||||
VectorMatrix& matrix_map_xl,
|
||||
VectorMatrix& underglow_map_xl
|
||||
);
|
||||
|
||||
VectorMatrix MakeEmptyMatrixMap
|
||||
(
|
||||
std::size_t height,
|
||||
std::size_t width
|
||||
);
|
||||
|
||||
void CleanMatrixMaps
|
||||
(
|
||||
VectorMatrix& matrix_map,
|
||||
VectorMatrix& underglow_map,
|
||||
unsigned int height,
|
||||
bool has_underglow
|
||||
);
|
||||
|
||||
std::vector<unsigned int> FlattenMatrixMap
|
||||
(
|
||||
VectorMatrix matrix_map
|
||||
);
|
||||
};
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController_QMKOpenRGBRevB.h |
|
||||
| |
|
||||
| RGBController for OpenRGB QMK Keyboard Protocol |
|
||||
| Revision B |
|
||||
| |
|
||||
| Kasper 28 Jun 2021 |
|
||||
| Jath03 28 May 2021 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include "RGBController.h"
|
||||
#include "QMKOpenRGBRevBController.h"
|
||||
|
||||
#define NO_LED 0xFFFFFFFF
|
||||
|
||||
typedef std::vector<std::vector<unsigned int>> VectorMatrix;
|
||||
|
||||
class RGBController_QMKOpenRGBRevB : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_QMKOpenRGBRevB(QMKOpenRGBRevBController* controller_ptr, bool save);
|
||||
~RGBController_QMKOpenRGBRevB();
|
||||
|
||||
void SetupZones();
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void DeviceUpdateMode();
|
||||
void DeviceSaveMode();
|
||||
|
||||
private:
|
||||
QMKOpenRGBRevBController* controller;
|
||||
std::vector<unsigned int> flat_matrix_map;
|
||||
std::vector<unsigned int> flat_underglow_map;
|
||||
|
||||
void InitializeMode
|
||||
(
|
||||
std::string name,
|
||||
unsigned int ¤t_mode,
|
||||
unsigned int flags,
|
||||
unsigned int color_mode,
|
||||
bool save
|
||||
);
|
||||
|
||||
unsigned int CalculateDivisor
|
||||
(
|
||||
std::vector<point_t> led_points,
|
||||
std::set<int> rows,
|
||||
std::set<int> columns
|
||||
);
|
||||
|
||||
void CountKeyTypes
|
||||
(
|
||||
std::vector<unsigned int> led_flags,
|
||||
unsigned int total_led_count,
|
||||
unsigned int& key_leds,
|
||||
unsigned int& underglow_leds
|
||||
);
|
||||
|
||||
void PlaceLEDsInMaps
|
||||
(
|
||||
std::set<int> unique_rows,
|
||||
std::set<int> unique_cols,
|
||||
unsigned int divisor,
|
||||
std::vector<point_t> led_points,
|
||||
std::vector<unsigned int> led_flags,
|
||||
VectorMatrix& matrix_map_xl,
|
||||
VectorMatrix& underglow_map_xl
|
||||
);
|
||||
|
||||
VectorMatrix MakeEmptyMatrixMap
|
||||
(
|
||||
std::size_t height,
|
||||
std::size_t width
|
||||
);
|
||||
|
||||
void CleanMatrixMaps
|
||||
(
|
||||
VectorMatrix& matrix_map,
|
||||
VectorMatrix& underglow_map,
|
||||
unsigned int height,
|
||||
bool has_underglow
|
||||
);
|
||||
|
||||
std::vector<unsigned int> FlattenMatrixMap
|
||||
(
|
||||
VectorMatrix matrix_map
|
||||
);
|
||||
};
|
||||
+225
-225
@@ -1,225 +1,225 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| QMKOpenRGBRevDController.cpp |
|
||||
| |
|
||||
| Driver for OpenRGB QMK Keyboard Protocol Revision D |
|
||||
| |
|
||||
| Neneya 26 Dec 2021 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "QMKKeycodes.h"
|
||||
#include "QMKOpenRGBRevDController.h"
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
QMKOpenRGBRevDController::QMKOpenRGBRevDController(hid_device *dev_handle, const char *path) :
|
||||
QMKOpenRGBBaseController(dev_handle, path, 15)
|
||||
{
|
||||
}
|
||||
|
||||
QMKOpenRGBRevDController::~QMKOpenRGBRevDController()
|
||||
{
|
||||
}
|
||||
|
||||
std::vector<unsigned int> QMKOpenRGBRevDController::GetLEDValues()
|
||||
{
|
||||
return led_values;
|
||||
}
|
||||
|
||||
void QMKOpenRGBRevDController::GetLEDInfo(unsigned int leds_count)
|
||||
{
|
||||
unsigned int leds_sent = 0;
|
||||
unsigned int leds_per_update_info = 8;
|
||||
|
||||
std::vector<point_t> underglow_points;
|
||||
std::vector<unsigned int> underglow_flags;
|
||||
std::vector<std::string> underglow_names;
|
||||
std::vector<RGBColor> underglow_colors;
|
||||
std::vector<unsigned int> underglow_values;
|
||||
|
||||
while (leds_sent < leds_count)
|
||||
{
|
||||
if ((leds_count - leds_sent) < leds_per_update_info)
|
||||
{
|
||||
leds_per_update_info = leds_count - leds_sent;
|
||||
}
|
||||
|
||||
unsigned char usb_buf[QMK_OPENRGB_PACKET_SIZE];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, QMK_OPENRGB_PACKET_SIZE);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up config table request packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x00;
|
||||
usb_buf[0x01] = QMK_OPENRGB_GET_LED_INFO;
|
||||
usb_buf[0x02] = leds_sent;
|
||||
usb_buf[0x03] = leds_per_update_info;
|
||||
|
||||
int bytes_read = 0;
|
||||
do
|
||||
{
|
||||
hid_write(dev, usb_buf, QMK_OPENRGB_PACKET_SIZE);
|
||||
bytes_read = hid_read_timeout(dev, usb_buf, QMK_OPENRGB_PACKET_SIZE, QMK_OPENRGB_HID_READ_TIMEOUT);
|
||||
} while(bytes_read <= 0);
|
||||
|
||||
for (unsigned int led_idx = 0; led_idx < leds_per_update_info; led_idx++)
|
||||
{
|
||||
unsigned int offset = led_idx * 7;
|
||||
|
||||
if(usb_buf[offset + QMK_OPENRGB_FLAG_BYTE] != QMK_OPENRGB_FAILURE)
|
||||
{
|
||||
if(usb_buf[offset + QMK_OPENRGB_FLAG_BYTE] & 2)
|
||||
{
|
||||
underglow_points.push_back(point_t{usb_buf[offset + QMK_OPENRGB_POINT_X_BYTE], usb_buf[offset + QMK_OPENRGB_POINT_Y_BYTE]});
|
||||
underglow_flags.push_back(usb_buf[offset + QMK_OPENRGB_FLAG_BYTE]);
|
||||
underglow_colors.push_back(ToRGBColor(usb_buf[offset + QMK_OPENRGB_R_COLOR_BYTE], usb_buf[offset + QMK_OPENRGB_G_COLOR_BYTE], usb_buf[offset + QMK_OPENRGB_B_COLOR_BYTE]));
|
||||
underglow_values.push_back((unsigned int)(underglow_values.size() + led_values.size()));
|
||||
}
|
||||
else
|
||||
{
|
||||
led_points.push_back(point_t{usb_buf[offset + QMK_OPENRGB_POINT_X_BYTE], usb_buf[offset + QMK_OPENRGB_POINT_Y_BYTE]});
|
||||
led_flags.push_back(usb_buf[offset + QMK_OPENRGB_FLAG_BYTE]);
|
||||
led_colors.push_back(ToRGBColor(usb_buf[offset + QMK_OPENRGB_R_COLOR_BYTE], usb_buf[offset + QMK_OPENRGB_G_COLOR_BYTE], usb_buf[offset + QMK_OPENRGB_B_COLOR_BYTE]));
|
||||
led_values.push_back((unsigned int)(underglow_values.size() + led_values.size()));
|
||||
}
|
||||
}
|
||||
|
||||
if(usb_buf[offset + QMK_OPENRGB_KEYCODE_BYTE] != 0)
|
||||
{
|
||||
if(qmk_keynames.count(usb_buf[offset + QMK_OPENRGB_KEYCODE_BYTE]) > 0)
|
||||
{
|
||||
led_names.push_back(qmk_keynames[usb_buf[offset + QMK_OPENRGB_KEYCODE_BYTE]]);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_DEBUG("[%s] Key code: %d (%02X) @ offset %d was not found in the QMK keyname map",
|
||||
device_name.c_str(), usb_buf[offset + QMK_OPENRGB_KEYCODE_BYTE],
|
||||
usb_buf[offset + QMK_OPENRGB_KEYCODE_BYTE], leds_sent + led_idx);
|
||||
led_names.push_back(KEY_EN_UNUSED);
|
||||
}
|
||||
}
|
||||
else if(usb_buf[offset + QMK_OPENRGB_FLAG_BYTE] & 2)
|
||||
{
|
||||
underglow_names.push_back("Underglow: " + std::to_string(underglow_names.size() + led_names.size()));
|
||||
}
|
||||
}
|
||||
|
||||
leds_sent += leds_per_update_info;
|
||||
}
|
||||
|
||||
led_points.insert(led_points.end(), underglow_points.begin(), underglow_points.end());
|
||||
led_flags.insert(led_flags.end(), underglow_flags.begin(), underglow_flags.end());
|
||||
led_colors.insert(led_colors.end(), underglow_colors.begin(), underglow_colors.end());
|
||||
led_names.insert(led_names.end(), underglow_names.begin(), underglow_names.end());
|
||||
led_values.insert(led_values.end(), underglow_values.begin(), underglow_values.end());
|
||||
}
|
||||
|
||||
std::vector<unsigned int> QMKOpenRGBRevDController::GetEnabledModes()
|
||||
{
|
||||
unsigned char usb_buf[QMK_OPENRGB_PACKET_SIZE];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, QMK_OPENRGB_PACKET_SIZE);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up config table request packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x00;
|
||||
usb_buf[0x01] = QMK_OPENRGB_GET_ENABLED_MODES;
|
||||
|
||||
int bytes_read = 0;
|
||||
do
|
||||
{
|
||||
hid_write(dev, usb_buf, QMK_OPENRGB_PACKET_SIZE);
|
||||
bytes_read = hid_read_timeout(dev, usb_buf, QMK_OPENRGB_PACKET_SIZE, QMK_OPENRGB_HID_READ_TIMEOUT);
|
||||
} while(bytes_read <= 0);
|
||||
|
||||
std::vector<unsigned int> enabled_modes;
|
||||
int i = 1;
|
||||
while (usb_buf[i] != 0)
|
||||
{
|
||||
enabled_modes.push_back(usb_buf[i]);
|
||||
i++;
|
||||
}
|
||||
return enabled_modes;
|
||||
}
|
||||
|
||||
void QMKOpenRGBRevDController::DirectModeSetSingleLED(unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
unsigned char usb_buf[QMK_OPENRGB_PACKET_SIZE];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, QMK_OPENRGB_PACKET_SIZE);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up config table request packet |
|
||||
\*-----------------------------------------------------*/
|
||||
|
||||
usb_buf[0x00] = 0x00;
|
||||
usb_buf[0x01] = QMK_OPENRGB_DIRECT_MODE_SET_SINGLE_LED;
|
||||
usb_buf[0x02] = led_values[led];
|
||||
usb_buf[0x03] = red;
|
||||
usb_buf[0x04] = green;
|
||||
usb_buf[0x05] = blue;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 65);
|
||||
hid_read_timeout(dev, usb_buf, 65, QMK_OPENRGB_HID_READ_TIMEOUT);
|
||||
}
|
||||
|
||||
void QMKOpenRGBRevDController::DirectModeSetLEDs(std::vector<RGBColor> colors, unsigned int leds_count)
|
||||
{
|
||||
unsigned int leds_sent = 0;
|
||||
unsigned int tmp_leds_per_update = leds_per_update;
|
||||
|
||||
while (leds_sent < leds_count)
|
||||
{
|
||||
if ((leds_count - leds_sent) < tmp_leds_per_update)
|
||||
{
|
||||
tmp_leds_per_update = leds_count - leds_sent;
|
||||
}
|
||||
|
||||
unsigned char usb_buf[QMK_OPENRGB_PACKET_SIZE];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, QMK_OPENRGB_PACKET_SIZE);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up config table request packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x00;
|
||||
usb_buf[0x01] = QMK_OPENRGB_DIRECT_MODE_SET_LEDS;
|
||||
usb_buf[0x02] = tmp_leds_per_update;
|
||||
|
||||
for (unsigned int led_idx = 0; led_idx < tmp_leds_per_update; led_idx++)
|
||||
{
|
||||
usb_buf[(led_idx * 4) + 3] = led_values[led_idx + leds_sent];
|
||||
usb_buf[(led_idx * 4) + 4] = RGBGetRValue(colors[led_idx + leds_sent]);
|
||||
usb_buf[(led_idx * 4) + 5] = RGBGetGValue(colors[led_idx + leds_sent]);
|
||||
usb_buf[(led_idx * 4) + 6] = RGBGetBValue(colors[led_idx + leds_sent]);
|
||||
}
|
||||
|
||||
hid_write(dev, usb_buf, 65);
|
||||
|
||||
if(delay > 0ms)
|
||||
{
|
||||
std::this_thread::sleep_for(delay);
|
||||
}
|
||||
|
||||
leds_sent += tmp_leds_per_update;
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------*\
|
||||
| QMKOpenRGBRevDController.cpp |
|
||||
| |
|
||||
| Driver for OpenRGB QMK Keyboard Protocol Revision D |
|
||||
| |
|
||||
| Neneya 26 Dec 2021 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "QMKKeycodes.h"
|
||||
#include "QMKOpenRGBRevDController.h"
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
QMKOpenRGBRevDController::QMKOpenRGBRevDController(hid_device *dev_handle, const char *path) :
|
||||
QMKOpenRGBBaseController(dev_handle, path, 15)
|
||||
{
|
||||
}
|
||||
|
||||
QMKOpenRGBRevDController::~QMKOpenRGBRevDController()
|
||||
{
|
||||
}
|
||||
|
||||
std::vector<unsigned int> QMKOpenRGBRevDController::GetLEDValues()
|
||||
{
|
||||
return led_values;
|
||||
}
|
||||
|
||||
void QMKOpenRGBRevDController::GetLEDInfo(unsigned int leds_count)
|
||||
{
|
||||
unsigned int leds_sent = 0;
|
||||
unsigned int leds_per_update_info = 8;
|
||||
|
||||
std::vector<point_t> underglow_points;
|
||||
std::vector<unsigned int> underglow_flags;
|
||||
std::vector<std::string> underglow_names;
|
||||
std::vector<RGBColor> underglow_colors;
|
||||
std::vector<unsigned int> underglow_values;
|
||||
|
||||
while (leds_sent < leds_count)
|
||||
{
|
||||
if ((leds_count - leds_sent) < leds_per_update_info)
|
||||
{
|
||||
leds_per_update_info = leds_count - leds_sent;
|
||||
}
|
||||
|
||||
unsigned char usb_buf[QMK_OPENRGB_PACKET_SIZE];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, QMK_OPENRGB_PACKET_SIZE);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up config table request packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x00;
|
||||
usb_buf[0x01] = QMK_OPENRGB_GET_LED_INFO;
|
||||
usb_buf[0x02] = leds_sent;
|
||||
usb_buf[0x03] = leds_per_update_info;
|
||||
|
||||
int bytes_read = 0;
|
||||
do
|
||||
{
|
||||
hid_write(dev, usb_buf, QMK_OPENRGB_PACKET_SIZE);
|
||||
bytes_read = hid_read_timeout(dev, usb_buf, QMK_OPENRGB_PACKET_SIZE, QMK_OPENRGB_HID_READ_TIMEOUT);
|
||||
} while(bytes_read <= 0);
|
||||
|
||||
for (unsigned int led_idx = 0; led_idx < leds_per_update_info; led_idx++)
|
||||
{
|
||||
unsigned int offset = led_idx * 7;
|
||||
|
||||
if(usb_buf[offset + QMK_OPENRGB_FLAG_BYTE] != QMK_OPENRGB_FAILURE)
|
||||
{
|
||||
if(usb_buf[offset + QMK_OPENRGB_FLAG_BYTE] & 2)
|
||||
{
|
||||
underglow_points.push_back(point_t{usb_buf[offset + QMK_OPENRGB_POINT_X_BYTE], usb_buf[offset + QMK_OPENRGB_POINT_Y_BYTE]});
|
||||
underglow_flags.push_back(usb_buf[offset + QMK_OPENRGB_FLAG_BYTE]);
|
||||
underglow_colors.push_back(ToRGBColor(usb_buf[offset + QMK_OPENRGB_R_COLOR_BYTE], usb_buf[offset + QMK_OPENRGB_G_COLOR_BYTE], usb_buf[offset + QMK_OPENRGB_B_COLOR_BYTE]));
|
||||
underglow_values.push_back((unsigned int)(underglow_values.size() + led_values.size()));
|
||||
}
|
||||
else
|
||||
{
|
||||
led_points.push_back(point_t{usb_buf[offset + QMK_OPENRGB_POINT_X_BYTE], usb_buf[offset + QMK_OPENRGB_POINT_Y_BYTE]});
|
||||
led_flags.push_back(usb_buf[offset + QMK_OPENRGB_FLAG_BYTE]);
|
||||
led_colors.push_back(ToRGBColor(usb_buf[offset + QMK_OPENRGB_R_COLOR_BYTE], usb_buf[offset + QMK_OPENRGB_G_COLOR_BYTE], usb_buf[offset + QMK_OPENRGB_B_COLOR_BYTE]));
|
||||
led_values.push_back((unsigned int)(underglow_values.size() + led_values.size()));
|
||||
}
|
||||
}
|
||||
|
||||
if(usb_buf[offset + QMK_OPENRGB_KEYCODE_BYTE] != 0)
|
||||
{
|
||||
if(qmk_keynames.count(usb_buf[offset + QMK_OPENRGB_KEYCODE_BYTE]) > 0)
|
||||
{
|
||||
led_names.push_back(qmk_keynames[usb_buf[offset + QMK_OPENRGB_KEYCODE_BYTE]]);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_DEBUG("[%s] Key code: %d (%02X) @ offset %d was not found in the QMK keyname map",
|
||||
device_name.c_str(), usb_buf[offset + QMK_OPENRGB_KEYCODE_BYTE],
|
||||
usb_buf[offset + QMK_OPENRGB_KEYCODE_BYTE], leds_sent + led_idx);
|
||||
led_names.push_back(KEY_EN_UNUSED);
|
||||
}
|
||||
}
|
||||
else if(usb_buf[offset + QMK_OPENRGB_FLAG_BYTE] & 2)
|
||||
{
|
||||
underglow_names.push_back("Underglow: " + std::to_string(underglow_names.size() + led_names.size()));
|
||||
}
|
||||
}
|
||||
|
||||
leds_sent += leds_per_update_info;
|
||||
}
|
||||
|
||||
led_points.insert(led_points.end(), underglow_points.begin(), underglow_points.end());
|
||||
led_flags.insert(led_flags.end(), underglow_flags.begin(), underglow_flags.end());
|
||||
led_colors.insert(led_colors.end(), underglow_colors.begin(), underglow_colors.end());
|
||||
led_names.insert(led_names.end(), underglow_names.begin(), underglow_names.end());
|
||||
led_values.insert(led_values.end(), underglow_values.begin(), underglow_values.end());
|
||||
}
|
||||
|
||||
std::vector<unsigned int> QMKOpenRGBRevDController::GetEnabledModes()
|
||||
{
|
||||
unsigned char usb_buf[QMK_OPENRGB_PACKET_SIZE];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, QMK_OPENRGB_PACKET_SIZE);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up config table request packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x00;
|
||||
usb_buf[0x01] = QMK_OPENRGB_GET_ENABLED_MODES;
|
||||
|
||||
int bytes_read = 0;
|
||||
do
|
||||
{
|
||||
hid_write(dev, usb_buf, QMK_OPENRGB_PACKET_SIZE);
|
||||
bytes_read = hid_read_timeout(dev, usb_buf, QMK_OPENRGB_PACKET_SIZE, QMK_OPENRGB_HID_READ_TIMEOUT);
|
||||
} while(bytes_read <= 0);
|
||||
|
||||
std::vector<unsigned int> enabled_modes;
|
||||
int i = 1;
|
||||
while (usb_buf[i] != 0)
|
||||
{
|
||||
enabled_modes.push_back(usb_buf[i]);
|
||||
i++;
|
||||
}
|
||||
return enabled_modes;
|
||||
}
|
||||
|
||||
void QMKOpenRGBRevDController::DirectModeSetSingleLED(unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
unsigned char usb_buf[QMK_OPENRGB_PACKET_SIZE];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, QMK_OPENRGB_PACKET_SIZE);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up config table request packet |
|
||||
\*-----------------------------------------------------*/
|
||||
|
||||
usb_buf[0x00] = 0x00;
|
||||
usb_buf[0x01] = QMK_OPENRGB_DIRECT_MODE_SET_SINGLE_LED;
|
||||
usb_buf[0x02] = led_values[led];
|
||||
usb_buf[0x03] = red;
|
||||
usb_buf[0x04] = green;
|
||||
usb_buf[0x05] = blue;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 65);
|
||||
hid_read_timeout(dev, usb_buf, 65, QMK_OPENRGB_HID_READ_TIMEOUT);
|
||||
}
|
||||
|
||||
void QMKOpenRGBRevDController::DirectModeSetLEDs(std::vector<RGBColor> colors, unsigned int leds_count)
|
||||
{
|
||||
unsigned int leds_sent = 0;
|
||||
unsigned int tmp_leds_per_update = leds_per_update;
|
||||
|
||||
while (leds_sent < leds_count)
|
||||
{
|
||||
if ((leds_count - leds_sent) < tmp_leds_per_update)
|
||||
{
|
||||
tmp_leds_per_update = leds_count - leds_sent;
|
||||
}
|
||||
|
||||
unsigned char usb_buf[QMK_OPENRGB_PACKET_SIZE];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, QMK_OPENRGB_PACKET_SIZE);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up config table request packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x00;
|
||||
usb_buf[0x01] = QMK_OPENRGB_DIRECT_MODE_SET_LEDS;
|
||||
usb_buf[0x02] = tmp_leds_per_update;
|
||||
|
||||
for (unsigned int led_idx = 0; led_idx < tmp_leds_per_update; led_idx++)
|
||||
{
|
||||
usb_buf[(led_idx * 4) + 3] = led_values[led_idx + leds_sent];
|
||||
usb_buf[(led_idx * 4) + 4] = RGBGetRValue(colors[led_idx + leds_sent]);
|
||||
usb_buf[(led_idx * 4) + 5] = RGBGetGValue(colors[led_idx + leds_sent]);
|
||||
usb_buf[(led_idx * 4) + 6] = RGBGetBValue(colors[led_idx + leds_sent]);
|
||||
}
|
||||
|
||||
hid_write(dev, usb_buf, 65);
|
||||
|
||||
if(delay > 0ms)
|
||||
{
|
||||
std::this_thread::sleep_for(delay);
|
||||
}
|
||||
|
||||
leds_sent += tmp_leds_per_update;
|
||||
}
|
||||
}
|
||||
+33
-33
@@ -1,33 +1,33 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| QMKOpenRGBRevDController.h |
|
||||
| |
|
||||
| Driver for OpenRGB QMK Keyboard Protocol Revision D |
|
||||
| |
|
||||
| Neneya 26 Dec 2021 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "QMKOpenRGBBaseController.h"
|
||||
|
||||
class QMKOpenRGBRevDController : public QMKOpenRGBBaseController
|
||||
{
|
||||
public:
|
||||
QMKOpenRGBRevDController(hid_device *dev_handle, const char *path);
|
||||
~QMKOpenRGBRevDController();
|
||||
|
||||
//Virtual function implementations
|
||||
void GetLEDInfo(unsigned int leds_count);
|
||||
void DirectModeSetSingleLED(unsigned int led, unsigned char red, unsigned char green, unsigned char blue);
|
||||
void DirectModeSetLEDs(std::vector<RGBColor> colors, unsigned int num_colors);
|
||||
|
||||
//Protocol Specific functions
|
||||
std::vector<unsigned int> GetLEDValues();
|
||||
std::vector<unsigned int> GetEnabledModes();
|
||||
|
||||
private:
|
||||
std::vector<unsigned int> led_values;
|
||||
};
|
||||
/*---------------------------------------------------------*\
|
||||
| QMKOpenRGBRevDController.h |
|
||||
| |
|
||||
| Driver for OpenRGB QMK Keyboard Protocol Revision D |
|
||||
| |
|
||||
| Neneya 26 Dec 2021 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "QMKOpenRGBBaseController.h"
|
||||
|
||||
class QMKOpenRGBRevDController : public QMKOpenRGBBaseController
|
||||
{
|
||||
public:
|
||||
QMKOpenRGBRevDController(hid_device *dev_handle, const char *path);
|
||||
~QMKOpenRGBRevDController();
|
||||
|
||||
//Virtual function implementations
|
||||
void GetLEDInfo(unsigned int leds_count);
|
||||
void DirectModeSetSingleLED(unsigned int led, unsigned char red, unsigned char green, unsigned char blue);
|
||||
void DirectModeSetLEDs(std::vector<RGBColor> colors, unsigned int num_colors);
|
||||
|
||||
//Protocol Specific functions
|
||||
std::vector<unsigned int> GetLEDValues();
|
||||
std::vector<unsigned int> GetEnabledModes();
|
||||
|
||||
private:
|
||||
std::vector<unsigned int> led_values;
|
||||
};
|
||||
+804
-804
File diff suppressed because it is too large.
Load diff
+100
-100
@@ -1,100 +1,100 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController_QMKOpenRGBRevD.h |
|
||||
| |
|
||||
| RGBController for OpenRGB QMK Keyboard Protocol |
|
||||
| Revision D |
|
||||
| |
|
||||
| Neneya 26 Dec 2021 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include "RGBController.h"
|
||||
#include "QMKOpenRGBRevDController.h"
|
||||
|
||||
#define NO_LED 0xFFFFFFFF
|
||||
|
||||
typedef std::vector<std::vector<unsigned int>> VectorMatrix;
|
||||
|
||||
class RGBController_QMKOpenRGBRevD : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_QMKOpenRGBRevD(QMKOpenRGBRevDController* controller_ptr, bool save);
|
||||
~RGBController_QMKOpenRGBRevD();
|
||||
|
||||
void SetupZones();
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void DeviceUpdateMode();
|
||||
void DeviceSaveMode();
|
||||
|
||||
private:
|
||||
QMKOpenRGBRevDController* controller;
|
||||
std::vector<unsigned int> flat_matrix_map;
|
||||
std::vector<unsigned int> flat_underglow_map;
|
||||
|
||||
void InitializeMode
|
||||
(
|
||||
std::string name,
|
||||
unsigned int ¤t_mode,
|
||||
unsigned int flags,
|
||||
unsigned int color_mode,
|
||||
bool save
|
||||
);
|
||||
|
||||
unsigned int CalculateDivisor
|
||||
(
|
||||
std::vector<point_t> led_points,
|
||||
std::set<int> rows,
|
||||
std::set<int> columns
|
||||
);
|
||||
|
||||
void CountKeyTypes
|
||||
(
|
||||
std::vector<unsigned int> led_flags,
|
||||
unsigned int total_led_count,
|
||||
unsigned int& key_leds,
|
||||
unsigned int& underglow_leds
|
||||
);
|
||||
|
||||
void PlaceLEDsInMaps
|
||||
(
|
||||
std::set<int> unique_rows,
|
||||
std::set<int> unique_cols,
|
||||
unsigned int divisor,
|
||||
std::vector<point_t> led_points,
|
||||
std::vector<unsigned int> led_flags,
|
||||
VectorMatrix& matrix_map_xl,
|
||||
VectorMatrix& underglow_map_xl
|
||||
);
|
||||
|
||||
VectorMatrix MakeEmptyMatrixMap
|
||||
(
|
||||
std::size_t height,
|
||||
std::size_t width
|
||||
);
|
||||
|
||||
void CleanMatrixMaps
|
||||
(
|
||||
VectorMatrix& matrix_map,
|
||||
VectorMatrix& underglow_map,
|
||||
unsigned int height,
|
||||
bool has_underglow
|
||||
);
|
||||
|
||||
std::vector<unsigned int> FlattenMatrixMap
|
||||
(
|
||||
VectorMatrix matrix_map
|
||||
);
|
||||
};
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController_QMKOpenRGBRevD.h |
|
||||
| |
|
||||
| RGBController for OpenRGB QMK Keyboard Protocol |
|
||||
| Revision D |
|
||||
| |
|
||||
| Neneya 26 Dec 2021 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include "RGBController.h"
|
||||
#include "QMKOpenRGBRevDController.h"
|
||||
|
||||
#define NO_LED 0xFFFFFFFF
|
||||
|
||||
typedef std::vector<std::vector<unsigned int>> VectorMatrix;
|
||||
|
||||
class RGBController_QMKOpenRGBRevD : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_QMKOpenRGBRevD(QMKOpenRGBRevDController* controller_ptr, bool save);
|
||||
~RGBController_QMKOpenRGBRevD();
|
||||
|
||||
void SetupZones();
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void DeviceUpdateMode();
|
||||
void DeviceSaveMode();
|
||||
|
||||
private:
|
||||
QMKOpenRGBRevDController* controller;
|
||||
std::vector<unsigned int> flat_matrix_map;
|
||||
std::vector<unsigned int> flat_underglow_map;
|
||||
|
||||
void InitializeMode
|
||||
(
|
||||
std::string name,
|
||||
unsigned int ¤t_mode,
|
||||
unsigned int flags,
|
||||
unsigned int color_mode,
|
||||
bool save
|
||||
);
|
||||
|
||||
unsigned int CalculateDivisor
|
||||
(
|
||||
std::vector<point_t> led_points,
|
||||
std::set<int> rows,
|
||||
std::set<int> columns
|
||||
);
|
||||
|
||||
void CountKeyTypes
|
||||
(
|
||||
std::vector<unsigned int> led_flags,
|
||||
unsigned int total_led_count,
|
||||
unsigned int& key_leds,
|
||||
unsigned int& underglow_leds
|
||||
);
|
||||
|
||||
void PlaceLEDsInMaps
|
||||
(
|
||||
std::set<int> unique_rows,
|
||||
std::set<int> unique_cols,
|
||||
unsigned int divisor,
|
||||
std::vector<point_t> led_points,
|
||||
std::vector<unsigned int> led_flags,
|
||||
VectorMatrix& matrix_map_xl,
|
||||
VectorMatrix& underglow_map_xl
|
||||
);
|
||||
|
||||
VectorMatrix MakeEmptyMatrixMap
|
||||
(
|
||||
std::size_t height,
|
||||
std::size_t width
|
||||
);
|
||||
|
||||
void CleanMatrixMaps
|
||||
(
|
||||
VectorMatrix& matrix_map,
|
||||
VectorMatrix& underglow_map,
|
||||
unsigned int height,
|
||||
bool has_underglow
|
||||
);
|
||||
|
||||
std::vector<unsigned int> FlattenMatrixMap
|
||||
(
|
||||
VectorMatrix matrix_map
|
||||
);
|
||||
};
|
||||
+820
-820
File diff suppressed because it is too large.
Load diff
+101
-101
@@ -1,101 +1,101 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController_QMKOpenRGBRevE.h |
|
||||
| |
|
||||
| RGBController for OpenRGB QMK Keyboard Protocol |
|
||||
| Revision E |
|
||||
| |
|
||||
| Neneya 26 Dec 2021 |
|
||||
| HorrorTroll 11 Jul 2022 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include "RGBController.h"
|
||||
#include "QMKOpenRGBRevDController.h"
|
||||
|
||||
#define NO_LED 0xFFFFFFFF
|
||||
|
||||
typedef std::vector<std::vector<unsigned int>> VectorMatrix;
|
||||
|
||||
class RGBController_QMKOpenRGBRevE : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_QMKOpenRGBRevE(QMKOpenRGBRevDController* controller_ptr, bool save);
|
||||
~RGBController_QMKOpenRGBRevE();
|
||||
|
||||
void SetupZones();
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void DeviceUpdateMode();
|
||||
void DeviceSaveMode();
|
||||
|
||||
private:
|
||||
QMKOpenRGBRevDController* controller;
|
||||
std::vector<unsigned int> flat_matrix_map;
|
||||
std::vector<unsigned int> flat_underglow_map;
|
||||
|
||||
void InitializeMode
|
||||
(
|
||||
std::string name,
|
||||
unsigned int ¤t_mode,
|
||||
unsigned int flags,
|
||||
unsigned int color_mode,
|
||||
bool save
|
||||
);
|
||||
|
||||
unsigned int CalculateDivisor
|
||||
(
|
||||
std::vector<point_t> led_points,
|
||||
std::set<int> rows,
|
||||
std::set<int> columns
|
||||
);
|
||||
|
||||
void CountKeyTypes
|
||||
(
|
||||
std::vector<unsigned int> led_flags,
|
||||
unsigned int total_led_count,
|
||||
unsigned int& key_leds,
|
||||
unsigned int& underglow_leds
|
||||
);
|
||||
|
||||
void PlaceLEDsInMaps
|
||||
(
|
||||
std::set<int> unique_rows,
|
||||
std::set<int> unique_cols,
|
||||
unsigned int divisor,
|
||||
std::vector<point_t> led_points,
|
||||
std::vector<unsigned int> led_flags,
|
||||
VectorMatrix& matrix_map_xl,
|
||||
VectorMatrix& underglow_map_xl
|
||||
);
|
||||
|
||||
VectorMatrix MakeEmptyMatrixMap
|
||||
(
|
||||
std::size_t height,
|
||||
std::size_t width
|
||||
);
|
||||
|
||||
void CleanMatrixMaps
|
||||
(
|
||||
VectorMatrix& matrix_map,
|
||||
VectorMatrix& underglow_map,
|
||||
unsigned int height,
|
||||
bool has_underglow
|
||||
);
|
||||
|
||||
std::vector<unsigned int> FlattenMatrixMap
|
||||
(
|
||||
VectorMatrix matrix_map
|
||||
);
|
||||
};
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController_QMKOpenRGBRevE.h |
|
||||
| |
|
||||
| RGBController for OpenRGB QMK Keyboard Protocol |
|
||||
| Revision E |
|
||||
| |
|
||||
| Neneya 26 Dec 2021 |
|
||||
| HorrorTroll 11 Jul 2022 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include "RGBController.h"
|
||||
#include "QMKOpenRGBRevDController.h"
|
||||
|
||||
#define NO_LED 0xFFFFFFFF
|
||||
|
||||
typedef std::vector<std::vector<unsigned int>> VectorMatrix;
|
||||
|
||||
class RGBController_QMKOpenRGBRevE : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_QMKOpenRGBRevE(QMKOpenRGBRevDController* controller_ptr, bool save);
|
||||
~RGBController_QMKOpenRGBRevE();
|
||||
|
||||
void SetupZones();
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void DeviceUpdateMode();
|
||||
void DeviceSaveMode();
|
||||
|
||||
private:
|
||||
QMKOpenRGBRevDController* controller;
|
||||
std::vector<unsigned int> flat_matrix_map;
|
||||
std::vector<unsigned int> flat_underglow_map;
|
||||
|
||||
void InitializeMode
|
||||
(
|
||||
std::string name,
|
||||
unsigned int ¤t_mode,
|
||||
unsigned int flags,
|
||||
unsigned int color_mode,
|
||||
bool save
|
||||
);
|
||||
|
||||
unsigned int CalculateDivisor
|
||||
(
|
||||
std::vector<point_t> led_points,
|
||||
std::set<int> rows,
|
||||
std::set<int> columns
|
||||
);
|
||||
|
||||
void CountKeyTypes
|
||||
(
|
||||
std::vector<unsigned int> led_flags,
|
||||
unsigned int total_led_count,
|
||||
unsigned int& key_leds,
|
||||
unsigned int& underglow_leds
|
||||
);
|
||||
|
||||
void PlaceLEDsInMaps
|
||||
(
|
||||
std::set<int> unique_rows,
|
||||
std::set<int> unique_cols,
|
||||
unsigned int divisor,
|
||||
std::vector<point_t> led_points,
|
||||
std::vector<unsigned int> led_flags,
|
||||
VectorMatrix& matrix_map_xl,
|
||||
VectorMatrix& underglow_map_xl
|
||||
);
|
||||
|
||||
VectorMatrix MakeEmptyMatrixMap
|
||||
(
|
||||
std::size_t height,
|
||||
std::size_t width
|
||||
);
|
||||
|
||||
void CleanMatrixMaps
|
||||
(
|
||||
VectorMatrix& matrix_map,
|
||||
VectorMatrix& underglow_map,
|
||||
unsigned int height,
|
||||
bool has_underglow
|
||||
);
|
||||
|
||||
std::vector<unsigned int> FlattenMatrixMap
|
||||
(
|
||||
VectorMatrix matrix_map
|
||||
);
|
||||
};
|
||||
Reference in new issue
Block a user