GamePad input in winform not connecting.

I am not able to get an xbox one controller to connect while running in winforms. All am not trying to create a game so I dont need the graphics just the input of the controller. Below is the winform application form1 that is not able to connect:

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

namespace XNAInWinformDelete
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
timer1.Start();
}

    private void timer1_Tick(object sender, EventArgs e)
    {
        Vector2 bSDL = GamePad.GetState(PlayerIndex.One).ThumbSticks.Left;
        xyValLbl.Text = bSDL.X.ToString() + ":" + bSDL.Y.ToString();
        xyValLbl.BackColor = GamePad.GetState(PlayerIndex.One).IsConnected ? System.Drawing.Color.Transparent : System.Drawing.Color.Salmon;
    }
}

}
`

The code above compiles however it is not able to connect like the monogame version as implemented below.

I have been able to effectively communicate with an xbox one controller using the following code (in a monoGame using “Windows Desktop application”):

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

namespace Png
{
public class Game1 : Game
{
private GraphicsDeviceManager _graphics;
private SpriteBatch _spriteBatch;

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

    protected override void Initialize()
    {
        // TODO: Add your initialization logic here

        base.Initialize();
    }

    protected override void LoadContent()
    {
        _spriteBatch = new SpriteBatch(GraphicsDevice);

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

    protected override void Update(GameTime gameTime)
    {
        if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            Exit();

        // TODO: Add your update logic here

        ButtonState bS = GamePad.GetState(PlayerIndex.One).Buttons.A;

        int here = 123;
        if (bS == ButtonState.Pressed)
            here += 1;

        Vector2 bSDL = GamePad.GetState(PlayerIndex.One).ThumbSticks.Left;
        if(GamePad.GetState(PlayerIndex.One).IsConnected)
            Console.Write(bSDL.X.ToString());

        base.Update(gameTime);
    }

    protected override void Draw(GameTime gameTime)
    {
        GraphicsDevice.Clear(Color.CornflowerBlue);

        // TODO: Add your drawing code here

        base.Draw(gameTime);
    }
}

}
`

Maybe I am missing a reference or initialization procedure. Any direction would be greatly appreciated.

I am able to get the controller to connect via the slight modification of adding a Game object an calling game.Run().

With that said, I get two windows: the winform and the game window. I dont want to have a gaming UI, as I just need to get the application to connect to the controller. Additionally, I have to select the “x” option in the gaming UI before the winform application will show.

My ultimate question is still: how do I connect without showing the gaming UI?
Ideally, the solution would just include what is needed to connect and read the inputs without the overhead of the gaming engine.

Any direction in removing the need for the gaming UI would be greatly appreciated.

Feel free to checkout MonoGame.Forms. It’s a game class independent, single application solution for Windows Forms.

Thank you, I will look into this!