Giter VIP home page Giter VIP logo

xbox360controllermanager's Introduction

Xbox 360 Controller Manager

This is a CocoaPod which provides a simple API for you to work with Xbox input devices such as controllers, guitars, and drumsets.

Requirements

  • You need at least Mountain Lion
  • Install the driver which allows you to connect Xbox input devices (Controllers, Guitars, Drumsets) to your Mac.

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:

Xbox 360 Wireless Receiver

Installation

Head over to cocoapods.org to learn more about how it works. Here's a quickie:

1. Download the repo next to your project:

git clone git://github.com/halo/Xbox360ControllerManager.git ~/some/where

2. Create a Gemfile in your project:

source :rubygems

gem 'cocoapods'

3. Create a Podfile in your project:

platform  :osx
xcodeproj 'YourProject'

pod 'Xbox360ControllerManager', '0.0.1', :local => '~/some/where'

4. Install and run bundler if you don't already have it:

gem install bundle
bundle install

4. Run the pod

pod install

Usage

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.

Credits

  • Colin Munro is the genius behind the Mac OS driver routine.
  • Derek van Vliet had an inspiring project that had the same conceptual idea behind it - and the project name :)

License

MIT 2013 funkensturm. See MIT-LICENSE.

xbox360controllermanager's People

Watchers

James Cloos avatar luohe avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.