예제 #1
0
        /// <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;
            }
        }
예제 #2
0
        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);
            }
        }
예제 #3
0
 public static void OnJoystickMoved(object sender, JoystickMoveEventArgs e)
 {
     if (controllers.ContainsKey(e.JoystickId))
     {
         controllers[e.JoystickId].OnStickMove(sender, e);
     }
 }
예제 #4
0
        // 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);
        }
예제 #5
0
 /// <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);
     }
 }
예제 #6
0
 private void RenderWindow_JoystickMoved(object?sender, JoystickMoveEventArgs e)
 {
     this.JoystickMoved(new JoystickMovedEvent()
     {
         JoystickID = e.JoystickId,
         Axis       = e.Axis.ToNonSFML(),
         Delta      = e.Position
     });
 }
예제 #7
0
        /// <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);
        }
예제 #8
0
        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;
            }
        }
예제 #9
0
        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);
            }
        }
예제 #10
0
 internal void OnStickMove(object s, JoystickMoveEventArgs e)
 {
 }
예제 #11
0
 private static void OnJoystickMoved(object sender, JoystickMoveEventArgs e)
 {
     Controller.OnJoystickMoved(sender, e);
 }
예제 #12
0
 protected override void JoystickMoved(object sender, JoystickMoveEventArgs arg)
 {
 }
예제 #13
0
 protected override void JoystickMoved(object sender, JoystickMoveEventArgs arg) => GetGameInput().JoystickMoved(Window, sender, arg);
예제 #14
0
 void OnJoystickMoved(object sender, JoystickMoveEventArgs e)
 {
     //Console.WriteLine("Joystick " + e.JoystickId + " moved axis " + e.Axis + " to " + e.Position);
 }
예제 #15
0
 public EventJoystickMove(JoystickMoveEventArgs args)
 {
     this.Position   = args.Position;
     this.JoystickId = (int)args.JoystickId;
     this.Axis       = args.Axis.ToString();
 }
예제 #16
0
 protected abstract void JoystickMoved(object sender, JoystickMoveEventArgs arg);
예제 #17
0
파일: Menu.cs 프로젝트: trejonh/Apocalypto
 /// <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);
예제 #18
0
 public static void OnJoyStickMoved(object sender, JoystickMoveEventArgs e)
 {
     Console.WriteLine("moved axis");
     Console.WriteLine(e);
 }
예제 #19
0
 // Fired when a joystick is moved.
 private void OnJoystickMoved(object sender, JoystickMoveEventArgs e)
 {
 }
예제 #20
0
 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);
 }