Skip to content

Commit 22f79a0

Browse files
ekcohjamesmcgill
andauthored
Star complaince docs - batch 1 (#1523)
* DOCS: Added missing API docs for PrimitiveValue, InputActionTrace, InputExtensions, CommonUsages, ReadOnlyArray. Co-authored-by: James McGill <james.mcgill@unity3d.com>
1 parent 0217c2d commit 22f79a0

6 files changed

Lines changed: 385 additions & 8 deletions

File tree

Packages/com.unity.inputsystem/InputSystem/Actions/InputActionTrace.cs

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,19 +98,43 @@ public sealed class InputActionTrace : IEnumerable<InputActionTrace.ActionEventP
9898
/// </summary>
9999
public InputEventBuffer buffer => m_EventBuffer;
100100

101+
/// <summary>
102+
/// Returns the number of events in the associated event buffer.
103+
/// </summary>
101104
public int count => m_EventBuffer.eventCount;
102105

106+
/// <summary>
107+
/// Constructs a new default initialized <c>InputActionTrace</c>.
108+
/// </summary>
109+
/// <remarks>
110+
/// When you use this constructor, the new InputActionTrace object does not start recording any actions.
111+
/// To record actions, you must explicitly set them up after creating the object.
112+
/// Alternatively, you can use one of the other constructor overloads which begin recording actions immediately.
113+
/// </remarks>
114+
/// <seealso cref="SubscribeTo(InputAction)"/>
115+
/// <seealso cref="SubscribeTo(InputActionMap)"/>
116+
/// <seealso cref="SubscribeToAll"/>
103117
public InputActionTrace()
104118
{
105119
}
106120

121+
/// <summary>
122+
/// Constructs a new <c>InputActionTrace</c> that records <paramref name="action"/>.
123+
/// </summary>
124+
/// <param name="action">The action to be recorded.</param>
125+
/// <exception cref="System.ArgumentNullException">Thrown if <paramref name="action"/> is <c>null</c>.</exception>
107126
public InputActionTrace(InputAction action)
108127
{
109128
if (action == null)
110129
throw new ArgumentNullException(nameof(action));
111130
SubscribeTo(action);
112131
}
113132

133+
/// <summary>
134+
/// Constructs a new <c>InputActionTrace</c> that records all actions in <paramref name="actionMap"/>.
135+
/// </summary>
136+
/// <param name="actionMap">The action-map containing actions to be recorded.</param>
137+
/// <exception cref="System.ArgumentNullException">Thrown if <paramref name="action"/> is <c>null</c>.</exception>
114138
public InputActionTrace(InputActionMap actionMap)
115139
{
116140
if (actionMap == null)
@@ -126,6 +150,8 @@ public InputActionTrace(InputActionMap actionMap)
126150
/// Instead, the trace will listen to <see cref="InputSystem.onActionChange"/> and automatically record
127151
/// every triggered action.
128152
/// </remarks>
153+
/// <seealso cref="SubscribeTo(InputAction)"/>
154+
/// <seealso cref="SubscribeTo(InputActionMap)"/>
129155
public void SubscribeToAll()
130156
{
131157
if (m_SubscribedToAll)
@@ -141,6 +167,11 @@ public void SubscribeToAll()
141167
UnsubscribeFrom(m_SubscribedActionMaps[m_SubscribedActionMaps.length - 1]);
142168
}
143169

170+
/// <summary>
171+
/// Unsubscribes from all actions currently being recorded.
172+
/// </summary>
173+
/// <seealso cref="UnsubscribeFrom(InputAction)"/>
174+
/// <seealso cref="UnsubscribeFrom(InputActionMap)"/>
144175
public void UnsubscribeFromAll()
145176
{
146177
// Only unhook from OnActionChange if we don't have any recorded actions. If we do have
@@ -156,6 +187,17 @@ public void UnsubscribeFromAll()
156187
UnsubscribeFrom(m_SubscribedActionMaps[m_SubscribedActionMaps.length - 1]);
157188
}
158189

190+
/// <summary>
191+
/// Subscribes to <paramref name="action"/>.
192+
/// </summary>
193+
/// <param name="action">The action to be recorded.</param>
194+
/// <remarks>
195+
/// **Note:** This method does not prevent you from subscribing to the same action multiple times.
196+
/// If you subscribe to the same action multiple times, your event buffer will contain duplicate entries.
197+
/// </remarks>
198+
/// <exception cref="ArgumentNullException">If <paramref name="action"/> is <c>null</c>.</exception>
199+
/// <seealso cref="SubscribeTo(InputActionMap)"/>
200+
/// <seealso cref="SubscribeToAll"/>
159201
public void SubscribeTo(InputAction action)
160202
{
161203
if (action == null)
@@ -171,6 +213,17 @@ public void SubscribeTo(InputAction action)
171213
m_SubscribedActions.AppendWithCapacity(action);
172214
}
173215

216+
/// <summary>
217+
/// Subscribes to all actions contained within <paramref name="actionMap"/>.
218+
/// </summary>
219+
/// <param name="actionMap">The action-map containing all actions to be recorded.</param>
220+
/// <remarks>
221+
/// **Note:** This method does not prevent you from subscribing to the same action multiple times.
222+
/// If you subscribe to the same action multiple times, your event buffer will contain duplicate entries.
223+
/// </remarks>
224+
/// <exception cref="ArgumentNullException">Thrown if <paramref name="actionMap"/> is null.</exception>
225+
/// <seealso cref="SubscribeTo(InputAction)"/>
226+
/// <seealso cref="SubscribeToAll"/>
174227
public void SubscribeTo(InputActionMap actionMap)
175228
{
176229
if (actionMap == null)
@@ -184,6 +237,16 @@ public void SubscribeTo(InputActionMap actionMap)
184237
m_SubscribedActionMaps.AppendWithCapacity(actionMap);
185238
}
186239

240+
/// <summary>
241+
/// Unsubscribes from an action, if that action was previously subscribed to.
242+
/// </summary>
243+
/// <param name="action">The action to unsubscribe from.</param>
244+
/// <remarks>
245+
/// **Note:** This method has no side effects if you attempt to unsubscribe from an action that you have not previously subscribed to.
246+
/// </remarks>
247+
/// <exception cref="ArgumentNullException">Thrown if <paramref name="action"/> is <c>null</c>.</exception>
248+
/// <seealso cref="UnsubscribeFrom(InputActionMap)"/>
249+
/// <seealso cref="UnsubscribeFromAll"/>
187250
public void UnsubscribeFrom(InputAction action)
188251
{
189252
if (action == null)
@@ -201,6 +264,16 @@ public void UnsubscribeFrom(InputAction action)
201264
m_SubscribedActions.RemoveAtWithCapacity(index);
202265
}
203266

267+
/// <summary>
268+
/// Unsubscribes from all actions included in <paramref name="actionMap"/>.
269+
/// </summary>
270+
/// <param name="actionMap">The action-map containing actions to unsubscribe from.</param>
271+
/// <remarks>
272+
/// **Note:** This method has no side effects if you attempt to unsubscribe from an action-map that you have not previously subscribed to.
273+
/// </remarks>
274+
/// <exception cref="ArgumentNullException">Thrown if <paramref name="actionMap"/> is <c>null</c>.</exception>
275+
/// <seealso cref="UnsubscribeFrom(InputAction)"/>
276+
/// <seealso cref="UnsubscribeFromAll"/>
204277
public void UnsubscribeFrom(InputActionMap actionMap)
205278
{
206279
if (actionMap == null)
@@ -258,6 +331,12 @@ public unsafe void RecordAction(InputAction.CallbackContext context)
258331
context.ReadValue(valueBuffer, valueSizeInBytes);
259332
}
260333

334+
/// <summary>
335+
/// Clears all recorded data.
336+
/// </summary>
337+
/// <remarks>
338+
/// **Note:** This method does not unsubscribe any actions that the instance is listening to, so after clearing the recorded data, new input on those subscribed actions will continue to be recorded.
339+
/// </remarks>
261340
public void Clear()
262341
{
263342
m_EventBuffer.Reset();
@@ -269,6 +348,7 @@ public void Clear()
269348
DisposeInternal();
270349
}
271350

351+
/// <inheritdoc/>
272352
public override string ToString()
273353
{
274354
if (count == 0)
@@ -288,6 +368,7 @@ public override string ToString()
288368
return str.ToString();
289369
}
290370

371+
/// <inheritdoc/>
291372
public void Dispose()
292373
{
293374
UnsubscribeFromAll();
@@ -311,6 +392,11 @@ private void DisposeInternal()
311392
}
312393
}
313394

395+
/// <summary>
396+
/// Returns an enumerator that enumerates all action events recorded for this instance.
397+
/// </summary>
398+
/// <returns>Enumerator instance, never <c>null</c>.</returns>
399+
/// <seealso cref="ActionEventPtr"/>
314400
public IEnumerator<ActionEventPtr> GetEnumerator()
315401
{
316402
return new Enumerator(this);
@@ -428,12 +514,26 @@ public unsafe struct ActionEventPtr
428514
internal InputActionState m_State;
429515
internal ActionEvent* m_Ptr;
430516

517+
/// <summary>
518+
/// The <see cref="InputAction"/> associated with this action event.
519+
/// </summary>
431520
public InputAction action => m_State.GetActionOrNull(m_Ptr->bindingIndex);
432521

522+
/// <summary>
523+
/// The <see cref="InputActionPhase"/> associated with this action event.
524+
/// </summary>
525+
/// <seealso cref="InputAction.phase"/>
526+
/// <seealso cref="InputAction.CallbackContext.phase"/>
433527
public InputActionPhase phase => m_Ptr->phase;
434528

529+
/// <summary>
530+
/// The <see cref="InputControl"/> instance associated with this action event.
531+
/// </summary>
435532
public InputControl control => m_State.controls[m_Ptr->controlIndex];
436533

534+
/// <summary>
535+
/// The <see cref="IInputInteraction"/> instance associated with this action event if applicable, or <c>null</c> if the action event is not associated with an input interaction.
536+
/// </summary>
437537
public IInputInteraction interaction
438538
{
439539
get
@@ -446,14 +546,36 @@ public IInputInteraction interaction
446546
}
447547
}
448548

549+
/// <summary>
550+
/// The time, in seconds since your game or app started, that the event occurred.
551+
/// </summary>
552+
/// <remarks>
553+
/// Times are in seconds and progress linearly in real-time. The timeline is the same as for <see cref="Time.realtimeSinceStartup"/>.
554+
/// </remarks>
449555
public double time => m_Ptr->baseEvent.time;
450556

557+
/// <summary>
558+
/// The time, in seconds since your game or app started, that the <see cref="phase"/> transitioned into <see cref="InputActionPhase.Started"/>.
559+
/// </summary>
451560
public double startTime => m_Ptr->startTime;
452561

562+
/// <summary>
563+
/// The duration, in seconds, that has elapsed between when this event was generated and when the
564+
/// action <see cref="phase"/> transitioned to <see cref="InputActionPhase.Started"/> and has remained active.
565+
/// </summary>
453566
public double duration => time - startTime;
454567

568+
/// <summary>
569+
/// The size, in bytes, of the value associated with this action event.
570+
/// </summary>
455571
public int valueSizeInBytes => m_Ptr->valueSizeInBytes;
456572

573+
/// <summary>
574+
/// Reads the value associated with this event as an <c>object</c>.
575+
/// </summary>
576+
/// <returns><c>object</c> representing the value of this action event.</returns>
577+
/// <seealso cref="ReadOnlyArray{TValue}"/>
578+
/// <seealso cref="ReadValue(void*, int)"/>
457579
public object ReadValueAsObject()
458580
{
459581
if (m_Ptr == null)
@@ -488,6 +610,15 @@ public object ReadValueAsObject()
488610
return control.ReadValueFromBufferAsObject(valuePtr, valueSizeInBytes);
489611
}
490612

613+
/// <summary>
614+
/// Reads the value associated with this event into the contiguous memory buffer defined by <c>[buffer, buffer + bufferSize)</c>.
615+
/// </summary>
616+
/// <param name="buffer">Pointer to the contiguous memory buffer to write value data to.</param>
617+
/// <param name="bufferSize">The size, in bytes, of the contiguous buffer pointed to by <paramref name="buffer"/>.</param>
618+
/// <exception cref="NullReferenceException">If <paramref name="buffer"/> is <c>null</c>.</exception>
619+
/// <exception cref="ArgumentException">If the given <paramref name="bufferSize"/> is less than the number of bytes required to write the event value to <paramref name="buffer"/>.</exception>
620+
/// <seealso cref="ReadValueAsObject"/>
621+
/// <seealso cref="ReadValue{TValue}"/>
491622
public void ReadValue(void* buffer, int bufferSize)
492623
{
493624
var valueSizeInBytes = m_Ptr->valueSizeInBytes;
@@ -501,6 +632,12 @@ public void ReadValue(void* buffer, int bufferSize)
501632
UnsafeUtility.MemCpy(buffer, m_Ptr->valueData, valueSizeInBytes);
502633
}
503634

635+
/// <summary>
636+
/// Reads the value associated with this event as an object of type <typeparamref name="TValue"/>.
637+
/// </summary>
638+
/// <typeparam name="TValue">The event value type to be used.</typeparam>
639+
/// <returns>Object of type <typeparamref name="TValue"/>.</returns>
640+
/// <exception cref="InvalidOperationException">In case the size of <typeparamref name="TValue"/> does not match the size of the value associated with this event.</exception>
504641
public TValue ReadValue<TValue>()
505642
where TValue : struct
506643
{
@@ -518,6 +655,7 @@ public TValue ReadValue<TValue>()
518655
return result;
519656
}
520657

658+
/// <inheritdoc/>
521659
public override string ToString()
522660
{
523661
if (m_Ptr == null)

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

Lines changed: 73 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,82 @@ public static class CommonUsages
1111
/// Primary 2D motion control.
1212
/// </summary>
1313
/// <remarks>
14-
/// Example: left stick on gamepad.
14+
/// Example: Left stick on a gamepad.
1515
/// </remarks>
1616
public static readonly InternedString Primary2DMotion = new InternedString("Primary2DMotion");
1717

1818
/// <summary>
1919
/// Secondary 2D motion control.
2020
/// </summary>
2121
/// <remarks>
22-
/// Example: right stick on gamepad.
22+
/// Example: Right stick on a gamepad.
2323
/// </remarks>
2424
public static readonly InternedString Secondary2DMotion = new InternedString("Secondary2DMotion");
2525

26+
/// <summary>
27+
/// The primary action control on any input device, such as a gamepad, mouse, or keyboard.
28+
/// </summary>
29+
/// <remarks>
30+
/// Example: Primary mouse button (left button on right-handed configuration, right button on left-handed configuration),
31+
/// south-button on a gamepad.
32+
/// </remarks>
2633
public static readonly InternedString PrimaryAction = new InternedString("PrimaryAction");
34+
35+
/// <summary>
36+
/// Secondary action control on any input device, such as a gamepad, mouse, or keyboard.
37+
/// </summary>
38+
/// <remarks>
39+
/// Example: Secondary mouse button (right button on right-handed configuration, left button on left-handed configuration),
40+
/// east-button on a gamepad.
41+
/// </remarks>
2742
public static readonly InternedString SecondaryAction = new InternedString("SecondaryAction");
43+
44+
/// <summary>
45+
/// The primary trigger control on input devices with triggers.
46+
/// </summary>
47+
/// <remarks>
48+
/// Example: Right trigger-button on a gamepad.
49+
/// </remarks>
2850
public static readonly InternedString PrimaryTrigger = new InternedString("PrimaryTrigger");
51+
52+
/// <summary>
53+
/// The secondary trigger control on input devices with triggers.
54+
/// </summary>
55+
/// <remarks>
56+
/// Example: Left trigger-button on a gamepad.
57+
/// </remarks>
2958
public static readonly InternedString SecondaryTrigger = new InternedString("SecondaryTrigger");
30-
public static readonly InternedString Modifier = new InternedString("Modifier"); // Stuff like CTRL
59+
60+
/// <summary>
61+
/// A modifier action control that modifies usage of other controls.
62+
/// </summary>
63+
/// <remarks>
64+
/// Example: Keyboard modifier keys like CTRL, SHIFT, ALT, OPTION, etc.
65+
/// </remarks>
66+
public static readonly InternedString Modifier = new InternedString("Modifier");
67+
68+
/// <summary>
69+
/// The spatial position control on input devices with spatial tracking.
70+
/// </summary>
71+
/// <remarks>
72+
/// Example: User head position in tracking-space using e.g. a head-tracking system. This could for example be a VR tracking system or another user-facing tracking sensor.
73+
/// </remarks>
3174
public static readonly InternedString Position = new InternedString("Position");
75+
76+
/// <summary>
77+
/// The spatial orientation control on input devices with spatial tracking.
78+
/// </summary>
79+
/// <remarks>
80+
/// Example: User head-orientation in tracking-space using e.g. a head-tracking system. This could for example be a VR tracking system or another user-facing tracking sensor.
81+
/// </remarks>
3282
public static readonly InternedString Orientation = new InternedString("Orientation");
83+
84+
/// <summary>
85+
/// The primary hat-switch control on input devices with hat-switches such as joysticks or gamepads.
86+
/// </summary>
87+
/// <remarks>
88+
/// Example: Joystick or gamepad hat-switch.
89+
/// </remarks>
3390
public static readonly InternedString Hatswitch = new InternedString("Hatswitch");
3491

3592
/// <summary>
@@ -108,9 +165,22 @@ public static class CommonUsages
108165
/// </summary>
109166
public static readonly InternedString ScrollVertical = new InternedString("ScrollVertical");
110167

168+
/// <summary>
169+
/// A screen-space point.
170+
/// </summary>
171+
/// <remarks>
172+
/// Example: Touch contact point.
173+
/// </remarks>
111174
public static readonly InternedString Point = new InternedString("Point");
112175

176+
/// <summary>
177+
/// Low-frequency haptic motor for force-feedback.
178+
/// </summary>
113179
public static readonly InternedString LowFreqMotor = new InternedString("LowFreqMotor");
180+
181+
/// <summary>
182+
/// High-frequency haptic motor for force-feedback.
183+
/// </summary>
114184
public static readonly InternedString HighFreqMotor = new InternedString("HighFreqMotor");
115185

116186
/// <summary>

0 commit comments

Comments
 (0)