public override void _Input(InputEvent _event) { var method = _event.InputMethod(); if (method == InputMethod.None) { return; } if (method != InputMethod.None && method != CurrentInputMethod) { CurrentInputMethod = method; if (IsVisibleInTree()) { InitializeKeybindings(); } } if (ActionWaitingForInput != null) { GetNode <Control>(keybindingPopupPath).Hide(); KeybindingElement element = GetKeybingingElement(ActionWaitingForInput); InputMap.ActionEraseEvent(ActionWaitingForInput, element.InputEvent); InputMap.ActionAddEvent(ActionWaitingForInput, _event); element.InputEvent = _event; ActionWaitingForInput = null; } }
public static void UnBind(string KeyName) { KeyName = KeyName.ToLower(); Godot.Collections.Array actions = InputMap.GetActions(); foreach (string a in actions) { if (!a.Contains("ui_")) { Godot.Collections.Array actionList = InputMap.GetActionList(a); foreach (InputEvent ie in actionList) { if (ie is InputEventKey iek) { string key = OS.GetScancodeString(iek.Scancode); if (key.ToLower() == KeyName) { InputMap.ActionEraseEvent(a, iek); RemoveBind(BindingsWithArg, a); RemoveBind(BindingsWithArgDistinct, a); RemoveBind(BindingsWithoutArg, a); RemoveBind(BindingsWithoutArgDistinct, a); } } } } } }
public static void EraseActionEvents(string key) { var actions = InputMap.GetActionList(key); foreach (var obj in actions) { var ev = obj as InputEvent; if (InputMap.HasAction(key)) { InputMap.ActionEraseEvent(key, ev); } } }
public void RemoveControl(Array binds) { var action = (ActionType)binds[0]; var inputEvent = (InputEvent)binds[1]; var node = (HBoxContainer)binds[2]; var type = inputEvent.ToInputBind().EventType; Settings.ActionControls[action].RemoveAll(x => x.EventType == type); InputMap.ActionEraseEvent(action.ToString(), inputEvent); node.QueueFree(); }
private void ClearKey(string Key, string Action) { InputEventKey EventKey = new InputEventKey(); EventKey.Scancode = (uint)EnumUtil.GetKeyFromString <int, KeyList>(Key); if (InputMap.HasAction(Action)) { if (InputMap.ActionHasEvent(Action, EventKey)) { InputMap.ActionEraseEvent(Action, EventKey); } } }
/// <summary> Unbind a mouse button from firing an action. </summary> public static void UnbindMouseButton(ButtonList mouseButton, string actionName) { if (InputMap.HasAction(actionName)) { foreach (InputEvent inputEvent in InputMap.GetActionList(actionName)) { if (inputEvent is InputEventMouseButton) // It could also be an InputEventKey { InputEventMouseButton mbEvent = (InputEventMouseButton)inputEvent; if (mbEvent.ButtonIndex == (int)mouseButton) { InputMap.ActionEraseEvent(actionName, inputEvent); return; } } } } }
/// <summary> Unbind a key from firing an action. </summary> public static void UnbindKey(KeyList key, string actionName) { if (InputMap.HasAction(actionName)) { foreach (InputEvent inputEvent in InputMap.GetActionList(actionName)) { if (inputEvent is InputEventKey) // It could also be an InputEventMouseButton { InputEventKey keyEvent = (InputEventKey)inputEvent; if (keyEvent.Scancode == (int)key) { InputMap.ActionEraseEvent(actionName, inputEvent); return; } } } } }
public override void _Input(InputEvent @event) { if (changing) { if (globale.controller_mode == "keyboard") { if (@event is InputEventKey) { Godot.Collections.Array old_button = InputMap.GetActionList(liste_strings[input_changing]); foreach (InputEvent e in old_button) { if (e is InputEventKey) { InputMap.ActionEraseEvent(liste_strings[input_changing], e); } } InputMap.ActionAddEvent(liste_strings[input_changing], @event); changing = false; changinge.Visible = changing; update(); } } else if (globale.controller_mode == "controller") { if (@event is InputEventJoypadButton) { Godot.Collections.Array old_button = InputMap.GetActionList(liste_strings[input_changing]); foreach (InputEvent e in old_button) { if (@event is InputEventJoypadButton) { InputMap.ActionEraseEvent(liste_strings[input_changing], e); } } InputMap.ActionAddEvent(liste_strings[input_changing], @event); changing = false; changinge.Visible = changing; update(); } } } }