Any one got any idea?
I got a simplest sample here, followed the code from this video:
https://developer.apple.com/videos/play/wwdc2021/10081/
But still not working.
#import "AppDelegate.h"
#import <GameController/GameController.h>
@implementation AppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
// Insert code here to initialize your application
[ [ NSNotificationCenter defaultCenter ] addObserver:self selector:@selector( controllerDidConnect: ) name:GCControllerDidConnectNotification object:nil ];
[ [ NSNotificationCenter defaultCenter ] addObserver:self selector:@selector( controllerDidDisconnect: ) name:GCControllerDidDisconnectNotification object:nil ];
[ GCController startWirelessControllerDiscoveryWithCompletionHandler:^
{
NSLog( @"Finished finding controllers" );
} ];
}
-(void)controllerDidConnect:( NSNotification * )notification
{
GCController *controller = notification.object;
[ controller.extendedGamepad.buttonA setValueChangedHandler:^( GCControllerButtonInput * button, float value, BOOL pressed )
{
NSLog(@"controller Button A pressed.");
if ([[[GCController current] physicalInputProfile] isKindOfClass:[GCDualSenseGamepad class]])
{
GCDualSenseGamepad *dualSense = (GCDualSenseGamepad *)[[GCController current] physicalInputProfile];
GCDualSenseAdaptiveTrigger * rightTrigger = dualSense.rightTrigger;
[rightTrigger setModeFeedbackWithStartPosition:0 resistiveStrength:0.9];
}
} ];
[ controller.extendedGamepad.buttonB setValueChangedHandler:^( GCControllerButtonInput * button, float value, BOOL pressed )
{
NSLog(@"controller Button B pressed.");
if ([[[GCController current] physicalInputProfile] isKindOfClass:[GCDualSenseGamepad class]])
{
GCDualSenseGamepad *dualSense = (GCDualSenseGamepad *)[[GCController current] physicalInputProfile];
GCDualSenseAdaptiveTrigger * rightTrigger = dualSense.rightTrigger;
[ rightTrigger setModeVibrationWithStartPosition:0 amplitude:0.5 frequency:0.03 ];
}
} ];
[ controller.extendedGamepad.buttonX setValueChangedHandler:^( GCControllerButtonInput * button, float value, BOOL pressed )
{
NSLog(@"controller Button X pressed.");
if ([[[GCController current] physicalInputProfile] isKindOfClass:[GCDualSenseGamepad class]])
{
GCDualSenseGamepad *dualSense = (GCDualSenseGamepad *)[[GCController current] physicalInputProfile];
GCDualSenseAdaptiveTrigger * rightTrigger = dualSense.rightTrigger;
[ rightTrigger setModeOff ];
}
} ];
}
-(void)controllerDidDisconnect:( NSNotification * )notification
{
}
@end