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