InputUserSettings.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. using System;
  2. ////WIP
  3. //how is it achieved that this applies on a per-device level rather than for all devices of a given type?
  4. //do we do this at the event-level?
  5. //where to do perform the input modification? pre-source or post-source?
  6. //pre-source:
  7. // + can be persisted such that the outcome is agnostic to user profile settings
  8. // - no longer possible to have input routed to multiple users from same device
  9. //
  10. //post-source:
  11. // + no need to modify device
  12. ////REVIEW: add ability to have per-device (or device layout?) settings?
  13. namespace UnityEngine.InputSystem.Users
  14. {
  15. /// <summary>
  16. /// A user profile may alter select aspects of input behavior at runtime.
  17. /// </summary>
  18. /// <remarks>
  19. /// This class implements several user adjustable input behaviors commonly found in games, such
  20. /// as mouse sensitivity and axis inversion.
  21. ///
  22. /// Note that the behaviors only work in combination with actions, i.e. for users that have
  23. /// actions associated with them via <see cref="InputUser.AssociateActionsWithUser(IInputActionCollection)"/>.
  24. /// The behaviors do not alter the input as present directly on the devices. Meaning that, for example,
  25. /// <see cref="invertMouseX"/> will not impact <see cref="Vector2.x"/> of <see cref="Mouse.delta"/> but will
  26. /// rather impact the value read out with <see cref="InputAction.CallbackContext.ReadValue"/> from an action
  27. /// bound to mouse deltas.
  28. ///
  29. /// In other words, all the input behaviors operate at the binding level and modify <see cref="InputBinding"/>s.
  30. /// ////REVIEW: does this really make sense?
  31. /// </remarks>
  32. [Serializable]
  33. internal class InputUserSettings
  34. {
  35. /// <summary>
  36. /// Customized bindings for the user.
  37. /// </summary>
  38. /// <remarks>
  39. /// This will only contain customizations explicitly applied to the user's bindings
  40. /// and will not contain default bindings. It is thus not a complete set of bindings
  41. /// but rather just a set of customizations.
  42. /// </remarks>
  43. public string customBindings { get; set; }
  44. ////REVIEW: for this to impact position, too, we need to know the screen dimensions
  45. /// <summary>
  46. /// Invert X on <see cref="Mouse.position"/> and <see cref="Mouse.delta"/>.
  47. /// </summary>
  48. public bool invertMouseX { get; set; }
  49. /// <summary>
  50. /// Invert Y on <see cref="Mouse.position"/> and <see cref="Mouse.delta"/>.
  51. /// </summary>
  52. public bool invertMouseY { get; set; }
  53. /// <summary>
  54. /// Smooth mouse motion on both X and Y ...
  55. /// </summary>
  56. public float? mouseSmoothing { get; set; }
  57. public float? mouseSensitivity { get; set; }
  58. /// <summary>
  59. /// Invert X axis on <see cref="Gamepad.leftStick"/> and <see cref="Gamepad.rightStick"/>.
  60. /// </summary>
  61. public bool invertStickX { get; set; }
  62. /// <summary>
  63. /// Invert Y axis on <see cref="Gamepad.leftStick"/> and <see cref="Gamepad.rightStick"/>.
  64. /// </summary>
  65. public bool invertStickY { get; set; }
  66. /// <summary>
  67. /// If true, swap sides
  68. /// </summary>
  69. public bool swapSticks { get; set; }
  70. /// <summary>
  71. /// Swap <see cref="Gamepad.leftShoulder"/> and <see cref="Gamepad.rightShoulder"/> on gamepads.
  72. /// </summary>
  73. public bool swapBumpers { get; set; }
  74. /// <summary>
  75. /// Swap <see cref="Gamepad.leftTrigger"/> and <see cref="Gamepad.rightTrigger"/> on gamepads.
  76. /// </summary>
  77. public bool swapTriggers { get; set; }
  78. public bool swapDpadAndLeftStick { get; set; }
  79. public float vibrationStrength { get; set; }
  80. public virtual void Apply(IInputActionCollection actions)
  81. {
  82. //set overrideProcessors and redirectPaths on respective bindings
  83. }
  84. [SerializeField] private string m_CustomBindings;
  85. }
  86. }