Skip to content

Commit

Permalink
Implement getWaveDirection()
Browse files Browse the repository at this point in the history
  • Loading branch information
z3ntu committed Dec 16, 2023
1 parent 5353bc5 commit 21a0308
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
7 changes: 7 additions & 0 deletions include/libopenrazer/led.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ class Led : public QObject
*/
virtual QVector<::openrazer::RGB> getCurrentColors() = 0;

/*!
* Returns the wave direction of this Led
*/
virtual ::openrazer::WaveDirection getWaveDirection() = 0;

/*!
* Returns the Led ID of this Led
*/
Expand Down Expand Up @@ -174,6 +179,7 @@ class Led : public ::libopenrazer::Led
bool hasFx(::openrazer::RazerEffect fx) override;
::openrazer::RazerEffect getCurrentEffect() override;
QVector<::openrazer::RGB> getCurrentColors() override;
::openrazer::WaveDirection getWaveDirection() override;
::openrazer::RazerLedId getLedId() override;
void setOff() override;
void setOn() override;
Expand Down Expand Up @@ -213,6 +219,7 @@ class Led : public ::libopenrazer::Led
bool hasFx(::openrazer::RazerEffect fx) override;
::openrazer::RazerEffect getCurrentEffect() override;
QVector<::openrazer::RGB> getCurrentColors() override;
::openrazer::WaveDirection getWaveDirection() override;
::openrazer::RazerLedId getLedId() override;
void setOff() override;
void setOn() override;
Expand Down
2 changes: 2 additions & 0 deletions src/demo/libopenrazerdemo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ int main(int argc, char *argv[])
qDebug() << " Effect:" << effect;
QVector<openrazer::RGB> colors = led->getCurrentColors();
qDebug() << " Colors:" << colors;
openrazer::WaveDirection waveDirection = led->getWaveDirection();
qDebug() << " Wave direction:" << waveDirection;

for (const libopenrazer::RazerCapability &cap : libopenrazer::ledFxList) {
if (led->hasFx(cap.getIdentifier())) {
Expand Down
13 changes: 13 additions & 0 deletions src/openrazer/led.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,19 @@ QVector<::openrazer::RGB> Led::getCurrentColors()
return colors;
}

::openrazer::WaveDirection Led::getWaveDirection()
{
// OpenRazer doesn't expose get*WaveDir when there's no effect supported.
// Also profile LEDs don't support any wave direction
if (!d->hasFx() || d->isProfileLed()) {
return ::openrazer::WaveDirection::LEFT_TO_RIGHT;
}

QDBusReply<int> reply = d->ledIface()->call("get" + d->lightingLocationMethod + "WaveDir");
int value = handleDBusReply(reply, Q_FUNC_INFO);
return static_cast<::openrazer::WaveDirection>(value);
}

::openrazer::RazerLedId Led::getLedId()
{
return d->ledId;
Expand Down
5 changes: 5 additions & 0 deletions src/razer_test/led.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ QVector<::openrazer::RGB> Led::getCurrentColors()
return handleDBusVariant<QVector<::openrazer::RGB>>(reply, d->ledIface()->lastError(), Q_FUNC_INFO);
}

::openrazer::WaveDirection Led::getWaveDirection()
{
return ::openrazer::WaveDirection::RIGHT_TO_LEFT; // TODO Needs implementation
}

::openrazer::RazerLedId Led::getLedId()
{
QVariant reply = d->ledIface()->property("LedId");
Expand Down

0 comments on commit 21a0308

Please sign in to comment.