public CreditsScreen() { backAction = new InputAction( new Buttons[] { Buttons.X }, new Keys[] { Keys.X }, true); }
public MenuScreen(string menuTitle) { this.menuTitle = menuTitle; this._titleFont = FontManager.Instance.GetFont(FontList.MenuTitle); TransitionOnTime = TimeSpan.FromSeconds(0.5); TransitionOffTime = TimeSpan.FromSeconds(0.5); menuUp = new InputAction( new Buttons[] { Buttons.DPadUp, Buttons.LeftThumbstickUp }, new Keys[] { Keys.Up }, true); menuDown = new InputAction( new Buttons[] { Buttons.DPadDown, Buttons.LeftThumbstickDown }, new Keys[] { Keys.Down }, true); menuLeft = new InputAction( new Buttons[] { Buttons.DPadLeft, Buttons.LeftThumbstickLeft }, new Keys[] { Keys.Left }, true); menuRight = new InputAction( new Buttons[] { Buttons.DPadRight, Buttons.LeftThumbstickRight }, new Keys[] { Keys.Right }, true); menuSelect = new InputAction( new Buttons[] { Buttons.A, Buttons.Start }, new Keys[] { Keys.Enter, Keys.Space }, true); menuCancel = new InputAction( new Buttons[] { Buttons.B, Buttons.Back }, new Keys[] { Keys.Escape }, true); }
public override void OnInputAction(InputAction action, bool pressedThisFrame) { if (pressedThisFrame) { switch (action) { case InputAction.Up: case InputAction.Down: case InputAction.Left: case InputAction.Right: Inventory.UpdateCursorPosition(currentPlayerControls, action); break; case InputAction.Start: case InputAction.Escape: if (currentPlayerControls == activePlayerIndex) { SoundManager.PlaySoundOnce("ButtonBack"); RetroGame.PopScreen(); } break; case InputAction.Action1: Inventory.SelectWithCursor(currentPlayerControls); break; case InputAction.Action2: Inventory.GoBack(currentPlayerControls, currentPlayerControls == activePlayerIndex); break; } } }
Boolean IInputManager.actionTapped(InputAction action) { if(keyInput.actionTapped(action)) { lastControllerTapped = ControllerType.Keyboard; return true; } if(padOneInput.actionTapped(action)) { lastControllerTapped = ControllerType.PadOne; return true; } if(padTwoInput.actionTapped(action)) { lastControllerTapped = ControllerType.PadTwo; return true; } if(padThreeInput.actionTapped(action)) { lastControllerTapped = ControllerType.PadThree; return true; } if(padFourInput.actionTapped(action)) { lastControllerTapped = ControllerType.PadFour; return true; } return false; }
/// <summary> /// Constructor fills in the menu contents. /// </summary> public MainMenuScreen() : base("") { exitAction = new InputAction( new Buttons[] { Buttons.X, Buttons.Back }, new Keys[] { Keys.Escape, Keys.X }, true); optionsMenuEntry = new MenuEntry(_newGameTextures, _newGameSelectedTextures); optionsMenuEntry.Selected += OptionsMenuEntrySelected; MenuEntries.Add(optionsMenuEntry); playersMenuEntry = new MenuEntry(_playersTextures, _playersSelectedTextures); playersMenuEntry.LeftClick += PlayersMenuEntryDecrement; playersMenuEntry.RightClick += PlayersMenuEntryIncrement; MenuEntries.Add(playersMenuEntry); resolutionMenuEntry = new MenuEntry(_resolutionTextures, _resolutionSelectedTextures); resolutionMenuEntry.LeftClick += ResolutionMenuEntryDecrement; resolutionMenuEntry.RightClick += ResolutionMenuEntryIncrement; MenuEntries.Add(resolutionMenuEntry); creditsMenuEntry = new MenuEntry(_creditsTextures, _creditsSelectedTextures); creditsMenuEntry.Selected += CreditsMenuEntrySelected; MenuEntries.Add(creditsMenuEntry); _exitButton = GameServices.GetService<ContentManager>().Load<Texture2D>("Images/MainMenu/exit_menu"); _exitButtonPosition = new Vector2(100, 850); GameServices.GetService<SoundManager>().PlaySong(SoundManager.MenuSong, true); }
/// <summary> /// Constructor. /// </summary> public OptionsMenuScreen() { LeftPad = new InputAction( new Buttons[] { Buttons.DPadLeft, Buttons.LeftThumbstickLeft }, new Keys[] { Keys.Left }, true ); RightPad = new InputAction( new Buttons[] { Buttons.DPadRight, Buttons.LeftThumbstickRight }, new Keys[] { Keys.Right }, true ); UpPad = new InputAction( new Buttons[] { Buttons.DPadUp, Buttons.LeftThumbstickUp }, new Keys[] { Keys.Up }, true); DownPad = new InputAction( new Buttons[] { Buttons.DPadDown, Buttons.LeftThumbstickDown }, new Keys[] { Keys.Down }, true); BackAction = new InputAction( new Buttons[] { Buttons.X, Buttons.Back }, new Keys[] { Keys.X, Keys.Escape }, true); SelectAction = new InputAction( new Buttons[] { Buttons.A }, new Keys[] { Keys.A }, true); UndoAction = new InputAction( new Buttons[] { Buttons.B }, new Keys[] { Keys.B }, true); }
public KeySet(InputAction Action, KeyCode Key, PressType Press, Action Function) { this.Action = Action; this.Key = Key; this.Press = Press; this.Function = Function; }
public async Task<ApiResult<Object>> ExecuteAction(InputAction action) { var result = await httpClient.PostAsync(Execute, new StringContent(JsonSerializer.Serialize(action), Encoding.UTF8, "application/json")); var content = await result.Content.ReadAsStringAsync(); return JsonSerializer.Deserialize<ApiResult<Object>>(content); }
protected override void onInputChange(InputAction inputAction, bool state) { if(this.character == null) { // No use in doing anything! return; } CharacterInputAction action = (CharacterInputAction)inputAction; switch(action) { case CharacterInputAction.WALK_LEFT: case CharacterInputAction.WALK_RIGHT: CharacterInputAction mirrorAction; GameObjectDirection direction; GameObjectDirection mirrorDirection; if(action == CharacterInputAction.WALK_LEFT) { direction = GameObjectDirection.LEFT; mirrorDirection = GameObjectDirection.RIGHT; mirrorAction = CharacterInputAction.WALK_RIGHT; } else { direction = GameObjectDirection.RIGHT; mirrorDirection = GameObjectDirection.LEFT; mirrorAction = CharacterInputAction.WALK_LEFT; } if (state) { // Walk key was pressed, start walking in that direction this.character.Direction = direction; this.character.Action = GameObjectAction.WALK; } else { // Walk key unpressed if(!this.keyStates[(int)mirrorAction]) { // The other walk key is not pressed either, we can stop walking this.character.Action = GameObjectAction.STAND; } else { // The other walk key is down, we need to continue walking but change direction this.character.Direction = mirrorDirection; } } break; case CharacterInputAction.JUMP: if(state) { this.character.Jump(); } break; default: break; } }
public MapEditorConfigMenuScreen() : base("Map Editor Config") { verticalNodeCount = 3; horizontalNodeCount = 3; // Configure Increase/Decrease count actions increaseCountAction = new InputAction(new Keys[] { Keys.Right }, true); decreaseCountAction = new InputAction(new Keys[] { Keys.Left }, true); // Add Menu Items MenuItem verticalNodesMenuItem = new MenuItem("Vertical Nodes: 3"); MenuItem horizontalNodesMenuItem = new MenuItem("Horizontal Nodes: 3"); MenuItem confirmMenuItem = new MenuItem("Confirm"); MenuItem cancelMenuItem = new MenuItem("Cancel"); // Hook up events confirmMenuItem.Selected += confirmMenuItem_Selected; cancelMenuItem.Selected += cancelMenuItem_Selected; // Add menu Items MenuItems.Add(verticalNodesMenuItem); MenuItems.Add(horizontalNodesMenuItem); MenuItems.Add(confirmMenuItem); MenuItems.Add(cancelMenuItem); }
public override void LoadContent() { spriteFont = Stage.Content.Load<Microsoft.Xna.Framework.Graphics.SpriteFont>("DefaultFont"); textBackground = Stage.Content.Load<Texture2D>("UI/Menu/blank"); ControlsQB cqb = Stage.ActiveStage.GetQB<ControlsQB>(); finishLoad = cqb.GetInputAction("FinishLoad"); }
public static void ActivateRevert(Hero controllingHero, InputAction cancelAction) { LastState = RetroGame.State; RetroGame.AddScreen(new RetroPortScreen(controllingHero, cancelAction), true); SoundManager.SetMusicReverse(true); SoundManager.SetLoopingSoundsReverse(true); }
private Tile _StartTile; //the inital starting tile #endregion Fields #region Constructors static Character() { up = InputAction.UP; down = InputAction.DOWN; left = InputAction.LEFT; right = InputAction.RIGHT; zoom = InputAction.RCLICK; }
public bool AddAction(String name, InputAction action) { if (!_actions.ContainsKey (name)) { _actions.Add (name, action); return true; } return false; }
//dummy screen that doesn't draw anything, just waits for a cancel action and disables all other input public RetroPortScreen(Hero controllingHero, InputAction cancelAction) { DrawPreviousScreen = true; bindings = controllingHero.bindings; this.controllingHero = controllingHero; this.cancelAction = cancelAction; }
public KeySelectMenuEntry(EAction action, InputAction defaultKeys) : base(action+": ") { Key = defaultKeys.Keys!=null ? defaultKeys.Keys[0] : Keys.None; Action = action; _actionName = action.GetDescription(); }
public PhoneMenuScreen(string title) { menuTitle = title; TransitionOnTime = TimeSpan.FromSeconds(0.5); TransitionOffTime = TimeSpan.FromSeconds(0.5); menuCancel = new InputAction(new Buttons[] { Buttons.Back }, true); }
public GameplayScreen() { TransitionOnTime = TimeSpan.FromSeconds(1.5); TransitionOffTime = TimeSpan.FromSeconds(0.5); pauseAction = new InputAction( new Buttons[] { Buttons.Start, Buttons.Back }, true); }
public override void Activate(InputAction activationAction) { if (bombTimer >= BombInterval && RetroGame.AvailableBombs > 0) { bombs.Add(new Bomb(this, hero.position, "bombtimed", EXPLOSION_TIME, ExplosionRadius)); bombTimer = 0; RetroGame.RemoveBomb(); } }
protected override void onInputChange(InputAction inputAction, bool state) { if (state && playerIndex == PlayerIndex.One) { switch (inputAction) { case InputAction.A: gameState.APressed(); break; case InputAction.B: gameState.BPressed(); break; case InputAction.DOWN: gameState.updateButtonChangeState(State.ButtonDown); break; case InputAction.UP: gameState.updateButtonChangeState(State.ButtonUp); break; case InputAction.LEFT: gameState.LeftPressed(); break; case InputAction.RIGHT: gameState.RightPressed(); break; default: break; } } else if (state && playerIndex == PlayerIndex.Two) { switch (inputAction) { case InputAction.A: gameState.APressed2(); break; case InputAction.B: gameState.BPressed(); break; case InputAction.DOWN: gameState.updateButtonChangeState(State.ButtonDown); break; case InputAction.UP: gameState.updateButtonChangeState(State.ButtonUp); break; case InputAction.LEFT: gameState.LeftPressed2(); break; case InputAction.RIGHT: gameState.RightPressed2(); break; default: break; } } }
float IInputManager.getActionValue(InputAction action) { Buttons check = InputLayout.getButton(action); float value; switch (check) { case Buttons.LeftTrigger: value = currentState.Triggers.Left; break; case Buttons.RightTrigger: value = currentState.Triggers.Right; break; //Thumbsticks have a vector, with each component ranging from -1 to 1 //Get value or '-value' so that a positive value is given in the direction being checked. case Buttons.LeftThumbstickRight: value = currentState.ThumbSticks.Left.X; break; case Buttons.LeftThumbstickLeft: value = -currentState.ThumbSticks.Left.X; break; case Buttons.LeftThumbstickUp: value = currentState.ThumbSticks.Left.Y; break; case Buttons.LeftThumbstickDown: value = -currentState.ThumbSticks.Left.Y; break; case Buttons.RightThumbstickRight: value = currentState.ThumbSticks.Right.X; break; case Buttons.RightThumbstickLeft: value = -currentState.ThumbSticks.Right.X; break; case Buttons.RightThumbstickUp: value = currentState.ThumbSticks.Right.Y; break; case Buttons.RightThumbstickDown: value = -currentState.ThumbSticks.Right.Y; break; //Button does not give an analog value default: if (currentState.IsButtonDown(check)) return 1f; else return 0f; } //If a negative value in thumbstick direction then return zero for that direction. if (value < 0f) return 0f; return value; }
public override void Activate(InputAction activationAction) { if (!bursting && burstRecharge >= BURST_COOLDOWN) { bursting = true; moveSpeedMultiplier = BURST_SPEED_MULTIPLIER; timeInBurst = 0; SoundManager.PlaySoundOnce("RocketBurst", playInReverseDuringReverse: true); } }
public StartScreen() : base("") { menuCancel = new InputAction(new Buttons[] { }, new Keys[] { }, true); MenuEntry enter = new MenuEntry("Press A"); enter.Selected += entry; MenuEntries.Add(enter); }
public void AddControl(string _cmdName, System.Action _cmd) { if (commandList.ContainsKey(_cmdName)) { commandList[_cmdName] = new InputAction(_cmd); } else { commandList.Add(_cmdName, new InputAction(_cmd)); } }
public void OnUnitClicked(Unit unit, MouseButton button) { if (currentAction == null) { if (unit.team == Unit.Team.PLAYER && !unit.usedThisTurn) { Movement m = new Movement(); m.Setup(unit); currentAction = m; } } else { currentAction.OnUnitClicked(unit, button); } }
public override void Activate(InputAction activationAction) { base.Activate(activationAction); if (bulletTimer < BULLET_FIRE_INTERVAL) return; bulletTimer = 0; ammo.Add(new Bullet(this, "bullet1", PrebuiltEmitter.SmallBulletSparks, EMITTER_STRAIGHT_COLOR, hero.direction, Bullet.DISTANCE_LIMIT_NORMAL, (int)(BULLET_DAMAGE_NORMAL * damageModifier))); ammo.Last().position = new Vector2(hero.position.X, hero.position.Y); ammo.Last().scale = BULLET_NORMAL_SCALE; ammo.Last().hitbox.originalRectangle.Height = BULLET_SIZE; ammo.Last().hitbox.originalRectangle.Width = BULLET_SIZE; shotFired = true; }
public override void Activate() { ContentManager content = new ContentManager(this.ScreenManager.Game.Services, "Content"); this._texture = content.Load<Texture2D>("Assets/Other/Game/SplashBanner"); this._position = new Vector2( this.ScreenManager.GraphicsDevice.Viewport.Width, this.ScreenManager.GraphicsDevice.Viewport.Height) * 0.5f; this._skipScreen = new InputAction( new Buttons[] { Buttons.A, Buttons.B, Buttons.Start, Buttons.Back, Buttons.X }, new Keys[] { Keys.Space, Keys.Enter, Keys.Escape, Keys.Tab, Keys.E }, true); }
/** * Maps a given input to a given function so that * when that input is detected the function will be called. */ public void Add(MultiPlatformInputs input, InputAction function) { if (inputMap.ContainsKey (input)) { List<InputAction> value = inputMap[input]; if(!value.Contains(function)) { value.Add(function); return; } } else { List<InputAction> value = new List<InputAction>(); value.Add(function); inputMap.Add (input, value); } }
/// <summary> /// Allows the action to be triggered by the key /// </summary> /// <param name="action">The input action to be triggered</param> /// <param name="key">The key to trigger the action</param> public void AddInput(InputAction action, Keys key) { if (actionDictionary.ContainsKey(action)) { if (!actionDictionary[action].Contains(key)) actionDictionary[action].Add(key); } else { ArrayList newList = new ArrayList(); newList.Add(key); actionDictionary.Add(action, newList); } }
/// <summary> /// Constructor. /// </summary> public Level1Screen() { TransitionOnTime = TimeSpan.FromSeconds(1.5); TransitionOffTime = TimeSpan.FromSeconds(0.5); pauseAction = new InputAction( new Buttons[] { Buttons.Start, Buttons.Back }, new Keys[] { Keys.Escape }, true); skillScreenAction = new InputAction( new Buttons[] { Buttons.Back }, new Keys[] { Keys.Back }, true); }
public void AddInputField(int mapCategoryId, InputAction action, AxisRange axisRange, ControllerType controllerType, int fieldIndex, GUIInputField inputField) { list.AddInputField(mapCategoryId, action, axisRange, controllerType, fieldIndex, inputField); }
public bool this[InputAction action] { get { return(keyPressed.ContainsKey(action)); } }
public static bool IsPerformed(this InputAction action) => action.phase == InputActionPhase.Performed;
public void Actions_CanPerformDoubleTapInteraction() { var gamepad = InputSystem.AddDevice <Gamepad>(); runtime.advanceTimeEachDynamicUpdate = 0; var action = new InputAction(binding: "<Gamepad>/buttonSouth", interactions: "multitap(tapTime=0.5,tapDelay=0.75,tapCount=2)"); action.Enable(); using (var trace = new InputActionTrace()) { trace.SubscribeTo(action); // Press button. runtime.currentTime = 1; InputSystem.QueueStateEvent(gamepad, new GamepadState().WithButton(GamepadButton.South), 1); InputSystem.Update(); var actions = trace.ToArray(); Assert.That(actions, Has.Length.EqualTo(1)); Assert.That(actions[0].phase, Is.EqualTo(InputActionPhase.Started)); Assert.That(actions[0].interaction, Is.TypeOf <MultiTapInteraction>()); Assert.That(actions[0].control, Is.SameAs(gamepad.buttonSouth)); Assert.That(actions[0].time, Is.EqualTo(1).Within(0.00001)); trace.Clear(); // Release before tap time and make sure the double tap cancels. runtime.currentTime = 12; InputSystem.QueueStateEvent(gamepad, new GamepadState(), 1.75); InputSystem.Update(); actions = trace.ToArray(); Assert.That(actions, Has.Length.EqualTo(1)); Assert.That(actions[0].phase, Is.EqualTo(InputActionPhase.Canceled)); Assert.That(actions[0].interaction, Is.TypeOf <MultiTapInteraction>()); Assert.That(actions[0].control, Is.SameAs(gamepad.buttonSouth)); Assert.That(actions[0].time, Is.EqualTo(1.75).Within(0.00001)); trace.Clear(); // Press again and then release before tap time. Should see only the start from // the initial press. runtime.currentTime = 2.5; InputSystem.QueueStateEvent(gamepad, new GamepadState().WithButton(GamepadButton.South), 2); InputSystem.QueueStateEvent(gamepad, new GamepadState(), 2.25); InputSystem.Update(); actions = trace.ToArray(); Assert.That(actions, Has.Length.EqualTo(1)); Assert.That(actions[0].phase, Is.EqualTo(InputActionPhase.Started)); Assert.That(actions[0].interaction, Is.TypeOf <MultiTapInteraction>()); Assert.That(actions[0].control, Is.SameAs(gamepad.buttonSouth)); Assert.That(actions[0].time, Is.EqualTo(2).Within(0.00001)); Assert.That(actions[0].ReadValue <float>(), Is.EqualTo(1).Within(0.00001)); trace.Clear(); // Wait for longer than tapDelay and make sure we're seeing a cancellation. runtime.currentTime = 4; InputSystem.Update(); actions = trace.ToArray(); Assert.That(actions, Has.Length.EqualTo(1)); Assert.That(actions[0].phase, Is.EqualTo(InputActionPhase.Canceled)); Assert.That(actions[0].interaction, Is.TypeOf <MultiTapInteraction>()); Assert.That(actions[0].control, Is.SameAs(gamepad.buttonSouth)); Assert.That(actions[0].time, Is.EqualTo(4).Within(0.00001)); Assert.That(actions[0].ReadValue <float>(), Is.EqualTo(0).Within(0.00001));// Button isn't pressed currently. trace.Clear(); // Now press and release within tap time. Then press again within delay time but release // only after tap time. Should we started and canceled. runtime.currentTime = 6; InputSystem.QueueStateEvent(gamepad, new GamepadState().WithButton(GamepadButton.South), 4.7); InputSystem.QueueStateEvent(gamepad, new GamepadState(), 4.9); InputSystem.QueueStateEvent(gamepad, new GamepadState().WithButton(GamepadButton.South), 5); InputSystem.QueueStateEvent(gamepad, new GamepadState(), 5.9); InputSystem.Update(); actions = trace.ToArray(); Assert.That(actions, Has.Length.EqualTo(2)); Assert.That(actions[0].phase, Is.EqualTo(InputActionPhase.Started)); Assert.That(actions[0].interaction, Is.TypeOf <MultiTapInteraction>()); Assert.That(actions[0].control, Is.SameAs(gamepad.buttonSouth)); Assert.That(actions[0].time, Is.EqualTo(4.7).Within(0.00001)); Assert.That(actions[0].ReadValue <float>(), Is.EqualTo(1).Within(0.00001)); Assert.That(actions[1].phase, Is.EqualTo(InputActionPhase.Canceled)); Assert.That(actions[1].interaction, Is.TypeOf <MultiTapInteraction>()); Assert.That(actions[1].control, Is.SameAs(gamepad.buttonSouth)); Assert.That(actions[1].time, Is.EqualTo(5.9).Within(0.00001)); Assert.That(actions[1].ReadValue <float>(), Is.EqualTo(0).Within(0.00001)); trace.Clear(); // Finally perform a full, proper double tap cycle. runtime.currentTime = 8; InputSystem.QueueStateEvent(gamepad, new GamepadState().WithButton(GamepadButton.South), 7); InputSystem.QueueStateEvent(gamepad, new GamepadState(), 7.25); InputSystem.QueueStateEvent(gamepad, new GamepadState().WithButton(GamepadButton.South), 7.5); InputSystem.QueueStateEvent(gamepad, new GamepadState(), 7.75); InputSystem.Update(); actions = trace.ToArray(); Assert.That(actions, Has.Length.EqualTo(2)); Assert.That(actions[0].phase, Is.EqualTo(InputActionPhase.Started)); Assert.That(actions[0].interaction, Is.TypeOf <MultiTapInteraction>()); Assert.That(actions[0].control, Is.SameAs(gamepad.buttonSouth)); Assert.That(actions[0].time, Is.EqualTo(7).Within(0.00001)); Assert.That(actions[0].ReadValue <float>(), Is.EqualTo(1).Within(0.00001)); Assert.That(actions[1].phase, Is.EqualTo(InputActionPhase.Performed)); Assert.That(actions[1].interaction, Is.TypeOf <MultiTapInteraction>()); Assert.That(actions[1].control, Is.SameAs(gamepad.buttonSouth)); Assert.That(actions[1].time, Is.EqualTo(7.75).Within(0.00001)); Assert.That(actions[1].ReadValue <float>(), Is.Zero.Within(0.00001)); } }
public void Trigger(InputAction action) { input.Trigger(action); }
public override void PerformAction(InputAction inputAction) { if (State.CurrentState != 1) { return; } switch (inputAction.Action) { case "UP": _selectedAction--; if (_selectedAction < 0) { _selectedAction = _actions.Length - 1; } RaiseSoundTriggered(SoundEvent.MENU_SELECT_UP); break; case "DOWN": _selectedAction++; if (_selectedAction >= _actions.Length) { _selectedAction = 0; } RaiseSoundTriggered(SoundEvent.MENU_SELECT_DOWN); break; case "LEFT": _currentPlayer--; if (_currentPlayer < 1) { _currentPlayer = 4; } RaiseSoundTriggered(SoundEvent.MENU_OPTION_SELECT_LEFT); break; case "RIGHT": _currentPlayer++; if (_currentPlayer > 4) { _currentPlayer = 1; } RaiseSoundTriggered(SoundEvent.MENU_OPTION_SELECT_RIGHT); break; case "START": StartPressed(); break; case "SELECT": RemoveBindings(); break; case "BACK": Core.ScreenTransition("MainMenu"); RaiseSoundTriggered(SoundEvent.MENU_BACK); break; } CreateBindingList(); }
private void Start() { _inputAction = new InputAction("SerieOfKeysChallenge", binding: "<Keyboard>/#()"); _inputAction.performed += _ => HasPressedCorrectKey(); _inputAction.Enable(); }
public void Components_CanUpdateGameObjectTransformThroughTrackedPoseDriver() { var position = new Vector3(1.0f, 2.0f, 3.0f); var rotation = new Quaternion(0.09853293f, 0.09853293f, 0.09853293f, 0.9853293f); var go = new GameObject(); var tpd = go.AddComponent <TrackedPoseDriver>(); var device = InputSystem.AddDevice <TestHMD>(); using (StateEvent.From(device, out var stateEvent)) { var positionAction = new InputAction(); positionAction.AddBinding("<TestHMD>/vector3"); var rotationAction = new InputAction(); rotationAction.AddBinding("<TestHMD>/quaternion"); tpd.positionAction = positionAction; tpd.rotationAction = rotationAction; // before render only var go1 = tpd.gameObject; go1.transform.position = Vector3.zero; go1.transform.rotation = new Quaternion(0, 0, 0, 0); tpd.updateType = TrackedPoseDriver.UpdateType.BeforeRender; tpd.trackingType = TrackedPoseDriver.TrackingType.RotationAndPosition; device.quaternion.WriteValueIntoEvent(rotation, stateEvent); device.vector3.WriteValueIntoEvent(position, stateEvent); InputSystem.QueueEvent(stateEvent); InputSystem.Update(InputUpdateType.Dynamic); Assert.That(tpd.gameObject.transform.position, Is.Not.EqualTo(position)); Assert.That(!tpd.gameObject.transform.rotation.Equals(rotation)); var go2 = tpd.gameObject; go2.transform.position = Vector3.zero; go2.transform.rotation = new Quaternion(0, 0, 0, 0); InputSystem.QueueEvent(stateEvent); InputSystem.Update(InputUpdateType.BeforeRender); Assert.That(tpd.gameObject.transform.position, Is.EqualTo(position)); Assert.That(tpd.gameObject.transform.rotation.Equals(rotation)); // update only var go3 = tpd.gameObject; go3.transform.position = Vector3.zero; go3.transform.rotation = new Quaternion(0, 0, 0, 0); tpd.updateType = TrackedPoseDriver.UpdateType.Update; tpd.trackingType = TrackedPoseDriver.TrackingType.RotationAndPosition; InputSystem.QueueEvent(stateEvent); InputSystem.Update(InputUpdateType.Dynamic); Assert.That(tpd.gameObject.transform.position, Is.EqualTo(position)); Assert.That(tpd.gameObject.transform.rotation.Equals(rotation)); var go4 = tpd.gameObject; go4.transform.position = Vector3.zero; go4.transform.rotation = new Quaternion(0, 0, 0, 0); InputSystem.QueueEvent(stateEvent); InputSystem.Update(InputUpdateType.BeforeRender); Assert.That(tpd.gameObject.transform.position, Is.Not.EqualTo(position)); Assert.That(!tpd.gameObject.transform.rotation.Equals(rotation)); // check the rot/pos case also Update AND Render. tpd.updateType = TrackedPoseDriver.UpdateType.UpdateAndBeforeRender; tpd.trackingType = TrackedPoseDriver.TrackingType.PositionOnly; var go5 = tpd.gameObject; go5.transform.position = Vector3.zero; go5.transform.rotation = new Quaternion(0, 0, 0, 0); InputSystem.QueueEvent(stateEvent); InputSystem.Update(InputUpdateType.Dynamic); Assert.That(tpd.gameObject.transform.position, Is.EqualTo(position)); Assert.That(!tpd.gameObject.transform.rotation.Equals(rotation)); tpd.trackingType = TrackedPoseDriver.TrackingType.RotationOnly; var go6 = tpd.gameObject; go6.transform.position = Vector3.zero; go6.transform.rotation = new Quaternion(0, 0, 0, 0); InputSystem.QueueEvent(stateEvent); InputSystem.Update(InputUpdateType.BeforeRender); Assert.That(tpd.gameObject.transform.position, Is.Not.EqualTo(position)); Assert.That(tpd.gameObject.transform.rotation.Equals(rotation)); } }
/// <summary> /// Initializes a new instance of the <see cref="MouseButtonEventArgs" /> struct. /// </summary> /// <param name="button">The mouse button for the event.</param> /// <param name="action">The action of the mouse button.</param> /// <param name="modifiers">The key modifiers held during the mouse button's action.</param> public MouseButtonEventArgs(MouseButton button, InputAction action, KeyModifiers modifiers) { Button = button; Action = action; Modifiers = modifiers; }
public static IDisposable BindAction <TInput>(this IReactive <UIButton> reactive, InputAction <TInput> action, Func <UIButton, TInput> inputTransform, ButtonEventType eventType = ButtonEventType.Tap) => reactive.BindAction <TInput, Unit>(action, inputTransform, eventType);
private void ReactToInventory(InputAction action, GameState gameState) { var inventoryComponent = Atom.GetComponent <InventoryComponent>(); inventoryComponent.PickUp(gameState); }
public static Vector2 GetAxis2D(InputAction action) { return(action.ReadValue <Vector2>()); }
public static bool GetButton(InputAction action) { return(action.ReadValue <float>() > 0.5f); }
public static bool GetButtonUp(InputAction action) { return(actions_canceled.Contains(action.GetHashCode())); }
private static void AddStartedAction(InputAction action) { actions_started.Add(action.GetHashCode()); }
public ObservableCancelablePriorityInputAction(InputAction inputAction, GameObject owner) { this.InputAction = inputAction; this.Owner = owner; }
public void TriggerWithButton(InputAction action, float state) { inputAction = action; Trigger(action.bindings.Count, state); }
public static void RegisterInputAction(string name, InputAction inputAction) { inputActionDict[name] = inputAction; }
public void Actions_CanPerformPressInteraction() { var gamepad = InputSystem.AddDevice <Gamepad>(); // We add a second input device (and bind to it), to test that the binding // conflict resolution will not interfere with the interaction handling. InputSystem.AddDevice <Keyboard>(); // Test all three press behaviors concurrently. var pressOnlyAction = new InputAction("PressOnly", binding: "<Gamepad>/buttonSouth", interactions: "press"); pressOnlyAction.AddBinding("<Keyboard>/a"); var releaseOnlyAction = new InputAction("ReleaseOnly", binding: "<Gamepad>/buttonSouth", interactions: "press(behavior=1)"); releaseOnlyAction.AddBinding("<Keyboard>/s"); var pressAndReleaseAction = new InputAction("PressAndRelease", binding: "<Gamepad>/buttonSouth", interactions: "press(behavior=2)"); pressAndReleaseAction.AddBinding("<Keyboard>/d"); pressOnlyAction.Enable(); releaseOnlyAction.Enable(); pressAndReleaseAction.Enable(); using (var trace = new InputActionTrace()) { trace.SubscribeToAll(); runtime.currentTime = 1; Press(gamepad.buttonSouth); var actions = trace.ToArray(); Assert.That(actions, Has.Length.EqualTo(5)); Assert.That(actions, Has.Exactly(1).With.Property("action").SameAs(pressOnlyAction).And.With.Property("phase") .EqualTo(InputActionPhase.Started).And.With.Property("duration") .EqualTo(0)); Assert.That(actions, Has.Exactly(1).With.Property("action").SameAs(pressOnlyAction).And.With.Property("phase") .EqualTo(InputActionPhase.Performed).And.With.Property("duration") .EqualTo(0)); Assert.That(actions, Has.Exactly(1).With.Property("action").SameAs(pressAndReleaseAction).And.With.Property("phase") .EqualTo(InputActionPhase.Started).And.With.Property("duration") .EqualTo(0)); Assert.That(actions, Has.Exactly(1).With.Property("action").SameAs(pressAndReleaseAction).And.With.Property("phase") .EqualTo(InputActionPhase.Performed).And.With.Property("duration") .EqualTo(0)); Assert.That(actions, Has.Exactly(1).With.Property("action").SameAs(releaseOnlyAction).And.With.Property("phase") .EqualTo(InputActionPhase.Started).And.With.Property("duration") .EqualTo(0)); trace.Clear(); runtime.currentTime = 2; Release(gamepad.buttonSouth); actions = trace.ToArray(); Assert.That(actions, Has.Length.EqualTo(3)); Assert.That(actions, Has.Exactly(1).With.Property("action").SameAs(releaseOnlyAction).And.With.Property("phase") .EqualTo(InputActionPhase.Performed).And.With.Property("duration") .EqualTo(1)); Assert.That(actions, Has.Exactly(1).With.Property("action").SameAs(pressAndReleaseAction).And.With.Property("phase") .EqualTo(InputActionPhase.Started).And.With.Property("duration") .EqualTo(0)); Assert.That(actions, Has.Exactly(1).With.Property("action").SameAs(pressAndReleaseAction).And.With.Property("phase") .EqualTo(InputActionPhase.Performed).And.With.Property("duration") .EqualTo(0)); trace.Clear(); runtime.currentTime = 5; Press(gamepad.buttonSouth); actions = trace.ToArray(); Assert.That(actions, Has.Length.EqualTo(5)); Assert.That(actions, Has.Exactly(1).With.Property("action").SameAs(pressOnlyAction).And.With.Property("phase") .EqualTo(InputActionPhase.Started).And.With.Property("duration") .EqualTo(0)); Assert.That(actions, Has.Exactly(1).With.Property("action").SameAs(pressOnlyAction).And.With.Property("phase") .EqualTo(InputActionPhase.Performed).And.With.Property("duration") .EqualTo(0)); Assert.That(actions, Has.Exactly(1).With.Property("action").SameAs(pressAndReleaseAction).And.With.Property("phase") .EqualTo(InputActionPhase.Started).And.With.Property("duration") .EqualTo(0)); Assert.That(actions, Has.Exactly(1).With.Property("action").SameAs(pressAndReleaseAction).And.With.Property("phase") .EqualTo(InputActionPhase.Performed).And.With.Property("duration") .EqualTo(0)); Assert.That(actions, Has.Exactly(1).With.Property("action").SameAs(releaseOnlyAction).And.With.Property("phase") .EqualTo(InputActionPhase.Started).And.With.Property("duration") .EqualTo(0)); } }
/// <inheritdoc cref="IRLActionInputAdaptor.GetActionSpecForInputAction"/> public ActionSpec GetActionSpecForInputAction(InputAction action) { return(ActionSpec.MakeContinuous(1)); }
public void Actions_CanPerformHoldInteraction() { const int timeOffset = 123; runtime.currentTimeOffsetToRealtimeSinceStartup = timeOffset; runtime.currentTime = 10 + timeOffset; var gamepad = InputSystem.AddDevice <Gamepad>(); var performedReceivedCalls = 0; InputAction performedAction = null; InputControl performedControl = null; var startedReceivedCalls = 0; InputAction startedAction = null; InputControl startedControl = null; var canceledReceivedCalls = 0; InputAction canceledAction = null; InputControl canceledControl = null; var action = new InputAction(binding: "<Gamepad>/{primaryAction}", interactions: "hold(duration=0.4)"); action.performed += ctx => { ++performedReceivedCalls; performedAction = ctx.action; performedControl = ctx.control; Assert.That(action.phase, Is.EqualTo(InputActionPhase.Performed)); Assert.That(ctx.duration, Is.GreaterThanOrEqualTo(0.4)); }; action.started += ctx => { ++startedReceivedCalls; startedAction = ctx.action; startedControl = ctx.control; Assert.That(action.phase, Is.EqualTo(InputActionPhase.Started)); Assert.That(ctx.duration, Is.EqualTo(0.0)); }; action.canceled += ctx => { ++canceledReceivedCalls; canceledAction = ctx.action; canceledControl = ctx.control; Assert.That(action.phase, Is.EqualTo(InputActionPhase.Canceled)); Assert.That(ctx.duration, Is.GreaterThan(0.0)); Assert.That(ctx.duration, Is.LessThan(0.4)); }; action.Enable(); InputSystem.QueueStateEvent(gamepad, new GamepadState().WithButton(GamepadButton.South), 10.0); InputSystem.Update(); Assert.That(startedReceivedCalls, Is.EqualTo(1)); Assert.That(performedReceivedCalls, Is.Zero); Assert.That(canceledReceivedCalls, Is.Zero); Assert.That(startedAction, Is.SameAs(action)); Assert.That(startedControl, Is.SameAs(gamepad.buttonSouth)); startedReceivedCalls = 0; InputSystem.QueueStateEvent(gamepad, new GamepadState(), 10.25); InputSystem.Update(); Assert.That(startedReceivedCalls, Is.Zero); Assert.That(performedReceivedCalls, Is.Zero); Assert.That(canceledReceivedCalls, Is.EqualTo(1)); Assert.That(canceledAction, Is.SameAs(action)); Assert.That(canceledControl, Is.SameAs(gamepad.buttonSouth)); Assert.That(action.phase, Is.EqualTo(InputActionPhase.Waiting)); canceledReceivedCalls = 0; InputSystem.QueueStateEvent(gamepad, new GamepadState().WithButton(GamepadButton.South), 10.5); InputSystem.Update(); Assert.That(startedReceivedCalls, Is.EqualTo(1)); Assert.That(performedReceivedCalls, Is.Zero); Assert.That(canceledReceivedCalls, Is.Zero); Assert.That(startedAction, Is.SameAs(action)); Assert.That(startedControl, Is.SameAs(gamepad.buttonSouth)); Assert.That(action.phase, Is.EqualTo(InputActionPhase.Started)); startedReceivedCalls = 0; runtime.currentTime = 10.75 + timeOffset; InputSystem.Update(); Assert.That(startedReceivedCalls, Is.Zero); Assert.That(performedReceivedCalls, Is.Zero); Assert.That(canceledReceivedCalls, Is.Zero); Assert.That(startedAction, Is.SameAs(action)); Assert.That(startedControl, Is.SameAs(gamepad.buttonSouth)); Assert.That(action.phase, Is.EqualTo(InputActionPhase.Started)); runtime.currentTime = 11 + timeOffset; InputSystem.Update(); Assert.That(startedReceivedCalls, Is.Zero); Assert.That(performedReceivedCalls, Is.EqualTo(1)); Assert.That(canceledReceivedCalls, Is.Zero); Assert.That(performedAction, Is.SameAs(action)); Assert.That(performedControl, Is.SameAs(gamepad.buttonSouth)); Assert.That(action.phase, Is.EqualTo(InputActionPhase.Waiting)); }
/// <inheritdoc cref="IRLActionInputAdaptor.QueueInputEventForAction"/> public void QueueInputEventForAction(InputAction action, InputControl control, ActionSpec actionSpec, in ActionBuffers actionBuffers)
// Start is called before the first frame update void Start() { rb = this.gameObject.GetComponent <Rigidbody>(); playerInput = this.gameObject.GetComponent <PlayerInput>(); moveAction = playerInput.currentActionMap.FindAction("Move"); }
private bool IsRebindableAction(InputAction action, InputBinding binding) { return(binding.isComposite || binding.isPartOfComposite || action.expectedControlType == "Button"); }
public static void RefreshMappings() { Debug.Log("Refreshing Input Mapping Icons"); foreach (ControllerMap current in ReInput.players.GetPlayer(0).controllers.maps.GetAllMaps(ControllerType.Mouse)) { foreach (ActionElementMap current2 in current.AllMaps) { if (!string.IsNullOrEmpty(current2.elementIdentifierName)) { try { string text = current2.elementIdentifierName.Replace(' ', '_'); InputAction action = ReInput.mapping.GetAction(current2.actionId); if (action.type == InputActionType.Axis) { InputMappingIcons.KeyboardMappings[(int)Enum.Parse(typeof(InputMappingIcons.Actions), ((current2.axisContribution != Pole.Positive) ? action.negativeDescriptiveName : action.positiveDescriptiveName).Replace(' ', '_'))] = text; } InputMappingIcons.KeyboardMappings[(int)Enum.Parse(typeof(InputMappingIcons.Actions), action.name.Replace(' ', '_'))] = text; } catch { } } } } foreach (ControllerMap current3 in ReInput.players.GetPlayer(0).controllers.maps.GetAllMaps(ControllerType.Keyboard)) { foreach (ActionElementMap current4 in current3.AllMaps) { if (!string.IsNullOrEmpty(current4.elementIdentifierName)) { try { string elementIdentifierName = current4.elementIdentifierName; string text2; if (elementIdentifierName != null) { if (InputMappingIcons.< > f__switch$map1A == null) { InputMappingIcons.< > f__switch$map1A = new Dictionary <string, int>(2) { { "Left Control", 0 }, { "Right Control", 1 } }; } int num; if (InputMappingIcons.< > f__switch$map1A.TryGetValue(elementIdentifierName, out num)) { if (num == 0) { text2 = "LCtrl"; goto IL_22B; } if (num == 1) { text2 = "RCtrl"; goto IL_22B; } } } text2 = current4.elementIdentifierName; IL_22B: InputAction action2 = ReInput.mapping.GetAction(current4.actionId); if (action2.type == InputActionType.Axis) { InputMappingIcons.KeyboardMappings[(int)Enum.Parse(typeof(InputMappingIcons.Actions), ((current4.axisContribution != Pole.Positive) ? action2.negativeDescriptiveName : action2.positiveDescriptiveName).Replace(' ', '_'))] = text2; } InputMappingIcons.KeyboardMappings[(int)Enum.Parse(typeof(InputMappingIcons.Actions), action2.name.Replace(' ', '_'))] = text2; } catch { } } } } if (InputMappingIcons.LastController != null) { bool flag = InputMappingIcons.LastController.name.Contains("DualShock"); foreach (ControllerMap current5 in ReInput.players.GetPlayer(0).controllers.maps.GetAllMaps(ControllerType.Joystick)) { if (current5.controllerId == InputMappingIcons.LastController.id) { foreach (ActionElementMap current6 in current5.AllMaps) { if (!string.IsNullOrEmpty(current6.elementIdentifierName)) { try { string elementIdentifierName = current6.elementIdentifierName; string text3; if (elementIdentifierName != null) { if (InputMappingIcons.< > f__switch$map1B == null) { InputMappingIcons.< > f__switch$map1B = new Dictionary <string, int>(4) { { "Right Stick X", 0 }, { "Right Stick Y", 0 }, { "Left Stick X", 1 }, { "Left Stick Y", 1 } }; } int num; if (InputMappingIcons.< > f__switch$map1B.TryGetValue(elementIdentifierName, out num)) { if (num == 0) { text3 = "Right_Stick_Button"; goto IL_47F; } if (num == 1) { text3 = "Left_Stick_Button"; goto IL_47F; } } } text3 = current6.elementIdentifierName.Replace(" X", string.Empty).Replace(" Y", string.Empty).TrimEnd(new char[] { ' ', '+', '-' }).Replace(' ', '_'); IL_47F: InputAction action3 = ReInput.mapping.GetAction(current6.actionId); if (flag) { text3 = "PS4_" + text3; if (action3.type == InputActionType.Axis) { InputMappingIcons.GamepadMappings[(int)Enum.Parse(typeof(InputMappingIcons.Actions), ((current6.axisContribution != Pole.Positive) ? action3.negativeDescriptiveName : action3.positiveDescriptiveName).Replace(' ', '_'))] = text3; } InputMappingIcons.GamepadMappings[(int)Enum.Parse(typeof(InputMappingIcons.Actions), action3.name.Replace(' ', '_'))] = text3; } else { text3 = "360_" + text3; if (action3.type == InputActionType.Axis) { InputMappingIcons.GamepadMappings[(int)Enum.Parse(typeof(InputMappingIcons.Actions), ((current6.axisContribution != Pole.Positive) ? action3.negativeDescriptiveName : action3.positiveDescriptiveName).Replace(' ', '_'))] = text3; } InputMappingIcons.GamepadMappings[(int)Enum.Parse(typeof(InputMappingIcons.Actions), action3.name.Replace(' ', '_'))] = text3; Debug.Log(Enum.Parse(typeof(InputMappingIcons.Actions), ReInput.mapping.GetAction(current6.actionId).name.Replace(' ', '_')) + " -> " + text3); } } catch { } } } } } } InputMappingIcons.Version++; }
InputAction DuplicateInputAction(InputAction source) { return(DuplicateInputAction(source.Name, source)); }
public void BindKey(Key key, InputAction action) { keyBindings[key] = action; }
private static void AddCanceledAction(InputAction action) { actions_canceled.Add(action.GetHashCode()); }
public static float GetAxis(InputAction action) { return(action.ReadValue <float>()); }
public static bool GetButtonDown(InputAction action) { return(actions_started.Contains(action.GetHashCode())); }