designing for game controllers - apple inc.€¦ · designing for game controllers session 611 jj...
TRANSCRIPT
![Page 1: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/1.jpg)
© 2014 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple.
#WWDC14
Designing for Game Controllers
Session 611 JJ Cwik Software Engineer
Graphics and Games
![Page 2: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/2.jpg)
Game Controllers
![Page 3: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/3.jpg)
MFi Specification
For third-party controller vendors
Defines hardware requirements
Gives confidence controllers work for all games which support controllers
![Page 4: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/4.jpg)
Game Controller Framework
Add controller support to your game
iOS and OS X
Simple API • Detect controllers
• Read inputs
One API for all controllers
![Page 5: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/5.jpg)
Form-Fitting Standard Controller
Form-fitting • Encases device
• Touch, motion
Standard control layout • D-pad
• Buttons—A, B, X, Y
• Shoulder buttons—L, R
![Page 6: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/6.jpg)
Form-Fitting Extended Controller
Form-fitting • Encases device
• Touch, motion
Extended control layout • D-pad
• Buttons—A, B, X, Y
• Shoulder buttons—L1, R1
• Thumbsticks
• Triggers—L2, R2
YX B
A
R2
R1L1
L2
![Page 7: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/7.jpg)
Form-Fitting Extended Controller
Form-fitting • Encases device
• Touch, motion
Extended control layout • D-pad
• Buttons—A, B, X, Y
• Shoulder buttons—L1, R1
• Thumbsticks
• Triggers—L2, R2
YX B
A
R2
R1L1
L2L2 R2
![Page 8: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/8.jpg)
Standalone Extended Controller
Standalone • Not attached to device
• Input only from controller
Extended control layout • D-pad
• Buttons—A, B, X, Y
• Shoulder buttons—L1, R1
• Thumbsticks
• Triggers—L2, R2
YX B
A
R2
R1
L2
L1
![Page 9: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/9.jpg)
Standalone Extended Controller
Standalone • Not attached to device
• Input only from controller
Extended control layout • D-pad
• Buttons—A, B, X, Y
• Shoulder buttons—L1, R1
• Thumbsticks
• Triggers—L2, R2
YX B
A
R2
R1
L2
L1
![Page 10: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/10.jpg)
Agenda
Overview
Finding controllers
Reading controller input
What’s new
Design guidance
![Page 11: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/11.jpg)
Finding Controllers
![Page 12: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/12.jpg)
GCController
Main class
Same class for all controllers
Provides • Finding controllers
• Reading input
• Controller information
YX B
A
YX B
A
![Page 13: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/13.jpg)
Finding Controllers
@interface GCController : NSObject + (NSArray *)controllers; ...
!
Currently-connected controllers
Array of GCController instances (empty if none)
Updated when controllers connect and disconnect
![Page 14: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/14.jpg)
Finding Controllers
-application:didFinishLaunchingWithOptions: -setupControllers:
![Page 15: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/15.jpg)
Finding Controllers
-application:didFinishLaunchingWithOptions: -setupControllers:
[GCController controllers]
![Page 16: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/16.jpg)
Finding Controllers
-application:didFinishLaunchingWithOptions: -setupControllers:
[GCController controllers]Connect/ Disconnect
![Page 17: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/17.jpg)
Finding Controllers
-application:didFinishLaunchingWithOptions: -setupControllers:
[GCController controllers]Wireless Discovery
Connect/ Disconnect
![Page 18: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/18.jpg)
-(BOOL)application:(UIApplication*)app didFinishLaunchingWithOptions:(NSDictionary*)dict { if ([GCController class]) { NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; !
[center addObserver:self selector:@selector(setupControllers:) name:GCControllerDidConnectNotification object:nil]; [center addObserver:self selector:@selector(setupControllers:) name:GCControllerDidDisconnectNotification object:nil]; !
[GCController startWirelessControllerDiscoveryWithCompletionHandler:^{...}]; }}
Finding Controllers
![Page 19: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/19.jpg)
-(BOOL)application:(UIApplication*)app didFinishLaunchingWithOptions:(NSDictionary*)dict { if ([GCController class]) { NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; !
[center addObserver:self selector:@selector(setupControllers:) name:GCControllerDidConnectNotification object:nil]; [center addObserver:self selector:@selector(setupControllers:) name:GCControllerDidDisconnectNotification object:nil]; !
[GCController startWirelessControllerDiscoveryWithCompletionHandler:^{...}]; }}
Finding Controllers
![Page 20: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/20.jpg)
-(BOOL)application:(UIApplication*)app didFinishLaunchingWithOptions:(NSDictionary*)dict { if ([GCController class]) { NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; !
[center addObserver:self selector:@selector(setupControllers:) name:GCControllerDidConnectNotification object:nil]; [center addObserver:self selector:@selector(setupControllers:) name:GCControllerDidDisconnectNotification object:nil]; !
[GCController startWirelessControllerDiscoveryWithCompletionHandler:^{...}]; }}
Finding Controllers
![Page 21: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/21.jpg)
-(BOOL)application:(UIApplication*)app didFinishLaunchingWithOptions:(NSDictionary*)dict { if ([GCController class]) { NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; !
[center addObserver:self selector:@selector(setupControllers:) name:GCControllerDidConnectNotification object:nil]; [center addObserver:self selector:@selector(setupControllers:) name:GCControllerDidDisconnectNotification object:nil]; !
[GCController startWirelessControllerDiscoveryWithCompletionHandler:^{...}]; }}
Finding Controllers
![Page 22: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/22.jpg)
Finding Controllers
- (void)setupControllers:(NSNotification *)notification { // Get array of connected controllers self.controllerArray = [GCController controllers]; !
if ([self.controllerArray count] > 0) // Found controllers ... }
![Page 23: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/23.jpg)
Finding Controllers
- (void)setupControllers:(NSNotification *)notification { // Get array of connected controllers self.controllerArray = [GCController controllers]; !
if ([self.controllerArray count] > 0) // Found controllers ... }
![Page 24: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/24.jpg)
Finding Controllers
- (void)setupControllers:(NSNotification *)notification { // Get array of connected controllers self.controllerArray = [GCController controllers]; !
if ([self.controllerArray count] > 0) // Found controllers ... }
![Page 25: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/25.jpg)
Finding Controllers
- (void)setupControllers:(NSNotification *)notification { // Get array of connected controllers self.controllerArray = [GCController controllers]; !
if ([self.controllerArray count] > 0) // Found controllers ... }
![Page 26: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/26.jpg)
Design GuidanceGraceful connecting and disconnecting
When connected • Move to controller-based input
• Remove onscreen virtual controls (including pause button)
• Set playerIndex to illuminate player indicator LEDs
When disconnecting • Pause gameplay
• Return to regular controls
![Page 27: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/27.jpg)
Design GuidanceTreat connected controller as intent to use
![Page 28: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/28.jpg)
YX B
A
Design GuidanceTreat connected controller as intent to use
![Page 29: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/29.jpg)
Design GuidanceTreat connected controller as intent to use
YES NO
Game controller detected. Do you want to use it?
YX B
A
![Page 30: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/30.jpg)
Design GuidanceTreat connected controller as intent to use
![Page 31: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/31.jpg)
Design GuidanceTreat connected controller as intent to use
YX B
A
![Page 32: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/32.jpg)
Reading Controller Input
![Page 33: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/33.jpg)
Design GuidanceFirst design for touch
Multi-touch and motion Game controllers
![Page 34: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/34.jpg)
Profiles
YX B
A
YX B
A
![Page 35: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/35.jpg)
Profiles
myController.gamepad
myController.extendedGamepad
myController.gamepad
YX B
A
YX B
A
![Page 36: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/36.jpg)
Gamepad Profile
Property Name Type
buttonA buttonBbuttonXbuttonY
GCControllerButtonInput
leftShoulder rightShoulder
GCControllerButtonInput
dpad GCControllerDirectionPad
leftThumbstick rightThumbstick
GCControllerDirectionPad
leftTrigger rightTrigger
GCControllerButtonInput
Face Buttons
![Page 37: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/37.jpg)
Gamepad Profile
Property Name Type
buttonA buttonBbuttonXbuttonY
GCControllerButtonInput
leftShoulder rightShoulder
GCControllerButtonInput
dpad GCControllerDirectionPad
leftThumbstick rightThumbstick
GCControllerDirectionPad
leftTrigger rightTrigger
GCControllerButtonInput
Left Shoulder Right Shoulder
![Page 38: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/38.jpg)
D-Pad
Gamepad Profile
Property Name Type
buttonA buttonBbuttonXbuttonY
GCControllerButtonInput
leftShoulder rightShoulder
GCControllerButtonInput
dpad GCControllerDirectionPad
leftThumbstick rightThumbstick
GCControllerDirectionPad
leftTrigger rightTrigger
GCControllerButtonInput
![Page 39: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/39.jpg)
ExtendedGamepad Profile
Property Name Type
buttonA buttonBbuttonXbuttonY
GCControllerButtonInput
leftShoulder rightShoulder
GCControllerButtonInput
dpad GCControllerDirectionPad
YX B
A
![Page 40: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/40.jpg)
ExtendedGamepad Profile
Property Name Type
buttonA buttonBbuttonXbuttonY
GCControllerButtonInput
leftShoulder rightShoulder
GCControllerButtonInput
dpad GCControllerDirectionPad
leftThumbstick rightThumbstick
GCControllerDirectionPad
YX B
A
Left Thumbstick Right Thumbstick
![Page 41: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/41.jpg)
L2 R2
Left Trigger Right Trigger
ExtendedGamepad Profile
Property Name Type
buttonA buttonBbuttonXbuttonY
GCControllerButtonInput
leftShoulder rightShoulder
GCControllerButtonInput
dpad GCControllerDirectionPad
leftThumbstick rightThumbstick
GCControllerDirectionPad
leftTrigger rightTrigger
GCControllerButtonInput
R2
R1L1
L2
![Page 42: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/42.jpg)
ExtendedGamepad Profile
Property Name Type
buttonA buttonBbuttonXbuttonY
GCControllerButtonInput
leftShoulder rightShoulder
GCControllerButtonInput
dpad GCControllerDirectionPad
leftThumbstick rightThumbstick
GCControllerDirectionPad
leftTrigger rightTrigger
GCControllerButtonInput
R2
R1L1
L2
![Page 43: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/43.jpg)
ExtendedGamepad Profile
Property Name Type
buttonA buttonBbuttonXbuttonY
GCControllerButtonInput
leftShoulder rightShoulder
GCControllerButtonInput
dpad GCControllerDirectionPad
leftThumbstick rightThumbstick
GCControllerDirectionPad
leftTrigger rightTrigger
GCControllerButtonInput
R2
R1L1
L2
![Page 44: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/44.jpg)
GCControllerButtonInput
Classic button state BOOL pressed; // digital
Buttons are also pressure-sensitive float value; // analog, 0.0 to 1.0
![Page 45: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/45.jpg)
GCControllerButtonInput
Classic button state BOOL pressed; // digital
Buttons are also pressure-sensitive float value; // analog, 0.0 to 1.0
![Page 46: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/46.jpg)
Design GuidanceObserve button conventions
A button—Primary action
B button—Secondary action
What are your game’s primary and secondary actions? • In-game (jump? shoot?)
• UI (accept, cancel)
YX B
A
![Page 47: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/47.jpg)
Design GuidanceObserve button conventions
A button—Primary action
B button—Secondary action
What are your game’s primary and secondary actions? • In-game (jump? shoot?)
• UI (accept, cancel)
YX B
A
YX B
A
![Page 48: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/48.jpg)
GCControllerDirectionPad
Treated as four buttons GCControllerButtonInput *up, *down, *left, *right;
Or as two axes GCControllerAxisInput *xAxis, *yAxis;
![Page 49: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/49.jpg)
GCControllerAxisInput
Measures movement along an axis float value; // -1.0 to +1.0, neutral is 0.0
Minimum range is unit circle
Automatic calibration
Automatic dead-zone handling
+1.0
-1.0
-1.0 +1.0
![Page 50: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/50.jpg)
Design GuidanceGroup logically-similar actions
YX B
A
![Page 51: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/51.jpg)
Design GuidanceGroup logically-similar actions
YX B
A
![Page 52: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/52.jpg)
Design GuidanceGroup logically-similar actions
YX B
A
![Page 53: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/53.jpg)
Design GuidanceGroup logically-similar actions
YX B
A
![Page 54: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/54.jpg)
YX B
A
Design GuidanceGroup logically-similar actions
X BA
![Page 55: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/55.jpg)
YX B
A
Design GuidanceGroup logically-similar actions
![Page 56: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/56.jpg)
YX B
A
Design GuidanceGroup logically-similar actions
![Page 57: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/57.jpg)
YX B
A
Design GuidanceGroup logically-similar actions
![Page 58: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/58.jpg)
YX B
A
YB
A
Design GuidanceGroup logically-similar actions
![Page 59: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/59.jpg)
Design GuidanceGroup logically-similar actions
YX B
A
![Page 60: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/60.jpg)
Design GuidanceGroup logically-similar actions
YX B
A
![Page 61: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/61.jpg)
Design GuidanceGroup logically-similar actions
YX B
A
![Page 62: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/62.jpg)
Reading Input—Polling
-(void)readControls {
// Weapons if (myController.gamepad.buttonA.pressed)
[self fireLasers]; if (myController.gamepad.buttonB.pressed)
[self fireMissilesAtRate:myController.gamepad.buttonB.value]; !
// Thrust [self applyThrust:myController.gamepad.dpad.yAxis.value]; !
// Camera if (myController.extendedGamepad) {
// this is an Extended controller GCControllerDirectionPad *r = myController.extendedGamepad.rightThumbstick; [self freeLookX:r.xAxis.value Y:r.yAxis.value];
...
![Page 63: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/63.jpg)
Reading Input—Polling
-(void)readControls {
// Weapons if (myController.gamepad.buttonA.pressed)
[self fireLasers]; if (myController.gamepad.buttonB.pressed)
[self fireMissilesAtRate:myController.gamepad.buttonB.value]; !
// Thrust [self applyThrust:myController.gamepad.dpad.yAxis.value]; !
// Camera if (myController.extendedGamepad) {
// this is an Extended controller GCControllerDirectionPad *r = myController.extendedGamepad.rightThumbstick; [self freeLookX:r.xAxis.value Y:r.yAxis.value];
...
![Page 64: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/64.jpg)
Reading Input—Polling
-(void)readControls {
// Weapons if (myController.gamepad.buttonA.pressed)
[self fireLasers]; if (myController.gamepad.buttonB.pressed)
[self fireMissilesAtRate:myController.gamepad.buttonB.value]; !
// Thrust [self applyThrust:myController.gamepad.dpad.yAxis.value]; !
// Camera if (myController.extendedGamepad) {
// this is an Extended controller GCControllerDirectionPad *r = myController.extendedGamepad.rightThumbstick; [self freeLookX:r.xAxis.value Y:r.yAxis.value];
...
![Page 65: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/65.jpg)
Reading Input—Polling
-(void)readControls {
// Weapons if (myController.gamepad.buttonA.pressed)
[self fireLasers]; if (myController.gamepad.buttonB.pressed)
[self fireMissilesAtRate:myController.gamepad.buttonB.value]; !
// Thrust [self applyThrust:myController.gamepad.dpad.yAxis.value]; !
// Camera if (myController.extendedGamepad) {
// this is an Extended controller GCControllerDirectionPad *r = myController.extendedGamepad.rightThumbstick; [self freeLookX:r.xAxis.value Y:r.yAxis.value];
...
![Page 66: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/66.jpg)
Reading Input—Polling
-(void)readControls {
// Weapons if (myController.gamepad.buttonA.pressed)
[self fireLasers]; if (myController.gamepad.buttonB.pressed)
[self fireMissilesAtRate:myController.gamepad.buttonB.value]; !
// Thrust [self applyThrust:myController.gamepad.dpad.yAxis.value]; !
// Camera if (myController.extendedGamepad) {
// this is an Extended controller GCControllerDirectionPad *r = myController.extendedGamepad.rightThumbstick; [self freeLookX:r.xAxis.value Y:r.yAxis.value];
...
![Page 67: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/67.jpg)
Reading Input—Polling
-(void)readControls {
// Weapons if (myController.gamepad.buttonA.pressed)
[self fireLasers]; if (myController.gamepad.buttonB.pressed)
[self fireMissilesAtRate:myController.gamepad.buttonB.value]; !
// Thrust [self applyThrust:myController.gamepad.dpad.yAxis.value]; !
// Camera if (myController.extendedGamepad) {
// this is an Extended controller GCControllerDirectionPad *r = myController.extendedGamepad.rightThumbstick; [self freeLookX:r.xAxis.value Y:r.yAxis.value];
...
![Page 68: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/68.jpg)
Reading Input—Polling
-(void)readControls {
// Weapons if (myController.gamepad.buttonA.pressed)
[self fireLasers]; if (myController.gamepad.buttonB.pressed)
[self fireMissilesAtRate:myController.gamepad.buttonB.value]; !
// Thrust [self applyThrust:myController.gamepad.dpad.yAxis.value]; !
// Camera if (myController.extendedGamepad) {
// this is an Extended controller GCControllerDirectionPad *r = myController.extendedGamepad.rightThumbstick; [self freeLookX:r.xAxis.value Y:r.yAxis.value];
...
![Page 69: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/69.jpg)
Reading Input—Events
Be notified when inputs change • Buttons
• Axes
• D-pad/thumbsticks
• Profiles
Register block as change handler
![Page 70: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/70.jpg)
Reading Input—Events
Value changed handlers • For analog changes myController.gamepad.buttonY.valueChangedHandler
!
Pressed changed handlers • For digital changes myController.gamepad.buttonY.pressedChangedHandler
![Page 71: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/71.jpg)
Reading Input—Events
Value changed handlers • For analog changes myController.gamepad.buttonY.valueChangedHandler
!
Pressed changed handlers • For digital changes myController.gamepad.buttonY.pressedChangedHandler
![Page 72: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/72.jpg)
myController.gamepad.buttonY.pressedChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed)
{ if (pressed)
// button pressed [self chargeSpeedBurst];
else // button released [self doSpeedBurst];
};
Reading Inputs—Events
![Page 73: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/73.jpg)
myController.gamepad.buttonY.pressedChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed)
{ if (pressed)
// button pressed [self chargeSpeedBurst];
else // button released [self doSpeedBurst];
};
Reading Inputs—Events
![Page 74: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/74.jpg)
myController.gamepad.buttonY.pressedChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed)
{ if (pressed)
// button pressed [self chargeSpeedBurst];
else // button released [self doSpeedBurst];
};
Reading Inputs—Events
![Page 75: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/75.jpg)
myController.gamepad.buttonY.pressedChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed)
{ if (pressed)
// button pressed [self chargeSpeedBurst];
else // button released [self doSpeedBurst];
};
Reading Inputs—Events
![Page 76: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/76.jpg)
Design GuidanceUse pressure-sensitivity with discernment
Don’t use “value” if merely pressing an input is what’s needed • Use “pressed” instead
Take advantage of pressure-sensitivity • D-pad—360 degree movement
• Face Buttons—Pass and shoot with varying speed in sports games
Tell player when using pressure-sensitivity
![Page 77: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/77.jpg)
Design GuidanceBe a good teacher
YX B
A
![Page 78: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/78.jpg)
Design GuidanceBe a good teacher
![Page 79: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/79.jpg)
Design GuidanceBe a good teacher
![Page 80: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/80.jpg)
Agenda
Overview
Finding controllers
Reading controller input
What’s new
Design guidance
![Page 81: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/81.jpg)
What’s New
![Page 82: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/82.jpg)
Forwarding
Use iPhone as wireless controller for another device
Works over Bluetooth or Wi-Fi
Both devices signed in to same iCloud account
![Page 83: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/83.jpg)
Forwarding
Use iPhone as wireless controller for another device
Works over Bluetooth or Wi-Fi
Both devices signed in to same iCloud account
![Page 84: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/84.jpg)
Forwarding
![Page 85: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/85.jpg)
Forwarding
![Page 86: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/86.jpg)
Forwarding
![Page 87: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/87.jpg)
Forwarding
![Page 88: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/88.jpg)
Forwarding
Controlling Leo’s Fortune
![Page 89: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/89.jpg)
Forwarding
iPhone discovered automatically in [GCController startWirelessControllerDiscoveryWithCompletionHandler:^{...}]
Appears as wireless controller to your game
![Page 90: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/90.jpg)
Motion Forwarding
Accelerometer and gyroscope data automatically forwarded
New profile @interface GCController : NSObject GCMotion *motion; ...
![Page 91: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/91.jpg)
Motion ForwardingGCMotion
@interface GCMotion : NSObject GCAcceleration gravity; GCAcceleration userAcceleration; GCQuaternion attitude; GCRotationRate rotationRate; ...
+Y
+X+Z
![Page 92: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/92.jpg)
Motion ForwardingGCAcceleration gravity
Vector which gravity is applying to device
Units are in G’s
Flat on table with screen up—(0, 0, -1)
!
typedef struct { double x, y, z; } GCAcceleration;
+Y
+X+Z
![Page 93: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/93.jpg)
Motion ForwardingGCAcceleration userAcceleration
Inertial acceleration seen by device
Excludes gravity
Units are in G’s
At rest: (0, 0, 0)
+Y
+X+Z
![Page 94: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/94.jpg)
Motion ForwardingGCQuaternion attitude
3D orientation of device • Yaw
• Pitch
• Roll
!
typedef struct { double x, y, z, w; } GCQuaternion;
+Y
+X+Z
![Page 95: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/95.jpg)
Motion ForwardingGCRotationRate rotationRate
Rate at which device is spinning
Units are in radians/second
!
typedef struct { double x, y, z; } GCRotationRate;
+Y
+X+Z
![Page 96: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/96.jpg)
Motion Forwarding
GCMotion *motionProfile = self.myController.motion; if (motionProfile) { // use controller’s motion profile } else { // use motion from device }
![Page 97: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/97.jpg)
Motion Forwarding
GCMotion *motionProfile = self.myController.motion; if (motionProfile) { // use controller’s motion profile } else { // use motion from device }
![Page 98: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/98.jpg)
Motion Forwarding
GCMotion *motionProfile = self.myController.motion; if (motionProfile) { // use controller’s motion profile } else { // use motion from device }
![Page 99: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/99.jpg)
Motion Forwarding
GCMotion *motionProfile = self.myController.motion; if (motionProfile) { // use controller’s motion profile } else { // use motion from device }
![Page 100: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/100.jpg)
Motion Forwarding
GCMotion *motionProfile = self.myController.motion; if (motionProfile) { // use controller’s motion profile } else { // use motion from device }
![Page 101: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/101.jpg)
+Y
+X+Z
Motion Forwarding
Motion axes move with device
Motion data will be jittery • Apply filter to smooth data
![Page 102: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/102.jpg)
Motion Forwarding
Motion axes move with device
Motion data will be jittery • Apply filter to smooth data
+Y +X
+Z
![Page 103: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/103.jpg)
Idle Timer
Prevents screen from turning off
iOS 8—Handled automatically
iOS 7—Handle yourself [[UIApplication sharedApplication] setIdleTimerDisabled:(BOOL)];
• Be careful
Motion apps should also manage their idle timer
![Page 104: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/104.jpg)
Additional Guidance
![Page 105: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/105.jpg)
Pause Button
Every controller has pause button
Treat as toggle
Handling required if support game controllers !
myController.controllerPausedHandler = ^(GCController *controller) { // Pause button pressed [self togglePauseResumeState]; };
![Page 106: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/106.jpg)
Pause Button
Every controller has pause button
Treat as toggle
Handling required if support game controllers !
myController.controllerPausedHandler = ^(GCController *controller) { // Pause button pressed [self togglePauseResumeState]; };
![Page 107: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/107.jpg)
Player Indicator LEDs
YX B
A
{
}
Always set for each controller your game uses if (self.myController.playerIndex == GCControllerPlayerIndexUnset) !
self.myController.playerIndex = 0; // Zero-based index
![Page 108: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/108.jpg)
Player Indicator LEDs
YX B
A
{
}
Always set for each controller your game uses if (self.myController.playerIndex == GCControllerPlayerIndexUnset) !
self.myController.playerIndex = 0; // Zero-based index
![Page 109: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/109.jpg)
Design GuidanceMultiple-controller games
Keep track of array of controllers • Set playerIndex for all controllers used
Consider which controller(s) can navigate menus
Determine whether game can proceed after a controller disconnects
![Page 110: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/110.jpg)
Design GuidanceMultiple-controller games
- (void)setupControllers:(NSNotification *)notification { ... for (GCController *c in self.myControllers) { if (c.playerIndex == GCControllerPlayerIndexUnset) { [self launchControllerPicker]; break; } } ... }
![Page 111: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/111.jpg)
Design GuidanceMultiple-controller games
- (void)setupControllers:(NSNotification *)notification { ... for (GCController *c in self.myControllers) { if (c.playerIndex == GCControllerPlayerIndexUnset) { [self launchControllerPicker]; break; } } ... }
![Page 112: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/112.jpg)
Design GuidanceMultiple-controller games
- (void)setupControllers:(NSNotification *)notification { ... for (GCController *c in self.myControllers) { if (c.playerIndex == GCControllerPlayerIndexUnset) { [self launchControllerPicker]; break; } } ... }
![Page 113: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/113.jpg)
Design GuidanceMultiple-controller games
- (void)setupControllers:(NSNotification *)notification { ... for (GCController *c in self.myControllers) { if (c.playerIndex == GCControllerPlayerIndexUnset) { [self launchControllerPicker]; break; } } ... }
![Page 114: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/114.jpg)
Design GuidanceRespond to game controller inputs early
Players instinctively press buttons upon game launch
Responding early tells players your game supports controllers • Splash screens
• Introductory cinematics
• Main menu—at the latest
![Page 115: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/115.jpg)
Design GuidanceRespond to game controller inputs early
![Page 116: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/116.jpg)
Design GuidanceRespond to game controller inputs early
![Page 117: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/117.jpg)
Design GuidanceRespond to game controller inputs early
![Page 118: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/118.jpg)
Design GuidanceMechanize UI for controllers
Support standalone controllers • Screen (touch) may not be
easily reachable
• Game input from controller only
YX B
A
![Page 119: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/119.jpg)
Summary
Overview
Finding controllers
Reading controller input
What’s new
Design guidance
![Page 120: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/120.jpg)
More Information
Allan SchafferGraphics and Game Technologies Evangelist [email protected]
Filip Iliescu Graphics and Game Technologies Evangelist [email protected]
Apple Developer Forums http://devforums.apple.com
![Page 121: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/121.jpg)
Related Sessions
• What's New in SpriteKit Pacific Heights Wednesday 2:00PM
• Best Practices for Building SpriteKit Games Pacific Heights Wednesday 3:15PM
• What's New in SceneKit Pacific Heights Thursday 10:15AM
• Building a Game with SceneKit Pacific Heights Thursday 11:30AM
• Graphics and Games Location Sunday 0:00PM
• Core OS Location Sunday 0:00PM
• Special Events Location Sunday 0:00PM
![Page 122: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/122.jpg)
Labs
• Game Controllers Lab Graphics and Games Lab B Friday 11:30AM
• Services Location Sunday 0:00PM
• Tools Location Sunday 0:00PM
• Media Location Sunday 0:00PM
• Graphics and Games Location Sunday 0:00PM
• Core OS Location Sunday 0:00PM
• Special Events Location Sunday 0:00PM
![Page 123: Designing for Game Controllers - Apple Inc.€¦ · Designing for Game Controllers Session 611 JJ Cwik Software Engineer Graphics and Games. Game Controllers. MFi Specification For](https://reader035.vdocuments.mx/reader035/viewer/2022070911/5fa5d407a5ad627aa915c419/html5/thumbnails/123.jpg)