Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gamepads are not detected on deployed game projects #1848

Open
vchelaru opened this issue Sep 11, 2024 · 5 comments
Open

Gamepads are not detected on deployed game projects #1848

vchelaru opened this issue Sep 11, 2024 · 5 comments

Comments

@vchelaru
Copy link

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
@vchelaru
Copy link
Author

Update - I have tested Slayer Knight ( https://andrewandrepowell.itch.io/slayer-knight-playground ) and I have the same problems - gamepad is not detected in chrome or firefox, but works fine in Edge.

@vchelaru
Copy link
Author

vchelaru commented Sep 11, 2024

This may be related to plugins on Chrome. I uninstalled most of my plugins and I was able to get a connected gamepad - at least, I was getting something I didn't get before - an exception. I think that the exception is an unrelated issue, but it is preventing me from testing with this Xbox360 gamepad that I have. For reference, the issue is:

#1850

I was able to get this exception to happen by uninstalling plugins/disabling plugins. This is what I have enabled (notice most are disabled):

image

Another user was able to get gamepads working, these are the plugins they had enabled:

image

@mfigueirido
Copy link

In Firefox after pressing a button, calling navigator.getGamepads() actually returns an array with the gamepad in it...
imaxe

Why the pooling code does not detect it?

@vchelaru
Copy link
Author

I can no longer reproduce the issue in chrome; however, I can reproduce the issue that @mfigueirido posted above in Firefox. I believe the two issues that I had (chrome and Firefox) might be unrelated. I can also see the gamepad array using the same code:

image

@nkast
Copy link

nkast commented Sep 14, 2024

I've tested it with two xbox360 controllers. Both worked on Chrome without making any changes.
On firefox unfortunately the controllers are not detected, not even locally.

For the issue in firefox, does it fire the gamepadConnected event? it's in window.js, place a break point there and connect/disconnect the controller and press a couple of buttons.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants