getDeviceList method

  1. @override
Future<List<Device>> getDeviceList()
override

Implementation

@override
Future<List<Device>> getDeviceList() async {
  List<Device> devices = [];
  final pointer = _api.enumerate(0, 0);
  var current = pointer;
  while (current.address != nullptr.address) {
    final ref = current.ref;
    devices.add(UsbDevice(
      vendorId: ref.vendor_id,
      productId: ref.product_id,
      serialNumber: ref.serial_number.toDartString(),
      productName: ref.product_string.toDartString(),
      usagePage: ref.usage_page,
      usage: ref.usage,
    ));
    current = ref.next;
  }
  _api.free_enumeration(pointer);
  return devices;
}