diff --git a/libusb.odin b/libusb.odin index 6c8761c..c0d2ff8 100644 --- a/libusb.odin +++ b/libusb.odin @@ -2,6 +2,7 @@ package libusb import "core:c" import "core:fmt" +//TODO: Make multiplatform //TODO: Switch to sys/posix when linux support is finished import "posix" @@ -1065,11 +1066,13 @@ Hotplug_Event :: enum c.int { * Since version 1.0.16, \ref LIBUSB_API_VERSION >= 0x01000102 * * 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. */ - ENUMERATE = 1, + ENUMERATE = 0, } +Hotplug_Flag :: bit_set[Hotplug_Flag_Bits; c.int] + /** \ingroup libusb_hotplug * Convenience macro when not using any flags */ HOTPLUG_NO_FLAGS :: 0 @@ -1079,9 +1082,9 @@ HOTPLUG_MATCH_ANY :: -1 Hotplug_Callback_Fn :: #type proc "c" ( ctx: Context, - device: ^Device, + device: Device, event: Hotplug_Event, - user_date: rawptr, + user_data: rawptr, ) -> c.int Callback_Handle :: distinct c.int @@ -1117,8 +1120,8 @@ foreign lib { exit :: proc(ctx: Context) --- //----- Device handling and enumeration ---------------------------------- - get_device_list :: proc(ctx: Context, list: ^^[^]Device) -> int --- - free_device_list :: proc(device: ^[^]Device, unref_devices: c.int) --- + get_device_list :: proc(ctx: Context, list: ^[^][^]Device) -> int --- + free_device_list :: proc(device: [^][^]Device, unref_devices: c.int) --- get_bus_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 --- @@ -1130,9 +1133,9 @@ foreign lib { ref_device :: proc(dev: ^Device) -> Device --- unref_device :: proc(dev: ^Device) --- 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 --- - close :: proc(dev_handle: ^Device_Handle) --- + close :: proc(dev_handle: Device_Handle) --- get_device :: proc(dev_handle: ^Device_Handle) -> ^Device --- get_configuration :: proc(dev: ^Device_Handle, config: ^c.int) -> Error --- set_configuration :: proc(dev_handle: ^Device_Handle, configuration: c.int) -> Error --- @@ -1172,12 +1175,12 @@ foreign lib { 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) --- 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_active_interface_association_descriptors :: proc(dev: ^Device, 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 --- free_interface_association_descriptors :: proc(iad_array: ^Interface_Association_Descriptor_Array) -> Error --- //----- 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_get_user_data :: proc(ctx: Context, hotplug_callback_handle: Callback_Handle) -> rawptr --- @@ -1213,9 +1216,9 @@ foreign lib { free_fds :: proc(pollfds: [^][^]Poll_Fd) --- //----- 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 --- - 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 --- + 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 --- + interrupt_transfer :: proc(dev_handle: Device_Handle, endpoint: u8, data: [^]u8, length: c.int, transferred: ^c.int, timeout: c.uint) -> Error --- } // ---------------------------------------------------------------------------------------------------------------------