From 1e59f3688fe183f64941bd3df6fc9ff6a6afa301 Mon Sep 17 00:00:00 2001 From: Janneske2001 Date: Wed, 10 Jun 2026 12:34:53 +0200 Subject: [PATCH 1/4] Added speed modifier --- .gitignore | 3 +++ CppKeyboardColour/CppKeyboardColour.cpp | Bin 5650 -> 7156 bytes CppKeyboardColour/IKeyboard.h | 4 +++- CppKeyboardColour/Keyboard.cpp | 24 ++++++++++++++++-------- CppKeyboardColour/Keyboard.h | 4 ++++ CppKeyboardColour/ThemeCommandLine.cpp | 14 ++++++++++++++ CppKeyboardColour/ThemeCommandLine.h | 4 +++- CppKeyboardColour/stdafx.cpp | Bin 610 -> 482 bytes 8 files changed, 43 insertions(+), 10 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..75bd5ee --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +Debug/ +x64/ +.vs/ \ No newline at end of file diff --git a/CppKeyboardColour/CppKeyboardColour.cpp b/CppKeyboardColour/CppKeyboardColour.cpp index b49d4ece19e67892b7a9ca99dd0da3b74c06379f..bddcd1776e52d5850b925d8ecc28e7c7f39946bf 100644 GIT binary patch literal 7156 zcmd6sYfl?T6o%((EA>BYs9L#EV}~fM6iSf@kP3wa1WwwhjV#9)Vujd_*FX^BueW{P zIiBooyoOxV%CdKNcIM2vyyrIl=kJzlxx{U_iR-(roAP_e^DB43?#(nL--!fy!oD+A-+CJ-+T*|CN=pDKDuIXMgqS>*T+wL)IF4%Fz{0Xb- z=ZlB8e7fv;=yv?x{RL~-%D`Q)n)!3v3C#oMsRzvVCMtR-!Zz828UiR;#?Zt zLbrYHr#Tv?r7@Jd?$}G2xO1J zyLGW(0uMx(Q8PZnJgR~j!vYHz| z_xF>T{?^?0p2FK4deWKZ0{=y6!l+?dJDtMuz`f(zM~h?ln7CCWSoh6kQq^wLMd?!vj z9r(A332!5FwA*92>42VHY`w+ZhDTVN=O?qhg^nOwxTauwfIK~xgl$kyME_l7{W|$9@!!>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1{|Lp3m36h= zndK*YvBeP7VhvS4n^|(Q4|@QVx0!t|*kSP;qEHb~Yfn53kO%M^$>ihqD6t``!=;?L(ixfuRzwPIvWrj%!aOW40{NClSV10|0Kmzj zgrO8j=K<|8geDKp$&teOz$6J${YH2ekku<<%8e8=V3|K6yTCCHisuKSO2FiZSetColour(0x00, 0x00, 0xFF, Zone::ALL); } +void Keyboard::SetSpeedFactor(float factor) +{ + m_speedFactor = factor; +} + void Keyboard::Animate(IAnimation& animation) { - for (size_t i = 0; i < animation.Size(); ++i) - { - if (const auto frame = animation.GetFrame(i)) - { - m_ptrKbComms->SetKBColour(frame->zone, frame->colour); - std::this_thread::sleep_for(millisec(frame->ms_time)); - } - } + for (size_t i = 0; i < animation.Size(); ++i) + { + if (const auto frame = animation.GetFrame(i)) + { + m_ptrKbComms->SetKBColour(frame->zone, frame->colour); + // MODIFIED: apply speed factor to the sleep duration + uint32_t sleepMs = static_cast(frame->ms_time / m_speedFactor); + if (sleepMs < 1) sleepMs = 1; + std::this_thread::sleep_for(millisec(sleepMs)); + } + } } void Keyboard::PlayAnimation(IAnimation& animation, bool bShouldLoop) diff --git a/CppKeyboardColour/Keyboard.h b/CppKeyboardColour/Keyboard.h index bc44a93..eabfe47 100644 --- a/CppKeyboardColour/Keyboard.h +++ b/CppKeyboardColour/Keyboard.h @@ -23,6 +23,8 @@ class Keyboard KeyboardType GetKBType() const; + void SetSpeedFactor(float factor) override; + ~Keyboard() = default; private: @@ -30,5 +32,7 @@ class Keyboard ColourFactory m_colourFactory{}; IKeyboardCommunicatorPtr m_ptrKbComms{}; + float m_speedFactor = 1.0f; + void Animate(IAnimation& animation); }; diff --git a/CppKeyboardColour/ThemeCommandLine.cpp b/CppKeyboardColour/ThemeCommandLine.cpp index 3297592..e79d2d2 100644 --- a/CppKeyboardColour/ThemeCommandLine.cpp +++ b/CppKeyboardColour/ThemeCommandLine.cpp @@ -108,4 +108,18 @@ std::unique_ptr ProcessThemeCommandLine(const std::vector& cmdLines) +{ + for (size_t i = 0; i < cmdLines.size(); ++i) + { + if (cmdLines[i] == L"-speed" && i + 1 < cmdLines.size()) + { + int percent = std::stoi(cmdLines[i + 1]); + if (percent <= 0) percent = 100; + return static_cast(percent) / 100.0f; + } + } + return 1.0f; // normal speed } \ No newline at end of file diff --git a/CppKeyboardColour/ThemeCommandLine.h b/CppKeyboardColour/ThemeCommandLine.h index dc21151..63ca959 100644 --- a/CppKeyboardColour/ThemeCommandLine.h +++ b/CppKeyboardColour/ThemeCommandLine.h @@ -22,4 +22,6 @@ enum class BacklightType ThemeFlags ProcessCmdThemeFlags(const std::vector& cmdLines); BacklightType ProcessBacklightCommandLine(const std::vector& cmdLines); SystemAnimation ProcessSystemAnimationCommandLine(const std::vector& cmdLines); -std::unique_ptr ProcessThemeCommandLine(const std::vector& cmdLines); \ No newline at end of file +std::unique_ptr ProcessThemeCommandLine(const std::vector& cmdLines); + +float ProcessSpeedCommandLine(const std::vector& cmdLines); \ No newline at end of file diff --git a/CppKeyboardColour/stdafx.cpp b/CppKeyboardColour/stdafx.cpp index bd74dc93ce16e10bb38172a8871d7b623d6f2727..ce410ee58b7f55d29439c1d3c15d36f9e2aacbe9 100644 GIT binary patch delta 11 ScmaFF@`!l@6XWDM#s>f!d<1a- delta 102 zcmWNI%MCzK00al`BvAtwR}L!jO^9E33ChrkMl>N&hQwx1JG1+EkGWhYOG$}Xu~g(V q>?BMSbfOzAy%JH1joRcQ<9WxS Date: Wed, 10 Jun 2026 12:52:06 +0200 Subject: [PATCH 2/4] Document custom speed feature for animations Added custom speed option for animations in README. --- README.md | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4a84cf9..bdc8fc8 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ This is a cleaner, more organized, and efficient version of the initial program. - **Predefined Animated Effects:** - 🌈 **Fading Colors:** Smooth color transitions (predefined themes). - 🎥 **Optimized Animations:** Enhanced visual effects using animation objects. + - ⏱️ **Custom Speed:** Change the speed to make an animation faster or slower. ⚠️ **Important Note:** This application requests for **Administrator privileges**. Please ensure you accept the Windows UAC prompt, as Windows Management Instrumentation (WMI) requires this to function correctly. @@ -33,7 +34,7 @@ The following commands are supported and can be executed via the **Command Promp Extract the program zip and run the commands **as an administrator**. To execute the `.exe` files, prepend the `.\` before the command. ```bash -.\CLEVO_KeyboardColour.exe theme/inbuilt/backlight [argument] +.\CLEVO_KeyboardColour.exe theme/inbuilt/backlight [argument] -speed [speed] ``` --- @@ -133,6 +134,25 @@ Extract the program zip and run the commands **as an administrator**. To execute --- +### ⏱️ Custom Speed: + +- **Slower** + ```bash + .\CLEVO_KeyboardColour.exe theme colourtransform -speed 50 + ``` + 🌈 Creates a slow rainbow sweep effect with smooth transitions at 50% speed. + +- **Faster** + ```bash + .\CLEVO_KeyboardColour.exe theme colourtransform -speed 200 + ``` + 🌈 Creates a fast rainbow sweep effect with smooth transitions at 200% speed. + + +**Setting speed is not required. You can leave it out, and it will default to the standard speed.** + +--- + ## 🛠️ How to Use 1. Download the release which contains the version of the program that supports your system. @@ -145,7 +165,7 @@ Extract the program zip and run the commands **as an administrator**. To execute 4. Run the desired command using the syntax: ``` - .\CLEVO_KeyboardColour.exe theme/inbuilt/backlight [argument] + .\CLEVO_KeyboardColour.exe theme/inbuilt/backlight [argument] -speed [speed] ``` --- From 47c1f70e2f9f71c98ca37bb80623c465431d546a Mon Sep 17 00:00:00 2001 From: Janneske2001 <60797324+Janneske2001@users.noreply.github.com> Date: Wed, 10 Jun 2026 12:53:12 +0200 Subject: [PATCH 3/4] Delete .gitignore from online repo --- .gitignore | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 .gitignore diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 75bd5ee..0000000 --- a/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -Debug/ -x64/ -.vs/ \ No newline at end of file From 7e3d4a7d71bb99cb57a48a74e6b2b81583a1511a Mon Sep 17 00:00:00 2001 From: Janneske2001 Date: Thu, 11 Jun 2026 11:15:16 +0200 Subject: [PATCH 4/4] Added 1-250 Limit to custom speed. Also extended error handling. --- CppKeyboardColour/CppKeyboardColour.cpp | Bin 7156 -> 8022 bytes CppKeyboardColour/IKeyboard.h | 2 +- CppKeyboardColour/Keyboard.cpp | 53 ++++++++++++++---------- CppKeyboardColour/Keyboard.h | 2 +- 4 files changed, 33 insertions(+), 24 deletions(-) diff --git a/CppKeyboardColour/CppKeyboardColour.cpp b/CppKeyboardColour/CppKeyboardColour.cpp index bddcd1776e52d5850b925d8ecc28e7c7f39946bf..eaad173bd31a94fcb290f81b4f88eefaaef61a69 100644 GIT binary patch delta 654 zcmexje$8%!5tDHlLq0<$LkfceLpVbskX6Fq1{5h`aAn8?vQvR9PlhxGKOid=s0xHN zChrzDOpXD{2LNSL8H#~W0ZF|AP+vY!B$c58Y@Qwi2r4mHGw?ES0mUJ(7^o_R!3qeI zfvWO=D$;>EN*FX4G@&YMH)}E_vuP6VtVVvt$s2_DCL2ieY+lCkhi&p74h}}e$qV@% zCm&)Fo4kRQV{!tg9Ec{-&;>kV-iAO|L0qoSpbun$+*}3>u^b=^6ne!B1wi+M!bb2q%p?GbT@xI|2YIj2Dvt diff --git a/CppKeyboardColour/IKeyboard.h b/CppKeyboardColour/IKeyboard.h index 653b8d3..daf92a0 100644 --- a/CppKeyboardColour/IKeyboard.h +++ b/CppKeyboardColour/IKeyboard.h @@ -16,7 +16,7 @@ class IKeyboard virtual void PlayAnimation(IAnimation& animation, bool bShouldLoop) = 0; virtual KeyboardType GetKBType() const = 0; - virtual void SetSpeedFactor(float factor) = 0; + virtual bool SetSpeedFactor(float factor) = 0; virtual ~IKeyboard() = default; }; \ No newline at end of file diff --git a/CppKeyboardColour/Keyboard.cpp b/CppKeyboardColour/Keyboard.cpp index 1e94a12..5ec754f 100644 --- a/CppKeyboardColour/Keyboard.cpp +++ b/CppKeyboardColour/Keyboard.cpp @@ -6,50 +6,60 @@ using millisec = std::chrono::milliseconds; Keyboard::Keyboard(KeyboardType kbType, IKeyboardCommunicatorPtr ptrKbComms) - : m_kbType(kbType), - m_ptrKbComms(std::move(ptrKbComms)) + : m_kbType(kbType), + m_ptrKbComms(std::move(ptrKbComms)) { } void Keyboard::SetColour(uint8_t r, uint8_t g, uint8_t b, Zone zone) { - m_ptrKbComms->SetKBColour(zone, m_colourFactory.Create(r, g, b)); + m_ptrKbComms->SetKBColour(zone, m_colourFactory.Create(r, g, b)); } KeyboardType Keyboard::GetKBType() const { - return m_kbType; + return m_kbType; }; void Keyboard::SendCode(uint32_t code) { - m_ptrKbComms->SendKBCode(code); + m_ptrKbComms->SendKBCode(code); } void Keyboard::SetBacklightOff() { - this->SetColour(0x00, 0x00, 0x00, Zone::ALL); + this->SetColour(0x00, 0x00, 0x00, Zone::ALL); } void Keyboard::SetBacklightOn() { - this->SetColour(0x00, 0x00, 0xFF, Zone::ALL); + this->SetColour(0x00, 0x00, 0xFF, Zone::ALL); } -void Keyboard::SetSpeedFactor(float factor) +bool Keyboard::SetSpeedFactor(float factor) { + // Convert percent (1-250) to speed multiplier (0.01 - 2.5) + int percent = static_cast(factor * 100.0f); + if (percent < 1 || percent > 250) + { + std::cout << "Speed value out of range (1-250). Animation will not play.\n"; + return false; // reject invalid speed + } + m_speedFactor = factor; + return true; } void Keyboard::Animate(IAnimation& animation) { + // Apply speed factor to the sleep duration + float invSpeed = 1.0f / m_speedFactor; for (size_t i = 0; i < animation.Size(); ++i) { if (const auto frame = animation.GetFrame(i)) { m_ptrKbComms->SetKBColour(frame->zone, frame->colour); - // MODIFIED: apply speed factor to the sleep duration - uint32_t sleepMs = static_cast(frame->ms_time / m_speedFactor); + uint32_t sleepMs = static_cast(frame->ms_time * invSpeed); if (sleepMs < 1) sleepMs = 1; std::this_thread::sleep_for(millisec(sleepMs)); } @@ -58,17 +68,16 @@ void Keyboard::Animate(IAnimation& animation) void Keyboard::PlayAnimation(IAnimation& animation, bool bShouldLoop) { - if (!animation.IsSupportedKB(this->GetKBType())) - { - std::wcout << animation.GetName() << L" animation is not supported on this system.\n"; - return; - } - - std::wcout << L"Playing " << animation.GetName() << L" animation...\n"; + if (!animation.IsSupportedKB(this->GetKBType())) + { + std::wcout << animation.GetName() << L" animation is not supported on this system.\n"; + return; + } - do - { - this->Animate(animation); + std::wcout << L"Playing " << animation.GetName() << L" animation...\n"; - } while (bShouldLoop); -} + do + { + this->Animate(animation); + } while (bShouldLoop); +} \ No newline at end of file diff --git a/CppKeyboardColour/Keyboard.h b/CppKeyboardColour/Keyboard.h index eabfe47..ccfe51c 100644 --- a/CppKeyboardColour/Keyboard.h +++ b/CppKeyboardColour/Keyboard.h @@ -23,7 +23,7 @@ class Keyboard KeyboardType GetKBType() const; - void SetSpeedFactor(float factor) override; + bool SetSpeedFactor(float factor) override; ~Keyboard() = default;