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

Enhanced queries for connected devices #145

Open
njbmartin opened this issue Jan 23, 2016 · 9 comments
Open

Enhanced queries for connected devices #145

njbmartin opened this issue Jan 23, 2016 · 9 comments
Assignees
Milestone

Comments

@njbmartin
Copy link

Was just asked whether there was an easy way to get the following:

  • A list of all the devices connected
  • Easily query if a certain device type is connected (ie. keyboard, mouse etc.)

Right now, you can query a specific device with the following:
Corale.Colore.Core.Chroma.Instance.Query(Corale.Colore.Razer.Devices.Tartarus).Connected

I'm proposing and plan to implement the following methods:
Chroma.Instance.Query(Corale.Colore.Razer.DeviceType deviceType).Connected

Chroma.Instance.ConnectedDevices() which returns List<DeviceInfo>()

@njbmartin
Copy link
Author

Please let me know if you could suggest better methods.

@njbmartin
Copy link
Author

Just realised a better way to query a connected devicetype would be this:

Chroma.Instance.Headset.Connected

@brandonscott
Copy link
Contributor

There is some value to this change, but for keyboards, given the different layouts it may simplify the checks too much?

@njbmartin
Copy link
Author

@brandonscott That is true. For keyboards you may still have to query which device it is. However, lets say you separate out the logic per device type, or simply want to show / hide options based on connected types, then this would definitely be handy.

As for layouts, I personally think there should be a definition for each layout, as a few share the same and I'm sure more devices will in the future too. We would then have the ability to query as to which layout it is instead of individual devices.

example:

switch(Keyboard.Layout){
     case Razer.Keyboard.Layouts.Standard:
     // do something
     break;
     case Razer.Keyboard.Layouts.Mini:
     // do something else
}

We should raise this with Razer if we agree this would make beneficial to most.

@njbmartin
Copy link
Author

Also, if you wanted keyboard device specific code, you would currently have to do something like this:

function Connected(DeviceInfo d){
    return c.Query(d).Connected;
}

if(Connected(Razer.Devices.Blackwidow)){
    // Do something
}else if(Connected(Razer.Devices.BlackwidowTe)){
    // Do something else
}else if(Connected(Razer.Devices.Deathstalker)){
    // Do something very different
}

Could potentially be shortened to a switch statement:

switch(Keyboard.Instance.Device)){
    case Razer.Devices.Deathstalker:
        // Do something
    break;
    case Razer.Devices.BlackwidowTe:
        // Do something else
    break;
    case Razer.Devices.Deathstalker:
        // Do something
    break;
    default:
        // Keyboard.Instance.Device.None for none connected.
}

It just feels cleaner.

Granted, in the rare case someone may have two of the same devices / device types connected.

@Sharparam
Copy link
Member

Granted, in the rare case someone may have two of the same devices / device types connected.

This is the big issue with having a Layout property. The Keyboard class doesn't represent a single device with its own layout, it represents every (Chroma) keyboard device connected to the system and method calls to it will affect every connected device of the applicable type.

IIRC we raised this issue with Razer before regarding detecting different physical layouts and their response was basically "Nope, we just expect everyone to only ever have a single of any possible device type connected.".

@Sharparam Sharparam removed the Chroma label Apr 3, 2016
@njbmartin
Copy link
Author

Ok, so having created a new method for listing the connected devices, which is just a simple List<Devices>(), seems we should also add the Device Name to DeviceInfo.

@njbmartin
Copy link
Author

Or at least attach the Guid.

@njbmartin
Copy link
Author

_devices = new Dictionary<Guid, DeviceInfo>(); this is the easiest solution specifically for the list of connected devices.

DeviceInfo alone contains no reference to the device itself.

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

No branches or pull requests

3 participants