Windows.Devices.Usb Namespace
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
This namespace defines Windows Runtime classes that a UWP app can use to communicate with WinUSB devices. These devices are handled by the inbox winusb.sys
driver and are identified by a specific Microsoft OS Descriptor.
A valid WinUSB device will have a compatible id of USB\MS_COMP_WINUSB
Device Support
This namespace supports most WinUSB devices. However, it does not provide access to USB devices with device classes of the following:
- Audio (
0x01
) - HID (
0x03
) - Image (
0x06
) - Printer (
0x07
) - Mass Storage (
0x08
) - Smart Card (
0x0B
) - Audio/Video (
0x10
) - Wireless Controller (
0xE0
)
USB Device Capabilities
A UWP app that accesses a USB device must include specific device capability data in the capabilities node of its manifest. This data identifies the device and its purpose (or function). Note that some devices may have multiple functions.
Since Windows 10, version 1809 (October 2018 Update)
<DeviceCapability Name="usb"/>
Before Windows 10, version 1809 (October 2018 Update)
Since 1809, the VendorId/ProductId and function-type no longer need to be specified and will be ignored on newer systems. If targeting systems below 1809, then see legacy USB device capabilities.
Troubleshooting
- Verify the USB capability (
usb
) is in the application manifest. - Verify the user has granted permission for the application to utilize USB devices.
- Validate the device type is not one designated as inaccessible.
- Machine-internal devices (
DEVPKEY_Device_InLocalMachineContainer == TRUE
) are generally not accessible unless running on a SKU with embedded mode andlowLevelDevices
capability. - Devices with stacks that contain upper/lower filter drivers are generally not accessible. These are sometimes added by 3rd parties to enable additional functionality for custom hardware.
- Device restriction is partially determined by
winusb.sys
during device enumeration, which may set the device interface propertyDEVPKEY_DeviceInterface_Restricted
toTRUE
on the WinUSB Device InterfaceGUID_DEVINTERFACE_WINUSB_WINRT
based on the presence of device/class filters. - The presence of device UpperFilter/LowerFilter drivers can be determined using DeviceManager by looking for
UpperFilters
andLowerFilters
properties. - The presence of WinUSB class UpperFilter/LowerFilter drivers can be determined using DeviceManager by looking for
Class upper filters
andClass lower filters
properties. - Device Interface properties can be inspected by calling
CM_Get_Device_Interface_Property
wherepszDeviceInterface
is the same string as would be passed to FromIdAsync.
- Device restriction is partially determined by
- These restrictions can be bypassed when making a custom device by working with the driver-developer to create a Hardware Support App
Classes
UsbBulkInEndpointDescriptor |
The endpoint descriptor for a USB bulk IN endpoint. The descriptor specifies the endpoint type, direction, number and also the maximum number of bytes that can be read from the endpoint, in a single transfer. |
UsbBulkInPipe |
Represents the pipe that the underlying USB driver opens to communicate with a USB bulk IN endpoint of the device. The app can get an input stream from the pipe and access data is being read from the endpoint. |
UsbBulkOutEndpointDescriptor |
The endpoint descriptor for a USB bulk OUT endpoint. The descriptor specifies the endpoint type, direction, number and also the maximum number of bytes that can be written to the endpoint, in a single transfer. |
UsbBulkOutPipe |
Represents the pipe that the underlying USB driver opens to communicate with a USB bulk OUT endpoint of the device. The object provides access to an output stream to which the app can write data to send to the endpoint. |
UsbConfiguration |
Provides information about a USB configuration, its descriptors and the interfaces defined within that configuration. For an explanation of a USB configuration, see Section 9.6.3 in the Universal Serial Bus (USB) specification. |
UsbConfigurationDescriptor |
Derives information from the first 9 bytes of a USB configuration descriptor. The information includes the power capabilities of the device when the configuration is active and the number of interfaces included in that configuration. For an explanation of a configuration descriptor, Section 9.6.3 Universal Serial Bus Specification. For information about descriptor fields, see:
|
UsbControlRequestType |
Provides information about the USB control transfer, the type of control request, whether the data is sent from or to the host, and the recipient of the request in the device. |
UsbDescriptor |
Provides information about the type of descriptor, its size (in bytes), and gets the descriptor data. |
UsbDevice |
Represents a USB device. The object provides methods and properties that an app can use to enumerate WinUSB devices and send IN and OUT control transfers. |
UsbDeviceClass |
Provides a way for the app to get an Advanced Query Syntax (AQS) string by specifying the class code, subclass code, and the protocol code defined by the device. The properties in this class are passed in the call to GetDeviceClassSelector. |
UsbDeviceClasses |
Provides a way for you to retrieve a UsbDeviceClass object based on the USB device class of a device. The properties defined in this class represent the supported USB device classes, and they return UsbDeviceClass objects. For information about USB device classes, see the official USB Website for Approved Class Specification Documents. |
UsbDeviceDescriptor |
Derives information from the USB device descriptor of the device. For an explanation of the device descriptor, see Table 9.8 in the Universal Serial Bus Specification. |
UsbEndpointDescriptor |
Derives information from the USB endpoint descriptor of the endpoint, such as type, direction, and endpoint number. This object also gets the specific endpoint descriptors based on the type of endpoint. For an explanation of an endpoint descriptor, see Section 9.6.5 in the Universal Serial Bus Specification:
|
UsbInterface |
Provides information about the USB interface including its endpoints, the number of alternate settings the interface supports, and gets the entire descriptor set for those settings. It also obtains pipes associated with the endpoints that the interface supports. |
UsbInterfaceDescriptor |
Describes a USB alternate setting (of an interface) in an interface descriptor. For an explanation of an interface descriptor, see Section 9.6.5 in the Universal Serial Bus Specification:
|
UsbInterfaceSetting |
Provides information about an alternate setting and select that setting. The app can get the USB interface descriptors for the setting and its endpoints, and determine whether this setting is currently selected. |
UsbInterruptInEndpointDescriptor |
The endpoint descriptor for a USB interrupt IN endpoint. The descriptor specifies the endpoint type, direction, number and also the maximum number of bytes that can be read from the endpoint, in a single transfer. The app can also get information about how often the host polls the endpoint for data. |
UsbInterruptInEventArgs |
Represents the object that is passed as a parameter to the event handler for the DataReceived event. |
UsbInterruptInPipe |
Represents the pipe that the underlying USB driver opens to communicate with a USB interrupt IN endpoint of the device. The object also enables the app to specify an event handler. That handler that gets invoked when data is read from the endpoint. |
UsbInterruptOutEndpointDescriptor |
The endpoint descriptor for a USB interrupt OUT endpoint. The descriptor specifies the endpoint type, direction, number and also the maximum number of bytes that can be written to the endpoint, in a single transfer. The app can also get information about how often the host polls the endpoint to send data. |
UsbInterruptOutPipe |
Represents the pipe that the underlying USB driver opens to communicate with a USB interrupt OUT endpoint of the device. The object provides access to an output stream to which the app can write data to send to the endpoint. |
UsbSetupPacket |
Describes the setup packet for a USB control transfer. For an explanation of the setup packet, see Table 9.2 in the Universal Serial Bus (USB) specification. |
Enums
UsbControlRecipient |
Defines constants that indicate the recipient of a USB control transfer. The recipient is defined in the setup packet of the control request. See Table 9.2 of section 9.3 of the Universal Serial Bus (USB) specification (www.usb.org). |
UsbControlTransferType |
Defines constants that indicate the type of USB control transfer: standard, class, or vendor. |
UsbEndpointType |
Defines constants that indicate the type of USB endpoint: control, bulk, isochronous, or interrupt. |
UsbReadOptions |
Defines constants for configuration flags that can be set for a USB pipe that the host opens for a USB bulk IN endpoint. |
UsbTransferDirection |
Defines constants that indicate the direction of USB transfer: IN or OUT transfers. |
UsbWriteOptions |
Defines constants for configuration flags that can be set for a USB pipe that the host opens for a USB OUT endpoint. |