libdc/src/usbhid.h
Linus Torvalds c52becf6d4 Merge git://github.com/libdivecomputer/libdivecomputer into Subsurface-branch
Merge with upstream:

 - support for the OSTC 2 TR

 - add support for dive computer filtering for device discovery

 - various cleanups particularly to timestamp handling

 - remove half-duplex emulation from the I/O api

* 'master' of git://github.com/libdivecomputer/libdivecomputer:
  Remove the half-duplex emulation from the I/O api
  Handle the half-duplex emulation in the vyper2 backend
  Use the new timer for the timestamps in the logging
  Use the new timer for the timeout calculations
  Add a high resolution timer module
  Add functions for converting bluetooth addresses
  Add support for the OSTC 2 TR
  Add a workaround for invalid logbook begin pointers
  Let the ringbuffer function handle a full ringbuffer
  Suppress the warning if no O2 sensors are present
  Integrate the connect step into the open function
  Implement some filter functions
  Add suport for applying a filter function
  Re-write the device discovery using the iterator api
  Cleanup the iterator internals
2018-03-11 12:43:59 -07:00

97 lines
2.8 KiB
C

/*
* libdivecomputer
*
* Copyright (C) 2016 Jef Driesen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
#ifndef DC_USBHID_H
#define DC_USBHID_H
#include <libdivecomputer/common.h>
#include <libdivecomputer/context.h>
#include <libdivecomputer/iostream.h>
#include <libdivecomputer/iterator.h>
#include <libdivecomputer/descriptor.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/**
* Opaque object representing a USB HID device.
*/
typedef struct dc_usbhid_device_t dc_usbhid_device_t;
/**
* Get the vendor id (VID) of the USB HID device.
*
* @param[in] device A valid USB HID device.
*/
unsigned int
dc_usbhid_device_get_vid (dc_usbhid_device_t *device);
/**
* Get the product id (PID) of the USB HID device.
*
* @param[in] device A valid USB HID device.
*/
unsigned int
dc_usbhid_device_get_pid (dc_usbhid_device_t *device);
/**
* Destroy the USB HID device and free all resources.
*
* @param[in] device A valid USB HID device.
*/
void
dc_usbhid_device_free(dc_usbhid_device_t *device);
/**
* Create an iterator to enumerate the USB HID devices.
*
* @param[out] iterator A location to store the iterator.
* @param[in] context A valid context object.
* @param[in] descriptor A valid device descriptor or NULL.
* @returns #DC_STATUS_SUCCESS on success, or another #dc_status_t code
* on failure.
*/
dc_status_t
dc_usbhid_iterator_new (dc_iterator_t **iterator, dc_context_t *context, dc_descriptor_t *descriptor);
/**
* Open a USB HID connection.
*
* @param[out] iostream A location to store the USB HID connection.
* @param[in] context A valid context object.
* @param[in] vid The USB Vendor ID of the device.
* @param[in] pid The USB Product ID of the device.
* @returns #DC_STATUS_SUCCESS on success, or another #dc_status_t code
* on failure.
*/
dc_status_t
dc_usbhid_open (dc_iostream_t **iostream, dc_context_t *context, unsigned int vid, unsigned int pid);
/* Create a dc_custom_io_t that uses usbhid for packet transfer */
dc_status_t
dc_usbhid_custom_io(dc_context_t *context, unsigned int vid, unsigned int pid);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* DC_USBHID_H */