Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

117 lines
4.1KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2017 - ROLI Ltd.
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. By using JUCE, you agree to the terms of both the JUCE 5 End-User License
  8. Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
  9. 27th April 2017).
  10. End User License Agreement: www.juce.com/juce-5-licence
  11. Privacy Policy: www.juce.com/juce-5-privacy-policy
  12. Or: You may also use this code under the terms of the GPL v3 (see
  13. www.gnu.org/licenses).
  14. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  15. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  16. DISCLAIMED.
  17. ==============================================================================
  18. */
  19. namespace juce
  20. {
  21. //==============================================================================
  22. #if JUCE_MAC || DOXYGEN
  23. /**
  24. Receives events from an Apple IR remote control device (Only available in OSX!).
  25. To use it, just create a subclass of this class, implementing the buttonPressed()
  26. callback, then call start() and stop() to start or stop receiving events.
  27. */
  28. class JUCE_API AppleRemoteDevice
  29. {
  30. public:
  31. //==============================================================================
  32. AppleRemoteDevice();
  33. virtual ~AppleRemoteDevice();
  34. //==============================================================================
  35. /** The set of buttons that may be pressed.
  36. @see buttonPressed
  37. */
  38. enum ButtonType
  39. {
  40. menuButton = 0, /**< The menu button (if it's held for a short time). */
  41. playButton, /**< The play button. */
  42. plusButton, /**< The plus or volume-up button. */
  43. minusButton, /**< The minus or volume-down button. */
  44. rightButton, /**< The right button (if it's held for a short time). */
  45. leftButton, /**< The left button (if it's held for a short time). */
  46. rightButton_Long, /**< The right button (if it's held for a long time). */
  47. leftButton_Long, /**< The menu button (if it's held for a long time). */
  48. menuButton_Long, /**< The menu button (if it's held for a long time). */
  49. playButtonSleepMode,
  50. switched
  51. };
  52. //==============================================================================
  53. /** Override this method to receive the callback about a button press.
  54. The callback will happen on the application's message thread.
  55. Some buttons trigger matching up and down events, in which the isDown parameter
  56. will be true and then false. Others only send a single event when the
  57. button is pressed.
  58. */
  59. virtual void buttonPressed (ButtonType buttonId, bool isDown) = 0;
  60. //==============================================================================
  61. /** Starts the device running and responding to events.
  62. Returns true if it managed to open the device.
  63. @param inExclusiveMode if true, the remote will be grabbed exclusively for this app,
  64. and will not be available to any other part of the system. If
  65. false, it will be shared with other apps.
  66. @see stop
  67. */
  68. bool start (bool inExclusiveMode);
  69. /** Stops the device running.
  70. @see start
  71. */
  72. void stop();
  73. /** Returns true if the device has been started successfully.
  74. */
  75. bool isActive() const;
  76. /** Returns the ID number of the remote, if it has sent one.
  77. */
  78. int getRemoteId() const { return remoteId; }
  79. //==============================================================================
  80. /** @internal */
  81. void handleCallbackInternal();
  82. private:
  83. void* device;
  84. void* queue;
  85. int remoteId;
  86. bool open (bool openInExclusiveMode);
  87. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AppleRemoteDevice)
  88. };
  89. #endif
  90. } // namespace juce