Skip to content

Commit

Permalink
Added better LED transitions
Browse files Browse the repository at this point in the history
  • Loading branch information
WujekFoliarz authored Jun 20, 2024
1 parent 44e3936 commit 082aef7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 36 deletions.
2 changes: 1 addition & 1 deletion DL1-Dualsense/DL1-Dualsense.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<PackageReference Include="Nefarius.ViGEm.Client" Version="1.21.256" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="swed64" Version="1.0.5" />
<PackageReference Include="Wujek_Dualsense_API" Version="1.0.4" />
<PackageReference Include="Wujek_Dualsense_API" Version="1.0.5" />
</ItemGroup>

</Project>
53 changes: 18 additions & 35 deletions DL1-Dualsense/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,11 @@ private static void Main(string[] args)
bool firstTime = true;
Stopwatch hapticCooldown = new Stopwatch();
Stopwatch footstepsCooldown = new Stopwatch();
Stopwatch lightbarAnimationCooldown = new Stopwatch();
Random rand = new Random();
hapticCooldown.Start();
footstepsCooldown.Start();
lightbarAnimationCooldown.Start();

new Thread(() =>
{
Expand Down Expand Up @@ -891,8 +893,6 @@ private static void Main(string[] args)
{
if (firstTimeAirdrop)
{


hapticCooldown.Restart();
dualsense.PlayHaptics(HapticEffect.ElectronicBeep, 1.0f, 1.0f, 1.0f, true);
firstTimeAirdrop = false;
Expand All @@ -914,25 +914,18 @@ private static void Main(string[] args)
hapticCooldown.Restart();
}

if (uvAnimationSide == false && uvAnimationCycleB >= 255)
if (uvAnimationSide == false && lightbarAnimationCooldown.ElapsedMilliseconds >= 350)
{
uvAnimationSide = true;
dualsense.SetLightbarTransition(0, 0, 255, 10, 25);
lightbarAnimationCooldown.Restart();
}
else if (uvAnimationSide == true && uvAnimationCycleB <= 0)
else if (uvAnimationSide == true && lightbarAnimationCooldown.ElapsedMilliseconds >= 350)
{
uvAnimationSide = false;
dualsense.SetLightbarTransition(0, 0, 0, 10, 25);
lightbarAnimationCooldown.Restart();
}

if (uvAnimationSide == false)
{
uvAnimationCycleB = Math.Min(uvAnimationCycleB + 10, 255);
}
else
{
uvAnimationCycleB = Math.Max(uvAnimationCycleB - 8, 0);
}

dualsense.SetLightbar(0, 0, uvAnimationCycleB);
}
else if (game.isUVRecharging())
{
Expand All @@ -944,7 +937,6 @@ private static void Main(string[] args)
}
else if (flashlight && dualsense.ButtonState.DpadUp && hapticCooldown.ElapsedMilliseconds > 250 && !lastDpadUP)
{

dualsense.PlayHaptics(HapticEffect.FlashlightOff, 1.0f, 0.0f, 1.0f, true);
flashlight = false;
hapticCooldown.Restart();
Expand All @@ -957,27 +949,18 @@ private static void Main(string[] args)
hapticCooldown.Restart();
}

if (uvAnimationSide == false && uvAnimationCycleB >= maxCycleValue)
if (uvAnimationSide == false && lightbarAnimationCooldown.ElapsedMilliseconds >= 350)
{
dualsense.SetLightbarTransition(200, 0, 10, 5, 20);
uvAnimationSide = true;
lightbarAnimationCooldown.Restart();
}
else if (uvAnimationSide == true && uvAnimationCycleB <= minCycleValue)
else if (uvAnimationSide == true && lightbarAnimationCooldown.ElapsedMilliseconds >= 350)
{
dualsense.SetLightbarTransition(60, 0, 255, 5, 20);
uvAnimationSide = false;
lightbarAnimationCooldown.Restart();
}

if (uvAnimationSide == false)
{
uvAnimationCycleR = Math.Min(uvAnimationCycleR + increment, minCycleValue);
uvAnimationCycleB = Math.Min(uvAnimationCycleB + increment, maxCycleValue);
}
else
{
uvAnimationCycleR = Math.Max(uvAnimationCycleR - increment, minCycleValue);
uvAnimationCycleB = Math.Max(uvAnimationCycleB - increment, minCycleValue);
}

dualsense.SetLightbar(uvAnimationCycleR, 0, uvAnimationCycleB);
}
// Change RGB colors to purple
else if (game.isUVOn())
Expand Down Expand Up @@ -1030,10 +1013,10 @@ private static void Main(string[] args)
firstTime = true;
firstTimeAirdrop = true;
// Change RGB colors according to HP
if (hp >= 175) { dualsense.SetLightbar(0, 255, 0); }
else if (hp < 175 && hp > 75) { dualsense.SetLightbar(255, 255, 0); }
else if (hp < 75 && hp != 0) { dualsense.SetLightbar(255, 0, 0); }
else { dualsense.SetLightbar(0, 0, 0); }
if (hp >= 175) { dualsense.SetLightbarTransition(0, 255, 0, 5, 10); }
else if (hp < 175 && hp > 75) { dualsense.SetLightbarTransition(255, 255, 0, 5, 10); }
else if (hp < 75 && hp != 0) { dualsense.SetLightbarTransition(255, 0, 0, 5, 10); }
else { dualsense.SetLightbarTransition(0, 0, 0, 5, 10); }
}

if (!game.isUVOn())
Expand Down

0 comments on commit 082aef7

Please sign in to comment.