# WARNING: Please don't edit this file. It was generated by Python/WinRT v1.0.0-beta.9

import enum
import datetime
import sys
import types
import typing

import winsdk.system
import winsdk.windows.foundation
import winsdk.windows.foundation.collections
import winsdk.windows.storage.streams

class UsbControlRecipient(enum.IntEnum):
    DEVICE = 0
    SPECIFIED_INTERFACE = 1
    ENDPOINT = 2
    OTHER = 3
    DEFAULT_INTERFACE = 4

class UsbControlTransferType(enum.IntEnum):
    STANDARD = 0
    CLASS = 1
    VENDOR = 2

class UsbEndpointType(enum.IntEnum):
    CONTROL = 0
    ISOCHRONOUS = 1
    BULK = 2
    INTERRUPT = 3

class UsbReadOptions(enum.IntFlag):
    NONE = 0
    AUTO_CLEAR_STALL = 0x1
    OVERRIDE_AUTOMATIC_BUFFER_MANAGEMENT = 0x2
    IGNORE_SHORT_PACKET = 0x4
    ALLOW_PARTIAL_READS = 0x8

class UsbTransferDirection(enum.IntEnum):
    OUT = 0
    IN = 1

class UsbWriteOptions(enum.IntFlag):
    NONE = 0
    AUTO_CLEAR_STALL = 0x1
    SHORT_PACKET_TERMINATE = 0x2

Self = typing.TypeVar('Self')

class UsbBulkInEndpointDescriptor(winsdk.system.Object):
    endpoint_number: winsdk.system.UInt8
    max_packet_size: winsdk.system.UInt32
    pipe: typing.Optional[UsbBulkInPipe]
    @staticmethod
    def _from(obj: winsdk.system.Object) -> UsbBulkInEndpointDescriptor: ...

class UsbBulkInPipe(winsdk.system.Object):
    read_options: UsbReadOptions
    endpoint_descriptor: typing.Optional[UsbBulkInEndpointDescriptor]
    input_stream: typing.Optional[winsdk.windows.storage.streams.IInputStream]
    max_transfer_size_bytes: winsdk.system.UInt32
    @staticmethod
    def _from(obj: winsdk.system.Object) -> UsbBulkInPipe: ...
    def clear_stall_async(self) -> winsdk.windows.foundation.IAsyncAction: ...
    def flush_buffer(self) -> None: ...

class UsbBulkOutEndpointDescriptor(winsdk.system.Object):
    endpoint_number: winsdk.system.UInt8
    max_packet_size: winsdk.system.UInt32
    pipe: typing.Optional[UsbBulkOutPipe]
    @staticmethod
    def _from(obj: winsdk.system.Object) -> UsbBulkOutEndpointDescriptor: ...

class UsbBulkOutPipe(winsdk.system.Object):
    write_options: UsbWriteOptions
    endpoint_descriptor: typing.Optional[UsbBulkOutEndpointDescriptor]
    output_stream: typing.Optional[winsdk.windows.storage.streams.IOutputStream]
    @staticmethod
    def _from(obj: winsdk.system.Object) -> UsbBulkOutPipe: ...
    def clear_stall_async(self) -> winsdk.windows.foundation.IAsyncAction: ...

class UsbConfiguration(winsdk.system.Object):
    configuration_descriptor: typing.Optional[UsbConfigurationDescriptor]
    descriptors: typing.Optional[winsdk.windows.foundation.collections.IVectorView[UsbDescriptor]]
    usb_interfaces: typing.Optional[winsdk.windows.foundation.collections.IVectorView[UsbInterface]]
    @staticmethod
    def _from(obj: winsdk.system.Object) -> UsbConfiguration: ...

class UsbConfigurationDescriptor(winsdk.system.Object):
    configuration_value: winsdk.system.UInt8
    max_power_milliamps: winsdk.system.UInt32
    remote_wakeup: winsdk.system.Boolean
    self_powered: winsdk.system.Boolean
    @staticmethod
    def _from(obj: winsdk.system.Object) -> UsbConfigurationDescriptor: ...
    @staticmethod
    def parse(descriptor: typing.Optional[UsbDescriptor]) -> typing.Optional[UsbConfigurationDescriptor]: ...
    @staticmethod
    def try_parse(descriptor: typing.Optional[UsbDescriptor]) -> typing.Tuple[winsdk.system.Boolean, typing.Optional[UsbConfigurationDescriptor]]: ...

class UsbControlRequestType(winsdk.system.Object):
    recipient: UsbControlRecipient
    direction: UsbTransferDirection
    control_transfer_type: UsbControlTransferType
    as_byte: winsdk.system.UInt8
    @staticmethod
    def _from(obj: winsdk.system.Object) -> UsbControlRequestType: ...
    def __new__(cls: typing.Type[UsbControlRequestType]) -> UsbControlRequestType:...

class UsbDescriptor(winsdk.system.Object):
    descriptor_type: winsdk.system.UInt8
    length: winsdk.system.UInt8
    @staticmethod
    def _from(obj: winsdk.system.Object) -> UsbDescriptor: ...
    def read_descriptor_buffer(self, buffer: typing.Optional[winsdk.windows.storage.streams.IBuffer]) -> None: ...

class UsbDevice(winsdk.system.Object):
    configuration: typing.Optional[UsbConfiguration]
    default_interface: typing.Optional[UsbInterface]
    device_descriptor: typing.Optional[UsbDeviceDescriptor]
    def __enter__(self: Self) -> Self: ...
    def __exit__(self, *args) -> None: ...
    @staticmethod
    def _from(obj: winsdk.system.Object) -> UsbDevice: ...
    def close(self) -> None: ...
    @staticmethod
    def from_id_async(device_id: str) -> winsdk.windows.foundation.IAsyncOperation[UsbDevice]: ...
    @staticmethod
    def get_device_class_selector(usb_class: typing.Optional[UsbDeviceClass]) -> str: ...
    @typing.overload
    @staticmethod
    def get_device_selector(win_usb_interface_class: winsdk.system.Guid) -> str: ...
    @typing.overload
    @staticmethod
    def get_device_selector(vendor_id: winsdk.system.UInt32, product_id: winsdk.system.UInt32) -> str: ...
    @typing.overload
    @staticmethod
    def get_device_selector(vendor_id: winsdk.system.UInt32, product_id: winsdk.system.UInt32, win_usb_interface_class: winsdk.system.Guid) -> str: ...
    @typing.overload
    def send_control_in_transfer_async(self, setup_packet: typing.Optional[UsbSetupPacket]) -> winsdk.windows.foundation.IAsyncOperation[winsdk.windows.storage.streams.IBuffer]: ...
    @typing.overload
    def send_control_in_transfer_async(self, setup_packet: typing.Optional[UsbSetupPacket], buffer: typing.Optional[winsdk.windows.storage.streams.IBuffer]) -> winsdk.windows.foundation.IAsyncOperation[winsdk.windows.storage.streams.IBuffer]: ...
    @typing.overload
    def send_control_out_transfer_async(self, setup_packet: typing.Optional[UsbSetupPacket]) -> winsdk.windows.foundation.IAsyncOperation[winsdk.system.UInt32]: ...
    @typing.overload
    def send_control_out_transfer_async(self, setup_packet: typing.Optional[UsbSetupPacket], buffer: typing.Optional[winsdk.windows.storage.streams.IBuffer]) -> winsdk.windows.foundation.IAsyncOperation[winsdk.system.UInt32]: ...

class UsbDeviceClass(winsdk.system.Object):
    subclass_code: typing.Optional[typing.Optional[winsdk.system.UInt8]]
    protocol_code: typing.Optional[typing.Optional[winsdk.system.UInt8]]
    class_code: winsdk.system.UInt8
    @staticmethod
    def _from(obj: winsdk.system.Object) -> UsbDeviceClass: ...
    def __new__(cls: typing.Type[UsbDeviceClass]) -> UsbDeviceClass:...

class UsbDeviceClasses(winsdk.system.Object):
    active_sync: typing.ClassVar[typing.Optional[UsbDeviceClass]]
    cdc_control: typing.ClassVar[typing.Optional[UsbDeviceClass]]
    device_firmware_update: typing.ClassVar[typing.Optional[UsbDeviceClass]]
    irda: typing.ClassVar[typing.Optional[UsbDeviceClass]]
    measurement: typing.ClassVar[typing.Optional[UsbDeviceClass]]
    palm_sync: typing.ClassVar[typing.Optional[UsbDeviceClass]]
    personal_healthcare: typing.ClassVar[typing.Optional[UsbDeviceClass]]
    physical: typing.ClassVar[typing.Optional[UsbDeviceClass]]
    vendor_specific: typing.ClassVar[typing.Optional[UsbDeviceClass]]
    @staticmethod
    def _from(obj: winsdk.system.Object) -> UsbDeviceClasses: ...

class UsbDeviceDescriptor(winsdk.system.Object):
    bcd_device_revision: winsdk.system.UInt32
    bcd_usb: winsdk.system.UInt32
    max_packet_size0: winsdk.system.UInt8
    number_of_configurations: winsdk.system.UInt8
    product_id: winsdk.system.UInt32
    vendor_id: winsdk.system.UInt32
    @staticmethod
    def _from(obj: winsdk.system.Object) -> UsbDeviceDescriptor: ...

class UsbEndpointDescriptor(winsdk.system.Object):
    as_bulk_in_endpoint_descriptor: typing.Optional[UsbBulkInEndpointDescriptor]
    as_bulk_out_endpoint_descriptor: typing.Optional[UsbBulkOutEndpointDescriptor]
    as_interrupt_in_endpoint_descriptor: typing.Optional[UsbInterruptInEndpointDescriptor]
    as_interrupt_out_endpoint_descriptor: typing.Optional[UsbInterruptOutEndpointDescriptor]
    direction: UsbTransferDirection
    endpoint_number: winsdk.system.UInt8
    endpoint_type: UsbEndpointType
    @staticmethod
    def _from(obj: winsdk.system.Object) -> UsbEndpointDescriptor: ...
    @staticmethod
    def parse(descriptor: typing.Optional[UsbDescriptor]) -> typing.Optional[UsbEndpointDescriptor]: ...
    @staticmethod
    def try_parse(descriptor: typing.Optional[UsbDescriptor]) -> typing.Tuple[winsdk.system.Boolean, typing.Optional[UsbEndpointDescriptor]]: ...

class UsbInterface(winsdk.system.Object):
    bulk_in_pipes: typing.Optional[winsdk.windows.foundation.collections.IVectorView[UsbBulkInPipe]]
    bulk_out_pipes: typing.Optional[winsdk.windows.foundation.collections.IVectorView[UsbBulkOutPipe]]
    descriptors: typing.Optional[winsdk.windows.foundation.collections.IVectorView[UsbDescriptor]]
    interface_number: winsdk.system.UInt8
    interface_settings: typing.Optional[winsdk.windows.foundation.collections.IVectorView[UsbInterfaceSetting]]
    interrupt_in_pipes: typing.Optional[winsdk.windows.foundation.collections.IVectorView[UsbInterruptInPipe]]
    interrupt_out_pipes: typing.Optional[winsdk.windows.foundation.collections.IVectorView[UsbInterruptOutPipe]]
    @staticmethod
    def _from(obj: winsdk.system.Object) -> UsbInterface: ...

class UsbInterfaceDescriptor(winsdk.system.Object):
    alternate_setting_number: winsdk.system.UInt8
    class_code: winsdk.system.UInt8
    interface_number: winsdk.system.UInt8
    protocol_code: winsdk.system.UInt8
    subclass_code: winsdk.system.UInt8
    @staticmethod
    def _from(obj: winsdk.system.Object) -> UsbInterfaceDescriptor: ...
    @staticmethod
    def parse(descriptor: typing.Optional[UsbDescriptor]) -> typing.Optional[UsbInterfaceDescriptor]: ...
    @staticmethod
    def try_parse(descriptor: typing.Optional[UsbDescriptor]) -> typing.Tuple[winsdk.system.Boolean, typing.Optional[UsbInterfaceDescriptor]]: ...

class UsbInterfaceSetting(winsdk.system.Object):
    bulk_in_endpoints: typing.Optional[winsdk.windows.foundation.collections.IVectorView[UsbBulkInEndpointDescriptor]]
    bulk_out_endpoints: typing.Optional[winsdk.windows.foundation.collections.IVectorView[UsbBulkOutEndpointDescriptor]]
    descriptors: typing.Optional[winsdk.windows.foundation.collections.IVectorView[UsbDescriptor]]
    interface_descriptor: typing.Optional[UsbInterfaceDescriptor]
    interrupt_in_endpoints: typing.Optional[winsdk.windows.foundation.collections.IVectorView[UsbInterruptInEndpointDescriptor]]
    interrupt_out_endpoints: typing.Optional[winsdk.windows.foundation.collections.IVectorView[UsbInterruptOutEndpointDescriptor]]
    selected: winsdk.system.Boolean
    @staticmethod
    def _from(obj: winsdk.system.Object) -> UsbInterfaceSetting: ...
    def select_setting_async(self) -> winsdk.windows.foundation.IAsyncAction: ...

class UsbInterruptInEndpointDescriptor(winsdk.system.Object):
    endpoint_number: winsdk.system.UInt8
    interval: datetime.timedelta
    max_packet_size: winsdk.system.UInt32
    pipe: typing.Optional[UsbInterruptInPipe]
    @staticmethod
    def _from(obj: winsdk.system.Object) -> UsbInterruptInEndpointDescriptor: ...

class UsbInterruptInEventArgs(winsdk.system.Object):
    interrupt_data: typing.Optional[winsdk.windows.storage.streams.IBuffer]
    @staticmethod
    def _from(obj: winsdk.system.Object) -> UsbInterruptInEventArgs: ...

class UsbInterruptInPipe(winsdk.system.Object):
    endpoint_descriptor: typing.Optional[UsbInterruptInEndpointDescriptor]
    @staticmethod
    def _from(obj: winsdk.system.Object) -> UsbInterruptInPipe: ...
    def clear_stall_async(self) -> winsdk.windows.foundation.IAsyncAction: ...
    def add_data_received(self, handler: winsdk.windows.foundation.TypedEventHandler[UsbInterruptInPipe, UsbInterruptInEventArgs]) -> winsdk.windows.foundation.EventRegistrationToken: ...
    def remove_data_received(self, token: winsdk.windows.foundation.EventRegistrationToken) -> None: ...

class UsbInterruptOutEndpointDescriptor(winsdk.system.Object):
    endpoint_number: winsdk.system.UInt8
    interval: datetime.timedelta
    max_packet_size: winsdk.system.UInt32
    pipe: typing.Optional[UsbInterruptOutPipe]
    @staticmethod
    def _from(obj: winsdk.system.Object) -> UsbInterruptOutEndpointDescriptor: ...

class UsbInterruptOutPipe(winsdk.system.Object):
    write_options: UsbWriteOptions
    endpoint_descriptor: typing.Optional[UsbInterruptOutEndpointDescriptor]
    output_stream: typing.Optional[winsdk.windows.storage.streams.IOutputStream]
    @staticmethod
    def _from(obj: winsdk.system.Object) -> UsbInterruptOutPipe: ...
    def clear_stall_async(self) -> winsdk.windows.foundation.IAsyncAction: ...

class UsbSetupPacket(winsdk.system.Object):
    value: winsdk.system.UInt32
    request_type: typing.Optional[UsbControlRequestType]
    request: winsdk.system.UInt8
    length: winsdk.system.UInt32
    index: winsdk.system.UInt32
    @staticmethod
    def _from(obj: winsdk.system.Object) -> UsbSetupPacket: ...
    @typing.overload
    def __new__(cls: typing.Type[UsbSetupPacket], eight_byte_buffer: typing.Optional[winsdk.windows.storage.streams.IBuffer]) -> UsbSetupPacket:...
    @typing.overload
    def __new__(cls: typing.Type[UsbSetupPacket]) -> UsbSetupPacket:...

