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.

juce_AppleRemote.h 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2013 - Raw Material Software Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. #ifndef JUCE_APPLEREMOTE_H_INCLUDED
  18. #define JUCE_APPLEREMOTE_H_INCLUDED
  19. //==============================================================================
  20. #if JUCE_MAC || DOXYGEN
  21. /**
  22. Receives events from an Apple IR remote control device (Only available in OSX!).
  23. To use it, just create a subclass of this class, implementing the buttonPressed()
  24. callback, then call start() and stop() to start or stop receiving events.
  25. */
  26. class JUCE_API AppleRemoteDevice
  27. {
  28. public:
  29. //==============================================================================
  30. AppleRemoteDevice();
  31. virtual ~AppleRemoteDevice();
  32. //==============================================================================
  33. /** The set of buttons that may be pressed.
  34. @see buttonPressed
  35. */
  36. enum ButtonType
  37. {
  38. menuButton = 0, /**< The menu button (if it's held for a short time). */
  39. playButton, /**< The play button. */
  40. plusButton, /**< The plus or volume-up button. */
  41. minusButton, /**< The minus or volume-down button. */
  42. rightButton, /**< The right button (if it's held for a short time). */
  43. leftButton, /**< The left button (if it's held for a short time). */
  44. rightButton_Long, /**< The right button (if it's held for a long time). */
  45. leftButton_Long, /**< The menu button (if it's held for a long time). */
  46. menuButton_Long, /**< The menu button (if it's held for a long time). */
  47. playButtonSleepMode,
  48. switched
  49. };
  50. //==============================================================================
  51. /** Override this method to receive the callback about a button press.
  52. The callback will happen on the application's message thread.
  53. Some buttons trigger matching up and down events, in which the isDown parameter
  54. will be true and then false. Others only send a single event when the
  55. button is pressed.
  56. */
  57. virtual void buttonPressed (ButtonType buttonId, bool isDown) = 0;
  58. //==============================================================================
  59. /** Starts the device running and responding to events.
  60. Returns true if it managed to open the device.
  61. @param inExclusiveMode if true, the remote will be grabbed exclusively for this app,
  62. and will not be available to any other part of the system. If
  63. false, it will be shared with other apps.
  64. @see stop
  65. */
  66. bool start (bool inExclusiveMode);
  67. /** Stops the device running.
  68. @see start
  69. */
  70. void stop();
  71. /** Returns true if the device has been started successfully.
  72. */
  73. bool isActive() const;
  74. /** Returns the ID number of the remote, if it has sent one.
  75. */
  76. int getRemoteId() const { return remoteId; }
  77. //==============================================================================
  78. /** @internal */
  79. void handleCallbackInternal();
  80. private:
  81. void* device;
  82. void* queue;
  83. int remoteId;
  84. bool open (bool openInExclusiveMode);
  85. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AppleRemoteDevice)
  86. };
  87. #endif
  88. #endif // JUCE_APPLEREMOTE_H_INCLUDED