summaryrefslogtreecommitdiff
path: root/grapher/Models/Devices/DeviceIDManager.cs
diff options
context:
space:
mode:
authora1xd <[email protected]>2021-02-02 23:28:51 -0500
committerGitHub <[email protected]>2021-02-02 23:28:51 -0500
commit59e86a6d6c2f6604f3c413b7c55ef484c607dfaf (patch)
tree688c572bb39ae26f1c86a2c3301bd59130f90e71 /grapher/Models/Devices/DeviceIDManager.cs
parentbump version (diff)
parentfix typos in guide (diff)
downloadrawaccel-1.4.2.tar.xz
rawaccel-1.4.2.zip
Merge pull request #71 from a1xd/fix-dev-idv1.4.2
1.4.2
Diffstat (limited to 'grapher/Models/Devices/DeviceIDManager.cs')
-rw-r--r--grapher/Models/Devices/DeviceIDManager.cs22
1 files changed, 2 insertions, 20 deletions
diff --git a/grapher/Models/Devices/DeviceIDManager.cs b/grapher/Models/Devices/DeviceIDManager.cs
index c50cda8..8592763 100644
--- a/grapher/Models/Devices/DeviceIDManager.cs
+++ b/grapher/Models/Devices/DeviceIDManager.cs
@@ -25,24 +25,6 @@ namespace grapher.Models.Devices
public Dictionary<string, DeviceIDItem> DeviceIDs { get; private set; }
- public static IEnumerable<(string, string)> GetDeviceIDs(string PNPClass = "Mouse")
- {
- ManagementObjectSearcher searcher = new ManagementObjectSearcher(new SelectQuery("Win32_PnPEntity"));
-
- foreach (ManagementObject obj in searcher.Get())
- {
- if (obj["PNPClass"] != null && obj["PNPClass"].ToString().Equals(PNPClass) && obj["DeviceID"] != null)
- {
- string name = obj["Name"].ToString();
-
- string devInstanceID = obj["DeviceID"].ToString();
- string devID = devInstanceID.Remove(devInstanceID.LastIndexOf('\\'));
-
- yield return (name, devID);
- }
- }
- }
-
public void SetActive(DeviceIDItem deviceIDItem)
{
if (SelectedDeviceID != null)
@@ -64,9 +46,9 @@ namespace grapher.Models.Devices
if (found) SetActive(anyDevice);
- foreach (var device in GetDeviceIDs().Distinct())
+ foreach (var (name, id) in RawInputInterop.GetDeviceIDs())
{
- var deviceItem = new DeviceIDItem(device.Item1, device.Item2, this);
+ var deviceItem = new DeviceIDItem(name, id, this);
if (!found && deviceItem.ID.Equals(devID))
{
SetActive(deviceItem);