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.

116 lines
4.4KB

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