Skip to content

Commit f7d9f60

Browse files
authored
DOCS: Improve Mouse & ButtonControl API docs (#2080)
1 parent 4d1137f commit f7d9f60

File tree

2 files changed

+44
-26
lines changed

2 files changed

+44
-26
lines changed

Packages/com.unity.inputsystem/InputSystem/Controls/ButtonControl.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ public class ButtonControl : AxisControl
3434
/// <summary>
3535
/// The minimum value the button has to reach for it to be considered pressed.
3636
/// </summary>
37-
/// <value>Button press threshold.</value>
3837
/// <remarks>
3938
/// The button is considered pressed, if it has a value equal to or greater than
4039
/// this value.
@@ -64,7 +63,6 @@ public class ButtonControl : AxisControl
6463
/// <summary>
6564
/// Return <see cref="pressPoint"/> if set, otherwise return <see cref="InputSettings.defaultButtonPressPoint"/>.
6665
/// </summary>
67-
/// <value>Effective value to use for press point thresholds.</value>
6866
public float pressPointOrDefault => pressPoint > 0 ? pressPoint : s_GlobalDefaultButtonPressPoint;
6967

7068
/// <summary>
@@ -106,7 +104,7 @@ public ButtonControl()
106104
/// <remarks>
107105
/// The default format for the control is <see cref="InputStateBlock.FormatBit"/>.
108106
/// The control's minimum value is set to 0 and the maximum value to 1.
109-
/// See <see cref="InputSettings.defaultButtonPressPoint"/> for the default press point.
107+
/// See <see cref="InputSettings.defaultButtonPressPoint"/> and <see cref="pressPoint"/>for the (default) press point.
110108
/// </remarks>
111109
/// <example>
112110
/// <code>
@@ -143,10 +141,9 @@ public ButtonControl()
143141
/// <summary>
144142
/// Whether the button is currently pressed.
145143
/// </summary>
146-
/// <value>True if button is currently pressed.</value>
147144
/// <remarks>
148145
/// A button is considered pressed if its value is equal to or greater
149-
/// than its button press threshold (<see cref="pressPointOrDefault"/>).
146+
/// than its button press threshold (<see cref="pressPointOrDefault"/>, <see cref="pressPoint"/>).
150147
/// </remarks>
151148
/// <example>
152149
/// <para>You can use this to read whether specific keys are currently pressed by using isPressed on keys, as shown in the following examples:</para>
@@ -242,7 +239,6 @@ private void BeginTestingForFramePresses(bool currentlyPressed, bool pressedLast
242239
/// <summary>
243240
/// Whether the press started this frame.
244241
/// </summary>
245-
/// <value>True if the current press of the button started this frame.</value>
246242
/// <remarks>
247243
/// The first time this function - or wasReleasedThisFrame - are called, it's possible that extremely fast
248244
/// inputs (or very slow frame update times) will result in presses/releases being missed.
@@ -304,12 +300,12 @@ public bool wasPressedThisFrame
304300
/// <summary>
305301
/// Whether the press ended this frame.
306302
/// </summary>
307-
/// <value>True if the current press of the button ended this frame.</value>
308303
/// <remarks>
309304
/// _Note_: The Input System identifies keys by physical layout, not according to the current language mapping of the keyboard. To query the name of the key according to the language mapping, use <see cref="InputControl.displayName"/>.
310305
/// </remarks>
311306
/// <example>
312307
/// <para>An example showing the use of this property on a gamepad button and a keyboard key:</para>
308+
///
313309
/// <code>
314310
/// using UnityEngine;
315311
/// using UnityEngine.InputSystem;

Packages/com.unity.inputsystem/InputSystem/Devices/Mouse.cs

Lines changed: 41 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -171,18 +171,37 @@ namespace UnityEngine.InputSystem
171171
/// An input device representing a mouse.
172172
/// </summary>
173173
/// <remarks>
174-
/// Adds a scroll wheel and a typical 3-button setup with a left, middle, and right
175-
/// button.
174+
/// Adds a scroll wheel and a typical 5-button setup with a left, middle, right,
175+
/// forward and backward button.
176176
///
177177
/// To control cursor display and behavior, use <see cref="UnityEngine.Cursor"/>.
178178
/// </remarks>
179+
/// <example>
180+
///
181+
/// <code>
182+
/// using UnityEngine;
183+
/// using UnityEngine.InputSystem;
184+
///
185+
/// public class ExampleScript : MonoBehaviour
186+
/// {
187+
/// void Update()
188+
/// {
189+
/// // If there is a current mouse and the left button was pressed
190+
/// if (Mouse.current != null &amp;&amp; Mouse.current.leftButton.wasPressedThisFrame)
191+
/// {
192+
/// // handle left mouse button being pressed
193+
/// }
194+
/// }
195+
/// }
196+
/// </code>
197+
/// </example>
198+
/// <seealso cref="Pointer"/>
179199
[InputControlLayout(stateType = typeof(MouseState), isGenericTypeOfDevice = true)]
180200
public class Mouse : Pointer, IInputStateCallbackReceiver
181201
{
182202
/// <summary>
183-
/// The horizontal and vertical scroll wheels.
203+
/// Control representing horizontal and vertical scroll wheels of a Mouse device.
184204
/// </summary>
185-
/// <value>Control representing the mouse scroll wheels.</value>
186205
/// <remarks>
187206
/// The <c>x</c> component corresponds to the horizontal scroll wheel, the
188207
/// <c>y</c> component to the vertical scroll wheel. Most mice do not have
@@ -191,58 +210,57 @@ public class Mouse : Pointer, IInputStateCallbackReceiver
191210
public DeltaControl scroll { get; protected set; }
192211

193212
/// <summary>
194-
/// The left mouse button.
213+
/// Control representing left button of a Mouse device.
195214
/// </summary>
196-
/// <value>Control representing the left mouse button.</value>
197215
public ButtonControl leftButton { get; protected set; }
198216

199217
/// <summary>
200-
/// The middle mouse button.
218+
/// Control representing middle button of a Mouse device.
201219
/// </summary>
202-
/// <value>Control representing the middle mouse button.</value>
203220
public ButtonControl middleButton { get; protected set; }
204221

205222
/// <summary>
206-
/// The right mouse button.
223+
/// Control representing right button of a Mouse device.
207224
/// </summary>
208-
/// <value>Control representing the right mouse button.</value>
209225
public ButtonControl rightButton { get; protected set; }
210226

211227
/// <summary>
212-
/// The first side button, often labeled/used as "back".
228+
/// Control representing the first side button, often labeled/used as "back", of a Mouse device.
213229
/// </summary>
214-
/// <value>Control representing the back button on the mouse.</value>
215230
/// <remarks>
216231
/// On Windows, this corresponds to <c>RI_MOUSE_BUTTON_4</c>.
217232
/// </remarks>
218233
public ButtonControl backButton { get; protected set; }
219234

220235
/// <summary>
221-
/// The second side button, often labeled/used as "forward".
236+
/// Control representing the second side button, often labeled/used as "forward", of a Mouse device.
222237
/// </summary>
223-
/// <value>Control representing the forward button on the mouse.</value>
224238
/// <remarks>
225239
/// On Windows, this corresponds to <c>RI_MOUSE_BUTTON_5</c>.
226240
/// </remarks>
227241
public ButtonControl forwardButton { get; protected set; }
228242

229243
/// <summary>
230-
/// Number of times any of the mouse buttons has been clicked in succession within
244+
/// Control representing the number of times any of the mouse buttons has been clicked in succession within
231245
/// the system-defined click time threshold.
232246
/// </summary>
233-
/// <value>Control representing the mouse click count.</value>
234247
public IntegerControl clickCount { get; protected set; }
235248

236249
/// <summary>
237250
/// The mouse that was added or updated last or null if there is no mouse
238251
/// connected to the system.
239252
/// </summary>
240-
/// <seealso cref="InputDevice.MakeCurrent"/>
253+
/// <remarks>
254+
/// To set a mouse device as current, use <see cref="Mouse.MakeCurrent"/>.
255+
/// </remarks>
241256
public new static Mouse current { get; private set; }
242257

243258
/// <summary>
244259
/// Called when the mouse becomes the current mouse.
245260
/// </summary>
261+
/// <remarks>
262+
/// This is called automatically by the system when there is input on a connected mouse.
263+
/// </remarks>
246264
public override void MakeCurrent()
247265
{
248266
base.MakeCurrent();
@@ -274,7 +292,9 @@ protected override void OnRemoved()
274292

275293
////REVIEW: how should we handle this being called from EditorWindow's? (where the editor window space processor will turn coordinates automatically into editor window space)
276294
/// <summary>
277-
/// Move the operating system's mouse cursor.
295+
/// Move the operating system's mouse cursor by performing a device command in a similar way to <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa363216%28v=vs.85%29.aspx?f=255&amp;MSPPError=-2147217396" >
296+
/// DeviceIoControl</a> on Windows and <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/ioctl.2.html#//apple_ref/doc/man/2/ioctl" >ioctl</a>
297+
/// on UNIX-like systems.
278298
/// </summary>
279299
/// <param name="position">New position in player window space.</param>
280300
/// <remarks>
@@ -313,7 +333,9 @@ protected override void FinishSetup()
313333
/// <summary>
314334
/// Implements <see cref="IInputStateCallbackReceiver.OnStateEvent"/> for the mouse.
315335
/// </summary>
316-
/// <param name="eventPtr"></param>
336+
/// <param name="eventPtr">Pointer to an <see cref="InputEvent"/>. Makes it easier to
337+
/// work with InputEvents and hides the unsafe operations necessary to work with them.
338+
/// </param>
317339
protected new unsafe void OnStateEvent(InputEventPtr eventPtr)
318340
{
319341
scroll.AccumulateValueInEvent(currentStatePtr, eventPtr);

0 commit comments

Comments
 (0)