From 21a030807ea60286d6cdb3d76d277569fe60e31a Mon Sep 17 00:00:00 2001 From: Luca Weiss Date: Wed, 11 Nov 2020 21:17:59 +0100 Subject: [PATCH] Implement getWaveDirection() --- include/libopenrazer/led.h | 7 +++++++ src/demo/libopenrazerdemo.cpp | 2 ++ src/openrazer/led.cpp | 13 +++++++++++++ src/razer_test/led.cpp | 5 +++++ 4 files changed, 27 insertions(+) diff --git a/include/libopenrazer/led.h b/include/libopenrazer/led.h index e736b00..ce1b315 100644 --- a/include/libopenrazer/led.h +++ b/include/libopenrazer/led.h @@ -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 */ @@ -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; @@ -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; diff --git a/src/demo/libopenrazerdemo.cpp b/src/demo/libopenrazerdemo.cpp index e8a8c33..e7cf930 100644 --- a/src/demo/libopenrazerdemo.cpp +++ b/src/demo/libopenrazerdemo.cpp @@ -161,6 +161,8 @@ int main(int argc, char *argv[]) qDebug() << " Effect:" << effect; QVector 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())) { diff --git a/src/openrazer/led.cpp b/src/openrazer/led.cpp index f6e2dd3..3b3e725 100644 --- a/src/openrazer/led.cpp +++ b/src/openrazer/led.cpp @@ -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 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; diff --git a/src/razer_test/led.cpp b/src/razer_test/led.cpp index ccef252..2cb9774 100644 --- a/src/razer_test/led.cpp +++ b/src/razer_test/led.cpp @@ -87,6 +87,11 @@ QVector<::openrazer::RGB> Led::getCurrentColors() return handleDBusVariant>(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");