summaryrefslogtreecommitdiffstats
path: root/osdep
diff options
context:
space:
mode:
authorMichael Vetter <g.bluehut@gmail.com>2015-05-15 10:34:39 +0200
committerwm4 <wm4@nowhere>2015-05-15 11:02:44 +0200
commit9251fa125f6ebc0f485c93af1809efb7b6da19bd (patch)
tree5c5fb05ef692115083a28cb42718a01447150b1a /osdep
parent24f98d1aaf347119b8b3a48e2736755d82a0f508 (diff)
downloadmpv-9251fa125f6ebc0f485c93af1809efb7b6da19bd.tar.bz2
mpv-9251fa125f6ebc0f485c93af1809efb7b6da19bd.tar.xz
Remove trailing whitespaces
Diffstat (limited to 'osdep')
-rw-r--r--osdep/ar/HIDRemote.h44
-rw-r--r--osdep/ar/HIDRemote.m356
2 files changed, 200 insertions, 200 deletions
diff --git a/osdep/ar/HIDRemote.h b/osdep/ar/HIDRemote.h
index 33f59f322d..9ea01d1fc2 100644
--- a/osdep/ar/HIDRemote.h
+++ b/osdep/ar/HIDRemote.h
@@ -12,21 +12,21 @@
//
// Copyright (c) 2007-2011 IOSPIRIT GmbH (http://www.iospirit.com/)
// All rights reserved.
-//
+//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
-//
+//
// * Redistributions of source code must retain the above copyright notice, this list
// of conditions and the following disclaimer.
-//
+//
// * Redistributions in binary form must reproduce the above copyright notice, this
// list of conditions and the following disclaimer in the documentation and/or other
// materials provided with the distribution.
-//
+//
// * Neither the name of IOSPIRIT GmbH nor the names of its contributors may be used to
// endorse or promote products derived from this software without specific prior
// written permission.
-//
+//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
@@ -166,7 +166,7 @@ typedef enum
newID:(SInt32)newID
forHardwareWithAttributes:(NSMutableDictionary *)attributes;
-// Notification about hardware additions/removals
+// Notification about hardware additions/removals
- (void)hidRemote:(HIDRemote *)hidRemote // Invoked when new hardware was found / added to HIDRemote's pool
foundNewHardwareWithAttributes:(NSMutableDictionary *)attributes;
@@ -180,7 +180,7 @@ typedef enum
// Matching of newly found receiver hardware
- (BOOL)hidRemote:(HIDRemote *)hidRemote // Invoked when new hardware is inspected
- inspectNewHardwareWithService:(io_service_t)service //
+ inspectNewHardwareWithService:(io_service_t)service //
prematchResult:(BOOL)prematchResult; // Return YES if HIDRemote should go on with this hardware and try
// to use it, or NO if it should not be persued further.
@@ -194,7 +194,7 @@ typedef enum
- (BOOL)hidRemote:(HIDRemote *)hidRemote
shouldRetryExclusiveLockWithInfo:(NSDictionary *)applicationInfo;
-@end
+@end
#pragma mark -- Actual header file for class --
@@ -207,55 +207,55 @@ typedef enum
// Notification ports
IONotificationPortRef _notifyPort;
CFRunLoopSourceRef _notifyRLSource;
-
+
// Matching iterator
io_iterator_t _matchingServicesIterator;
-
+
// SecureInput notification
io_object_t _secureInputNotification;
-
+
// Service attributes
NSMutableDictionary *_serviceAttribMap;
-
+
// Mode
HIDRemoteMode _mode;
BOOL _autoRecover;
NSTimer *_autoRecoveryTimer;
-
+
// Delegate
NSObject <HIDRemoteDelegate> *_delegate;
-
+
// Last seen ID and remote model
SInt32 _lastSeenRemoteID;
HIDRemoteModel _lastSeenModel;
SInt32 _lastSeenModelRemoteID;
-
+
// Unused button codes
NSArray *_unusedButtonCodes;
-
+
// Simulate Plus/Minus Hold
BOOL _simulateHoldEvents;
-
+
// SecureEventInput workaround
BOOL _secureEventInputWorkAround;
UInt64 _lastSecureEventInputPIDSum;
uid_t _lastFrontUserSession;
-
+
// Exclusive lock lending
BOOL _exclusiveLockLending;
BOOL _sendExclusiveResourceReuseNotification;
NSNumber *_waitForReturnByPID;
NSNumber *_returnToPID;
BOOL _isRestarting;
-
+
// Status notifications
BOOL _sendStatusNotifications;
NSString *_pidString;
-
+
// Status
BOOL _applicationIsTerminating;
BOOL _isStopping;
-
+
// Thread safety
#ifdef HIDREMOTE_THREADSAFETY_HARDENED_NOTIFICATION_HANDLING /* #define HIDREMOTE_THREADSAFETY_HARDENED_NOTIFICATION_HANDLING if you're running your HIDRemote instance on a background thread (requires OS X 10.5 or later) */
NSThread *_runOnThread;
@@ -271,7 +271,7 @@ typedef enum
- (HIDRemoteAluminumRemoteSupportLevel)aluminiumRemoteSystemSupportLevel;
#pragma mark -- PUBLIC: Interface / API --
-- (BOOL)startRemoteControl:(HIDRemoteMode)hidRemoteMode;
+- (BOOL)startRemoteControl:(HIDRemoteMode)hidRemoteMode;
- (void)stopRemoteControl;
- (BOOL)isStarted;
diff --git a/osdep/ar/HIDRemote.m b/osdep/ar/HIDRemote.m
index 977b9cbdb9..f62289e23c 100644
--- a/osdep/ar/HIDRemote.m
+++ b/osdep/ar/HIDRemote.m
@@ -12,21 +12,21 @@
//
// Copyright (c) 2007-2011 IOSPIRIT GmbH (http://www.iospirit.com/)
// All rights reserved.
-//
+//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
-//
+//
// * Redistributions of source code must retain the above copyright notice, this list
// of conditions and the following disclaimer.
-//
+//
// * Redistributions in binary form must reproduce the above copyright notice, this
// list of conditions and the following disclaimer in the documentation and/or other
// materials provided with the distribution.
-//
+//
// * Neither the name of IOSPIRIT GmbH nor the names of its contributors may be used to
// endorse or promote products derived from this software without specific prior
// written permission.
-//
+//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
@@ -52,7 +52,7 @@
#import "HIDRemote.h"
// Callback Prototypes
-static void HIDEventCallback( void * target,
+static void HIDEventCallback( void * target,
IOReturn result,
void * refcon,
void * sender);
@@ -83,7 +83,7 @@ static HIDRemote *sHIDRemote = nil;
{
sHIDRemote = [[HIDRemote alloc] init];
}
-
+
return (sHIDRemote);
}
@@ -94,7 +94,7 @@ static HIDRemote *sHIDRemote = nil;
#ifdef HIDREMOTE_THREADSAFETY_HARDENED_NOTIFICATION_HANDLING
_runOnThread = [[NSThread currentThread] retain];
#endif
-
+
// Detect application becoming active/inactive
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_appStatusChanged:) name:NSApplicationDidBecomeActiveNotification object:NSApp];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_appStatusChanged:) name:NSApplicationWillResignActiveNotification object:NSApp];
@@ -102,18 +102,18 @@ static HIDRemote *sHIDRemote = nil;
// Handle distributed notifications
_pidString = [[NSString alloc] initWithFormat:@"%d", getpid()];
-
+
[[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(_handleNotifications:) name:kHIDRemoteDNHIDRemotePing object:nil];
[[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(_handleNotifications:) name:kHIDRemoteDNHIDRemoteRetry object:kHIDRemoteDNHIDRemoteRetryGlobalObject];
[[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(_handleNotifications:) name:kHIDRemoteDNHIDRemoteRetry object:_pidString];
// Enabled by default: simulate hold events for plus/minus
_simulateHoldEvents = YES;
-
+
// Enabled by default: work around for a locking issue introduced with Security Update 2008-004 / 10.4.9 and beyond (credit for finding this workaround goes to Martin Kahr)
_secureEventInputWorkAround = YES;
_secureInputNotification = 0;
-
+
// Initialize instance variables
_lastSeenRemoteID = -1;
_lastSeenModel = kHIDRemoteModelUndetermined;
@@ -121,7 +121,7 @@ static HIDRemote *sHIDRemote = nil;
_exclusiveLockLending = NO;
_sendExclusiveResourceReuseNotification = YES;
_applicationIsTerminating = NO;
-
+
// Send status notifications
_sendStatusNotifications = YES;
}
@@ -139,7 +139,7 @@ static HIDRemote *sHIDRemote = nil;
[[NSDistributedNotificationCenter defaultCenter] removeObserver:self name:kHIDRemoteDNHIDRemoteRetry object:kHIDRemoteDNHIDRemoteRetryGlobalObject];
[[NSDistributedNotificationCenter defaultCenter] removeObserver:self name:kHIDRemoteDNHIDRemoteRetry object:_pidString];
[[NSDistributedNotificationCenter defaultCenter] removeObserver:self name:nil object:nil]; /* As demanded by the documentation for -[NSDistributedNotificationCenter removeObserver:name:object:] */
-
+
[self stopRemoteControl];
[self setExclusiveLockLendingEnabled:NO];
@@ -195,13 +195,13 @@ static HIDRemote *sHIDRemote = nil;
HIDRemoteAluminumRemoteSupportLevel supportLevel = kHIDRemoteAluminumRemoteSupportLevelNone;
NSEnumerator *attribDictsEnum;
NSDictionary *hidAttribsDict;
-
+
attribDictsEnum = [_serviceAttribMap objectEnumerator];
-
+
while ((hidAttribsDict = [attribDictsEnum nextObject]) != nil)
{
NSNumber *deviceSupportLevel;
-
+
if ((deviceSupportLevel = [hidAttribsDict objectForKey:kHIDRemoteAluminumRemoteSupportLevel]) != nil)
{
if ([deviceSupportLevel intValue] > (int)supportLevel)
@@ -210,7 +210,7 @@ static HIDRemote *sHIDRemote = nil;
}
}
}
-
+
return (supportLevel);
}
@@ -222,16 +222,16 @@ static HIDRemote *sHIDRemote = nil;
kern_return_t kernReturn;
CFMutableDictionaryRef matchDict=NULL;
io_service_t rootService;
-
+
do
{
// Get IOKit master port
kernReturn = IOMasterPort(bootstrap_port, &_masterPort);
if ((kernReturn!=kIOReturnSuccess) || (_masterPort==0)) { break; }
-
+
// Setup notification port
_notifyPort = IONotificationPortCreate(_masterPort);
-
+
if ((_notifyRLSource = IONotificationPortGetRunLoopSource(_notifyPort)) != NULL)
{
CFRunLoopAddSource( CFRunLoopGetCurrent(),
@@ -242,7 +242,7 @@ static HIDRemote *sHIDRemote = nil;
{
break;
}
-
+
// Setup SecureInput notification
if ((hidRemoteMode == kHIDRemoteModeExclusive) || (hidRemoteMode == kHIDRemoteModeExclusiveAuto))
{
@@ -255,7 +255,7 @@ static HIDRemote *sHIDRemote = nil;
(void *)self,
&_secureInputNotification);
if (kernReturn != kIOReturnSuccess) { break; }
-
+
[self _updateSessionInformation];
}
else
@@ -277,32 +277,32 @@ static HIDRemote *sHIDRemote = nil;
&_matchingServicesIterator);
if (kernReturn != kIOReturnSuccess) { break; }
- // Setup serviceAttribMap
+ // Setup serviceAttribMap
_serviceAttribMap = [[NSMutableDictionary alloc] init];
if (_serviceAttribMap==nil) { break; }
-
+
// Phew .. everything went well!
_mode = hidRemoteMode;
CFRelease(matchDict);
-
+
[self _serviceMatching:_matchingServicesIterator];
-
+
[self _postStatusWithAction:kHIDRemoteDNStatusActionStart];
-
+
return (YES);
}while(0);
-
+
// An error occured. Do necessary clean up.
if (matchDict!=NULL)
{
CFRelease(matchDict);
matchDict = NULL;
}
-
+
[self stopRemoteControl];
}
-
+
return (NO);
}
@@ -312,7 +312,7 @@ static HIDRemote *sHIDRemote = nil;
_autoRecover = NO;
_isStopping = YES;
-
+
if (_autoRecoveryTimer!=nil)
{
[_autoRecoveryTimer invalidate];
@@ -323,22 +323,22 @@ static HIDRemote *sHIDRemote = nil;
if (_serviceAttribMap!=nil)
{
NSDictionary *cloneDict = [[NSDictionary alloc] initWithDictionary:_serviceAttribMap];
-
+
if (cloneDict!=nil)
{
NSEnumerator *mapKeyEnum = [cloneDict keyEnumerator];
NSNumber *serviceValue;
-
+
while ((serviceValue = [mapKeyEnum nextObject]) != nil)
{
[self _destructService:(io_object_t)[serviceValue unsignedIntValue]];
serviceCount++;
};
-
+
[cloneDict release];
cloneDict = nil;
}
-
+
[_serviceAttribMap release];
_serviceAttribMap = nil;
}
@@ -348,7 +348,7 @@ static HIDRemote *sHIDRemote = nil;
IOObjectRelease((io_object_t) _matchingServicesIterator);
_matchingServicesIterator = 0;
}
-
+
if (_secureInputNotification!=0)
{
IOObjectRelease((io_object_t) _secureInputNotification);
@@ -390,7 +390,7 @@ static HIDRemote *sHIDRemote = nil;
if (((_mode==kHIDRemoteModeExclusive) || (_mode==kHIDRemoteModeExclusiveAuto)) && (_sendExclusiveResourceReuseNotification==YES) && (_exclusiveLockLending==NO) && (serviceCount>0))
{
_mode = kHIDRemoteModeNone;
-
+
if (!_isRestarting)
{
[[NSDistributedNotificationCenter defaultCenter] postNotificationName:kHIDRemoteDNHIDRemoteRetry
@@ -404,7 +404,7 @@ static HIDRemote *sHIDRemote = nil;
}
}
}
-
+
_mode = kHIDRemoteModeNone;
_isStopping = NO;
}
@@ -458,7 +458,7 @@ static HIDRemote *sHIDRemote = nil;
{
[newArrayWithUnusedButtonCodesAsNSNumbers retain];
[_unusedButtonCodes release];
-
+
_unusedButtonCodes = newArrayWithUnusedButtonCodesAsNSNumbers;
[self _postStatusWithAction:kHIDRemoteDNStatusActionUpdate];
@@ -490,7 +490,7 @@ static HIDRemote *sHIDRemote = nil;
if (newExclusiveLockLendingEnabled != _exclusiveLockLending)
{
_exclusiveLockLending = newExclusiveLockLendingEnabled;
-
+
if (_exclusiveLockLending)
{
[[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(_handleNotifications:) name:kHIDRemoteDNHIDRemoteStatus object:nil];
@@ -498,7 +498,7 @@ static HIDRemote *sHIDRemote = nil;
else
{
[[NSDistributedNotificationCenter defaultCenter] removeObserver:self name:kHIDRemoteDNHIDRemoteStatus object:nil];
-
+
[_waitForReturnByPID release];
_waitForReturnByPID = nil;
}
@@ -545,7 +545,7 @@ static HIDRemote *sHIDRemote = nil;
return;
}
}
-
+
if ([[notification name] isEqual:NSApplicationWillResignActiveNotification])
{
if (_mode != kHIDRemoteModeExclusiveAuto)
@@ -553,7 +553,7 @@ static HIDRemote *sHIDRemote = nil;
return;
}
}
-
+
[self performSelector:@selector(_appStatusChanged:) onThread:_runOnThread withObject:notification waitUntilDone:[[notification name] isEqual:NSApplicationWillTerminateNotification]];
return;
}
@@ -592,11 +592,11 @@ static HIDRemote *sHIDRemote = nil;
_autoRecover = YES;
}
}
-
+
if ([[notification name] isEqual:NSApplicationWillTerminateNotification])
{
_applicationIsTerminating = YES;
-
+
if ([self isStarted])
{
[self stopRemoteControl];
@@ -668,7 +668,7 @@ static HIDRemote *sHIDRemote = nil;
if ([self isStarted])
{
BOOL retry = YES;
-
+
// Ignore our own global retry broadcasts
if ([[notification object] isEqual:kHIDRemoteDNHIDRemoteRetryGlobalObject])
{
@@ -682,7 +682,7 @@ static HIDRemote *sHIDRemote = nil;
}
}
}
-
+
if (retry)
{
if (([self delegate] != nil) &&
@@ -691,22 +691,22 @@ static HIDRemote *sHIDRemote = nil;
retry = [[self delegate] hidRemote:self shouldRetryExclusiveLockWithInfo:[notification userInfo]];
}
}
-
+
if (retry)
{
HIDRemoteMode restartInMode = _mode;
-
+
if (restartInMode != kHIDRemoteModeNone)
{
_isRestarting = YES;
[self stopRemoteControl];
-
+
[_returnToPID release];
_returnToPID = nil;
-
+
[self startRemoteControl:restartInMode];
_isRestarting = NO;
-
+
if (restartInMode != kHIDRemoteModeShared)
{
_returnToPID = [[[notification userInfo] objectForKey:kHIDRemoteDNStatusPIDKey] retain];
@@ -720,18 +720,18 @@ static HIDRemote *sHIDRemote = nil;
_returnToPID = [[[notification userInfo] objectForKey:kHIDRemoteDNStatusPIDKey] retain];
[self _postStatusWithAction:kHIDRemoteDNStatusActionNoNeed];
[_returnToPID release];
-
+
_returnToPID = cacheReturnPID;
}
}
}
-
+
if (_exclusiveLockLending)
{
if ([notificationName isEqual:kHIDRemoteDNHIDRemoteStatus])
{
NSString *action;
-
+
if ((action = [[notification userInfo] objectForKey:kHIDRemoteDNStatusActionKey]) != nil)
{
if ((_mode == kHIDRemoteModeNone) && (_waitForReturnByPID!=nil))
@@ -741,13 +741,13 @@ static HIDRemote *sHIDRemote = nil;
if ((pidNumber = [[notification userInfo] objectForKey:kHIDRemoteDNStatusPIDKey]) != nil)
{
returnToPIDNumber = [[notification userInfo] objectForKey:kHIDRemoteDNStatusReturnToPIDKey];
-
+
if ([action isEqual:kHIDRemoteDNStatusActionStart])
{
if ([pidNumber isEqual:_waitForReturnByPID])
{
NSNumber *startMode;
-
+
if ((startMode = [[notification userInfo] objectForKey:kHIDRemoteDNStatusModeKey]) != nil)
{
if ([startMode intValue] == kHIDRemoteModeShared)
@@ -767,7 +767,7 @@ static HIDRemote *sHIDRemote = nil;
{
[_waitForReturnByPID release];
_waitForReturnByPID = nil;
-
+
if (([self delegate] != nil) &&
([[self delegate] respondsToSelector:@selector(hidRemote:exclusiveLockReleasedByApplicationWithInfo:)]))
{
@@ -789,7 +789,7 @@ static HIDRemote *sHIDRemote = nil;
{
NSNumber *originPID = [[notification userInfo] objectForKey:kHIDRemoteDNStatusPIDKey];
BOOL lendLock = YES;
-
+
if ([originPID intValue] != getpid())
{
if (([self delegate] != nil) &&
@@ -797,16 +797,16 @@ static HIDRemote *sHIDRemote = nil;
{
lendLock = [[self delegate] hidRemote:self lendExclusiveLockToApplicationWithInfo:[notification userInfo]];
}
-
+
if (lendLock)
{
[_waitForReturnByPID release];
_waitForReturnByPID = [originPID retain];
-
+
if (_waitForReturnByPID != nil)
{
[self stopRemoteControl];
-
+
[[NSDistributedNotificationCenter defaultCenter] postNotificationName:kHIDRemoteDNHIDRemoteRetry
object:[NSString stringWithFormat:@"%d", [_waitForReturnByPID intValue]]
userInfo:[NSDictionary dictionaryWithObjectsAndKeys:
@@ -841,7 +841,7 @@ static HIDRemote *sHIDRemote = nil;
BOOL serviceMatches = NO;
NSString *ioClass;
NSNumber *candelairHIDRemoteCompatibilityMask;
-
+
if (service != 0)
{
// IOClass matching
@@ -856,14 +856,14 @@ static HIDRemote *sHIDRemote = nil;
CFTypeRef candelairHIDRemoteCompatibilityDevice;
serviceMatches = YES;
-
+
if ((candelairHIDRemoteCompatibilityDevice = IORegistryEntryCreateCFProperty((io_registry_entry_t)service, CFSTR("CandelairHIDRemoteCompatibilityDevice"), kCFAllocatorDefault, 0)) != NULL)
{
if (CFEqual(kCFBooleanTrue, candelairHIDRemoteCompatibilityDevice))
{
serviceMatches = NO;
}
-
+
CFRelease (candelairHIDRemoteCompatibilityDevice);
}
}
@@ -873,7 +873,7 @@ static HIDRemote *sHIDRemote = nil;
{
serviceMatches = YES;
}
-
+
CFRelease((CFTypeRef)ioClass);
}
@@ -891,7 +891,7 @@ static HIDRemote *sHIDRemote = nil;
serviceMatches = NO;
}
}
-
+
CFRelease((CFTypeRef)candelairHIDRemoteCompatibilityMask);
}
}
@@ -901,7 +901,7 @@ static HIDRemote *sHIDRemote = nil;
{
serviceMatches = [((NSObject <HIDRemoteDelegate> *)[self delegate]) hidRemote:self inspectNewHardwareWithService:service prematchResult:serviceMatches];
}
-
+
return (serviceMatches);
}
@@ -918,7 +918,7 @@ static HIDRemote *sHIDRemote = nil;
// Aluminum Remote: Center
buttonCode = (kHIDRemoteButtonCodeCenter|kHIDRemoteButtonCodeAluminumMask);
break;
-
+
case kHIDUsage_Csmr_ModeStep:
// Aluminium Remote: Center Hold
buttonCode = (kHIDRemoteButtonCodeCenterHold|kHIDRemoteButtonCodeAluminumMask);
@@ -928,11 +928,11 @@ static HIDRemote *sHIDRemote = nil;
// Aluminum Remote: Play/Pause
buttonCode = (kHIDRemoteButtonCodePlay|kHIDRemoteButtonCodeAluminumMask);
break;
-
+
case kHIDUsage_Csmr_Rewind:
buttonCode = kHIDRemoteButtonCodeLeftHold;
break;
-
+
case kHIDUsage_Csmr_FastForward:
buttonCode = kHIDRemoteButtonCodeRightHold;
break;
@@ -942,7 +942,7 @@ static HIDRemote *sHIDRemote = nil;
break;
}
break;
-
+
case kHIDPage_GenericDesktop:
switch (usage)
{
@@ -971,7 +971,7 @@ static HIDRemote *sHIDRemote = nil;
break;
}
break;
-
+
case 0x06: /* Reserved */
switch (usage)
{
@@ -980,7 +980,7 @@ static HIDRemote *sHIDRemote = nil;
break;
}
break;
-
+
case 0xFF01: /* Vendor specific */
switch (usage)
{
@@ -996,7 +996,7 @@ static HIDRemote *sHIDRemote = nil;
}
break;
}
-
+
return (buttonCode);
}
@@ -1030,52 +1030,52 @@ static HIDRemote *sHIDRemote = nil;
kIOCFPlugInInterfaceID,
&cfPluginInterface,
&score);
-
+
if (kernResult != kIOReturnSuccess)
{
error = [NSError errorWithDomain:NSMachErrorDomain code:kernResult userInfo:nil];
errorCode = 1;
- break;
+ break;
}
-
+
// .. use it to get the HID interface ..
- hResult = (*cfPluginInterface)->QueryInterface( cfPluginInterface,
+ hResult = (*cfPluginInterface)->QueryInterface( cfPluginInterface,
CFUUIDGetUUIDBytes(kIOHIDDeviceInterfaceID122),
(LPVOID)&hidDeviceInterface);
-
+
if ((hResult!=S_OK) || (hidDeviceInterface==NULL))
{
error = [NSError errorWithDomain:NSMachErrorDomain code:hResult userInfo:nil];
errorCode = 2;
- break;
+ break;
}
-
+
// .. then open it ..
switch (_mode)
{
case kHIDRemoteModeShared:
hResult = (*hidDeviceInterface)->open(hidDeviceInterface, kIOHIDOptionsTypeNone);
break;
-
+
case kHIDRemoteModeExclusive:
case kHIDRemoteModeExclusiveAuto:
hResult = (*hidDeviceInterface)->open(hidDeviceInterface, kIOHIDOptionsTypeSeizeDevice);
break;
-
+
default:
goto cleanUp; // Ugh! But there are no "double breaks" available in C AFAIK ..
break;
}
-
+
if (hResult!=S_OK)
{
error = [NSError errorWithDomain:NSMachErrorDomain code:hResult userInfo:nil];
errorCode = 3;
break;
}
-
+
opened = YES;
// .. query the HID elements ..
@@ -1086,7 +1086,7 @@ static HIDRemote *sHIDRemote = nil;
{
error = [NSError errorWithDomain:NSMachErrorDomain code:returnCode userInfo:nil];
errorCode = 4;
-
+
break;
}
@@ -1121,7 +1121,7 @@ static HIDRemote *sHIDRemote = nil;
UInt32 i, hidElementCnt = CFArrayGetCount(hidElements);
NSMutableDictionary *cookieButtonCodeLUT = [[NSMutableDictionary alloc] init];
NSMutableDictionary *cookieCount = [[NSMutableDictionary alloc] init];
-
+
if ((cookieButtonCodeLUT==nil) || (cookieCount==nil))
{
[cookieButtonCodeLUT release];
@@ -1135,20 +1135,20 @@ static HIDRemote *sHIDRemote = nil;
break;
}
-
+
// Analyze the HID elements and find matching elements
for (i=0;i<hidElementCnt;i++)
{
CFDictionaryRef hidDict;
NSNumber *usage, *usagePage, *cookie;
HIDRemoteButtonCode buttonCode = kHIDRemoteButtonCodeNone;
-
+
hidDict = CFArrayGetValueAtIndex(hidElements, i);
-
+
usage = (NSNumber *) CFDictionaryGetValue(hidDict, CFSTR(kIOHIDElementUsageKey));
usagePage = (NSNumber *) CFDictionaryGetValue(hidDict, CFSTR(kIOHIDElementUsagePageKey));
cookie = (NSNumber *) CFDictionaryGetValue(hidDict, CFSTR(kIOHIDElementCookieKey));
-
+
if ((usage!=nil) && (usagePage!=nil) && (cookie!=nil))
{
// Find the button codes for the ID combos
@@ -1160,23 +1160,23 @@ static HIDRemote *sHIDRemote = nil;
#include "HIDRemoteAdditions.h"
#undef _HIDREMOTE_EXTENSIONS_SECTION
#endif /* _HIDREMOTE_EXTENSIONS */
-
+
// Did record match?
if (buttonCode != kHIDRemoteButtonCodeNone)
{
NSString *pairString = [[NSString alloc] initWithFormat:@"%u_%u", [usagePage unsignedIntValue], [usage unsignedIntValue]];
NSNumber *buttonCodeNumber = [[NSNumber alloc] initWithUnsignedInt:(unsigned int)buttonCode];
-
+
#ifdef _HIDREMOTE_EXTENSIONS
// Debug logging code
#define _HIDREMOTE_EXTENSIONS_SECTION 4
#include "HIDRemoteAdditions.h"
#undef _HIDREMOTE_EXTENSIONS_SECTION
#endif /* _HIDREMOTE_EXTENSIONS */
-
+
[cookieCount setObject:buttonCodeNumber forKey:pairString];
[cookieButtonCodeLUT setObject:buttonCodeNumber forKey:cookie];
-
+