From dbe08f0e47cc0603f7d22fb1d793934bf8a4724c Mon Sep 17 00:00:00 2001 From: ThirteenAG Date: Sat, 11 Nov 2023 14:21:53 +0800 Subject: [PATCH] led effects: added target device calls --- .../SplinterCellDoubleAgent.WidescreenFix.ini | 2 +- includes/LED/LEDEffects.h | 21 +++++++++++++++++++ .../dllmain.cpp | 6 ++++-- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/data/SplinterCellDoubleAgent.WidescreenFix/SCDA-Offline/System/scripts/SplinterCellDoubleAgent.WidescreenFix.ini b/data/SplinterCellDoubleAgent.WidescreenFix/SCDA-Offline/System/scripts/SplinterCellDoubleAgent.WidescreenFix.ini index 41b27c4e4..975d5d0fe 100644 --- a/data/SplinterCellDoubleAgent.WidescreenFix/SCDA-Offline/System/scripts/SplinterCellDoubleAgent.WidescreenFix.ini +++ b/data/SplinterCellDoubleAgent.WidescreenFix/SCDA-Offline/System/scripts/SplinterCellDoubleAgent.WidescreenFix.ini @@ -2,7 +2,7 @@ ResX = 0 ResY = 0 ForceLL = 1 // Fixes startup crash, same thing as -ll shortcut switch. -SingleCoreAffinity = 1 // Experimental, attempt to avoid mid-loading hang. +SingleCoreAffinity = 0 // Experimental, attempt to avoid mid-loading hang. [GRAPHICS] ;ShadowMapResolution = 2048 // Do not use, causes bugs. Default is 1024, max is 8192 diff --git a/includes/LED/LEDEffects.h b/includes/LED/LEDEffects.h index 5a1d9076f..b53ceb0cc 100644 --- a/includes/LED/LEDEffects.h +++ b/includes/LED/LEDEffects.h @@ -354,6 +354,7 @@ class LEDEffects static inline void SetLightingLeftSide(int redPercentage, int greenPercentage, int bluePercentage, bool ignoreCardiogram = false, bool ignoreCardiogramDead = false, bool ignoreFSide = false) { + LogiLedSetTargetDevice(LOGI_DEVICETYPE_PERKEY_RGB); for (auto key : leftSide) { if (ignoreCardiogram && std::any_of(std::begin(keysCardiogram), std::end(keysCardiogram), [key](auto i) { return i == key; })) @@ -367,10 +368,15 @@ class LEDEffects LogiLedSetLightingForKeyWithKeyName(key, redPercentage, greenPercentage, bluePercentage); } + + LogiLedSetTargetDevice(LOGI_DEVICETYPE_RGB); + LogiLedSetLighting(redPercentage, greenPercentage, bluePercentage); + LogiLedSetTargetDevice(LOGI_DEVICETYPE_ALL); } static inline void SetLightingRightSide(int redPercentage, int greenPercentage, int bluePercentage, bool ignoreCardiogram = false, bool ignoreCardiogramDead = false, bool ignoreFSide = false) { + LogiLedSetTargetDevice(LOGI_DEVICETYPE_PERKEY_RGB); for (auto key : rightSide) { if (ignoreCardiogram && std::any_of(std::begin(keysCardiogramNumpad), std::end(keysCardiogramNumpad), [key](auto i) { return i == key; })) @@ -384,10 +390,15 @@ class LEDEffects LogiLedSetLightingForKeyWithKeyName(key, redPercentage, greenPercentage, bluePercentage); } + + LogiLedSetTargetDevice(LOGI_DEVICETYPE_RGB); + LogiLedSetLighting(redPercentage, greenPercentage, bluePercentage); + LogiLedSetTargetDevice(LOGI_DEVICETYPE_ALL); } static inline void SetLighting(int redPercentage, int greenPercentage, int bluePercentage, bool ignoreCardiogram = false, bool ignoreCardiogramDead = false, bool ignoreFSide = false) { + LogiLedSetTargetDevice(LOGI_DEVICETYPE_PERKEY_RGB); SetLightingLeftSide(redPercentage, greenPercentage, bluePercentage, ignoreCardiogram, ignoreCardiogramDead, ignoreFSide); for (auto key : rightSide) { @@ -396,10 +407,15 @@ class LEDEffects LogiLedSetLightingForKeyWithKeyName(key, redPercentage, greenPercentage, bluePercentage); } + + LogiLedSetTargetDevice(LOGI_DEVICETYPE_RGB); + LogiLedSetLighting(redPercentage, greenPercentage, bluePercentage); + LogiLedSetTargetDevice(LOGI_DEVICETYPE_ALL); } static inline void DrawCardiogram(int startRedPercentage, int startGreenPercentage, int startBluePercentage, int finishRedPercentage, int finishGreenPercentage, int finishBluePercentage, bool dead = false) { + LogiLedSetTargetDevice(LOGI_DEVICETYPE_PERKEY_RGB); auto& arr = dead ? keysCardiogramDead : keysCardiogram; static auto TIMERA = Timer(); static auto counter = 0; @@ -413,10 +429,12 @@ class LEDEffects counter++; TIMERA.reset(); } + LogiLedSetTargetDevice(LOGI_DEVICETYPE_ALL); } static inline void DrawCardiogramNumpad(int startRedPercentage, int startGreenPercentage, int startBluePercentage, int finishRedPercentage, int finishGreenPercentage, int finishBluePercentage, bool dead = false) { + LogiLedSetTargetDevice(LOGI_DEVICETYPE_PERKEY_RGB); auto& arr = dead ? keysCardiogramNumpadDead : keysCardiogramNumpad; static auto TIMERB = Timer(); static auto counter = 0; @@ -430,6 +448,7 @@ class LEDEffects counter++; TIMERB.reset(); } + LogiLedSetTargetDevice(LOGI_DEVICETYPE_ALL); } static inline void DrawPoliceSirenMouse() @@ -461,6 +480,7 @@ class LEDEffects static void DrawPoliceSirenKeyboard(bool withWhiteStrip = false, int duration = 1200, bool isInfinite = true) { + LogiLedSetTargetDevice(LOGI_DEVICETYPE_PERKEY_RGB); static auto TIMERD = Timer(); if (TIMERD >= duration || isInfinite) @@ -503,5 +523,6 @@ class LEDEffects else TIMERD.reset(); } + LogiLedSetTargetDevice(LOGI_DEVICETYPE_ALL); } }; \ No newline at end of file diff --git a/source/SplinterCellDoubleAgent.WidescreenFix/dllmain.cpp b/source/SplinterCellDoubleAgent.WidescreenFix/dllmain.cpp index 64fef368b..e05b55d4e 100644 --- a/source/SplinterCellDoubleAgent.WidescreenFix/dllmain.cpp +++ b/source/SplinterCellDoubleAgent.WidescreenFix/dllmain.cpp @@ -250,10 +250,12 @@ void Init() { static auto fPlayerVisibility = gVisibility; std::this_thread::sleep_for(std::chrono::milliseconds(100)); + auto gVisCmp = static_cast(static_cast(gVisibility * 10.0f)) / 10.0f; + auto fPlVisCmp = static_cast(static_cast(fPlayerVisibility * 10.0f)) / 10.0f; - if (fPlayerVisibility > gVisibility) + if (fPlVisCmp > gVisCmp) fPlayerVisibility -= 0.05f; - else if (fPlayerVisibility < gVisibility) + else if (fPlVisCmp < gVisCmp) fPlayerVisibility += 0.05f; fPlayerVisibility = std::clamp(fPlayerVisibility, 0.0f, 1.0f);