Skip to content

Commit

Permalink
Fix USB transfers on Windows by using unsigned bitfield types for enums
Browse files Browse the repository at this point in the history
  • Loading branch information
calc84maniac committed Oct 1, 2024
1 parent 57db3b0 commit 7018586
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions core/usb/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down
14 changes: 8 additions & 6 deletions core/usb/physical.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down

0 comments on commit 7018586

Please sign in to comment.