diogotr7 / OpenRGB.NET

C# client for the OpenRGB SDK
MIT License
40 stars 16 forks source link

Documentation #5

Open Tom60chat opened 4 years ago

Tom60chat commented 4 years ago

It's difficult to use this library without documentation.

Can you made one ?

BalaDeSilver commented 3 years ago

Just examples would be a beginning. Multiple examples.

Tom60chat commented 3 years ago

If you want examples :

private OpenRGBClient client;
private bool Available => client != null ? client.Connected : false;

public bool Start(string name)
{
    client = new OpenRGBClient(name: name, autoconnect: false);
    try
    {
        client.Connect();
    } catch (TimeoutException)
    {
        return false;
    }
    return Available;
}

public void SetLeds(DeviceType type, OpenRGB.NET.Models.Color color)
{
    if (!Available) return;

    OpenRGB.NET.Models.Color[] openRGBColors;

    foreach (var deviceId in client.GetControllerCount())
    {
        device = client.GetControllerData(deviceId);
        openRGBColors = new OpenRGB.NET.Models.Color[device.Colors.Length];
        for (int i = 0; i < openRGBColors.Length; i++)
            openRGBColors[i] = color;

        client.UpdateLeds(deviceId, openRGBColors);
    }
}
gyorokpeter commented 3 years ago

Is there a way to know which index in the array maps to which key? By adding a pause after changing the color of each key I found that it changes the keys roughly in columns, and roughly from left to right but not strictly in that order, with the function, cursor etc. keys randomly thrown in between.

diogotr7 commented 3 years ago

I'm not sure what you mean by this. If i understood correctly, there are in general two ways of identifying LEDs:

Hope that helps.

gyorokpeter commented 3 years ago

openRgbClient.UpdateLeds takes an array of colors. But there is nothing to indicate which element of the array corresponds to which key. For example for my keyboard, index 0 does nothing, index 1 is the ~/` key, index 2 is TAB... so I would like something that maps e.g. TILDE to 1, TAB to 2 etc.