File indexing completed on 2024-05-19 05:29:59

0001 /*
0002  *   SPDX-FileCopyrightText: 2001 Matthias Hoelzer-Kluepfel <mhk@caldera.de>
0003  *   SPDX-License-Identifier: GPL-2.0-or-later
0004  */
0005 
0006 #ifndef __USB_DEVICES_H__
0007 #define __USB_DEVICES_H__
0008 
0009 #include <QList>
0010 #include <QString>
0011 
0012 #include <libusb.h>
0013 
0014 class USBDB;
0015 
0016 class USBDevice
0017 {
0018 public:
0019     USBDevice(libusb_device *dev, struct libusb_device_descriptor &dev_desc);
0020 
0021     ~USBDevice();
0022 
0023     int level() const
0024     {
0025         return _level;
0026     }
0027     int device() const
0028     {
0029         return _device;
0030     }
0031     int parent() const
0032     {
0033         return _parent;
0034     }
0035     int bus() const
0036     {
0037         return _bus;
0038     }
0039     QString product();
0040 
0041     QString dump();
0042 
0043     static QList<USBDevice *> &devices()
0044     {
0045         return _devices;
0046     }
0047     static USBDevice *find(int bus, int device);
0048     static bool load();
0049     static void clear();
0050 
0051 private:
0052     static QList<USBDevice *> _devices;
0053     static libusb_context *_context;
0054 
0055     static USBDB *_db;
0056 
0057     int _bus, _level, _parent, _port, _device, _channels;
0058     float _speed;
0059 
0060     QString _manufacturer, _product, _serial;
0061 
0062     unsigned int _verMajor, _verMinor;
0063     uint8_t _class, _sub, _prot;
0064     unsigned int _maxPacketSize;
0065 
0066     uint16_t _vendorID, _prodID;
0067 
0068     void collectDataSys(libusb_device *dev);
0069 };
0070 
0071 #endif