@@ -110,7 +110,43 @@ FN_INTERNAL int fnusb_list_device_attributes(fnusb_ctx *ctx, struct freenect_dev
110
110
111
111
* camera_prev_next = new_dev_attrs ;
112
112
// Copy string with serial number
113
- new_dev_attrs -> camera_serial = strdup ((char * )string_desc );
113
+ if (strncmp ((const char * )string_desc , K4W_AND_1473_SERIAL_NO , 16 ) == 0 ){
114
+ printf ("\n k4w detected\n" );
115
+ int j ;
116
+ struct libusb_device_descriptor audio_desc ;
117
+ for (j = 0 ; j < count ; j ++ ) {
118
+ int result = libusb_get_device_descriptor (devs [j ], & audio_desc );
119
+ if (result < 0 )
120
+ continue ;
121
+
122
+ if (audio_desc .idVendor == VID_MICROSOFT && audio_desc .idProduct == PID_K4W_AUDIO ) {
123
+ // Verify that a serial number exists to query. If not, don't touch the device.
124
+ if (audio_desc .iSerialNumber == 0 ) {
125
+ continue ;
126
+ }
127
+ int audio_bus_num = libusb_get_bus_number (libusb_get_parent (devs [j ]));
128
+ int audio_port_num = libusb_get_port_number (libusb_get_parent (devs [j ]));
129
+ if (libusb_get_bus_number (libusb_get_parent (devs [i ])) == audio_bus_num &&
130
+ libusb_get_port_number (libusb_get_parent (devs [i ])) == audio_port_num &&
131
+ audio_bus_num != 0 && audio_port_num != 0 ) {
132
+ int result_audio ;
133
+ libusb_device_handle * this_audio_device ;
134
+ result_audio = libusb_open (devs [j ], & this_audio_device );
135
+ if (result_audio != 0 ) {
136
+ continue ;
137
+ }
138
+ result_audio = libusb_get_string_descriptor_ascii (this_device , audio_desc .iSerialNumber , string_desc , 256 );
139
+ if (result_audio < 0 ) {
140
+ continue ;
141
+ }
142
+ libusb_close (this_audio_device );
143
+ }
144
+ }
145
+ }
146
+ new_dev_attrs -> camera_serial = strdup ((char * )string_desc );
147
+ } else {
148
+ new_dev_attrs -> camera_serial = strdup ((char * )string_desc );
149
+ }
114
150
camera_prev_next = & (new_dev_attrs -> next );
115
151
// Increment number of cameras found
116
152
num_cams ++ ;
0 commit comments