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