The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
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.

113 lines
4.1KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2015 - ROLI 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. #pragma once
  18. //==============================================================================
  19. #if JUCE_MAC || DOXYGEN
  20. /**
  21. Receives events from an Apple IR remote control device (Only available in OSX!).
  22. To use it, just create a subclass of this class, implementing the buttonPressed()
  23. callback, then call start() and stop() to start or stop receiving events.
  24. */
  25. class JUCE_API AppleRemoteDevice
  26. {
  27. public:
  28. //==============================================================================
  29. AppleRemoteDevice();
  30. virtual ~AppleRemoteDevice();
  31. //==============================================================================
  32. /** The set of buttons that may be pressed.
  33. @see buttonPressed
  34. */
  35. enum ButtonType
  36. {
  37. menuButton = 0, /**< The menu button (if it's held for a short time). */
  38. playButton, /**< The play button. */
  39. plusButton, /**< The plus or volume-up button. */
  40. minusButton, /**< The minus or volume-down button. */
  41. rightButton, /**< The right button (if it's held for a short time). */
  42. leftButton, /**< The left button (if it's held for a short time). */
  43. rightButton_Long, /**< The right button (if it's held for a long time). */
  44. leftButton_Long, /**< The menu button (if it's held for a long time). */
  45. menuButton_Long, /**< The menu button (if it's held for a long time). */
  46. playButtonSleepMode,
  47. switched
  48. };
  49. //==============================================================================
  50. /** Override this method to receive the callback about a button press.
  51. The callback will happen on the application's message thread.
  52. Some buttons trigger matching up and down events, in which the isDown parameter
  53. will be true and then false. Others only send a single event when the
  54. button is pressed.
  55. */
  56. virtual void buttonPressed (ButtonType buttonId, bool isDown) = 0;
  57. //==============================================================================
  58. /** Starts the device running and responding to events.
  59. Returns true if it managed to open the device.
  60. @param inExclusiveMode if true, the remote will be grabbed exclusively for this app,
  61. and will not be available to any other part of the system. If
  62. false, it will be shared with other apps.
  63. @see stop
  64. */
  65. bool start (bool inExclusiveMode);
  66. /** Stops the device running.
  67. @see start
  68. */
  69. void stop();
  70. /** Returns true if the device has been started successfully.
  71. */
  72. bool isActive() const;
  73. /** Returns the ID number of the remote, if it has sent one.
  74. */
  75. int getRemoteId() const { return remoteId; }
  76. //==============================================================================
  77. /** @internal */
  78. void handleCallbackInternal();
  79. private:
  80. void* device;
  81. void* queue;
  82. int remoteId;
  83. bool open (bool openInExclusiveMode);
  84. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AppleRemoteDevice)
  85. };
  86. #endif