]> git.sesse.net Git - vlc/blob - modules/gui/macosx/AppleRemote.h
Adds support for Apple's remote (only handles Play/Pause at the moment).
[vlc] / modules / gui / macosx / AppleRemote.h
1 //
2 //  AppleRemote.h
3 //  AppleRemote
4 //
5 //  Created by Martin Kahr on 11.03.06.
6 //  Copyright 2006 martinkahr.com. All rights reserved.
7 //
8
9 #import <Cocoa/Cocoa.h>
10 #import <mach/mach.h>
11 #import <mach/mach_error.h>
12 #import <IOKit/IOKitLib.h>
13 #import <IOKit/IOCFPlugIn.h>
14 #import <IOKit/hid/IOHIDLib.h>
15 #import <IOKit/hid/IOHIDKeys.h>
16
17 enum AppleRemoteEventIdentifier
18 {
19         kRemoteButtonVolume_Plus=0,
20         kRemoteButtonVolume_Minus,
21         kRemoteButtonMenu,
22         kRemoteButtonPlay,
23         kRemoteButtonRight,     
24         kRemoteButtonLeft,      
25         kRemoteButtonRight_Hold,        
26         kRemoteButtonLeft_Hold,
27         kRemoteButtonMenu_Hold,
28         kRemoteButtonPlay_Sleep,
29         kRemoteControl_Switched
30 };
31 typedef enum AppleRemoteEventIdentifier AppleRemoteEventIdentifier;
32
33 /*      Encapsulates usage of the apple remote control
34         This class is implemented as a singleton as there is exactly one remote per machine (until now)
35         The class is not thread safe
36 */
37 @interface AppleRemote : NSObject {
38         IOHIDDeviceInterface** hidDeviceInterface;
39         IOHIDQueueInterface**  queue;
40         NSMutableArray*            allCookies;
41         NSMutableDictionary*   cookieToButtonMapping;
42
43         BOOL openInExclusiveMode;
44         
45         int remoteId;
46
47         IBOutlet id delegate;
48 }
49
50 - (void) setRemoteId: (int) aValue;
51 - (int) remoteId;
52
53 - (BOOL) isRemoteAvailable;
54
55 - (BOOL) isListeningToRemote;
56 - (void) setListeningToRemote: (BOOL) value;
57
58 - (BOOL) isOpenInExclusiveMode;
59 - (void) setOpenInExclusiveMode: (BOOL) value;
60
61 - (void) setDelegate: (id) delegate;
62 - (id) delegate;
63
64 - (IBAction) startListening: (id) sender;
65 - (IBAction) stopListening: (id) sender;
66 @end
67
68 @interface AppleRemote (Singleton)
69
70 + (AppleRemote*) sharedRemote;
71
72 @end
73
74 /*      Method definitions for the delegate of the AppleRemote class
75 */
76 @interface NSObject(NSAppleRemoteDelegate)
77
78 - (void) appleRemoteButton: (AppleRemoteEventIdentifier)buttonIdentifier pressedDown: (BOOL) pressedDown;
79
80 @end
81
82 @interface AppleRemote (PrivateMethods) 
83 - (NSDictionary*) cookieToButtonMapping;
84 - (IOHIDQueueInterface**) queue;
85 - (IOHIDDeviceInterface**) hidDeviceInterface;
86 - (void) handleEventWithCookieString: (NSString*) cookieString sumOfValues: (SInt32) sumOfValues; 
87 @end
88
89 @interface AppleRemote (IOKitMethods) 
90 - (io_object_t) findAppleRemoteDevice;
91 - (IOHIDDeviceInterface**) createInterfaceForDevice: (io_object_t) hidDevice;
92 - (BOOL) initializeCookies;
93 - (BOOL) openDevice;
94 @end