21 lines
474 B
C
21 lines
474 B
C
|
#pragma once
|
||
|
|
||
|
#include <stdatomic.h>
|
||
|
#include <stdint.h>
|
||
|
#include <threads.h>
|
||
|
|
||
|
#include <libusb-1.0/libusb.h>
|
||
|
|
||
|
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;
|
||
|
};
|
||
|
|
||
|
struct usb_detector* create_detector(uint16_t vendor_id, uint16_t product_id);
|
||
|
void destroy_detector(struct usb_detector*);
|