Merge tag 'v0.2.0'
[rtmpclient.git] / app / src / main / jni / libusb / libusb / hotplug.h
1 /* -*- Mode: C; indent-tabs-mode:t ; c-basic-offset:8 -*- */
2 /*
3  * Hotplug support for libusb
4  * Copyright © 2012-2013 Nathan Hjelm <hjelmn@mac.com>
5  * Copyright © 2012-2013 Peter Stuge <peter@stuge.se>
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21
22 #if !defined(USBI_HOTPLUG_H)
23 #define USBI_HOTPLUG_H
24
25 #ifndef LIBUSBI_H
26 #include "libusbi.h"
27 #endif
28
29 /** \ingroup hotplug
30  * The hotplug callback structure. The user populates this structure with
31  * libusb_hotplug_prepare_callback() and then calls libusb_hotplug_register_callback()
32  * to receive notification of hotplug events.
33  */
34 struct libusb_hotplug_callback {
35         /** Context this callback is associated with */
36         struct libusb_context *ctx;
37
38         /** Vendor ID to match or LIBUSB_HOTPLUG_MATCH_ANY */
39         int vendor_id;
40
41         /** Product ID to match or LIBUSB_HOTPLUG_MATCH_ANY */
42         int product_id;
43
44         /** Device class to match or LIBUSB_HOTPLUG_MATCH_ANY */
45         int dev_class;
46
47         /** Hotplug callback flags */
48         libusb_hotplug_flag flags;
49
50         /** Event(s) that will trigger this callback */
51         libusb_hotplug_event events;
52
53         /** Callback function to invoke for matching event/device */
54         libusb_hotplug_callback_fn cb;
55
56         /** Handle for this callback (used to match on deregister) */
57         libusb_hotplug_callback_handle handle;
58
59         /** User data that will be passed to the callback function */
60         void *user_data;
61
62         /** Callback is marked for deletion */
63         int needs_free;
64
65         /** List this callback is registered in (ctx->hotplug_cbs) */
66         struct list_head list;
67 };
68
69 typedef struct libusb_hotplug_callback libusb_hotplug_callback;
70
71 struct libusb_hotplug_message {
72         libusb_hotplug_event event;
73         struct libusb_device *device;
74 };
75
76 typedef struct libusb_hotplug_message libusb_hotplug_message;
77
78 void usbi_hotplug_deregister_all(struct libusb_context *ctx);
79 void usbi_hotplug_match(struct libusb_context *ctx, struct libusb_device *dev,
80                         libusb_hotplug_event event);
81
82 #endif