Windows: Header file cleanup
authorChris Dickens <christopher.a.dickens@gmail.com>
Tue, 6 Jun 2017 06:18:13 +0000 (23:18 -0700)
committerChris Dickens <christopher.a.dickens@gmail.com>
Tue, 6 Jun 2017 06:18:13 +0000 (23:18 -0700)
This commit removes unused or redundant definitions from the
windows_winusb.h header file and leverages existing definitions
within the core library headers. The definitions of structures
related to the Windows API are also modified to match official
headers.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
libusb/os/windows_winusb.c
libusb/os/windows_winusb.h
libusb/version_nano.h

index 2371096..16f31fb 100644 (file)
@@ -856,7 +856,7 @@ static int force_hcd_device_descriptor(struct libusb_device *dev)
 
        dev->num_configurations = 1;
        priv->dev_descriptor.bLength = sizeof(USB_DEVICE_DESCRIPTOR);
-       priv->dev_descriptor.bDescriptorType = USB_DEVICE_DESCRIPTOR_TYPE;
+       priv->dev_descriptor.bDescriptorType = LIBUSB_DT_DEVICE;
        priv->dev_descriptor.bNumConfigurations = 1;
        priv->active_config = 1;
 
@@ -908,15 +908,15 @@ static int cache_config_descriptors(struct libusb_device *dev, HANDLE hub_handle
                if ((i >= dev->num_configurations) || (r != LIBUSB_SUCCESS))
                        break;
 
-               size = sizeof(USB_CONFIGURATION_DESCRIPTOR_SHORT);
+               size = sizeof(cd_buf_short);
                memset(&cd_buf_short, 0, size);
 
                cd_buf_short.req.ConnectionIndex = (ULONG)priv->port;
                cd_buf_short.req.SetupPacket.bmRequest = LIBUSB_ENDPOINT_IN;
-               cd_buf_short.req.SetupPacket.bRequest = USB_REQUEST_GET_DESCRIPTOR;
-               cd_buf_short.req.SetupPacket.wValue = (USB_CONFIGURATION_DESCRIPTOR_TYPE << 8) | i;
+               cd_buf_short.req.SetupPacket.bRequest = LIBUSB_REQUEST_GET_DESCRIPTOR;
+               cd_buf_short.req.SetupPacket.wValue = (LIBUSB_DT_CONFIG << 8) | i;
                cd_buf_short.req.SetupPacket.wIndex = 0;
-               cd_buf_short.req.SetupPacket.wLength = (USHORT)(size - sizeof(USB_DESCRIPTOR_REQUEST));
+               cd_buf_short.req.SetupPacket.wLength = (USHORT)sizeof(USB_CONFIGURATION_DESCRIPTOR);
 
                // Dummy call to get the required data size. Initial failures are reported as info rather
                // than error as they can occur for non-penalizing situations, such as with some hubs.
@@ -927,12 +927,12 @@ static int cache_config_descriptors(struct libusb_device *dev, HANDLE hub_handle
                        LOOP_BREAK(LIBUSB_ERROR_IO);
                }
 
-               if ((ret_size != size) || (cd_buf_short.data.wTotalLength < sizeof(USB_CONFIGURATION_DESCRIPTOR))) {
+               if ((ret_size != size) || (cd_buf_short.desc.wTotalLength < sizeof(USB_CONFIGURATION_DESCRIPTOR))) {
                        usbi_info(ctx, "unexpected configuration descriptor size (dummy) for '%s'.", device_id);
                        LOOP_BREAK(LIBUSB_ERROR_IO);
                }
 
-               size = sizeof(USB_DESCRIPTOR_REQUEST) + cd_buf_short.data.wTotalLength;
+               size = sizeof(USB_DESCRIPTOR_REQUEST) + cd_buf_short.desc.wTotalLength;
                cd_buf_actual = calloc(1, size);
                if (cd_buf_actual == NULL) {
                        usbi_err(ctx, "could not allocate configuration descriptor buffer for '%s'.", device_id);
@@ -942,10 +942,10 @@ static int cache_config_descriptors(struct libusb_device *dev, HANDLE hub_handle
                // Actual call
                cd_buf_actual->ConnectionIndex = (ULONG)priv->port;
                cd_buf_actual->SetupPacket.bmRequest = LIBUSB_ENDPOINT_IN;
-               cd_buf_actual->SetupPacket.bRequest = USB_REQUEST_GET_DESCRIPTOR;
-               cd_buf_actual->SetupPacket.wValue = (USB_CONFIGURATION_DESCRIPTOR_TYPE << 8) | i;
+               cd_buf_actual->SetupPacket.bRequest = LIBUSB_REQUEST_GET_DESCRIPTOR;
+               cd_buf_actual->SetupPacket.wValue = (LIBUSB_DT_CONFIG << 8) | i;
                cd_buf_actual->SetupPacket.wIndex = 0;
-               cd_buf_actual->SetupPacket.wLength = (USHORT)(size - sizeof(USB_DESCRIPTOR_REQUEST));
+               cd_buf_actual->SetupPacket.wLength = cd_buf_short.desc.wTotalLength;
 
                if (!DeviceIoControl(hub_handle, IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION, cd_buf_actual, size,
                        cd_buf_actual, size, &ret_size, NULL)) {
@@ -955,12 +955,12 @@ static int cache_config_descriptors(struct libusb_device *dev, HANDLE hub_handle
 
                cd_data = (PUSB_CONFIGURATION_DESCRIPTOR)((UCHAR *)cd_buf_actual + sizeof(USB_DESCRIPTOR_REQUEST));
 
-               if ((size != ret_size) || (cd_data->wTotalLength != cd_buf_short.data.wTotalLength)) {
+               if ((size != ret_size) || (cd_data->wTotalLength != cd_buf_short.desc.wTotalLength)) {
                        usbi_err(ctx, "unexpected configuration descriptor size (actual) for '%s'.", device_id);
                        LOOP_BREAK(LIBUSB_ERROR_IO);
                }
 
-               if (cd_data->bDescriptorType != USB_CONFIGURATION_DESCRIPTOR_TYPE) {
+               if (cd_data->bDescriptorType != LIBUSB_DT_CONFIG) {
                        usbi_err(ctx, "not a configuration descriptor for '%s'", device_id);
                        LOOP_BREAK(LIBUSB_ERROR_IO);
                }
@@ -2751,9 +2751,9 @@ static int winusbx_submit_control_transfer(int sub_api, struct usbi_transfer *it
                return LIBUSB_ERROR_NO_MEM;
 
        // Sending of set configuration control requests from WinUSB creates issues
-       if (((setup->request_type & (0x03 << 5)) == LIBUSB_REQUEST_TYPE_STANDARD)
-                       && (setup->request == LIBUSB_REQUEST_SET_CONFIGURATION)) {
-               if (setup->value != priv->active_config) {
+       if ((LIBUSB_REQ_TYPE(setup->RequestType) == LIBUSB_REQUEST_TYPE_STANDARD)
+                       && (setup->Request == LIBUSB_REQUEST_SET_CONFIGURATION)) {
+               if (setup->Value != priv->active_config) {
                        usbi_warn(ctx, "cannot set configuration other than the default one");
                        usbi_free_fd(&wfd);
                        return LIBUSB_ERROR_INVALID_PARAM;
@@ -3753,12 +3753,12 @@ static int hid_submit_control_transfer(int sub_api, struct usbi_transfer *itrans
        if (wfd.fd < 0)
                return LIBUSB_ERROR_NOT_FOUND;
 
-       switch(LIBUSB_REQ_TYPE(setup->request_type)) {
+       switch(LIBUSB_REQ_TYPE(setup->RequestType)) {
        case LIBUSB_REQUEST_TYPE_STANDARD:
-               switch(setup->request) {
+               switch(setup->Request) {
                case LIBUSB_REQUEST_GET_DESCRIPTOR:
-                       r = _hid_get_descriptor(priv->hid, wfd.handle, LIBUSB_REQ_RECIPIENT(setup->request_type),
-                               (setup->value >> 8) & 0xFF, setup->value & 0xFF, transfer->buffer + LIBUSB_CONTROL_SETUP_SIZE, &size);
+                       r = _hid_get_descriptor(priv->hid, wfd.handle, LIBUSB_REQ_RECIPIENT(setup->RequestType),
+                               (setup->Value >> 8) & 0xFF, setup->Value & 0xFF, transfer->buffer + LIBUSB_CONTROL_SETUP_SIZE, &size);
                        break;
                case LIBUSB_REQUEST_GET_CONFIGURATION:
                        r = windows_get_configuration(transfer->dev_handle, &config);
@@ -3769,7 +3769,7 @@ static int hid_submit_control_transfer(int sub_api, struct usbi_transfer *itrans
                        }
                        break;
                case LIBUSB_REQUEST_SET_CONFIGURATION:
-                       if (setup->value == priv->active_config) {
+                       if (setup->Value == priv->active_config) {
                                r = LIBUSB_COMPLETED;
                        } else {
                                usbi_warn(ctx, "cannot set configuration other than the default one");
@@ -3782,7 +3782,7 @@ static int hid_submit_control_transfer(int sub_api, struct usbi_transfer *itrans
                        r = LIBUSB_COMPLETED;
                        break;
                case LIBUSB_REQUEST_SET_INTERFACE:
-                       r = hid_set_interface_altsetting(0, transfer->dev_handle, setup->index, setup->value);
+                       r = hid_set_interface_altsetting(0, transfer->dev_handle, setup->Index, setup->Value);
                        if (r == LIBUSB_SUCCESS)
                                r = LIBUSB_COMPLETED;
                        break;
@@ -3793,8 +3793,8 @@ static int hid_submit_control_transfer(int sub_api, struct usbi_transfer *itrans
                }
                break;
        case LIBUSB_REQUEST_TYPE_CLASS:
-               r = _hid_class_request(priv->hid, wfd.handle, setup->request_type, setup->request, setup->value,
-                       setup->index, transfer->buffer + LIBUSB_CONTROL_SETUP_SIZE, transfer_priv,
+               r = _hid_class_request(priv->hid, wfd.handle, setup->RequestType, setup->Request, setup->Value,
+                       setup->Index, transfer->buffer + LIBUSB_CONTROL_SETUP_SIZE, transfer_priv,
                        &size, wfd.overlapped);
                break;
        default:
@@ -4138,14 +4138,14 @@ static int composite_submit_control_transfer(int sub_api, struct usbi_transfer *
        // Interface shouldn't matter for control, but it does in practice, with Windows'
        // restrictions with regards to accessing HID keyboards and mice. Try to target
        // a specific interface first, if possible.
-       switch (LIBUSB_REQ_RECIPIENT(setup->request_type)) {
+       switch (LIBUSB_REQ_RECIPIENT(setup->RequestType)) {
        case LIBUSB_RECIPIENT_INTERFACE:
-               iface = setup->index & 0xFF;
+               iface = setup->Index & 0xFF;
                break;
        case LIBUSB_RECIPIENT_ENDPOINT:
                r = libusb_get_active_config_descriptor(transfer->dev_handle->dev, &conf_desc);
                if (r == LIBUSB_SUCCESS) {
-                       iface = get_interface_by_endpoint(conf_desc, (setup->index & 0xFF));
+                       iface = get_interface_by_endpoint(conf_desc, (setup->Index & 0xFF));
                        libusb_free_config_descriptor(conf_desc);
                        break;
                }
index b7b9cd9..89ebc24 100644 (file)
 #endif
 
 // Missing from MSVC6 setupapi.h
-#if !defined(SPDRP_ADDRESS)
+#ifndef SPDRP_ADDRESS
 #define SPDRP_ADDRESS          28
 #endif
-#if !defined(SPDRP_INSTALL_STATE)
+#ifndef SPDRP_INSTALL_STATE
 #define SPDRP_INSTALL_STATE    34
 #endif
 
 // http://msdn.microsoft.com/en-us/library/ff545978.aspx
 // http://msdn.microsoft.com/en-us/library/ff545972.aspx
 // http://msdn.microsoft.com/en-us/library/ff545982.aspx
-#if !defined(GUID_DEVINTERFACE_USB_HOST_CONTROLLER)
+#ifndef GUID_DEVINTERFACE_USB_HOST_CONTROLLER
 const GUID GUID_DEVINTERFACE_USB_HOST_CONTROLLER = { 0x3ABF6F2D, 0x71C4, 0x462A, {0x8A, 0x92, 0x1E, 0x68, 0x61, 0xE6, 0xAF, 0x27} };
 #endif
-#if !defined(GUID_DEVINTERFACE_USB_DEVICE)
+#ifndef GUID_DEVINTERFACE_USB_DEVICE
 const GUID GUID_DEVINTERFACE_USB_DEVICE = { 0xA5DCBF10, 0x6530, 0x11D2, {0x90, 0x1F, 0x00, 0xC0, 0x4F, 0xB9, 0x51, 0xED} };
 #endif
-#if !defined(GUID_DEVINTERFACE_USB_HUB)
+#ifndef GUID_DEVINTERFACE_USB_HUB
 const GUID GUID_DEVINTERFACE_USB_HUB = { 0xF18A0E88, 0xC30C, 0x11D0, {0x88, 0x15, 0x00, 0xA0, 0xC9, 0x06, 0xBE, 0xD8} };
 #endif
-#if !defined(GUID_DEVINTERFACE_LIBUSB0_FILTER)
+#ifndef GUID_DEVINTERFACE_LIBUSB0_FILTER
 const GUID GUID_DEVINTERFACE_LIBUSB0_FILTER = { 0xF9F3FF14, 0xAE21, 0x48A0, {0x8A, 0x25, 0x80, 0x11, 0xA7, 0xA9, 0x31, 0xD9} };
 #endif
 
@@ -326,37 +326,14 @@ typedef DWORD RETURN_TYPE;
 typedef RETURN_TYPE CONFIGRET;
 
 #define CR_SUCCESS                             0x00000000
-#define CR_NO_SUCH_DEVNODE                     0x0000000D
-
-#define USB_DEVICE_DESCRIPTOR_TYPE             LIBUSB_DT_DEVICE
-#define USB_CONFIGURATION_DESCRIPTOR_TYPE      LIBUSB_DT_CONFIG
-#define USB_STRING_DESCRIPTOR_TYPE             LIBUSB_DT_STRING
-#define USB_INTERFACE_DESCRIPTOR_TYPE          LIBUSB_DT_INTERFACE
-#define USB_ENDPOINT_DESCRIPTOR_TYPE           LIBUSB_DT_ENDPOINT
-
-#define USB_REQUEST_GET_STATUS                 LIBUSB_REQUEST_GET_STATUS
-#define USB_REQUEST_CLEAR_FEATURE              LIBUSB_REQUEST_CLEAR_FEATURE
-#define USB_REQUEST_SET_FEATURE                        LIBUSB_REQUEST_SET_FEATURE
-#define USB_REQUEST_SET_ADDRESS                        LIBUSB_REQUEST_SET_ADDRESS
-#define USB_REQUEST_GET_DESCRIPTOR             LIBUSB_REQUEST_GET_DESCRIPTOR
-#define USB_REQUEST_SET_DESCRIPTOR             LIBUSB_REQUEST_SET_DESCRIPTOR
-#define USB_REQUEST_GET_CONFIGURATION          LIBUSB_REQUEST_GET_CONFIGURATION
-#define USB_REQUEST_SET_CONFIGURATION          LIBUSB_REQUEST_SET_CONFIGURATION
-#define USB_REQUEST_GET_INTERFACE              LIBUSB_REQUEST_GET_INTERFACE
-#define USB_REQUEST_SET_INTERFACE              LIBUSB_REQUEST_SET_INTERFACE
-#define USB_REQUEST_SYNC_FRAME                 LIBUSB_REQUEST_SYNCH_FRAME
-
-#define USB_GET_NODE_INFORMATION               258
+
+#ifndef USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION
 #define USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION        260
-#define USB_GET_NODE_CONNECTION_NAME           261
-#define USB_GET_HUB_CAPABILITIES               271
-#if !defined(USB_GET_NODE_CONNECTION_INFORMATION_EX)
-#define USB_GET_NODE_CONNECTION_INFORMATION_EX 274
 #endif
-#if !defined(USB_GET_HUB_CAPABILITIES_EX)
-#define USB_GET_HUB_CAPABILITIES_EX            276
+#ifndef USB_GET_NODE_CONNECTION_INFORMATION_EX
+#define USB_GET_NODE_CONNECTION_INFORMATION_EX 274
 #endif
-#if !defined(USB_GET_NODE_CONNECTION_INFORMATION_EX_V2)
+#ifndef USB_GET_NODE_CONNECTION_INFORMATION_EX_V2
 #define USB_GET_NODE_CONNECTION_INFORMATION_EX_V2      279
 #endif
 
@@ -402,72 +379,19 @@ DLL_DECLARE_FUNC(WINAPI, CONFIGRET, CM_Get_Child, (PDEVINST, DEVINST, ULONG));
 DLL_DECLARE_FUNC(WINAPI, CONFIGRET, CM_Get_Sibling, (PDEVINST, DEVINST, ULONG));
 DLL_DECLARE_FUNC(WINAPI, CONFIGRET, CM_Get_Device_IDA, (DEVINST, PCHAR, ULONG, ULONG));
 
-#define IOCTL_USB_GET_HUB_CAPABILITIES_EX \
-       CTL_CODE( FILE_DEVICE_USB, USB_GET_HUB_CAPABILITIES_EX, METHOD_BUFFERED, FILE_ANY_ACCESS)
-
-#define IOCTL_USB_GET_HUB_CAPABILITIES \
-       CTL_CODE(FILE_DEVICE_USB, USB_GET_HUB_CAPABILITIES, METHOD_BUFFERED, FILE_ANY_ACCESS)
-
 #define IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION \
        CTL_CODE(FILE_DEVICE_USB, USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION, METHOD_BUFFERED, FILE_ANY_ACCESS)
 
-#define IOCTL_USB_GET_ROOT_HUB_NAME \
-       CTL_CODE(FILE_DEVICE_USB, HCD_GET_ROOT_HUB_NAME, METHOD_BUFFERED, FILE_ANY_ACCESS)
-
-#define IOCTL_USB_GET_NODE_INFORMATION \
-       CTL_CODE(FILE_DEVICE_USB, USB_GET_NODE_INFORMATION, METHOD_BUFFERED, FILE_ANY_ACCESS)
-
 #define IOCTL_USB_GET_NODE_CONNECTION_INFORMATION_EX \
        CTL_CODE(FILE_DEVICE_USB, USB_GET_NODE_CONNECTION_INFORMATION_EX, METHOD_BUFFERED, FILE_ANY_ACCESS)
 
 #define IOCTL_USB_GET_NODE_CONNECTION_INFORMATION_EX_V2 \
        CTL_CODE(FILE_DEVICE_USB, USB_GET_NODE_CONNECTION_INFORMATION_EX_V2, METHOD_BUFFERED, FILE_ANY_ACCESS)
 
-#define IOCTL_USB_GET_NODE_CONNECTION_ATTRIBUTES \
-       CTL_CODE(FILE_DEVICE_USB, USB_GET_NODE_CONNECTION_ATTRIBUTES, METHOD_BUFFERED, FILE_ANY_ACCESS)
-
-#define IOCTL_USB_GET_NODE_CONNECTION_NAME \
-       CTL_CODE(FILE_DEVICE_USB, USB_GET_NODE_CONNECTION_NAME, METHOD_BUFFERED, FILE_ANY_ACCESS)
-
 // Most of the structures below need to be packed
-#pragma pack(push, 1)
-
-typedef struct USB_INTERFACE_DESCRIPTOR {
-       UCHAR bLength;
-       UCHAR bDescriptorType;
-       UCHAR bInterfaceNumber;
-       UCHAR bAlternateSetting;
-       UCHAR bNumEndpoints;
-       UCHAR bInterfaceClass;
-       UCHAR bInterfaceSubClass;
-       UCHAR bInterfaceProtocol;
-       UCHAR iInterface;
-} USB_INTERFACE_DESCRIPTOR, *PUSB_INTERFACE_DESCRIPTOR;
+#include <pshpack1.h>
 
-typedef struct USB_CONFIGURATION_DESCRIPTOR_SHORT {
-       struct {
-               ULONG ConnectionIndex;
-               struct {
-                       UCHAR bmRequest;
-                       UCHAR bRequest;
-                       USHORT wValue;
-                       USHORT wIndex;
-                       USHORT wLength;
-               } SetupPacket;
-       } req;
-       USB_CONFIGURATION_DESCRIPTOR data;
-} USB_CONFIGURATION_DESCRIPTOR_SHORT;
-
-typedef struct USB_ENDPOINT_DESCRIPTOR {
-       UCHAR bLength;
-       UCHAR bDescriptorType;
-       UCHAR bEndpointAddress;
-       UCHAR bmAttributes;
-       USHORT wMaxPacketSize;
-       UCHAR bInterval;
-} USB_ENDPOINT_DESCRIPTOR, *PUSB_ENDPOINT_DESCRIPTOR;
-
-typedef struct USB_DESCRIPTOR_REQUEST {
+typedef struct _USB_DESCRIPTOR_REQUEST {
        ULONG ConnectionIndex;
        struct {
                UCHAR bmRequest;
@@ -479,68 +403,24 @@ typedef struct USB_DESCRIPTOR_REQUEST {
 //     UCHAR Data[0];
 } USB_DESCRIPTOR_REQUEST, *PUSB_DESCRIPTOR_REQUEST;
 
-typedef struct USB_HUB_DESCRIPTOR {
-       UCHAR bDescriptorLength;
-       UCHAR bDescriptorType;
-       UCHAR bNumberOfPorts;
-       USHORT wHubCharacteristics;
-       UCHAR bPowerOnToPowerGood;
-       UCHAR bHubControlCurrent;
-       UCHAR bRemoveAndPowerMask[64];
-} USB_HUB_DESCRIPTOR, *PUSB_HUB_DESCRIPTOR;
-
-typedef struct USB_ROOT_HUB_NAME {
-       ULONG ActualLength;
-       WCHAR RootHubName[1];
-} USB_ROOT_HUB_NAME, *PUSB_ROOT_HUB_NAME;
-
-typedef struct USB_ROOT_HUB_NAME_FIXED {
-       ULONG ActualLength;
-       WCHAR RootHubName[MAX_PATH_LENGTH];
-} USB_ROOT_HUB_NAME_FIXED;
-
-typedef struct USB_NODE_CONNECTION_NAME {
-       ULONG ConnectionIndex;
-       ULONG ActualLength;
-       WCHAR NodeName[1];
-} USB_NODE_CONNECTION_NAME, *PUSB_NODE_CONNECTION_NAME;
-
-typedef struct USB_NODE_CONNECTION_NAME_FIXED {
-       ULONG ConnectionIndex;
-       ULONG ActualLength;
-       WCHAR NodeName[MAX_PATH_LENGTH];
-} USB_NODE_CONNECTION_NAME_FIXED;
-
-typedef struct USB_HUB_NAME_FIXED {
-       union {
-               USB_ROOT_HUB_NAME_FIXED root;
-               USB_NODE_CONNECTION_NAME_FIXED node;
-       } u;
-} USB_HUB_NAME_FIXED;
-
-typedef struct USB_HUB_INFORMATION {
-       USB_HUB_DESCRIPTOR HubDescriptor;
-       BOOLEAN HubIsBusPowered;
-} USB_HUB_INFORMATION, *PUSB_HUB_INFORMATION;
-
-typedef struct USB_MI_PARENT_INFORMATION {
-       ULONG NumberOfInterfaces;
-} USB_MI_PARENT_INFORMATION, *PUSB_MI_PARENT_INFORMATION;
-
-typedef struct USB_NODE_INFORMATION {
-       USB_HUB_NODE NodeType;
-       union {
-               USB_HUB_INFORMATION HubInformation;
-               USB_MI_PARENT_INFORMATION MiParentInformation;
-       } u;
-} USB_NODE_INFORMATION, *PUSB_NODE_INFORMATION;
+typedef struct _USB_CONFIGURATION_DESCRIPTOR_SHORT {
+       USB_DESCRIPTOR_REQUEST req;
+       USB_CONFIGURATION_DESCRIPTOR desc;
+} USB_CONFIGURATION_DESCRIPTOR_SHORT;
 
-typedef struct USB_PIPE_INFO {
-       USB_ENDPOINT_DESCRIPTOR EndpointDescriptor;
-       ULONG ScheduleOffset;
-} USB_PIPE_INFO, *PUSB_PIPE_INFO;
+typedef struct USB_INTERFACE_DESCRIPTOR {
+       UCHAR bLength;
+       UCHAR bDescriptorType;
+       UCHAR bInterfaceNumber;
+       UCHAR bAlternateSetting;
+       UCHAR bNumEndpoints;
+       UCHAR bInterfaceClass;
+       UCHAR bInterfaceSubClass;
+       UCHAR bInterfaceProtocol;
+       UCHAR iInterface;
+} USB_INTERFACE_DESCRIPTOR, *PUSB_INTERFACE_DESCRIPTOR;
 
-typedef struct USB_NODE_CONNECTION_INFORMATION_EX {
+typedef struct _USB_NODE_CONNECTION_INFORMATION_EX {
        ULONG ConnectionIndex;
        USB_DEVICE_DESCRIPTOR DeviceDescriptor;
        UCHAR CurrentConfigurationValue;
@@ -578,25 +458,7 @@ typedef struct _USB_NODE_CONNECTION_INFORMATION_EX_V2 {
        USB_NODE_CONNECTION_INFORMATION_EX_V2_FLAGS Flags;
 } USB_NODE_CONNECTION_INFORMATION_EX_V2, *PUSB_NODE_CONNECTION_INFORMATION_EX_V2;
 
-typedef struct USB_HUB_CAP_FLAGS {
-       ULONG HubIsHighSpeedCapable:1;
-       ULONG HubIsHighSpeed:1;
-       ULONG HubIsMultiTtCapable:1;
-       ULONG HubIsMultiTt:1;
-       ULONG HubIsRoot:1;
-       ULONG HubIsArmedWakeOnConnect:1;
-       ULONG ReservedMBZ:26;
-} USB_HUB_CAP_FLAGS, *PUSB_HUB_CAP_FLAGS;
-
-typedef struct USB_HUB_CAPABILITIES {
-       ULONG HubIs2xCapable:1;
-} USB_HUB_CAPABILITIES, *PUSB_HUB_CAPABILITIES;
-
-typedef struct USB_HUB_CAPABILITIES_EX {
-       USB_HUB_CAP_FLAGS CapabilityFlags;
-} USB_HUB_CAPABILITIES_EX, *PUSB_HUB_CAPABILITIES_EX;
-
-#pragma pack(pop)
+#include <poppack.h>
 
 /* winusb.dll interface */
 
@@ -615,29 +477,31 @@ typedef struct USB_HUB_CAPABILITIES_EX {
 #define FullSpeed              0x02
 #define HighSpeed              0x03
 
-typedef enum USBD_PIPE_TYPE {
+typedef enum _USBD_PIPE_TYPE {
        UsbdPipeTypeControl,
        UsbdPipeTypeIsochronous,
        UsbdPipeTypeBulk,
        UsbdPipeTypeInterrupt
 } USBD_PIPE_TYPE;
 
-typedef struct {
+typedef struct _WINUSB_PIPE_INFORMATION {
        USBD_PIPE_TYPE PipeType;
        UCHAR PipeId;
        USHORT MaximumPacketSize;
        UCHAR Interval;
 } WINUSB_PIPE_INFORMATION, *PWINUSB_PIPE_INFORMATION;
 
-#pragma pack(1)
-typedef struct {
-       UCHAR request_type;
-       UCHAR request;
-       USHORT value;
-       USHORT index;
-       USHORT length;
+#include <pshpack1.h>
+
+typedef struct _WINUSB_SETUP_PACKET {
+       UCHAR RequestType;
+       UCHAR Request;
+       USHORT Value;
+       USHORT Index;
+       USHORT Length;
 } WINUSB_SETUP_PACKET, *PWINUSB_SETUP_PACKET;
-#pragma pack()
+
+#include <poppack.h>
 
 typedef void *WINUSB_INTERFACE_HANDLE, *PWINUSB_INTERFACE_HANDLE;
 
@@ -846,17 +710,19 @@ struct winusb_interface {
 #define HIDP_STATUS_SUCCESS    0x110000
 typedef void * PHIDP_PREPARSED_DATA;
 
-#pragma pack(1)
-typedef struct {
+#include <pshpack1.h>
+
+typedef struct _HIDD_ATTIRBUTES {
        ULONG Size;
        USHORT VendorID;
        USHORT ProductID;
        USHORT VersionNumber;
 } HIDD_ATTRIBUTES, *PHIDD_ATTRIBUTES;
-#pragma pack()
+
+#include <poppack.h>
 
 typedef USHORT USAGE;
-typedef struct {
+typedef struct _HIDP_CAPS {
        USAGE Usage;
        USAGE UsagePage;
        USHORT InputReportByteLength;
index 33169bc..11e7752 100644 (file)
@@ -1 +1 @@
-#define LIBUSB_NANO 11198
+#define LIBUSB_NANO 11199