Skip to content

Commit a0ad998

Browse files
committed
update keyboard documentation
1 parent 59c7c40 commit a0ad998

File tree

4 files changed

+362
-152
lines changed

4 files changed

+362
-152
lines changed

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

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,60 @@ protected void RefreshConfigurationIfNeeded()
790790
}
791791
}
792792

793+
/// <summary>
794+
/// Refresh the configuration of the control. This is used to update the control's state (e.g. Keyboard Layout or display Name of Keys).
795+
/// </summary>
796+
/// <remarks>
797+
/// The system will call this method automatically whenever change is made to one of the control's configuration properties.
798+
/// See <seealso cref="RefreshConfigurationIfNeeded"/>.
799+
/// </remarks>
800+
/// <example>
801+
/// <code>
802+
/// public class MyDevice : InputDevice
803+
/// {
804+
/// public enum Orientation
805+
/// {
806+
/// Horizontal,
807+
/// Vertical,
808+
/// }
809+
/// private Orientation m_Orientation;
810+
///
811+
/// public Orientation orientation
812+
/// {
813+
/// get
814+
/// {
815+
/// // Call RefreshOrientation if the configuration of the device has been
816+
/// // invalidated since last time we initialized m_Orientation.
817+
/// // Calling RefreshConfigurationIfNeeded() is sufficient in most cases, RefreshConfiguration() forces the refresh.
818+
/// RefreshConfiguration();
819+
/// return m_Orientation;
820+
/// }
821+
/// }
822+
/// protected override void RefreshConfiguration()
823+
/// {
824+
/// // Fetch the current orientation from the backend. How you do this
825+
/// // depends on your device. Using DeviceCommands is one way.
826+
/// var fetchOrientationCommand = new FetchOrientationCommand();
827+
/// ExecuteCommand(ref fetchOrientationCommand);
828+
/// m_Orientation = fetchOrientation;
829+
///
830+
/// // Reflect the orientation on the device.
831+
/// switch (m_Orientation)
832+
/// {
833+
/// case Orientation.Vertical:
834+
/// InputSystem.RemoveDeviceUsage(this, s_Horizontal);
835+
/// InputSystem.AddDeviceUsage(this, s_Vertical);
836+
/// break;
837+
///
838+
/// case Orientation.Horizontal:
839+
/// InputSystem.RemoveDeviceUsage(this, s_Vertical);
840+
/// InputSystem.AddDeviceUsage(this, s_Horizontal);
841+
/// break;
842+
/// }
843+
/// }
844+
/// }
845+
/// </code>
846+
/// </example>
793847
protected virtual void RefreshConfiguration()
794848
{
795849
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public int scanCode
5858
return m_ScanCode;
5959
}
6060
}
61-
61+
/// <inheritdoc/>
6262
protected override void RefreshConfiguration()
6363
{
6464
// Wipe our last cached set of data (if any).

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,10 +521,24 @@ protected virtual void OnAdded()
521521
/// </summary>
522522
/// <remarks>
523523
/// This is called <em>after</em> the device has already been removed.
524-
/// </remarks>
525524
/// <seealso cref="InputSystem.devices"/>
526525
/// <seealso cref="InputDeviceChange.Removed"/>
527526
/// <seealso cref="OnRemoved"/>
527+
/// </remarks>
528+
/// <example>
529+
/// <code>
530+
/// public class MyDevice : InputDevice
531+
/// {
532+
/// protected override void OnRemoved()
533+
/// {
534+
/// // use this context to unassign the current device for instance
535+
/// base.OnRemoved();
536+
/// if (current == this)
537+
/// current = null;
538+
/// }
539+
/// }
540+
/// </code>
541+
/// </example>
528542
protected virtual void OnRemoved()
529543
{
530544
}

0 commit comments

Comments
 (0)