@@ -398,59 +398,7 @@ namespace UnityEngine.InputSystem
398398 /// generic <see cref="Joystick"/> or as just a plain <see cref="HID.HID"/> instead.
399399 /// </remarks>
400400 /// <example>
401- /// <code>
402- ///
403- /// using UnityEngine;
404- /// using UnityEngine.InputSystem;
405- ///
406- /// public class Example : MonoBehaviour
407- /// {
408- /// void Start()
409- /// {
410- /// // Print all connected gamepads
411- /// Debug.Log(string.Join("\n", Gamepad.all));
412- /// }
413- ///
414- /// void Update()
415- /// {
416- /// var gamepad = Gamepad.current;
417- ///
418- /// // No gamepad connected.
419- /// if (gamepad == null)
420- /// {
421- /// return;
422- /// }
423- ///
424- /// // Check if "Button North" was pressed this frame
425- /// if (gamepad.buttonNorth.wasPressedThisFrame)
426- /// {
427- /// Debug.Log("Button North was pressed");
428- /// }
429- ///
430- /// // Check if the button control is being continuously actuated and read its value
431- /// if (gamepad.rightTrigger.IsActuated())
432- /// {
433- /// Debug.Log("Right trigger value: " + gamepad.rightTrigger.ReadValue());
434- /// }
435- ///
436- /// // Read left stick value and perform some code based on the value
437- /// Vector2 move = gamepad.leftStick.ReadValue();
438- /// {
439- /// // Do 'move' code here
440- /// }
441- ///
442- /// // Creating haptic feedback while "Button South" is pressed and stopping it when released.
443- /// if (gamepad.buttonSouth.wasPressedThisFrame)
444- /// {
445- /// gamepad.SetMotorSpeeds(0.2f, 1.0f);
446- ///
447- /// } else if (gamepad.buttonSouth.wasReleasedThisFrame)
448- /// {
449- /// gamepad.ResetHaptics();
450- /// }
451- /// }
452- /// }
453- /// </code>
401+ /// <code source="../../DocCodeSamples.Tests/GamepadExample.cs" />
454402 /// </example>
455403 /// <seealso cref="all"/>
456404 /// <seealso cref="current"/>
@@ -751,23 +699,23 @@ public override void MakeCurrent()
751699 current = this ;
752700 }
753701
702+ /// <inheritdoc cref="InputDevice.OnAdded"/>
754703 /// <summary>
755704 /// Called when the gamepad is added to the system.
756705 /// </summary>
757706 /// <remarks>
758- /// <inheritdoc cref="InputDevice.OnAdded()"/>
759707 /// It will also add the gamepad to the list of <see cref="all"/> gamepads.
760708 /// </remarks>
761709 protected override void OnAdded ( )
762710 {
763711 ArrayHelpers . AppendWithCapacity ( ref s_Gamepads , ref s_GamepadCount , this ) ;
764712 }
765713
714+ /// <inheritdoc cref="InputDevice.OnRemoved"/>
766715 /// <summary>
767716 /// Called when the gamepad is removed from the system.
768717 /// </summary>
769718 /// <remarks>
770- /// <inheritdoc cref="InputDevice.OnRemoved()"/>
771719 /// It will also remove the gamepad from the list of <see cref="all"/> gamepads.
772720 /// </remarks>
773721 protected override void OnRemoved ( )
@@ -788,45 +736,50 @@ protected override void OnRemoved()
788736
789737 /// <summary>
790738 /// Pause rumble effects on the gamepad.
791- /// <inheritdoc cref="DualMotorRumble.PauseHaptics"/>
792739 /// </summary>
793740 /// <remarks>
794- /// Resume with <see cref="ResumeHaptics"/>.
795- /// <inheritdoc cref="DualMotorRumble.PauseHaptics"/>
741+ /// It will pause rumble effects and save the current motor speeds.
742+ /// Resume from those speeds with <see cref="ResumeHaptics"/>.
743+ /// Some devices such as <see cref="DualShock.DualSenseGamepadHID"/> and
744+ /// <see cref="DualShock.DualShock4GamepadHID"/> can also set the LED color when this method is called.
796745 /// </remarks>
797746 /// <seealso cref="IDualMotorRumble"/>
798747 /// <example>
799- /// <inheritdoc cref="SetMotorSpeeds "/>
748+ /// <code source="../../DocCodeSamples.Tests/GamepadHapticsExample.cs "/>
800749 /// </example>
801750 public virtual void PauseHaptics ( )
802751 {
803752 m_Rumble . PauseHaptics ( this ) ;
804753 }
805754
806755 /// <summary>
807- /// Resume rumble affects on the gamepad that have been paused with <see cref="PauseHaptics"/> .
756+ /// Resume rumble effects on the gamepad.
808757 /// </summary>
809758 /// <remarks>
810- /// <inheritdoc cref="DualMotorRumble.ResumeHaptics"/>
759+ /// It will resume rumble effects from the previously set motor speeds, such as motor speeds saved when
760+ /// calling <see cref="PauseHaptics"/>.
761+ /// Some devices such as <see cref="DualShock.DualSenseGamepadHID"/> and
762+ /// <see cref="DualShock.DualShock4GamepadHID"/> can also set the LED color when this method is called.
811763 /// </remarks>
812764 /// <seealso cref="IDualMotorRumble"/>
813765 /// <example>
814- /// <inheritdoc cref="SetMotorSpeeds "/>
766+ /// <code source="../../DocCodeSamples.Tests/GamepadHapticsExample.cs "/>
815767 /// </example>
816768 public virtual void ResumeHaptics ( )
817769 {
818770 m_Rumble . ResumeHaptics ( this ) ;
819771 }
820772
821773 /// <summary>
822- /// Reset rumble effects on the gamepad.
774+ /// Resets rumble effects on the gamepad by setting motor speeds to 0 .
823775 /// </summary>
824776 /// <remarks>
825- /// <inheritdoc cref="DualMotorRumble.ResetHaptics"/>
777+ /// Some devices such as <see cref="DualShock.DualSenseGamepadHID"/> and
778+ /// <see cref="DualShock.DualShock4GamepadHID"/> can also set the LED color when this method is called.
826779 /// </remarks>
827780 /// <seealso cref="IDualMotorRumble"/>
828781 /// <example>
829- /// <inheritdoc cref="SetMotorSpeeds "/>
782+ /// <code source="../../DocCodeSamples.Tests/GamepadHapticsExample.cs "/>
830783 /// </example>
831784 public virtual void ResetHaptics ( )
832785 {
@@ -835,53 +788,7 @@ public virtual void ResetHaptics()
835788
836789 /// <inheritdoc />
837790 /// <example>
838- /// <code>
839- /// using UnityEngine;
840- /// using UnityEngine.InputSystem;
841- ///
842- /// public class GamepadHapticsExample : MonoBehaviour
843- /// {
844- /// bool hapticsArePaused = false;
845- ///
846- /// void Update() {
847- /// var gamepad = Gamepad.current;
848- ///
849- /// // No gamepad connected, no need to continue.
850- /// if (gamepad == null)
851- /// return;
852- ///
853- /// float leftTrigger = gamepad.leftTrigger.ReadValue();
854- /// float rightTrigger = gamepad.rightTrigger.ReadValue();
855- ///
856- /// // Only set motor speeds if haptics were not paused and if trigger is actuated.
857- /// // Both triggers must be actuated past 0.2f to start haptics.
858- /// if (!hapticsArePaused &&
859- /// (gamepad.leftTrigger.IsActuated() || gamepad.rightTrigger.IsActuated()))
860- /// gamepad.SetMotorSpeeds(
861- /// leftTrigger < 0.2f ? 0.0f : leftTrigger,
862- /// rightTrigger < 0.2f ? 0.0f : rightTrigger);
863- ///
864- /// // Toggle haptics "playback" when "Button South" is pressed.
865- /// // Notice that if you release the triggers after pausing,
866- /// // and press the button again, haptics will resume.
867- /// if (gamepad.buttonSouth.wasPressedThisFrame)
868- /// {
869- /// if (hapticsArePaused)
870- /// gamepad.ResumeHaptics();
871- /// else
872- /// gamepad.PauseHaptics();
873- ///
874- /// hapticsArePaused = !hapticsArePaused;
875- /// }
876- ///
877- /// // Notice that if you release the triggers after pausing,
878- /// // and press the Start button, haptics will be reset.
879- /// if (gamepad.startButton.wasPressedThisFrame)
880- /// gamepad.ResetHaptics();
881- /// }
882- /// }
883- ///
884- /// </code>
791+ /// <code source="../../DocCodeSamples.Tests/GamepadHapticsExample.cs"/>
885792 /// </example>
886793 public virtual void SetMotorSpeeds ( float lowFrequency , float highFrequency )
887794 {
0 commit comments