File size: 2,320 Bytes
18a519f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
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;
    }
}