Permalink
Browse files

Now supports Snow Leopard.

  • Loading branch information...
bastos authored and mattetti committed Sep 8, 2010
1 parent f402c47 commit c9aed3df0ad43dc9d0e3b2c97af65b6b81ee0259
Showing with 25 additions and 8 deletions.
  1. +25 −8 AppleRemote.m
View
@@ -35,9 +35,13 @@
const char* AppleRemoteDeviceName = "AppleIRController";
-// the WWDC 07 Leopard Build is missing the constant
+ // the WWDC 07 Leopard Build is missing the constant
#ifndef NSAppKitVersionNumber10_4
- #define NSAppKitVersionNumber10_4 824
+#define NSAppKitVersionNumber10_4 824
+#endif
+
+#ifndef NSAppKitVersionNumber10_5_3
+#define NSAppKitVersionNumber10_5_3 949.33
#endif
@implementation AppleRemote
@@ -48,7 +52,7 @@ + (const char*) remoteControlDeviceName {
- (void) setCookieMappingInDictionary: (NSMutableDictionary*) _cookieToButtonMapping {
if (floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_4) {
- // 10.4.x Tiger
+ // 10.4.x Tiger
[_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonPlus] forKey:@"14_12_11_6_"];
[_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonMinus] forKey:@"14_13_11_6_"];
[_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonMenu] forKey:@"14_7_6_14_7_6_"];
@@ -60,8 +64,8 @@ - (void) setCookieMappingInDictionary: (NSMutableDictionary*) _cookieToButtonMap
[_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonMenu_Hold] forKey:@"14_6_14_6_"];
[_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonPlay_Hold] forKey:@"18_14_6_18_14_6_"];
[_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteControl_Switched] forKey:@"19_"];
- } else {
- // 10.5.x Leopard
+ } else if (floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_5_3) {
+ // 10.5.x Leopard
[_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonPlus] forKey:@"31_29_28_19_18_"];
[_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonMinus] forKey:@"31_30_28_19_18_"];
[_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonMenu] forKey:@"31_20_19_18_31_20_19_18_"];
@@ -73,19 +77,32 @@ - (void) setCookieMappingInDictionary: (NSMutableDictionary*) _cookieToButtonMap
[_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonMenu_Hold] forKey:@"31_19_18_31_19_18_"];
[_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonPlay_Hold] forKey:@"35_31_19_18_35_31_19_18_"];
[_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteControl_Switched] forKey:@"19_"];
- }
+ } else {
+ // 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: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_"];
+ [_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonLeft] forKey:@"33_25_21_20_2_33_25_21_20_2_"];
+ [_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonRight_Hold] forKey:@"33_21_20_14_12_2_"];
+ [_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_Hold] forKey:@"37_33_21_20_2_37_33_21_20_2_"];
+ [_cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteControl_Switched] forKey:@"19_"];
+ }
}
- (void) sendRemoteButtonEvent: (RemoteControlEventIdentifier) event pressedDown: (BOOL) pressedDown {
if (pressedDown == NO && event == kRemoteButtonMenu_Hold) {
- // There is no seperate event for pressed down on menu hold. We are simulating that event here
+ // There is no seperate 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 seperate event when the button is being released. We are simulating that event here
+ // There is no seperate event when the button is being released. We are simulating that event here
[super sendRemoteButtonEvent:event pressedDown:NO];
}
}

0 comments on commit c9aed3d

Please sign in to comment.