aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Input/Button.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Ryujinx.Input/Button.cs')
-rw-r--r--src/Ryujinx.Input/Button.cs33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/Ryujinx.Input/Button.cs b/src/Ryujinx.Input/Button.cs
new file mode 100644
index 00000000..4289901c
--- /dev/null
+++ b/src/Ryujinx.Input/Button.cs
@@ -0,0 +1,33 @@
+using System;
+
+namespace Ryujinx.Input
+{
+ public readonly struct Button
+ {
+ public readonly ButtonType Type;
+ private readonly uint _rawValue;
+
+ public Button(Key key)
+ {
+ Type = ButtonType.Key;
+ _rawValue = (uint)key;
+ }
+
+ public Button(GamepadButtonInputId gamepad)
+ {
+ Type = ButtonType.GamepadButtonInputId;
+ _rawValue = (uint)gamepad;
+ }
+
+ public Button(StickInputId stick)
+ {
+ Type = ButtonType.StickId;
+ _rawValue = (uint)stick;
+ }
+
+ public T AsHidType<T>() where T : Enum
+ {
+ return (T)Enum.ToObject(typeof(T), _rawValue);
+ }
+ }
+}