SKUGCControllerController

Superclass:
NSObject
Declared In:
See Also:

Introduction

Not intended for you to create instances of this class but instead to be able to control controller related functions through the SKUtilities singleton. See the see also above.



Methods

-canPlayerControlNav:
-checkForChangedControllerState
-gamepadForPlayer:
-gamepadForVendor:
-setPlayerOne:

canPlayerControlNav:


-(BOOL)canPlayerControlNav:(GCControllerPlayerIndex)player; 
Discussion

Returns boolean answering whether a particular player is allowed to control navigation set via the flag validPlayerNav.

See Also


checkForChangedControllerState


-(void)checkForChangedControllerState; 
Discussion

Called automatically when a controller connects or disconnects, but can also be called manually if you want to.


gamepadForPlayer:


-(GCController*)gamepadForPlayer:(GCControllerPlayerIndex)player; 
Parameters
player

which player

Return Value

GCController object designated for the player.

Discussion

Finds the GCController object for a given player. Returns nil if not found.


gamepadForVendor:


-(GCController*)gamepadForVendor:(NSString*)vendor; 
Discussion

Returns the first GCController object found for a given vendor string. Returns nil if not found.


setPlayerOne:


-(void)setPlayerOne:(GCController*)controller; 
Parameters
controller

GCController object that should get set to player one.

Discussion

Allows you to set which controller is player one and then fills in the rest automatically. This is primarily intended for convenience on the AppleTV if you want to turn the Siri remote to player two and allow the gamepad to take over as P1.


Properties

controllerStates
navControllerState
playerControllers
validPlayerNav
view

controllerStates


@property (nonatomic,
    strong,
    readonly) NSArray<SKUGameControllerState*>* controllerStates; 
Discussion

Array with a designated controller state for each player. These are initialized and updated automatically.


navControllerState


@property (nonatomic,
    strong) SKUGameControllerState* navControllerState; 
Discussion

Used for access to the current controller state for navigation purposes. Internal.


playerControllers


@property (nonatomic,
    strong) NSMutableArray* playerControllers; 
Discussion

Array with controller objects in the order of players. Note that it's not readonly and is mutable, but do NOT change it. It's this way for internal reasons: it's only intended for you to read from this array.


validPlayerNav


@property (nonatomic) uint8_t validPlayerNav; 
Discussion

Flags determining which players are allowed to control navigation. Note that Siri Remote ALWAYS gets to control nav.

See Also


view


@property (nonatomic,
    weak) SKView* view; 
Discussion

Set automatically when setting the [SKUtilities setNavFocus] method on the scene itself or if you call [super didMoveToView] on an SKUScene. Note that this is only set if the gcController object has already been initialized (which happens automatically if you use SKUScene). If the view ever gets changed, you will need to update this property with the current view and call "checkForChangedControllerState" again (untested, but I think should work).