Skip to content

Commit

Permalink
Add support for the 'wheel' effect
Browse files Browse the repository at this point in the history
As seen on BlackWidow V4 Pro
  • Loading branch information
z3ntu committed Oct 17, 2023
1 parent 2e13550 commit 5e5a0ae
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/ledwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,11 @@ LedWidget::LedWidget(QWidget *parent, libopenrazer::Led *led)
connect(colorButton, &QPushButton::clicked, this, &LedWidget::colorButtonClicked);
}

/* Wave left/right radio buttons */
/* Wave & wheel radio buttons */
for (int i = 1; i <= 2; i++) {
QString name;
// TODO: Use Clockwise & Counterclockwise labels for Wheel
// TODO: Also use Clockwise & Counterclockwise for mousepads
if (i == 1)
name = tr("Left");
else
Expand All @@ -119,7 +121,7 @@ LedWidget::LedWidget(QWidget *parent, libopenrazer::Led *led)
if (i == 1) // set the 'left' checkbox to activated
radio->setChecked(true);
// Hide radio button when we don't need it
if (currentEffect != openrazer::RazerEffect::Wave) {
if (currentEffect != openrazer::RazerEffect::Wave && currentEffect != openrazer::RazerEffect::Wheel) {
radio->hide();
}
lightingHBox->addWidget(radio);
Expand Down Expand Up @@ -199,7 +201,7 @@ void LedWidget::fxComboboxChanged(int index)
}

// Show/hide the wave radiobuttons
if (capability.getIdentifier() != openrazer::RazerEffect::Wave) {
if (capability.getIdentifier() != openrazer::RazerEffect::Wave && capability.getIdentifier() != openrazer::RazerEffect::Wheel) {
findChild<QRadioButton *>("radiobutton1")->hide();
findChild<QRadioButton *>("radiobutton2")->hide();
} else {
Expand All @@ -225,6 +227,13 @@ openrazer::WaveDirection LedWidget::getWaveDirection()
return findChild<QRadioButton *>("radiobutton1")->isChecked() ? openrazer::WaveDirection::RIGHT_TO_LEFT : openrazer::WaveDirection::LEFT_TO_RIGHT;
}

openrazer::WheelDirection LedWidget::getWheelDirection()
{
return findChild<QRadioButton *>("radiobutton1")->isChecked()
? openrazer::WheelDirection::CLOCKWISE
: openrazer::WheelDirection::COUNTER_CLOCKWISE;
}

void LedWidget::brightnessSliderChanged(int value)
{
try {
Expand Down Expand Up @@ -284,6 +293,10 @@ void LedWidget::applyEffectStandardLoc(openrazer::RazerEffect effect)
mLed->setWave(getWaveDirection());
break;
}
case openrazer::RazerEffect::Wheel: {
mLed->setWheel(getWheelDirection());
break;
}
case openrazer::RazerEffect::Reactive: {
openrazer::RGB c = getColorForButton(1);
mLed->setReactive(c, openrazer::ReactiveSpeed::_500MS); // TODO Configure speed?
Expand Down
1 change: 1 addition & 0 deletions src/ledwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class LedWidget : public QWidget

openrazer::RGB getColorForButton(int num);
openrazer::WaveDirection getWaveDirection();
openrazer::WheelDirection getWheelDirection();

void applyEffect();
void applyEffectStandardLoc(openrazer::RazerEffect identifier);
Expand Down

0 comments on commit 5e5a0ae

Please sign in to comment.