public void UpdateButtonMapping(ButtonNames button, GamepadButtonAction action) { Settings settings = _settingsRepository.Get(); settings.SetActionForButton(button, action); _settingsRepository.Save(settings); }
public void UpdateThumbStickMapping(ButtonNames button, GamepadThumbStickAction action) { Settings settings = _settingsRepository.Get(); settings.SetThumbStickAction(button, action); _settingsRepository.Save(settings); }
private void OnButtonClicked(ButtonNames button) { if (this.ButtonClicked != null) { ButtonClickedEventArgs args = new ButtonClickedEventArgs(button, this.time); this.ButtonClicked(this, args); } }
public GamepadButtonAction GetActionForButton(ButtonNames button) { switch (button) { case ButtonNames.DpadUp: return(Mappings.DpadUpMapping); case ButtonNames.DpadDown: return(Mappings.DpadDownMapping); case ButtonNames.DpadLeft: return(Mappings.DpadLeftMapping); case ButtonNames.DpadRight: return(Mappings.DpadRightMapping); case ButtonNames.Start: return(Mappings.StartMapping); case ButtonNames.Back: return(Mappings.BackMapping); case ButtonNames.LeftThumb: return(Mappings.LeftThumbMapping); case ButtonNames.RightThumb: return(Mappings.RightThumbMapping); case ButtonNames.LeftShoulder: return(Mappings.LeftShoulderMapping); case ButtonNames.RightShoulder: return(Mappings.RightShoulderMapping); case ButtonNames.A: return(Mappings.AMapping); case ButtonNames.B: return(Mappings.BMapping); case ButtonNames.X: return(Mappings.XMapping); case ButtonNames.Y: return(Mappings.YMapping); case ButtonNames.LeftTrigger: return(Mappings.LeftTriggerMapping); case ButtonNames.RightTrigger: return(Mappings.RightTriggerMapping); default: throw new ArgumentException(); } }
/// <summary> /// Part of the linked Animation. Hold a button to trigger the animation /// </summary> private void ActivateChildOnHold() { //Abbrechen if (Input.GetButtonDown(ButtonNames.GetButtonName(KeyType.A))) { _ghostDrivenAnimationActive = false; } if (_animationType != AnimationType.GhostActivateOnKeyHold) { return; } if (_ghostDrivenAnimationActive) { if (Input.GetButton(ButtonNames.GetButtonName(_keyType)) && !_animationActivated) { _animationActivated = true; _frameCount = 0; } } if (!_ghostDrivenAnimationActive || !Input.GetButton(ButtonNames.GetButtonName(_keyType))) { if (_open && _animationActivated) { _frameCount = 0; _animationActivated = false; } } if (_animationActivated && !_open) { if (_frameCount == _animationDurationInFrames) { SetObjectToPos(_positionAnimated, _rotationAnimated, _scaleAnimated); _open = true; } TransformObject(_positionStepOpen, _scaleStepOpen); } if (_animationActivated || !_open) { return; } if (_frameCount == _animationDurationInFrames) { SetObjectToPos(_positionBase, _rotationBase, _scaleBase); _animationActive = false; _open = false; } TransformObject(_positionStepClose, _scaleStepClose); }
public bool CheckButtonAction(ButtonNames buttonName, bool down, bool up, bool pressed) { if (ButtonStateDict.TryGetValue(buttonName, out ButtonState myButtonState)) { return((down && myButtonState.Down) || (up && myButtonState.Up) || (pressed && myButtonState.Pressed)); } else { return(false); } }
public GamepadThumbStickAction GetThumbStickAction(ButtonNames button) { switch (button) { case ButtonNames.LeftThumb: return(Mappings.LeftThumbOffsetMapping); case ButtonNames.RightThumb: return(Mappings.RightThumbOffsetMapping); default: throw new ArgumentException(); } }
private void PerformButtonReleasedAction(ButtonNames button) { GamepadButtonAction mapping = _settingsService.GetButtonMapping(button); switch (mapping) { case GamepadButtonAction.None: break; case GamepadButtonAction.LeftClick: Cursor.Current.LeftMouseButtonUp(); break; case GamepadButtonAction.RightClick: Cursor.Current.RightMouseButtonUp(); break; case GamepadButtonAction.MiddleClick: Cursor.Current.MiddleMouseButtonUp(); break; case GamepadButtonAction.ShowKeyboard: _onScreenKeyboardService.Toggle(); break; case GamepadButtonAction.MediaPause: _inputSimulator.Keyboard.KeyUp(VirtualKeyCode.MEDIA_PLAY_PAUSE); break; case GamepadButtonAction.MediaSkipForwards: _inputSimulator.Keyboard.KeyUp(VirtualKeyCode.MEDIA_NEXT_TRACK); break; case GamepadButtonAction.MediaGoBack: _inputSimulator.Keyboard.KeyUp(VirtualKeyCode.MEDIA_PREV_TRACK); break; case GamepadButtonAction.VolumeUp: _inputSimulator.Keyboard.KeyUp(VirtualKeyCode.VOLUME_UP); break; case GamepadButtonAction.VolumeDown: _inputSimulator.Keyboard.KeyUp(VirtualKeyCode.VOLUME_DOWN); break; case GamepadButtonAction.Mute: _inputSimulator.Keyboard.KeyUp(VirtualKeyCode.VOLUME_MUTE); break; } }
/// <summary> /// Moves object by pressing the same button consecutively /// </summary> private void MoveOnKeySmash() { if (GhostDrivenAnimationActive) { if (_animationType == AnimationType.GhostMoveOnKeySmash) { //Button, which sould be smashed if (Input.GetButtonDown(ButtonNames.GetButtonName(_keyType))) { if (_framesToNextStop == 0 && _animationDurationInFrames != _frameCount) { _framesToNextStop = _animationStepsPerKlick; } } //If there are frames left, he proceeds the animation if (_framesToNextStop != 0 && _animationDurationInFrames != _frameCount) { _framesToNextStop--; TransformObject(_positionStepOpen, _scaleStepOpen); } //Checks if animation is processed else if (_animationDurationInFrames == _frameCount) { _framesToNextStop = 0; _ghostDrivenAnimationActive = false; if (_objectInteractionListener.CanBeTakenToInventory) { _objectInteractionListener.CanBePickedUpAfterGhostAction = false; } if (_activateObjectPhysikAfterAnimation) { _rigidbody.useGravity = true; _rigidbody.isKinematic = false; _animationActive = false; } _open = true; SetObjectToPos(_positionAnimated, _rotationAnimated, _scaleBase); } } } if (_open && !_onedirectionAnimation) { } }
public void SetThumbStickAction(ButtonNames button, GamepadThumbStickAction action) { switch (button) { case ButtonNames.LeftThumb: Mappings.LeftThumbOffsetMapping = action; break; case ButtonNames.RightThumb: Mappings.RightThumbOffsetMapping = action; break; default: throw new ArgumentException(); } }
private void PerformThumbOffset(ButtonNames button, float magnitude, float x, float y) { GamepadThumbStickAction mapping = _settingsService.GetThumbStickMapping(button); switch (mapping) { case GamepadThumbStickAction.Scroll: Cursor.Current.MoveWheel((int)(y / Math.Abs(y))); break; case GamepadThumbStickAction.MoveMouse: int sensitivity = 5 + (int)(Math.Log(magnitude / 10000) * 20); for (int i = 0; i < sensitivity; i++) { Cursor.Current.MoveBy((int)(x * Multiplier), -(int)(y * Multiplier)); } break; } }
protected ButtonedDevice() { _bakedButtonNames = ButtonNames.Select(s => s != null ? "0" + s : null).ToArray(); _bakedAnalogNames = AnalogNames.Select(s => "0" + s).ToArray(); Definition = new ControllerDefinition { BoolButtons = _bakedButtonNames .Select((s, i) => new { s, i }) .Where(a => a.s != null) .OrderBy(a => ButtonOrdinal(ButtonNames[a.i])) .Select(a => a.s) .ToList(), }; Definition.FloatControls.AddRange(_bakedAnalogNames .Select((s, i) => new { s, i }) .OrderBy(a => AnalogOrdinal(AnalogNames[a.i])) .Select(a => a.s)); Definition.FloatRanges.AddRange(_bakedAnalogNames.Select(s => AnalogFloatRange)); }
public UIbutton(ButtonNames buttonName) { Name = buttonName.ToString().Replace("_", "."); }
private void CreateButtons(ButtonNames buttons) { var v = Enums.Values <ButtonNames>().Select(a => ((buttons & a) == a) ? a.ToString() : null).Where(a => !String.IsNullOrEmpty(a)); CreateButtonsFromNames(Enums.Values <ButtonNames>().Select(a => ((buttons & a) == a) ? a.ToString() : null).Where(a => !String.IsNullOrEmpty(a))); }
/// <summary> /// Constructs instance of button. /// </summary> /// <param name="name">Name of button being constructed.</param> internal Button(ButtonNames name) { Name = name; }
// private static KeyCode jump = KeyCode; // private static KeyCode run; public Controller(int playerNo) { butts = new ButtonNames(playerNo); lastJumpTime = -jumpInputLeeway; }
public GamepadButtonAction GetButtonMapping(ButtonNames button) => _settingsRepository.Get() .GetActionForButton(button);
public void SetActionForButton(ButtonNames button, GamepadButtonAction action) { switch (button) { case ButtonNames.DpadUp: Mappings.DpadUpMapping = action; break; case ButtonNames.DpadDown: Mappings.DpadDownMapping = action; break; case ButtonNames.DpadLeft: Mappings.DpadLeftMapping = action; break; case ButtonNames.DpadRight: Mappings.DpadRightMapping = action; break; case ButtonNames.Start: Mappings.StartMapping = action; break; case ButtonNames.Back: Mappings.BackMapping = action; break; case ButtonNames.LeftThumb: Mappings.LeftThumbMapping = action; break; case ButtonNames.RightThumb: Mappings.RightThumbMapping = action; break; case ButtonNames.LeftShoulder: Mappings.LeftShoulderMapping = action; break; case ButtonNames.RightShoulder: Mappings.RightShoulderMapping = action; break; case ButtonNames.A: Mappings.AMapping = action; break; case ButtonNames.B: Mappings.BMapping = action; break; case ButtonNames.X: Mappings.XMapping = action; break; case ButtonNames.Y: Mappings.YMapping = action; break; case ButtonNames.LeftTrigger: Mappings.LeftTriggerMapping = action; break; case ButtonNames.RightTrigger: Mappings.RightTriggerMapping = action; break; default: throw new ArgumentException(); } }
private void CreateButtons(ButtonNames buttons) { var v = Enums.Values<ButtonNames>().Select(a => ((buttons & a) == a) ? a.ToString() : null).Where(a => !String.IsNullOrEmpty(a)); CreateButtonsFromNames(Enums.Values<ButtonNames>().Select(a => ((buttons & a) == a) ? a.ToString() : null).Where(a => !String.IsNullOrEmpty(a))); }
public ButtonClickedEventArgs(ButtonNames button, GameTime time) { this.Button = button; this.Time = time; }
public GamepadThumbStickAction GetThumbStickMapping(ButtonNames button) => _settingsRepository.Get() .GetThumbStickAction(button);