Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4009856
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T08:55:44+00:00 2026-05-20T08:55:44+00:00

The vertical menus in my game allow you to press up or down on

  • 0

The vertical menus in my game allow you to press up or down on the thumbstick to jump to the next (or previous) menu item. I implement this by storing the old thumbstick state. If the state was zero and is now non-zero, the next (or previous) menu item is selected.

I have never noticed any “flicking” with this implementation either on Xbox controller attached to a PC or an Xbox. I have tested with several controllers.

However when I answered the question question XNA – how to tell if a thumb stick was “twitched” in a certain direction, Andrew Russell commented:

While this is the right idea, the
threshold needs to be above zero (for
use in menus), and there needs to be a
margin between activation and
deactivation to prevent it flicking.

My understanding is that Xna already provides filtering and a “dead-zone” on the thumb-stick input and that no threshold or margin is necessary to prevent flicking. Andrew’s statement worried me.

Are there controllers out there that do need a threshold or margin to prevent “flicking”?

Should I code in a threshold and margin just to be safe?

The following code is a minimal implementation of my method of input polling for XNA menus. The only difference is that my actual menus autoscroll after the control’s value has been non-zero in the same direction for a short while. The logic related to this question is in the ProcessUserInput function.

The ball represents the active menu item. Press the left thumbstick up or down to jump the ball to the next/previous menu item. I can’t get it to “flicker”.

using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

namespace WindowsGame
{
    public class Ball
    {
        public float RADIUS = DIAMETER * 0.5f;
        const int DIAMETER = 40;
        static readonly uint WHITE = Color.White.PackedValue;
        static readonly uint BLACK = new Color(0, 0, 0, 0).PackedValue;

        Texture2D m_texture;

        public Ball(GraphicsDevice graphicsDevice)
        {
            m_texture = new Texture2D(graphicsDevice, DIAMETER, DIAMETER);

            uint[] data = new uint[DIAMETER * DIAMETER];

            for (int i = 0; i < DIAMETER; i++)
            {
                float iPosition = i - RADIUS;

                for (int j = 0; j < DIAMETER; j++)
                {
                    data[i * DIAMETER + j] = new Vector2(iPosition, j - RADIUS).Length() <= RADIUS ? WHITE : BLACK;
                }
            }

            m_texture.SetData<uint>(data);
        }

        public Vector2 Position { get; set; }

        private Rectangle DrawRectangle
        {
            get
            {
                return new Rectangle((int)Math.Round(Position.X - RADIUS), (int)Math.Round(Position.Y - RADIUS), DIAMETER, DIAMETER);
            }
        }

        public void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(m_texture, DrawRectangle, Color.White);
        }
    }

    public class Game1 : Microsoft.Xna.Framework.Game
    {
        GraphicsDeviceManager graphics;
        SpriteBatch spriteBatch;
        Matrix viewMatrix;
        Matrix inverseViewMatrix;
        Ball ball;
        GamePadState m_lastGamePadState;

        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
            IsMouseVisible = true;
        }

        protected override void Initialize()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
            ball = new Ball(GraphicsDevice);
            viewMatrix = Matrix.CreateTranslation(Window.ClientBounds.Width * 0.5f, Window.ClientBounds.Height * 0.5f, 0.0f);
            inverseViewMatrix = Matrix.Invert(viewMatrix);
            m_lastGamePadState = GamePad.GetState(PlayerIndex.One);
            base.Initialize();
        }

        private void ProcessUserInput()
        {
            GamePadState gamePadState = GamePad.GetState(PlayerIndex.One);

            if (m_lastGamePadState.ThumbSticks.Left.Y == 0.0f)
            {
                ball.Position += Vector2.UnitY * (-Math.Sign(gamePadState.ThumbSticks.Left.Y) * ball.RADIUS * 2.0f);
            }

            m_lastGamePadState = gamePadState;
        }

        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                this.Exit();
            ProcessUserInput();
            base.Update(gameTime);
        }

        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);
            spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, viewMatrix);
            ball.Draw(spriteBatch);
            spriteBatch.End();
            base.Draw(gameTime);
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T08:55:44+00:00Added an answer on May 20, 2026 at 8:55 am

    It’s basically about getting the controls to feel “nice”.

    Setting a threshold above zero is required (because the sticks are never exactly on zero). The dead-zone counts as a threshold, but it’s very small. I think the default XNA dead-zone is about 0.24. This is way too small to use in a menu.

    I suspect – but I am not in a position to test this right now – that XNA’s interpret-the-thumbsticks-as-buttons code uses the same, tiny, unsatisfying dead zone as its activation threshold.

    As you can see from my answer you linked, I set an activation threshold at 0.85, which is considerably higher. Admittedly, my code is not for a menu. The tuning for a menu might be a bit smaller, but still not as small as the default dead-zone.

    As for the margin (eg: activate at 0.85, deactivate at 0.75). This is particularly required to get a satisfying feel when you’re specifically responding to an “off-on-off” transition. It is not really necessary when you’re simply detecting the “on” state.

    It also prevents the situation where you’re interpreting stick movement as button presses (as you might for a menu) and may, on rare occasion, receive a spurious double-press.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created two menus, a horizontal drop-down and a vertical menu, these both
I have a vertical menu having an item Click here to get the scientific
I wanted to show a vertical drop-down menu on click on a div. Suppose
I was asked to implement a menu bar that is neither horizontal nor vertical.
How to use vertical menus and I have tried the vertical menu bar.Iam not
I have this script for my CSS Vertical Menu: //Nested Side Bar Menu (Mar
I have this kind of vertical menu :- Europe France Paris Germany Berlin Asia
I've made a vertical menu using css. It's a menu with sub menus similar
I'm trying to create a vertical menu and I need to make a multicolumn
I am trying to created a vertical menu (on the left side of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.