hotplug.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /* -*- Mode: C; indent-tabs-mode:nil ; c-basic-offset:8 -*- */
  2. /*
  3. * Hotplug support for libusb 1.0
  4. * Copyright (C) 2012 Nathan Hjelm <hjelmn@users.sourceforge.net>
  5. * Copyright (C) 2012 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. #if !defined(USBI_HOTPLUG_H)
  22. #define USBI_HOTPLUG_H
  23. /** \ingroup hotplug
  24. * The hotplug callback structure. The user populates this structure with
  25. * libusb_hotplug_prepare_callback() and then calls libusb_hotplug_register_callback()
  26. * to receive notification of hotplug events.
  27. */
  28. struct libusb_hotplug_callback {
  29. /** Context this callback is associated with */
  30. struct libusb_context *ctx;
  31. /** Vendor ID to match or LIBUSB_HOTPLUG_MATCH_ANY */
  32. int vendor_id;
  33. /** Product ID to match or LIBUSB_HOTPLUG_MATCH_ANY */
  34. int product_id;
  35. /** Device class to match or LIBUSB_HOTPLUG_MATCH_ANY */
  36. int dev_class;
  37. /** Hotplug callback flags */
  38. libusb_hotplug_flag flags;
  39. /** Event(s) that will trigger this callback */
  40. libusb_hotplug_event events;
  41. /** Callback function to invoke for matching event/device */
  42. libusb_hotplug_callback_fn cb;
  43. /** Handle for this callback (used to match on deregister) */
  44. libusb_hotplug_callback_handle handle;
  45. /** User data that will be passed to the callback function */
  46. void *user_data;
  47. /** Callback is marked for deletion */
  48. int needs_free;
  49. /** List this callback is registered in (ctx->hotplug_cbs) */
  50. struct list_head list;
  51. };
  52. typedef struct libusb_hotplug_callback libusb_hotplug_callback;
  53. struct libusb_hotplug_message {
  54. libusb_hotplug_event event;
  55. struct libusb_device *device;
  56. };
  57. typedef struct libusb_hotplug_message libusb_hotplug_message;
  58. void usbi_hotplug_deregister_all(struct libusb_context *ctx);
  59. void usbi_hotplug_match(struct libusb_device *dev, libusb_hotplug_event event);
  60. #endif