mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2026-05-18 11:35:21 -04:00
G815 performance tweaks
* Remove some unnecessary operations on the G815 controller * Use reserved memory for key color array to avoid excessive memory copy on vector pushback Commits squashed and commit message amended by Adam Honse <calcprogrammer1@gmail.com>
This commit is contained in:
@@ -320,7 +320,7 @@ void RGBController_LogitechG815::DeviceUpdateLEDs()
|
||||
if (current_colors[led_idx]==new_colors[led_idx])
|
||||
{
|
||||
/*-------------------------------------------------*\
|
||||
| Not ready for prime. |
|
||||
| Don't send if key color is not changed |
|
||||
\*-------------------------------------------------*/
|
||||
continue;
|
||||
}
|
||||
@@ -363,16 +363,6 @@ void RGBController_LogitechG815::DeviceUpdateLEDs()
|
||||
size_t frame_pos = 3;
|
||||
uint8_t li = 0;
|
||||
|
||||
memset(frame_buffer_big_mode, 0x00, sizeof(frame_buffer_big_mode));
|
||||
memset(frame_buffer_little_mode, 0x00, sizeof(frame_buffer_little_mode));
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Don't ask why but the keyboard needs one 6F |
|
||||
| packet in order to handle a 1F packet with one single led |
|
||||
| color. |
|
||||
\*---------------------------------------------------------*/
|
||||
//logitech->SetDummyBigPacket();
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Create frame_buffers of type 1F (Little, up to 4 leds |
|
||||
| per packet) and 6F (big, up to 13 leds per packet). |
|
||||
@@ -402,19 +392,24 @@ void RGBController_LogitechG815::DeviceUpdateLEDs()
|
||||
frame_pos++;
|
||||
}
|
||||
}
|
||||
|
||||
if (frame_pos < data_size)
|
||||
{
|
||||
/*-----------------------------------------*\
|
||||
| Zeroing just what is needed and if needed |
|
||||
\*-----------------------------------------*/
|
||||
memset(frame_buffer_big_mode + frame_pos, 0x00, sizeof(frame_buffer_big_mode) - frame_pos);
|
||||
|
||||
/*-----------------------------------------*\
|
||||
| End of Data byte |
|
||||
\*-----------------------------------------*/
|
||||
frame_buffer_big_mode[frame_pos] = 0xFF;
|
||||
frame_pos++;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zeroing just what is needed |
|
||||
\*-----------------------------------------------------*/
|
||||
logitech->SetDirect(LOGITECH_G815_ZONE_FRAME_TYPE_BIG, frame_buffer_big_mode);
|
||||
|
||||
memset(frame_buffer_big_mode, 0x00, sizeof(frame_buffer_big_mode));
|
||||
|
||||
bi = bi + max_key_per_color;
|
||||
}
|
||||
}
|
||||
@@ -441,7 +436,6 @@ void RGBController_LogitechG815::DeviceUpdateLEDs()
|
||||
| No End of Data byte if the packet is full |
|
||||
\*-----------------------------------------*/
|
||||
logitech->SetDirect(LOGITECH_G815_ZONE_FRAME_TYPE_LITTLE, frame_buffer_little_mode);
|
||||
memset(frame_buffer_little_mode, 0x00, sizeof(frame_buffer_little_mode));
|
||||
led_in_little_frame=0;
|
||||
}
|
||||
}
|
||||
@@ -455,7 +449,12 @@ void RGBController_LogitechG815::DeviceUpdateLEDs()
|
||||
if(led_in_little_frame > 0)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| End of Data byte |
|
||||
| Zeroing just what is needed |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(frame_buffer_little_mode + (led_in_little_frame * 4 + 1), 0x00, sizeof(frame_buffer_little_mode) - led_in_little_frame * 4);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Data byte |
|
||||
\*-----------------------------------------------------*/
|
||||
frame_buffer_little_mode[led_in_little_frame*4 + 0] = 0xFF;
|
||||
|
||||
@@ -463,7 +462,6 @@ void RGBController_LogitechG815::DeviceUpdateLEDs()
|
||||
| Send little frame and clear little frame buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
logitech->SetDirect(LOGITECH_G815_ZONE_FRAME_TYPE_LITTLE, frame_buffer_little_mode);
|
||||
memset(frame_buffer_little_mode, 0x00, sizeof(frame_buffer_little_mode));
|
||||
}
|
||||
if(ledsByColors.size() > 0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user