From 701858645d64db709ccb358bb98f720054f5bf53 Mon Sep 17 00:00:00 2001 From: Brendan Fletcher Date: Tue, 1 Oct 2024 04:00:13 -0400 Subject: [PATCH] Fix USB transfers on Windows by using unsigned bitfield types for enums --- core/usb/device.h | 4 ++-- core/usb/physical.c | 14 ++++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/core/usb/device.h b/core/usb/device.h index 832db3646..20b649021 100644 --- a/core/usb/device.h +++ b/core/usb/device.h @@ -51,7 +51,7 @@ typedef struct usb_transfer_info { uint16_t length, max_pkt_size; usb_transfer_status_t status : 8; uint8_t address : 7, : 1, endpoint : 4; - usb_transfer_type_t type : 3; + uint8_t type : 3; /* usb_transfer_type_t */ bool direction : 1; } usb_transfer_info_t; @@ -72,7 +72,7 @@ typedef struct usb_event { usb_progress_handler_t *progress_handler; void *progress_context, *context; bool host : 1; - usb_speed_t speed : 2; + uint8_t speed : 2; /* usb_speed_t */ usb_event_type_t type; union { usb_init_info_t init; diff --git a/core/usb/physical.c b/core/usb/physical.c index ffc42df99..876a94025 100644 --- a/core/usb/physical.c +++ b/core/usb/physical.c @@ -114,16 +114,18 @@ struct hub { port_t ports[]; }; +enum device_state { + DEVICE_STATE_ATTACHED, + DEVICE_STATE_POWERED, + DEVICE_STATE_DEFAULT_OR_ADDRESS, + DEVICE_STATE_CONFIGURED, +}; + struct device { node_t node; libusb_device_handle *handle; endpoint_t endpoints[0x20]; - enum device_state { - DEVICE_STATE_ATTACHED, - DEVICE_STATE_POWERED, - DEVICE_STATE_DEFAULT_OR_ADDRESS, - DEVICE_STATE_CONFIGURED, - } state : 2; + uint8_t state : 2; /* enum device_state */ uint8_t address : 7, numPorts : 7; hub_t hub; };