TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Dec 2014 |
Maintained by Unclaimed.
Work is in progress. I've established basic connection with the Controllers and am working on the abstraction so that you can plug this cocoa pod into your project. I don't want you to have to deal with IOHIDDevices, but with real controller instances and proper Notifications.
This is a CocoaPod which provides a simple API for you to work with Xbox input devices such as controllers, guitars, and drumsets.
You're ready to roll with USB-cable devices! If you plan on using wireless devices, you'll have to buy one of those first:
Head over to cocoapods.org to learn more about how it works. Here's a quickie:
git clone git://github.com/halo/Xbox360ControllerManager.git ~/some/where
Gemfile
in your project:source :rubygems
gem 'cocoapods'
Podfile
in your project:platform :osx
xcodeproj 'YourProject'
pod 'Xbox360ControllerManager', '0.0.1', :local => '~/some/where'
gem install bundle
bundle install
pod install
This would be a minimal implementation of your Application Delegate:
#import "AppDelegate.h"
#import "Xbox360Controller.h"
#import "Xbox360ControllerManager.h"
@implementation AppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// Start listening for device activity
[Xbox360ControllerManager sharedInstance];
// Register to the notifications
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(controllerAdded:) name:Xbox360ControllerAddedNotification object:NULL];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(controllerRemoved:) name:Xbox360ControllerRemovedNotification object:NULL];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(controllerActivity:) name:Xbox360ControllerActivityNotification object:NULL];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(controllerUpdated:) name:Xbox360ControllerUpdatedNotification object:NULL];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(controllerAction:) name:Xbox360ControllerActionNotification object:NULL];
}
- (void) controllerAdded:(NSNotification*)notification {
NSLog(@"You added a controller: %@", [notification object]);
}
- (void) controllerRemoved:(NSNotification*)notification {
NSLog(@"You removed a controller: %@", [notification object]);
}
- (void) controllerActivity:(NSNotification*)notification {
NSLog(@"You pressed some buttons: %@", [notification object]);
}
- (void) controllerUpdated:(NSNotification*)notification {
Xbox360Controller *controller = [notification object];
NSLog(@"Controller updated: %d", controller.leftStickHorizontal);
}
- (void) controllerAction:(NSNotification*)notification {
NSLog(@"Controller action: %@", [notification object]);
}
@end
If you are a little more low-level adventurous, you can also register to the Xbox360HIDAddedNotification
, Xbox360HIDRemovedNotification
, and Xbox360HIDActivityNotification
after calling [Xbox360HIDManager sharedInstance]
. Those will provide you with a IOHIDDeviceRef
on activity.
MIT 2013 funkensturm. See MIT-LICENSE.