r e a d o n l y

This commit is contained in:
Isaac Marovitz 2023-09-19 11:05:20 -04:00 committed by Isaac Marovitz
parent 6846f23c62
commit fffe67b5c5

View file

@ -4,45 +4,45 @@ namespace Ryujinx.Input
{
public enum ButtonValueType { Key, GamepadButtonInputId, StickId }
public struct ButtonValue
public readonly struct ButtonValue
{
private ButtonValueType Type;
private uint RawValue;
private readonly ButtonValueType _type;
private readonly uint _rawValue;
public ButtonValue(Key key)
{
Type = ButtonValueType.Key;
RawValue = (uint)key;
_type = ButtonValueType.Key;
_rawValue = (uint)key;
}
public ButtonValue(GamepadButtonInputId gamepad)
{
Type = ButtonValueType.GamepadButtonInputId;
RawValue = (uint)gamepad;
_type = ButtonValueType.GamepadButtonInputId;
_rawValue = (uint)gamepad;
}
public ButtonValue(StickInputId stick)
{
Type = ButtonValueType.StickId;
RawValue = (uint)stick;
_type = ButtonValueType.StickId;
_rawValue = (uint)stick;
}
public Common.Configuration.Hid.Key AsKey()
{
Debug.Assert(Type == ButtonValueType.Key);
return (Common.Configuration.Hid.Key)RawValue;
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;
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;
Debug.Assert(_type == ButtonValueType.StickId);
return (Common.Configuration.Hid.Controller.StickInputId)_rawValue;
}
}
}