From b938bf6c1d9724943f2ec2d555d8860b9f68a41a Mon Sep 17 00:00:00 2001 From: Kevin Pearson Date: Thu, 26 Sep 2019 08:50:46 -0400 Subject: [PATCH] Add ripple and off effects NOTE: Ripple effect (0x05) seems to have a conflict with an unadvertised "stars"-like effect for the G410 and G810. Did not explore setting timing for the G410/G810 effect, but is likely contrasted greatly with the timing of the new Ripple effect. GHub limits ripple timing between 20ms and 200ms, but actual values are arbitrary and were tested up to 5000ms. Ideally should be kept within the 20-200ms range for best feel of the effect. Logo does not honor the effect, and GHub simply sets to the default "Logitech Blue". Signed-off-by: Kevin Pearson --- src/classes/Keyboard.cpp | 20 ++++++++++++++++++++ src/classes/Keyboard.h | 10 +++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/classes/Keyboard.cpp b/src/classes/Keyboard.cpp index 1268fcb..8e9fa05 100644 --- a/src/classes/Keyboard.cpp +++ b/src/classes/Keyboard.cpp @@ -739,12 +739,15 @@ bool LedKeyboard::setNativeEffect(NativeEffect effect, NativeEffectPart part, break; case NativeEffectGroup::cycle: case NativeEffectGroup::waves: + case NativeEffectGroup::ripple: if (! setGroupKeys( LedKeyboard::KeyGroup::indicators, LedKeyboard::Color({0xff, 0xff, 0xff})) ) return false; if (! commit()) return false; break; + default: + break; } return ( setNativeEffect(effect, LedKeyboard::NativeEffectPart::keys, period, color, storage) && @@ -810,6 +813,19 @@ bool LedKeyboard::setNativeEffect(NativeEffect effect, NativeEffectPart part, switch (part) { case NativeEffectPart::keys: data[4] = 0x01; + + //Seems to conflict with a star-like effect on G410 and G810 + switch (effect) { + case NativeEffect::ripple: + //Adjust periodicity + data[9]=0x00; + data[10]=period.count() >> 8 & 0xff;; + data[11]=period.count() & 0xff; + data[12]=0x00; + break; + default: + break; + } break; case NativeEffectPart::logo: data[4] = 0x00; @@ -827,6 +843,10 @@ bool LedKeyboard::setNativeEffect(NativeEffect effect, NativeEffectPart part, case NativeEffect::cycle: data[5]=0x02; break; + case NativeEffect::ripple: + case NativeEffect::off: + data[5]=0x00; + break; default: data[5]=0x01; break; diff --git a/src/classes/Keyboard.h b/src/classes/Keyboard.h index 6579835..74505e2 100644 --- a/src/classes/Keyboard.h +++ b/src/classes/Keyboard.h @@ -79,19 +79,23 @@ class LedKeyboard { color }; enum class NativeEffectGroup : uint8_t { - color = 0x01, + off, + color, breathing, cycle, - waves + waves, + ripple }; enum class NativeEffect : uint16_t { + off, color = static_cast(NativeEffectGroup::color) << 8, breathing = static_cast(NativeEffectGroup::breathing) << 8, cycle = static_cast(NativeEffectGroup::cycle) << 8, waves = static_cast(NativeEffectGroup::waves) << 8, hwave, vwave, - cwave + cwave, + ripple = static_cast(NativeEffectGroup::ripple) << 8 }; enum class NativeEffectPart : uint8_t { all = 0xff,