#pragma once #include #include #include #include typedef void (*hotplug_callback_f)(); struct usb_detector { atomic_bool is_connected; atomic_bool event_handler_should_exit; thrd_t event_handler_thread; struct libusb_context* usb_context; libusb_hotplug_callback_handle hotplug_handle; atomic_bool has_hotplug_callbacks; hotplug_callback_f on_connected; hotplug_callback_f on_disconnected; }; struct usb_detector* create_detector(uint16_t vendor_id, uint16_t product_id); void destroy_detector(struct usb_detector*);