-
Notifications
You must be signed in to change notification settings - Fork 41
Implementing in Objective C
I've tested most of the functionality of the framework, but if I missed anything please let me know at [email protected].
A very basic Objective C sample project is included that demonstrates the setup and key method calls for both Peripheral and Central modes.
In Build Settings, the Embedded Content Contains Swift Code setting must be set to YES.
-
Notifications must be implemented using the string version of the notification name, rather than the global constants that are offered when using Swift, for example:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(foundService:) name:@"VgcPeripheralDidConnectNotification" object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(foundService:) name:@"VgcPeripheralDidDisconnectNotification" object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(foundService:) name:@"VgcPeripheralFoundService" object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(foundService:) name:@"VgcPeripheralLostService" object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(foundService:) name:@"VgcPeripheralFoundService" object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(foundService:) name:@"VgcPeripheralDidResetBrowser" object:nil];
-
Setting up a Peripheral device is done as follows (appIdentifier should be changed to something appropriate to your project name):
[VgcManager startAs:AppRolePeripheral appIdentifier:@"vgc"]; DeviceInfo * deviceInfo = [[DeviceInfo alloc] initWithDeviceUID:@"" vendorName:@"" attachedToDevice:NO profileType:ProfileTypeExtendedGamepad controllerType:ControllerTypeSoftware supportsMotion:YES]; [[VgcManager peripheral] setDeviceInfo:deviceInfo];
-
Search for available Centrals and Bridges as follows:
[[VgcManager peripheral] browseForServices];
-
Send a element value to a Central or Bridge:
Element * rightTrigger = [[VgcManager elements] rightTrigger]; rightTrigger.value = @1.0; [[VgcManager peripheral] sendElementState:rightTrigger];
Setting up as a Central is done as follows (appIdentifier should be changed to something appropriate to your project name):
[VgcManager startAs:AppRoleCentral appIdentifier:@"vgc"];
Setting up as a Bridge is done as follows:
[VgcManager startAs:AppRoleBridge appIdentifier:@"vgc"];