Changeset 5523

Show
Ignore:
Timestamp:
05/11/08 21:50:29 (4 days ago)
Author:
morris
Message:

Only disconnect from Bluetooth remotes on delay when there are no player windows open

Refactor delegate methods a bit

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • Spiral/trunk/SPApplicationController.m

    r5521 r5523  
    512512#pragma mark - 
    513513 
    514 - (void)PS3RemotePressedButton:(SPPS3RemoteButton)button { 
     514- (BOOL)PS3RemoteShouldDisconnect:(SPPS3Remote *)remote { 
     515        id              delegate; 
     516 
     517        delegate = [[NSApp keyWindow] delegate]; 
     518 
     519        if([delegate isKindOfClass:[SPPlayerController class]] || [delegate isKindOfClass:[SPDrillController class]]) 
     520                return NO; 
     521         
     522        return YES; 
     523
     524 
     525 
     526 
     527- (void)PS3Remote:(SPPS3Remote *)remote pressedButton:(SPPS3RemoteButton)button { 
    515528        SPRemoteAction          action; 
    516529         
     
    526539 
    527540 
    528 - (void)PS3RemoteHeldButton:(SPPS3RemoteButton)button { 
     541- (void)PS3Remote:(SPPS3Remote *)remote heldButton:(SPPS3RemoteButton)button { 
    529542        if([NSApp isActive]) { 
    530543                _holdingPS3RemoteButton = YES; 
     
    553566 
    554567 
    555 - (void)PS3RemoteReleasedButton
     568- (void)PS3RemoteReleasedButton:(SPPS3Remote *)remote
    556569        if([NSApp isActive]) 
    557570                _holdingPS3RemoteButton = NO; 
     
    562575#pragma mark - 
    563576 
    564 - (void)wiiRemotePressedButton:(SPWiiRemoteButton)button { 
     577- (BOOL)wiiRemoteShouldDisconnect:(SPWiiRemote *)remote { 
     578        id              delegate; 
     579 
     580        delegate = [[NSApp keyWindow] delegate]; 
     581 
     582        if([delegate isKindOfClass:[SPPlayerController class]] || [delegate isKindOfClass:[SPDrillController class]]) 
     583                return NO; 
     584         
     585        return YES; 
     586
     587 
     588 
     589 
     590- (void)wiiRemote:(SPWiiRemote *)remote pressedButton:(SPWiiRemoteButton)button { 
    565591        SPRemoteAction          action; 
    566592         
     
    576602 
    577603 
    578 - (void)wiiRemoteHeldButton:(SPWiiRemoteButton)button { 
     604- (void)wiiRemote:(SPWiiRemote *)remote heldButton:(SPWiiRemoteButton)button { 
    579605        if([NSApp isActive]) { 
    580606                _holdingWiiRemoteButton = YES; 
     
    603629 
    604630 
    605 - (void)wiiRemoteReleasedButton
     631- (void)wiiRemoteReleasedButton:(SPWiiRemote *)remote
    606632        if([NSApp isActive]) 
    607633                _holdingWiiRemoteButton = NO; 
  • Spiral/trunk/SPBluetoothRemote.h

    r5517 r5523  
    5959- (void)connectAfterDelay; 
    6060- (void)disconnectAfterDelay; 
     61- (BOOL)remoteShouldDisconnect; 
    6162- (void)remoteDidConnect; 
    6263 
  • Spiral/trunk/SPBluetoothRemote.m

    r5517 r5523  
    124124        NSLog(@"*** -[%@ _disconnect]", [self class]); 
    125125 
    126         if(_controlConnected) 
    127                 [_controlChannel closeChannel]; 
    128  
    129         if(_interruptConnected) 
    130                 [_interruptChannel closeChannel]; 
    131          
    132         [_device closeConnection]; 
     126        if([self remoteShouldDisconnect]) { 
     127                if(_controlConnected) 
     128                        [_controlChannel closeChannel]; 
     129 
     130                if(_interruptConnected) 
     131                        [_interruptChannel closeChannel]; 
     132                 
     133                [_device closeConnection]; 
     134        } else { 
     135                [self disconnectAfterDelay]; 
     136        } 
    133137} 
    134138 
     
    197201 
    198202- (void)disconnectAfterDelay { 
    199         [self performSelectorOnce:@selector(_disconnect) afterDelay:1800.0]; 
     203        [self performSelectorOnce:@selector(_disconnect) afterDelay:600.0]; 
     204
     205 
     206 
     207 
     208- (BOOL)remoteShouldDisconnect { 
     209        return NO; 
    200210} 
    201211 
  • Spiral/trunk/SPPS3Remote.h

    r5472 r5523  
    111111@protocol SPPS3RemoteDelegate <NSObject> 
    112112 
     113- (BOOL)PS3RemoteShouldDisconnect:(SPPS3Remote *)remote; 
     114 
    113115@optional 
    114116 
    115 - (void)PS3RemotePressedButton:(SPPS3RemoteButton)button; 
    116 - (void)PS3RemoteHeldButton:(SPPS3RemoteButton)button; 
    117 - (void)PS3RemoteReleasedButton
     117- (void)PS3Remote:(SPPS3Remote *)remote pressedButton:(SPPS3RemoteButton)button; 
     118- (void)PS3Remote:(SPPS3Remote *)remote heldButton:(SPPS3RemoteButton)button; 
     119- (void)PS3RemoteReleasedButton:(SPPS3Remote *)remote
    118120 
    119121@end 
  • Spiral/trunk/SPPS3Remote.m

    r5521 r5523  
    4848 
    4949                if(_delegatePS3RemotePressedButton) 
    50                         [delegate PS3RemotePressedButton:button]; 
     50                        [delegate PS3Remote:self pressedButton:button]; 
    5151        } else { 
    5252                if(_lastButtonSimulatedHold) { 
     
    5858                 
    5959                if(_delegatePS3RemoteReleasedButton) 
    60                         [delegate PS3RemoteReleasedButton]; 
     60                        [delegate PS3RemoteReleasedButton:self]; 
    6161        } 
    6262} 
     
    6969 
    7070                if(_delegatePS3RemoteHeldButton) 
    71                         [delegate PS3RemoteHeldButton:_lastHoldButton]; 
     71                        [delegate PS3Remote:self heldButton:_lastHoldButton]; 
    7272        } 
    7373} 
     
    110110         
    111111        [super remoteDidConnect]; 
     112} 
     113 
     114 
     115 
     116- (BOOL)remoteShouldDisconnect { 
     117        return [delegate PS3RemoteShouldDisconnect:self]; 
    112118} 
    113119 
  • Spiral/trunk/SPWiiRemote.h

    r5472 r5523  
    7171@protocol SPWiiRemoteDelegate <NSObject> 
    7272 
     73- (BOOL)wiiRemoteShouldDisconnect:(SPWiiRemote *)remote; 
     74 
    7375@optional 
    7476 
    75 - (void)wiiRemotePressedButton:(SPWiiRemoteButton)button; 
    76 - (void)wiiRemoteHeldButton:(SPWiiRemoteButton)button; 
    77 - (void)wiiRemoteReleasedButton
     77- (void)wiiRemote:(SPWiiRemote *)remote pressedButton:(SPWiiRemoteButton)button; 
     78- (void)wiiRemote:(SPWiiRemote *)remote heldButton:(SPWiiRemoteButton)button; 
     79- (void)wiiRemoteReleasedButton:(SPWiiRemote *)remote
    7880 
    7981@end 
  • Spiral/trunk/SPWiiRemote.m

    r5520 r5523  
    7474 
    7575                if(_delegateWiiRemotePressedButton) 
    76                         [delegate wiiRemotePressedButton:button]; 
     76                        [delegate wiiRemote:self pressedButton:button]; 
    7777        } else { 
    7878                if(_lastButtonSimulatedHold) { 
     
    8484                 
    8585                if(_delegateWiiRemoteReleasedButton) 
    86                         [delegate wiiRemoteReleasedButton]; 
     86                        [delegate wiiRemoteReleasedButton:self]; 
    8787        } 
    8888} 
     
    9595 
    9696                if(_delegateWiiRemoteHeldButton) 
    97                         [delegate wiiRemoteHeldButton:_lastHoldButton]; 
     97                        [delegate wiiRemote:self heldButton:_lastHoldButton]; 
    9898        } 
    9999} 
     
    156156         
    157157        [super remoteDidConnect]; 
     158} 
     159 
     160 
     161 
     162- (BOOL)remoteShouldDisconnect { 
     163        return [delegate wiiRemoteShouldDisconnect:self]; 
    158164} 
    159165