internal static bool KeyPressed(Microsoft.Xna.Framework.Input.Keys key, GameTime gameTime) { lock (lockObj) { return(CapturedKeyboardComponent?.KeyPressed(key, gameTime) ?? false); } }
void InputManager_OnKeyReleased(Microsoft.Xna.Framework.Input.Keys key, GameTime gameTime) { lock (lockObj) { CurrentScene?.KeyReleased(key, gameTime); } }
public KeySelector(string name, Microsoft.Xna.Framework.Input.Keys @default) { InitializeComponent(); label.Text = name; value = @default; textBox.Text = value.ToString(); }
private void handleKeyboardInput() { Keys key = RawKeyboardInput.GetSingleJustPressedKey(); if (key == Keys.None) // if did not press a new key { if (lastKey != Keys.None) // but key was down on previous frame { checkKeyRepeat(); if (isRepeatingKey) { handleContinueRepeatingKey(); } else { handleBeginRepeatingKey(); } } return; } if (isRepeatingKey) { resetKeyRepeat(); } lastKey = key; handleSingleKey(key); }
public void OnInitialize() { if (!Keys.TryParse(IniAPI.ReadIni("PortableCraftingGuide", "ToggleKey", "C", writeIt: true), out pcgKey)) { pcgKey = Keys.C; } Loader.RegisterHotkey(() => { pcg = !pcg; if (!pcg) { Main.InGuideCraftMenu = false; Main.player[Main.myPlayer].talkNPC = -1; } }, pcgKey); Keys invKey; Keys.TryParse(Main.cInv, out invKey); Loader.RegisterHotkey(() => { pcg = false; }, invKey); }
public override bool KeyReleased(Microsoft.Xna.Framework.Input.Keys key) { if (key == Microsoft.Xna.Framework.Input.Keys.W) { moveForward = false; return(true); } if (key == Microsoft.Xna.Framework.Input.Keys.S) { moveBackward = false; return(true); } if (key == Microsoft.Xna.Framework.Input.Keys.A) { strafeLeft = false; return(true); } if (key == Microsoft.Xna.Framework.Input.Keys.D) { strafeRight = false; return(true); } if (key == Microsoft.Xna.Framework.Input.Keys.LeftShift) { SpeedModifier /= 3.0f; return(true); } return(false); }
public static void RegisterHotkey(string command, Keys key, bool control = false, bool shift = false, bool alt = false, bool ignoreModifierKeys = false) { RegisterHotkey(command, new Hotkey() { Key = key, Control = control, Shift = shift, Alt = alt, IgnoreModifierKeys = ignoreModifierKeys }); }
public static void UnregisterHotkey(Keys key, bool control = false, bool shift = false, bool alt = false, bool ignoreModifierKeys = false) { UnregisterHotkey(new Hotkey() { Key = key, Control = control, Shift = shift, Alt = alt, IgnoreModifierKeys = ignoreModifierKeys }); }
public static void RegisterHotkey(Action action, Keys key, bool control = false, bool shift = false, bool alt = false, bool ignoreModifierKeys = false) { RegisterHotkey(new Hotkey() { Action = action, Key = key, Control = control, Shift = shift, Alt = alt, IgnoreModifierKeys = ignoreModifierKeys }); }
private void KeyboardHandler_KeysPressed(object sender, Microsoft.Xna.Framework.Input.Keys e) { if (e == SettingsManager.Keybindings.Settings.OpenInGameEscapeMenu) { this.HandleEscapeKey(); } }
public NPC() { var npc = Assembly.GetEntryAssembly().GetType("Terraria.NPC"); defaultMaxSpawns = npc.GetField("defaultMaxSpawns", BindingFlags.Static | BindingFlags.NonPublic); defaultSpawnRate = npc.GetField("defaultSpawnRate", BindingFlags.Static | BindingFlags.NonPublic); DefaultMaxSpawns = int.Parse(IniAPI.ReadIni("Spawning", "SpawnLimit", "5", writeIt: true)); DefaultSpawnRate = int.Parse(IniAPI.ReadIni("Spawning", "SpawnRate", "100", writeIt: true)); if (!Keys.TryParse(IniAPI.ReadIni("NPC", "Toggle", "N", writeIt: true), out toggleKey)) toggleKey = Keys.N; if (!Keys.TryParse(IniAPI.ReadIni("NPC", "Increase", "OemPlus", writeIt: true), out increaseKey)) increaseKey = Keys.OemPlus; if (!Keys.TryParse(IniAPI.ReadIni("NPC", "Decrease", "OemMinus", writeIt: true), out decreaseKey)) decreaseKey = Keys.OemMinus; Color purple = Color.Purple; Loader.RegisterHotkey(() => { ModifySpawnLimit(-1); Main.NewText("Spawn limit: " + DefaultMaxSpawns, purple.R, purple.G, purple.B, false); }, decreaseKey, control: true); Loader.RegisterHotkey(() => { ModifySpawnRate(-20); Main.NewText("Spawn rate: " + DefaultSpawnRate + "%", purple.R, purple.G, purple.B, false); }, decreaseKey, control: false); Loader.RegisterHotkey(() => { ModifySpawnLimit(1); Main.NewText("Spawn limit: " + DefaultMaxSpawns, purple.R, purple.G, purple.B, false); }, increaseKey, control: true); Loader.RegisterHotkey(() => { ModifySpawnRate(20); Main.NewText("Spawn rate: " + DefaultSpawnRate + "%", purple.R, purple.G, purple.B, false); }, increaseKey, control: false); Loader.RegisterHotkey(() => { if (DefaultMaxSpawns > 0) { previousMaxSpawns = DefaultMaxSpawns; previousSpawnRate = DefaultSpawnRate; DefaultMaxSpawns = 0; DefaultSpawnRate = 0; KillAllNPCs(); } else { DefaultMaxSpawns = previousMaxSpawns; DefaultSpawnRate = previousSpawnRate; } Main.NewText("Spawn rate: " + DefaultSpawnRate + "%", purple.R, purple.G, purple.B, false); Main.NewText("Spawn limit: " + DefaultMaxSpawns, purple.R, purple.G, purple.B, false); }, toggleKey); }
public void RecieveSpecialInput(Microsoft.Xna.Framework.Input.Keys key) { if (Component.Selected) { Component.SpecialReceived(key); } }
public override void OnKeyDown(Microsoft.Xna.Framework.Input.Keys key) { base.OnKeyDown(key); if (key == Microsoft.Xna.Framework.Input.Keys.Down) { if (_selectedIndex < _items.Count - 1) { _selectedIndex++; } } if (key == Microsoft.Xna.Framework.Input.Keys.Up) { if (_selectedIndex > 0) { _selectedIndex--; } } if (key == Microsoft.Xna.Framework.Input.Keys.Enter) { if (OnActivate != null) { OnActivate(); } } }
public override void PerformKey(Microsoft.Xna.Framework.Input.Keys key) { if (_textEntryActive) { _textEntry.PerformKey(key); } }
/// <summary> /// Checks if the Key used is blocked by either the key whitelist or key blacklist. /// </summary> /// <param name="whiteKeys">The key whitelist.</param> /// <param name="blackKeys">The key blacklist.</param> /// <param name="key">The key to be checked.</param> private static bool KeyBlocked(Keys[] whiteKeys, Keys[] blackKeys, Keys key) { var mapWhite = whiteKeys.Length > 0; var mapBlack = blackKeys.Length > 0; //Check if key is whitelisted: return(!(!mapWhite || (mapWhite && whiteKeys.Contains(key))) || !(!mapBlack || (mapBlack && !blackKeys.Contains(key)))); }
public override bool OnKeyDown(Microsoft.Xna.Framework.Input.Keys key) { if (key == Microsoft.Xna.Framework.Input.Keys.Enter) { exitCallback(); } return(true); }
private void CatchKeyTextBoxEntered(object sender, EventArgs e) { using (KeyReader kr = new KeyReader(label.Text)) { value = kr.ShowSelectDialog(); textBox.Text = value.ToString(); } }
private void RegisterMoveKey(Keyboard info, Keys key, Direction direction) { if (info.IsKeyDown(key) && !registeredpresses.ContainsKey(key)) { registeredpresses.Add(key, Global.GameTimeUpdate.TotalGameTime.TotalSeconds); Game.GetPlayer.Move(direction); } }
public void AddIgnoredKey(Keys keyToIgnore) { mAxisAlignedRectangles.IgnoredKeys.Add(keyToIgnore); mAxisAlignedCubes.IgnoredKeys.Add(keyToIgnore); mPolygons.IgnoredKeys.Add(keyToIgnore); mSpheres.IgnoredKeys.Add(keyToIgnore); mCircles.IgnoredKeys.Add(keyToIgnore); }
private InputFrame DeserializeFrame(BinaryReader reader) { int frames = reader.ReadInt32(); // Keyboard byte keyLength = reader.ReadByte(); XnaKeys[] keys = new XnaKeys[keyLength]; for (int i = 0; i < keyLength; i++) { keys[i] = (XnaKeys)reader.ReadByte(); } // Mouse int mouseX = reader.ReadInt32(); int mouseY = reader.ReadInt32(); int mouseScroll = reader.ReadInt32(); byte mouseButtons = reader.ReadByte(); bool leftButton = (mouseButtons & 0b00001) != 0; bool middleButton = (mouseButtons & 0b00010) != 0; bool rightButton = (mouseButtons & 0b00100) != 0; bool xButton1 = (mouseButtons & 0b01000) != 0; bool xButton2 = (mouseButtons & 0b10000) != 0; // Create frame InputFrame frame = new InputFrame(frames); frame.Keys = keys; frame.MouseX = mouseX; frame.MouseY = mouseY; frame.MouseScroll = mouseScroll; frame.MouseLeft = leftButton; frame.MouseMiddle = middleButton; frame.MouseRight = rightButton; frame.Mouse4 = xButton1; frame.Mouse5 = xButton2; // Gamepads for (int i = 0; i < 4; i++) { frame.Pads[i].Connected = reader.ReadBoolean(); if (!frame.Pads[i].Connected) { continue; } frame.Pads[i].Buttons = reader.ReadUInt16(); frame.Pads[i].LeftTrigger = reader.ReadByte(); frame.Pads[i].RightTrigger = reader.ReadByte(); frame.Pads[i].ThumbLX = reader.ReadInt16(); frame.Pads[i].ThumbLY = reader.ReadInt16(); frame.Pads[i].ThumbRX = reader.ReadInt16(); frame.Pads[i].ThumbRY = reader.ReadInt16(); } return(frame); }
void GameControl_KeyDown(object sender, KeyEventArgs e) { XKeys xkey = KeyboardUtil.ToXna(e.KeyCode); if (!_keys.Contains(xkey)) { _keys.Add(xkey); } }
private void CatchKeyPressed(object sender, KeyEventArgs e) { Microsoft.Xna.Framework.Input.Keys[] keys = Microsoft.Xna.Framework.Input.Keyboard.GetState().GetPressedKeys(); if (keys.Length != 0) { selectedKey = keys[0]; Close(); } }
void GameControl_KeyUp(object sender, KeyEventArgs e) { XKeys xkey = KeyboardUtil.ToXna(e.KeyCode); if (_keys.Contains(xkey)) { _keys.Remove(xkey); } }
protected internal virtual bool KeyReleased(Microsoft.Xna.Framework.Input.Keys key, GameTime gameTime) { if (UserInteractionEnabled == false) { return(true); } return(false); }
internal void BeginRebind() { if (selectIndex == 0 || selectIndex == 1) { newKey = default(Microsoft.Xna.Framework.Input.Keys); bRebindNow = true; collumn = selectIndex; } }
private void KeyboardHandler_KeysPressed(object sender, Microsoft.Xna.Framework.Input.Keys e) { if (!Game1.SplashDone) { if (e == Microsoft.Xna.Framework.Input.Keys.Escape || e == Microsoft.Xna.Framework.Input.Keys.Enter || e == Microsoft.Xna.Framework.Input.Keys.Space) { this.SkipOne(); } } }
void keyReleasedHandler(string keyReleased, Keys key) { if (_buttonHeld != key) { return; } _buttonHeldTime = 0; _buttonHeld = Keys.None; _buttonHeldTimePreRepeat = 0; _buttonHeldString = ""; }
public static String InterpretKey(Microsoft.Xna.Framework.Input.Keys key) { if (m_CameraControls.ContainsKey(key)) { return(m_CameraControls[key]); } else { return(Enum.GetName(key.GetType(), key)); } }
/// <summary> /// Adds a Key to a Binding /// </summary> /// <param name="id">The ID of the Binding</param> /// <param name="key">The Key</param> public void AddKey(string id, Keys key) { Binding binding; if (bindings.TryGetValue(id, out binding)) { if (!binding.Keys.Contains(key)) { binding.Keys.Add(key); } } }
/// <summary> /// Removes a Key from a Binding /// </summary> /// <param name="id">The ID of the Binding</param> /// <param name="key">The Key</param> public void RemoveKey(string id, Keys key) { Binding binding; if (bindings.TryGetValue(id, out binding)) { if (binding.Keys.Contains(key)) { binding.Keys.Remove(key); } } }
public void SetKeyCode(Microsoft.Xna.Framework.Input.Keys key) { var ka = new KeyboardArgument() { KeyCode = key }; gameObjectEvent.EventArguments = ka; gameObjectEvent.EventType = KeyboardType == 0 ? BaseGameObjectEventType.KeyPress : KeyboardType == 1 ? BaseGameObjectEventType.KeyRelease : BaseGameObjectEventType.KeyDown; this.DialogResult = DialogResult.OK; this.Close(); }
public void OnInitialize() { if (!Keys.TryParse(IniAPI.ReadIni("PortableCraftingGuide", "ToggleKey", "C", writeIt: true), out pcgKey)) pcgKey = Keys.C; Loader.RegisterHotkey(() => { pcg = !pcg; if (!pcg) { Main.craftGuide = false; Main.player[Main.myPlayer].talkNPC = -1; } }, pcgKey); Keys invKey; Keys.TryParse(Main.cInv, out invKey); Loader.RegisterHotkey(() => { pcg = false; }, invKey); }
// Is key being held public bool isKeyHeld(XKeys key) { return _keysPressed[(int)key]; }
// Is key pressed public bool isKeyPressed(XKeys key) { int keyCode = (int)key; bool result = !_keysChecked[keyCode] && _keysPressed[keyCode]; if (_keysPressed[keyCode]) { _keysChecked[keyCode] = true; } return result; }
public bool IsKeyDown(XKeys key) { return System.Windows.Input.Keyboard.IsKeyDown(_XKeyToWKey[key]); }
void keyReleasedHandler(string keyReleased, Keys key) { if (_buttonHeld != key) return; _buttonHeldTime = 0; _buttonHeld = Keys.None; _buttonHeldTimePreRepeat = 0; _buttonHeldString = ""; }
void keyPressedHandler(string keyPressed, Keys key) { if (!Selected || !Editable) return; if (_buttonHeld != key) { _buttonHeld = key; _buttonHeldTime = 0; _buttonHeldTimePreRepeat = 0; _buttonHeldString = keyPressed; } bool ctrlPressed = InputManager.IsKeyPressed(Keys.LeftControl) || InputManager.IsKeyPressed(Keys.RightControl); if (ctrlPressed) { switch (key) { case Keys.A: this._selectionStart = new Vector2(0, 0); this._selectionEnd = new Vector2(TextLines[TextLines.Length - 1].Length, TextLines.Length - 1); break; case Keys.C: break; case Keys.X: break; case Keys.V: string text = Clipboard.GetText(); if (!String.IsNullOrEmpty(text)) AppendTextCursor(text); break; case Keys.Back: break; } } else { switch (key) { case Keys.Back: erase(false); break; case Keys.Delete: erase(true); break; case Keys.Left: SelectionArrowKeys(); MoveCursorX(-1); break; case Keys.Right: SelectionArrowKeys(); MoveCursorX(1); break; case Keys.Up: SelectionArrowKeys(); MoveCursorY(-1); break; case Keys.Down: SelectionArrowKeys(); MoveCursorY(1); break; case Keys.Enter: if (MultiLine) AppendTextCursor("\n"); else if (Text.Length != 0 && OnTextSubmitted != null && this.Validate()) OnTextSubmitted(); break; case Keys.Space: AppendTextCursor(" "); break; case Keys.Tab: if (InputManager.IsKeyPressed(Keys.LeftControl)) this.Blur(); if (this.AllowTab && !this.justReceivedFocus) this.FocusNextInputView(reverse: InputManager.IsKeyPressed(Keys.LeftShift)); break; default: if (this.Filter(key)) AppendTextCursor(keyPressed); break; } } ReEvaluateOffset(); }
public Events() { var worldGen = Assembly.GetEntryAssembly().GetType("Terraria.WorldGen"); triggerLunarApocalypse = worldGen.GetMethod("TriggerLunarApocalypse"); spawnMeteor = worldGen.GetField("spawnMeteor"); dropMeteor = worldGen.GetMethod("dropMeteor"); if (!Keys.TryParse(IniAPI.ReadIni("Events", "Meteor", "NumPad0", writeIt: true), out meteor)) meteor = Keys.NumPad0; if (!Keys.TryParse(IniAPI.ReadIni("Events", "BloodMoon", "NumPad1", writeIt: true), out bloodMoon)) bloodMoon = Keys.NumPad1; if (!Keys.TryParse(IniAPI.ReadIni("Events", "GoblinArmy", "NumPad2", writeIt: true), out goblin)) goblin = Keys.NumPad2; if (!Keys.TryParse(IniAPI.ReadIni("Events", "FrostLegion", "NumPad3", writeIt: true), out frost)) frost = Keys.NumPad3; if (!Keys.TryParse(IniAPI.ReadIni("Events", "PirateInvasion", "NumPad4", writeIt: true), out pirates)) pirates = Keys.NumPad4; if (!Keys.TryParse(IniAPI.ReadIni("Events", "SolarEclipse", "NumPad5", writeIt: true), out eclipse)) eclipse = Keys.NumPad5; if (!Keys.TryParse(IniAPI.ReadIni("Events", "PumpkinMoon", "NumPad6", writeIt: true), out pumpkinMoon)) pumpkinMoon = Keys.NumPad6; if (!Keys.TryParse(IniAPI.ReadIni("Events", "FrostMoon", "NumPad7", writeIt: true), out frostMoon)) frostMoon = Keys.NumPad7; if (!Keys.TryParse(IniAPI.ReadIni("Events", "MartianMadness", "NumPad8", writeIt: true), out martians)) martians = Keys.NumPad8; if (!Keys.TryParse(IniAPI.ReadIni("Events", "LunarApocalypse", "NumPad9", writeIt: true), out lunarApocalypse)) lunarApocalypse = Keys.NumPad9; if (!Keys.TryParse(IniAPI.ReadIni("Events", "Moon Lord", "Add", writeIt: true), out moonLord)) moonLord = Keys.Add; Loader.RegisterHotkey(() => { if (Main.invasionType > 0) Main.invasionSize = 0; else Main.StartInvasion(1); }, goblin); Loader.RegisterHotkey(() => { if (Main.invasionType > 0) Main.invasionSize = 0; else Main.StartInvasion(2); }, frost); Loader.RegisterHotkey(() => { if (Main.invasionType > 0) Main.invasionSize = 0; else Main.StartInvasion(3); }, pirates); Loader.RegisterHotkey(() => { if (Main.invasionType > 0) Main.invasionSize = 0; else Main.StartInvasion(4); }, martians); Loader.RegisterHotkey(() => { if (Main.pumpkinMoon) Main.stopMoonEvent(); else Main.startPumpkinMoon(); }, pumpkinMoon); Loader.RegisterHotkey(() => { if (Main.snowMoon) Main.stopMoonEvent(); else Main.startSnowMoon(); }, frostMoon); Loader.RegisterHotkey(() => { if (Terraria.NPC.LunarApocalypseIsUp || Terraria.NPC.AnyNPCs(398)) StopLunarEvent(); else TriggerLunarApocalypse(); }, lunarApocalypse); Loader.RegisterHotkey(() => { if (Terraria.NPC.LunarApocalypseIsUp || Terraria.NPC.AnyNPCs(398)) StopLunarEvent(); else SpawnMoonLord(); }, moonLord); Loader.RegisterHotkey(() => { if (Main.bloodMoon) Main.bloodMoon = false; else TriggerBloodMoon(); }, bloodMoon); Loader.RegisterHotkey(() => { if (Main.eclipse) Main.eclipse = false; else TriggerEclipse(); }, eclipse); Loader.RegisterHotkey(() => { SpawnMeteor = false; DropMeteor(); }, meteor); }
/// <summary> /// Construct a new Key event arg for a key press /// </summary> /// <param name="keyCode"> </param> public KeyEventArgs(Keys keyCode) { KeyCode = keyCode; }