Skip to content

Gamepads are not detected on deployed game projects #1848

@vchelaru

Description

@vchelaru

Gamepads are detected properly when creating a local game project (both debug and release), but they are not detected when the project is deployed.

I have created a simple project that reproduces the problem:

XboxGamepadTest.zip

For convenience, the only difference between this project and a brand new BlazorGL project is the code to read the gamepad and output it to the console. Here's the entire Game class:

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

namespace XboxGamepadTest;
public class XboxGamepadTestGame : Game
{
    GraphicsDeviceManager graphics;
    public XboxGamepadTestGame()
    {
        graphics = new GraphicsDeviceManager(this);
    }

    DateTime lastCheck;
    protected override void Update(GameTime gameTime)
    {
        GamePadState gamePadState = GamePad.GetState(PlayerIndex.One); 

        if (DateTime.Now - lastCheck > TimeSpan.FromSeconds(1))
        {
            System.Console.WriteLine($"Is Connected:{gamePadState.IsConnected} Is A Down:{gamePadState.IsButtonDown(Buttons.A)}");
            lastCheck = DateTime.Now;
        }
        base.Update(gameTime);
    }

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

If I run this locally, I can view the console in the browser to see that the gamepad does get connected once I press the A button (it does not connect until input is registered).

image

I have uploaded the project here:

https://files.flatredball.com/WebProjects/GamepadTest/wwwroot/

Unfortunately if I run this, the gamepad is never connected, nor is input detected even if I press buttons on the gamepad.

image

This problem reproduces on both Chrome and Firefox, but mysteriously enough it works fine in Edge.

image

What could I be doing wrong on Firefox and Chrome?

What version of KNI does the bug occur on:

  • KNI 3.13.9001.1

What operating system are you using:

  • Windows11

What KNI platform are you using:

  • BlazorGL

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions