Changeset 5460

Show
Ignore:
Timestamp:
04/17/08 21:17:32 (1 month ago)
Author:
morris
Message:

Add support for PlayStation? 3 Bluetooth remote

Change how Apple Remote works a bit

Add indicators in preferences when remotes are enabled

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • Spiral/trunk/English.lproj/Preferences.nib/classes.nib

    r5139 r5460  
    3131                        <key>OUTLETS</key> 
    3232                        <dict> 
     33                                <key>_PS3RemoteImageView</key> 
     34                                <string>NSImageView</string> 
     35                                <key>_PS3RemoteProgressIndicator</key> 
     36                                <string>NSProgressIndicator</string> 
     37                                <key>_PS3RemoteTextField</key> 
     38                                <string>NSTextField</string> 
    3339                                <key>_checkForUpdateButton</key> 
    3440                                <string>NSButton</string> 
  • Spiral/trunk/English.lproj/Preferences.nib/info.nib

    r5139 r5460  
    55        <key>IBFramework Version</key> 
    66        <string>629</string> 
     7        <key>IBLastKnownRelativeProjectPath</key> 
     8        <string>../../Spiral.xcodeproj</string> 
    79        <key>IBOldestOS</key> 
    810        <integer>5</integer> 
     
    1214        </array> 
    1315        <key>IBSystem Version</key> 
    14         <string>9B18</string> 
     16        <string>9C7010</string> 
    1517        <key>targetFramework</key> 
    1618        <string>IBCocoaFramework</string> 
  • Spiral/trunk/SPAppleRemote.h

    r5118 r5460  
    6060#import <IOKit/hid/IOHIDKeys.h> 
    6161 
    62 enum _SPAppleRemoteEventIdentifier
     62enum _SPAppleRemoteButton
    6363        SPAppleRemoteButtonVolumePlus                           = 1 << 1, 
    6464        SPAppleRemoteButtonVolumeMinus                          = 1 << 2, 
     
    7171        SPAppleRemoteButtonMenuHold                                     = 1 << 9, 
    7272        SPAppleRemoteButtonPlaySleep                            = 1 << 10, 
    73         SPAppleRemoteControlSwitched                            = 1 << 11, 
    74         SPAppleRemoteButtonVolumePlusHold                       = 1 << 12, 
    75         SPAppleRemoteButtonVolumeMinusHold                      = 1 << 13 
     73        SPAppleRemoteControlSwitched                            = 1 << 11 
    7674}; 
    77 typedef enum _SPAppleRemoteEventIdentifier             SPAppleRemoteEventIdentifier
     75typedef enum _SPAppleRemoteButton                              SPAppleRemoteButton
    7876 
    7977 
     
    9088        NSMutableArray                                                          *_allCookies; 
    9189         
    92         SPAppleRemoteEventIdentifier                            _lastPlusMinusEvent; 
    93         BOOL                                                                            _lastEventSimulatedHold; 
    94         NSTimeInterval                                                          _lastPlusMinusEventTime; 
     90        SPAppleRemoteButton                                                     _lastHoldButton; 
     91        NSTimeInterval                                                          _lastHoldButtonTime; 
     92        BOOL                                                                            _lastButtonSimulatedHold; 
     93         
     94        BOOL                                                                            _delegateAppleRemotePressedButtonDown; 
     95        BOOL                                                                            _delegateAppleRemoteHeldButton; 
    9596} 
    9697 
     
    111112@optional 
    112113 
    113 - (void)appleRemoteButton:(SPAppleRemoteEventIdentifier)buttonIdentifier pressedDown:(BOOL)pressedDown; 
     114- (void)appleRemotePressedButton:(SPAppleRemoteButton)button down:(BOOL)down; 
     115- (void)appleRemoteHeldButton:(SPAppleRemoteButton)button; 
    114116 
    115117@end 
  • Spiral/trunk/SPAppleRemote.m

    r5099 r5460  
    6565- (BOOL)_openDevice; 
    6666- (IOHIDQueueInterface **)_queue; 
    67 - (void)_handleEventWithCookieString:(NSString *)string sum:(SInt32)sum;  
     67- (void)_handleButtonWithCookieString:(NSString *)string sum:(SInt32)sum;  
    6868- (NSString*)_validCookieSubstring:(NSString *)cookieString; 
    6969 
     
    242242 
    243243 
    244 - (void)_handleEventWithCookieString:(NSString *)string sum:(SInt32)sum { 
    245         NSNumber                                                *button; 
    246         NSString                                                *substring, *lastSubstring; 
    247         SPAppleRemoteEventIdentifier    event; 
    248         BOOL                                                    pressedDown; 
     244- (void)_handleButtonWithCookieString:(NSString *)string sum:(SInt32)sum { 
     245        NSString                                *substring, *lastSubstring; 
     246        SPAppleRemoteButton             button; 
     247        BOOL                                    pressedDown, held; 
    249248         
    250249        if([string length] == 0) 
    251250                return; 
    252251         
    253         button = [_buttonsByCookie objectForKey:string]; 
    254  
    255         if(button) { 
    256                 event = [button intValue]; 
     252        button = [[_buttonsByCookie objectForKey:string] intValue]; 
     253 
     254        if(button != 0) { 
    257255                pressedDown = (sum > 0); 
    258                  
    259                 if(event == SPAppleRemoteButtonVolumeMinus || event == SPAppleRemoteButtonVolumePlus) { 
     256                held = NO; 
     257                 
     258                if(button == SPAppleRemoteButtonVolumeMinus || button == SPAppleRemoteButtonVolumePlus) { 
    260259                        if(pressedDown) { 
    261                                 _lastPlusMinusEvent = event
    262                                 _lastPlusMinusEventTime = [NSDate timeIntervalSinceReferenceDate]; 
     260                                _lastHoldButton = button
     261                                _lastHoldButtonTime = [NSDate timeIntervalSinceReferenceDate]; 
    263262                                 
    264                                 [self performSelector:@selector(_handleSimulatedPlusMinusEvent:)  
    265                                                    withObject:[NSNumber numberWithDouble:_lastPlusMinusEventTime] 
     263                                [self performSelector:@selector(_handleSimulatedHoldButton:)  
     264                                                   withObject:[NSNumber numberWithDouble:_lastHoldButtonTime] 
    266265                                                   afterDelay:0.3]; 
    267                                 return; 
     266                                 
     267                                held = YES; 
    268268                        } else { 
    269                                 if(_lastEventSimulatedHold) { 
    270                                         event = (event == SPAppleRemoteButtonVolumeMinus) 
    271                                                 ? SPAppleRemoteButtonVolumeMinusHold 
    272                                                 : SPAppleRemoteButtonVolumePlusHold; 
    273                                          
    274                                         _lastPlusMinusEvent = 0; 
    275                                         _lastEventSimulatedHold = NO; 
     269                                if(_lastButtonSimulatedHold) { 
     270                                        _lastHoldButton = 0; 
     271                                        _lastButtonSimulatedHold = NO; 
    276272                                } else { 
     273                                        _lastHoldButton = 0; 
     274 
    277275                                        pressedDown = YES; 
    278  
    279                                         _lastPlusMinusEvent = 0; 
    280276                                } 
    281277                        } 
    282278                } 
    283279 
    284                 [delegate appleRemoteButton:event pressedDown:pressedDown]; 
     280                if(!held) { 
     281                        if(_delegateAppleRemotePressedButtonDown) 
     282                                [delegate appleRemotePressedButton:button down:pressedDown]; 
     283                } 
    285284        } else { 
    286285                lastSubstring = NULL; 
     
    292291                 
    293292                if(lastSubstring) 
    294                         [self _handleEventWithCookieString:lastSubstring sum:0]; 
     293                        [self _handleButtonWithCookieString:lastSubstring sum:0]; 
    295294 
    296295                if([string length] > 0) 
    297                         NSLog(@"*** _handleEventWithCookieString:sum:: unknown button for cookie string '%@'", string); 
    298         } 
    299 
    300  
    301  
    302  
    303 - (void)_handleSimulatedPlusMinusEvent:(id)time { 
    304         SPAppleRemoteEventIdentifier            event; 
    305  
    306         if(_lastPlusMinusEvent > 0 && _lastPlusMinusEventTime == [time doubleValue]) { 
    307                 _lastEventSimulatedHold = YES; 
    308  
    309                 event = (_lastPlusMinusEvent == SPAppleRemoteButtonVolumeMinus) 
    310                         ? SPAppleRemoteButtonVolumeMinusHold 
    311                         : SPAppleRemoteButtonVolumePlusHold; 
    312  
    313                 [delegate appleRemoteButton:event pressedDown:YES]; 
     296                        NSLog(@"*** _handleButtonWithCookieString:sum:: unknown button for cookie string '%@'", string); 
     297        } 
     298
     299 
     300 
     301 
     302- (void)_handleSimulatedHoldButton:(id)time { 
     303        if(_lastHoldButton > 0 && _lastHoldButtonTime == [time doubleValue]) { 
     304                _lastButtonSimulatedHold = YES; 
     305 
     306                if(_delegateAppleRemoteHeldButton) 
     307                        [delegate appleRemoteHeldButton:_lastHoldButton]; 
    314308        } 
    315309} 
     
    352346 
    353347                if((int) event.elementCookie == 19) { 
    354                         [remote _handleEventWithCookieString:@"19_" sum:0]; 
     348                        [remote _handleButtonWithCookieString:@"19_" sum:0]; 
    355349                } else { 
    356350                        if((int) event.elementCookie != 5) { 
     
    362356        } 
    363357 
    364         [remote _handleEventWithCookieString:string sum:sum]; 
     358        [remote _handleButtonWithCookieString:string sum:sum]; 
    365359} 
    366360 
     
    416410- (void)setDelegate:(id <SPAppleRemoteDelegate>)aDelegate { 
    417411        delegate = aDelegate; 
     412         
     413        _delegateAppleRemotePressedButtonDown = [delegate respondsToSelector:@selector(appleRemotePressedButton:down:)]; 
     414        _delegateAppleRemoteHeldButton = [delegate respondsToSelector:@selector(appleRemoteHeldButton:)]; 
    418415} 
    419416 
  • Spiral/trunk/SPApplicationController.h

    r5121 r5460  
    2828 
    2929#import "SPAppleRemote.h" 
     30#import "SPPS3Remote.h" 
    3031 
    3132@class SPPlaylistFile; 
    3233 
    33 @interface SPApplicationController : WIObject <SPAppleRemoteDelegate> { 
     34@interface SPApplicationController : WIObject <SPAppleRemoteDelegate, SPPS3RemoteDelegate> { 
    3435        IBOutlet NSMenu                         *_chaptersMenu; 
    3536        IBOutlet NSMenu                         *_audioTrackMenu; 
     
    4950         
    5051        BOOL                                            _holdingAppleRemoteButton; 
     52        BOOL                                            _holdingPS3RemoteButton; 
    5153} 
    5254 
  • Spiral/trunk/SPApplicationController.m

    r5141 r5460  
    3535#import "SPPlaylistController.h" 
    3636#import "SPPreferencesController.h" 
     37#import "SPPS3Remote.h" 
    3738#import "SPSettings.h" 
    3839 
     
    6768         
    6869    [[SPAppleRemote sharedRemote] setDelegate:self]; 
     70 
     71    [[SPPS3Remote sharedRemote] setDelegate:self]; 
     72//    [[SPPS3Remote sharedRemote] connect]; 
    6973} 
    7074 
     
    206210 
    207211 
    208 - (void)appleRemoteButton:(SPAppleRemoteEventIdentifier)button pressedDown:(BOOL)pressedDown { 
     212- (void)appleRemotePressedButton:(SPAppleRemoteButton)button down:(BOOL)down { 
    209213        SPMovieController               *movieController; 
    210214        id                                              delegate; 
    211215        double                                  rate; 
    212216         
    213         if(button == SPAppleRemoteButtonVolumeMinusHold || button == SPAppleRemoteButtonVolumePlusHold) { 
    214                 _holdingAppleRemoteButton = pressedDown; 
    215                  
    216                 if(pressedDown) { 
    217                         [self performSelector:@selector(holdAppleRemoteButton:)  
    218                                            withObject:[NSNumber numberWithInt:button]]; 
    219                 } 
    220         } else { 
    221                 delegate = [[NSApp keyWindow] delegate]; 
    222                  
    223                 if([delegate isKindOfClass:[SPPlayerController class]] || [delegate isKindOfClass:[SPDrillController class]]) { 
    224                         movieController = [delegate movieController]; 
    225                                  
    226                         if([delegate isKindOfClass:[SPDrillController class]] && 
    227                            (![movieController isInFullscreen] || button == SPAppleRemoteButtonMenu)) { 
    228                                 if(button == SPAppleRemoteButtonPlay || button == SPAppleRemoteButtonRight) 
    229                                         [delegate openSelection]; 
    230                                 else if(button == SPAppleRemoteButtonVolumeMinus && pressedDown) 
    231                                         [delegate moveSelectionDown]; 
    232                                 else if(button == SPAppleRemoteButtonVolumePlus && pressedDown) 
    233                                         [delegate moveSelectionUp]; 
    234                                 else if(button == SPAppleRemoteButtonLeft) 
    235                                         [delegate closeSelection]; 
    236                                 else if(button == SPAppleRemoteButtonMenu) 
    237                                         [delegate closeWindow]; 
    238                         } else { 
    239                                 if(button == SPAppleRemoteButtonPlay) 
    240                                         [movieController play]; 
    241                                 else if(button == SPAppleRemoteButtonLeft) 
    242                                         [movieController openPrevious]; 
    243                                 else if(button == SPAppleRemoteButtonRight) 
    244                                         [movieController openNext]; 
    245                                 else if(button == SPAppleRemoteButtonVolumeMinus) 
    246                                         [movieController cycleSubtitleTracksForwards:YES]; 
    247                                 else if(button == SPAppleRemoteButtonVolumePlus) 
    248                                         [movieController cycleAudioTracksForwards:YES]; 
    249                                 else if(button == SPAppleRemoteButtonMenu) { 
    250                                         if(![movieController isInFullscreen]) 
    251                                                 [[SPDrillController drillController] showWindow:self]; 
    252                                 } 
    253                                 else if(button == SPAppleRemoteButtonLeftHold || button == SPAppleRemoteButtonRightHold) { 
    254                                         if(pressedDown) { 
    255                                                 rate = [SPSettings doubleForKey:SPFastForwardFactor]; 
    256                                                  
    257                                                 [movieController playAtRate:(button == SPAppleRemoteButtonRightHold) ? rate : -rate]; 
    258                                         } else { 
    259                                                 [movieController playAtRate:1.0]; 
    260                                         } 
    261                                 } 
    262                         } 
    263                 } 
    264                 else if([delegate isKindOfClass:[SPPlaylistController class]]) { 
    265                         if(button == SPAppleRemoteButtonPlay) 
    266                                 [(SPPlaylistController *) delegate open:self]; 
    267                         else if(button == SPAppleRemoteButtonVolumeMinus && pressedDown) 
     217        delegate = [[NSApp keyWindow] delegate]; 
     218         
     219        if([delegate isKindOfClass:[SPPlayerController class]] || [delegate isKindOfClass:[SPDrillController class]]) { 
     220                movieController = [delegate movieController]; 
     221                 
     222                if([delegate isKindOfClass:[SPDrillController class]] && 
     223                   (![movieController isInFullscreen] || 
     224                        button == SPAppleRemoteButtonMenu)) { 
     225                        if(button == SPAppleRemoteButtonPlay || button == SPAppleRemoteButtonRight) 
     226                                [delegate openSelection]; 
     227                        else if(button == SPAppleRemoteButtonVolumeMinus && down) 
    268228                                [delegate moveSelectionDown]; 
    269                         else if(button == SPAppleRemoteButtonVolumePlus && pressedDown) 
     229                        else if(button == SPAppleRemoteButtonVolumePlus && down) 
    270230                                [delegate moveSelectionUp]; 
    271231                        else if(button == SPAppleRemoteButtonLeft) 
    272232                                [delegate closeSelection]; 
     233                        else if(button == SPAppleRemoteButtonMenu) 
     234                                [delegate closeWindow]; 
     235                } else { 
     236                        if(button == SPAppleRemoteButtonPlay) 
     237                                [movieController play]; 
     238                        else if(button == SPAppleRemoteButtonLeft) 
     239                                [movieController openPrevious]; 
    273240                        else if(button == SPAppleRemoteButtonRight) 
    274                                 [delegate openSelection]; 
    275                         else if(button == SPAppleRemoteButtonMenu) 
    276                                 [[SPDrillController drillController] showWindow:self]; 
    277                 } 
    278                 else if(button == SPAppleRemoteButtonMenu) { 
     241                                [movieController openNext]; 
     242                        else if(button == SPAppleRemoteButtonVolumeMinus) 
     243                                [movieController cycleSubtitleTracksForwards:YES]; 
     244                        else if(button == SPAppleRemoteButtonVolumePlus) 
     245                                [movieController cycleAudioTracksForwards:YES]; 
     246                        else if(button == SPAppleRemoteButtonMenu) { 
     247                                if(![movieController isInFullscreen]) 
     248                                        [[SPDrillController drillController] showWindow:self]; 
     249                        } 
     250                        else if(button == SPAppleRemoteButtonLeftHold || button == SPAppleRemoteButtonRightHold) { 
     251                                if(down) { 
     252                                        rate = [SPSettings doubleForKey:SPFastForwardFactor]; 
     253                                         
     254                                        [movieController playAtRate:(button == SPAppleRemoteButtonRightHold) ? rate : -rate]; 
     255                                } else { 
     256                                        [movieController playAtRate:1.0]; 
     257                                } 
     258                        } 
     259                } 
     260        } 
     261        else if([delegate isKindOfClass:[SPPlaylistController class]]) { 
     262                if(button == SPAppleRemoteButtonPlay) 
     263                        [(SPPlaylistController *) delegate open:self]; 
     264                else if(button == SPAppleRemoteButtonVolumeMinus && down) 
     265                        [delegate moveSelectionDown]; 
     266                else if(button == SPAppleRemoteButtonVolumePlus && down) 
     267                        [delegate moveSelectionUp]; 
     268                else if(button == SPAppleRemoteButtonLeft) 
     269                        [delegate closeSelection]; 
     270                else if(button == SPAppleRemoteButtonRight) 
     271                        [delegate openSelection]; 
     272                else if(button == SPAppleRemoteButtonMenu) 
    279273                        [[SPDrillController drillController] showWindow:self]; 
    280                 } 
    281         } 
    282 
    283  
    284  
    285  
    286 - (void)holdAppleRemoteButton:(NSNumber *)buttonNumber { 
    287         id                                                              delegate; 
    288         SPAppleRemoteEventIdentifier    button; 
    289  
     274        } 
     275        else if(button == SPAppleRemoteButtonMenu) { 
     276                [[SPDrillController drillController] showWindow:self]; 
     277        } 
     278 
     279        _holdingAppleRemoteButton = NO; 
     280
     281 
     282 
     283 
     284- (void)appleRemoteHeldButton:(SPAppleRemoteButton)button { 
     285        _holdingAppleRemoteButton = YES; 
     286                 
     287        [self performSelector:@selector(holdAppleRemoteButton:)  
     288                           withObject:[NSNumber numberWithInt:button]]; 
     289
     290 
     291 
     292 
     293- (void)holdAppleRemoteButton:(NSNumber *)button { 
     294        id                      delegate; 
     295         
    290296        if(_holdingAppleRemoteButton) { 
    291                 button = [buttonNumber intValue]; 
    292297                delegate = [[NSApp keyWindow] delegate]; 
    293298                 
    294299                if([delegate isKindOfClass:[SPDrillController class]] ||  
    295300                   [delegate isKindOfClass:[SPPlaylistController class]]) { 
    296                         if(button == SPAppleRemoteButtonVolumeMinusHold
     301                        if([button intValue] == SPAppleRemoteButtonVolumeMinus
    297302                                [delegate moveSelectionDown]; 
    298                         else if(button == SPAppleRemoteButtonVolumePlusHold
     303                        else if([button intValue] == SPAppleRemoteButtonVolumePlus
    299304                                [delegate moveSelectionUp]; 
    300305                } 
    301306                 
    302307                [self performSelector:@selector(holdAppleRemoteButton:)  
    303                                    withObject:buttonNumber 
     308                                   withObject:button 
    304309                                   afterDelay:0.05];          
    305310        } 
     311} 
     312 
     313 
     314 
     315- (void)PS3RemotePressedButton:(SPPS3RemoteButton)button { 
     316        SPMovieController               *movieController; 
     317        id                                              delegate; 
     318        double                                  rate; 
     319         
     320        NSLog(@"0x%x", button); 
     321         
     322        if(button == SPPS3RemoteButtonEject) { 
     323                [[NSWorkspace sharedWorkspace] ejectCDDrive]; 
     324                 
     325                return; 
     326        } 
     327         
     328        delegate = [[NSApp keyWindow] delegate]; 
     329         
     330        if([delegate isKindOfClass:[SPPlayerController class]] || [delegate isKindOfClass:[SPDrillController class]]) { 
     331                movieController = [delegate movieController]; 
     332 
     333                if([delegate isKindOfClass:[SPDrillController class]] && 
     334                   (![movieController isInFullscreen] || 
     335                        button == SPPS3RemoteButtonTopMenu || 
     336                        button == SPPS3RemoteButtonStop || 
     337                        button == SPPS3RemoteButtonReturn || 
     338                        button == SPPS3RemoteButtonX || 
     339                        button == SPPS3RemoteButtonBack)) { 
     340                        if(button == SPPS3RemoteButtonEnter || button == SPPS3RemoteButtonRight) 
     341                                [delegate openSelection]; 
     342                        else if(button == SPPS3RemoteButtonDown) 
     343                                [delegate moveSelectionDown]; 
     344                        else if(button == SPPS3RemoteButtonUp) 
     345                                [delegate moveSelectionUp]; 
     346                        else if(button == SPPS3RemoteButtonLeft) 
     347                                [delegate closeSelection]; 
     348                        else if(button == SPPS3RemoteButtonReturn || button == SPPS3RemoteButtonX || button == SPPS3RemoteButtonBack) { 
     349                                if([movieController isInFullscreen]) 
     350                                        [delegate closeWindow]; 
     351                                else 
     352                                        [delegate closeSelection]; 
     353                        } 
     354                        else if(button == SPPS3RemoteButtonStop) { 
     355                                if([movieController isInFullscreen]) 
     356                                        [delegate closeWindow]; 
     357                        } 
     358                        else if(button == SPPS3RemoteButtonTopMenu) 
     359                                [delegate closeWindow]; 
     360                } else { 
     361                        if(button == SPPS3RemoteButtonPlay) 
     362                                [movieController playAtRate:1.0]; 
     363                        else if(button == SPPS3RemoteButtonPause || button == SPPS3RemoteButtonStop) 
     364                                [movieController stop]; 
     365                        else if(button == SPPS3RemoteButtonAudio) 
     366                                [movieController cycleAudioTracksForwards:YES]; 
     367                        else if(button == SPPS3RemoteButtonSubtitle) 
     368                                [movieController cycleSubtitleTracksForwards:YES]; 
     369                        else if(button == SPPS3RemoteButtonTime || button == SPPS3RemoteButtonDisplay) 
     370                                [movieController flashCurrentTime]; 
     371                        else if(button == SPPS3RemoteButtonTopMenu) { 
     372                                if(![movieController isInFullscreen]) 
     373                                        [[SPDrillController drillController] showWindow:self]; 
     374                        } 
     375                        else if(button == SPPS3RemoteButtonPopUpMenu) 
     376                                [movieController orderFrontFullscreenHUDWindow]; 
     377                        else if(button == SPPS3RemoteButtonPrevious) 
     378                                [movieController openPrevious]; 
     379                        else if(button == SPPS3RemoteButtonNext) 
     380                                [movieController openNext]; 
     381                        else if(button == SPPS3RemoteButtonStepBackward) 
     382                                [movieController stepBackward]; 
     383                        else if(button == SPPS3RemoteButtonStepForward) 
     384                                [movieController stepForward]; 
     385                        else if(button == SPPS3RemoteButtonScanBackward || button == SPPS3RemoteButtonScanForward) { 
     386                                rate = [SPSettings doubleForKey:SPFastForwardFactor]; 
     387                                 
     388                                [movieController playAtRate:(button == SPPS3RemoteButtonScanForward) ? rate : -rate]; 
     389                        } 
     390                } 
     391        } 
     392        else if([delegate isKindOfClass:[SPPlaylistController class]]) { 
     393                if(button == SPPS3RemoteButtonEnter) 
     394                        [(SPPlaylistController *) delegate open:self]; 
     395                else if(button == SPPS3RemoteButtonDown) 
     396                        [delegate moveSelectionDown]; 
     397                else if(button == SPPS3RemoteButtonUp) 
     398                        [delegate moveSelectionUp]; 
     399                else if(button == SPPS3RemoteButtonLeft) 
     400                        [delegate closeSelection]; 
     401                else if(button == SPPS3RemoteButtonRight) 
     402                        [delegate openSelection]; 
     403                else if(button == SPPS3RemoteButtonTopMenu) 
     404                        [[SPDrillController drillController] showWindow:self]; 
     405        } 
     406        else if(button == SPPS3RemoteButtonTopMenu) { 
     407                [[SPDrillController drillController] showWindow:self]; 
     408        } 
     409 
     410        _holdingPS3RemoteButton = NO; 
     411} 
     412 
     413 
     414 
     415- (void)PS3RemoteHeldButton:(SPPS3RemoteButton)button { 
     416        NSLog(@"held 0x%x", button); 
     417         
     418        _holdingPS3RemoteButton = YES; 
     419                 
     420        [self performSelector:@selector(holdPS3RemoteButton:)  
     421                           withObject:[NSNumber numberWithInt:button]]; 
     422} 
     423 
     424 
     425 
     426- (void)holdPS3RemoteButton:(NSNumber *)button { 
     427        SPMovieController               *movieController; 
     428        id                                              delegate; 
     429         
     430        if(_holdingPS3RemoteButton) { 
     431                delegate = [[NSApp keyWindow] delegate]; 
     432                 
     433                if([delegate isKindOfClass:[SPPlayerController class]] || [delegate isKindOfClass:[SPDrillController class]]) { 
     434                        movieController = [delegate movieController]; 
     435                         
     436                        if([button intValue] == SPPS3RemoteButtonDown) 
     437                                [delegate moveSelectionDown]; 
     438                        else if([button intValue] == SPPS3RemoteButtonUp) 
     439                                [delegate moveSelectionUp]; 
     440                        else if([button intValue] == SPPS3RemoteButtonStepBackward) 
     441                                [movieController stepBackward]; 
     442                        else if([button intValue] == SPPS3RemoteButtonStepForward) 
     443                                [movieController stepForward]; 
     444                } 
     445                else if([delegate isKindOfClass:[SPPlaylistController class]]) { 
     446                        if([button intValue] == SPPS3RemoteButtonDown) 
     447                                [delegate moveSelectionDown]; 
     448                        else if([button intValue] == SPPS3RemoteButtonUp) 
     449                                [delegate moveSelectionUp]; 
     450                } 
     451                    
     452                [self performSelector:@selector(holdPS3RemoteButton:)  
     453                                   withObject:button 
     454                                   afterDelay:0.05];          
     455        } 
     456} 
     457 
     458 
     459 
     460- (void)PS3RemoteReleasedButton { 
     461        _holdingPS3RemoteButton = NO; 
    306462} 
    307463 
  • Spiral/trunk/SPPlaylistController.m

    r5316 r5460  
    631631        row = [_outlineView selectedRow]; 
    632632         
     633        if(row == -1) 
     634                row = rows; 
     635         
    633636        if(row == 0) 
    634637                return; 
     
    854857                        } 
    855858                         
    856                         [[item parentItem] removeItem:item]; 
     859                        [(SPPlaylistGroup *) [item parentItem] removeItem:item]; 
    857860                } 
    858861        } 
     
    12291232                                newItem = item; 
    12301233                         
    1231                         [[newItem parentItem] removeItem:newItem]; 
     1234                        [(SPPlaylistGroup *) [newItem parentItem] removeItem:newItem]; 
    12321235                         
    12331236                        if(index >= 0 && (NSUInteger) index < [group numberOfItems]) 
  • Spiral/trunk/SPPreferencesController.h

    r5139 r5460  
    2727 */ 
    2828 
    29 #define SPPreferencesDidChangeNotification             @"SPPreferencesDidChangeNotification" 
     29#define SPPreferencesDidChangeNotification      @"SPPreferencesDidChangeNotification" 
    3030 
    3131@interface SPPreferencesController : WIWindowController { 
    32         IBOutlet NSButton                       *_playMoviesWhenOpenedButton; 
    33         IBOutlet NSButton                       *_simplifyFilenamesButton; 
    34         IBOutlet NSButton                       *_checkForUpdateButton; 
    35         IBOutlet NSPopUpButton          *_defaultSizePopUpButton; 
    36         IBOutlet NSMatrix                       *_resumeBehaviorMatrix; 
    37         IBOutlet NSSlider                       *_fastForwardSpeedSlider; 
    38         IBOutlet NSTextField            *_fastForwardSpeedTextField; 
    39         IBOutlet NSComboBox                     *_preferredAudioComboBox; 
    40         IBOutlet NSComboBox                     *_preferredSubtitleComboBox; 
     32        IBOutlet NSButton                                               *_playMoviesWhenOpenedButton; 
     33        IBOutlet NSButton                                               *_simplifyFilenamesButton; 
     34        IBOutlet NSButton                                               *_checkForUpdateButton; 
     35        IBOutlet NSPopUpButton                                  *_defaultSizePopUpButton; 
     36        IBOutlet NSMatrix                                               *_resumeBehaviorMatrix; 
     37        IBOutlet NSSlider                                               *_fastForwardSpeedSlider; 
     38        IBOutlet NSTextField                                    *_fastForwardSpeedTextField; 
     39        IBOutlet NSComboBox                                             *_preferredAudioComboBox; 
     40        IBOutlet NSComboBox                                             *_preferredSubtitleComboBox; 
     41         
     42        IBOutlet NSImageView                                    *_PS3RemoteImageView; 
     43        IBOutlet NSTextField                                    *_PS3RemoteTextField; 
     44        IBOutlet NSProgressIndicator                    *_PS3RemoteProgressIndicator; 
    4145} 
    4246 
  • Spiral/trunk/SPPreferencesController.m

    r5139 r5460  
    3434 
    3535- (void)_updateFastForwardSpeedTextField; 
     36- (void)_updatePS3RemoteStatus; 
    3637 
    3738@end 
     
    4647} 
    4748 
     49 
     50 
     51- (void)_updatePS3RemoteStatus { 
     52        SPPS3Remote             *remote; 
     53 
     54        remote = [SPPS3Remote sharedRemote]; 
     55         
     56        if(![remote hasDevice]) { 
     57                [_PS3RemoteTextField setStringValue:NSLS(@"No remote found", @"PS3 remote status")]; 
     58                [_PS3RemoteImageView setImage:[NSImage imageNamed:@"RemoteNoDeviceFound"]]; 
     59        } 
     60        else if([remote isConnected]) { 
     61                [_PS3RemoteTextField setStringValue:NSLS(@"Connected", @"PS3 remote status")]; 
     62                [_PS3RemoteImageView setImage:[NSImage imageNamed:@"RemoteConnected"]]; 
     63        } 
     64        else if([remote isConnecting]) { 
     65                [_PS3RemoteTextField setStringValue:NSLS(@"Connecting...", @"PS3 remote status")]; 
     66                [_PS3RemoteImageView setImage:NULL]; 
     67        } 
     68        else { 
     69                [_PS3RemoteTextField setStringValue:NSLS(@"Not connected", @"PS3 remote status")]; 
     70                [_PS3RemoteImageView setImage:[NSImage imageNamed:@"RemoteNotConnected"]]; 
     71        } 
     72 
     73        if([remote isConnecting]) 
     74                [_PS3RemoteProgressIndicator startAnimation:self]; 
     75        else 
     76                [_PS3RemoteProgressIndicator stopAnimation:self]; 
     77} 
     78 
    4879@end 
    4980 
     
    6495 
    6596- (id)init { 
    66         return [super initWithWindowNibName:@"Preferences"]; 
     97        self = [super initWithWindowNibName:@"Preferences"]; 
     98         
     99        [[NSNotificationCenter defaultCenter] 
     100                addObserver:self 
     101                   selector:@selector(PS3RemoteWillConnect:) 
     102                           name:SPPS3RemoteWillConnect]; 
     103 
     104        [[NSNotificationCenter defaultCenter] 
     105                addObserver:self 
     106                   selector:@selector(PS3RemoteDidConnect:) 
     107                           name:SPPS3RemoteDidConnect]; 
     108         
     109        return self; 
     110
     111 
     112 
     113 
     114- (void)dealloc { 
     115        [[NSNotificationCenter defaultCenter] removeObserver:self]; 
     116         
     117        [super dealloc]; 
    67118} 
    68119 
     
    84