While I was working in one of my projects, I found that JoyShockLibrary stopped working after some lightbar changes. I then tried it in a clean C# script and found out that it will hang on JslSetLightColour (I didn't tested the other functions due to only wanted to use the Lightbar).
The following script was used to test the library in .NET 5.0 (I used the JoyShockLibrary.cs from the downloads with the Unity imports removed):
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Threading;
namespace JoyShockLibraryTest
{
public class Program
{
public static void Main()
{
int count = JSL.JslConnectDevices();
int[] deviceIds = new int[count];
JSL.JslGetConnectedDeviceHandles(deviceIds, count);
List<int> devices = new List<int>();
foreach (int id in deviceIds)
{
switch (JSL.JslGetControllerType(id))
{
case 4:
Console.WriteLine($"Found DualShock 4: {id}");
devices.Add(id);
break;
case 5:
Console.WriteLine($"Found DualSense: {id}");
devices.Add(id);
break;
}
}
Random random = new Random();
while (true)
{
Color color = Color.FromArgb(random.Next(256), random.Next(256), random.Next(256));
foreach (int id in devices)
{
JSL.JslSetLightColour(id, color.ToArgb());
}
Console.WriteLine(DateTime.UtcNow.ToString("O"));
Thread.Sleep(100);
}
}
}
}
It changes the color of the Lightbar about 10 times per second on all connected DS4 and DSense devices, and prints the current time.
After some random time, it will hang permanently in JslSetLightColour forcing a hard restart. No controller connections or disconnections were performed while the script was running.
I used a DS4 v2 (CUH-ZCT2U, Days of Play Blue) to test the script with JoyShockLibrary 2.1.0.
While I was working in one of my projects, I found that JoyShockLibrary stopped working after some lightbar changes. I then tried it in a clean C# script and found out that it will hang on JslSetLightColour (I didn't tested the other functions due to only wanted to use the Lightbar).
The following script was used to test the library in .NET 5.0 (I used the JoyShockLibrary.cs from the downloads with the Unity imports removed):
It changes the color of the Lightbar about 10 times per second on all connected DS4 and DSense devices, and prints the current time.
After some random time, it will hang permanently in JslSetLightColour forcing a hard restart. No controller connections or disconnections were performed while the script was running.
I used a DS4 v2 (CUH-ZCT2U, Days of Play Blue) to test the script with JoyShockLibrary 2.1.0.