1010// Air USB VID and PID
1111#define AIR_VID 0x3318
1212#define AIR_PID 0x0424
13+ #define AIR_2_PID 0x0428
14+ #define AIR_2_PRO_PID 0x0432
1315
1416// Is Tracking
1517bool g_isTracking = false ;
@@ -215,8 +217,27 @@ process_accel(const int32_t in_accel[3], float out_vec[])
215217static hid_device*
216218open_device ()
217219{
218- struct hid_device_info * devs = hid_enumerate (AIR_VID, AIR_PID);
219- struct hid_device_info * cur_dev = devs;
220+ struct hid_device_info * devs = NULL ;
221+ struct hid_device_info * devs_1 = hid_enumerate (AIR_VID, AIR_PID);
222+ struct hid_device_info * devs_2 = hid_enumerate (AIR_VID, AIR_2_PID);
223+ struct hid_device_info * devs_2_pro = hid_enumerate (AIR_VID, AIR_2_PRO_PID);
224+
225+ struct hid_device_info * cur_dev = NULL ;
226+
227+ if (devs_1 != NULL ) {
228+ cur_dev = devs_1;
229+ devs = devs_1;
230+ }
231+ else if (devs_2 != NULL ) {
232+ cur_dev = devs_2;
233+ devs = devs_2;
234+
235+ }
236+ else if (devs_2_pro != NULL ) {
237+ cur_dev = devs_2_pro;
238+ devs = devs_2_pro;
239+ }
240+
220241 hid_device* device = NULL ;
221242
222243 while (devs) {
@@ -236,8 +257,26 @@ open_device()
236257static hid_device*
237258open_device4 ()
238259{
239- struct hid_device_info * devs = hid_enumerate (AIR_VID, AIR_PID);
240- struct hid_device_info * cur_dev = devs;
260+ struct hid_device_info * devs = NULL ;
261+ struct hid_device_info * devs_1 = hid_enumerate (AIR_VID, AIR_PID);
262+ struct hid_device_info * devs_2 = hid_enumerate (AIR_VID, AIR_2_PID);
263+ struct hid_device_info * devs_2_pro = hid_enumerate (AIR_VID, AIR_2_PRO_PID);
264+
265+ struct hid_device_info * cur_dev = NULL ;
266+
267+ if (devs_1 != NULL ) {
268+ cur_dev = devs_1;
269+ devs = devs_1;
270+ }
271+ else if (devs_2 != NULL ) {
272+ cur_dev = devs_2;
273+ devs = devs_2;
274+
275+ }
276+ else if (devs_2_pro != NULL ) {
277+ cur_dev = devs_2_pro;
278+ devs = devs_2_pro;
279+ }
241280 hid_device* device = NULL ;
242281
243282 while (devs) {
@@ -359,7 +398,7 @@ DWORD WINAPI interface4Handler(LPVOID lpParam) {
359398 std::array<uint8_t , 17 > initBrightness = { 0x00 , 0xfd , 0x1e , 0xb9 , 0xf0 , 0x68 , 0x11 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x03 };
360399 hid_write (device4, initBrightness.data (), initBrightness.size ());
361400
362-
401+
363402 while (g_isListening) {
364403 std::array<uint8_t , 65 > recv = {};
365404 int res = hid_read (device4, recv.data (), recv.size ());
@@ -396,6 +435,7 @@ DWORD WINAPI interface4Handler(LPVOID lpParam) {
396435 }
397436 }
398437 }
438+ return 0 ;
399439}
400440
401441
0 commit comments