diff --git a/RGBController/RGBController.h b/RGBController/RGBController.h index fd5cc2c6..485c6e08 100644 --- a/RGBController/RGBController.h +++ b/RGBController/RGBController.h @@ -35,6 +35,19 @@ enum MODE_FLAG_PER_LED_COLOR = (1 << 7), /* Mode uses device LED colors */ }; +/*------------------------------------------------------------------*\ +| Mode Directions | +\*------------------------------------------------------------------*/ +enum +{ + MODE_DIRECTION_LEFT = 0, /* Mode direction left */ + MODE_DIRECTION_RIGHT = 1, /* Mode direction right */ + MODE_DIRECTION_UP = 2, /* Mode direction up */ + MODE_DIRECTION_DOWN = 3, /* Mode direction down */ + MODE_DIRECTION_HORIZONTAL = 4, /* Mode direction horizontal */ + MODE_DIRECTION_VERTICAL = 5, /* Mode direction vertical */ +}; + /*------------------------------------------------------------------*\ | Mode Type | \*------------------------------------------------------------------*/ @@ -53,6 +66,7 @@ typedef struct | Mode Settings | \*--------------------------------------------------------------*/ unsigned int speed; /* Mode speed parameter value */ + unsigned int direction; /* Mode direction value */ bool random; /* Random color mode enabled */ } mode; diff --git a/qt/OpenRGBDevicePage.cpp b/qt/OpenRGBDevicePage.cpp index 790ab2ce..beb3bcc7 100644 --- a/qt/OpenRGBDevicePage.cpp +++ b/qt/OpenRGBDevicePage.cpp @@ -153,7 +153,15 @@ void Ui::OpenRGBDevicePage::on_RandomCheck_clicked() UpdateMode(); } -void Ui::OpenRGBDevicePage::on_SpeedSlider_valueChanged(int value) +void Ui::OpenRGBDevicePage::on_SpeedSlider_valueChanged(int /*value*/) +{ + /*-----------------------------------------------------*\ + | Change device mode | + \*-----------------------------------------------------*/ + UpdateMode(); +} + +void Ui::OpenRGBDevicePage::on_DirectionBox_currentIndexChanged(int /*index*/) { /*-----------------------------------------------------*\ | Change device mode | @@ -176,7 +184,11 @@ void Ui::OpenRGBDevicePage::UpdateModeUi() bool supports_random = ( device->modes[selected_mode].flags & MODE_FLAG_HAS_COLOR ) && ( device->modes[selected_mode].flags & MODE_FLAG_RANDOM_COLOR ); bool supports_speed = ( device->modes[selected_mode].flags & MODE_FLAG_HAS_SPEED ); + bool supports_dir_lr = ( device->modes[selected_mode].flags & MODE_FLAG_HAS_DIRECTION_LR ); + bool supports_dir_ud = ( device->modes[selected_mode].flags & MODE_FLAG_HAS_DIRECTION_UD ); + bool supports_dir_hv = ( device->modes[selected_mode].flags & MODE_FLAG_HAS_DIRECTION_HV ); bool random = device->modes[selected_mode].random; + unsigned int dir = device->modes[selected_mode].direction; if(supports_speed) { @@ -200,6 +212,74 @@ void Ui::OpenRGBDevicePage::UpdateModeUi() { ui->SpeedSlider->setEnabled(false); } + + ui->DirectionBox->clear(); + + if(supports_dir_lr) + { + ui->DirectionBox->addItem("Left"); + ui->DirectionBox->addItem("Right"); + } + + if(supports_dir_ud) + { + ui->DirectionBox->addItem("Up"); + ui->DirectionBox->addItem("Down"); + } + + if(supports_dir_hv) + { + ui->DirectionBox->addItem("Horizontal"); + ui->DirectionBox->addItem("Vertical"); + } + + if(supports_dir_lr || supports_dir_ud || supports_dir_hv) + { + if((supports_dir_lr) + &&((dir == MODE_DIRECTION_LEFT) + ||(dir == MODE_DIRECTION_RIGHT))) + { + ui->DirectionBox->setCurrentIndex(dir); + } + + if((supports_dir_ud) + &&((dir == MODE_DIRECTION_UP) + ||(dir == MODE_DIRECTION_DOWN))) + { + if(supports_dir_lr) + { + ui->DirectionBox->setCurrentIndex(dir); + } + else + { + ui->DirectionBox->setCurrentIndex(dir - 2); + } + } + + if((supports_dir_hv) + &&((dir == MODE_DIRECTION_HORIZONTAL) + ||(dir == MODE_DIRECTION_VERTICAL))) + { + if(supports_dir_lr && supports_dir_ud) + { + ui->DirectionBox->setCurrentIndex(dir); + } + else if(supports_dir_lr || supports_dir_ud) + { + ui->DirectionBox->setCurrentIndex(dir - 2); + } + else + { + ui->DirectionBox->setCurrentIndex(dir - 4); + } + } + + ui->DirectionBox->setEnabled(true); + } + else + { + ui->DirectionBox->setEnabled(false); + } if(supports_random) { @@ -218,9 +298,53 @@ void Ui::OpenRGBDevicePage::UpdateMode() /*-----------------------------------------------------*\ | Read user interface | \*-----------------------------------------------------*/ - int current_mode = ui->ModeBox->currentIndex(); - int current_speed = ui->SpeedSlider->value(); - bool current_random = ui->RandomCheck->checkState(); + int current_mode = ui->ModeBox->currentIndex(); + int current_speed = ui->SpeedSlider->value(); + 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; + } + + device->modes[current_mode].direction = current_direction; /*-----------------------------------------------------*\ | If Speed Slider is inverted, invert value | diff --git a/qt/OpenRGBDevicePage.h b/qt/OpenRGBDevicePage.h index 8d82a990..53b9995f 100644 --- a/qt/OpenRGBDevicePage.h +++ b/qt/OpenRGBDevicePage.h @@ -48,6 +48,8 @@ private slots: void on_SpeedSlider_valueChanged(int value); + void on_DirectionBox_currentIndexChanged(int index); + private: Ui::OpenRGBDevicePageUi *ui; RGBController *device; diff --git a/qt/OpenRGBDevicePage.ui b/qt/OpenRGBDevicePage.ui index 46f549a2..893c7d99 100644 --- a/qt/OpenRGBDevicePage.ui +++ b/qt/OpenRGBDevicePage.ui @@ -17,7 +17,7 @@ 71 - 50 + 30 160 22 @@ -27,7 +27,7 @@ 31 - 50 + 30 40 22 @@ -40,7 +40,7 @@ 31 - 90 + 70 40 22 @@ -53,7 +53,7 @@ 71 - 90 + 70 160 22 @@ -63,7 +63,7 @@ 31 - 210 + 190 40 22 @@ -76,7 +76,7 @@ 71 - 210 + 190 160 22 @@ -86,7 +86,7 @@ 190 - 140 + 120 41 22 @@ -99,7 +99,7 @@ 130 - 140 + 120 41 22 @@ -346,7 +346,7 @@ 70 - 140 + 120 41 22 @@ -359,7 +359,7 @@ 30 - 140 + 120 40 22 @@ -372,7 +372,7 @@ 110 - 170 + 150 80 22 @@ -385,7 +385,7 @@ 100 - 240 + 220 100 20 @@ -398,7 +398,7 @@ 70 - 270 + 240 160 22 @@ -411,7 +411,7 @@ 30 - 270 + 240 40 22 @@ -420,6 +420,29 @@ Speed: + + + + 70 + 270 + 160 + 22 + + + + + + + 30 + 270 + 40 + 22 + + + + Dir: + +