From 088479d9d2ee0cd0d874033632ee282e63aacdfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Freire?= Date: Wed, 4 Dec 2024 11:29:12 +0200 Subject: [PATCH 01/10] Do documentation improvements to Gamepad.cs Addresses most issues to be solved in Docs Quality Week 2024 December --- .../InputSystem/Devices/Gamepad.cs | 268 +++++++++++++----- 1 file changed, 200 insertions(+), 68 deletions(-) diff --git a/Packages/com.unity.inputsystem/InputSystem/Devices/Gamepad.cs b/Packages/com.unity.inputsystem/InputSystem/Devices/Gamepad.cs index 1a6a98c1e9..9a48a7d02a 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Devices/Gamepad.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Devices/Gamepad.cs @@ -102,7 +102,6 @@ public struct GamepadState : IInputStateTypeInfo /// /// Button bit mask. /// - /// Button bit mask. /// /// /// @@ -132,20 +131,18 @@ public struct GamepadState : IInputStateTypeInfo public uint buttons; /// - /// Left stick position. Each axis goes from -1 to 1 with - /// 0 being center position. + /// Left stick position. /// - /// Left stick position. + /// Each axis goes from -1 to 1 with 0 being center position. /// [InputControl(layout = "Stick", usage = "Primary2DMotion", processors = "stickDeadzone", displayName = "Left Stick", shortDisplayName = "LS")] [FieldOffset(4)] public Vector2 leftStick; /// - /// Right stick position. Each axis from -1 to 1 with - /// 0 being center position. + /// Right stick position. /// - /// Right stick position. + /// Each axis from -1 to 1 with 0 being center position. /// [InputControl(layout = "Stick", usage = "Secondary2DMotion", processors = "stickDeadzone", displayName = "Right Stick", shortDisplayName = "RS")] [FieldOffset(12)] @@ -154,18 +151,18 @@ public struct GamepadState : IInputStateTypeInfo ////REVIEW: should left and right trigger get deadzones? /// - /// Position of the left trigger. Goes from 0 (not pressed) to 1 (fully pressed). + /// Position of the left trigger. /// - /// Position of left trigger. + /// Goes from 0 (not pressed) to 1 (fully pressed). /// [InputControl(layout = "Button", format = "FLT", usage = "SecondaryTrigger", displayName = "Left Trigger", shortDisplayName = "LT")] [FieldOffset(20)] public float leftTrigger; /// - /// Position of the right trigger. Goes from 0 (not pressed) to 1 (fully pressed). + /// Position of the right trigger. /// - /// Position of right trigger. + /// Goes from 0 (not pressed) to 1 (fully pressed). /// [InputControl(layout = "Button", format = "FLT", usage = "SecondaryTrigger", displayName = "Right Trigger", shortDisplayName = "RT")] [FieldOffset(24)] @@ -174,7 +171,7 @@ public struct GamepadState : IInputStateTypeInfo /// /// State format tag for GamepadState. /// - /// Returns "GPAD". + /// Returns "GPAD". public FourCC format => Format; /// @@ -402,106 +399,146 @@ namespace UnityEngine.InputSystem /// /// /// - /// // Show all gamepads in the system. - /// Debug.Log(string.Join("\n", Gamepad.all)); /// - /// // Check whether the X button on the current gamepad is pressed. - /// if (Gamepad.current.xButton.wasPressedThisFrame) - /// Debug.Log("Pressed"); + /// using UnityEngine; + /// using UnityEngine.InputSystem; /// - /// // Rumble the left motor on the current gamepad slightly. - /// Gamepad.current.SetMotorSpeeds(0.2f, 0. + /// public class Example : MonoBehaviour + /// { + /// void Start() + /// { + /// // Print all connected gamepads + /// Debug.Log(string.Join("\n", Gamepad.all)); + /// } + /// + /// void Update() + /// { + /// var gamepad = Gamepad.current; + /// + /// // No gamepad connected. + /// if (gamepad == null) + /// { + /// return; + /// } + /// + /// // Check if "Button North" was pressed this frame + /// if (gamepad.buttonNorth.wasPressedThisFrame) + /// { + /// Debug.Log("Button North was pressed"); + /// } + /// + /// // Check if the button control is being continuously actuated and read its value + /// if (gamepad.rightTrigger.IsActuated()) + /// { + /// Debug.Log("Right trigger value: " + gamepad.rightTrigger.ReadValue()); + /// } + /// + /// // Read left stick value and perform some code based on the value + /// Vector2 move = gamepad.leftStick.ReadValue(); + /// { + /// // Do 'move' code here + /// } + /// + /// // Creating haptic feedback while "Button South" is pressed and stopping it when released. + /// if (gamepad.buttonSouth.wasPressedThisFrame) + /// { + /// gamepad.SetMotorSpeeds(0.2f, 1.0f); + /// + /// } else if (gamepad.buttonSouth.wasReleasedThisFrame) + /// { + /// gamepad.ResetHaptics(); + /// } + /// } + /// } /// /// /// + /// + /// + /// + /// + /// + /// [InputControlLayout(stateType = typeof(GamepadState), isGenericTypeOfDevice = true)] public class Gamepad : InputDevice, IDualMotorRumble { /// /// The left face button of the gamepad. /// - /// Control representing the X/Square face button. /// - /// On an Xbox controller, this is the X button and on the PS4 controller, this is the - /// square button. + /// Control representing the X/Square face button. + /// On an Xbox controller, this is the and on the PS4 controller, this is the + /// . /// - /// - /// public ButtonControl buttonWest { get; protected set; } /// /// The top face button of the gamepad. /// - /// Control representing the Y/Triangle face button. /// - /// On an Xbox controller, this is the Y button and on the PS4 controller, this is the - /// triangle button. + /// Control representing the Y/Triangle face button. + /// On an Xbox controller, this is the and on the PS4 controller, this is the + /// . /// - /// - /// public ButtonControl buttonNorth { get; protected set; } /// /// The bottom face button of the gamepad. /// - /// Control representing the A/Cross face button. /// - /// On an Xbox controller, this is the A button and on the PS4 controller, this is the - /// cross button. + /// Control representing the A/Cross face button. + /// On an Xbox controller, this is the and on the PS4 controller, this is the + /// . /// - /// - /// public ButtonControl buttonSouth { get; protected set; } /// /// The right face button of the gamepad. /// - /// Control representing the B/Circle face button. /// - /// On an Xbox controller, this is the B button and on the PS4 controller, this is the - /// circle button. + /// Control representing the B/Circle face button. + /// On an Xbox controller, this is the and on the PS4 controller, this is the + /// . /// - /// - /// public ButtonControl buttonEast { get; protected set; } /// /// The button that gets triggered when is pressed down. /// - /// Control representing a click with the left stick. + /// Control representing a click with the left stick. public ButtonControl leftStickButton { get; protected set; } /// /// The button that gets triggered when is pressed down. /// - /// Control representing a click with the right stick. + /// Control representing a click with the right stick. public ButtonControl rightStickButton { get; protected set; } /// /// The right button in the middle section of the gamepad (called "menu" on Xbox /// controllers and "options" on PS4 controllers). /// - /// Control representing the right button in midsection. + /// Control representing the right button in midsection. public ButtonControl startButton { get; protected set; } /// /// The left button in the middle section of the gamepad (called "view" on Xbox /// controllers and "share" on PS4 controllers). /// - /// Control representing the left button in midsection. + /// Control representing the left button in midsection. public ButtonControl selectButton { get; protected set; } /// /// The 4-way directional pad on the gamepad. /// - /// Control representing the d-pad. + /// Control representing the d-pad. public DpadControl dpad { get; protected set; } /// /// The left shoulder/bumper button that sits on top of . /// - /// Control representing the left shoulder button. /// + /// Control representing the left shoulder button. /// On Xbox controllers, this is usually called "left bumper" whereas on PS4 /// controllers, this button is referred to as "L1". /// @@ -510,8 +547,8 @@ public class Gamepad : InputDevice, IDualMotorRumble /// /// The right shoulder/bumper button that sits on top of . /// - /// Control representing the right shoulder button. /// + /// Control representing the right shoulder button. /// On Xbox controllers, this is usually called "right bumper" whereas on PS4 /// controllers, this button is referred to as "R1". /// @@ -520,20 +557,19 @@ public class Gamepad : InputDevice, IDualMotorRumble /// /// The left thumbstick on the gamepad. /// - /// Control representing the left thumbstick. + /// Control representing the left thumbstick. public StickControl leftStick { get; protected set; } /// /// The right thumbstick on the gamepad. /// - /// Control representing the right thumbstick. + /// Control representing the right thumbstick. public StickControl rightStick { get; protected set; } /// /// The left trigger button sitting below . /// - /// Control representing the left trigger button. - /// + /// Control representing the left trigger button. /// On PS4 controllers, this button is referred to as "L2". /// public ButtonControl leftTrigger { get; protected set; } @@ -541,8 +577,7 @@ public class Gamepad : InputDevice, IDualMotorRumble /// /// The right trigger button sitting below . /// - /// Control representing the right trigger button. - /// + /// Control representing the right trigger button. /// On PS4 controllers, this button is referred to as "R2". /// public ButtonControl rightTrigger { get; protected set; } @@ -550,49 +585,41 @@ public class Gamepad : InputDevice, IDualMotorRumble /// /// Same as . Xbox-style alias. /// - /// Same as . public ButtonControl aButton => buttonSouth; /// /// Same as . Xbox-style alias. /// - /// Same as . public ButtonControl bButton => buttonEast; /// /// Same as Xbox-style alias. /// - /// Same as . public ButtonControl xButton => buttonWest; /// /// Same as . Xbox-style alias. /// - /// Same as . public ButtonControl yButton => buttonNorth; /// /// Same as . PS4-style alias. /// - /// Same as . public ButtonControl triangleButton => buttonNorth; /// /// Same as . PS4-style alias. /// - /// Same as . public ButtonControl squareButton => buttonWest; /// /// Same as . PS4-style alias. /// - /// Same as . public ButtonControl circleButton => buttonEast; /// /// Same as . PS4-style alias. /// - /// Same as . public ButtonControl crossButton => buttonSouth; /// @@ -637,28 +664,29 @@ public ButtonControl this[GamepadButton button] /// /// When added, a device is automatically made current (see ), so /// when connecting a gamepad, it will also become current. After that, it will only become current again - /// when input change on non-noisy controls (see ) is received. + /// when input change on non-noisy controls (see ) is received. It will also + /// be available once is queried. /// /// For local multiplayer scenarios (or whenever there are multiple gamepads that need to be usable /// in a concurrent fashion), it is not recommended to rely on this property. Instead, it is recommended /// to use or . /// - /// - /// public static Gamepad current { get; private set; } /// /// A list of gamepads currently connected to the system. /// - /// All currently connected gamepads. /// + /// Returns all currently connected gamepads. + /// /// Does not cause GC allocation. /// /// Do not hold on to the value returned by this getter but rather query it whenever /// you need it. Whenever the gamepad setup changes, the value returned by this getter /// is invalidated. + /// + /// Alternately, if you want a single gamepad, you can use for example. /// - /// public new static ReadOnlyArray all => new ReadOnlyArray(s_Gamepads, 0, s_GamepadCount); /// @@ -695,7 +723,29 @@ protected override void FinishSetup() /// /// /// This is called automatically by the system when there is input on a gamepad. + /// + /// More remarks are available in when it comes to devices with + /// controls. /// + /// + /// + /// using System; + /// using UnityEngine; + /// using UnityEngine.InputSystem; + /// + /// public class MakeCurrentGamepadExample : MonoBehaviour + /// { + /// void Update() + /// { + /// /// Make the first Gamepad always the current one + /// if (Gamepad.all.Count > 0) + /// { + /// Gamepad.all[0].MakeCurrent(); + /// } + /// } + /// } + /// + /// public override void MakeCurrent() { base.MakeCurrent(); @@ -705,6 +755,10 @@ public override void MakeCurrent() /// /// Called when the gamepad is added to the system. /// + /// + /// + /// It will also add the gamepad to the list of gamepads. + /// protected override void OnAdded() { ArrayHelpers.AppendWithCapacity(ref s_Gamepads, ref s_GamepadCount, this); @@ -713,6 +767,10 @@ protected override void OnAdded() /// /// Called when the gamepad is removed from the system. /// + /// + /// + /// It will also remove the gamepad from the list of gamepads. + /// protected override void OnRemoved() { if (current == this) @@ -730,9 +788,19 @@ protected override void OnRemoved() } /// - /// Pause rumble effects on the gamepad. Resume with . + /// Pause rumble effects on the gamepad. + /// /// + /// + /// Resume with . + /// + /// /// + /// + /// + /// + /// + /// public virtual void PauseHaptics() { m_Rumble.PauseHaptics(this); @@ -741,23 +809,87 @@ public virtual void PauseHaptics() /// /// Resume rumble affects on the gamepad that have been paused with . /// + /// + /// + /// /// + /// + /// + /// + /// + /// public virtual void ResumeHaptics() { m_Rumble.ResumeHaptics(this); } /// - /// Reset rumble effects on the gamepad. Puts the gamepad rumble motors back into their - /// default state. + /// Reset rumble effects on the gamepad. /// + /// + /// + /// /// + /// + /// + /// + /// + /// public virtual void ResetHaptics() { m_Rumble.ResetHaptics(this); } /// + /// + /// + /// using UnityEngine; + /// using UnityEngine.InputSystem; + /// + /// public class GamepadHapticsExample : MonoBehaviour + /// { + /// bool hapticsArePaused = false; + /// + /// void Update() { + /// var gamepad = Gamepad.current; + /// + /// // No gamepad connected, no need to continue. + /// if (gamepad == null) + /// return; + /// + /// float leftTrigger = gamepad.leftTrigger.ReadValue(); + /// float rightTrigger = gamepad.rightTrigger.ReadValue(); + /// + /// // Only set motor speeds if haptics were not paused and if trigger is actuated. + /// // Both triggers must be actuated past 0.2f to start haptics. + /// if (!hapticsArePaused && + /// (gamepad.leftTrigger.IsActuated() || gamepad.rightTrigger.IsActuated())) + /// gamepad.SetMotorSpeeds( + /// leftTrigger < 0.2f ? 0.0f : leftTrigger, + /// rightTrigger < 0.2f ? 0.0f : rightTrigger); + /// + /// // Toggle haptics "playback" when "Button South" is pressed. + /// // Notice that if you release the triggers after pausing, + /// // and press the button again, haptics will resume. + /// if (gamepad.buttonSouth.wasPressedThisFrame) + /// { + /// if (hapticsArePaused) + /// gamepad.ResumeHaptics(); + /// else + /// gamepad.PauseHaptics(); + /// + /// hapticsArePaused = !hapticsArePaused; + /// } + /// + /// // Notice that if you release the triggers after pausing, + /// // and press the Start button, haptics will be reset. + /// if (gamepad.startButton.wasPressedThisFrame) + /// gamepad.ResetHaptics(); + /// } + /// } + /// + /// + /// public virtual void SetMotorSpeeds(float lowFrequency, float highFrequency) { m_Rumble.SetMotorSpeeds(this, lowFrequency, highFrequency); From 8d6b31e0da59b8bc71b9177eccf9f508a7b9de43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Freire?= Date: Wed, 4 Dec 2024 11:32:18 +0200 Subject: [PATCH 02/10] Make DualMotorRumble.cs more consistent based on Gamepad.cs changes. --- .../Devices/Haptics/DualMotorRumble.cs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Packages/com.unity.inputsystem/InputSystem/Devices/Haptics/DualMotorRumble.cs b/Packages/com.unity.inputsystem/InputSystem/Devices/Haptics/DualMotorRumble.cs index 9a4d0ddba9..4f0048c4ca 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Devices/Haptics/DualMotorRumble.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Devices/Haptics/DualMotorRumble.cs @@ -39,9 +39,13 @@ internal struct DualMotorRumble || !Mathf.Approximately(highFrequencyMotorSpeed, 0f); /// - /// Reset motor speeds to zero but retain current values for - /// and . + /// Reset motor speeds to zero. /// + /// + /// Sets both motor speeds to zero while retaining the current values for + /// and . + /// It will only send the command if is true. + /// /// Device to send command to. /// is null. public void PauseHaptics(InputDevice device) @@ -60,6 +64,9 @@ public void PauseHaptics(InputDevice device) /// Resume haptics by setting motor speeds to the current values of /// and . /// + /// + /// It will only set motor speeds if is true + /// /// Device to send command to. /// is null. public void ResumeHaptics(InputDevice device) @@ -74,9 +81,12 @@ public void ResumeHaptics(InputDevice device) } /// - /// Reset haptics by setting both and - /// to zero. + /// Reset haptics by setting motor speeds to zero. /// + /// + /// Sets and to zero. + /// It will only set motor speeds if is true. + /// /// Device to send command to. /// is null. public void ResetHaptics(InputDevice device) From 6de42bbad4db02a2de00f0fdc826f6fcc61bfedb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Freire?= Date: Wed, 4 Dec 2024 13:37:44 +0200 Subject: [PATCH 03/10] Right stick remarks fix based on review --- Packages/com.unity.inputsystem/InputSystem/Devices/Gamepad.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Packages/com.unity.inputsystem/InputSystem/Devices/Gamepad.cs b/Packages/com.unity.inputsystem/InputSystem/Devices/Gamepad.cs index 9a48a7d02a..dcef95e815 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Devices/Gamepad.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Devices/Gamepad.cs @@ -142,7 +142,7 @@ public struct GamepadState : IInputStateTypeInfo /// /// Right stick position. /// - /// Each axis from -1 to 1 with 0 being center position. + /// Each axis goes from -1 to 1 with 0 being center position. /// [InputControl(layout = "Stick", usage = "Secondary2DMotion", processors = "stickDeadzone", displayName = "Right Stick", shortDisplayName = "RS")] [FieldOffset(12)] From 3231e5925394fac2dff5d51b6361a997ed4663d3 Mon Sep 17 00:00:00 2001 From: Ben Pitt Date: Wed, 4 Dec 2024 14:26:30 +0000 Subject: [PATCH 04/10] Lengthened some doc fields to meet minimum length requirements --- .../InputSystem/Devices/Gamepad.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Packages/com.unity.inputsystem/InputSystem/Devices/Gamepad.cs b/Packages/com.unity.inputsystem/InputSystem/Devices/Gamepad.cs index dcef95e815..6434064797 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Devices/Gamepad.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Devices/Gamepad.cs @@ -131,18 +131,18 @@ public struct GamepadState : IInputStateTypeInfo public uint buttons; /// - /// Left stick position. + /// A 2D vector representing the current position of the left stick on a gamepad. /// - /// Each axis goes from -1 to 1 with 0 being center position. + /// Each axis of the 2D vector's range goes from -1 to 1. 0 represents the stick in its center position, and -1 or 1 represents the the stick pushed to its extent in each direction along the axis. /// [InputControl(layout = "Stick", usage = "Primary2DMotion", processors = "stickDeadzone", displayName = "Left Stick", shortDisplayName = "LS")] [FieldOffset(4)] public Vector2 leftStick; /// - /// Right stick position. + /// A 2D vector representing the current position of the right stick on a gamepad. /// - /// Each axis goes from -1 to 1 with 0 being center position. + /// Each axis of the 2D vector's range goes from -1 to 1. 0 represents the stick in its center position, and -1 or 1 represents the the stick pushed to its extent in each direction along the axis. /// [InputControl(layout = "Stick", usage = "Secondary2DMotion", processors = "stickDeadzone", displayName = "Right Stick", shortDisplayName = "RS")] [FieldOffset(12)] @@ -151,18 +151,18 @@ public struct GamepadState : IInputStateTypeInfo ////REVIEW: should left and right trigger get deadzones? /// - /// Position of the left trigger. + /// The current position of the left trigger on a gamepad. /// - /// Goes from 0 (not pressed) to 1 (fully pressed). + /// The value's range goes from 0 to 1, where 0 represents the trigger not pressed at all, and 1 represents the trigger in its fully pressed position. /// [InputControl(layout = "Button", format = "FLT", usage = "SecondaryTrigger", displayName = "Left Trigger", shortDisplayName = "LT")] [FieldOffset(20)] public float leftTrigger; /// - /// Position of the right trigger. + /// The current position of the right trigger on a gamepad. /// - /// Goes from 0 (not pressed) to 1 (fully pressed). + /// The value's range goes from 0 to 1, where 0 represents the trigger not pressed at all, and 1 represents the trigger in its fully pressed position. /// [InputControl(layout = "Button", format = "FLT", usage = "SecondaryTrigger", displayName = "Right Trigger", shortDisplayName = "RT")] [FieldOffset(24)] From 9ccb42c635c4eabbb862207fe4f8230f766c4f85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Freire?= Date: Wed, 4 Dec 2024 16:52:08 +0200 Subject: [PATCH 05/10] Add some more small fixes Will follow up on errors next. --- .../com.unity.inputsystem/InputSystem/Devices/Gamepad.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Packages/com.unity.inputsystem/InputSystem/Devices/Gamepad.cs b/Packages/com.unity.inputsystem/InputSystem/Devices/Gamepad.cs index 6434064797..1eb6e1b748 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Devices/Gamepad.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Devices/Gamepad.cs @@ -171,7 +171,7 @@ public struct GamepadState : IInputStateTypeInfo /// /// State format tag for GamepadState. /// - /// Returns "GPAD". + /// Holds the format tag for GamepadState ("GPAD") public FourCC format => Format; /// @@ -396,7 +396,7 @@ namespace UnityEngine.InputSystem /// to be mapped correctly and consistently. If, based on the set of supported devices available /// to the input system, this cannot be guaranteed, a given device is usually represented as a /// generic or as just a plain instead. - /// + /// /// /// /// @@ -452,7 +452,6 @@ namespace UnityEngine.InputSystem /// } /// /// - /// /// /// /// From 16b4eed111f84f78b474cfb74eda3fbd82cd8f37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Freire?= Date: Wed, 4 Dec 2024 17:04:41 +0200 Subject: [PATCH 06/10] WIP Attempt to fix CI errors --- .../com.unity.inputsystem/InputSystem/Devices/Gamepad.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Packages/com.unity.inputsystem/InputSystem/Devices/Gamepad.cs b/Packages/com.unity.inputsystem/InputSystem/Devices/Gamepad.cs index 1eb6e1b748..871ffc7062 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Devices/Gamepad.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Devices/Gamepad.cs @@ -796,9 +796,7 @@ protected override void OnRemoved() /// /// /// - /// /// - /// /// public virtual void PauseHaptics() { @@ -813,9 +811,7 @@ public virtual void PauseHaptics() /// /// /// - /// /// - /// /// public virtual void ResumeHaptics() { @@ -830,9 +826,7 @@ public virtual void ResumeHaptics() /// /// /// - /// /// - /// /// public virtual void ResetHaptics() { From 0c1d43c2514e23557cb9c1d53e2ab7972fd91f6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Freire?= Date: Thu, 5 Dec 2024 16:03:09 +0200 Subject: [PATCH 07/10] Fix PVP errors and improve examples reusability can only be used as a top-level xml tag. Since it is not possible to inherit code examples, I went ahead with the guidelines for API Package Documentation. --- .../DocCodeSamples.Tests/GamepadExample.cs | 50 +++++++ .../GamepadExample.cs.meta | 3 + .../GamepadHapticsExample.cs | 45 ++++++ .../GamepadHapticsExample.cs.meta | 3 + .../InputSystem/Devices/Gamepad.cs | 131 +++--------------- 5 files changed, 120 insertions(+), 112 deletions(-) create mode 100644 Packages/com.unity.inputsystem/DocCodeSamples.Tests/GamepadExample.cs create mode 100644 Packages/com.unity.inputsystem/DocCodeSamples.Tests/GamepadExample.cs.meta create mode 100644 Packages/com.unity.inputsystem/DocCodeSamples.Tests/GamepadHapticsExample.cs create mode 100644 Packages/com.unity.inputsystem/DocCodeSamples.Tests/GamepadHapticsExample.cs.meta diff --git a/Packages/com.unity.inputsystem/DocCodeSamples.Tests/GamepadExample.cs b/Packages/com.unity.inputsystem/DocCodeSamples.Tests/GamepadExample.cs new file mode 100644 index 0000000000..7b4fd6cb62 --- /dev/null +++ b/Packages/com.unity.inputsystem/DocCodeSamples.Tests/GamepadExample.cs @@ -0,0 +1,50 @@ +using UnityEngine; +using UnityEngine.InputSystem; + +internal class GamepadExample : MonoBehaviour +{ + void Start() + { + // Print all connected gamepads + Debug.Log(string.Join("\n", Gamepad.all)); + } + + void Update() + { + var gamepad = Gamepad.current; + + // No gamepad connected. + if (gamepad == null) + { + return; + } + + // Check if "Button North" was pressed this frame + if (gamepad.buttonNorth.wasPressedThisFrame) + { + Debug.Log("Button North was pressed"); + } + + // Check if the button control is being continuously actuated and read its value + if (gamepad.rightTrigger.IsActuated()) + { + Debug.Log("Right trigger value: " + gamepad.rightTrigger.ReadValue()); + } + + // Read left stick value and perform some code based on the value + Vector2 move = gamepad.leftStick.ReadValue(); + { + // Do 'move' code here + } + + // Creating haptic feedback while "Button South" is pressed and stopping it when released. + if (gamepad.buttonSouth.wasPressedThisFrame) + { + gamepad.SetMotorSpeeds(0.2f, 1.0f); + } + else if (gamepad.buttonSouth.wasReleasedThisFrame) + { + gamepad.ResetHaptics(); + } + } +} diff --git a/Packages/com.unity.inputsystem/DocCodeSamples.Tests/GamepadExample.cs.meta b/Packages/com.unity.inputsystem/DocCodeSamples.Tests/GamepadExample.cs.meta new file mode 100644 index 0000000000..2b7c0d0a09 --- /dev/null +++ b/Packages/com.unity.inputsystem/DocCodeSamples.Tests/GamepadExample.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 898672c95e554f2fb492125d78b11af2 +timeCreated: 1733401360 \ No newline at end of file diff --git a/Packages/com.unity.inputsystem/DocCodeSamples.Tests/GamepadHapticsExample.cs b/Packages/com.unity.inputsystem/DocCodeSamples.Tests/GamepadHapticsExample.cs new file mode 100644 index 0000000000..b2840520c0 --- /dev/null +++ b/Packages/com.unity.inputsystem/DocCodeSamples.Tests/GamepadHapticsExample.cs @@ -0,0 +1,45 @@ +using UnityEngine; +using UnityEngine.InputSystem; + +internal class GamepadHapticsExample : MonoBehaviour +{ + bool hapticsArePaused = false; + + void Update() + { + var gamepad = Gamepad.current; + + // No gamepad connected, no need to continue. + if (gamepad == null) + return; + + float leftTrigger = gamepad.leftTrigger.ReadValue(); + float rightTrigger = gamepad.rightTrigger.ReadValue(); + + // Only set motor speeds if haptics were not paused and if trigger is actuated. + // Both triggers must be actuated past 0.2f to start haptics. + if (!hapticsArePaused && + (gamepad.leftTrigger.IsActuated() || gamepad.rightTrigger.IsActuated())) + gamepad.SetMotorSpeeds( + leftTrigger < 0.2f ? 0.0f : leftTrigger, + rightTrigger < 0.2f ? 0.0f : rightTrigger); + + // Toggle haptics "playback" when "Button South" is pressed. + // Notice that if you release the triggers after pausing, + // and press the button again, haptics will resume. + if (gamepad.buttonSouth.wasPressedThisFrame) + { + if (hapticsArePaused) + gamepad.ResumeHaptics(); + else + gamepad.PauseHaptics(); + + hapticsArePaused = !hapticsArePaused; + } + + // Notice that if you release the triggers after pausing, + // and press the Start button, haptics will be reset. + if (gamepad.startButton.wasPressedThisFrame) + gamepad.ResetHaptics(); + } +} diff --git a/Packages/com.unity.inputsystem/DocCodeSamples.Tests/GamepadHapticsExample.cs.meta b/Packages/com.unity.inputsystem/DocCodeSamples.Tests/GamepadHapticsExample.cs.meta new file mode 100644 index 0000000000..42a614007b --- /dev/null +++ b/Packages/com.unity.inputsystem/DocCodeSamples.Tests/GamepadHapticsExample.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 3bbc200178984676a2dcb977a2fe3bae +timeCreated: 1733400387 \ No newline at end of file diff --git a/Packages/com.unity.inputsystem/InputSystem/Devices/Gamepad.cs b/Packages/com.unity.inputsystem/InputSystem/Devices/Gamepad.cs index 871ffc7062..3b732e4d49 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Devices/Gamepad.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Devices/Gamepad.cs @@ -398,59 +398,7 @@ namespace UnityEngine.InputSystem /// generic or as just a plain instead. /// /// - /// - /// - /// using UnityEngine; - /// using UnityEngine.InputSystem; - /// - /// public class Example : MonoBehaviour - /// { - /// void Start() - /// { - /// // Print all connected gamepads - /// Debug.Log(string.Join("\n", Gamepad.all)); - /// } - /// - /// void Update() - /// { - /// var gamepad = Gamepad.current; - /// - /// // No gamepad connected. - /// if (gamepad == null) - /// { - /// return; - /// } - /// - /// // Check if "Button North" was pressed this frame - /// if (gamepad.buttonNorth.wasPressedThisFrame) - /// { - /// Debug.Log("Button North was pressed"); - /// } - /// - /// // Check if the button control is being continuously actuated and read its value - /// if (gamepad.rightTrigger.IsActuated()) - /// { - /// Debug.Log("Right trigger value: " + gamepad.rightTrigger.ReadValue()); - /// } - /// - /// // Read left stick value and perform some code based on the value - /// Vector2 move = gamepad.leftStick.ReadValue(); - /// { - /// // Do 'move' code here - /// } - /// - /// // Creating haptic feedback while "Button South" is pressed and stopping it when released. - /// if (gamepad.buttonSouth.wasPressedThisFrame) - /// { - /// gamepad.SetMotorSpeeds(0.2f, 1.0f); - /// - /// } else if (gamepad.buttonSouth.wasReleasedThisFrame) - /// { - /// gamepad.ResetHaptics(); - /// } - /// } - /// } - /// + /// /// /// /// @@ -751,11 +699,11 @@ public override void MakeCurrent() current = this; } + /// /// /// Called when the gamepad is added to the system. /// /// - /// /// It will also add the gamepad to the list of gamepads. /// protected override void OnAdded() @@ -763,11 +711,11 @@ protected override void OnAdded() ArrayHelpers.AppendWithCapacity(ref s_Gamepads, ref s_GamepadCount, this); } + /// /// /// Called when the gamepad is removed from the system. /// /// - /// /// It will also remove the gamepad from the list of gamepads. /// protected override void OnRemoved() @@ -788,15 +736,16 @@ protected override void OnRemoved() /// /// Pause rumble effects on the gamepad. - /// /// /// - /// Resume with . - /// + /// It will pause rumble effects and save the current motor speeds. + /// Resume from those speeds with . + /// Some devices such as and + /// can also set the LED color when this method is called. /// /// /// - /// + /// /// public virtual void PauseHaptics() { @@ -804,14 +753,17 @@ public virtual void PauseHaptics() } /// - /// Resume rumble affects on the gamepad that have been paused with . + /// Resume rumble effects on the gamepad. /// /// - /// + /// It will resume rumble effects from the previously set motor speeds, such as motor speeds saved when + /// calling . + /// Some devices such as and + /// can also set the LED color when this method is called. /// /// /// - /// + /// /// public virtual void ResumeHaptics() { @@ -819,14 +771,15 @@ public virtual void ResumeHaptics() } /// - /// Reset rumble effects on the gamepad. + /// Resets rumble effects on the gamepad by setting motor speeds to 0. /// /// - /// + /// Some devices such as and + /// can also set the LED color when this method is called. /// /// /// - /// + /// /// public virtual void ResetHaptics() { @@ -835,53 +788,7 @@ public virtual void ResetHaptics() /// /// - /// - /// using UnityEngine; - /// using UnityEngine.InputSystem; - /// - /// public class GamepadHapticsExample : MonoBehaviour - /// { - /// bool hapticsArePaused = false; - /// - /// void Update() { - /// var gamepad = Gamepad.current; - /// - /// // No gamepad connected, no need to continue. - /// if (gamepad == null) - /// return; - /// - /// float leftTrigger = gamepad.leftTrigger.ReadValue(); - /// float rightTrigger = gamepad.rightTrigger.ReadValue(); - /// - /// // Only set motor speeds if haptics were not paused and if trigger is actuated. - /// // Both triggers must be actuated past 0.2f to start haptics. - /// if (!hapticsArePaused && - /// (gamepad.leftTrigger.IsActuated() || gamepad.rightTrigger.IsActuated())) - /// gamepad.SetMotorSpeeds( - /// leftTrigger < 0.2f ? 0.0f : leftTrigger, - /// rightTrigger < 0.2f ? 0.0f : rightTrigger); - /// - /// // Toggle haptics "playback" when "Button South" is pressed. - /// // Notice that if you release the triggers after pausing, - /// // and press the button again, haptics will resume. - /// if (gamepad.buttonSouth.wasPressedThisFrame) - /// { - /// if (hapticsArePaused) - /// gamepad.ResumeHaptics(); - /// else - /// gamepad.PauseHaptics(); - /// - /// hapticsArePaused = !hapticsArePaused; - /// } - /// - /// // Notice that if you release the triggers after pausing, - /// // and press the Start button, haptics will be reset. - /// if (gamepad.startButton.wasPressedThisFrame) - /// gamepad.ResetHaptics(); - /// } - /// } - /// - /// + /// /// public virtual void SetMotorSpeeds(float lowFrequency, float highFrequency) { From 2cc1362f11fdccce4f1adca6c6bde19348536b78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Freire?= Date: Thu, 5 Dec 2024 16:09:42 +0200 Subject: [PATCH 08/10] Improvements based on PR review --- .../InputSystem/Devices/Gamepad.cs | 14 ++++++++++---- .../InputSystem/Devices/Haptics/DualMotorRumble.cs | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Packages/com.unity.inputsystem/InputSystem/Devices/Gamepad.cs b/Packages/com.unity.inputsystem/InputSystem/Devices/Gamepad.cs index 3b732e4d49..eed0d2e8c1 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Devices/Gamepad.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Devices/Gamepad.cs @@ -142,7 +142,9 @@ public struct GamepadState : IInputStateTypeInfo /// /// A 2D vector representing the current position of the right stick on a gamepad. /// - /// Each axis of the 2D vector's range goes from -1 to 1. 0 represents the stick in its center position, and -1 or 1 represents the the stick pushed to its extent in each direction along the axis. + /// Each axis of the 2D vector's range goes from -1 to 1. + /// 0 represents the stick in its center position. + /// -1 or 1 represents the stick pushed to its extent in each direction along the axis. /// [InputControl(layout = "Stick", usage = "Secondary2DMotion", processors = "stickDeadzone", displayName = "Right Stick", shortDisplayName = "RS")] [FieldOffset(12)] @@ -153,7 +155,9 @@ public struct GamepadState : IInputStateTypeInfo /// /// The current position of the left trigger on a gamepad. /// - /// The value's range goes from 0 to 1, where 0 represents the trigger not pressed at all, and 1 represents the trigger in its fully pressed position. + /// The value's range goes from 0 to 1. + /// 0 represents the trigger in its neutral position. + /// 1 represents the trigger in its fully pressed position. /// [InputControl(layout = "Button", format = "FLT", usage = "SecondaryTrigger", displayName = "Left Trigger", shortDisplayName = "LT")] [FieldOffset(20)] @@ -162,7 +166,9 @@ public struct GamepadState : IInputStateTypeInfo /// /// The current position of the right trigger on a gamepad. /// - /// The value's range goes from 0 to 1, where 0 represents the trigger not pressed at all, and 1 represents the trigger in its fully pressed position. + /// The value's range goes from 0 to 1. + /// 0 represents the trigger in its neutral position. + /// 1 represents the trigger in its fully pressed position. /// [InputControl(layout = "Button", format = "FLT", usage = "SecondaryTrigger", displayName = "Right Trigger", shortDisplayName = "RT")] [FieldOffset(24)] @@ -632,7 +638,7 @@ public ButtonControl this[GamepadButton button] /// you need it. Whenever the gamepad setup changes, the value returned by this getter /// is invalidated. /// - /// Alternately, if you want a single gamepad, you can use for example. + /// Alternately, for querying a single gamepad, you can use for example. /// public new static ReadOnlyArray all => new ReadOnlyArray(s_Gamepads, 0, s_GamepadCount); diff --git a/Packages/com.unity.inputsystem/InputSystem/Devices/Haptics/DualMotorRumble.cs b/Packages/com.unity.inputsystem/InputSystem/Devices/Haptics/DualMotorRumble.cs index 4f0048c4ca..c54a0f4c01 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Devices/Haptics/DualMotorRumble.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Devices/Haptics/DualMotorRumble.cs @@ -39,7 +39,7 @@ internal struct DualMotorRumble || !Mathf.Approximately(highFrequencyMotorSpeed, 0f); /// - /// Reset motor speeds to zero. + /// Stops haptics by setting motor speeds to zero. /// /// /// Sets both motor speeds to zero while retaining the current values for From 73d92d54c2b3b3593ccea16a95e0d2cd85506176 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Freire?= Date: Thu, 5 Dec 2024 17:45:58 +0200 Subject: [PATCH 09/10] Add namespace and missing files, and improve comment --- .../DocCodeSamples.Tests.meta | 8 ++ .../DocCodeSamples.asmdef | 16 ++++ .../DocCodeSamples.asmdef.meta | 7 ++ .../DocCodeSamples.Tests/GamepadExample.cs | 73 +++++++++--------- .../GamepadHapticsExample.cs | 75 ++++++++++--------- 5 files changed, 108 insertions(+), 71 deletions(-) create mode 100644 Packages/com.unity.inputsystem/DocCodeSamples.Tests.meta create mode 100644 Packages/com.unity.inputsystem/DocCodeSamples.Tests/DocCodeSamples.asmdef create mode 100644 Packages/com.unity.inputsystem/DocCodeSamples.Tests/DocCodeSamples.asmdef.meta diff --git a/Packages/com.unity.inputsystem/DocCodeSamples.Tests.meta b/Packages/com.unity.inputsystem/DocCodeSamples.Tests.meta new file mode 100644 index 0000000000..b137e3ae9b --- /dev/null +++ b/Packages/com.unity.inputsystem/DocCodeSamples.Tests.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c0f26b555bfc14351a9f8ec342fd6ae8 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.unity.inputsystem/DocCodeSamples.Tests/DocCodeSamples.asmdef b/Packages/com.unity.inputsystem/DocCodeSamples.Tests/DocCodeSamples.asmdef new file mode 100644 index 0000000000..180bbcadf0 --- /dev/null +++ b/Packages/com.unity.inputsystem/DocCodeSamples.Tests/DocCodeSamples.asmdef @@ -0,0 +1,16 @@ +{ + "name": "Unity.InputSystem.DocCodeSamples", + "rootNamespace": "", + "references": [ + "GUID:75469ad4d38634e559750d17036d5f7c" + ], + "includePlatforms": [], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": true, + "precompiledReferences": [], + "autoReferenced": false, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/Packages/com.unity.inputsystem/DocCodeSamples.Tests/DocCodeSamples.asmdef.meta b/Packages/com.unity.inputsystem/DocCodeSamples.Tests/DocCodeSamples.asmdef.meta new file mode 100644 index 0000000000..213c7c30d8 --- /dev/null +++ b/Packages/com.unity.inputsystem/DocCodeSamples.Tests/DocCodeSamples.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 41b01d3964f844d8b43923c18b3a9a6f +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.unity.inputsystem/DocCodeSamples.Tests/GamepadExample.cs b/Packages/com.unity.inputsystem/DocCodeSamples.Tests/GamepadExample.cs index 7b4fd6cb62..1ba384dd31 100644 --- a/Packages/com.unity.inputsystem/DocCodeSamples.Tests/GamepadExample.cs +++ b/Packages/com.unity.inputsystem/DocCodeSamples.Tests/GamepadExample.cs @@ -1,50 +1,53 @@ using UnityEngine; using UnityEngine.InputSystem; -internal class GamepadExample : MonoBehaviour +namespace DocCodeSamples.Tests { - void Start() + internal class GamepadExample : MonoBehaviour { - // Print all connected gamepads - Debug.Log(string.Join("\n", Gamepad.all)); - } - - void Update() - { - var gamepad = Gamepad.current; - - // No gamepad connected. - if (gamepad == null) + void Start() { - return; + // Print all connected gamepads + Debug.Log(string.Join("\n", Gamepad.all)); } - // Check if "Button North" was pressed this frame - if (gamepad.buttonNorth.wasPressedThisFrame) + void Update() { - Debug.Log("Button North was pressed"); - } + var gamepad = Gamepad.current; - // Check if the button control is being continuously actuated and read its value - if (gamepad.rightTrigger.IsActuated()) - { - Debug.Log("Right trigger value: " + gamepad.rightTrigger.ReadValue()); - } + // No gamepad connected. + if (gamepad == null) + { + return; + } - // Read left stick value and perform some code based on the value - Vector2 move = gamepad.leftStick.ReadValue(); - { - // Do 'move' code here - } + // Check if "Button North" was pressed this frame + if (gamepad.buttonNorth.wasPressedThisFrame) + { + Debug.Log("Button North was pressed"); + } - // Creating haptic feedback while "Button South" is pressed and stopping it when released. - if (gamepad.buttonSouth.wasPressedThisFrame) - { - gamepad.SetMotorSpeeds(0.2f, 1.0f); - } - else if (gamepad.buttonSouth.wasReleasedThisFrame) - { - gamepad.ResetHaptics(); + // Check if the button control is being continuously actuated and read its value + if (gamepad.rightTrigger.IsActuated()) + { + Debug.Log("Right trigger value: " + gamepad.rightTrigger.ReadValue()); + } + + // Read left stick value and perform some code based on the value + Vector2 move = gamepad.leftStick.ReadValue(); + { + // Use the Vector2 move for the game logic here + } + + // Creating haptic feedback while "Button South" is pressed and stopping it when released. + if (gamepad.buttonSouth.wasPressedThisFrame) + { + gamepad.SetMotorSpeeds(0.2f, 1.0f); + } + else if (gamepad.buttonSouth.wasReleasedThisFrame) + { + gamepad.ResetHaptics(); + } } } } diff --git a/Packages/com.unity.inputsystem/DocCodeSamples.Tests/GamepadHapticsExample.cs b/Packages/com.unity.inputsystem/DocCodeSamples.Tests/GamepadHapticsExample.cs index b2840520c0..b1c414641b 100644 --- a/Packages/com.unity.inputsystem/DocCodeSamples.Tests/GamepadHapticsExample.cs +++ b/Packages/com.unity.inputsystem/DocCodeSamples.Tests/GamepadHapticsExample.cs @@ -1,45 +1,48 @@ using UnityEngine; using UnityEngine.InputSystem; -internal class GamepadHapticsExample : MonoBehaviour +namespace DocCodeSamples.Tests { - bool hapticsArePaused = false; - - void Update() + internal class GamepadHapticsExample : MonoBehaviour { - var gamepad = Gamepad.current; - - // No gamepad connected, no need to continue. - if (gamepad == null) - return; - - float leftTrigger = gamepad.leftTrigger.ReadValue(); - float rightTrigger = gamepad.rightTrigger.ReadValue(); - - // Only set motor speeds if haptics were not paused and if trigger is actuated. - // Both triggers must be actuated past 0.2f to start haptics. - if (!hapticsArePaused && - (gamepad.leftTrigger.IsActuated() || gamepad.rightTrigger.IsActuated())) - gamepad.SetMotorSpeeds( - leftTrigger < 0.2f ? 0.0f : leftTrigger, - rightTrigger < 0.2f ? 0.0f : rightTrigger); - - // Toggle haptics "playback" when "Button South" is pressed. - // Notice that if you release the triggers after pausing, - // and press the button again, haptics will resume. - if (gamepad.buttonSouth.wasPressedThisFrame) - { - if (hapticsArePaused) - gamepad.ResumeHaptics(); - else - gamepad.PauseHaptics(); + bool hapticsArePaused = false; - hapticsArePaused = !hapticsArePaused; + void Update() + { + var gamepad = Gamepad.current; + + // No gamepad connected, no need to continue. + if (gamepad == null) + return; + + float leftTrigger = gamepad.leftTrigger.ReadValue(); + float rightTrigger = gamepad.rightTrigger.ReadValue(); + + // Only set motor speeds if haptics were not paused and if trigger is actuated. + // Both triggers must be actuated past 0.2f to start haptics. + if (!hapticsArePaused && + (gamepad.leftTrigger.IsActuated() || gamepad.rightTrigger.IsActuated())) + gamepad.SetMotorSpeeds( + leftTrigger < 0.2f ? 0.0f : leftTrigger, + rightTrigger < 0.2f ? 0.0f : rightTrigger); + + // Toggle haptics "playback" when "Button South" is pressed. + // Notice that if you release the triggers after pausing, + // and press the button again, haptics will resume. + if (gamepad.buttonSouth.wasPressedThisFrame) + { + if (hapticsArePaused) + gamepad.ResumeHaptics(); + else + gamepad.PauseHaptics(); + + hapticsArePaused = !hapticsArePaused; + } + + // Notice that if you release the triggers after pausing, + // and press the Start button, haptics will be reset. + if (gamepad.startButton.wasPressedThisFrame) + gamepad.ResetHaptics(); } - - // Notice that if you release the triggers after pausing, - // and press the Start button, haptics will be reset. - if (gamepad.startButton.wasPressedThisFrame) - gamepad.ResetHaptics(); } } From 5b93549127bd25c2df8a55937247b17d4ad55bec Mon Sep 17 00:00:00 2001 From: Ben Pitt Date: Fri, 6 Dec 2024 10:25:22 +0000 Subject: [PATCH 10/10] added more detail for OnAdded and OnRemoved docs --- .../com.unity.inputsystem/InputSystem/Devices/Gamepad.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Packages/com.unity.inputsystem/InputSystem/Devices/Gamepad.cs b/Packages/com.unity.inputsystem/InputSystem/Devices/Gamepad.cs index eed0d2e8c1..3841c4d723 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Devices/Gamepad.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Devices/Gamepad.cs @@ -707,10 +707,10 @@ public override void MakeCurrent() /// /// - /// Called when the gamepad is added to the system. + /// Called when a gamepad is added to the system. /// /// - /// It will also add the gamepad to the list of gamepads. + /// Override this method if you want to do additional processing when a gamepad becomes connected. After this method is called, the gamepad is automatically added to the list of gamepads. /// protected override void OnAdded() { @@ -722,7 +722,7 @@ protected override void OnAdded() /// Called when the gamepad is removed from the system. /// /// - /// It will also remove the gamepad from the list of gamepads. + /// Override this method if you want to do additional processing when a gamepad becomes disconnected. After this method is called, the gamepad is automatically removed from the list of gamepads. /// protected override void OnRemoved() {