Untitled

mail@pastecode.io avatar
unknown
c_cpp
2 years ago
3.1 kB
2
Indexable
Never
ifdef PLATFORM_PS5
#if PLATFORM_PS5
	{
		FPS5TriggerEffectProperty RightTrigger( FPS5TriggerEffectProperty::TriggerMask::Right );
		FPS5TriggerEffectProperty LeftTrigger( FPS5TriggerEffectProperty::TriggerMask::Left );
		TArray< uint8 > StrengthArray;
		StrengthArray.Init( 0, 10 );

		FRobinFancyControllerTriggerResistanceObject* BestResistOption = nullptr;

		if( TriggerResistanceObjects.IsValidIndex( 0 ) )
		{
			BestResistOption = &TriggerResistanceObjects[ 0 ];
			for( FRobinFancyControllerTriggerResistanceObject& NextObject : TriggerResistanceObjects )
			{
				if( NextObject.Object &&
					( ( NextObject.Active && NextObject.PriorityLevel >= BestResistOption->PriorityLevel ) || ( !BestResistOption->Active && NextObject.Active ) ) )
				{
					BestResistOption = &NextObject;
				}
			}

			if( BestResistOption && BestResistOption->Object && BestResistOption->Active )
			{
				uint8 FeedbackStrength = BestResistOption->Strength;
				// test

				StrengthArray.Empty();
				StrengthArray.Init( FeedbackStrength, 10 );

				if( BestResistOption->Initial )
				{
					if( StrengthArray.IsValidIndex( 0 ) )
					{
						StrengthArray[ 0 ] = FeedbackStrength;
					}
				}

				if( BestResistOption->TargetTrigger == ERobinFancyControllerTargetTrigger::Right || BestResistOption->TargetTrigger == ERobinFancyControllerTargetTrigger::Both )
				{
					RightTrigger.SetFeedback( StrengthArray );
					GetInputInterface()->SetDeviceProperty( GetControllerId(), &RightTrigger );
				}
				if( BestResistOption->TargetTrigger == ERobinFancyControllerTargetTrigger::Left || BestResistOption->TargetTrigger == ERobinFancyControllerTargetTrigger::Both )
				{
					LeftTrigger.SetFeedback( StrengthArray );
					GetInputInterface()->SetDeviceProperty( GetControllerId(), &LeftTrigger );
				}
			}
			else
			{
				TriggerResistanceObjects.Empty();
			}
		}
		else
		{
			StrengthArray.Empty();
			StrengthArray.Init( 0, 10 );
			RightTrigger.SetFeedback( StrengthArray );
			LeftTrigger.SetFeedback( StrengthArray );
			GetInputInterface()->SetDeviceProperty( GetControllerId(), &RightTrigger );
			GetInputInterface()->SetDeviceProperty( GetControllerId(), &LeftTrigger );
		}
	}

	// Color
	FRobinFancyControllerColorChangeObject* BestColorOption = nullptr;
	if( ColorChangingObjects.IsValidIndex( 0 ) )
	{
		BestColorOption = &ColorChangingObjects[ 0 ];
		for( FRobinFancyControllerColorChangeObject& Next : ColorChangingObjects )
		{
			if( ( Next.Active && Next.PriorityLevel >= BestColorOption->PriorityLevel ) || ( !BestColorOption->Active && Next.Active ) )
			{
				BestColorOption = &Next;
			}
		}
		if( BestColorOption && BestColorOption->Object && BestColorOption->Active )
		{
			FColor const Color = BestColorOption->Color.ToFColor( true );
			GetInputInterface()->SetLightColor( GetControllerId(), Color );
		}
		else
		{
			GetInputInterface()->ResetLightColor( GetControllerId() );
			ColorChangingObjects.Empty();
		}
	}
	else
	{
		GetInputInterface()->ResetLightColor( GetControllerId() );
	}
#endif
#endif