hidapi_darwin.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*******************************************************
  2. HIDAPI - Multi-Platform library for
  3. communication with HID devices.
  4. libusb/hidapi Team
  5. Copyright 2022, All Rights Reserved.
  6. At the discretion of the user of this library,
  7. this software may be licensed under the terms of the
  8. GNU General Public License v3, a BSD-Style license, or the
  9. original HIDAPI license as outlined in the LICENSE.txt,
  10. LICENSE-gpl3.txt, LICENSE-bsd.txt, and LICENSE-orig.txt
  11. files located at the root of the source distribution.
  12. These files may also be found in the public source
  13. code repository located at:
  14. https://github.com/libusb/hidapi .
  15. ********************************************************/
  16. /** @file
  17. * @defgroup API hidapi API
  18. * Since version 0.12.0, @ref HID_API_VERSION >= HID_API_MAKE_VERSION(0, 12, 0)
  19. */
  20. #ifndef HIDAPI_DARWIN_H__
  21. #define HIDAPI_DARWIN_H__
  22. #include <stdint.h>
  23. #include "../hidapi/hidapi.h"
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. /** @brief Get the location ID for a HID device.
  28. Since version 0.12.0, @ref HID_API_VERSION >= HID_API_MAKE_VERSION(0, 12, 0)
  29. @ingroup API
  30. @param dev A device handle returned from hid_open().
  31. @param location_id The device's location ID on return.
  32. @returns
  33. This function returns 0 on success and -1 on error.
  34. */
  35. int HID_API_EXPORT_CALL hid_darwin_get_location_id(hid_device *dev, uint32_t *location_id);
  36. /** @brief Changes the behavior of all further calls to @ref hid_open or @ref hid_open_path.
  37. By default on Darwin platform all devices opened by HIDAPI with @ref hid_open or @ref hid_open_path
  38. are opened in exclusive mode (see kIOHIDOptionsTypeSeizeDevice).
  39. Since version 0.12.0, @ref HID_API_VERSION >= HID_API_MAKE_VERSION(0, 12, 0)
  40. @ingroup API
  41. @param open_exclusive When set to 0 - all further devices will be opened
  42. in non-exclusive mode. Otherwise - all further devices will be opened
  43. in exclusive mode.
  44. @note During the initialisation by @ref hid_init - this property is set to 1 (TRUE).
  45. This is done to preserve full backward compatibility with previous behavior.
  46. @note Calling this function before @ref hid_init or after @ref hid_exit has no effect.
  47. */
  48. void HID_API_EXPORT_CALL hid_darwin_set_open_exclusive(int open_exclusive);
  49. /** @brief Getter for option set by @ref hid_darwin_set_open_exclusive.
  50. Since version 0.12.0, @ref HID_API_VERSION >= HID_API_MAKE_VERSION(0, 12, 0)
  51. @ingroup API
  52. @return 1 if all further devices will be opened in exclusive mode.
  53. @note Value returned by this function before calling to @ref hid_init or after @ref hid_exit
  54. is not reliable.
  55. */
  56. int HID_API_EXPORT_CALL hid_darwin_get_open_exclusive(void);
  57. /** @brief Check how the device was opened.
  58. Since version 0.12.0, @ref HID_API_VERSION >= HID_API_MAKE_VERSION(0, 12, 0)
  59. @ingroup API
  60. @param dev A device to get property from.
  61. @return 1 if the device is opened in exclusive mode, 0 - opened in non-exclusive,
  62. -1 - if dev is invalid.
  63. */
  64. int HID_API_EXPORT_CALL hid_darwin_is_device_open_exclusive(hid_device *dev);
  65. #ifdef __cplusplus
  66. }
  67. #endif
  68. #endif