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 3.9KB

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