Hey all. I took a look at a video that caught my attention(https://developer.apple.com/videos/play/wwdc2021/10081) and wish to use this for my ios and iPad game. However, the language used here is swift, and want to use either objective-c or c++. Did anyone here used this method shown is this video but without swift?
On-screen joystick(s) for iOS and iPadOS using Metal?
Hi CuriousAsking123
The GCVirtualController class is available from Objective-C. Here is a code snippet showing how to set it up.
#import <GameController/GameController.h>
// Assumes your class declares an instance variable named '_virtualController' with type GCVirtualController*
GCVirtualControllerConfiguration *configuration = [GCVirtualControllerConfiguration new];
configuration.elements = [NSSet setWithArray:@[
GCInputButtonA,
GCInputButtonB,
GCInputButtonX,
GCInputButtonY,
GCInputLeftShoulder,
GCInputLeftTrigger,
GCInputRightShoulder,
GCInputRightTrigger,
GCInputDirectionPad,
GCInputRightThumbstick
]];
_virtualController = [GCVirtualController virtualControllerWithConfiguration:configuration];
[_virtualController connectWithReplyHandler:^(NSError *error) {
if (error) { NSLog(@"%@", error); }
}];