GCDualSenseAdaptiveTrigger API set trigger mode not working

I'm trying to add support to PS5 DualSense controller. when I try to use the API from here: https://developer.apple.com/documentation/gamecontroller/gcdualsenseadaptivetrigger?language=objc None of the API works, am I missed anything? The code is like this:

			if ( [ controller.extendedGamepad isKindOfClass:[ GCDualSenseGamepad class ] ] )
			{
				GCDualSenseGamepad * dualSenseGamePad = ( GCDualSenseGamepad * )controller.extendedGamepad;

				auto funcSetEffectTrigger = []( TriggerEffectParams& params, GCDualSenseAdaptiveTrigger *trigger ) {
					if ( params.m_mode == TriggerEffectMode::Off )
					{
						[ trigger setModeOff ];
						NSLog(@"setModeOff trigger.mode:%d", trigger.mode );
					}
					else if ( params.m_mode == TriggerEffectMode::Feedback )
					{
						[ trigger setModeFeedbackWithStartPosition: 0.2f resistiveStrength: 0.5f ];
					}
					else if ( params.m_mode == TriggerEffectMode::Weapon )
					{
						[ trigger setModeWeaponWithStartPosition: 0.2f endPosition: 0.4f resistiveStrength: 0.5f ];
					}
					else if ( params.m_mode == TriggerEffectMode::Vibration )
					{
						[ trigger setModeVibrationWithStartPosition: position amplitude: amplitude frequency: frequency ];
					}
				};
				if ( L2 )
				{
					funcSetEffectTrigger( params, dualSenseGamePad.leftTrigger );
				}
				if ( R2 )
				{
					funcSetEffectTrigger( params, dualSenseGamePad.rightTrigger );
				}
			}

I've also tested to add "Game Controllers" capability to Target, still not working. Can't find anything else from the document or forums. I've no idea what need to do.

Just to verify the simplest issues aren’t in play, have you verified that your funcSetEffectTrigger lambda is being executed?

Yes, I've debugged it step by step, and checked the value one by one. One thing I've notice is that after the setModeWeaponWithStartPosition (or setModeFeedbackWithStartPosition), the mode is still 0 (GCDualSenseAdaptiveTriggerModeOff), I don't know if this is normal.

By the way:

  • MacOS: Sequoia 15.2
  • Chip: Apple M1 Ultra

If it metters.

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

I think something broke in GCController code on macOS. I downloaded the "Fox2" sample code from WWDC21, connected my DS4 controller via bluetooth, and ran the project; it registers the controller is connected and even sends haptic feedback to the controller when I use keyboard inputs, but doesn't get inputs back from the controller.

[Update] I just updated to 15.2 and it's working again. Maybe I should have just tried restarting the Mac first.

@WangHeng0301 Please attach your sample project to a Feedback Assistant report and share the FB number here.

GCDualSenseAdaptiveTrigger API set trigger mode not working
 
 
Q