Skip to content

Commit

Permalink
sort device with serial to guarantee permanent device index
Browse files Browse the repository at this point in the history
  • Loading branch information
hanasaan committed Dec 11, 2014
1 parent 0f96af8 commit 88cfd70
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions libs/protonect/src/libfreenect2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ class Freenect2Impl
};
typedef std::vector<UsbDeviceWithSerial> UsbDeviceVector;
typedef std::vector<Freenect2DeviceImpl *> DeviceVector;

static bool asc(const Freenect2Impl::UsbDeviceWithSerial& left, const Freenect2Impl::UsbDeviceWithSerial& right ) {
return left.serial < right.serial;
}

bool has_device_enumeration_;
UsbDeviceVector enumerated_devices_;
Expand Down Expand Up @@ -293,6 +297,13 @@ class Freenect2Impl
libusb_unref_device(dev);
}
}

{
std::sort(enumerated_devices_.begin(), enumerated_devices_.end(), asc);
for (const UsbDeviceWithSerial& dev : enumerated_devices_) {
std::cout << "[Freenect2Impl] [sorted] found valid Kinect v2 " << PrintBusAndDevice(dev.dev) << " with serial " << dev.serial << std::endl;
}
}

libusb_free_device_list(device_list, 0);
has_device_enumeration_ = true;
Expand Down

0 comments on commit 88cfd70

Please sign in to comment.