Class MacUsbDevice

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static com.sun.jna.platform.mac.CoreFoundation CF  
      private static java.lang.String IOSERVICE  
      private static java.lang.String IOUSB  
    • Constructor Summary

      Constructors 
      Constructor Description
      MacUsbDevice​(java.lang.String name, java.lang.String vendor, java.lang.String vendorId, java.lang.String productId, java.lang.String serialNumber, java.lang.String uniqueDeviceId, java.util.List<UsbDevice> connectedDevices)  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      private static void addDeviceAndChildrenToMaps​(com.sun.jna.platform.mac.IOKit.IORegistryEntry device, long parentId, java.util.Map<java.lang.Long,​java.lang.String> nameMap, java.util.Map<java.lang.Long,​java.lang.String> vendorMap, java.util.Map<java.lang.Long,​java.lang.String> vendorIdMap, java.util.Map<java.lang.Long,​java.lang.String> productIdMap, java.util.Map<java.lang.Long,​java.lang.String> serialMap, java.util.Map<java.lang.Long,​java.util.List<java.lang.Long>> hubMap)
      Recursively populate maps with information from a USB Device and its children
      private static void addDevicesToList​(java.util.List<UsbDevice> deviceList, java.util.List<UsbDevice> list)  
      private static void getControllerIdByLocation​(long id, com.sun.jna.platform.mac.CoreFoundation.CFTypeRef locationId, com.sun.jna.platform.mac.CoreFoundation.CFStringRef locationIDKey, com.sun.jna.platform.mac.CoreFoundation.CFStringRef ioPropertyMatchKey, java.util.Map<java.lang.Long,​java.lang.String> vendorIdMap, java.util.Map<java.lang.Long,​java.lang.String> productIdMap)
      Looks up vendor and product id information for a USB Host Controller by cross-referencing the location
      private static MacUsbDevice getDeviceAndChildren​(java.lang.Long registryEntryId, java.lang.String vid, java.lang.String pid, java.util.Map<java.lang.Long,​java.lang.String> nameMap, java.util.Map<java.lang.Long,​java.lang.String> vendorMap, java.util.Map<java.lang.Long,​java.lang.String> vendorIdMap, java.util.Map<java.lang.Long,​java.lang.String> productIdMap, java.util.Map<java.lang.Long,​java.lang.String> serialMap, java.util.Map<java.lang.Long,​java.util.List<java.lang.Long>> hubMap)
      Recursively creates MacUsbDevices by fetching information from maps to populate fields
      private static java.util.List<UsbDevice> getUsbDevices()  
      static java.util.List<UsbDevice> getUsbDevices​(boolean tree)
      Instantiates a list of UsbDevice objects, representing devices connected via a usb port (including internal devices).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • CF

        private static final com.sun.jna.platform.mac.CoreFoundation CF
    • Constructor Detail

      • MacUsbDevice

        public MacUsbDevice​(java.lang.String name,
                            java.lang.String vendor,
                            java.lang.String vendorId,
                            java.lang.String productId,
                            java.lang.String serialNumber,
                            java.lang.String uniqueDeviceId,
                            java.util.List<UsbDevice> connectedDevices)
    • Method Detail

      • getUsbDevices

        public static java.util.List<UsbDevice> getUsbDevices​(boolean tree)
        Instantiates a list of UsbDevice objects, representing devices connected via a usb port (including internal devices).

        If the value of tree is true, the top level devices returned from this method are the USB Controllers; connected hubs and devices in its device tree share that controller's bandwidth. If the value of tree is false, USB devices (not controllers) are listed in a single flat list.

        Parameters:
        tree - If true, returns a list of controllers, which requires recursive iteration of connected devices. If false, returns a flat list of devices excluding controllers.
        Returns:
        a list of UsbDevice objects.
      • getUsbDevices

        private static java.util.List<UsbDevice> getUsbDevices()
      • addDeviceAndChildrenToMaps

        private static void addDeviceAndChildrenToMaps​(com.sun.jna.platform.mac.IOKit.IORegistryEntry device,
                                                       long parentId,
                                                       java.util.Map<java.lang.Long,​java.lang.String> nameMap,
                                                       java.util.Map<java.lang.Long,​java.lang.String> vendorMap,
                                                       java.util.Map<java.lang.Long,​java.lang.String> vendorIdMap,
                                                       java.util.Map<java.lang.Long,​java.lang.String> productIdMap,
                                                       java.util.Map<java.lang.Long,​java.lang.String> serialMap,
                                                       java.util.Map<java.lang.Long,​java.util.List<java.lang.Long>> hubMap)
        Recursively populate maps with information from a USB Device and its children
        Parameters:
        device - The device which, along with its children, should be added
        parentId - The id of the device's parent.
        nameMap - the map of names
        vendorMap - the map of vendors
        vendorIdMap - the map of vendorIds
        productIdMap - the map of productIds
        serialMap - the map of serial numbers
        hubMap - the map of hubs
      • addDevicesToList

        private static void addDevicesToList​(java.util.List<UsbDevice> deviceList,
                                             java.util.List<UsbDevice> list)
      • getControllerIdByLocation

        private static void getControllerIdByLocation​(long id,
                                                      com.sun.jna.platform.mac.CoreFoundation.CFTypeRef locationId,
                                                      com.sun.jna.platform.mac.CoreFoundation.CFStringRef locationIDKey,
                                                      com.sun.jna.platform.mac.CoreFoundation.CFStringRef ioPropertyMatchKey,
                                                      java.util.Map<java.lang.Long,​java.lang.String> vendorIdMap,
                                                      java.util.Map<java.lang.Long,​java.lang.String> productIdMap)
        Looks up vendor and product id information for a USB Host Controller by cross-referencing the location
        Parameters:
        id - The global unique ID for the host controller used as a key for maps
        locationId - The locationID of this controller returned from the registry
        locationIDKey - A pointer to the locationID string
        ioPropertyMatchKey - A pointer to the IOPropertyMatch string
        productIdMap - the map of productIds
        vendorIdMap - the map of vendorIds
      • getDeviceAndChildren

        private static MacUsbDevice getDeviceAndChildren​(java.lang.Long registryEntryId,
                                                         java.lang.String vid,
                                                         java.lang.String pid,
                                                         java.util.Map<java.lang.Long,​java.lang.String> nameMap,
                                                         java.util.Map<java.lang.Long,​java.lang.String> vendorMap,
                                                         java.util.Map<java.lang.Long,​java.lang.String> vendorIdMap,
                                                         java.util.Map<java.lang.Long,​java.lang.String> productIdMap,
                                                         java.util.Map<java.lang.Long,​java.lang.String> serialMap,
                                                         java.util.Map<java.lang.Long,​java.util.List<java.lang.Long>> hubMap)
        Recursively creates MacUsbDevices by fetching information from maps to populate fields
        Parameters:
        registryEntryId - The device unique registry id.
        vid - The default (parent) vendor ID
        pid - The default (parent) product ID
        nameMap - the map of names
        vendorMap - the map of vendors
        vendorIdMap - the map of vendorIds
        productIdMap - the map of productIds
        serialMap - the map of serial numbers
        hubMap - the map of hubs
        Returns:
        A MacUsbDevice corresponding to this device