This commit is contained in:
2025-01-17 13:10:42 +01:00
commit 4536213c91
15115 changed files with 1442174 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e072bc6a44a3a4944bb32165f753b9ca
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,81 @@
using System;
namespace UnityEngine.InputSystem.Users
{
/// <summary>
/// Handle for a user account in an external API.
/// </summary>
public struct InputUserAccountHandle : IEquatable<InputUserAccountHandle>
{
/// <summary>
/// Symbolic name of the API that owns the handle.
/// </summary>
/// <remarks>
/// This essentially provides a namespace for <see cref="handle"/>.
///
/// On PS4, for example, this will read "PS4" for user handles corresponding
/// to <c>sceUserId</c>.
///
/// This will not be null or empty except if the handle is invalid.
/// </remarks>
public string apiName
{
get { return m_ApiName; }
}
public ulong handle
{
get { return m_Handle; }
}
public InputUserAccountHandle(string apiName, ulong handle)
{
if (string.IsNullOrEmpty(apiName))
throw new ArgumentNullException("apiName");
m_ApiName = apiName;
m_Handle = handle;
}
public override string ToString()
{
if (m_ApiName == null)
return base.ToString();
return string.Format("{0}({1})", m_ApiName, m_Handle);
}
public bool Equals(InputUserAccountHandle other)
{
return string.Equals(apiName, other.apiName) && Equals(handle, other.handle);
}
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
return false;
return obj is InputUserAccountHandle && Equals((InputUserAccountHandle)obj);
}
public static bool operator==(InputUserAccountHandle left, InputUserAccountHandle right)
{
return left.Equals(right);
}
public static bool operator!=(InputUserAccountHandle left, InputUserAccountHandle right)
{
return !left.Equals(right);
}
public override int GetHashCode()
{
unchecked
{
return ((apiName != null ? apiName.GetHashCode() : 0) * 397) ^ handle.GetHashCode();
}
}
private string m_ApiName;
private ulong m_Handle;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 76765a8c5cba74c0abc5ab4afd8266e2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,114 @@
using UnityEngine.InputSystem.LowLevel;
////REVIEW: how do we handle the case where the OS may (through whatever means) recognize individual real-world users,
//// associate a user account with each one, and recognize when a controller is passed from one user to the other?
//// (NUI on Xbox probably gives us that scenario)
namespace UnityEngine.InputSystem.Users
{
/// <summary>
/// Indicates what type of change related to an <see cref="InputUser"/> occurred.
/// </summary>
/// <seealso cref="InputUser.onChange"/>
public enum InputUserChange
{
/// <summary>
/// A new user was added to the system.
/// </summary>
/// <seealso cref="InputUser.PerformPairingWithDevice"/>
Added,
/// <summary>
/// An existing user was removed from the user.
/// </summary>
/// <remarks>
/// <see cref="InputUser"/>s are only removed when explicitly requested (<see cref="InputUser.UnpairDevicesAndRemoveUser"/>).
/// </remarks>
/// <seealso cref="InputUser.UnpairDevicesAndRemoveUser"/>
Removed,
/// <summary>
/// A user has had a device assigned to it.
/// </summary>
/// <seealso cref="InputUser.PerformPairingWithDevice"/>
/// <seealso cref="InputUser.pairedDevices"/>
DevicePaired,
/// <summary>
/// A user has had a device removed from it.
/// </summary>
/// <remarks>
/// This is different from <see cref="DeviceLost"/> in that the removal is intentional. <see cref="DeviceLost"/>
/// instead indicates that the device was removed due to causes outside of the control of the application (such
/// as battery loss) whereas DeviceUnpaired indicates the device was removed from the user under the control of
/// the application itself.
/// </remarks>
/// <seealso cref="InputUser.UnpairDevice"/>
/// <seealso cref="InputUser.UnpairDevicesAndRemoveUser"/>
/// <seealso cref="InputUser.pairedDevices"/>
DeviceUnpaired,
/// <summary>
/// A device was removed while paired to the user.
/// </summary>
/// <remarks>
/// This scenario happens on battery loss, for example.
///
/// Note that there is still a <see cref="DevicePaired"/> change sent when the device is subsequently removed
/// from the user.
/// </remarks>
/// <seealso cref="InputUser.pairedDevices"/>
/// <seealso cref="InputUser.lostDevices"/>
DeviceLost,
////REVIEW: should we tie this to the specific device requirement slot in the control scheme?
/// <summary>
/// A device that was previously lost (<see cref="DeviceLost"/>) was regained by the user.
/// </summary>
/// <remarks>
/// This can happen, for example, when a gamepad runs out of battery and is then plugged in by wire.
///
/// Note that a device may be permanently lost and instead be replaced by a different device.
/// </remarks>
/// <seealso cref="InputUser.lostDevices"/>
DeviceRegained,
////TODO: bring documentation for these back when user management is implemented on Xbox and PS
AccountChanged,
AccountNameChanged,
AccountSelectionInProgress,
AccountSelectionCanceled,
AccountSelectionComplete,
////REVIEW: send notifications about the matching status of the control scheme? maybe ControlSchemeActivated, ControlSchemeDeactivated,
//// and ControlSchemeChanged?
/// <summary>
/// A user switched to a different control scheme.
/// </summary>
/// <seealso cref="InputUser.ActivateControlScheme(string)"/>
/// <seealso cref="InputUser.ActivateControlScheme(InputControlScheme)"/>
ControlSchemeChanged,
/// <summary>
/// A user's bound controls have changed, either because the bindings of the user have changed (for example,
/// due to an override applied with <see cref="InputActionRebindingExtensions.ApplyBindingOverride(InputAction,InputBinding)"/>)
/// or because the controls themselves may have changed configuration (every time the device of the controls receives
/// an <see cref="DeviceConfigurationEvent"/>; for example, when the current keyboard layout on a <see cref="Keyboard"/>
/// changes which in turn modifies the <see cref="InputControl.displayName"/>s of the keys on the keyboard).
/// </summary>
ControlsChanged,
/*
////TODO: this is waiting for InputUserSettings
/// <summary>
/// A setting in the user's <see cref="InputUserSettings"/> has changed.
/// </summary>
/// <remarks>
/// This is separate from <see cref="BindingsChanged"/> even though bindings are part of user profiles
/// (<see cref="InputUserSettings.customBindings"/>). The reason is that binding changes often require
/// </remarks>
SettingsChanged,
*/
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ce1664b057efc40759e0da41d54e3e4e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,51 @@
using System;
namespace UnityEngine.InputSystem.Users
{
/// <summary>
/// Options to modify the behavior on <see cref="InputUser.PerformPairingWithDevice"/>.
/// </summary>
[Flags]
public enum InputUserPairingOptions
{
/// <summary>
/// Default behavior.
/// </summary>
None = 0,
/// <summary>
/// Even if the device is already paired to a user account at the platform level, force the user to select
/// an account.
/// </summary>
/// <remarks>
/// This is only supported on Xbox and Switch, at the moment.
///
/// On PS4, this is ignored as account pairing is under system control. If the user wants to switch accounts,
/// he/she does so by pressing the PS4 button on the controller.
///
/// On Xbox, this option will bring up the account picker even if the device is already paired to a user.
/// This behavior is useful to allow the player to change accounts.
///
/// On platforms other than Xbox and Switch, this option is ignored.
/// </remarks>
ForcePlatformUserAccountSelection = 1 << 0,
/// <summary>
/// Suppress user account selection when supported at the platform level and a device is not currently paired
/// to a user account.
/// </summary>
/// <remarks>
/// On Xbox, if a device that does not currently have a user account logged in on it is paired to an
/// <see cref="InputUser"/>, no account picker will come up and the device will be used without an associated
/// user account.
///
/// On Switch, this prevents the user management applet from coming up.
/// </remarks>
ForceNoPlatformUserAccountSelection = 1 << 1,
/// <summary>
/// If the user already has paired devices, unpair them first.
/// </summary>
UnpairCurrentDevicesFromUser = 1 << 3,
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 33c4f889206d84e84b124cc6f7367963
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,105 @@
using System;
////WIP
//how is it achieved that this applies on a per-device level rather than for all devices of a given type?
//do we do this at the event-level?
//where to do perform the input modification? pre-source or post-source?
//pre-source:
// + can be persisted such that the outcome is agnostic to user profile settings
// - no longer possible to have input routed to multiple users from same device
//
//post-source:
// + no need to modify device
////REVIEW: add ability to have per-device (or device layout?) settings?
namespace UnityEngine.InputSystem.Users
{
/// <summary>
/// A user profile may alter select aspects of input behavior at runtime.
/// </summary>
/// <remarks>
/// This class implements several user adjustable input behaviors commonly found in games, such
/// as mouse sensitivity and axis inversion.
///
/// Note that the behaviors only work in combination with actions, that is, for users that have
/// actions associated with them via <see cref="InputUser.AssociateActionsWithUser(IInputActionCollection)"/>.
/// The behaviors do not alter the input as present directly on the devices. Meaning that, for example,
/// <see cref="invertMouseX"/> will not impact <see cref="Vector2.x"/> of <see cref="Mouse.delta"/> but will
/// rather impact the value read out with <see cref="InputAction.CallbackContext.ReadValue"/> from an action
/// bound to mouse deltas.
///
/// In other words, all the input behaviors operate at the binding level and modify <see cref="InputBinding"/>s.
/// ////REVIEW: does this really make sense?
/// </remarks>
[Serializable]
internal class InputUserSettings
{
/// <summary>
/// Customized bindings for the user.
/// </summary>
/// <remarks>
/// This will only contain customizations explicitly applied to the user's bindings
/// and will not contain default bindings. It is thus not a complete set of bindings
/// but rather just a set of customizations.
/// </remarks>
public string customBindings { get; set; }
////REVIEW: for this to impact position, too, we need to know the screen dimensions
/// <summary>
/// Invert X on <see cref="Mouse.position"/> and <see cref="Mouse.delta"/>.
/// </summary>
public bool invertMouseX { get; set; }
/// <summary>
/// Invert Y on <see cref="Mouse.position"/> and <see cref="Mouse.delta"/>.
/// </summary>
public bool invertMouseY { get; set; }
/// <summary>
/// Smooth mouse motion on both X and Y ...
/// </summary>
public float? mouseSmoothing { get; set; }
public float? mouseSensitivity { get; set; }
/// <summary>
/// Invert X axis on <see cref="Gamepad.leftStick"/> and <see cref="Gamepad.rightStick"/>.
/// </summary>
public bool invertStickX { get; set; }
/// <summary>
/// Invert Y axis on <see cref="Gamepad.leftStick"/> and <see cref="Gamepad.rightStick"/>.
/// </summary>
public bool invertStickY { get; set; }
/// <summary>
/// If true, swap sides
/// </summary>
public bool swapSticks { get; set; }
/// <summary>
/// Swap <see cref="Gamepad.leftShoulder"/> and <see cref="Gamepad.rightShoulder"/> on gamepads.
/// </summary>
public bool swapBumpers { get; set; }
/// <summary>
/// Swap <see cref="Gamepad.leftTrigger"/> and <see cref="Gamepad.rightTrigger"/> on gamepads.
/// </summary>
public bool swapTriggers { get; set; }
public bool swapDpadAndLeftStick { get; set; }
public float vibrationStrength { get; set; }
public virtual void Apply(IInputActionCollection actions)
{
//set overrideProcessors and redirectPaths on respective bindings
}
[SerializeField] private string m_CustomBindings;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f720cfe5a69dc41b28e4c0a6ac2054c5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: