java.lang.Object
net.codecrete.usb.USB
Provides access to USB devices.
-
Method Summary
Modifier and TypeMethodDescriptionGets a list of all connected USB devices.static USBDevicegetDevice(List<USBDeviceFilter> filters) Gets the first connected USB device matching any of the specified filters.static USBDevicegetDevice(USBDeviceFilter filter) Gets the first connected USB device matching the specified filter.getDevices(List<USBDeviceFilter> filters) Gets a list of connected USB devices matching any of the specified filters.getDevices(USBDeviceFilter filter) Gets a list of connected USB devices matching the specified filter.static voidsetOnDeviceConnected(Consumer<USBDevice> handler) Sets the handler to be called when a USB device is connected.static voidsetOnDeviceDisconnected(Consumer<USBDevice> handler) Sets the handler to be called when a USB device is disconnected.
-
Method Details
-
getAllDevices
Gets a list of all connected USB devices.Depending on the operating system, the list might or might not include USB hubs and USB host controllers.
- Returns:
- list of USB devices
-
getDevices
Gets a list of connected USB devices matching the specified filter.- Parameters:
filter- device filter- Returns:
- list of USB devices
-
getDevices
Gets a list of connected USB devices matching any of the specified filters.- Parameters:
filters- list of device filters- Returns:
- list of USB devices
-
getDevice
Gets the first connected USB device matching the specified filter.- Parameters:
filter- device filter- Returns:
- USB device, or
nullif no device matches
-
getDevice
Gets the first connected USB device matching any of the specified filters.- Parameters:
filters- list of device filters- Returns:
- USB device, or
nullif no device matches
-
setOnDeviceConnected
Sets the handler to be called when a USB device is connected.- Parameters:
handler- handler function, ornullto remove a previous handler
-
setOnDeviceDisconnected
Sets the handler to be called when a USB device is disconnected.- Parameters:
handler- handler function, ornullto remove a previous handler
-