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 } RemoteControlEventIdentifier;
69 
70 @interface NSObject(RemoteControlDelegate)
71 
72 - (void) sendRemoteButtonEvent: (RemoteControlEventIdentifier) event pressedDown: (BOOL) pressedDown remoteControl: (RemoteControl*) remoteControl;
73 
74 @end
75 
76 /*
77 	Base Interface for Remote Control devices
78 */
79 @interface RemoteControl : NSObject {
80 	id delegate;
81 }
82 
83 // returns nil if the remote control device is not available
84 - (id) initWithDelegate: (id) remoteControlDelegate;
85 
86 - (void) setListeningToRemote: (BOOL) value;
87 - (BOOL) isListeningToRemote;
88 
89 - (BOOL) isOpenInExclusiveMode;
90 - (void) setOpenInExclusiveMode: (BOOL) value;
91 
92 - (void) startListening: (id) sender;
93 - (void) stopListening: (id) sender;
94 
95 // is this remote control sending the given event?
96 - (BOOL) sendsEventForButtonIdentifier: (RemoteControlEventIdentifier) identifier;
97 
98 // sending of notifications between applications
99 + (void) sendFinishedNotifcationForAppIdentifier: (NSString*) identifier;
100 + (void) sendRequestForRemoteControlNotification;
101 
102 // name of the device
103 + (const char*) remoteControlDeviceName;
104 
105 @end
106