blob: f037e6b60a65f1826b643c554508529354edea25 (
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
using System.Diagnostics;
namespace Ryujinx.Input
{
public enum ButtonValueType { Key, GamepadButtonInputId, StickId }
public readonly struct ButtonValue
{
private readonly ButtonValueType _type;
private readonly uint _rawValue;
public ButtonValue(Key key)
{
_type = ButtonValueType.Key;
_rawValue = (uint)key;
}
public ButtonValue(GamepadButtonInputId gamepad)
{
_type = ButtonValueType.GamepadButtonInputId;
_rawValue = (uint)gamepad;
}
public ButtonValue(StickInputId stick)
{
_type = ButtonValueType.StickId;
_rawValue = (uint)stick;
}
public Common.Configuration.Hid.Key AsKey()
{
Debug.Assert(_type == ButtonValueType.Key);
return (Common.Configuration.Hid.Key)_rawValue;
}
public Common.Configuration.Hid.Controller.GamepadInputId AsGamepadButtonInputId()
{
Debug.Assert(_type == ButtonValueType.GamepadButtonInputId);
return (Common.Configuration.Hid.Controller.GamepadInputId)_rawValue;
}
public Common.Configuration.Hid.Controller.StickInputId AsGamepadStickId()
{
Debug.Assert(_type == ButtonValueType.StickId);
return (Common.Configuration.Hid.Controller.StickInputId)_rawValue;
}
}
}
|