]> git.sesse.net Git - vlc/blobdiff - modules/gui/macosx/AppleRemote.h
* various improvements to the AppleRemote support by Martin Kahr <martin -attt->...
[vlc] / modules / gui / macosx / AppleRemote.h
index d53225f84ec62fc7dde1cc0f5e6f9d091f59ff6d..57b7010145fde183b159e9a65f634ddf295a0185 100644 (file)
 
 enum AppleRemoteEventIdentifier
 {
-       kRemoteButtonVolume_Plus=0,
-       kRemoteButtonVolume_Minus,
-       kRemoteButtonMenu,
-       kRemoteButtonPlay,
-       kRemoteButtonRight,     
-       kRemoteButtonLeft,      
-       kRemoteButtonRight_Hold,        
-       kRemoteButtonLeft_Hold,
-       kRemoteButtonMenu_Hold,
-       kRemoteButtonPlay_Sleep,
-       kRemoteControl_Switched
+    kRemoteButtonVolume_Plus        =1<<1,
+    kRemoteButtonVolume_Minus       =1<<2,
+    kRemoteButtonMenu               =1<<3,
+    kRemoteButtonPlay               =1<<4,
+    kRemoteButtonRight              =1<<5,
+    kRemoteButtonLeft               =1<<6,
+    kRemoteButtonRight_Hold         =1<<7,
+    kRemoteButtonLeft_Hold          =1<<8,
+    kRemoteButtonMenu_Hold          =1<<9,
+    kRemoteButtonPlay_Sleep         =1<<10,
+    kRemoteControl_Switched         =1<<11,
+    kRemoteButtonVolume_Plus_Hold   =1<<12,
+    kRemoteButtonVolume_Minus_Hold  =1<<13
 };
 typedef enum AppleRemoteEventIdentifier AppleRemoteEventIdentifier;
 
-/*     Encapsulates usage of the apple remote control
-       This class is implemented as a singleton as there is exactly one remote per machine (until now)
-       The class is not thread safe
+/*  Encapsulates usage of the apple remote control
+This class is implemented as a singleton as there is exactly one remote per machine (until now)
+The class is not thread safe
 */
 @interface AppleRemote : NSObject {
-       IOHIDDeviceInterface** hidDeviceInterface;
-       IOHIDQueueInterface**  queue;
-       NSMutableArray*            allCookies;
-       NSMutableDictionary*   cookieToButtonMapping;
-
-       BOOL openInExclusiveMode;
-       
-       int remoteId;
-
-       IBOutlet id delegate;
+    IOHIDDeviceInterface** hidDeviceInterface;
+    IOHIDQueueInterface**  queue;
+    NSMutableArray*        allCookies;
+    NSMutableDictionary*   cookieToButtonMapping;
+    
+    BOOL openInExclusiveMode;
+    BOOL simulatePlusMinusHold;
+    BOOL processesBacklog;
+    
+    /* state for simulating plus/minus hold */
+    BOOL lastEventSimulatedHold;
+    AppleRemoteEventIdentifier lastPlusMinusEvent;
+    NSTimeInterval lastPlusMinusEventTime;
+    
+    int remoteId;
+    unsigned int clickCountEnabledButtons;
+    NSTimeInterval maxClickTimeDifference;
+    NSTimeInterval lastClickCountEventTime; 
+    AppleRemoteEventIdentifier lastClickCountEvent;
+    unsigned int eventClickCount;
+    
+    IBOutlet id delegate;
 }
 
-- (void) setRemoteId: (int) aValue;
 - (int) remoteId;
 
 - (BOOL) isRemoteAvailable;
@@ -103,6 +116,42 @@ typedef enum AppleRemoteEventIdentifier AppleRemoteEventIdentifier;
 - (BOOL) isOpenInExclusiveMode;
 - (void) setOpenInExclusiveMode: (BOOL) value;
 
+/* click counting makes it possible to recognize if the user has pressed a button repeatedly
+ * click counting does delay each event as it has to wait if there is another event (second click)
+ * therefore there is a slight time difference (maximumClickCountTimeDifference) between a single click
+ * of the user and the call of your delegate method
+ * click counting can be enabled individually for specific buttons. Use the property clickCountEnableButtons
+ * to set the buttons for which click counting shall be enabled */
+- (BOOL) clickCountingEnabled;
+- (void) setClickCountingEnabled: (BOOL) value;
+
+- (unsigned int) clickCountEnabledButtons;
+- (void) setClickCountEnabledButtons: (unsigned int)value;
+
+/* the maximum time difference till which clicks are recognized as multi clicks */
+- (NSTimeInterval) maximumClickCountTimeDifference;
+- (void) setMaximumClickCountTimeDifference: (NSTimeInterval) timeDiff;
+
+/* When your application needs to much time on the main thread when processing an event other events
+ * may already be received which are put on a backlog. As soon as your main thread
+ * has some spare time this backlog is processed and may flood your delegate with calls.
+ * Backlog processing is turned off by default. */
+- (BOOL) processesBacklog;
+- (void) setProcessesBacklog: (BOOL) value;
+
+/* Sets an NSApplication delegate which starts listening when application is becoming active
+ * and stops listening when application resigns being active. 
+ * If an NSApplication delegate has been already set all method calls will be forwarded to this delegate, too. */
+- (BOOL) listeningOnAppActivate;
+- (void) setListeningOnAppActivate: (BOOL) value;
+
+/* Simulating plus/minus hold does deactivate sending of individual requests for plus/minus pressed down/released.
+ * Instead special hold events are being triggered when the user is pressing and holding plus/minus for a small period.
+ * With simulating enabled the plus/minus buttons do behave as the left/right buttons */
+- (BOOL) simulatesPlusMinusHold;
+- (void) setSimulatesPlusMinusHold: (BOOL) value;
+
+/* Delegates are not retained */
 - (void) setDelegate: (id) delegate;
 - (id) delegate;
 
@@ -116,15 +165,15 @@ typedef enum AppleRemoteEventIdentifier AppleRemoteEventIdentifier;
 
 @end
 
-/*     Method definitions for the delegate of the AppleRemote class
-*/
+/*  Method definitions for the delegate of the AppleRemote class */
 @interface NSObject(NSAppleRemoteDelegate)
 
-- (void) appleRemoteButton: (AppleRemoteEventIdentifier)buttonIdentifier pressedDown: (BOOL) pressedDown;
+- (void) appleRemoteButton: (AppleRemoteEventIdentifier)buttonIdentifier pressedDown: (BOOL) pressedDown clickCount: (unsigned int) count;
 
 @end
 
 @interface AppleRemote (PrivateMethods) 
+- (void) setRemoteId: (int) aValue;
 - (NSDictionary*) cookieToButtonMapping;
 - (IOHIDQueueInterface**) queue;
 - (IOHIDDeviceInterface**) hidDeviceInterface;
@@ -136,4 +185,15 @@ typedef enum AppleRemoteEventIdentifier AppleRemoteEventIdentifier;
 - (IOHIDDeviceInterface**) createInterfaceForDevice: (io_object_t) hidDevice;
 - (BOOL) initializeCookies;
 - (BOOL) openDevice;
+@end
+
+/* A NSApplication delegate which is used to activate and deactivate listening to the remote control
+ * dependent on the activation state of your application.
+ * All events are delegated to the original NSApplication delegate if necessary */
+@interface AppleRemoteApplicationDelegate : NSObject {
+    id applicationDelegate;
+}
+
+- (id) initWithApplicationDelegate: (id) delegate;
+- (id) applicationDelegate;
 @end
\ No newline at end of file