Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JslSetLightColour function hangs in C# after some time #21

Open
justalemon opened this issue Jan 8, 2021 · 0 comments
Open

JslSetLightColour function hangs in C# after some time #21

justalemon opened this issue Jan 8, 2021 · 0 comments

Comments

@justalemon
Copy link

justalemon commented Jan 8, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant