public virtual void OnInputInitialize() { if (SettingsType == null) { return; } object settings = _Settings; if (settings == null) { return; } foreach (PropertyInfo prop in SettingsType.GetProperties()) { if (!prop.CanRead) { continue; } if (typeof(ButtonBinding).IsAssignableFrom(prop.PropertyType)) { InitializeButtonBinding(settings, prop); } else if (false) { // TODO: JoystickBindings } } }
public virtual void OnInputDeregister() { if (SettingsType == null) { return; } object settings = _Settings; foreach (PropertyInfo prop in SettingsType.GetProperties()) { if (!prop.CanRead) { continue; } if (typeof(ButtonBinding).IsAssignableFrom(prop.PropertyType)) { if (!(prop.GetValue(settings) is ButtonBinding binding)) { continue; } binding.Button?.Deregister(); } else if (false) { // TODO: JoystickBindings } } }
public virtual void OnInputInitialize() { if (SettingsType == null) { return; } object settings = _Settings; if (settings == null) { return; } foreach (PropertyInfo prop in SettingsType.GetProperties()) { if (!prop.CanRead) { continue; } if (typeof(ButtonBinding).IsAssignableFrom(prop.PropertyType)) { if (!(prop.GetValue(settings) is ButtonBinding binding)) { binding = new ButtonBinding(); DefaultButtonBindingAttribute defaults = prop.GetCustomAttribute <DefaultButtonBindingAttribute>(); if (defaults != null) { if (defaults.Button != 0) { binding.Buttons.Add(defaults.Button); } if (defaults.Key != 0) { binding.Keys.Add(defaults.Key); } } prop.SetValue(settings, binding); } VirtualButton vbutton = new VirtualButton(); foreach (Keys key in binding.Keys) { vbutton.Nodes.Add(new VirtualButton.KeyboardKey(key)); } foreach (Buttons button_ in binding.Buttons) { Buttons button = button_; if ((button & Buttons.LeftTrigger) == Buttons.LeftTrigger) { vbutton.Nodes.Add(new VirtualButton.PadLeftTrigger(Input.Gamepad, 0.25f)); button &= ~Buttons.LeftTrigger; } if ((button & Buttons.RightTrigger) == Buttons.RightTrigger) { vbutton.Nodes.Add(new VirtualButton.PadLeftTrigger(Input.Gamepad, 0.25f)); button &= ~Buttons.RightTrigger; } if (button != 0) { vbutton.Nodes.Add(new VirtualButton.PadButton(Input.Gamepad, button)); } } binding.Button = vbutton; } else if (false) { // TODO: JoystickBindings } } }