diff options
author | maestrodd <maestrodd@svn> | 2009-10-23 14:56:14 +0000 |
---|---|---|
committer | maestrodd <maestrodd@svn> | 2009-10-23 14:56:14 +0000 |
commit | f7010c06a63fe730b9fb2953439319a12f2d0cbe (patch) | |
tree | 37a7477d7331af0ada563d55519e6a58d54c357d /tools/EventClients | |
parent | 453b5a35f6578076df43873f743898417db48bc4 (diff) |
[OSX] XBMCHelper: updated to final HIDRemote framework; adapted XBMCHelper
git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk@23931 568bbfeb-2a22-0410-94d2-cc84cf5bfa90
Diffstat (limited to 'tools/EventClients')
4 files changed, 26 insertions, 218 deletions
diff --git a/tools/EventClients/Clients/OSXRemote/HIDRemote/HIDRemote.h b/tools/EventClients/Clients/OSXRemote/HIDRemote/HIDRemote.h index b42f60b712..358a9b0bc3 100644 --- a/tools/EventClients/Clients/OSXRemote/HIDRemote/HIDRemote.h +++ b/tools/EventClients/Clients/OSXRemote/HIDRemote/HIDRemote.h @@ -127,14 +127,16 @@ typedef enum // Notification of button events - (void)hidRemote:(HIDRemote *)hidRemote // The instance of HIDRemote sending this eventWithButton:(HIDRemoteButtonCode)buttonCode // Event for the button specified by code - isPressed:(BOOL)isPressed; // The button was pressed (YES) / released (NO) + isPressed:(BOOL)isPressed // The button was pressed (YES) / released (NO) + fromHardwareWithAttributes:(NSMutableDictionary *)attributes; // Information on the device this event comes from @optional // Notification of ID changes -- (void)hidRemote:(HIDRemote *)hidRemote - remoteIDChangedOldID:(SInt32)old // Invoked when the user switched to a remote control with a different ID - newID:(SInt32)newID; +- (void)hidRemote:(HIDRemote *)hidRemote // Invoked when the user switched to a remote control with a different ID + remoteIDChangedOldID:(SInt32)old + newID:(SInt32)newID + forHardwareWithAttributes:(NSMutableDictionary *)attributes; // Notification about hardware additions/removals - (void)hidRemote:(HIDRemote *)hidRemote // Invoked when new hardware was found / added to HIDRemote's pool @@ -212,236 +214,43 @@ typedef enum } #pragma mark -- PUBLIC: Shared HID Remote -- -/* - DESCRIPTION - It is possible to alloc & init multiple instances of this class. However, this is not recommended unless - you subclass it and build something different. Instead of allocating & initializing the instance yourself, - you can make use of the +sharedHIDRemote singleton. - - RESULT - The HIDRemote instance globally shared in your application. You should not -release the returned object. -*/ + (HIDRemote *)sharedHIDRemote; #pragma mark -- PUBLIC: System Information -- -/* - DESCRIPTION - Determine whether the Candelair driver version 1.7.0 or later is installed. - - RESULT - YES, if it is installed. NO, if it isn't. -*/ + (BOOL)isCandelairInstalled; - -/* - DESCRIPTION - Determine whether the user needs to install the Candelair driver in order for your application to get - access to the IR Receiver in a specific mode. - - RESULT - YES, if the user runs your application on an operating system version that makes the installation of - the Candelair driver necessary for your application to get access to the IR Receiver in the specified - mode. - NO, if the operating system version in use either doesn't make the installation of the Candelair driver - a necessity - or - if it is already installed. - - SAMPLE CODE - Please see DemoController.m from the HIDRemoteSample project for a reusable example on how to make best - use of this method in your code. -*/ + (BOOL)isCandelairInstallationRequiredForRemoteMode:(HIDRemoteMode)remoteMode; #pragma mark -- PUBLIC: Interface / API -- -/* - DESCRIPTION - Starts the HIDRemote in the respective mode kHIDRemoteModeShared, kHIDRemoteModeExclusive or - kHIDRemoteModeExclusiveAuto. - - RESULT - YES, if setup was successful. NO, if an error occured during setup. Note that a successful setup - does not mean that you gained the respective level of access or that remote control hardware was - actually found. This is only the case if -activeRemoteControlCount returns a value - greater zero. I.e. your setup code could look like this: - - if ((hidRemoteControl = [HIDRemoteControl sharedHIDRemote]) != nil) - { - [hidRemoteControl setDelegate:myDelegate]; - - if ([HIDRemote isCandelairInstallationRequiredForRemoteMode:kHIDRemoteModeExclusiveAuto]) - { - NSLog(@"Installation of Candelair required."); // See DemoController.m for a reusable code snippet presenting an - // alert and offering to open related URLs - } - else - { - if ([hidRemoteControl startRemoteControl:kHIDRemoteModeExclusiveAuto]) - { - NSLog(@"Driver has started successfully."); - - if ([hidRemoteControl activeRemoteControlCount]) - { - NSLog(@"Driver has found %d remotes.", [hidRemoteControl activeRemoteControlCount]); - } - else - { - NSLog(@"Driver has not found any remotes it could use. Will use remotes as they become available."); - } - } - else - { - // .. Setup failed .. - } - } - } -*/ - (BOOL)startRemoteControl:(HIDRemoteMode)hidRemoteMode; - -/* - DESCRIPTION - Stops the HIDRemote. You will no longer get remote control events after this. Other applications can - then access the remote again. To get a lock on the HIDRemote again, make use of -startRemoteControl:. -*/ - (void)stopRemoteControl; -/* - DESCRIPTION - Determine, whether the HIDRemote has been started with -startRemoteControl:. - - RESULT - YES, if it was started. NO, if it was not. -*/ - (BOOL)isStarted; -/* - DESCRIPTION - Determine the number of remote controls/receivers HIDRemote has currently opened in the mode supplied to - -startRemoteControl: - - RESULT - The number of remote controls/receivers HIDRemote has currently opened. Zero if none could be found or opened. -*/ - (unsigned)activeRemoteControlCount; -/* - DESCRIPTION - Returns the ID of the remote from which the button press was received from last. You can sign up your delegate for - ID change notifications by implementing the (optional) -hidRemote:remoteIDChangedOldID:newID: selector. - - RESULT - The ID of the last seen remote. Returns -1, if the ID is unknown. -*/ - (SInt32)lastSeenRemoteControlID; -/* - DESCRIPTION - Set a new delegate object. This object has to implement the HIDRemoteDelegate protocol. If it is also implementing - the optional HIDRemoteDelegate protocol methods, it will be able to receive additional notifications and events. - - IMPORTANT - The delegate is not retained. Make sure you execute a -[hidRemoteInstance setDelegate:nil] in the dealloc method of - your delegate. -*/ - (void)setDelegate:(NSObject <HIDRemoteDelegate> *)newDelegate; - -/* - DESCRIPTION - Get the currently set delegate object. - - RESULT - The currently set delegate object. -*/ - (NSObject <HIDRemoteDelegate> *)delegate; -/* - DESCRIPTION - Set whether hold events should be simulated for the + and - buttons. The simulation is active by default. This value - should only be changed when no button is currently pressed (f.ex. before calling -startRemoteControl:). The behaviour - is undefined if a button press is currently in progress. -*/ - (void)setSimulateHoldEvents:(BOOL)newSimulateHoldEvents; - -/* - DESCRIPTION - Determine whether the simulation of hold events for the + and - buttons is currently active. - - RESULT - YES or NO depending on whether the simulation is currently active. -*/ - (BOOL)simulateHoldEvents; -/* - DESCRIPTION - Set an array of NSNumbers with HIDRemoteButtonCodes that are not used by your application. This is empty by default. - By providing this information, you improve interoperation with popular remote control solutions such as Remote Buddy. - If, for example, you don't use the MenuHold button code, you'd express it like this in your sourcecode: - - if (hidRemote = [HIDRemote sharedHIDRemote]) - { - // .. - - [hidRemote setUnusedButtonCodes:[NSArray arrayWithObjects:[NSNumber numberWithInt:(int)kHIDRemoteButtonCodeMenuHold], nil]]; - - // .. - } - - Advanced remote control solutions such as Remote Buddy do then know that you're not using the MenuHold button code and - can automatically create a mapping table for your application, with all buttons presses except MenuHold being forwarded - to your application. For MenuHold, Remote Buddy might map an action to open its own menu. -*/ - (void)setUnusedButtonCodes:(NSArray *)newArrayWithUnusedButtonCodesAsNSNumbers; - -/* - DESCRIPTION - Return an array of NSNumbers with HIDRemoteButtonCodes your application does not use. For more information, see the - description for -setUnusedButtonCodes: - - RESULT - An array of NSNumbers with HIDRemoteButtonCodes your application does not use. -*/ - (NSArray *)unusedButtonCodes; #pragma mark -- PUBLIC: Expert APIs -- -/* - DESCRIPTION - Enables/disables a workaround to a locking issue introduced with Security Update 2008-004 / 10.4.9 and beyond. Essentially, - without this workaround enabled, using an application that uses a password textfield would degrade exclusive locks to shared - locks with the result being that both normal OS X as well as your application would react to the same HID event when really - only your application should. Credit for finding this workaround goes to Martin Kahr. - - Enabled by default. -*/ - (void)setEnableSecureEventInputWorkaround:(BOOL)newEnableSecureEventInputWorkaround; -/* - DESCRIPTION - Determine whether aforementioned workaround is active. - - RESULT - YES or NO. -*/ - (BOOL)enableSecureEventInputWorkaround; -/* - DESCRIPTION - Enables/disables lending of the exclusive lock to other applications when in kHIDRemoteModeExclusive mode. - - Enable this option only when you are writing a background application that keeps a permanent, exclusive lock on the IR receiver. - - When this option is enabled and another application using the HIDRemote class indicates that it'd like to get exclusive access - to the IR receiver itself while your application is having it, your application's instance of HIDRemote automatically stops and - signals the other application that it can now get exclusive access. When the other application's HIDRemote instance no longer uses - the IR receiver exclusively, it lets your application know so that it can recover its exclusive lock. - - This option is disabled by default. Unless you have special needs, you really should use the kHIDRemoteModeExclusiveAuto mode for - best compatibility with other applications. -*/ - (void)setExclusiveLockLendingEnabled:(BOOL)newExclusiveLockLendingEnabled; - (BOOL)exclusiveLockLendingEnabled; #pragma mark -- PRIVATE: HID Event handling -- - (void)_handleButtonCode:(HIDRemoteButtonCode)buttonCode isPressed:(BOOL)isPressed hidAttribsDict:(NSMutableDictionary *)hidAttribsDict; -- (void)_sendButtonCode:(HIDRemoteButtonCode)buttonCode isPressed:(BOOL)isPressed; +- (void)_sendButtonCode:(HIDRemoteButtonCode)buttonCode isPressed:(BOOL)isPressed hidAttribsDict:(NSMutableDictionary *)hidAttribsDict; - (void)_hidEventFor:(io_service_t)hidDevice from:(IOHIDQueueInterface **)interface withResult:(IOReturn)result; #pragma mark -- PRIVATE: Service setup and destruction -- diff --git a/tools/EventClients/Clients/OSXRemote/HIDRemote/HIDRemote.m b/tools/EventClients/Clients/OSXRemote/HIDRemote/HIDRemote.m index 55ea52a776..9b3769d304 100644 --- a/tools/EventClients/Clients/OSXRemote/HIDRemote/HIDRemote.m +++ b/tools/EventClients/Clients/OSXRemote/HIDRemote/HIDRemote.m @@ -706,8 +706,8 @@ static HIDRemote *sHIDRemote = nil; kCFAllocatorDefault, 0)) != nil) { - // Match on Apple's AppleIRController - if ([ioClass isEqual:@"AppleIRController"]) + // Match on Apple's AppleIRController and old versions of the Remote Buddy IR Controller + if ([ioClass isEqual:@"AppleIRController"] || [ioClass isEqual:@"RBIOKitAIREmu"]) { CFTypeRef candelairHIDRemoteCompatibilityDevice; @@ -1336,7 +1336,7 @@ static HIDRemote *sHIDRemote = nil; [shTimer invalidate]; [hidAttribsDict removeObjectForKey:kHIDRemoteSimulateHoldEventsTimer]; - [self _sendButtonCode:(((HIDRemoteButtonCode)[shButtonCode unsignedIntValue])|kHIDRemoteButtonCodeHoldMask) isPressed:YES]; + [self _sendButtonCode:(((HIDRemoteButtonCode)[shButtonCode unsignedIntValue])|kHIDRemoteButtonCodeHoldMask) isPressed:YES hidAttribsDict:hidAttribsDict]; } } } @@ -1383,14 +1383,14 @@ static HIDRemote *sHIDRemote = nil; if (shTimer && shButtonCode) { - [self _sendButtonCode:(HIDRemoteButtonCode)[shButtonCode unsignedIntValue] isPressed:YES]; - [self _sendButtonCode:(HIDRemoteButtonCode)[shButtonCode unsignedIntValue] isPressed:NO]; + [self _sendButtonCode:(HIDRemoteButtonCode)[shButtonCode unsignedIntValue] isPressed:YES hidAttribsDict:hidAttribsDict]; + [self _sendButtonCode:(HIDRemoteButtonCode)[shButtonCode unsignedIntValue] isPressed:NO hidAttribsDict:hidAttribsDict]; } else { if (shButtonCode) { - [self _sendButtonCode:(((HIDRemoteButtonCode)[shButtonCode unsignedIntValue])|kHIDRemoteButtonCodeHoldMask) isPressed:NO]; + [self _sendButtonCode:(((HIDRemoteButtonCode)[shButtonCode unsignedIntValue])|kHIDRemoteButtonCodeHoldMask) isPressed:NO hidAttribsDict:hidAttribsDict]; } } } @@ -1402,17 +1402,17 @@ static HIDRemote *sHIDRemote = nil; } default: - [self _sendButtonCode:buttonCode isPressed:isPressed]; + [self _sendButtonCode:buttonCode isPressed:isPressed hidAttribsDict:hidAttribsDict]; break; } } -- (void)_sendButtonCode:(HIDRemoteButtonCode)buttonCode isPressed:(BOOL)isPressed +- (void)_sendButtonCode:(HIDRemoteButtonCode)buttonCode isPressed:(BOOL)isPressed hidAttribsDict:(NSMutableDictionary *)hidAttribsDict { if (([self delegate]!=nil) && - ([[self delegate] respondsToSelector:@selector(hidRemote:eventWithButton:isPressed:)])) + ([[self delegate] respondsToSelector:@selector(hidRemote:eventWithButton:isPressed:fromHardwareWithAttributes:)])) { - [((NSObject <HIDRemoteDelegate> *)[self delegate]) hidRemote:self eventWithButton:buttonCode isPressed:isPressed]; + [((NSObject <HIDRemoteDelegate> *)[self delegate]) hidRemote:self eventWithButton:buttonCode isPressed:isPressed fromHardwareWithAttributes:hidAttribsDict]; } } @@ -1477,9 +1477,9 @@ static HIDRemote *sHIDRemote = nil; if (buttonCode == kHIDRemoteButtonCodeIDChanged) { if (([self delegate]!=nil) && - ([[self delegate] respondsToSelector:@selector(hidRemote:remoteIDChangedOldID:newID:)])) + ([[self delegate] respondsToSelector:@selector(hidRemote:remoteIDChangedOldID:newID:forHardwareWithAttributes:)])) { - [((NSObject <HIDRemoteDelegate> *)[self delegate]) hidRemote:self remoteIDChangedOldID:_lastSeenRemoteID newID:hidEvent.value]; + [((NSObject <HIDRemoteDelegate> *)[self delegate]) hidRemote:self remoteIDChangedOldID:_lastSeenRemoteID newID:hidEvent.value forHardwareWithAttributes:hidAttribsDict]; } _lastSeenRemoteID = hidEvent.value; diff --git a/tools/EventClients/Clients/OSXRemote/XBMCHelper.h b/tools/EventClients/Clients/OSXRemote/XBMCHelper.h index 7f6ae5cdb9..5aa984cda3 100644 --- a/tools/EventClients/Clients/OSXRemote/XBMCHelper.h +++ b/tools/EventClients/Clients/OSXRemote/XBMCHelper.h @@ -8,7 +8,7 @@ #import <Cocoa/Cocoa.h> #import "xbmcclientwrapper.h" -#import "HIDRemote.h" +#import "HIDRemote/HIDRemote.h" @interface XBMCHelper : NSObject<HIDRemoteDelegate> { HIDRemote *remote; diff --git a/tools/EventClients/Clients/OSXRemote/XBMCHelper.m b/tools/EventClients/Clients/OSXRemote/XBMCHelper.m index ccbe65efd9..22b11e0d57 100644 --- a/tools/EventClients/Clients/OSXRemote/XBMCHelper.m +++ b/tools/EventClients/Clients/OSXRemote/XBMCHelper.m @@ -8,7 +8,7 @@ #import "XBMCHelper.h" #import "XBMCDebugHelpers.h" -#import "HIDRemote.h" + //---------------------------------------------------------------------------- //---------------------------------------------------------------------------- @interface XBMCHelper (private) @@ -118,9 +118,8 @@ #pragma mark HIDRemote delegate methods // Notification of button events -- (void)hidRemote:(HIDRemote *)hidRemote // The instance of HIDRemote sending this - eventWithButton:(HIDRemoteButtonCode)buttonCode // Event for the button specified by code - isPressed:(BOOL)isPressed // The button was pressed (YES) / released (NO) +- (void)hidRemote:(HIDRemote *)hidRemote eventWithButton:(HIDRemoteButtonCode)buttonCode + isPressed:(BOOL)isPressed fromHardwareWithAttributes:(NSMutableDictionary *)attributes { if(m_verbose){ NSLog(@"Received button '%@' %@ event", [self buttonNameForButtonCode:buttonCode], (isPressed)?@"press":@"release"); @@ -187,13 +186,13 @@ // Notification of ID changes -- (void)hidRemote:(HIDRemote *)hidRemote -remoteIDChangedOldID:(SInt32)old // Invoked when the user switched to a remote control with a different ID - newID:(SInt32)newID +- (void)hidRemote:(HIDRemote *)hidRemote remoteIDChangedOldID:(SInt32)old + newID:(SInt32)newID forHardwareWithAttributes:(NSMutableDictionary *)attributes { if(m_verbose) NSLog(@"Change of remote ID from %d to %d", old, newID); [mp_wrapper switchRemote: newID]; + } #pragma mark - |