diff --git a/include/libopenrazer/device.h b/include/libopenrazer/device.h index 95767c8..d162555 100644 --- a/include/libopenrazer/device.h +++ b/include/libopenrazer/device.h @@ -110,6 +110,26 @@ class Device : public QObject */ virtual ::openrazer::RazerDPI getDPI() = 0; + /*! + * Sets the DPI stages of the mouse to the specified \a dpiStages and sets stage nr. \a activeStage active. + * A maximum of 5 stages are possible. + * The active stage is 1-indexed. + * The DPI value of each must not exceed the maximum DPI of the device. + * + * \sa getDPIStages(), maxDPI() + */ + virtual void setDPIStages(uchar activeStage, QVector<::openrazer::RazerDPI> dpiStages) = 0; + + /*! + * Returns a pair of the active DPI stage and the configured DPI stages of the mouse. + * A maximum of 5 stages are possible. + * The active stage is 1-indexed. + * Ex: 3, [(500, 500), (1500, 1500), (1800, 1800)] + * + * \sa setDPIStages(), maxDPI() + */ + virtual QPair> getDPIStages() = 0; + /*! * Returns the maximum DPI possible for the device. * @@ -180,6 +200,8 @@ class Device : public ::libopenrazer::Device QVector getSupportedPollRates() override; void setDPI(::openrazer::RazerDPI dpi) override; ::openrazer::RazerDPI getDPI() override; + void setDPIStages(uchar activeStage, QVector<::openrazer::RazerDPI> dpiStages) override; + QPair> getDPIStages() override; ushort maxDPI() override; QVector getAllowedDPI() override; void displayCustomFrame() override; @@ -222,6 +244,8 @@ class Device : public ::libopenrazer::Device QVector getSupportedPollRates() override; void setDPI(::openrazer::RazerDPI dpi) override; ::openrazer::RazerDPI getDPI() override; + void setDPIStages(uchar activeStage, QVector<::openrazer::RazerDPI> dpiStages) override; + QPair> getDPIStages() override; ushort maxDPI() override; QVector getAllowedDPI() override; void displayCustomFrame() override; diff --git a/include/libopenrazer/openrazer.h b/include/libopenrazer/openrazer.h index 62a54dd..c6111e2 100644 --- a/include/libopenrazer/openrazer.h +++ b/include/libopenrazer/openrazer.h @@ -293,6 +293,8 @@ inline void registerMetaTypes() qDBusRegisterMetaType(); qRegisterMetaType>("QVector"); qDBusRegisterMetaType>(); + qRegisterMetaType>>("QPair>"); + qDBusRegisterMetaType>>(); qRegisterMetaType("ReactiveSpeed"); qDBusRegisterMetaType(); diff --git a/src/demo/libopenrazerdemo.cpp b/src/demo/libopenrazerdemo.cpp index e7cf930..68db3f7 100644 --- a/src/demo/libopenrazerdemo.cpp +++ b/src/demo/libopenrazerdemo.cpp @@ -132,6 +132,13 @@ int main(int argc, char *argv[]) } else { device->setDPI({ 500, 500 }); } + if (device->hasFeature("dpi_stages")) { + QPair> dpiStages = device->getDPIStages(); + qDebug() << "DPI stages:" << dpiStages; + device->setDPIStages(2, { { 400, 500 }, { 600, 700 }, { 800, 900 } }); + // restore DPI stages + device->setDPIStages(dpiStages.first, dpiStages.second); + } qDebug() << "Maximum DPI:" << device->maxDPI(); // restore DPI device->setDPI(dpi); diff --git a/src/openrazer/device.cpp b/src/openrazer/device.cpp index f554481..9a5a985 100644 --- a/src/openrazer/device.cpp +++ b/src/openrazer/device.cpp @@ -79,6 +79,8 @@ void DevicePrivate::setupCapabilities() supportedFeatures.append("dpi"); if (hasCapabilityInternal("razer.device.dpi", "availableDPI")) supportedFeatures.append("restricted_dpi"); + if (hasCapabilityInternal("razer.device.dpi", "setDPIStages")) + supportedFeatures.append("dpi_stages"); if (hasCapabilityInternal("razer.device.misc", "setPollRate")) supportedFeatures.append("poll_rate"); if (hasCapabilityInternal("razer.device.lighting.chroma", "setCustom")) @@ -249,6 +251,18 @@ ::openrazer::RazerDPI Device::getDPI() } } +void Device::setDPIStages(uchar activeStage, QVector<::openrazer::RazerDPI> dpiStages) +{ + QDBusReply reply = d->deviceDpiIface()->call("setDPIStages", QVariant::fromValue(activeStage), QVariant::fromValue(dpiStages)); + handleDBusReply(reply, Q_FUNC_INFO); +} + +QPair> Device::getDPIStages() +{ + QDBusReply>> reply = d->deviceDpiIface()->call("getDPIStages"); + return handleDBusReply(reply, Q_FUNC_INFO); +} + ushort Device::maxDPI() { QDBusReply reply = d->deviceDpiIface()->call("maxDPI"); diff --git a/src/razer_test/device.cpp b/src/razer_test/device.cpp index 63a741a..8759268 100644 --- a/src/razer_test/device.cpp +++ b/src/razer_test/device.cpp @@ -136,6 +136,17 @@ ::openrazer::RazerDPI Device::getDPI() return handleDBusReply(reply, Q_FUNC_INFO); } +void Device::setDPIStages(uchar activeStage, QVector<::openrazer::RazerDPI> dpiStages) +{ + // TODO Needs implementation +} + +QPair> Device::getDPIStages() +{ + // TODO Needs implementation + return { 0, {} }; +} + ushort Device::maxDPI() { QDBusReply reply = d->deviceIface()->call("getMaxDPI");