summaryrefslogtreecommitdiff
path: root/devicelist/Program.cs
blob: 9323fd4370530cc3bddc3e10d5cac2eeb0517a1c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System;
using System.Text;
using System.Management;
using System.Windows.Forms;

namespace devicelist
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("To use Raw Accel driver for a specific device, "
                + "replace '\"Device Hardware ID\": null' in 'settings.json' by following:");
            Console.WriteLine("");

            ManagementObjectSearcher searcher = new ManagementObjectSearcher(new SelectQuery("Win32_PnPEntity"));

            foreach (ManagementObject obj in searcher.Get())
            {
                bool is_mouse = obj["PNPClass"] != null && obj["PNPClass"].ToString() == "Mouse"; // == "HIDClass" ???

                if (is_mouse && obj["HardwareID"] != null) {
                    String[] hwidArray = (String[])(obj["HardwareID"]);
                    if (hwidArray.Length > 0) {
                        String hwid = hwidArray[0].ToString().Replace(@"\", @"\\");
                        String name = obj["Name"].ToString();
                        Console.WriteLine(name + ":");
                        Console.WriteLine("\"Device Hardware ID\": \"" + hwid + "\"");
                        Console.WriteLine("");
                    }
                }
            }

            Console.ReadKey();
        }
    }
}