libusb.h | libusb.h | |||
---|---|---|---|---|
skipping to change at line 153 | skipping to change at line 153 | |||
* | * | |||
* Internally, LIBUSBX_API_VERSION is defined as follows: | * Internally, LIBUSBX_API_VERSION is defined as follows: | |||
* (libusbx major << 24) | (libusbx minor << 16) | (16 bit incremental) | * (libusbx major << 24) | (libusbx minor << 16) | (16 bit incremental) | |||
*/ | */ | |||
#define LIBUSBX_API_VERSION 0x01000102 | #define LIBUSBX_API_VERSION 0x01000102 | |||
#ifdef __cplusplus | #ifdef __cplusplus | |||
extern "C" { | extern "C" { | |||
#endif | #endif | |||
/** \def libusb_cpu_to_le16 | /** \fn libusb_cpu_to_le16 | |||
* \ingroup misc | * \ingroup misc | |||
* Convert a 16-bit value from host-endian to little-endian format. On | * Convert a 16-bit value from host-endian to little-endian format. On | |||
* little endian systems, this function does nothing. On big endian systems , | * little endian systems, this function does nothing. On big endian systems , | |||
* the bytes are swapped. | * the bytes are swapped. | |||
* \param x the host-endian value to convert | * \param x the host-endian value to convert | |||
* \returns the value in little-endian byte order | * \returns the value in little-endian byte order | |||
*/ | */ | |||
static inline uint16_t libusb_cpu_to_le16(const uint16_t x) | static inline uint16_t libusb_cpu_to_le16(const uint16_t x) | |||
{ | { | |||
union { | union { | |||
skipping to change at line 1429 | skipping to change at line 1429 | |||
* Calling this function only makes sense from a transfer callback function , | * Calling this function only makes sense from a transfer callback function , | |||
* or situations where you have already allocated a suitably sized buffer a t | * or situations where you have already allocated a suitably sized buffer a t | |||
* transfer->buffer. | * transfer->buffer. | |||
* | * | |||
* \param transfer a transfer | * \param transfer a transfer | |||
* \returns a casted pointer to the start of the transfer data buffer | * \returns a casted pointer to the start of the transfer data buffer | |||
*/ | */ | |||
static inline struct libusb_control_setup *libusb_control_transfer_get_setu p( | static inline struct libusb_control_setup *libusb_control_transfer_get_setu p( | |||
struct libusb_transfer *transfer) | struct libusb_transfer *transfer) | |||
{ | { | |||
return (struct libusb_control_setup *) transfer->buffer; | return (struct libusb_control_setup *)(void *) transfer->buffer; | |||
} | } | |||
/** \ingroup asyncio | /** \ingroup asyncio | |||
* Helper function to populate the setup packet (first 8 bytes of the data | * Helper function to populate the setup packet (first 8 bytes of the data | |||
* buffer) for a control transfer. The wIndex, wValue and wLength values sh ould | * buffer) for a control transfer. The wIndex, wValue and wLength values sh ould | |||
* be given in host-endian byte order. | * be given in host-endian byte order. | |||
* | * | |||
* \param buffer buffer to output the setup packet into | * \param buffer buffer to output the setup packet into | |||
* This pointer must be aligned to at least 2 bytes boundary. | ||||
* \param bmRequestType see the | * \param bmRequestType see the | |||
* \ref libusb_control_setup::bmRequestType "bmRequestType" field of | * \ref libusb_control_setup::bmRequestType "bmRequestType" field of | |||
* \ref libusb_control_setup | * \ref libusb_control_setup | |||
* \param bRequest see the | * \param bRequest see the | |||
* \ref libusb_control_setup::bRequest "bRequest" field of | * \ref libusb_control_setup::bRequest "bRequest" field of | |||
* \ref libusb_control_setup | * \ref libusb_control_setup | |||
* \param wValue see the | * \param wValue see the | |||
* \ref libusb_control_setup::wValue "wValue" field of | * \ref libusb_control_setup::wValue "wValue" field of | |||
* \ref libusb_control_setup | * \ref libusb_control_setup | |||
* \param wIndex see the | * \param wIndex see the | |||
* \ref libusb_control_setup::wIndex "wIndex" field of | * \ref libusb_control_setup::wIndex "wIndex" field of | |||
* \ref libusb_control_setup | * \ref libusb_control_setup | |||
* \param wLength see the | * \param wLength see the | |||
* \ref libusb_control_setup::wLength "wLength" field of | * \ref libusb_control_setup::wLength "wLength" field of | |||
* \ref libusb_control_setup | * \ref libusb_control_setup | |||
*/ | */ | |||
static inline void libusb_fill_control_setup(unsigned char *buffer, | static inline void libusb_fill_control_setup(unsigned char *buffer, | |||
uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t w Index, | uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t w Index, | |||
uint16_t wLength) | uint16_t wLength) | |||
{ | { | |||
struct libusb_control_setup *setup = (struct libusb_control_setup *) buffer; | struct libusb_control_setup *setup = (struct libusb_control_setup *) (void *) buffer; | |||
setup->bmRequestType = bmRequestType; | setup->bmRequestType = bmRequestType; | |||
setup->bRequest = bRequest; | setup->bRequest = bRequest; | |||
setup->wValue = libusb_cpu_to_le16(wValue); | setup->wValue = libusb_cpu_to_le16(wValue); | |||
setup->wIndex = libusb_cpu_to_le16(wIndex); | setup->wIndex = libusb_cpu_to_le16(wIndex); | |||
setup->wLength = libusb_cpu_to_le16(wLength); | setup->wLength = libusb_cpu_to_le16(wLength); | |||
} | } | |||
struct libusb_transfer * LIBUSB_CALL libusb_alloc_transfer(int iso_packets) ; | struct libusb_transfer * LIBUSB_CALL libusb_alloc_transfer(int iso_packets) ; | |||
int LIBUSB_CALL libusb_submit_transfer(struct libusb_transfer *transfer); | int LIBUSB_CALL libusb_submit_transfer(struct libusb_transfer *transfer); | |||
int LIBUSB_CALL libusb_cancel_transfer(struct libusb_transfer *transfer); | int LIBUSB_CALL libusb_cancel_transfer(struct libusb_transfer *transfer); | |||
skipping to change at line 1494 | skipping to change at line 1495 | |||
* -# Call libusb_submit_transfer() | * -# Call libusb_submit_transfer() | |||
* | * | |||
* It is also legal to pass a NULL buffer to this function, in which case t his | * It is also legal to pass a NULL buffer to this function, in which case t his | |||
* function will not attempt to populate the length field. Remember that yo u | * function will not attempt to populate the length field. Remember that yo u | |||
* must then populate the buffer and length fields later. | * must then populate the buffer and length fields later. | |||
* | * | |||
* \param transfer the transfer to populate | * \param transfer the transfer to populate | |||
* \param dev_handle handle of the device that will handle the transfer | * \param dev_handle handle of the device that will handle the transfer | |||
* \param buffer data buffer. If provided, this function will interpret the | * \param buffer data buffer. If provided, this function will interpret the | |||
* first 8 bytes as a setup packet and infer the transfer length from that. | * first 8 bytes as a setup packet and infer the transfer length from that. | |||
* This pointer must be aligned to at least 2 bytes boundary. | ||||
* \param callback callback function to be invoked on transfer completion | * \param callback callback function to be invoked on transfer completion | |||
* \param user_data user data to pass to callback function | * \param user_data user data to pass to callback function | |||
* \param timeout timeout for the transfer in milliseconds | * \param timeout timeout for the transfer in milliseconds | |||
*/ | */ | |||
static inline void libusb_fill_control_transfer( | static inline void libusb_fill_control_transfer( | |||
struct libusb_transfer *transfer, libusb_device_handle *dev_handle, | struct libusb_transfer *transfer, libusb_device_handle *dev_handle, | |||
unsigned char *buffer, libusb_transfer_cb_fn callback, void *user_da ta, | unsigned char *buffer, libusb_transfer_cb_fn callback, void *user_da ta, | |||
unsigned int timeout) | unsigned int timeout) | |||
{ | { | |||
struct libusb_control_setup *setup = (struct libusb_control_setup *) buffer; | struct libusb_control_setup *setup = (struct libusb_control_setup *) (void *) buffer; | |||
transfer->dev_handle = dev_handle; | transfer->dev_handle = dev_handle; | |||
transfer->endpoint = 0; | transfer->endpoint = 0; | |||
transfer->type = LIBUSB_TRANSFER_TYPE_CONTROL; | transfer->type = LIBUSB_TRANSFER_TYPE_CONTROL; | |||
transfer->timeout = timeout; | transfer->timeout = timeout; | |||
transfer->buffer = buffer; | transfer->buffer = buffer; | |||
if (setup) | if (setup) | |||
transfer->length = (int) (LIBUSB_CONTROL_SETUP_SIZE | transfer->length = (int) (LIBUSB_CONTROL_SETUP_SIZE | |||
+ libusb_le16_to_cpu(setup->wLength)); | + libusb_le16_to_cpu(setup->wLength)); | |||
transfer->user_data = user_data; | transfer->user_data = user_data; | |||
transfer->callback = callback; | transfer->callback = callback; | |||
skipping to change at line 1878 | skipping to change at line 1880 | |||
* recommended the callback do minimal processing before returning. | * recommended the callback do minimal processing before returning. | |||
* | * | |||
* libusbx will call this function later, when a matching event had happene d on | * libusbx will call this function later, when a matching event had happene d on | |||
* a matching device. See \ref hotplug for more information. | * a matching device. See \ref hotplug for more information. | |||
* | * | |||
* It is safe to call either libusb_hotplug_register_callback() or | * It is safe to call either libusb_hotplug_register_callback() or | |||
* libusb_hotplug_deregister_callback() from within a callback function. | * libusb_hotplug_deregister_callback() from within a callback function. | |||
* | * | |||
* Since version 1.0.16, \ref LIBUSBX_API_VERSION >= 0x01000102 | * Since version 1.0.16, \ref LIBUSBX_API_VERSION >= 0x01000102 | |||
* | * | |||
* \param libusb_context context of this notification | * \param ctx context of this notification | |||
* \param device libusb_device this event occurred on | * \param device libusb_device this event occurred on | |||
* \param event event that occurred | * \param event event that occurred | |||
* \param user_data user data provided when this callback was register ed | * \param user_data user data provided when this callback was register ed | |||
* \returns bool whether this callback is finished processing events. | * \returns bool whether this callback is finished processing events. | |||
* returning 1 will cause this callback to be deregis tered | * returning 1 will cause this callback to be deregis tered | |||
*/ | */ | |||
typedef int (LIBUSB_CALL *libusb_hotplug_callback_fn)(libusb_context *ctx, | typedef int (LIBUSB_CALL *libusb_hotplug_callback_fn)(libusb_context *ctx, | |||
libusb_device *device, | libusb_device *device, | |||
libusb_hotplug_event event, | libusb_hotplug_event event, | |||
void *user_data); | void *user_data); | |||
/** \ingroup hotplug | /** \ingroup hotplug | |||
* Register a hotplug callback function | * Register a hotplug callback function | |||
* | * | |||
* Register a callback with the libusb_context. The callback will fire | * Register a callback with the libusb_context. The callback will fire | |||
* when a matching event occurs on a matching device. The callback is | * when a matching event occurs on a matching device. The callback is | |||
* armed until either it is deregistered with libusb_hotplug_deregister_cal lback() | * armed until either it is deregistered with libusb_hotplug_deregister_cal lback() | |||
* or the supplied callback returns 1 to indicate it is finished processing events. | * or the supplied callback returns 1 to indicate it is finished processing events. | |||
* | * | |||
* If the \ref LIBUSB_HOTPLUG_ENUMERATE is passed the callback will be | ||||
* called with a \ref LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED for all devices | ||||
* already plugged into the machine. Note that libusbx modifies its interna | ||||
l | ||||
* device list from a separate thread, while calling hotplug callbacks from | ||||
* libusb_handle_events(), so it is possible for a device to already be pre | ||||
sent | ||||
* on, or removed from, its internal device list, while the hotplug callbac | ||||
ks | ||||
* still need to be dispatched. This means that when using \ref | ||||
* LIBUSB_HOTPLUG_ENUMERATE, your callback may be called twice for the arri | ||||
val | ||||
* of the same device, once from libusb_hotplug_register_callback() and onc | ||||
e | ||||
* from libusb_handle_events(); and/or your callback may be called for the | ||||
* removal of a device for which an arrived call was never made. | ||||
* | ||||
* Since version 1.0.16, \ref LIBUSBX_API_VERSION >= 0x01000102 | * Since version 1.0.16, \ref LIBUSBX_API_VERSION >= 0x01000102 | |||
* | * | |||
* \param[in] ctx context to register this callback with | * \param[in] ctx context to register this callback with | |||
* \param[in] events bitwise or of events that will trigger this callback. See \ref | * \param[in] events bitwise or of events that will trigger this callback. See \ref | |||
* libusb_hotplug_event | * libusb_hotplug_event | |||
* \param[in] flags hotplug callback flags. See \ref libusb_hotplug_flag | * \param[in] flags hotplug callback flags. See \ref libusb_hotplug_flag | |||
* \param[in] vendor_id the vendor id to match or \ref LIBUSB_HOTPLUG_MATCH _ANY | * \param[in] vendor_id the vendor id to match or \ref LIBUSB_HOTPLUG_MATCH _ANY | |||
* \param[in] product_id the product id to match or \ref LIBUSB_HOTPLUG_MAT CH_ANY | * \param[in] product_id the product id to match or \ref LIBUSB_HOTPLUG_MAT CH_ANY | |||
* \param[in] dev_class the device class to match or \ref LIBUSB_HOTPLUG_MA TCH_ANY | * \param[in] dev_class the device class to match or \ref LIBUSB_HOTPLUG_MA TCH_ANY | |||
* \param[in] cb_fn the function to be invoked on a matching event/device | * \param[in] cb_fn the function to be invoked on a matching event/device | |||
End of changes. 8 change blocks. | ||||
5 lines changed or deleted | 24 lines changed or added | |||