// Do an animation where they break one by one //private IEnumerator BreakCoroutine() //{ // while (keysToBreak.Count > 0 || fragmentsToBreak.Count > 0) // { // bool itemBroken = false; // if (keysToBreak.Count > 0 && Random.value < 0.5) // { // InputKey inputKey = keysToBreak[Random.Range(0, keysToBreak.Count)]; // keysToBreak.Remove(inputKey); // BreakKey(inputKey); // itemBroken = true; // } // else // { // InputFragment inputFragment = fragmentsToBreak[Random.Range(0, fragmentsToBreak.Count)]; // // Only break a fragment once any keys in it have been broken // bool fragmentContainsKeys = false; // foreach (InputSlot inputSlot in inputFragment.GetComponentsInChildren<InputSlot>()) // { // if (inputSlot.GetInputKey() != null) // { // fragmentContainsKeys = true; // break; // } // } // if (!fragmentContainsKeys) // { // fragmentsToBreak.Remove(inputFragment); // BreakFragment(inputFragment); // itemBroken = true; // } // } // if (itemBroken) { yield return new WaitForSeconds(0.2f); } // } //} private void BreakKey(InputKey inputKey) { if (dragging && draggedKey == inputKey) { StopDragging(); } Vector3 positionVector = inputKey.transform.position - keyParent.transform.position; positionVector = CanvasScale.Instance.WorldToCanvas(positionVector); positionVector.x *= 2; positionVector.y *= 4; inputKey.Break( positionVector + (Vector3)Random.insideUnitCircle * 500f, Random.Range(-360, 360)); InputSlot inputSlot = inputKey.GetInputSlot(); if (inputSlot != null) { inputSlot.SetInputKey(null); InputMapper.Instance.RemoveMapping(inputSlot.GetAction()); } inputKey.SetInputSlot(null); inputKeys.Remove(inputKey); }
public InputChordAction CreateChordAction(string name, InputKey key, IList <int> buttons) { var a = new InputChordAction(name, key, buttons); _actions.Add(a); return(a); }
public void AcceptInput(InputKey key) { if (cooldowns.Count <= (int)key) { cooldowns.AddRange(new float[(int)key - cooldowns.Count + 1]); } if (cooldowns[(int)key] > 0f) { return; } cooldowns[(int)key] = KeyRepeatInterval; var focus = (selectStack.Count > 0) ? selectStack.Peek().Value: null; if (key == InputKey.Up || key == InputKey.Down) { if (focus != null) { focus.Unfocus(); } var elem = Select(key == InputKey.Down ? Direction.Next: Direction.Previous); elem.Focus(); return; } if (focus != null) { focus.Input(key); } }
private void InputKey() { if (Input.GetKeyDown(KeyCode.Space)) { if ((int)calibStats % 2 == 0) { CalibO2A(); } } if (Input.GetKeyDown(KeyCode.Return)) { if ((int)calibStats % 2 == 1) { CalibO2A(); } } if (InputKey.GetKeyDown(KeyCode.Esc)) { if (calibStats == CalibStats.start) { calibStats = CalibStats.end; endCalibAxi = true; } } }
private static string FindConflictInGameSettings(InputKey sample) { var fieldList = typeof(Settings).GetFields(BindingFlags.Static | BindingFlags.Public); foreach (var field in fieldList) { var customAttributes = field.GetCustomAttributes(typeof(RebindableKeyAttribute), false) as RebindableKeyAttribute[]; if (customAttributes != null && customAttributes.Length > 0) { var category = customAttributes[0].category; if (category != string.Empty && category != "Game") { // Ignore other categories: MapEditor, Decoration, ThemeEditor, ScenarioEditor continue; } var str = field.GetValue(null) as string; var savedInputKey = new SavedInputKey(str, Settings.gameSettingsFile, GetDefaultEntryInGameSettings(str), true); if (savedInputKey.value == sample) { return((category == string.Empty ? string.Empty : (category + " -- ")) + CamelCaseSplit(field.Name)); } } } return(string.Empty); }
/// <summary> /// For given key and category check TM:PE settings for the Global category /// and the same category if it is not Global. This will allow reusing key in other tool /// categories without conflicting. /// </summary> /// <param name="testSample">The key to search for</param> /// <param name="testSampleCategory">The category Global or some tool name</param> /// <param name="fields">Fields of the key settings class</param> /// <returns>Empty string if no conflicts otherwise the key name to print an error</returns> private static string FindConflictInTmpe(InputKey testSample, string testSampleCategory, FieldInfo[] fields) { foreach (var field in fields) { // This will match inputkeys of TMPE key settings if (field.FieldType != typeof(KeybindSetting)) { continue; } var tmpeSetting = field.GetValue(null) as KeybindSetting; // Check category // settingCategory=Global will check against any other test samples // category=<other> will check Global and its own only if (tmpeSetting.Category == "Global" || testSampleCategory == tmpeSetting.Category) { if (tmpeSetting.HasKey(testSample)) { return("TM:PE, " + Translation.Options.Get("KeybindCategory." + tmpeSetting.Category) + " -- " + CamelCaseSplit(field.Name)); } } } return(string.Empty); }
/// <summary> /// For an inputkey, try find where possibly it is already used. /// This covers game Settings class, and self (OptionsKeymapping class). /// </summary> /// <param name="k">Key to search for the conflicts</param> /// <param name="sampleCategory">Check the same category keys if possible</param> /// <returns>Empty string for no conflict, or the conflicting key name</returns> private string FindConflict(KeybindSetting.Editable editedKeybind, InputKey sample, string sampleCategory) { if (Keybind.IsEmpty(sample)) { // empty key never conflicts return(string.Empty); } var inGameSettings = FindConflictInGameSettings(sample); if (!string.IsNullOrEmpty(inGameSettings)) { return(inGameSettings); } // Saves and null 'self.editingBinding_' to allow rebinding the key to itself. var saveEditingBinding = editedKeybind.TargetKey.value; editedKeybind.TargetKey.value = SavedInputKey.Empty; // Check in TMPE settings var tmpeSettingsType = typeof(KeybindSettingsBase); var tmpeFields = tmpeSettingsType.GetFields(BindingFlags.Static | BindingFlags.Public); var inTmpe = FindConflictInTmpe(sample, sampleCategory, tmpeFields); editedKeybind.TargetKey.value = saveEditingBinding; return(inTmpe); }
public override void Input(InputKey key) { if (key == InputKey.Return) { OnPressed(); } }
private void OnBindingMouseDown(UIComponent comp, UIMouseEventParameter p) { if (this.m_EditingBinding == null) { p.Use(); this.m_EditingBinding = (SavedInputKey)p.source.objectUserData; UIButton uibutton = p.source as UIButton; uibutton.buttonsMask = (UIMouseButton.Left | UIMouseButton.Right | UIMouseButton.Middle | UIMouseButton.Special0 | UIMouseButton.Special1 | UIMouseButton.Special2 | UIMouseButton.Special3); uibutton.text = "Press any key"; p.source.Focus(); UIView.PushModal(p.source); return; } if (!IsUnbindableMouseButton(p.buttons)) { p.Use(); UIView.PopModal(); InputKey value = SavedInputKey.Encode(ButtonToKeycode(p.buttons), IsControlDown(), IsShiftDown(), IsAltDown()); this.m_EditingBinding.value = value; UIButton uibutton2 = p.source as UIButton; uibutton2.text = this.m_EditingBinding.ToLocalizedString("KEYNAME"); uibutton2.buttonsMask = UIMouseButton.Left; this.m_EditingBinding = null; } }
protected void OnBindingMouseDown(UIComponent comp, UIMouseEventParameter p) { if (this.m_EditingBinding == null) { p.Use(); this.m_EditingBinding = (SavedInputKey)p.source.objectUserData; this.m_EditingBindingCategory = p.source.stringUserData; UIButton uIButton = p.source as UIButton; uIButton.buttonsMask = (UIMouseButton.Left | UIMouseButton.Right | UIMouseButton.Middle | UIMouseButton.Special0 | UIMouseButton.Special1 | UIMouseButton.Special2 | UIMouseButton.Special3); uIButton.text = "Press any key"; p.source.Focus(); UIView.PushModal(p.source); } else if (!this.IsUnbindableMouseButton(p.buttons)) { p.Use(); UIView.PopModal(); InputKey inputKey = SavedInputKey.Encode(this.ButtonToKeycode(p.buttons), this.IsControlDown(), this.IsShiftDown(), this.IsAltDown()); this.m_EditingBinding.value = inputKey; UIButton uIButton2 = p.source as UIButton; uIButton2.text = this.m_EditingBinding.ToLocalizedString("KEYNAME"); uIButton2.buttonsMask = UIMouseButton.Left; this.m_EditingBinding = null; this.m_EditingBindingCategory = string.Empty; } }
private bool handleNewPressed(InputState state, InputKey newKey) { var pressedCombination = KeyCombination.FromInputState(state); bool handled = false; var newlyPressed = KeyBindings.Except(pressedBindings).Where(m => m.KeyCombination.Keys.Contains(newKey) && // only handle bindings matching current key (not required for correct logic) m.KeyCombination.IsPressed(pressedCombination)); if (isModifier(newKey)) { // if the current key pressed was a modifier, only handle modifier-only bindings. newlyPressed = newlyPressed.Where(b => b.KeyCombination.Keys.All(isModifier)); } // we want to always handle bindings with more keys before bindings with less. newlyPressed = newlyPressed.OrderByDescending(b => b.KeyCombination.Keys.Count()).ToList(); pressedBindings.AddRange(newlyPressed); foreach (var newBinding in newlyPressed) { handled |= PropagatePressed(KeyBindingInputQueue, newBinding.GetAction <T>()); // we only want to handle the first valid binding (the one with the most keys) in non-simultaneous mode. if (simultaneousMode == SimultaneousBindingMode.None && handled) { break; } } return(handled); }
/// <summary> /// Sets up key tracking data. /// </summary> public override void Initialize() { // Loop through the Keys enumeration foreach (string key in Enum.GetNames(typeof(Keys))) { bool found = false; // Search for the key in our list foreach (InputKey compareKey in keys) { if (compareKey.Key == (Keys)Enum.Parse(typeof(Keys), key)) { found = true; } } // If it wasn't found, we need to add it if (!found) { // Create the key instance and set the values InputKey newKey = new InputKey(); newKey.Key = (Keys)Enum.Parse(typeof(Keys), key); newKey.Pressed = false; newKey.Countdown = RepeatDelay; // Add the key. this.keys.Add(newKey); } } base.Initialize(); }
public override void OnInputMade(InputKey key) { if (key == InputKey.XPadAction) { midBrightness = 1f; } }
void InvokeDictionaryButton() { if (buttonEventDictionary.Count == 0) { return; } IList <InputKey> keys = listKeys; for (int i = 0; i < keys.Count; i++) { InputKey key = keys[i]; if (buttonEventDictionary[key] == ButtonStats.Up && GetButtonUp(key.keyInt)) { InvokeButtonUpEvent(key.keyInt); } if (buttonEventDictionary[key] == ButtonStats.Down && GetButtonDown(key.keyInt)) { InvokeButtonDownEvent(key.keyInt); } if (buttonEventDictionary[key] == ButtonStats.Hold && GetButton(key.keyInt)) { InvokeButtonHoldEvent(key.keyInt); } } }
public static int JoystickValue(InputKey key, Controller c, bool invertAxis = false) { var a = c.Input[key]; if (a == null) { if (key == InputKey.hotkey) { a = c.Input[InputKey.hotkeyenable]; } if (a == null) { return(0); } } int JOY_MAX_INPUTS = 64; int value = 0; if (a.Type == "button") { value = 1 + (c.Index - 1) * JOY_MAX_INPUTS + (int)a.Id; } else if (a.Type == "hat") { int hatfirst = 1 + (c.Index - 1) * JOY_MAX_INPUTS + c.NbButtons + 2 * c.NbAxes + 4 * (int)a.Id; if (a.Value == 2) // SDL_HAT_RIGHT { hatfirst += 1; } else if (a.Value == 4) // SDL_HAT_DOWN { hatfirst += 2; } else if (a.Value == 8) // SDL_HAT_LEFT { hatfirst += 3; } value = hatfirst; } else if (a.Type == "axis") { int axisfirst = 1 + (c.Index - 1) * JOY_MAX_INPUTS + c.NbButtons + 2 * (int)a.Id; if ((invertAxis && a.Value < 0) || (!invertAxis && a.Value > 0)) { axisfirst++; } value = axisfirst; } if (c.Input.Type != "keyboard") { value += 600; } return(value); }
public InputChordAction CreateChordAction(string name, InputKey key) { var a = new InputChordAction(name, key); _actions.Add(a); return(a); }
public static string GetKeyText(InputKey key) { if (key >= InputKey.D0 && key <= InputKey.D9) { return(key.ToString().TrimStart('D')); } return(key switch { InputKey.None => string.Empty, InputKey.MouseLeftButton => Title_LeftMouseButton, InputKey.MouseRightButton => Title_RightMouseButton, InputKey.MouseScrollButton => Title_MouseScrollButton, InputKey.MouseExtraButton1 => Title_MouseExtraButton1, InputKey.MouseExtraButton2 => Title_MouseExtraButton2, InputKey.Space => Title_SpaceBar, InputKey.CapsLock => Title_CapsLock, InputKey.OemTilde => "~", InputKey.CircumflexAccent => '\u005E'.ToString(), InputKey.OemMinus => "-", InputKey.OemPlus => "+", InputKey.OemComma => ",", InputKey.OemPeriod => ".", InputKey.OemSemicolon => ";", InputKey.OemQuestion => "?", InputKey.OemPipe => "|", InputKey.OemOpenBrackets => "[", InputKey.OemCloseBrackets => "]", InputKey.PageUp => Title_PageUp, InputKey.PageDown => Title_PageDown, _ => key.ToString() });
public static string GetKeyText(InputKey key) { if (key >= InputKey.D0 && key <= InputKey.D9) { return(key.ToString().TrimStart('D')); } switch (key) { case InputKey.None: return(string.Empty); case InputKey.MouseLeftButton: return(Title_LeftMouseButton); case InputKey.MouseRightButton: return(Title_RightMouseButton); case InputKey.MouseScrollButton: return(Title_MouseScrollButton); case InputKey.Space: return(Title_SpaceBar); case InputKey.CapsLock: return(Title_CapsLock); case InputKey.OemTilde: return("~"); case InputKey.CircumflexAccent: return('\u005E'.ToString()); case InputKey.OemMinus: return("-"); case InputKey.OemPlus: return("+"); case InputKey.OemComma: return(","); case InputKey.OemPeriod: return("."); case InputKey.OemQuestion: return("?"); case InputKey.PageUp: return(Title_PageUp); case InputKey.PageDown: return(Title_PageDown); default: return(key.ToString()); } }
public bool IsKeyHeld(InputKey key, int ms = 1000) { if (heldKeys.TryGetValue(key, out int currMs) && currMs >= ms) { return(true); } return(false); }
public void RemoveKeyListener(InputKey toRemove) { if (_keyListeners == null) { return; } _keyListeners -= toRemove; }
protected internal HotKeyBase(string uid, string displayName, string description, InputKey defaultKey, string category) { Uid = uid; DisplayName = displayName; Description = description; DefaultKey = defaultKey; Category = category; }
private void tbShippment_KeyDown(object sender, KeyEventArgs e) { e.SuppressKeyPress = true; if (InputKey.ValidNumberKey(e)) { e.SuppressKeyPress = false; } }
public HandInputBase(InputKey keyCode) : base(keyCode) { mKeyForce = 0f; mBoolDown = false; mBoolUp = false; mPressed = false; mTouched = false; }
bool HasKey(InputKey key) { if (_keys != null) { return(_keys.Contains(key)); } return(false); }
private void RegisterCheatHotkey( string id, InputKey hotkeyKey, HotKey.Modifiers modifiers, HotKey.Modifiers negativeModifiers = HotKey.Modifiers.None) { this.RegisterHotKey(new HotKey(id, "Cheats", hotkeyKey, modifiers, negativeModifiers)); }
/// <summary> /// Construct a new instance from input state. /// </summary> /// <param name="state">The input state object.</param> /// <param name="scrollDelta">Delta of scroller's position.</param> /// <returns>The new constructed <see cref="KeyCombination"/> instance.</returns> /// <remarks>This factory method is optimized and should be used for hot paths.</remarks> public static KeyCombination FromInputState(InputState state, Vector2?scrollDelta = null) { var keys = ImmutableArray.CreateBuilder <InputKey>(); if (state.Mouse != null) { foreach (var button in state.Mouse.Buttons) { keys.Add(FromMouseButton(button)); } } if (scrollDelta is Vector2 v && v.Y != 0) { keys.Add(FromScrollDelta(v)); } if (state.Keyboard != null) { foreach (var key in state.Keyboard.Keys) { InputKey iKey = FromKey(key); switch (key) { case Key.LShift: case Key.RShift: case Key.LAlt: case Key.RAlt: case Key.LControl: case Key.RControl: case Key.LWin: case Key.RWin: if (!keys.Contains(iKey)) { keys.Add(iKey); } break; default: keys.Add(iKey); break; } } } if (state.Joystick != null) { foreach (var joystickButton in state.Joystick.Buttons) { keys.Add(FromJoystickButton(joystickButton)); } } Debug.Assert(!keys.Contains(InputKey.None)); // Having None in pressed keys will break IsPressed keys.Sort(); return(new KeyCombination(keys.ToImmutable())); }
private bool handleNewPressed(InputState state, InputKey newKey, bool repeat, Vector2?scrollDelta = null, bool isPrecise = false) { float scrollAmount = 0; if (newKey == InputKey.MouseWheelUp) { scrollAmount = scrollDelta?.Y ?? 0; } else if (newKey == InputKey.MouseWheelDown) { scrollAmount = -(scrollDelta?.Y ?? 0); } var pressedCombination = KeyCombination.FromInputState(state, scrollDelta); bool handled = false; var bindings = (repeat ? KeyBindings : KeyBindings?.Except(pressedBindings)) ?? Enumerable.Empty <KeyBinding>(); var newlyPressed = bindings.Where(m => m.KeyCombination.Keys.Contains(newKey) && // only handle bindings matching current key (not required for correct logic) m.KeyCombination.IsPressed(pressedCombination, matchingMode)); if (KeyCombination.IsModifierKey(newKey)) { // if the current key pressed was a modifier, only handle modifier-only bindings. newlyPressed = newlyPressed.Where(b => b.KeyCombination.Keys.All(KeyCombination.IsModifierKey)); } // we want to always handle bindings with more keys before bindings with less. newlyPressed = newlyPressed.OrderByDescending(b => b.KeyCombination.Keys.Count()).ToList(); if (!repeat) { pressedBindings.AddRange(newlyPressed); } // exact matching may result in no pressed (new or old) bindings, in which case we want to trigger releases for existing actions if (simultaneousMode == SimultaneousBindingMode.None && (matchingMode == KeyCombinationMatchingMode.Exact || matchingMode == KeyCombinationMatchingMode.Modifiers)) { // only want to release pressed actions if no existing bindings would still remain pressed if (pressedBindings.Count > 0 && !pressedBindings.Any(m => m.KeyCombination.IsPressed(pressedCombination, matchingMode))) { releasePressedActions(); } } foreach (var newBinding in newlyPressed) { handled |= PropagatePressed(KeyBindingInputQueue, newBinding.GetAction <T>(), scrollAmount, isPrecise); // we only want to handle the first valid binding (the one with the most keys) in non-simultaneous mode. if (simultaneousMode == SimultaneousBindingMode.None && handled) { break; } } return(handled); }
public InputKeyInfo( InputKey key, InputModifiers modifiers, char character, bool hasMoreInput) { Key = key; Modifiers = modifiers; Character = character; HasMoreInput = hasMoreInput; }
public static KeyCombination FromInputState(InputState state) { List <InputKey> keys = new List <InputKey>(); if (state.Mouse != null) { foreach (var button in state.Mouse.Buttons) { keys.Add(FromMouseButton(button)); } if (state.Mouse.WheelDelta > 0) { keys.Add(InputKey.MouseWheelUp); } if (state.Mouse.WheelDelta < 0) { keys.Add(InputKey.MouseWheelDown); } } if (state.Keyboard != null) { foreach (var key in state.Keyboard.Keys) { InputKey iKey = FromKey(key); switch (key) { case Key.LShift: case Key.RShift: case Key.LAlt: case Key.RAlt: case Key.LControl: case Key.RControl: case Key.LWin: case Key.RWin: if (!keys.Contains(iKey)) { keys.Add(iKey); } break; default: keys.Add(iKey); break; } } } if (state.Joystick != null) { keys.AddRange(state.Joystick.Buttons.Select(FromJoystickButton)); } return(new KeyCombination(keys)); }
public void Initialize(PlayerController controller, InputManager inputManager) { this.controller = controller; this.inputManager = inputManager; slashKey = inputManager.GetKey(OctoKey.SLASH); slashKey.OnKeyDown += () => NextComboAttack(0); base.Initialize(); }
public void AcceptInput(InputKey key) { if (cooldowns.Count <= (int) key) cooldowns.AddRange(new float[(int)key - cooldowns.Count + 1]); if (cooldowns[(int)key] > 0f) return; cooldowns[(int)key] = KeyRepeatInterval; var focus = (selectStack.Count > 0) ? selectStack.Peek().Value: null; if (key == InputKey.Up || key == InputKey.Down) { if (focus != null) focus.Unfocus(); var elem = Select(key == InputKey.Down ? Direction.Next: Direction.Previous); elem.Focus(); return; } if (focus != null) focus.Input(key); }
public SquidInputManager(Game game) { SpecialKeys.Add(Keys.Home, 0xC7); SpecialKeys.Add(Keys.Up, 0xC8); SpecialKeys.Add(Keys.Left, 0xCB); SpecialKeys.Add(Keys.Right, 0xCD); SpecialKeys.Add(Keys.End, 0xCF); SpecialKeys.Add(Keys.Down, 0xD0); SpecialKeys.Add(Keys.Insert, 0xD2); SpecialKeys.Add(Keys.Delete, 0xD3); SpecialKeys.Add(Keys.MediaPreviousTrack, 0x90); foreach (Keys k in System.Enum.GetValues(typeof(Keys))) { InputKey key = new InputKey(); key.Key = k; key.ScanCode = VirtualKeyToScancode(k); InputKeys.Add(k, key); } }
/// <summary> /// Sets up key tracking data. /// </summary> public override void Initialize() { // Loop through the Keys enumeration foreach (string key in Enum.GetNames(typeof(Keys))) { bool found = false; // Search for the key in our list foreach (InputKey compareKey in keys) { if (compareKey.Key == (Keys)Enum.Parse(typeof(Keys), key)) found = true; } // If it wasn't found, we need to add it if (!found) { // Create the key instance and set the values InputKey newKey = new InputKey(); newKey.Key = (Keys)Enum.Parse(typeof(Keys), key); newKey.Pressed = false; newKey.Countdown = RepeatDelay; // Add the key. this.keys.Add(newKey); } } base.Initialize(); }
/// <summary> /// Processes an input key. /// </summary> /// <param name="inputKey"> /// The input key. /// </param> /// <returns> /// A value indicating whether the input operation terminated. /// </returns> protected override bool ProcessInputKey(InputKey inputKey) { var inputOperation = this.InputOperation; if (!inputOperation.ReadCharacter) { var zsciiCharacter = (Zscii)inputKey; if (ValidFunctionKeyCode(zsciiCharacter) && this.IsTerminator(zsciiCharacter)) { this.FinishInputLineOperation(inputOperation.InputText, new InputValue(inputKey)); return true; } } return base.ProcessInputKey(inputKey); }
/// <summary> /// Verwarbeitet eine Eingabe. /// </summary> /// <param name="key">Die auszuführende Aktion.</param> internal void Process( InputKey key ) { // Report if (TransitionConfiguration.KeyLogger.Enabled) Trace.TraceInformation( Properties.Resources.Trace_LogInput_State, UniqueIdentifier ); // Check for action KeyActionList list; if (m_Actions.TryGetValue( key, out list )) Configuration.Execute( list ); }
//////////////////////////////////////////////////////////////////////////// #endregion #region //// Methods /////////// //////////////////////////////////////////////////////////////////////////// public virtual void Initialize() { keys.Clear(); mouseButtons.Clear(); gamePadButtons.Clear(); #if (!XBOX && !XBOX_FAKE) foreach (string str in Enum.GetNames(typeof(Keys))) { InputKey key = new InputKey(); key.Key = (Keys)Enum.Parse(typeof(Keys), str); keys.Add(key); } foreach (string str in Enum.GetNames(typeof(MouseButton))) { InputMouseButton btn = new InputMouseButton(); btn.Button = (MouseButton)Enum.Parse(typeof(MouseButton), str); mouseButtons.Add(btn); } foreach (string str in Enum.GetNames(typeof(GamePadButton))) { InputGamePadButton btn = new InputGamePadButton(); btn.Button = (GamePadButton)Enum.Parse(typeof(GamePadButton), str); gamePadButtons.Add(btn); } #else gamePadButtons.Add(new InputGamePadButton(GamePadButton.None)); gamePadButtons.Add(new InputGamePadButton(GamePadButton.Start)); gamePadButtons.Add(new InputGamePadButton(GamePadButton.Back)); gamePadButtons.Add(new InputGamePadButton(GamePadButton.Up)); gamePadButtons.Add(new InputGamePadButton(GamePadButton.Down)); gamePadButtons.Add(new InputGamePadButton(GamePadButton.Left)); gamePadButtons.Add(new InputGamePadButton(GamePadButton.Right)); gamePadButtons.Add(new InputGamePadButton(GamePadButton.A)); gamePadButtons.Add(new InputGamePadButton(GamePadButton.B)); gamePadButtons.Add(new InputGamePadButton(GamePadButton.X)); gamePadButtons.Add(new InputGamePadButton(GamePadButton.Y)); gamePadButtons.Add(new InputGamePadButton(GamePadButton.BigButton)); gamePadButtons.Add(new InputGamePadButton(GamePadButton.LeftShoulder)); gamePadButtons.Add(new InputGamePadButton(GamePadButton.RightShoulder)); gamePadButtons.Add(new InputGamePadButton(GamePadButton.LeftTrigger)); gamePadButtons.Add(new InputGamePadButton(GamePadButton.RightTrigger)); gamePadButtons.Add(new InputGamePadButton(GamePadButton.LeftStick)); gamePadButtons.Add(new InputGamePadButton(GamePadButton.RightStick)); gamePadButtons.Add(new InputGamePadButton(GamePadButton.LeftStickLeft)); gamePadButtons.Add(new InputGamePadButton(GamePadButton.LeftStickRight)); gamePadButtons.Add(new InputGamePadButton(GamePadButton.LeftStickUp)); gamePadButtons.Add(new InputGamePadButton(GamePadButton.LeftStickDown)); gamePadButtons.Add(new InputGamePadButton(GamePadButton.RightStickLeft)); gamePadButtons.Add(new InputGamePadButton(GamePadButton.RightStickRight)); gamePadButtons.Add(new InputGamePadButton(GamePadButton.RightStickUp)); gamePadButtons.Add(new InputGamePadButton(GamePadButton.RightStickDown)); #endif }
/// <summary> /// Check the input from the keyboard and handle it. /// </summary> /// <param name="inputKey">Tetris Key</param> public void keyPress(InputKey inputKey) { if (_isInGame) { int[,] tempBlock; switch (inputKey) { //Handle the left key input, that is "A". case InputKey.Left: if (_blockPositionX > 0 && CanBlockBePositionedAt(_currentTetrisBlock, _blockPositionX - 1, _blockPositionY)) { _blockPositionX--; } break; //Handle the right key input, that is "D". case InputKey.Right: if (_blockPositionX < _tetrisBoardContainer.GetUpperBound(0) && CanBlockBePositionedAt(_currentTetrisBlock, _blockPositionX + 1, _blockPositionY)) { _blockPositionX++; } break; //Handle the Counter clockwise key input, that is "W". case InputKey.CounterClockwise: tempBlock = TetrisBlockClass.RotateCounterClockwise(_currentTetrisBlock); if (CanBlockBePositionedAt(tempBlock, _blockPositionX, _blockPositionY)) { _currentTetrisBlock = TetrisBlockClass.RotateCounterClockwise(_currentTetrisBlock); } break; //Handle the Counter clockwise key input, that is "S". case InputKey.Clockwise: tempBlock = TetrisBlockClass.RotateClockWise(_currentTetrisBlock); if (CanBlockBePositionedAt(tempBlock, _blockPositionX, _blockPositionY)) { _currentTetrisBlock = TetrisBlockClass.RotateClockWise(_currentTetrisBlock); } break; default: break; } } }
/// <summary> /// Bearbeitet eine Eingabe. /// </summary> /// <param name="key">Das beobachtete Zeichen.</param> /// <returns>Gesetzt, wenn das Zeichen bearbeitet wurde.</returns> internal bool Process( InputKey key ) { // Report if (TransitionConfiguration.KeyLogger.Enabled) Trace.TraceWarning( string.Format( Properties.Resources.Trace_LogInput_NextDigit, key, State.UniqueIdentifier, m_Number ) ); // Check for digit if (key >= InputKey.Digit0) if (key <= InputKey.Digit9) { // Do the compose and remember the time the user entered the last key m_Number = 10 * m_Number + (uint) (key - InputKey.Digit0); m_LastKey = DateTime.UtcNow; // Check the number of digits allowed var digits = MaximumValue.ToString().Length; var fmt = new string( '0', digits ); // Clip if necessary var number = m_Number.ToString( fmt ); if (number.Length > digits) m_Number = uint.Parse( number = number.Substring( number.Length - digits, digits ) ); // See if we end up on the first valid number and there is no other way to end the number successfully if (AutoAcceptTimeOut < 1) if (!EndKey.HasValue) if (IsValid) { // Finish State.Configuration.DoNumberFeedback( checked( (int) m_Number ), this, true ); // We did it all return true; } // Do the feedback State.Configuration.DoNumberFeedback( number, this, false ); // Got it return true; } // See if this is our termination key var regular = (EndKey.GetValueOrDefault( InputKey.Digit0 ) == key); // Use helper Finish( regular ); // Not us return regular; }
/// <summary> /// Processes an input key. /// </summary> /// <param name="inputKey"> /// The input key. /// </param> /// <returns> /// A value indicating whether the input operation terminated. /// </returns> protected override bool ProcessInputKey(InputKey inputKey) { if (this.InputOperation.ReadCharacter) { var zsciiCharacter = (Zscii)inputKey; if (zsciiCharacter == Zscii.Delete || zsciiCharacter == Zscii.NewLine || zsciiCharacter == Zscii.Escape || ValidFunctionKeyCode(zsciiCharacter)) { this.FinishInputCharacterOperation(new InputValue(inputKey)); return true; } return false; } return base.ProcessInputKey(inputKey); }
/// <summary> /// Processes an input key. /// </summary> /// <param name="inputKey"> /// The input key. /// </param> /// <returns> /// A value indicating whether the input operation terminated. /// </returns> protected virtual bool ProcessInputKey(InputKey inputKey) { switch (inputKey) { case InputKey.NewLine: var inputText = this.InputOperation.InputText; this.WriteToTranscript(inputText); this.Write(new ImmutableStack<Zscii>(Zscii.NewLine)); this.FinishInputLineOperation(inputText, new InputValue(inputKey)); return true; case InputKey.Delete: if (this.InputOperation.DeleteCharacter()) { this.FrontEnd.DeleteCharacterFromDisplay(this.BackgroundColour); } break; } return false; }
/// <summary> /// Verwarbeitet eine Eingabe. /// </summary> /// <param name="key">Die auszuführende Aktion.</param> public void Process( InputKey key ) { // Be safe try { // Attach to the site if (m_Site == null) throw new InvalidOperationException( Properties.Resources.Exception_NoSite ); // Check mode if (m_Site.InvokeRequired) throw new NotSupportedException( Properties.Resources.Exception_WrongThread ); // Check it if (KeyLogger.Enabled) Trace.TraceInformation( Properties.Resources.Trace_LogInput_Key, key ); // Check for error if (m_Current == null) throw new InvalidOperationException( Properties.Resources.Exception_NoState ); // Check for number composer var composer = m_Composer; m_Composer = null; // See if we should activate number composer if (composer == null) if (key >= InputKey.Digit0) if (key <= InputKey.Digit9) if ((composer = m_Current.NumberComposer) != null) composer.Reset(); // Dispatch if (composer != null) if (composer.Process( key )) return; // Fall back m_Current.Process( key ); } catch (Exception e) { // Forward ReportException( e ); } }
private bool LoadDotXim(String file) { VarManager varManager = Singleton<VarManager>.Instance; CommandParser cmdParser = CommandParser.Instance; m_infoTextManager.WriteLine("Loading xim config from: " + Environment.NewLine + "\t" + file + "... "); StreamReader sr; if (!OpenFile(file, out sr)) { m_infoTextManager.Write("Failed!! file not found :("); return false; } cmdParser.ParseLine("unbindall"); String currentSection = ""; String altSens = ""; bool onMouseBinding = false; String s; while ( (s = sr.ReadLine()) != null) { s = s.ToLower(); if (s.StartsWith(";")) { continue; } else if (s.StartsWith("[")) { // Entering a new section. s = s.Substring(1, s.Length - 2); currentSection = s; } else { String[] tokens = s.Split(new char[]{ ' ','=' }, StringSplitOptions.RemoveEmptyEntries ); if (tokens.Length == 2) { if (tokens[0] == "binding") { onMouseBinding = tokens[1] == "mouse"; } if (tokens[0] == "deadzone") { cmdParser.ParseLine("set deadzone " + tokens[1]); } else if (tokens[0] == "deadzonetype") { cmdParser.ParseLine("set deadzonecircle " + tokens[1] == "circle" ? "true" : "false"); } else if (tokens[0] == "yxratio") { cmdParser.ParseLine("set yxratio " + tokens[1]); } else if (tokens[0] == "smoothness") { cmdParser.ParseLine("set smoothness " + tokens[1]); } else if (tokens[0] == "diagonaldampen") { cmdParser.ParseLine("set diagonaldampen " + tokens[1]); } else if (tokens[0] == "translationexponent") { cmdParser.ParseLine("set transexponent1 " + tokens[1]); } else if (tokens[0] == "sensitivityprimary" && onMouseBinding ) { cmdParser.ParseLine("set sensitivity1 " + tokens[1]); } else if (tokens[0] == "sensitivitytoggle" && onMouseBinding) { altSens = tokens[1]; } else if (tokens[0] == "sensitivitysecondary" && onMouseBinding) { cmdParser.ParseLine("set sensitivity2 " + tokens[1]); } else if (tokens[0] == "autoanalogdisconnect") { cmdParser.ParseLine("set autoanalogdisconnect " + tokens[1]); } else if (tokens[0] == "inputupdatefrequency") { cmdParser.ParseLine("set rate " + tokens[1]); } else if (m_xim.ContainsKey(currentSection + tokens[0])) { // Some sort of binding. Xim.Button ximButton; m_xim.TryGetValue(currentSection + tokens[0], out ximButton); if (m_mouse.ContainsKey(tokens[1])) { Mouse.Button mouseButton; m_mouse.TryGetValue(tokens[1],out mouseButton); cmdParser.ParseLine("bind " + mouseButton.ToString().ToLower() + " ." + ximButton.ToString().ToLower()); } else if (m_key.ContainsKey(tokens[1])) { DxI.Key keyButton; m_key.TryGetValue(tokens[1], out keyButton); cmdParser.ParseLine("bind " + keyButton.ToString().ToLower() + " ." + ximButton.ToString().ToLower()); } } } } } if (altSens.Length > 0) { string otherBinds = ""; if (m_mouse.ContainsKey(altSens)) { Mouse.Button mouseButton; m_mouse.TryGetValue(altSens, out mouseButton); InputKey<Mouse.Button> mouseKey = new InputKey<Mouse.Button>(mouseButton); if (BindingManager.Instance.IsBound(mouseKey)) { otherBinds = BindingManager.Instance.GetBindString(mouseKey); } cmdParser.ParseLine("bind " + mouseButton.ToString().ToLower() +" "+ otherBinds + ".altsens"); } else if (m_key.ContainsKey(altSens)) { DxI.Key keyButton; m_key.TryGetValue(altSens, out keyButton); InputKey<DxI.Key> key = new InputKey<Microsoft.DirectX.DirectInput.Key>(keyButton); if (BindingManager.Instance.IsBound(key)) { otherBinds = BindingManager.Instance.GetBindString(key); } cmdParser.ParseLine("bind " + keyButton.ToString().ToLower() +" "+ otherBinds + ".altsens"); } } m_infoTextManager.Write("Success!!!"); return true; }
public virtual void Input(InputKey key) {}
public virtual void Initialize() { keys.Clear(); mouseButtons.Clear(); foreach (string str in Enum.GetNames(typeof(Keys))) { InputKey key = new InputKey(); key.Key = (Keys)Enum.Parse(typeof(Keys), str); keys.Add(key); } foreach (string str in Enum.GetNames(typeof(MouseButton))) { InputMouseButton btn = new InputMouseButton(); btn.Button = (MouseButton)Enum.Parse(typeof(MouseButton), str); mouseButtons.Add(btn); } }
/// <summary> /// Initializes a new instance of the <see cref="InputValue"/> struct. /// </summary> /// <param name="inputKey"> /// The input character. /// </param> internal InputValue(InputKey inputKey) { this.value = inputKey; }
public override void Input(InputKey key) { if (key == InputKey.Return) OnPressed(); }