/// <summary> /// Handle if the joystick axis is moved /// </summary> /// <param name="sender"></param> /// <param name="axis"></param> public void OnJoystickAxisMoved(object sender, JoystickMoveEventArgs axis) { switch (axis.Axis) { case (Joystick.Axis)Controller.Controller.XboxOneDirection.DPadXDir: float dx = 0, dy = 0; if (Joystick.GetAxisPosition(0, axis.Axis) > 0) { SetDirection(Direction.Right); dx = LinearVelocity * Friction * GameMaster.Delta.AsSeconds(); Play(); } else if (Joystick.GetAxisPosition(0, axis.Axis) < 0) { SetDirection(Direction.Left); dx = -1 * LinearVelocity * Friction * GameMaster.Delta.AsSeconds(); Play(); } Move(dx, dy); break; case (Joystick.Axis)Controller.Controller.XboxOneDirection.Triggers: break; } }
public void JoystickMoved(object joystickMoveEventArgs) { JoystickMoveEventArgs joystick = (JoystickMoveEventArgs)joystickMoveEventArgs; bool xAxis = joystick.Axis == Joystick.Axis.X; bool yAxis = joystick.Axis == Joystick.Axis.Y; float direction = joystick.Position; if (xAxis && direction < 0) { Game.EventMgr.Notify(Event.JoystickMoveLeft, joystick); } else if (xAxis && direction > 0) { Game.EventMgr.Notify(Event.JoystickMoveRight, joystick); } else if (yAxis && direction < 0) { Game.EventMgr.Notify(Event.JoystickMoveUp, joystick); } else if (yAxis && direction > 0) { Game.EventMgr.Notify(Event.JoystickMoveDown, joystick); } }
public static void OnJoystickMoved(object sender, JoystickMoveEventArgs e) { if (controllers.ContainsKey(e.JoystickId)) { controllers[e.JoystickId].OnStickMove(sender, e); } }
// Method to process the inputs from the joystick private void ProcessJoyInputs(object sender, JoystickMoveEventArgs e) { if (StateSystem.GameState != States.InGame) { return; } if (e.Axis == Joystick.Axis.X) { if (Math.Abs(e.Position) > bound) { moveX = speed * (e.Position / 100); } else { moveX = 0.0f; } } if (e.Axis == Joystick.Axis.Y) { if (Math.Abs(e.Position) > bound) { moveY = speed * (e.Position / 100); } else { moveY = 0.0f; } } Program.map.Girl.setVelocity(moveX, moveY); }
/// <summary> /// Handles the JoyMoved event of the <see cref="GameBase.RenderWindow"/>. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="SFML.Window.JoystickMoveEventArgs"/> instance containing the event data.</param> void rw_JoystickMoved(object sender, JoystickMoveEventArgs e) { if (JoyMoved != null) { JoyMoved.Raise(this, e); } }
private void RenderWindow_JoystickMoved(object?sender, JoystickMoveEventArgs e) { this.JoystickMoved(new JoystickMovedEvent() { JoystickID = e.JoystickId, Axis = e.Axis.ToNonSFML(), Delta = e.Position }); }
/// <summary> /// Handler for joystick axis moving /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public override void OnJoyStickAxisMoved(object sender, JoystickMoveEventArgs e) { Vector2f?pointerPoition; if ((pointerPoition = Pointer.GetPosition()) == null) { LogManager.LogWarning("The main menu pointer has no location."); return; } if (e.Axis != (Joystick.Axis)Controller.Controller.XboxOneDirection.DPadYDir && e.Axis != (Joystick.Axis)Controller.Controller.XboxOneDirection.LThumbYDir) { return; } if (e.Position > 5) { try { if ((_currentNode = _currentNode.Previous) != null) { pointerPoition = _currentNode.Value; } } catch (NullReferenceException exception) { _currentNode = _pointerPositions.Last; pointerPoition = _currentNode.Value; LogManager.LogWarning(exception.Message); } } else if (e.Position < -1) { try { if ((_currentNode = _currentNode.Next) != null) { pointerPoition = _currentNode.Value; } } catch (NullReferenceException exception) { _currentNode = _pointerPositions.First; pointerPoition = _currentNode.Value; LogManager.LogWarning(exception.Message); } } Pointer.SetPosition(pointerPoition.Value); }
private void OnJoyMoved(object sender, JoystickMoveEventArgs e) { if (e.Axis == Joystick.Axis.X) { left = e.Position == -100 ? 0 : 1; right = e.Position == 100 ? 0 : 1; } else if (e.Axis == Joystick.Axis.Y) { up = e.Position == -100 ? 0 : 1; down = e.Position == 100 ? 0 : 1; } if (left + right + up + down != 4) { Interrupts.JoypadIrqReq = true; } }
public void JoystickMoved(RenderWindow target, object sender, JoystickMoveEventArgs arg) { #if DEBUG $"Controller ({arg.JoystickId}) Moved: Axis({arg.Axis}), Position({arg.Position})".Log(); #endif // Move Down if (arg.Axis == Joystick.Axis.PovY && Math.Abs(arg.Position + 100) < GamepadMinimumInputTolerance) { MenuItem nextSelectedMenuItem = GetMenuItems().OrderBy(c => c.Position).FirstOrDefault(c => c.Enable && c.FunctionType != MenuItemFunctionType.CustomPage && c.Position > _selectedMenuItem.Position); if (nextSelectedMenuItem != null) { PlaySound(_menuSoundBeep); _selectedMenuItem = nextSelectedMenuItem; } } // Move Up else if (arg.Axis == Joystick.Axis.PovY && Math.Abs(arg.Position - 100) < GamepadMinimumInputTolerance) { MenuItem nextSelectedMenuItem = GetMenuItems().OrderByDescending(c => c.Position).FirstOrDefault(c => c.Enable && c.FunctionType != MenuItemFunctionType.CustomPage && c.Position < _selectedMenuItem.Position); if (nextSelectedMenuItem != null) { PlaySound(_menuSoundBeep); _selectedMenuItem = nextSelectedMenuItem; } } // Move Left else if (_selectedMenuItem.FunctionType == MenuItemFunctionType.YesNo && arg.Axis == Joystick.Axis.PovX && Math.Abs(arg.Position + 100) < GamepadMinimumInputTolerance) { _selectedMenuItem.FunctionObject?.Invoke((bool)_selectedMenuItem.FunctionObject(null, null), -YesNoVolumeStep); } // Move Right else if (_selectedMenuItem.FunctionType == MenuItemFunctionType.YesNo && arg.Axis == Joystick.Axis.PovX && Math.Abs(arg.Position - 100) < GamepadMinimumInputTolerance) { _selectedMenuItem.FunctionObject?.Invoke((bool)_selectedMenuItem.FunctionObject(null, null), YesNoVolumeStep); } }
internal void OnStickMove(object s, JoystickMoveEventArgs e) { }
private static void OnJoystickMoved(object sender, JoystickMoveEventArgs e) { Controller.OnJoystickMoved(sender, e); }
protected override void JoystickMoved(object sender, JoystickMoveEventArgs arg) { }
protected override void JoystickMoved(object sender, JoystickMoveEventArgs arg) => GetGameInput().JoystickMoved(Window, sender, arg);
void OnJoystickMoved(object sender, JoystickMoveEventArgs e) { //Console.WriteLine("Joystick " + e.JoystickId + " moved axis " + e.Axis + " to " + e.Position); }
public EventJoystickMove(JoystickMoveEventArgs args) { this.Position = args.Position; this.JoystickId = (int)args.JoystickId; this.Axis = args.Axis.ToString(); }
protected abstract void JoystickMoved(object sender, JoystickMoveEventArgs arg);
/// <summary> /// Event call back when joystick axis is moved /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public abstract void OnJoyStickAxisMoved(object sender, JoystickMoveEventArgs e);
public static void OnJoyStickMoved(object sender, JoystickMoveEventArgs e) { Console.WriteLine("moved axis"); Console.WriteLine(e); }
// Fired when a joystick is moved. private void OnJoystickMoved(object sender, JoystickMoveEventArgs e) { }
static void JoystickMoved(object sender, JoystickMoveEventArgs e) { EventMgr.Notify(Event.JoystickMoved, e); }
private void OnJoystickMoved(object sender, JoystickMoveEventArgs joystickMoveEventArgs) { JoystickMoved(sender, joystickMoveEventArgs); //Console.WriteLine("Input Event: Joystick Moved: ID: " + joystickMoveEventArgs.JoystickId + " Axis: " + joystickMoveEventArgs.Axis + " to Position: " + joystickMoveEventArgs.Position); }