subrascasse

Sub Rascasse: an iPhone dive log for Subsurface cloud storage, with a pure-Swift git client (GPL-2.0)
git clone https://git.schurger.org/subrascasse.git
Log | Files | Refs | README | LICENSE

usbhid.h (2705B)


      1 /*
      2  * libdivecomputer
      3  *
      4  * Copyright (C) 2016 Jef Driesen
      5  *
      6  * This library is free software; you can redistribute it and/or
      7  * modify it under the terms of the GNU Lesser General Public
      8  * License as published by the Free Software Foundation; either
      9  * version 2.1 of the License, or (at your option) any later version.
     10  *
     11  * This library is distributed in the hope that it will be useful,
     12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     14  * Lesser General Public License for more details.
     15  *
     16  * You should have received a copy of the GNU Lesser General Public
     17  * License along with this library; if not, write to the Free Software
     18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
     19  * MA 02110-1301 USA
     20  */
     21 
     22 #ifndef DC_USBHID_H
     23 #define DC_USBHID_H
     24 
     25 #include "common.h"
     26 #include "context.h"
     27 #include "iostream.h"
     28 #include "iterator.h"
     29 #include "descriptor.h"
     30 
     31 #ifdef __cplusplus
     32 extern "C" {
     33 #endif /* __cplusplus */
     34 
     35 /**
     36  * USB HID device descriptor.
     37  */
     38 typedef struct dc_usbhid_desc_t {
     39 	unsigned short vid;
     40 	unsigned short pid;
     41 } dc_usbhid_desc_t;
     42 
     43 /**
     44  * Opaque object representing a USB HID device.
     45  */
     46 typedef struct dc_usbhid_device_t dc_usbhid_device_t;
     47 
     48 /**
     49  * Get the vendor id (VID) of the USB HID device.
     50  *
     51  * @param[in]  device  A valid USB HID device.
     52  */
     53 unsigned int
     54 dc_usbhid_device_get_vid (dc_usbhid_device_t *device);
     55 
     56 /**
     57  * Get the product id (PID) of the USB HID device.
     58  *
     59  * @param[in]  device  A valid USB HID device.
     60  */
     61 unsigned int
     62 dc_usbhid_device_get_pid (dc_usbhid_device_t *device);
     63 
     64 /**
     65  * Destroy the USB HID device and free all resources.
     66  *
     67  * @param[in]  device  A valid USB HID device.
     68  */
     69 void
     70 dc_usbhid_device_free(dc_usbhid_device_t *device);
     71 
     72 /**
     73  * Create an iterator to enumerate the USB HID devices.
     74  *
     75  * @param[out] iterator    A location to store the iterator.
     76  * @param[in]  context     A valid context object.
     77  * @param[in]  descriptor  A valid device descriptor or NULL.
     78  * @returns #DC_STATUS_SUCCESS on success, or another #dc_status_t code
     79  * on failure.
     80  */
     81 dc_status_t
     82 dc_usbhid_iterator_new (dc_iterator_t **iterator, dc_context_t *context, dc_descriptor_t *descriptor);
     83 
     84 /**
     85  * Open a USB HID connection.
     86  *
     87  * @param[out]  iostream A location to store the USB HID connection.
     88  * @param[in]   context  A valid context object.
     89  * @param[in]   device   A valid USB HID device.
     90  * @returns #DC_STATUS_SUCCESS on success, or another #dc_status_t code
     91  * on failure.
     92  */
     93 dc_status_t
     94 dc_usbhid_open (dc_iostream_t **iostream, dc_context_t *context, dc_usbhid_device_t *device);
     95 
     96 #ifdef __cplusplus
     97 }
     98 #endif /* __cplusplus */
     99 #endif /* DC_USBHID_H */