HaxeFlixel / flixel

Free, cross-platform 2D game engine powered by Haxe and OpenFL
https://haxeflixel.com/
MIT License
1.97k stars 436 forks source link

Gamepad detection in HTML5 #2257

Open thefurfel opened 4 years ago

thefurfel commented 4 years ago

Code snippet reproducing the issue:

package;

import flixel.FlxState;
import flixel.FlxG;

class PlayState extends FlxState
{
    override public function create():Void
    {
        trace(FlxG.gamepads.numActiveGamepads); // Always returns 0
    }
}

Observed behavior: No gamepads are detected in a browser. However, in pure JS it works.

Expected behavior: Gamepads should be detected and the event should be dispatched from JS because the browser registers the gamepad after pressing a button in "ongamepadconnected" window event. This could be also a problem between JS and OpenFL but might also be between OpenFL and Flixel.

RichardBray commented 4 years ago

Hmm, have you looked at the demo here: https://haxeflixel.com/demos/GamepadTest/

Personally, it works fine on my Mac with a PS4 controller and a Wired Xbox 360 one, but it would be good to know what the demo says for you.

Geokureli commented 4 years ago

In Html5 you have to interact with the gamepad after the game starts for flixel to know it exists, where, in other targets, controllers will be active if you connected them and pressed a button before the program started

pfoof commented 4 years ago

Apparently, it's not a Flixel issue - it's Lime.

Geokureli commented 4 years ago

I see you made a lime issue, linking it here

https://github.com/haxelime/lime/issues/1431