void KeyboardAction(InputEventKey key) { Vector2 input_movement_vector = new Vector2(); Vector3 Direction = new Vector3(); switch (key.Scancode) { case (int)KeyList.W: case (int)KeyList.Up: input_movement_vector.y -= 1; break; case (int)KeyList.S: case (int)KeyList.Down: input_movement_vector.y += 1; break; case (int)KeyList.A: case (int)KeyList.Left: input_movement_vector.x -= 1; break; case (int)KeyList.D: case (int)KeyList.Right: input_movement_vector.x += 1; break; } Direction = GlobalTransform.basis.z.Normalized() * input_movement_vector.y; Direction += GlobalTransform.basis.x.Normalized() * input_movement_vector.x * 2; AddGlobalOrigin(Direction); }
public override void _UnhandledKeyInput(InputEventKey @event) { if (Input.IsKeyPressed((int)KeyList.Space)) { GenerateGalaxy(); } }
private void AddKeyboardInputsToGameMapping() { string playerPrefix; string action; InputEventKey iek; SC.IDictionaryEnumerator it; Dictionary mapping; for (int i = 1; i <= playerAmount; i++) { playerPrefix = this.CreateString("p", i, "_"); mapping = keyboardInputMapping[i.ToString()] as Dictionary; if (mapping != null) { it = mapping.GetEnumerator(); while (it.MoveNext()) { action = this.CreateString(playerPrefix, it.Entry.Key); InputMap.ActionEraseEvents(action); iek = new InputEventKey(); iek.Scancode = uint.Parse(it.Entry.Value as string); InputMap.ActionAddEvent(action, iek); } } } }
public void DoCameraZoom(Player instance, InputEventKey emb) { if (currentZoom == null) { currentZoom = new Vector2(); } if (emb.IsPressed()) { if (emb.Scancode == Keybinds.KEYBIND_ZOOM_IN) { if (zoomVal > instance.MinZoom) { currentZoom.x = instance.camera.Translation.z + instance.ZoomSpeed; currentZoom.y = instance.camera.Translation.y - 0.05f; zoomVal -= instance.ZoomSpeed; UpdateCameraZoom(instance); } } else if (emb.Scancode == Keybinds.KEYBIND_ZOOM_OUT) { if (zoomVal < instance.MaxZoom) { currentZoom.x = instance.camera.Translation.z - instance.ZoomSpeed; currentZoom.y = instance.camera.Translation.y + 0.05f; zoomVal += instance.ZoomSpeed; UpdateCameraZoom(instance); } } } }
public static void CheckAndAddAction(string action, KeyList key, bool ctrl = false, bool alt = false, bool shift = false, bool cmd = false) { if (!InputMap.HasAction(action)) { //Tell user that input was added string message = action + " not found in Input Map. Action was added and set to "; if (ctrl || alt || shift || cmd) { message += (ctrl ? "ctrl + " : "") + (alt ? "alt + " : "") + (shift ? "shift + " : "") + (cmd ? "cmd + " : ""); } message += key.ToString(); GD.Print(message); //Add the action InputMap.AddAction(action); //Create the event InputEventWithModifiers inputEventWithModifiers = new InputEventKey { Scancode = (uint)key }; inputEventWithModifiers.Control = ctrl; inputEventWithModifiers.Alt = alt; inputEventWithModifiers.Shift = shift; inputEventWithModifiers.Command = cmd; //Add event to action InputMap.ActionAddEvent(action, inputEventWithModifiers); } }
internal InputKeyThrottleAxis(string a_eventKeyName, InputEventKey a_positive, InputEventKey a_negative, float a_gravity = 0f, float a_sensitivity = 2f) : base(a_eventKeyName, a_positive, a_negative, a_gravity, a_sensitivity) { }
public override void _UnhandledKeyInput(InputEventKey @event) { if (@event.IsActionPressed("ui_do_less")) { OnButtonPressed(); } }
public override void _Ready() { GetPopup().AddCheckItem("Show Inspector"); GetPopup().AddCheckItem("Show Binder"); GetPopup().AddCheckItem("Show Dock"); GetPopup().AddCheckItem("Big Icons"); Array inspectorActionList = InputMap.GetActionList("inspector_toggle"); InputEventKey inspectorKey = (InputEventKey)inspectorActionList[0]; GetPopup().SetItemAccelerator(0, inspectorKey.GetScancodeWithModifiers()); Array binderActionList = InputMap.GetActionList("binder_toggle"); InputEventKey binderKey = (InputEventKey)binderActionList[0]; GetPopup().SetItemAccelerator(1, binderKey.GetScancodeWithModifiers()); Array dockActionList = InputMap.GetActionList("dock_toggle"); InputEventKey dockKey = (InputEventKey)dockActionList[0]; GetPopup().SetItemAccelerator(2, dockKey.GetScancodeWithModifiers()); GetPopup().Connect("index_pressed", this, nameof(OnItemPressed)); CallDeferred(nameof(SetValues)); }
public static InputEventKey GetInputFromKey(Keys key) { InputEventKey inputEvent = new InputEventKey(); inputEvent.Scancode = (uint)OS.FindScancodeFromString((string)SettingsData[InputHandler.GetNameFromKey(key)]); return(inputEvent); }
private void LoadInputMapConfiguration(string configPath, string defaultPath) { ConfigFile configFile = new ConfigFile(); Directory directory = new Directory(); Dictionary <string, Dictionary <string, object> > config = this.LoadConfig(configPath, defaultPath, configFile, directory); foreach (var item in config) { var action = item.Key; var value = item.Value; var deadzone = value.ContainsKey("deadzone") ? (float)value["deadzone"] : 0.5f; var gamepad = value.ContainsKey("GamePad") ? (int)value["GamePad"] : -1; var keyboard = value.ContainsKey("Keyboard") ? value["Keyboard"] as string : ""; if (action != "" && gamepad != -1 && keyboard != "") { if (!InputMap.HasAction(action)) { InputMap.AddAction(action); } var inputKey = new InputEventKey(); inputKey.Scancode = (uint)OS.FindScancodeFromString(keyboard); InputMap.ActionAddEvent(action, inputKey); var inputjoy = new InputEventJoypadButton(); inputjoy.ButtonIndex = gamepad; InputMap.ActionAddEvent(action, inputjoy); InputMap.ActionSetDeadzone(action, deadzone); } } }
public override void _UnhandledKeyInput(InputEventKey @event) { if (@event.Pressed && @event.Scancode == (int)KeyList.Escape) { _on_BtnReturn_pressed(); } }
internal InputEventToggle(string a_eventKeyName, InputEventKey a_input, bool a_state = false) : base(a_eventKeyName) { _isActive = a_state; toggleKey = a_input; toggleKey.onActivation += OnToggle; }
public void mimic_esc() { var e = new InputEventKey(); e.Scancode = (uint)KeyList.Escape; Input.ParseInputEvent(e); }
internal InputEventToggle(string a_eventKeyName, InputEventKey a_input, bool a_state = false) : base(a_eventKeyName) { _isActive = a_state; toggleKey = a_input; toggleKey.onActivation += OnToggle; }
public override void _UnhandledKeyInput(InputEventKey @event) { if (@event.IsActionPressed("main_save")) { GetNode <EditorControls>("..").SaveDiagram(); } }
internal InputKeyThrottleAxis(EInputAxisKey a_eventKey, InputEventKey a_positive, InputEventKey a_negative, float a_gravity = 0f, float a_sensitivity = 2f) : this(a_eventKey.ToString(), a_positive, a_negative, a_gravity, a_sensitivity) { }
public static void SetActionFromString(string key, string code) { InputEventKey inputEvent = new InputEventKey(); inputEvent.Scancode = (uint)OS.FindScancodeFromString(code); SetActionFromInput(key, inputEvent); }
internal InputKeyAxis(EInputAxisKey a_eventKey, InputEventKey a_positive, InputEventKey a_negative, float a_gravity = 0f, float a_sensitivity = 2f) : this(a_eventKey.ToString(), a_positive, a_negative, a_gravity, a_sensitivity) { }
internal InputKeyThrottleAxis(string a_eventKeyName, InputEventKey a_positive, InputEventKey a_negative, float a_gravity = 0f, float a_sensitivity = 2f) : base(a_eventKeyName, a_positive, a_negative, a_gravity, a_sensitivity) { }
private static void applyKey(string action_name, string key) { int scancode = OS.FindScancodeFromString(key); var e = new InputEventKey(); e.Scancode = (uint)scancode; InputMap.ActionAddEvent(action_name, e); }
public void UpdatingKeyConfig() { InputEventKey updatedKey = SettingsOptions.GetInputFromKey(input); InputHandler.SetActionFromInput(InputHandler.GetNameFromKey(input), updatedKey); button.Text = OS.GetScancodeString(updatedKey.Scancode); previousText = button.Text; }
public override void _UnhandledKeyInput(InputEventKey @event) { if (@event.IsActionPressed("ui_cancel", true)) { OnCloseButtonPressed(); return; } }
public static string GetScanCode(string key) { string holder = ""; InputEventKey eventKey = (InputEventKey)InputMap.GetActionList(key)[0]; holder = OS.GetScancodeString(eventKey.Scancode); return(holder); }
public static void UpdateKeyData(Keys name, InputEventKey key) { if (SettingsData == null) { UpdateDataFromSource(); } NewSettings[InputHandler.GetNameFromKey(name)] = OS.GetScancodeString(key.Scancode); }
public override void _UnhandledKeyInput(InputEventKey @event) { if (AcceptInput) { System.Console.WriteLine(@event.Scancode == (int)'K'); } AcceptInput = !AcceptInput; }
public override void _UnhandledKeyInput(InputEventKey key) { if (Pressed && key.IsActionPressed("main_remove")) { OnItemSelected(0); Pressed = false; ReleaseFocus(); GetPopup().Visible = false; } }
protected virtual void Awake() { Debug.Log(name + " : " + key.ToString()); keycodebutton.callback += ModifyKeyCode; triggerModeButton.callback += ToggleActivationMode; _inputKey = new InputEventKey(key, binding); UpdateDisplay(); }
internal InputEventSwitch(string a_eventKeyName, InputEventKey a_inputOn, InputEventKey a_inputOff, bool a_state = false) : base(a_eventKeyName) { _isActive = a_state; toggleOn = a_inputOn; toggleOn.onActivation += OnToggleOn; toggleOff = a_inputOff; toggleOff.onActivation += OnToggleOff; }
internal InputEventSwitch(string a_eventKeyName, InputEventKey a_inputOn, InputEventKey a_inputOff, bool a_state = false) : base(a_eventKeyName) { _isActive = a_state; toggleOn = a_inputOn; toggleOn.onActivation += OnToggleOn; toggleOff = a_inputOff; toggleOff.onActivation += OnToggleOff; }
public override void _UnhandledKeyInput(InputEventKey @event) { if (@event.IsActionPressed("Inventory")) { HandleInventory(); } else if (@event.IsActionPressed("Back")) { HandleBack(); } }
protected virtual void Awake () { keycodebutton.callback += ModifyKeyCode; triggerModeButton.callback += ToggleActivationMode; _inputKey = new InputEventKey(key,binding); //FFEngine.Inputs.Register(_inputKey); UpdateDisplay(); }
/// <summary> Bind a key to fire an action. </summary> public static void BindKey(KeyList key, string actionName) { InputEventKey inputEvent = new InputEventKey(); inputEvent.Scancode = (uint)key; if (!InputMap.HasAction(actionName)) { InputMap.AddAction(actionName); } InputMap.ActionAddEvent(actionName, inputEvent); }
private void HandleInput(InputEventKey inputEventKey) { if (inputEventKey != null && inputEventKey.Pressed) { uint scancode = inputEventKey.Scancode; if (scancode == (uint)KeyList.End) { GetTree().Paused = !GetTree().Paused; } } }
public override void _UnhandledKeyInput(InputEventKey @event) { // I don't like iterating over every single possible action every time - surely there's a nicer way to do this? foreach (string mapping in ActionMapping.AllMappings) { if (@event.IsActionPressed(mapping, true) && _playerMappingQueue.Count < _queueSize) { _playerMappingQueue.Add(new InputAction(mapping)); return; } } }
private void HandleExit(InputEventKey inputEventKey) { if (inputEventKey != null && inputEventKey.Pressed) { uint keycode = inputEventKey.Scancode; if ((uint)KeyList.Escape == keycode) { ShowScreen(false); } } }
internal InputKeyAxis(string a_eventKeyName, InputEventKey a_positive, InputEventKey a_negative, float a_gravity = 0f, float a_sensitivity = 2f) : base(a_eventKeyName) { _sensitibity = a_sensitivity; _currentValue = 0f; _gravity = a_gravity; inputPositive = a_positive; if(inputPositive != null) { inputPositive.onActivation += Increase; } inputNegative = a_negative; if(inputNegative != null) { inputNegative.onActivation += Decrease; } }
internal InputEventSwitch(EInputEventKey a_eventKey, InputEventKey a_inputOn, InputEventKey a_inputOff, bool a_state = false) : this(a_eventKey.ToString(), a_inputOn, a_inputOff, a_state) { }
internal InputEventToggle(EInputEventKey a_eventKey, InputEventKey a_input, bool a_state = false) : this(a_eventKey.ToString(), a_input, a_state) { }