Commit da380a41 authored by Felix Paul Kühne's avatar Felix Paul Kühne

macosx: updated cookie for the 2009 Apple Remote and fixed a minor issue when...

macosx: updated cookie for the 2009 Apple Remote and fixed a minor issue when switching between multiple remotes
parent 302e7eb5
......@@ -32,7 +32,7 @@
* or (at your option) any later version.
* Thus, the following statements apply to our changes:
*
* Copyright (C) 2006-2007 the VideoLAN team
* Copyright (C) 2006-2011 the VideoLAN team
* Authors: Eric Petit <titer@m0k.org>
* Felix Kühne <fkuehne at videolan dot org>
*
......@@ -75,19 +75,21 @@ enum AppleRemoteEventIdentifier
kRemoteButtonVolume_Plus_Hold =1<<12,
kRemoteButtonVolume_Minus_Hold =1<<13,
k2009RemoteButtonPlay =1<<14,
k2009RemoteButtonFullscreen =1<<15
k2009RemoteButtonFullscreen =1<<15,
k2009RemoteButtonSwitched =1<<16
};
typedef enum AppleRemoteEventIdentifier AppleRemoteEventIdentifier;
/* Encapsulates usage of the apple remote control
This class is implemented as a singleton as there is exactly one remote per machine (until now)
The class is not thread safe
*/
This class is implemented as a singleton as there is exactly one remote per machine (until now)
The class is not thread safe
*/
@interface AppleRemote : NSObject {
IOHIDDeviceInterface** hidDeviceInterface;
IOHIDQueueInterface** queue;
NSMutableArray* allCookies;
NSMutableDictionary* cookieToButtonMapping;
NSString* switchCookie;
CFRunLoopSourceRef eventSource;
BOOL openInExclusiveMode;
......@@ -178,6 +180,7 @@ The class is not thread safe
@interface AppleRemote (PrivateMethods)
- (void) setRemoteId: (int) aValue;
- (NSDictionary*) cookieToButtonMapping;
- (NSString *) switchCookie;
- (IOHIDQueueInterface**) queue;
- (IOHIDDeviceInterface**) hidDeviceInterface;
- (void) handleEventWithCookieString: (NSString*) cookieString sumOfValues: (SInt32) sumOfValues;
......
......@@ -32,7 +32,7 @@
* or (at your option) any later version.
* Thus, the following statements apply to our changes:
*
* Copyright (C) 2006-2009 the VideoLAN team
* Copyright (C) 2006-2011 the VideoLAN team
* Authors: Eric Petit <titer@m0k.org>
* Felix Kühne <fkuehne at videolan dot org>
*
......@@ -58,6 +58,7 @@
const char* AppleRemoteDeviceName = "AppleIRController";
const int REMOTE_SWITCH_COOKIE=19;
const int FUTURE_REMOTE_SWITCH_COOKIE=42;
const NSTimeInterval DEFAULT_MAXIMUM_CLICK_TIME_DIFFERENCE=0.35;
const NSTimeInterval HOLD_RECOGNITION_TIME_INTERVAL=0.4;
......@@ -87,6 +88,7 @@ const NSTimeInterval HOLD_RECOGNITION_TIME_INTERVAL=0.4;
[cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonMenu_Hold] forKey:@"31_18_31_18_"];
[cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonPlay_Sleep] forKey:@"35_31_18_35_31_18_"];
[cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteControl_Switched] forKey:@"19_"];
switchCookie = @"19_";
}
else if( NSAppKitVersionNumber >= 1115.2 )
{
......@@ -103,8 +105,10 @@ const NSTimeInterval HOLD_RECOGNITION_TIME_INTERVAL=0.4;
[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:@"42_33_23_21_20_2_33_23_21_20_2_"];
[cookieToButtonMapping setObject:[NSNumber numberWithInt:k2009RemoteButtonSwitched] forKey:@"42_33_21_20_8_2_33_21_20_8_2_"];
[cookieToButtonMapping setObject:[NSNumber numberWithInt:k2009RemoteButtonPlay] forKey:@"33_21_20_8_2_33_21_20_8_2_"];
[cookieToButtonMapping setObject:[NSNumber numberWithInt:k2009RemoteButtonFullscreen] forKey:@"33_21_20_3_2_33_21_20_3_2_"];
switchCookie = @"42_33_23_21_20_2_33_23_21_20_2_";
}
else
{
......@@ -123,6 +127,7 @@ const NSTimeInterval HOLD_RECOGNITION_TIME_INTERVAL=0.4;
[cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteControl_Switched] forKey:@"19_"];
[cookieToButtonMapping setObject:[NSNumber numberWithInt:k2009RemoteButtonPlay] forKey:@"33_21_20_8_2_33_21_20_8_2_"];
[cookieToButtonMapping setObject:[NSNumber numberWithInt:k2009RemoteButtonFullscreen] forKey:@"33_21_20_3_2_33_21_20_3_2_"];
switchCookie = @"19_";
}
}
......@@ -136,6 +141,7 @@ const NSTimeInterval HOLD_RECOGNITION_TIME_INTERVAL=0.4;
- (void) dealloc {
[self stopListening:self];
[cookieToButtonMapping release];
[switchCookie release];
[super dealloc];
}
......@@ -358,6 +364,9 @@ static AppleRemote* sharedInstance=nil;
return hidDeviceInterface;
}
- (NSString *) switchCookie {
return switchCookie;
}
- (NSDictionary*) cookieToButtonMapping {
return cookieToButtonMapping;
......@@ -499,8 +508,8 @@ static AppleRemote* sharedInstance=nil;
@end
/* Callback method for the device queue
Will be called for any event of any type (cookie) to which we subscribe
*/
Will be called for any event of any type (cookie) to which we subscribe
*/
static void QueueCallbackFunction(void* target, IOReturn result, void* refcon, void* sender) {
AppleRemote* remote = (AppleRemote*)target;
......@@ -516,9 +525,9 @@ static void QueueCallbackFunction(void* target, IOReturn result, void* refcon,
//printf("%d %d %d\n", event.elementCookie, event.value, event.longValue);
if (REMOTE_SWITCH_COOKIE == (int)event.elementCookie) {
if (REMOTE_SWITCH_COOKIE == (int)event.elementCookie || FUTURE_REMOTE_SWITCH_COOKIE == (int)event.elementCookie) {
[remote setRemoteId: event.value];
[remote handleEventWithCookieString: @"19_" sumOfValues: 0];
[remote handleEventWithCookieString: [remote switchCookie] sumOfValues: 0];
} else {
if (((int)event.elementCookie)!=5) {
sumOfValues+=event.value;
......
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