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