InputDeviceChange.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. using UnityEngine.InputSystem.LowLevel;
  2. using UnityEngine.InputSystem.Utilities;
  3. namespace UnityEngine.InputSystem
  4. {
  5. /// <summary>
  6. /// Indicates what type of change related to an <see cref="InputDevice">input device</see> occurred.
  7. /// </summary>
  8. /// <remarks>
  9. /// Use <see cref="InputSystem.onDeviceChange"/> to receive notifications about changes
  10. /// to the input device setup in the system.
  11. ///
  12. /// <example>
  13. /// <code>
  14. /// InputSystem.onDeviceChange +=
  15. /// (device, change) =>
  16. /// {
  17. /// switch (change)
  18. /// {
  19. /// case InputDeviceChange.Added:
  20. /// Debug.Log($"Device {device} was added");
  21. /// break;
  22. /// case InputDeviceChange.Removed:
  23. /// Debug.Log($"Device {device} was removed");
  24. /// break;
  25. /// }
  26. /// };
  27. /// </code>
  28. /// </example>
  29. /// </remarks>
  30. public enum InputDeviceChange
  31. {
  32. /// <summary>
  33. /// A new device was added to the system. This is triggered <em>after</em> the device
  34. /// has already been added, i.e. it already appears on <see cref="InputSystem.devices"/>.
  35. /// </summary>
  36. /// <seealso cref="InputSystem.AddDevice(string,string,string)"/>
  37. /// <seealso cref="InputSystem.AddDevice{TDevice}(string)"/>
  38. /// <seealso cref="InputDevice.added"/>
  39. Added,
  40. /// <summary>
  41. /// An existing device was removed from the system. This is triggered <em>after</em> the
  42. /// device has already been removed, i.e. it already has been cleared from <see cref="InputSystem.devices"/>.
  43. /// </summary>
  44. /// <remarks>
  45. /// Other than when a device is removed programmatically, this happens when a device
  46. /// is unplugged from the system. Subsequent to the notification, the system will remove
  47. /// the <see cref="InputDevice"/> instance from its list and remove the device's
  48. /// recorded input state.
  49. /// </remarks>
  50. /// <seealso cref="InputSystem.RemoveDevice"/>
  51. Removed,
  52. /// <summary>
  53. /// A device reported by the <see cref="IInputRuntime"/> was <see cref="Removed"/> but was
  54. /// retained by the system as <see cref="InputSystem.disconnectedDevices">disconnected</see>.
  55. /// </summary>
  56. /// <seealso cref="InputSystem.disconnectedDevices"/>
  57. Disconnected,
  58. /// <summary>
  59. /// A device that was previously retained as <see cref="Disconnected"/> has been re-discovered
  60. /// and has been <see cref="Added"/> to the system again.
  61. /// </summary>
  62. /// <seealso cref="InputSystem.disconnectedDevices"/>
  63. /// <seealso cref="IInputRuntime.onDeviceDiscovered"/>
  64. Reconnected,
  65. /// <summary>
  66. /// An existing device was re-enabled after having been <see cref="Disabled"/>.
  67. /// </summary>
  68. /// <seealso cref="InputSystem.EnableDevice"/>
  69. /// <seealso cref="InputDevice.enabled"/>
  70. Enabled,
  71. /// <summary>
  72. /// An existing device was disabled.
  73. /// </summary>
  74. /// <seealso cref="InputSystem.DisableDevice"/>
  75. /// <seealso cref="InputDevice.enabled"/>
  76. Disabled,
  77. /// <summary>
  78. /// The usages on a device have changed.
  79. /// </summary>
  80. /// <remarks>
  81. /// This may signal, for example, that what was the right hand XR controller before
  82. /// is now the left hand controller.
  83. /// </remarks>
  84. /// <seealso cref="InputSystem.SetDeviceUsage(InputDevice,InternedString)"/>
  85. /// <seealso cref="InputControl.usages"/>
  86. UsageChanged,
  87. /// <summary>
  88. /// The configuration of a device has changed.
  89. /// </summary>
  90. /// <remarks>
  91. /// This may signal, for example, that the layout used by the keyboard has changed or
  92. /// that, on a console, a gamepad has changed which player ID(s) it is assigned to.
  93. /// </remarks>
  94. /// <seealso cref="DeviceConfigurationEvent"/>
  95. /// <seealso cref="InputSystem.QueueConfigChangeEvent"/>
  96. ConfigurationChanged,
  97. ////TODO: fire this when we purge disconnected devices
  98. Destroyed,
  99. }
  100. }