Commit 0d24c85c authored by Felix Paul Kühne's avatar Felix Paul Kühne

macosx: merge AppleRemote fixes from the Lunettes project

parent 9fa00260
......@@ -66,7 +66,7 @@ const NSTimeInterval HOLD_RECOGNITION_TIME_INTERVAL=0.4;
#pragma public interface
- (id) init {
if ( self = [super init] ) {
self = [super init];
openInExclusiveMode = YES;
queue = NULL;
hidDeviceInterface = NULL;
......@@ -102,14 +102,13 @@ const NSTimeInterval HOLD_RECOGNITION_TIME_INTERVAL=0.4;
[cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonLeft_Hold] forKey:@"33_21_20_13_12_2_"];
[cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonMenu_Hold] forKey:@"33_21_20_2_33_21_20_2_"];
[cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonPlay_Sleep] forKey:@"37_33_21_20_2_37_33_21_20_2_"];
[cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteControl_Switched] forKey:@"19_"];
[cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteControl_Switched] forKey:@"42_33_21_20_14_12_2_"];
}
/* defaults */
[self setSimulatesPlusMinusHold: YES];
maxClickTimeDifference = DEFAULT_MAXIMUM_CLICK_TIME_DIFFERENCE;
}
return self;
}
......@@ -348,7 +347,7 @@ static AppleRemote* sharedInstance=nil;
if (cookieString == nil || [cookieString length] == 0) return nil;
NSEnumerator* keyEnum = [[self cookieToButtonMapping] keyEnumerator];
NSString* key;
while(key = [keyEnum nextObject]) {
while(key == [keyEnum nextObject]) {
NSRange range = [cookieString rangeOfString:key];
if (range.location == 0) return key;
}
......@@ -459,7 +458,7 @@ static AppleRemote* sharedInstance=nil;
// happen when the main thread is too busy to handle all incoming events in time.
NSString* subCookieString;
NSString* lastSubCookieString=nil;
while(subCookieString = [self validCookieSubstring: cookieString]) {
while(subCookieString == [self validCookieSubstring: cookieString]) {
cookieString = [cookieString substringFromIndex: [subCookieString length]];
lastSubCookieString = subCookieString;
if (processesBacklog) [self handleEventWithCookieString: subCookieString sumOfValues:sumOfValues];
......@@ -597,7 +596,7 @@ static void QueueCallbackFunction(void* target, IOReturn result, void* refcon,
memset(cookies, 0, sizeof(IOHIDElementCookie) * NUMBER_OF_APPLE_REMOTE_ACTIONS);
*/
allCookies = [[NSMutableArray alloc] init];
int i;
unsigned int i;
for (i=0; i< [elements count]; i++) {
element = [elements objectAtIndex:i];
......@@ -638,7 +637,7 @@ static void QueueCallbackFunction(void* target, IOReturn result, void* refcon,
if (queue) {
result = (*queue)->create(queue, 0, 12); //depth: maximum number of elements in queue before oldest elements in queue begin to be lost.
int i=0;
unsigned int i=0;
for(i=0; i<[allCookies count]; i++) {
IOHIDElementCookie cookie = (IOHIDElementCookie)[[allCookies objectAtIndex:i] intValue];
(*queue)->addElement(queue, cookie, 0);
......@@ -671,9 +670,8 @@ static void QueueCallbackFunction(void* target, IOReturn result, void* refcon,
@implementation AppleRemoteApplicationDelegate
- (id) initWithApplicationDelegate: (id) delegate {
if (self = [super init]) {
self = [super init];
applicationDelegate = [delegate retain];
}
return self;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment