summaryrefslogtreecommitdiff
path: root/apple_remote
diff options
context:
space:
mode:
authorAlexander Wilms <f.alexander.wilms@gmail.com>2014-02-25 17:23:41 +0100
committerCaolán McNamara <caolanm@redhat.com>2014-02-25 16:26:29 +0000
commitb2afdb85c30c27c7fce96f206aeb115cb2a193ab (patch)
treecf28c4a65fb75f04b42e298507162d5da9ae783d /apple_remote
parent27c3b8bca22353dfdcf4c248539a727522fc4e76 (diff)
Remove visual noise from apple_remote
Change-Id: I12bec42cb699d8cbcfab2eb4d2f8ad8f5ed83b78 Reviewed-on: https://gerrit.libreoffice.org/8229 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'apple_remote')
-rw-r--r--apple_remote/source/AppleRemote.m22
-rw-r--r--apple_remote/source/HIDRemoteControlDevice.m10
-rw-r--r--apple_remote/source/KeyspanFrontRowControl.m34
-rw-r--r--apple_remote/source/MultiClickRemoteBehavior.m58
-rw-r--r--apple_remote/source/RemoteMainController.m4
5 files changed, 64 insertions, 64 deletions
diff --git a/apple_remote/source/AppleRemote.m b/apple_remote/source/AppleRemote.m
index 8f1b2ce777be..48dd9effe3c8 100644
--- a/apple_remote/source/AppleRemote.m
+++ b/apple_remote/source/AppleRemote.m
@@ -3,13 +3,13 @@
* RemoteControlWrapper.m
* RemoteControlWrapper
*
- * Created by Martin Kahr on 11.03.06 under a MIT-style license.
+ * Created by Martin Kahr on 11.03.06 under a MIT-style license.
* Copyright (c) 2006 martinkahr.com. All rights reserved.
*
- * Code modified and adapted to OpenOffice.org
+ * Code modified and adapted to OpenOffice.org
* by Eric Bachard on 11.08.2008 under the same license
*
- * Permission is hereby granted, free of charge, to any person obtaining a
+ * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
@@ -21,7 +21,7 @@
*
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
@@ -45,15 +45,15 @@ const char* AppleRemoteDeviceName = "AppleIRController";
return AppleRemoteDeviceName;
}
-- (void) setCookieMappingInDictionary: (NSMutableDictionary*) _cookieToButtonMapping {
-
- // TODO : avoid such magics
+- (void) setCookieMappingInDictionary: (NSMutableDictionary*) _cookieToButtonMapping {
+
+ // TODO : avoid such magics
#ifdef DEBUG
NSLog( @"Apple Remote: setting 10.6 cookies" );
#endif
// 10.6.x Snow Leopard
[_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonPlus] forKey:@"33_31_30_21_20_2_"];
- [_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonMinus] forKey:@"33_32_30_21_20_2_"];
+ [_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonMinus] forKey:@"33_32_30_21_20_2_"];
[_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonMenu] forKey:@"33_22_21_20_2_33_22_21_20_2_"];
[_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonPlay] forKey:@"33_23_21_20_2_33_23_21_20_2_"];
[_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonRight] forKey:@"33_24_21_20_2_33_24_21_20_2_"];
@@ -72,10 +72,10 @@ const char* AppleRemoteDeviceName = "AppleIRController";
if (pressedDown == NO && event == kRemoteButtonMenu_Hold) {
// There is no separate event for pressed down on menu hold. We are simulating that event here
[super sendRemoteButtonEvent:event pressedDown:YES];
- }
-
+ }
+
[super sendRemoteButtonEvent:event pressedDown:pressedDown];
-
+
if (pressedDown && (event == kRemoteButtonRight || event == kRemoteButtonLeft || event == kRemoteButtonPlay || event == kRemoteButtonMenu || event == kRemoteButtonPlay_Hold)) {
// There is no separate event when the button is being released. We are simulating that event here
[super sendRemoteButtonEvent:event pressedDown:NO];
diff --git a/apple_remote/source/HIDRemoteControlDevice.m b/apple_remote/source/HIDRemoteControlDevice.m
index cffcfa0e50a6..e82034849d2a 100644
--- a/apple_remote/source/HIDRemoteControlDevice.m
+++ b/apple_remote/source/HIDRemoteControlDevice.m
@@ -149,23 +149,23 @@
if ([self isListeningToRemote]) return;
// 4th July 2007
- //
+
// A security update in february of 2007 introduced an odd behavior.
// Whenever SecureEventInput is activated or deactivated the exclusive access
// to the remote control device is lost. This leads to very strange behavior where
// a press on the Menu button activates FrontRow while your app still gets the event.
// A great number of people have complained about this.
- //
+
// Enabling the SecureEventInput and keeping it enabled does the trick.
- //
+
// I'm pretty sure this is a kind of bug at Apple and I'm in contact with the responsible
// Apple Engineer. This solution is not a perfect one - I know.
// One of the side effects is that applications that listen for special global keyboard shortcuts (like Quicksilver)
// may get into problems as they no longer get the events.
// As there is no official Apple Remote API from Apple I also failed to open a technical incident on this.
- //
+
// Note that there is a corresponding DisableSecureEventInput in the stopListening method below.
- //
+
if ([self isOpenInExclusiveMode] && fixSecureEventInputBug) EnableSecureEventInput();
[self removeNotifcationObserver];
diff --git a/apple_remote/source/KeyspanFrontRowControl.m b/apple_remote/source/KeyspanFrontRowControl.m
index 09787383e91b..c637aa9cf9c7 100644
--- a/apple_remote/source/KeyspanFrontRowControl.m
+++ b/apple_remote/source/KeyspanFrontRowControl.m
@@ -3,13 +3,13 @@
* KeyspanFrontRowControl.m
* RemoteControlWrapper
*
- * Created by Martin Kahr on 11.03.06 under a MIT-style license.
+ * Created by Martin Kahr on 11.03.06 under a MIT-style license.
* Copyright (c) 2006 martinkahr.com. All rights reserved.
*
- * Code modified and adapted to OpenOffice.org
+ * Code modified and adapted to OpenOffice.org
* by Eric Bachard on 11.08.2008 under the same License
*
- * Permission is hereby granted, free of charge, to any person obtaining a
+ * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
@@ -21,14 +21,14 @@
*
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*****************************************************************************/
-
+
#import "KeyspanFrontRowControl.h"
#import <mach/mach.h>
#import <mach/mach_error.h>
@@ -38,10 +38,10 @@
@implementation KeyspanFrontRowControl
-- (void) setCookieMappingInDictionary: (NSMutableDictionary*) _cookieToButtonMapping {
+- (void) setCookieMappingInDictionary: (NSMutableDictionary*) _cookieToButtonMapping {
[_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonPlus] forKey:@"11_18_99_10_"];
- [_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonMinus] forKey:@"11_18_98_10_"];
- [_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonMenu] forKey:@"11_18_58_10_"];
+ [_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonMinus] forKey:@"11_18_98_10_"];
+ [_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonMenu] forKey:@"11_18_58_10_"];
[_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonPlay] forKey:@"11_18_61_10_"];
[_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonRight] forKey:@"11_18_96_10_"];
[_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonLeft] forKey:@"11_18_97_10_"];
@@ -50,22 +50,22 @@
[_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonLeft_Hold] forKey:@"14_6_3_2_"];
[_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonMenu_Hold] forKey:@"14_6_14_6_"];
[_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonPlay_Sleep] forKey:@"18_14_6_18_14_6_"];
- [_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteControl_Switched] forKey:@"19_"];
+ [_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteControl_Switched] forKey:@"19_"];
*/
}
+ (io_object_t) findRemoteDevice {
CFMutableDictionaryRef hidMatchDictionary = NULL;
- IOReturn ioReturnValue = kIOReturnSuccess;
+ IOReturn ioReturnValue = kIOReturnSuccess;
io_iterator_t hidObjectIterator = 0;
io_object_t hidDevice = 0;
SInt32 idVendor = 1741;
- SInt32 idProduct = 0x420;
-
+ SInt32 idProduct = 0x420;
+
// Set up a matching dictionary to search the I/O Registry by class
// name for all HID class devices
hidMatchDictionary = IOServiceMatching(kIOHIDDeviceKey);
-
+
CFNumberRef numberRefVendor = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &idVendor);
if ( numberRefVendor )
{
@@ -77,22 +77,22 @@
if ( numberRefProduct )
{
CFDictionaryAddValue(hidMatchDictionary, CFSTR(kIOHIDProductIDKey), numberRefProduct);
- CFRelease(numberRefProduct);
+ CFRelease(numberRefProduct);
}
// Now search I/O Registry for matching devices.
ioReturnValue = IOServiceGetMatchingServices(kIOMasterPortDefault, hidMatchDictionary, &hidObjectIterator);
-
+
if ((ioReturnValue == kIOReturnSuccess) && (hidObjectIterator != 0)) {
hidDevice = IOIteratorNext(hidObjectIterator);
}
-
+
// release the iterator
if ( hidObjectIterator )
IOObjectRelease(hidObjectIterator);
return hidDevice;
-
+
}
@end
diff --git a/apple_remote/source/MultiClickRemoteBehavior.m b/apple_remote/source/MultiClickRemoteBehavior.m
index 1d624a76284d..0972a5ae99d6 100644
--- a/apple_remote/source/MultiClickRemoteBehavior.m
+++ b/apple_remote/source/MultiClickRemoteBehavior.m
@@ -3,13 +3,13 @@
* MultiClickRemoteBehavior.m
* RemoteControlWrapper
*
- * Created by Martin Kahr on 11.03.06 under a MIT-style license.
+ * Created by Martin Kahr on 11.03.06 under a MIT-style license.
* Copyright (c) 2006 martinkahr.com. All rights reserved.
*
- * Code modified and adapted to OpenOffice.org
+ * Code modified and adapted to OpenOffice.org
* by Eric Bachard on 11.08.2008 under the same License
*
- * Permission is hereby granted, free of charge, to any person obtaining a
+ * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
@@ -21,7 +21,7 @@
*
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
@@ -45,12 +45,12 @@ const NSTimeInterval HOLD_RECOGNITION_TIME_INTERVAL = 0.4;
// Delegates are not retained!
// http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaFundamentals/CommunicatingWithObjects/chapter_6_section_4.html
-// Delegating objects do not (and should not) retain their delegates.
+// Delegating objects do not (and should not) retain their delegates.
// However, clients of delegating objects (applications, usually) are responsible for ensuring that their delegates are around
// to receive delegation messages. To do this, they may have to retain the delegate.
- (void) setDelegate: (id) _delegate {
if ( _delegate && ( [_delegate respondsToSelector:@selector(remoteButton:pressedDown:clickCount:)] == NO )) return; // return what ?
-
+
delegate = _delegate;
}
- (id) delegate {
@@ -66,8 +66,8 @@ const NSTimeInterval HOLD_RECOGNITION_TIME_INTERVAL = 0.4;
- (BOOL) simulatesHoldForButtonIdentifier: (RemoteControlEventIdentifier) identifier remoteControl: (RemoteControl*) remoteControl {
// we do that check only for the normal button identifiers as we would check for hold support for hold events instead
- if (identifier > (1 << EVENT_TO_HOLD_EVENT_OFFSET)) return NO;
-
+ if (identifier > (1 << EVENT_TO_HOLD_EVENT_OFFSET)) return NO;
+
return [self simulateHoldEvent] && [remoteControl sendsEventForButtonIdentifier: (identifier << EVENT_TO_HOLD_EVENT_OFFSET)]==NO;
}
@@ -110,32 +110,32 @@ const NSTimeInterval HOLD_RECOGNITION_TIME_INTERVAL = 0.4;
}
- (void) executeClickCountEvent: (NSArray*) values {
- RemoteControlEventIdentifier event = [[values objectAtIndex: 0] unsignedIntValue];
+ RemoteControlEventIdentifier event = [[values objectAtIndex: 0] unsignedIntValue];
NSTimeInterval eventTimePoint = [[values objectAtIndex: 1] doubleValue];
-
+
BOOL finishedClicking = NO;
- int finalClickCount = eventClickCount;
-
+ int finalClickCount = eventClickCount;
+
@synchronized(self) {
finishedClicking = (event != lastClickCountEvent || eventTimePoint == lastClickCountEventTime);
if (finishedClicking) {
- eventClickCount = 0;
+ eventClickCount = 0;
lastClickCountEvent = 0;
lastClickCountEventTime = 0;
}
}
-
- if (finishedClicking) {
- [delegate remoteButton:event pressedDown: YES clickCount:finalClickCount];
+
+ if (finishedClicking) {
+ [delegate remoteButton:event pressedDown: YES clickCount:finalClickCount];
// trigger a button release event, too
[NSThread sleepUntilDate: [NSDate dateWithTimeIntervalSinceNow:0.1]];
[delegate remoteButton:event pressedDown: NO clickCount:finalClickCount];
}
}
-- (void) sendRemoteButtonEvent: (RemoteControlEventIdentifier) event pressedDown: (BOOL) pressedDown remoteControl: (RemoteControl*) remoteControl {
+- (void) sendRemoteButtonEvent: (RemoteControlEventIdentifier) event pressedDown: (BOOL) pressedDown remoteControl: (RemoteControl*) remoteControl {
if (!delegate) return;
-
+
BOOL clickCountingForEvent = ([self clickCountEnabledButtons] & event) == event;
if ([self simulatesHoldForButtonIdentifier: event remoteControl: remoteControl] && lastClickCountEvent==0) {
@@ -143,7 +143,7 @@ const NSTimeInterval HOLD_RECOGNITION_TIME_INTERVAL = 0.4;
// wait to see if it is a hold
lastHoldEvent = event;
lastHoldEventTime = [NSDate timeIntervalSinceReferenceDate];
- [self performSelector:@selector(sendSimulatedHoldEvent:)
+ [self performSelector:@selector(sendSimulatedHoldEvent:)
withObject:[NSNumber numberWithDouble:lastHoldEventTime]
afterDelay:HOLD_RECOGNITION_TIME_INTERVAL];
return;
@@ -161,31 +161,31 @@ const NSTimeInterval HOLD_RECOGNITION_TIME_INTERVAL = 0.4;
RemoteControlEventIdentifier previousEvent = lastHoldEvent;
@synchronized(self) {
lastHoldEvent = 0;
- }
-
+ }
+
// in case click counting is enabled we have to setup the state for that, too
if (clickCountingForEvent) {
lastClickCountEvent = previousEvent;
lastClickCountEventTime = lastHoldEventTime;
NSNumber* eventNumber;
- NSNumber* timeNumber;
+ NSNumber* timeNumber;
eventClickCount = 1;
timeNumber = [NSNumber numberWithDouble:lastClickCountEventTime];
eventNumber= [NSNumber numberWithUnsignedInt:previousEvent];
NSTimeInterval diffTime = maxClickTimeDifference-([NSDate timeIntervalSinceReferenceDate]-lastHoldEventTime);
- [self performSelector: @selector(executeClickCountEvent:)
+ [self performSelector: @selector(executeClickCountEvent:)
withObject: [NSArray arrayWithObjects:eventNumber, timeNumber, nil]
- afterDelay: diffTime];
+ afterDelay: diffTime];
// we do not return here because we are still in the press-release event
// that will be consumed below
} else {
// trigger the pressed down event that we consumed first
- [delegate remoteButton:event pressedDown: YES clickCount:1];
+ [delegate remoteButton:event pressedDown: YES clickCount:1];
}
- }
+ }
}
}
-
+
if (clickCountingForEvent) {
if (pressedDown == NO) return;
@@ -202,12 +202,12 @@ const NSTimeInterval HOLD_RECOGNITION_TIME_INTERVAL = 0.4;
timeNumber = [NSNumber numberWithDouble:lastClickCountEventTime];
eventNumber= [NSNumber numberWithUnsignedInt:event];
}
- [self performSelector: @selector(executeClickCountEvent:)
+ [self performSelector: @selector(executeClickCountEvent:)
withObject: [NSArray arrayWithObjects:eventNumber, timeNumber, nil]
afterDelay: maxClickTimeDifference];
} else {
[delegate remoteButton:event pressedDown: pressedDown clickCount:1];
- }
+ }
}
diff --git a/apple_remote/source/RemoteMainController.m b/apple_remote/source/RemoteMainController.m
index c163a387be9c..cccb4b612268 100644
--- a/apple_remote/source/RemoteMainController.m
+++ b/apple_remote/source/RemoteMainController.m
@@ -35,9 +35,9 @@
#import "RemoteControlContainer.h"
#import "MultiClickRemoteBehavior.h"
-// -------------------------------------------------------------------------------------------
+
// Sample Code 3: Multi Click Behavior and Hold Event Simulation
-// -------------------------------------------------------------------------------------------
+
@implementation AppleRemoteMainController