fna-workbench

fna-workbench Git Source Tree


Root/src/Input/GamePadTriggers.cs

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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#region License
/* FNA - XNA4 Reimplementation for Desktop Platforms
 * Copyright 2009-2016 Ethan Lee and the MonoGame Team
 *
 * Released under the Microsoft Public License.
 * See LICENSE for details.
 */
#endregion
 
namespace Microsoft.Xna.Framework.Input
{
    public struct GamePadTriggers
    {
        #region Public Properties
 
        public float Left
        {
            get
            {
                return left;
            }
            internal set
            {
                left = MathHelper.Clamp(value, 0f, 1f);
            }
        }
        public float Right
        {
            get
            {
                return right;
            }
            internal set
            {
                right = MathHelper.Clamp(value, 0f, 1f);
            }
        }
 
        #endregion
 
        #region Private Variables
 
        private float left;
        private float right;
 
        #endregion
 
        #region Public Constructor
 
        public GamePadTriggers(float leftTrigger, float rightTrigger):this()
        {
            Left = leftTrigger;
            Right = rightTrigger;
        }
 
        #endregion
 
        #region Public Static Operators and Override Methods
 
        /// <summary>
        /// Determines whether two specified instances of <see cref="GamePadTriggers"/> are
        /// equal.
        /// </summary>
        /// <param name="left">The first object to compare.</param>
        /// <param name="right">The second object to compare.</param>
        /// <returns>
        /// True if <paramref name="left"/> and <paramref name="right"/> are equal;
        /// otherwise, false.
        /// </returns>
        public static bool operator ==(GamePadTriggers left, GamePadTriggers right)
        {
            return (    (MathHelper.WithinEpsilon(left.left, right.left)) &&
                    (MathHelper.WithinEpsilon(left.right, right.right)) );
        }
 
        /// <summary>
        /// Determines whether two specified instances of <see cref="GamePadTriggers"/> are
        /// not equal.
        /// </summary>
        /// <param name="left">The first object to compare.</param>
        /// <param name="right">The second object to compare.</param>
        /// <returns>
        /// True if <paramref name="left"/> and <paramref name="right"/> are not equal;
        /// otherwise, false.
        /// </returns>
        public static bool operator !=(GamePadTriggers left, GamePadTriggers right)
        {
            return !(left == right);
        }
 
        /// <summary>
        /// Returns a value indicating whether this instance is equal to a specified object.
        /// </summary>
        /// <param name="obj">An object to compare to this instance.</param>
        /// <returns>
        /// True if <paramref name="obj"/> is a <see cref="GamePadTriggers"/> and has the
        /// same value as this instance; otherwise, false.
        /// </returns>
        public override bool Equals(object obj)
        {
            return (obj is GamePadTriggers) && (this == (GamePadTriggers) obj);
        }
 
        public override int GetHashCode ()
        {
            return this.Left.GetHashCode() + this.Right.GetHashCode();
        }
 
        #endregion
    }
}

Archive Download this file

Branches

Number of commits:
Page rendered in 0.14683s using 11 queries.