Fixed types

This commit is contained in:
Zachary
2024-10-29 08:19:25 -07:00
committed by n
parent 5c79c16337
commit 7fb888e814

View File

@ -2,6 +2,7 @@ package libusb
import "core:c" import "core:c"
import "core:fmt" import "core:fmt"
//TODO: Make multiplatform
//TODO: Switch to sys/posix when linux support is finished //TODO: Switch to sys/posix when linux support is finished
import "posix" import "posix"
@ -869,13 +870,13 @@ Transfer_Cb :: #type proc "c" (transfer: ^Transfer)
*/ */
Transfer :: struct { Transfer :: struct {
/** Handle of the device that this transfer will be submitted to */ /** Handle of the device that this transfer will be submitted to */
dev_handle: ^Device_Handle, dev_handle: Device_Handle,
/** A bitwise OR combination of \ref libusb_transfer_flags. */ /** A bitwise OR combination of \ref libusb_transfer_flags. */
flags: Transfer_Flag, flags: Transfer_Flag,
/** Address of the endpoint where this transfer will be sent. */ /** Address of the endpoint where this transfer will be sent. */
endpoint: c.char, endpoint: u8,
/** Type of the transfer from \ref libusb_transfer_type */ /** Type of the transfer from \ref libusb_transfer_type */
type: c.char, type: u8,
/** Timeout for this transfer in milliseconds. A value of 0 indicates no /** Timeout for this transfer in milliseconds. A value of 0 indicates no
* timeout. */ * timeout. */
timeout: c.uint, timeout: c.uint,
@ -908,7 +909,7 @@ Transfer :: struct {
* - libusb_fill_iso_transfer() */ * - libusb_fill_iso_transfer() */
user_data: rawptr, user_data: rawptr,
/** Data buffer */ /** Data buffer */
buffer: [^]c.char, buffer: [^]u8,
/** Number of isochronous packets. Only used for I/O with isochronous /** Number of isochronous packets. Only used for I/O with isochronous
* endpoints. Must be non-negative. */ * endpoints. Must be non-negative. */
num_iso_packets: c.int, num_iso_packets: c.int,
@ -1065,11 +1066,13 @@ Hotplug_Event :: enum c.int {
* Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102 * Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102
* *
* Hotplug flags */ * Hotplug flags */
Hotplug_Flag :: enum c.int { Hotplug_Flag_Bits :: enum c.int {
/** Arm the callback and fire it for all matching currently attached devices. */ /** Arm the callback and fire it for all matching currently attached devices. */
ENUMERATE = 1, ENUMERATE = 0,
} }
Hotplug_Flag :: bit_set[Hotplug_Flag_Bits; c.int]
/** \ingroup libusb_hotplug /** \ingroup libusb_hotplug
* Convenience macro when not using any flags */ * Convenience macro when not using any flags */
HOTPLUG_NO_FLAGS :: 0 HOTPLUG_NO_FLAGS :: 0
@ -1079,9 +1082,9 @@ HOTPLUG_MATCH_ANY :: -1
Hotplug_Callback_Fn :: #type proc "c" ( Hotplug_Callback_Fn :: #type proc "c" (
ctx: Context, ctx: Context,
device: ^Device, device: Device,
event: Hotplug_Event, event: Hotplug_Event,
user_date: rawptr, user_data: rawptr,
) -> c.int ) -> c.int
Callback_Handle :: distinct c.int Callback_Handle :: distinct c.int
@ -1117,34 +1120,34 @@ foreign lib {
exit :: proc(ctx: Context) --- exit :: proc(ctx: Context) ---
//----- Device handling and enumeration ---------------------------------- //----- Device handling and enumeration ----------------------------------
get_device_list :: proc(ctx: Context, list: ^^[^]Device) -> int --- get_device_list :: proc(ctx: Context, list: ^[^]Device) -> int ---
free_device_list :: proc(device: ^[^]Device, unref_devices: c.int) --- free_device_list :: proc(device: [^]Device, unref_devices: c.int) ---
get_bus_number :: proc(dev: ^Device) -> u8 --- get_bus_number :: proc(dev: Device) -> u8 ---
get_port_number :: proc(dev: ^Device) -> u8 --- get_port_number :: proc(dev: Device) -> u8 ---
get_port_numbers :: proc(dev: ^Device, port_numbers: [^]u8, port_numbers_len: c.int) -> Error --- get_port_numbers :: proc(dev: Device, port_numbers: [^]u8, port_numbers_len: c.int) -> Error ---
get_parent :: proc(dev: ^Device) -> ^Device --- get_parent :: proc(dev: Device) -> Device ---
get_device_address :: proc(dev: ^Device) -> u8 --- get_device_address :: proc(dev: Device) -> u8 ---
get_device_speed :: proc(dev: ^Device) -> Speed --- get_device_speed :: proc(dev: Device) -> Speed ---
get_max_iso_packet_size :: proc(dev: ^Device, endpoint: c.char) -> c.int --- get_max_iso_packet_size :: proc(dev: Device, endpoint: c.char) -> c.int ---
get_max_alt_packet_size :: proc(dev: ^Device, interface_number: c.int, alternate_setting: c.int, endpoint: u8) -> c.int --- get_max_alt_packet_size :: proc(dev: Device, interface_number: c.int, alternate_setting: c.int, endpoint: u8) -> c.int ---
ref_device :: proc(dev: ^Device) -> Device --- ref_device :: proc(dev: Device) -> Device ---
unref_device :: proc(dev: ^Device) --- unref_device :: proc(dev: Device) ---
wrap_sys_device :: proc(ctx: Context, sys_dev: rawptr, dev_handle: ^^Device_Handle) -> Error --- wrap_sys_device :: proc(ctx: Context, sys_dev: rawptr, dev_handle: ^Device_Handle) -> Error ---
open :: proc(dev: ^Device, dev_handle: ^Device_Handle) -> Error --- open :: proc(dev: Device, dev_handle: ^Device_Handle) -> Error ---
open_device_with_vid_pid :: proc(ctx: Context, vendor_id: u16, product_id: u16) -> ^Device_Handle --- open_device_with_vid_pid :: proc(ctx: Context, vendor_id: u16, product_id: u16) -> Device_Handle ---
close :: proc(dev_handle: ^Device_Handle) --- close :: proc(dev_handle: Device_Handle) ---
get_device :: proc(dev_handle: ^Device_Handle) -> ^Device --- get_device :: proc(dev_handle: Device_Handle) -> Device ---
get_configuration :: proc(dev: ^Device_Handle, config: ^c.int) -> Error --- get_configuration :: proc(dev: Device_Handle, config: ^c.int) -> Error ---
set_configuration :: proc(dev_handle: ^Device_Handle, configuration: c.int) -> Error --- set_configuration :: proc(dev_handle: Device_Handle, configuration: c.int) -> Error ---
claim_interface :: proc(dev_handle: ^Device_Handle, interface_number: c.int) -> Error --- claim_interface :: proc(dev_handle: Device_Handle, interface_number: c.int) -> Error ---
release_interface :: proc(dev_handle: ^Device_Handle, interface_number: c.int) -> Error --- release_interface :: proc(dev_handle: Device_Handle, interface_number: c.int) -> Error ---
interface_alt_setting :: proc(dev_handle: ^Device_Handle, interface_number: c.int, alternate_setting: c.int) -> Error --- interface_alt_setting :: proc(dev_handle: Device_Handle, interface_number: c.int, alternate_setting: c.int) -> Error ---
clear_halt :: proc(dev_handle: ^Device_Handle, endpoint: u8) -> Error --- clear_halt :: proc(dev_handle: Device_Handle, endpoint: u8) -> Error ---
reset_device :: proc(dev_handle: ^Device_Handle) -> Error --- reset_device :: proc(dev_handle: Device_Handle) -> Error ---
kernel_driver_active :: proc(dev_handle: ^Device_Handle, interface_number: c.int) -> Error --- kernel_driver_active :: proc(dev_handle: Device_Handle, interface_number: c.int) -> Error ---
detach_kernel_driver :: proc(dev_handle: ^Device_Handle, interface_number: c.int) -> Error --- detach_kernel_driver :: proc(dev_handle: Device_Handle, interface_number: c.int) -> Error ---
attach_kernel_driver :: proc(dev_handle: ^Device_Handle, interface_number: c.int) -> Error --- attach_kernel_driver :: proc(dev_handle: Device_Handle, interface_number: c.int) -> Error ---
set_auto_detach_kernel_driver :: proc(dev_handle: ^Device_Handle, enable: c.int) -> Error --- set_auto_detach_kernel_driver :: proc(dev_handle: Device_Handle, enable: c.int) -> Error ---
//----- Miscellaneous ---------------------------------- //----- Miscellaneous ----------------------------------
has_capability :: proc(capability: Capability) -> c.int --- has_capability :: proc(capability: Capability) -> c.int ---
@ -1154,14 +1157,14 @@ foreign lib {
strerror :: proc(errcode: Error) -> cstring --- strerror :: proc(errcode: Error) -> cstring ---
//----- USB descriptors ---------------------------------- //----- USB descriptors ----------------------------------
get_device_descriptor :: proc(dev: ^Device, desc: ^Device_Descriptor) -> Error --- get_device_descriptor :: proc(dev: Device, desc: ^Device_Descriptor) -> Error ---
get_active_config_descriptor :: proc(dev: ^Device, config: ^^Config_Descriptor) -> Error --- get_active_config_descriptor :: proc(dev: Device, config: ^^Config_Descriptor) -> Error ---
get_config_descriptor :: proc(dev: ^Device, config_index: u8, config_descriptor: ^^Config_Descriptor) -> Error --- get_config_descriptor :: proc(dev: Device, config_index: u8, config_descriptor: ^^Config_Descriptor) -> Error ---
get_config_descriptor_by_value :: proc(dev: ^Device, bConfigurationValue: u8, config: ^^Config_Descriptor) -> Error --- get_config_descriptor_by_value :: proc(dev: Device, bConfigurationValue: u8, config: ^^Config_Descriptor) -> Error ---
free_config_descriptor :: proc(config: ^Config_Descriptor) --- free_config_descriptor :: proc(config: ^Config_Descriptor) ---
get_ss_endpoint_companion_descriptor :: proc(ctx: Context, endpoint: ^Endpoint_Direction, ep_comp: ^^Ss_Endpoint_Companion_Descriptor) -> Error --- get_ss_endpoint_companion_descriptor :: proc(ctx: Context, endpoint: ^Endpoint_Direction, ep_comp: ^^Ss_Endpoint_Companion_Descriptor) -> Error ---
free_ss_endpoint_companion_descriptor :: proc(ep_comp: ^Ss_Endpoint_Companion_Descriptor) --- free_ss_endpoint_companion_descriptor :: proc(ep_comp: ^Ss_Endpoint_Companion_Descriptor) ---
get_bos_descriptor :: proc(dev_handle: ^Device_Handle, bos: ^^Bos_Descriptor) -> Error --- get_bos_descriptor :: proc(dev_handle: Device_Handle, bos: ^^Bos_Descriptor) -> Error ---
free_bos_descriptor :: proc(bos: ^Bos_Descriptor) --- free_bos_descriptor :: proc(bos: ^Bos_Descriptor) ---
get_usb2_extension_descriptor :: proc(ctx: Context, dev_cap: ^Bos_Dev_Capability_Descriptor, usb2_extension: ^^Usb2_Extension_Descriptor) -> Error --- get_usb2_extension_descriptor :: proc(ctx: Context, dev_cap: ^Bos_Dev_Capability_Descriptor, usb2_extension: ^^Usb2_Extension_Descriptor) -> Error ---
free_usb2_extension_descriptor :: proc(usb2_extension: ^Usb2_Extension_Descriptor) --- free_usb2_extension_descriptor :: proc(usb2_extension: ^Usb2_Extension_Descriptor) ---
@ -1171,13 +1174,13 @@ foreign lib {
free_container_id_descriptor :: proc(container_id: ^Container_Id_Descriptor) --- free_container_id_descriptor :: proc(container_id: ^Container_Id_Descriptor) ---
get_platform_descriptor :: proc(ctx: Context, dev_cap: ^Bos_Dev_Capability_Descriptor, platform_descriptor: ^^Platform_Descriptor) -> Error --- get_platform_descriptor :: proc(ctx: Context, dev_cap: ^Bos_Dev_Capability_Descriptor, platform_descriptor: ^^Platform_Descriptor) -> Error ---
free_platform_descriptor :: proc(platform_descriptor: ^Platform_Descriptor) --- free_platform_descriptor :: proc(platform_descriptor: ^Platform_Descriptor) ---
get_string_descriptor_ascii :: proc(dev_handle: ^Device_Handle, desc_index: u8, data: cstring, length: c.int) -> c.int --- get_string_descriptor_ascii :: proc(dev_handle: Device_Handle, desc_index: u8, data: cstring, length: c.int) -> c.int ---
get_interface_association_descriptors :: proc(dev: ^Device, config_index: u8, iad_array: ^^Interface_Association_Descriptor_Array) -> Error --- get_interface_association_descriptors :: proc(dev: Device, config_index: u8, iad_array: [^][^]Interface_Association_Descriptor_Array) -> Error ---
get_active_interface_association_descriptors :: proc(dev: ^Device, iad_array: ^^Interface_Association_Descriptor_Array) -> Error --- get_active_interface_association_descriptors :: proc(dev: Device, iad_array: [^][^]Interface_Association_Descriptor_Array) -> Error ---
free_interface_association_descriptors :: proc(iad_array: ^Interface_Association_Descriptor_Array) -> Error --- free_interface_association_descriptors :: proc(iad_array: ^Interface_Association_Descriptor_Array) -> Error ---
//----- Device hotplug event notification ---------------------------------- //----- Device hotplug event notification ----------------------------------
hotplug_register_callback :: proc(ctx: Context, events: c.int, flags: c.int, vendor_id: c.int, product_id: c.int, dev_class: c.int, cb_fn: Hotplug_Callback_Fn, callback_handle: Callback_Handle) -> Error --- hotplug_register_callback :: proc(ctx: Context, events: c.int, flags: Hotplug_Flag, vendor_id: c.int, product_id: c.int, dev_class: c.int, cb_fn: Hotplug_Callback_Fn, user_data: rawptr, callback_handle: ^Callback_Handle) -> Error ---
hotplug_deregister_callback :: proc(ctx: Context, hotplug_callback_handle: Callback_Handle) --- hotplug_deregister_callback :: proc(ctx: Context, hotplug_callback_handle: Callback_Handle) ---
hotplug_get_user_data :: proc(ctx: Context, hotplug_callback_handle: Callback_Handle) -> rawptr --- hotplug_get_user_data :: proc(ctx: Context, hotplug_callback_handle: Callback_Handle) -> rawptr ---
@ -1213,9 +1216,9 @@ foreign lib {
free_fds :: proc(pollfds: [^][^]Poll_Fd) --- free_fds :: proc(pollfds: [^][^]Poll_Fd) ---
//----- Synchronous device I/O ---------------------------------- //----- Synchronous device I/O ----------------------------------
control_transfer :: proc(dev_handle: ^Device_Handle, bmRequestType: u8, bRequest: u8, wValue: u16, wIndex: u16, data: [^]u8, wLength: u16, timeout: c.uint) -> Error --- control_transfer :: proc(dev_handle: Device_Handle, bmRequestType: u8, bRequest: u8, wValue: u16, wIndex: u16, data: [^]u8, wLength: u16, timeout: c.uint) -> Error ---
bulk_transfer :: proc(dev_handle: ^Device_Handle, endpoint: u8, data: [^]u8, length: c.int, transferred: ^c.int, timeout: c.uint) -> Error --- bulk_transfer :: proc(dev_handle: Device_Handle, endpoint: u8, data: [^]u8, length: c.int, transferred: ^c.int, timeout: c.uint) -> Error ---
interrupt_transfer :: proc(dev_handle: ^Device_Handle, endpoint: u8, data: [^]u8, length: c.int, transferred: ^c.int, timeout: c.uint) -> Error --- interrupt_transfer :: proc(dev_handle: Device_Handle, endpoint: u8, data: [^]u8, length: c.int, transferred: ^c.int, timeout: c.uint) -> Error ---
} }
// --------------------------------------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------------------------------------