1cdf0e10cSrcweir /*****************************************************************************
2cdf0e10cSrcweir  * MultiClickRemoteBehavior.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 
32cdf0e10cSrcweir #import <Cocoa/Cocoa.h>
33cdf0e10cSrcweir #import "RemoteControl.h"
34cdf0e10cSrcweir 
35cdf0e10cSrcweir /**
36cdf0e10cSrcweir 	A behavior that adds multiclick and hold events on top of a device.
37cdf0e10cSrcweir 	Events are generated and send to a delegate
38cdf0e10cSrcweir  */
39cdf0e10cSrcweir @interface MultiClickRemoteBehavior : NSObject {
40cdf0e10cSrcweir 	id delegate;
41cdf0e10cSrcweir 
42cdf0e10cSrcweir 	// state for simulating plus/minus hold
43cdf0e10cSrcweir 	BOOL simulateHoldEvents;
44cdf0e10cSrcweir 	BOOL lastEventSimulatedHold;
45cdf0e10cSrcweir 	RemoteControlEventIdentifier lastHoldEvent;
46cdf0e10cSrcweir 	NSTimeInterval lastHoldEventTime;
47cdf0e10cSrcweir 
48cdf0e10cSrcweir 	// state for multi click
49cdf0e10cSrcweir 	unsigned int clickCountEnabledButtons;
50cdf0e10cSrcweir 	NSTimeInterval maxClickTimeDifference;
51cdf0e10cSrcweir 	NSTimeInterval lastClickCountEventTime;
52cdf0e10cSrcweir 	RemoteControlEventIdentifier lastClickCountEvent;
53cdf0e10cSrcweir 	unsigned int eventClickCount;
54cdf0e10cSrcweir }
55cdf0e10cSrcweir 
init()56cdf0e10cSrcweir - (id) init;
57cdf0e10cSrcweir 
58cdf0e10cSrcweir // Delegates are not retained
setDelegate:(id)59cdf0e10cSrcweir - (void) setDelegate: (id) delegate;
delegate()60cdf0e10cSrcweir - (id) delegate;
61cdf0e10cSrcweir 
62cdf0e10cSrcweir // Simulating hold events does deactivate sending of individual requests for pressed down/released.
63cdf0e10cSrcweir // Instead special hold events are being triggered when the user is pressing and holding a button for a small period.
64*07a3d7f1SPedro Giffuni // Simulation is activated only for those buttons and remote control that do not have a separate event already
simulateHoldEvent()65cdf0e10cSrcweir - (BOOL) simulateHoldEvent;
setSimulateHoldEvent:(BOOL)66cdf0e10cSrcweir - (void) setSimulateHoldEvent: (BOOL) value;
67cdf0e10cSrcweir 
68cdf0e10cSrcweir // click counting makes it possible to recognize if the user has pressed a button repeatedly
69cdf0e10cSrcweir // click counting does delay each event as it has to wait if there is another event (second click)
70cdf0e10cSrcweir // therefore there is a slight time difference (maximumClickCountTimeDifference) between a single click
71cdf0e10cSrcweir // of the user and the call of your delegate method
72cdf0e10cSrcweir // click counting can be enabled individually for specific buttons. Use the property clickCountEnableButtons to
73cdf0e10cSrcweir // set the buttons for which click counting shall be enabled
clickCountingEnabled()74cdf0e10cSrcweir - (BOOL) clickCountingEnabled;
setClickCountingEnabled:(BOOL)75cdf0e10cSrcweir - (void) setClickCountingEnabled: (BOOL) value;
76cdf0e10cSrcweir 
clickCountEnabledButtons()77cdf0e10cSrcweir - (unsigned int) clickCountEnabledButtons;
setClickCountEnabledButtons:(unsigned int)78cdf0e10cSrcweir - (void) setClickCountEnabledButtons: (unsigned int)value;
79cdf0e10cSrcweir 
80cdf0e10cSrcweir // the maximum time difference till which clicks are recognized as multi clicks
maximumClickCountTimeDifference()81cdf0e10cSrcweir - (NSTimeInterval) maximumClickCountTimeDifference;
setMaximumClickCountTimeDifference:(NSTimeInterval)82cdf0e10cSrcweir - (void) setMaximumClickCountTimeDifference: (NSTimeInterval) timeDiff;
83cdf0e10cSrcweir 
84cdf0e10cSrcweir @end
85cdf0e10cSrcweir 
86cdf0e10cSrcweir /*
87cdf0e10cSrcweir  * Method definitions for the delegate of the MultiClickRemoteBehavior class
88cdf0e10cSrcweir  */
89cdf0e10cSrcweir @interface NSObject(MultiClickRemoteBehaviorDelegate)
90cdf0e10cSrcweir 
remoteButton:pressedDown:clickCount:(RemoteControlEventIdentifier,BOOL,unsigned int)91cdf0e10cSrcweir - (void) remoteButton: (RemoteControlEventIdentifier)buttonIdentifier pressedDown: (BOOL) pressedDown clickCount: (unsigned int) count;
92cdf0e10cSrcweir 
93cdf0e10cSrcweir @end
94