|
1 | | -namespace Lench.AdvancedControls.Input |
| 1 | +#pragma warning disable CS0660, CS0661 |
| 2 | +namespace Lench.AdvancedControls.Input |
2 | 3 | { |
3 | 4 | /// <summary> |
4 | 5 | /// Button interface for mapping in Input axes. |
5 | 6 | /// </summary> |
6 | | - public interface Button |
| 7 | + public abstract class Button |
7 | 8 | { |
8 | 9 | /// <summary> |
9 | 10 | /// Identifier string containing full information. |
10 | 11 | /// </summary> |
11 | | - string ID { get; } |
| 12 | + public abstract string ID { get; } |
12 | 13 |
|
13 | 14 | /// <summary> |
14 | 15 | /// Button's display name. |
15 | 16 | /// </summary> |
16 | | - string Name { get; } |
| 17 | + public abstract string Name { get; } |
17 | 18 |
|
18 | 19 | /// <summary> |
19 | 20 | /// Button value is 1 if pressed and 0 if released. |
20 | 21 | /// Analog buttons can take values in between. |
21 | 22 | /// </summary> |
22 | | - float Value { get; } |
| 23 | + public abstract float Value { get; } |
| 24 | + |
| 25 | + /// <summary> |
| 26 | + /// Compares buttons a and b by values. |
| 27 | + /// </summary> |
| 28 | + /// <param name="a"></param> |
| 29 | + /// <param name="b"></param> |
| 30 | + /// <returns></returns> |
| 31 | + public static bool operator ==(Button a, Button b) |
| 32 | + { |
| 33 | + if ((object)a == null && (object)b == null) |
| 34 | + return true; |
| 35 | + if (((object)a == null) != ((object)b == null)) |
| 36 | + return false; |
| 37 | + if (a.GetType() != b.GetType()) |
| 38 | + return false; |
| 39 | + return a.ID == b.ID; |
| 40 | + } |
| 41 | + |
| 42 | + /// <summary> |
| 43 | + /// Compares buttons a and b by values. |
| 44 | + /// </summary> |
| 45 | + /// <param name="a"></param> |
| 46 | + /// <param name="b"></param> |
| 47 | + /// <returns></returns> |
| 48 | + public static bool operator !=(Button a, Button b) |
| 49 | + { |
| 50 | + return !(a == b); |
| 51 | + } |
23 | 52 |
|
24 | 53 | #pragma warning disable CS1591 |
25 | | - bool IsDown { get; } |
26 | | - bool Pressed { get; } |
27 | | - bool Released { get; } |
28 | | - bool Connected { get; } |
| 54 | + public abstract bool IsDown { get; } |
| 55 | + public abstract bool Pressed { get; } |
| 56 | + public abstract bool Released { get; } |
| 57 | + public abstract bool Connected { get; } |
29 | 58 | } |
30 | 59 | } |
0 commit comments