Just set active_mode rather than call SetMode for SetCustomModefunction. Implement for a few tested devices only for now. Fix some user interface issues with custom mode selection.
This commit is contained in:
parent
966297710b
commit
6828335dc5
5 changed files with 85 additions and 69 deletions
|
|
@ -144,6 +144,12 @@ RGBController_CorsairKeyboard::RGBController_CorsairKeyboard(CorsairKeyboardCont
|
|||
name = "Corsair RGB Keyboard";
|
||||
type = DEVICE_TYPE_KEYBOARD;
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = 0;
|
||||
Direct.flags = MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR;
|
||||
modes.push_back(Direct);
|
||||
|
||||
colors.resize(111);
|
||||
|
||||
unsigned int led_idx = 0;
|
||||
|
|
@ -193,7 +199,7 @@ void RGBController_CorsairKeyboard::UpdateSingleLED(int led)
|
|||
|
||||
void RGBController_CorsairKeyboard::SetCustomMode()
|
||||
{
|
||||
|
||||
active_mode = 0;
|
||||
}
|
||||
|
||||
void RGBController_CorsairKeyboard::UpdateMode()
|
||||
|
|
|
|||
|
|
@ -251,7 +251,7 @@ void RGBController_HyperXKeyboard::UpdateSingleLED(int led)
|
|||
|
||||
void RGBController_HyperXKeyboard::SetCustomMode()
|
||||
{
|
||||
SetMode(0);
|
||||
active_mode = 1;
|
||||
}
|
||||
|
||||
void RGBController_HyperXKeyboard::UpdateMode()
|
||||
|
|
|
|||
|
|
@ -229,7 +229,7 @@ void RGBController_PoseidonZRGB::UpdateSingleLED(int led)
|
|||
|
||||
void RGBController_PoseidonZRGB::SetCustomMode()
|
||||
{
|
||||
SetMode(0);
|
||||
active_mode = 0;
|
||||
}
|
||||
|
||||
void RGBController_PoseidonZRGB::UpdateMode()
|
||||
|
|
|
|||
|
|
@ -126,10 +126,10 @@ int RGBController_RGBFusion::GetDeviceMode()
|
|||
|
||||
void RGBController_RGBFusion::SetCustomMode()
|
||||
{
|
||||
rgb_fusion->SetMode(RGB_FUSION_MODE_STATIC, 0);
|
||||
active_mode = 0;
|
||||
}
|
||||
|
||||
void RGBController_RGBFusion::UpdateMode()
|
||||
{
|
||||
rgb_fusion->SetMode(modes[active_mode].value, modes[active_mode].speed);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -240,6 +240,8 @@ void Ui::OpenRGBDevicePage::UpdateModeUi()
|
|||
|
||||
if(supports_speed)
|
||||
{
|
||||
ui->SpeedSlider->blockSignals(true);
|
||||
|
||||
if(device->modes[selected_mode].speed_min > device->modes[selected_mode].speed_max)
|
||||
{
|
||||
InvertedSpeed = true;
|
||||
|
|
@ -255,10 +257,13 @@ void Ui::OpenRGBDevicePage::UpdateModeUi()
|
|||
|
||||
ui->SpeedSlider->setValue(device->modes[selected_mode].speed);
|
||||
ui->SpeedSlider->setEnabled(true);
|
||||
ui->SpeedSlider->blockSignals(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->SpeedSlider->blockSignals(true);
|
||||
ui->SpeedSlider->setEnabled(false);
|
||||
ui->SpeedSlider->blockSignals(false);
|
||||
}
|
||||
|
||||
ui->DirectionBox->clear();
|
||||
|
|
@ -348,84 +353,88 @@ void Ui::OpenRGBDevicePage::UpdateMode()
|
|||
| Read user interface |
|
||||
\*-----------------------------------------------------*/
|
||||
int current_mode = ui->ModeBox->currentIndex();
|
||||
int current_speed = 0;
|
||||
bool current_random = ui->RandomCheck->checkState();
|
||||
int current_dir_idx = ui->DirectionBox->currentIndex();
|
||||
int current_direction = 0;
|
||||
bool supports_dir_lr = ( device->modes[current_mode].flags & MODE_FLAG_HAS_DIRECTION_LR );
|
||||
bool supports_dir_ud = ( device->modes[current_mode].flags & MODE_FLAG_HAS_DIRECTION_UD );
|
||||
bool supports_dir_hv = ( device->modes[current_mode].flags & MODE_FLAG_HAS_DIRECTION_HV );
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set the direction value |
|
||||
\*-----------------------------------------------------*/
|
||||
if(supports_dir_hv)
|
||||
if(current_mode >= 0)
|
||||
{
|
||||
if(supports_dir_lr && supports_dir_ud)
|
||||
int current_speed = 0;
|
||||
bool current_random = ui->RandomCheck->checkState();
|
||||
int current_dir_idx = ui->DirectionBox->currentIndex();
|
||||
int current_direction = 0;
|
||||
bool supports_dir_lr = ( device->modes[current_mode].flags & MODE_FLAG_HAS_DIRECTION_LR );
|
||||
bool supports_dir_ud = ( device->modes[current_mode].flags & MODE_FLAG_HAS_DIRECTION_UD );
|
||||
bool supports_dir_hv = ( device->modes[current_mode].flags & MODE_FLAG_HAS_DIRECTION_HV );
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set the direction value |
|
||||
\*-----------------------------------------------------*/
|
||||
if(supports_dir_hv)
|
||||
{
|
||||
if(supports_dir_lr && supports_dir_ud)
|
||||
{
|
||||
current_direction = current_dir_idx;
|
||||
}
|
||||
else if(supports_dir_lr || supports_dir_ud)
|
||||
{
|
||||
current_direction = current_dir_idx + 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
current_direction = current_dir_idx + 4;
|
||||
}
|
||||
}
|
||||
|
||||
if(supports_dir_ud)
|
||||
{
|
||||
if(supports_dir_lr)
|
||||
{
|
||||
current_direction = current_dir_idx;
|
||||
}
|
||||
else
|
||||
{
|
||||
current_direction = current_dir_idx + 2;
|
||||
}
|
||||
}
|
||||
|
||||
if((supports_dir_lr)
|
||||
&&(current_dir_idx < 2))
|
||||
{
|
||||
current_direction = current_dir_idx;
|
||||
}
|
||||
else if(supports_dir_lr || supports_dir_ud)
|
||||
{
|
||||
current_direction = current_dir_idx + 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
current_direction = current_dir_idx + 4;
|
||||
}
|
||||
}
|
||||
|
||||
if(supports_dir_ud)
|
||||
{
|
||||
if(supports_dir_lr)
|
||||
{
|
||||
current_direction = current_dir_idx;
|
||||
}
|
||||
else
|
||||
{
|
||||
current_direction = current_dir_idx + 2;
|
||||
}
|
||||
}
|
||||
|
||||
if((supports_dir_lr)
|
||||
&&(current_dir_idx < 2))
|
||||
{
|
||||
current_direction = current_dir_idx;
|
||||
}
|
||||
|
||||
device->modes[current_mode].direction = current_direction;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| If Speed Slider is enabled, read the speed value |
|
||||
\*-----------------------------------------------------*/
|
||||
if(ui->SpeedSlider->isEnabled())
|
||||
{
|
||||
current_speed = ui->SpeedSlider->value();
|
||||
device->modes[current_mode].direction = current_direction;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| If Speed Slider is inverted, invert value |
|
||||
| If Speed Slider is enabled, read the speed value |
|
||||
\*-----------------------------------------------------*/
|
||||
if(InvertedSpeed)
|
||||
if(ui->SpeedSlider->isEnabled())
|
||||
{
|
||||
current_speed = device->modes[current_mode].speed_min - current_speed + device->modes[current_mode].speed_max;
|
||||
current_speed = ui->SpeedSlider->value();
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| If Speed Slider is inverted, invert value |
|
||||
\*-----------------------------------------------------*/
|
||||
if(InvertedSpeed)
|
||||
{
|
||||
current_speed = device->modes[current_mode].speed_min - current_speed + device->modes[current_mode].speed_max;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Don't set the mode if the current mode is invalid |
|
||||
\*-----------------------------------------------------*/
|
||||
if(current_mode < device->modes.size())
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Update mode parameters |
|
||||
\*-----------------------------------------------------*/
|
||||
device->modes[current_mode].speed = current_speed;
|
||||
device->modes[current_mode].random = current_random;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Change device mode |
|
||||
| Don't set the mode if the current mode is invalid |
|
||||
\*-----------------------------------------------------*/
|
||||
device->SetMode(current_mode);
|
||||
if(current_mode < device->modes.size())
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Update mode parameters |
|
||||
\*-----------------------------------------------------*/
|
||||
device->modes[current_mode].speed = current_speed;
|
||||
device->modes[current_mode].random = current_random;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Change device mode |
|
||||
\*-----------------------------------------------------*/
|
||||
device->SetMode(current_mode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -448,6 +457,7 @@ void Ui::OpenRGBDevicePage::SetCustomMode()
|
|||
ui->ModeBox->setCurrentIndex(device->active_mode);
|
||||
ui->ModeBox->blockSignals(false);
|
||||
UpdateModeUi();
|
||||
UpdateMode();
|
||||
}
|
||||
|
||||
void Ui::OpenRGBDevicePage::on_SetDeviceButton_clicked()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue