-
Notifications
You must be signed in to change notification settings - Fork 0
/
Acer_Detect_Lighting_Device.cs
158 lines (138 loc) · 6.23 KB
/
Acer_Detect_Lighting_Device.cs
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
// Acer_Class.Acer_Detect_Lighting_Device
using System;
using System.Threading;
internal class Acer_Detect_Lighting_Device
{
public const int LATENCY_OF_DETECT_USB_DEVICE = 5;
public const int DETECT_USB_CONNECTED_LATENCY = 50;
public static bool IsConnected_GB100;
public static bool IsConnected_X35;
public static bool IsConnected_GM310;
public static bool IsConnected_GK300;
public static bool IsConnected_GH300;
public static bool IsConnected_GM300;
public static bool IsConnected_GB300;
public static int Connected_Device_Number;
public static bool Is_USB30_Port(int VID, int PID)
{
foreach (Acer_USB_Library.USBController hostController in Acer_USB_Library.GetHostControllers())
{
Console.WriteLine("hostCtrl.Index: " + hostController.Index);
Console.WriteLine("hostCtrl.Name: " + hostController.Name);
foreach (Acer_USB_Library.USBPort port in hostController.GetRootHub().GetPorts())
{
if (port.IsDeviceConnected && !port.IsHub)
{
Acer_USB_Library.USBDevice device = port.GetDevice();
if (device.VID == VID && device.PID == PID)
{
bool result = port.IsHub;
Console.WriteLine("IsHub: " + result.ToString());
Console.WriteLine("Product: " + device.Product);
Console.WriteLine("VID/PID: " + device.VID + " / " + device.PID);
Console.WriteLine("Manufacturer: " + device.Manufacturer);
Console.WriteLine("HubDevicePath: " + device.HubDevicePath);
if (device.HubDevicePath.Contains("HUB30"))
{
Console.WriteLine("USB 3.0 port");
result = true;
return result;
}
Console.WriteLine("Name: " + device.Name);
Console.WriteLine("DriverKey: " + device.DriverKey);
Console.WriteLine("InstanceID: " + device.InstanceID);
Console.WriteLine("Serial: " + device.DeviceSerialNumber);
Console.WriteLine("Speed: " + port.Speed);
Console.WriteLine("Port: " + device.PortNumber + Environment.NewLine);
}
}
}
Console.WriteLine("===============\n");
}
return false;
}
public static bool Detect_Connected_GB100()
{
return LED_Control_API.Acer_Detect_Lighting_Device(7649, 44033);
}
public static bool Detect_Connected_GM310_Mouse()
{
return LED_Control_API.Acer_Detect_Lighting_Device(14648, 4470);
}
public static bool Detect_Connected_Archos_K92_KB()
{
return LED_Control_API.Acer_Detect_Lighting_Device(14648, 4482);
}
public static bool Detect_Connected_Acer_X35()
{
return LED_Control_API.Acer_Detect_Lighting_Device(4292, 60048);
}
public static bool Detect_Connected_GH300()
{
return LED_Control_API.Acer_Detect_Lighting_Device(7649, 44034);
}
public static bool Detect_Connected_GM300()
{
return LED_Control_API.Acer_Detect_Lighting_Device(14648, 4469);
}
public static bool Detect_Connected_GB300()
{
return LED_Control_API.Acer_Detect_Lighting_Device(7649, 44035);
}
public static void Do_All_Lighting_Device_Detection()
{
Acer_Detect_Lighting_Device.Reset_Lighting_Device_Detection_Result();
//Acer_Detect_Lighting_Device.IsConnected_GB100 = Acer_Detect_Lighting_Device.Detect_Connected_GB100();
//Thread.Sleep(5);
//Acer_Detect_Lighting_Device.IsConnected_GM310 = Acer_Detect_Lighting_Device.Detect_Connected_GM310_Mouse();
//Thread.Sleep(5);
//Acer_Detect_Lighting_Device.IsConnected_GK300 = Acer_Detect_Lighting_Device.Detect_Connected_Archos_K92_KB();
//Thread.Sleep(5);
Acer_Detect_Lighting_Device.IsConnected_X35 = Acer_Detect_Lighting_Device.Detect_Connected_Acer_X35();
Thread.Sleep(5);
//Acer_Detect_Lighting_Device.IsConnected_GH300 = Acer_Detect_Lighting_Device.Detect_Connected_GH300();
//Thread.Sleep(5);
//Acer_Detect_Lighting_Device.IsConnected_GM300 = Acer_Detect_Lighting_Device.Detect_Connected_GM300();
//Thread.Sleep(5);
//Acer_Detect_Lighting_Device.IsConnected_GB300 = Acer_Detect_Lighting_Device.Detect_Connected_GB300();
//Thread.Sleep(5);
if (Acer_Detect_Lighting_Device.IsConnected_GB100)
{
Acer_Detect_Lighting_Device.Connected_Device_Number++;
}
if (Acer_Detect_Lighting_Device.IsConnected_GM310)
{
Acer_Detect_Lighting_Device.Connected_Device_Number++;
}
if (Acer_Detect_Lighting_Device.IsConnected_GK300)
{
Acer_Detect_Lighting_Device.Connected_Device_Number++;
}
if (Acer_Detect_Lighting_Device.IsConnected_GH300)
{
Acer_Detect_Lighting_Device.Connected_Device_Number++;
}
if (Acer_Detect_Lighting_Device.IsConnected_X35)
{
Acer_Detect_Lighting_Device.Connected_Device_Number++;
}
if (Acer_Detect_Lighting_Device.IsConnected_GM300)
{
Acer_Detect_Lighting_Device.Connected_Device_Number++;
}
if (Acer_Detect_Lighting_Device.IsConnected_GB300)
{
Acer_Detect_Lighting_Device.Connected_Device_Number++;
}
}
public static void Reset_Lighting_Device_Detection_Result()
{
Acer_Detect_Lighting_Device.Connected_Device_Number = 0;
Acer_Detect_Lighting_Device.IsConnected_GB100 = false;
Acer_Detect_Lighting_Device.IsConnected_GM310 = false;
Acer_Detect_Lighting_Device.IsConnected_GK300 = false;
Acer_Detect_Lighting_Device.IsConnected_X35 = false;
Acer_Detect_Lighting_Device.IsConnected_GH300 = false;
Acer_Detect_Lighting_Device.IsConnected_GM300 = false;
}
}