]> git.sesse.net Git - vlc/blob - modules/gui/macosx/AppleRemote.h
Rebuild the array of currently playing items as a background task.
[vlc] / modules / gui / macosx / AppleRemote.h
1 /*****************************************************************************
2  * AppleRemote.h
3  * AppleRemote
4  * $Id$
5  *
6  * Created by Martin Kahr on 11.03.06 under a MIT-style license. 
7  * Copyright (c) 2006 martinkahr.com. All rights reserved.
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining a 
10  * copy of this software and associated documentation files (the "Software"),
11  * to deal in the Software without restriction, including without limitation
12  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13  * and/or sell copies of the Software, and to permit persons to whom the
14  * Software is furnished to do so, subject to the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be included
17  * in all copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
22  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25  * THE SOFTWARE.
26  *
27  *****************************************************************************
28  *
29  * Note that changes made by any members or contributors of the VideoLAN team
30  * (i.e. changes that were checked in into one of VideoLAN's source code
31  * repositories) are licensed under the GNU General Public License version 2,
32  * or (at your option) any later version. 
33  * Thus, the following statements apply to our changes:
34  *
35  * Copyright (C) 2006 the VideoLAN team
36  * Authors: Eric Petit <titer@m0k.org>
37  *          Felix Kühne <fkuehne at videolan dot org>
38  *
39  * This program is free software; you can redistribute it and/or modify
40  * it under the terms of the GNU General Public License as published by
41  * the Free Software Foundation; either version 2 of the License, or
42  * (at your option) any later version.
43  *
44  * This program is distributed in the hope that it will be useful,
45  * but WITHOUT ANY WARRANTY; without even the implied warranty of
46  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
47  * GNU General Public License for more details.
48  *
49  * You should have received a copy of the GNU General Public License
50  * along with this program; if not, write to the Free Software
51  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
52  *****************************************************************************/
53
54 #import <Cocoa/Cocoa.h>
55 #import <mach/mach.h>
56 #import <mach/mach_error.h>
57 #import <IOKit/IOKitLib.h>
58 #import <IOKit/IOCFPlugIn.h>
59 #import <IOKit/hid/IOHIDLib.h>
60 #import <IOKit/hid/IOHIDKeys.h>
61
62 enum AppleRemoteEventIdentifier
63 {
64         kRemoteButtonVolume_Plus=0,
65         kRemoteButtonVolume_Minus,
66         kRemoteButtonMenu,
67         kRemoteButtonPlay,
68         kRemoteButtonRight,     
69         kRemoteButtonLeft,      
70         kRemoteButtonRight_Hold,        
71         kRemoteButtonLeft_Hold,
72         kRemoteButtonMenu_Hold,
73         kRemoteButtonPlay_Sleep,
74         kRemoteControl_Switched
75 };
76 typedef enum AppleRemoteEventIdentifier AppleRemoteEventIdentifier;
77
78 /*      Encapsulates usage of the apple remote control
79         This class is implemented as a singleton as there is exactly one remote per machine (until now)
80         The class is not thread safe
81 */
82 @interface AppleRemote : NSObject {
83         IOHIDDeviceInterface** hidDeviceInterface;
84         IOHIDQueueInterface**  queue;
85         NSMutableArray*            allCookies;
86         NSMutableDictionary*   cookieToButtonMapping;
87
88         BOOL openInExclusiveMode;
89         
90         int remoteId;
91
92         IBOutlet id delegate;
93 }
94
95 - (void) setRemoteId: (int) aValue;
96 - (int) remoteId;
97
98 - (BOOL) isRemoteAvailable;
99
100 - (BOOL) isListeningToRemote;
101 - (void) setListeningToRemote: (BOOL) value;
102
103 - (BOOL) isOpenInExclusiveMode;
104 - (void) setOpenInExclusiveMode: (BOOL) value;
105
106 - (void) setDelegate: (id) delegate;
107 - (id) delegate;
108
109 - (IBAction) startListening: (id) sender;
110 - (IBAction) stopListening: (id) sender;
111 @end
112
113 @interface AppleRemote (Singleton)
114
115 + (AppleRemote*) sharedRemote;
116
117 @end
118
119 /*      Method definitions for the delegate of the AppleRemote class
120 */
121 @interface NSObject(NSAppleRemoteDelegate)
122
123 - (void) appleRemoteButton: (AppleRemoteEventIdentifier)buttonIdentifier pressedDown: (BOOL) pressedDown;
124
125 @end
126
127 @interface AppleRemote (PrivateMethods) 
128 - (NSDictionary*) cookieToButtonMapping;
129 - (IOHIDQueueInterface**) queue;
130 - (IOHIDDeviceInterface**) hidDeviceInterface;
131 - (void) handleEventWithCookieString: (NSString*) cookieString sumOfValues: (SInt32) sumOfValues; 
132 @end
133
134 @interface AppleRemote (IOKitMethods) 
135 - (io_object_t) findAppleRemoteDevice;
136 - (IOHIDDeviceInterface**) createInterfaceForDevice: (io_object_t) hidDevice;
137 - (BOOL) initializeCookies;
138 - (BOOL) openDevice;
139 @end