aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Input/Button.cs
blob: 4289901ce927541b5f4e462cc95bf71735401bae (plain) (blame)
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
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);
        }
    }
}