1 /*****************************************************************************
2  * RemoteControl.h
3  * RemoteControlWrapper
4  *
5  * Created by Martin Kahr on 11.03.06 under a MIT-style license.
6  * Copyright (c) 2006 martinkahr.com. All rights reserved.
7  *
8  * Code modified and adapted to OpenOffice.org
9  * by Eric Bachard on 11.08.2008 under the same License
10  *
11  * Permission is hereby granted, free of charge, to any person obtaining a
12  * copy of this software and associated documentation files (the "Software"),
13  * to deal in the Software without restriction, including without limitation
14  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
15  * and/or sell copies of the Software, and to permit persons to whom the
16  * Software is furnished to do so, subject to the following conditions:
17  *
18  * The above copyright notice and this permission notice shall be included
19  * in all copies or substantial portions of the Software.
20  *
21  * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27  * THE SOFTWARE.
28  *
29  *****************************************************************************/
30 
31 #import <Cocoa/Cocoa.h>
32 
33 // notifaction names that are being used to signal that an application wants to
34 // have access to the remote control device or if the application has finished
35 // using the remote control device
36 extern NSString* REQUEST_FOR_REMOTE_CONTROL_NOTIFCATION;
37 extern NSString* FINISHED_USING_REMOTE_CONTROL_NOTIFICATION;
38 
39 // keys used in user objects for distributed notifications
40 extern NSString* kRemoteControlDeviceName;
41 extern NSString* kApplicationIdentifier;
42 extern NSString* kTargetApplicationIdentifier;
43 
44 // we have a 6 bit offset to make a hold event out of a normal event
45 #define EVENT_TO_HOLD_EVENT_OFFSET 6
46 
47 @class RemoteControl;
48 
49 typedef enum _RemoteControlEventIdentifier {
50 	// normal events
51 	kRemoteButtonPlus				=1<<1,
52 	kRemoteButtonMinus				=1<<2,
53 	kRemoteButtonMenu				=1<<3,
54 	kRemoteButtonPlay				=1<<4,
55 	kRemoteButtonRight				=1<<5,
56 	kRemoteButtonLeft				=1<<6,
57 
58 	// hold events
59 	kRemoteButtonPlus_Hold			=1<<7,
60 	kRemoteButtonMinus_Hold			=1<<8,
61 	kRemoteButtonMenu_Hold			=1<<9,
62 	kRemoteButtonPlay_Hold			=1<<10,
63 	kRemoteButtonRight_Hold			=1<<11,
64 	kRemoteButtonLeft_Hold			=1<<12,
65 
66 	// special events (not supported by all devices)
67 	kRemoteControl_Switched			=1<<13,
68 
69 	// New values for the "metallic" Remote (2009 model)
70 	kMetallicRemote2009ButtonPlay		=1<<14,
71 	kMetallicRemote2009ButtonMiddlePlay	=1<<15
72 
73 } RemoteControlEventIdentifier;
74 
75 @interface NSObject(RemoteControlDelegate)
76 
sendRemoteButtonEvent:pressedDown:remoteControl:(RemoteControlEventIdentifier,BOOL,RemoteControl*)77 - (void) sendRemoteButtonEvent: (RemoteControlEventIdentifier) event pressedDown: (BOOL) pressedDown remoteControl: (RemoteControl*) remoteControl;
78 
79 @end
80 
81 /*
82 	Base Interface for Remote Control devices
83 */
84 @interface RemoteControl : NSObject {
85 	id delegate;
86 }
87 
88 // returns nil if the remote control device is not available
initWithDelegate:(id)89 - (id) initWithDelegate: (id) remoteControlDelegate;
90 
setListeningToRemote:(BOOL)91 - (void) setListeningToRemote: (BOOL) value;
isListeningToRemote()92 - (BOOL) isListeningToRemote;
93 
isOpenInExclusiveMode()94 - (BOOL) isOpenInExclusiveMode;
setOpenInExclusiveMode:(BOOL)95 - (void) setOpenInExclusiveMode: (BOOL) value;
96 
startListening:(id)97 - (void) startListening: (id) sender;
stopListening:(id)98 - (void) stopListening: (id) sender;
99 
100 // is this remote control sending the given event?
sendsEventForButtonIdentifier:(RemoteControlEventIdentifier)101 - (BOOL) sendsEventForButtonIdentifier: (RemoteControlEventIdentifier) identifier;
102 
103 // sending of notifications between applications
104 + (void) sendFinishedNotifcationForAppIdentifier: (NSString*) identifier;
105 + (void) sendRequestForRemoteControlNotification;
106 
107 // name of the device
108 + (const char*) remoteControlDeviceName;
109 
110 @end
111