Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Controlling Apple TV for tvOS Demo

Controlling Apple TV for tvOS Demo

Controlling Apple TV for tvOS Demo
Chicago Cocoaheads 11/10/2015

Patrick McCarron

November 10, 2015
Tweet

More Decks by Patrick McCarron

Other Decks in Programming

Transcript

  1. New Apple TV Remote Support Required!! Bluetooth 4.0 Ships with

    Apple TV Lightning Charge Port Lanyard Option Mini Layout & Motion Limit ONE per Apple TV
  2. Steel Series Nimbus $49.99 New Hotness Bluetooth 4.0 Apple TV

    Approved Lightning Charge Port Extended Layout Limit TWO per Apple TV
  3. Steel Series Stratus $40-60 Depreciated Bluetooth 2.0 NOT Apple TV

    Approved Micro USB Charge Port Extended Layout Also limit TWO per Apple TV
  4. iOS App as Controller No Frameworks For Yet
 No GKPeerPickerController

    Use P2P Networking (Bonjour) Separate App or Mode in Universal App “Unlimited” devices can be paired
  5. UIKit - UIPress UIPressType is Limited: D-pad: Up, Down, Left

    & Right Buttons: Select, Menu & Play/Pause Digital not analog pressesBegan/Ended/Changed/Cancelled methods
  6. UIKit - UIPress Example override func pressesBegan(presses: Set<UIPress>, withEvent event:

    UIPressesEvent?) { for item in presses { if item.type == .Select { print("Select pressed") } } }
  7. Low Level - GameController Subclass GCEventViewController to toggle between UIKit

    and Low Level handling with controllerUserInteractionEnabled. Use GCController class to detect controllers and setup value change listeners on them. Or optionally check GCController objects during the run loop to see what buttons are depressed. This method can be used to assign player numbers, change behavior of Apple TV Remote, etc.
  8. GameController Example NSNotificationCenter.defaultCenter().addObserverForName(GCControllerDidConnectNotification, object: nil, queue: nil) { notification in

    for controller in GCController.controllers() { controller.controllerPausedHandler = { controller in //Toggle game/app paused state. self.controllerUserInteractionEnabled = !self.controllerUserInteractionEnabled } if controller.extendedGamepad != nil { controller.extendedGamepad?.valueChangedHandler = { gamepad, element in if let button = element as? GCControllerButtonInput { print("Extended Gamepad: button \(button) pressed") } } } } }