This project is read-only.

No data from right thumbstick

May 3, 2014 at 5:31 PM
Hi.

I have just started to learn how to use Nuclex.Input and there is one problem: I have no response from right thumbstick.

Code:
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Nuclex.Input;

namespace GamePadTest3
{
    public class Game1 : Microsoft.Xna.Framework.Game
    {
        GraphicsDeviceManager graphics;
        SpriteBatch spriteBatch;

        private InputManager inputManager;
        private int game_pads;
        private Nuclex.Input.Devices.GamePad gamePad;
        private int buttons_cnt;

        private Texture2D buttonT;

        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            this.inputManager = new InputManager(Services, Window.Handle);
            Content.RootDirectory = "Content";
        }

        protected override void Initialize()
        {
            base.Initialize();

            this.graphics.PreferredBackBufferWidth = 640;
            this.graphics.PreferredBackBufferHeight = 480;
            this.graphics.IsFullScreen = false;
            this.graphics.ApplyChanges();

            this.buttonT = createTexture(20, 20, Color.White);

            this.game_pads = this.inputManager.GamePads.Count;
            Console.WriteLine("GamePads = " + this.game_pads.ToString());

            for (int i=0; i <this.game_pads; ++i)
            {
                if (this.inputManager.GamePads[i].GetState().IsConnected)
                    Console.WriteLine("Gamepad #" + (i+1) + ": connected");
            }

            this.gamePad = (Nuclex.Input.Devices.GamePad)this.inputManager.GetGamePad(ExtendedPlayerIndex.Five);

            Console.WriteLine(this.gamePad.Name);
            Console.WriteLine(this.gamePad.GetState().IsConnected);

            this.buttons_cnt = this.gamePad.GetExtendedState().ButtonCount;
            Console.WriteLine("buttons = " + this.buttons_cnt);
        }

        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here
        }

        protected override void UnloadContent()
        {
            // TODO: Unload any non ContentManager content here
        }

        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            //if (this.gamePad.GetState().Buttons.Back == ButtonState.Pressed)
            //    this.Exit();

            // TODO: Add your update logic here

            this.inputManager.Update();
            for (int index = 0; index < this.gamePad.GetExtendedState().ButtonCount; ++index)
            {
                if (this.gamePad.GetExtendedState().IsButtonDown(index))
                    Console.WriteLine("Button #" + index + " : DOWN!");
                //else
                //    Console.WriteLine("Button #" + index + " : UP!");
            }

            float lx = this.inputManager.GetGamePad(ExtendedPlayerIndex.Five).GetState().ThumbSticks.Left.X;
            float ly = this.inputManager.GetGamePad(ExtendedPlayerIndex.Five).GetState().ThumbSticks.Left.Y;
            float rx = this.inputManager.GetGamePad(ExtendedPlayerIndex.Five).GetState().ThumbSticks.Right.X;
            float ry = this.inputManager.GetGamePad(ExtendedPlayerIndex.Five).GetState().ThumbSticks.Right.Y;

            if (lx != 0)
                Console.WriteLine("left x = " + lx);
            if (ly != 0)
                Console.WriteLine("left y = " + ly);
            if (rx != 0)
                Console.WriteLine("right x = " + rx);
            if (ry != 0)
                Console.WriteLine("right y = " + ry);

            base.Update(gameTime);
        }

        protected override void Draw(GameTime gameTime)
        {
            ...
        }
    }
}
I am using Genius Maxfire Grandias 12 gamepad with "MODE" button. If mode is off, both thumbsticks give -1, 0 or 1 and right thumbstick mirrors 1-4 buttons. If mode is on, left thumbstick gives float values between -1 and 1, but right thumbstick values are always 0.

Example of output, left thumbstick works well, no entries for right thumbstick:
left y = -0,3492126
left x = -0,1953185
left y = -0,3492126
left x = -0,3515732
left y = -0,555542
left x = -0,6015809
left y = -0,7063293
left x = -0,6015809
left y = -0,7063293
left x = -0,65627
left y = -0,7301636
left x = -0,65627
left y = -0,7301636
left x = -0,6953337
Please help.
Thanks in advance.